/* Abakon Ceník — tabulka na webu.
 *
 * Dvě nezávislé části:
 *
 *   .abakon-cenik-responsive  obal kolem holé tabulky. Na počítači nedělá nic,
 *                             na telefonu tabulku přeskládá do řádků.
 *   .abakon-cenik-table       vlastní vzhled pluginu, jen pro style="plugin".
 *
 * Na širokém displeji se tabulka nesmí změnit ani o pixel — má vypadat přesně
 * tak, jak si ji nastyluje šablona webu. Všechna pravidla, která něco přesouvají,
 * proto leží uvnitř @media.
 */

/* --------------------------------------------------------------------------
 * Responzivní obal (výchozí režim)
 * ----------------------------------------------------------------------- */

.abakon-cenik-responsive {
	/* projeví se, teprve když se tabulka nevejde */
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

@media screen and (max-width: 782px) {

	/*
	 * Karty místo tabulky - ale bez vlastního pozadí.
	 *
	 * Návrh počítal s šedým panelem za kartami a bílými kartami na něm. Na webu
	 * to ale tluče do vlastního pozadí sekce, takže se sem žádná výplň nekreslí.
	 * Karty drží pohromadě jen rámečkem a text si bere barvy ze šablony -
	 * proto rgba() a opacity místo napevno zadaných odstínů: fungují na světlém
	 * i tmavém podkladu, ať už si web nastaví cokoliv.
	 */
	.abakon-cenik-responsive {
		--ab-border: rgba(0, 0, 0, .14);
		--ab-accent: #2a75ba;

		display: block;
		overflow-x: visible;
	}

	/* Nulování toho, co tabulce vnucuje šablona webu. */
	.abakon-cenik-responsive table,
	.abakon-cenik-responsive tbody,
	.abakon-cenik-responsive tr,
	.abakon-cenik-responsive th,
	.abakon-cenik-responsive td {
		background: none !important;
		background-color: transparent !important;
		border: 0 !important;
		padding: 0 !important;
		margin: 0 !important;
		box-shadow: none !important;
		border-radius: 0 !important;
		text-align: left !important;
		width: auto !important;
		font-size: inherit !important;
		line-height: normal !important;
	}

	.abakon-cenik-responsive table,
	.abakon-cenik-responsive tbody {
		display: block !important;
	}

	/* záhlaví zmizí z očí, čtečky ho mají dál slyšet */
	.abakon-cenik-responsive thead {
		position: absolute !important;
		width: 1px !important;
		height: 1px !important;
		overflow: hidden !important;
		clip: rect(0 0 0 0) !important;
		clip-path: inset(50%) !important;
		white-space: nowrap !important;
	}

	/* jeden dům = jedna karta, ohraničená rámečkem */
	.abakon-cenik-responsive tr {
		display: grid !important;
		grid-template-columns: 1fr 1fr;
		grid-template-areas:
			"name  price"
			"meta  price"
			"link1 link2";
		column-gap: 12px;
		row-gap: 8px;
		border: 1px solid var(--ab-border) !important;
		border-radius: 12px !important;
		padding: 14px !important;
		margin-bottom: 10px !important;
	}

	/* název domu */
	.abakon-cenik-responsive td:nth-child(1) {
		grid-area: name;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 5px;
		font-weight: 600;
		font-size: 16px !important;
		line-height: 1.3 !important;
	}

	.abakon-cenik-responsive td:nth-child(1) a {
		color: inherit;
		text-decoration: none;
		white-space: normal !important;
	}

	.abakon-cenik-responsive td:nth-child(1) a::after {
		content: "\203A";
		margin-left: 5px;
		opacity: .45;
		font-weight: 400;
	}

	/* štítek si červenou drží - je to značka, ne podbarvení tabulky */
	.abakon-cenik-responsive td:nth-child(1) .abakon-badge {
		background: #e63946 !important;
		color: #fff !important;
		font-size: 11px !important;
		font-weight: 700 !important;
		text-transform: uppercase;
		letter-spacing: 0.03em;
		padding: 3px 7px !important;
		border-radius: 4px !important;
		margin-left: 0 !important;
		white-space: nowrap;
	}

	/* podlahová plocha */
	.abakon-cenik-responsive td:nth-child(2) {
		grid-area: meta;
		align-self: start;
		opacity: .65;
		font-size: 13px !important;
	}

	/* cena */
	.abakon-cenik-responsive td:nth-child(3) {
		grid-area: price;
		display: flex;
		flex-direction: column;
		align-items: flex-end;
		justify-content: center;
		text-align: right !important;
	}

	.abakon-cenik-responsive td:nth-child(3) strong {
		font-size: 18px;
		font-weight: 700;
		white-space: nowrap;
	}

	.abakon-cenik-responsive td:nth-child(3) .abakon-unit {
		display: block;
		opacity: .6;
		font-size: 12px;
		font-weight: 400;
		margin-top: 2px;
	}

	/* odkazy na PDF jako tlačítka - jen obrys, žádná výplň */
	.abakon-cenik-responsive td:nth-child(4) {
		grid-area: link1;
	}

	.abakon-cenik-responsive td:nth-child(5) {
		grid-area: link2;
	}

	.abakon-cenik-responsive td:nth-child(4) a,
	.abakon-cenik-responsive td:nth-child(5) a {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 6px;
		min-height: 44px;
		border: 1px solid var(--ab-border);
		border-radius: 8px;
		color: inherit;
		text-decoration: none;
		font-size: 14px;
		font-weight: 600;
	}

	.abakon-cenik-responsive td:nth-child(4) a::after,
	.abakon-cenik-responsive td:nth-child(5) a::after {
		content: "PDF";
		font-size: 10px;
		font-weight: 600;
		opacity: .6;
		border: 1px solid var(--ab-border);
		border-radius: 3px;
		padding: 1px 4px;
	}

	/*
	 * Zvýraznění jen tam, kde se najíždí myší, a jen rámečkem. Na dotyku se
	 * :hover po klepnutí zasekne a tlačítko by zůstalo zvýrazněné.
	 */
	@media (hover: hover) {

		.abakon-cenik-responsive td:nth-child(4) a:hover,
		.abakon-cenik-responsive td:nth-child(5) a:hover {
			border-color: var(--ab-accent);
			color: var(--ab-accent);
		}
	}

	/*
	 * Dům bez ceny.
	 *
	 * "Cena na dotaz" je v tabulce ve sloupci s ceníkem, ne u ceny - tak to má
	 * i tabulka na počítači a měnit se to nedá. Na kartě se proto přesune tam,
	 * kde by cena byla, a dole zůstane jen karta domu přes celou šířku.
	 *
	 * Prohlížeč bez :has() (starší Firefox) pravidla přeskočí a karta zůstane
	 * v základní podobě - text bude dole vlevo. Nerozbije se nic.
	 */
	.abakon-cenik-responsive tr:has(td:nth-child(3):empty) {
		grid-template-areas:
			"name  price"
			"meta  price"
			"link2 link2";
	}

	.abakon-cenik-responsive tr:has(td:nth-child(3):empty) td:nth-child(3) {
		display: none;
	}

	.abakon-cenik-responsive tr:has(td:nth-child(3):empty) td:nth-child(4) {
		grid-area: price;
		display: flex;
		flex-direction: column;
		align-items: flex-end;
		justify-content: center;
		text-align: right !important;
		font-weight: 700;
		font-size: 18px !important;
		opacity: .75;
	}
}

/* --------------------------------------------------------------------------
 * Vlastní vzhled pluginu — jen pro [abakon_cenik style="plugin"]
 * ----------------------------------------------------------------------- */

.abakon-cenik-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.abakon-cenik-table {
	width: 100%;
	border-collapse: collapse;
}

.abakon-cenik-table th,
.abakon-cenik-table td {
	padding: 12px 14px;
	text-align: left;
	border-bottom: 1px solid rgba(0, 0, 0, .08);
	vertical-align: middle;
}

.abakon-cenik-table th {
	font-weight: 700;
	white-space: nowrap;
}

.abakon-cenik-table .abakon-col-price,
.abakon-cenik-table .abakon-col-area {
	white-space: nowrap;
}

.abakon-cenik-table .abakon-ask {
	opacity: .7;
}

@media screen and (max-width: 782px) {

	.abakon-cenik-table thead {
		display: none;
	}

	.abakon-cenik-table tr {
		display: block;
		padding: 8px 0;
		border-bottom: 2px solid rgba(0, 0, 0, .12);
	}

	.abakon-cenik-table td {
		display: flex;
		justify-content: space-between;
		gap: 16px;
		border: 0;
		padding: 6px 0;
	}

	.abakon-cenik-table td::before {
		content: attr(data-label);
		font-weight: 600;
		opacity: .65;
		flex: 0 0 auto;
	}

	.abakon-cenik-table td:empty {
		display: none;
	}
}
