/*
 * The home page (inc/Home.php, front-page.php) and the styleguide: what only these pages show, so no other page loads it.
 *
 *   .pg-home-hero     the hero as on the old home page (Jaroslav 6. 11. and 7. 11.): the panel Kategórie (.pg-cat-panel,
 *                     about a quarter) beside the carousel (.pg-hero-slides, about three quarters), under them Do eshopu
 *   .pg-hero--slide   a slide (Template::hero(), size slide): the photo over the whole slide, the text at the bottom on a
 *                     dark band, the small card of a product beside it (.pg-hero__aside)
 *   .pg-home-top      Najpredávanejšie tento mesiac: the grid of products on a light grey band, two whole rows; on a
 *                     phone the rest by 4 with Zobraziť viac (.pg-more-btn, more.js)
 *   .pg-home-product  Odporúčaný produkt: the upper part of the product page (product.css)
 *   .pg-home-note     a note for administrators (the dashed note of the footer and of a legal document)
 */

/* ---------- Hero ----------
 * From 1025 px two columns, 1 : 3 with the gap of the cards, the panel as tall as the slides. Up to 1024 px the slides
 * alone over the content (the categories are in the menu E-Shop of the header). The button under them in the middle. */
.pg-home-hero { row-gap: var(--pg-gap-grid); }

.pg-home-hero__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
	gap: var(--pg-gap-grid);
}

.pg-home-hero__grid:not(:has(> .pg-cat-panel)) { grid-template-columns: minmax(0, 1fr); }

.pg-home-hero__shop {
	display: flex;
	justify-content: center;
	margin: 0;
}

@media (max-width: 1024px) {
	.pg-home-hero__grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Panel Kategórie (.pg-cat-panel, Home::panel(), home.js) ----------
 * A white panel with the line of the site, the title, then the list of the categories, each with its icon (24 px, as in
 * the menu of the header) and a line under it. The panel is as tall as the slides (it takes no height of its own: 0 and
 * at least the whole row), the list scrolls inside it with the thin bar of the rail of products. The button of a category
 * opens its subcategories, the list grows smoothly (0fr to 1fr, the duration of the filters); hidden subcategories take
 * no focus (visibility). The buttons keep their room from the start and show, and the lists close, only once home.js
 * has prepared the panel (is-ready, right after the panel while the page is parsed): without JavaScript, or when the
 * script fails, every list is open and the buttons stay invisible (skeptik 7, web 10 and 11). */
.pg-cat-panel {
	--pg-rail-thumb: var(--pg-accent-text);
	--pg-rail-bar: var(--pg-line);
	--pg-rail-bar-h: var(--pg-space-4);
	display: flex;
	flex-direction: column;
	height: 0;
	min-height: 100%;
	border: 1px solid var(--pg-line);
	background: var(--pg-white);
}

@media (max-width: 1024px) {
	.pg-cat-panel { display: none; }
}

.pg-cat-panel__title { padding: var(--pg-gap-block) var(--pg-gap-block) var(--pg-gap-el); }

.pg-cat-panel .pg-cat-panel__list {
	flex: 1 1 auto;
	min-height: 0;
	margin: 0;
	padding: 0 var(--pg-gap-block) var(--pg-gap-el);
	list-style: none;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.pg-cat-panel__list::-webkit-scrollbar { width: var(--pg-rail-bar-h); }
.pg-cat-panel__list::-webkit-scrollbar-track { background: var(--pg-rail-bar); }
.pg-cat-panel__list::-webkit-scrollbar-thumb { background: var(--pg-rail-thumb); border-radius: var(--pg-radius-pill); }

@supports not selector(::-webkit-scrollbar) {
	.pg-cat-panel__list {
		scrollbar-width: thin;
		scrollbar-color: var(--pg-rail-thumb) var(--pg-rail-bar);
	}
}

.pg-cat-panel__item + .pg-cat-panel__item { border-block-start: 1px solid var(--pg-line); }

.pg-cat-panel__row {
	display: flex;
	align-items: center;
	gap: var(--pg-gap-el);
}

.pg-cat-panel__link {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	gap: var(--pg-space-12);
	min-width: 0;
	min-height: var(--pg-control-h);
	padding-block: var(--pg-space-8);
	color: var(--pg-text);
	text-decoration: none;
	transition: color var(--pg-dur-fast) var(--pg-ease);
}

.pg-cat-panel__link:hover,
.pg-cat-panel__sublink:hover { color: var(--pg-accent-text-hover); }

.pg-cat-panel__icon {
	flex: none;
	width: var(--pg-space-24);
	height: var(--pg-space-24);
	object-fit: contain;
}

.pg-cat-panel__toggle {
	display: grid;
	flex: none;
	place-items: center;
	width: var(--pg-control-h-s);
	height: var(--pg-control-h-s);
	padding: 0;
	border: 0;
	border-radius: var(--pg-radius);
	background: transparent;
	color: var(--pg-text);
	cursor: pointer;
	transition: background-color var(--pg-dur-fast) var(--pg-ease);
}

.pg-cat-panel:not(.is-ready) .pg-cat-panel__toggle { visibility: hidden; }

.pg-cat-panel__toggle:hover { background: var(--pg-surface-hover); }
.pg-cat-panel__toggle .pg-svg { width: var(--pg-space-20); height: var(--pg-space-20); transition: transform var(--pg-dur) var(--pg-ease); }
.pg-cat-panel__item.is-open .pg-cat-panel__toggle .pg-svg { transform: rotate(180deg); }

.pg-cat-panel__sub {
	display: grid;
	grid-template-rows: 1fr;
}

.pg-cat-panel.is-ready .pg-cat-panel__sub {
	grid-template-rows: 0fr;
	visibility: hidden;
}

/* The length and curve of everything that unrolls on the site (zadanie 10, bod 7). */
.pg-cat-panel.is-animated .pg-cat-panel__sub { transition: grid-template-rows var(--pg-dur-expand) var(--pg-ease-expand), visibility 0s linear var(--pg-dur-expand); }

.pg-cat-panel.is-ready .pg-cat-panel__item.is-open > .pg-cat-panel__sub {
	grid-template-rows: 1fr;
	visibility: visible;
	transition-delay: 0s;
}

.pg-cat-panel .pg-cat-panel__sublist {
	min-height: 0;
	margin: 0;
	padding: 0 0 0 calc(var(--pg-space-24) + var(--pg-space-12));
	overflow: hidden;
	list-style: none;
}

/* The room under the last subcategory inside the list: a padding of the list itself would stay open when it is closed. */
.pg-cat-panel__sublist > :last-child { padding-block-end: var(--pg-space-8); }

.pg-cat-panel__sublink {
	display: block;
	padding-block: var(--pg-space-4);
	color: var(--pg-text-2);
	font-size: var(--pg-text-s);
	text-decoration: none;
	transition: color var(--pg-dur-fast) var(--pg-ease);
}

/* ---------- Carousel (.pg-hero-slides, rail.js) ----------
 * The slides side by side in a row that snaps to one (a finger swipes it), the row as tall as the tallest slide. Over
 * it Predchádzajúci and Ďalší slajd in the middle of its height, the button of the automatic change in the top right
 * corner: quiet controls (zadanie 11, pripomienka 2, Jaroslav: too many buttons in the hero), no fill and no line, the
 * icon white at 20 % (--pg-hero-ctrl); under the pointer and with the focus of the keyboard the icon white and a fill of
 * white at 10 % (--pg-hero-ctrl-bg), both fading over --pg-dur (0 s with reduced motion); a ring of white and black for
 * the focus. The row
 * is endless (rail.js, loop.js; Jaroslav 10. 11.): after the last slide the first follows right away; only without
 * loop.js the row fades out and comes back at the first (is-wrapping). The scroll bar of the system is hidden
 * (the arrows and the finger move the row); without JavaScript the thin bar of the rail of products. */
.pg-hero-slides {
	position: relative;
	min-width: 0;
	/* The dark green behind the row (seen while the row fades out without loop.js), not under its outer pixel on each
	   side: there the gap between two slides can show (below) and must show the page, not a dark line. */
	background: linear-gradient(var(--pg-green-dark), var(--pg-green-dark)) center / calc(100% - 2px) 100% no-repeat;
}

.pg-hero-slides .pg-rail__track {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 100%;
	/* A slide is rarely a whole number of pixels wide (the gutter is 3vw) and the browser scrolls the row to a whole
	   one: without the gap the next slide showed as a line of 1 px along the right edge (at 1440 px, kontrola zadania 11).
	   What can show now is a part of the gap, with the page behind it (the background above leaves that pixel out). */
	column-gap: 1px;
	height: 100%;
	margin: 0;
	padding: 0;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	transition: opacity var(--pg-dur-slow) var(--pg-ease);
}

.pg-hero-slides .pg-rail__track::-webkit-scrollbar { display: none; }
.pg-hero-slides.is-wrapping .pg-rail__track { opacity: 0; }

@media (scripting: none) {
	.pg-hero-slides .pg-rail__track {
		scrollbar-width: thin;
		scrollbar-color: var(--pg-accent-text) var(--pg-line);
	}
	.pg-hero-slides .pg-rail__track::-webkit-scrollbar { display: block; height: var(--pg-space-4); }
	.pg-hero-slides .pg-rail__track::-webkit-scrollbar-track { background: var(--pg-line); }
	.pg-hero-slides .pg-rail__track::-webkit-scrollbar-thumb { background: var(--pg-accent-text); }
}

.pg-hero-slides > .pg-btn {
	--pg-btn-bg: transparent;
	--pg-btn-fg: var(--pg-hero-ctrl);
	--pg-btn-line: transparent;
	position: absolute;
	z-index: var(--pg-z-raised-2);
	transition: background-color var(--pg-dur) var(--pg-ease), color var(--pg-dur) var(--pg-ease), transform var(--pg-dur-fast) var(--pg-ease);
}

/* Lit: under the pointer of a mouse, with the focus of the keyboard and while pressed. The pointer only where there is
   one (hover: hover, pointer: fine, as the cards of products): a tap on a phone leaves :hover on the button until the
   next tap elsewhere, the arrow just used would stay white beside the two quiet ones. A finger lights the button only
   while it presses it (:active). */
.pg-hero-slides > .pg-btn:not([aria-disabled="true"]):active,
.pg-hero-slides > .pg-btn:focus-visible {
	--pg-btn-bg: var(--pg-hero-ctrl-bg);
	--pg-btn-fg: var(--pg-white);
	--pg-btn-line: transparent;
}

@media (hover: hover) and (pointer: fine) {
	.pg-hero-slides > .pg-btn:not([aria-disabled="true"]):hover {
		--pg-btn-bg: var(--pg-hero-ctrl-bg);
		--pg-btn-fg: var(--pg-white);
		--pg-btn-line: transparent;
	}
}

.pg-hero-slides > .pg-rail__btn {
	inset-block-start: 50%;
	translate: 0 -50%;
}

.pg-hero-slides > [data-pg-rail-prev] { inset-inline-start: var(--pg-gap-el); }
.pg-hero-slides > [data-pg-rail-next] { inset-inline-end: var(--pg-gap-el); }

.pg-hero-slides__play {
	inset-block-start: var(--pg-gap-el);
	inset-inline-end: var(--pg-gap-el);
}

/* A phone: the arrows beside the button of the automatic change in the top right corner, over the photo, where the text
   of the slide never is (it starts under the transparent top of its band); in the middle they would cover the text. */
@media (max-width: 767px) {
	.pg-hero-slides > .pg-rail__btn {
		inset-block-start: var(--pg-gap-el);
		translate: none;
	}
	.pg-hero-slides > [data-pg-rail-prev] { inset-inline-start: auto; inset-inline-end: calc(var(--pg-gap-el) + 2 * (var(--pg-control-h-s) + var(--pg-space-8))); }
	.pg-hero-slides > [data-pg-rail-next] { inset-inline-end: calc(var(--pg-gap-el) + var(--pg-control-h-s) + var(--pg-space-8)); }
	.pg-hero-slides:not(:has(> .pg-hero-slides__play)) > [data-pg-rail-prev] { inset-inline-end: calc(var(--pg-gap-el) + var(--pg-control-h-s) + var(--pg-space-8)); }
	.pg-hero-slides:not(:has(> .pg-hero-slides__play)) > [data-pg-rail-next] { inset-inline-end: var(--pg-gap-el); }
}

.pg-hero-slides__play .pg-hero-slides__start,
.pg-hero-slides__play.is-stopped .pg-hero-slides__pause { display: none; }
.pg-hero-slides__play.is-stopped .pg-hero-slides__start { display: block; }

.pg-hero-slides > .pg-btn:focus-visible {
	outline-color: var(--pg-white);
	box-shadow: 0 0 0 calc(3 * var(--pg-space-2)) var(--pg-text); /* black from the button to 6 px, the white outline 2 to 4 px over it */
}

/* An inactive arrow over the slide (only without loop.js, the row is endless) keeps the click (an inactive button of the
   site lets it through to the slide, where it would reach nothing), without the fill of the pointer, and is fainter than
   an active one at rest (the opacity of an inactive button of the site, base.css), so the two can be told apart.
   Over a rail of products the click goes through to the card (layout.css). */
.pg-hero-slides > .pg-rail__btn[aria-disabled="true"] {
	pointer-events: auto;
	cursor: default;
}

/* ---------- Slide (.pg-hero--slide, Template::hero()) ----------
 * The photo behind the whole slide (no flat scrim over it, as on the old home page), the title, the text and the buttons
 * at the bottom on the left, on a band from transparent to --pg-scrim where the text starts (white 4.7:1 also over a
 * white photo) and --pg-scrim-strong at the bottom, the band of the large card of the blog. The small card of a product
 * on the right of the band (not on a phone: the slide is too small for it). Without a photo the dark green slide. */
.pg-hero--slide {
	--pg-hero-slide-pad: calc(var(--pg-control-h-s) + 2 * var(--pg-gap-el)); /* the text clear of the arrows on its sides */
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-content: end;
	min-block-size: var(--pg-hero-home);
	height: 100%;
	overflow: hidden;
	background: var(--pg-green-dark);
	color: var(--pg-white);
	text-align: start;
}

.pg-hero--slide.has-image::after { content: none; }

.pg-hero--slide > .pg-hero__inner {
	grid-row: 1;
	grid-column: 1 / -1;
	justify-self: stretch;
	align-items: flex-start;
	max-width: none;
	padding: var(--pg-space-64) var(--pg-hero-slide-pad) var(--pg-gap-head);
	background: linear-gradient(to bottom, transparent, var(--pg-scrim) var(--pg-space-64), var(--pg-scrim-strong));
}

.pg-hero--slide .pg-hero__actions { justify-content: flex-start; }

.pg-hero--slide.has-aside > .pg-hero__inner { padding-inline-end: calc(var(--pg-hero-card-w) + var(--pg-gap-head) + var(--pg-hero-slide-pad)); }

.pg-hero--slide > .pg-hero__aside {
	position: relative;
	z-index: var(--pg-z-raised);
	grid-row: 1;
	grid-column: 2;
	align-self: end;
	width: var(--pg-hero-card-w);
	margin: var(--pg-gap-head) var(--pg-hero-slide-pad);
}

.pg-hero__card { padding: var(--pg-space-12); }

/* A phone (Jaroslav, skeptik 7, web 15): the title and the first button only, the text and the second button stay for
   the larger screens, so the dark band covers the bottom of the slide only and the photo stays in view; the band reaches
   --pg-scrim where the title starts (32 px under its top, white 4.7:1 also over a white photo). */
@media (max-width: 767px) {
	.pg-hero--slide { --pg-hero-slide-pad: var(--pg-gap-head); }
	.pg-hero--slide > .pg-hero__aside { display: none; }
	.pg-hero--slide.has-aside > .pg-hero__inner { padding-inline-end: var(--pg-hero-slide-pad); }
	.pg-hero--slide > .pg-hero__inner {
		padding-block-start: var(--pg-space-32);
		background: linear-gradient(to bottom, transparent, var(--pg-scrim) var(--pg-space-32), var(--pg-scrim-strong));
	}
	.pg-hero--slide .pg-hero__lead,
	.pg-hero--slide .pg-hero__actions > :nth-child(n + 2) { display: none; }
}

/* ---------- Najpredávanejšie tento mesiac (.pg-home-top) ----------
 * The grid of products (.pg-grid--5: 5, 4 up to 1279 px, 3 up to 1024 px, 2 on a phone) on the light grey band of the
 * site (.pg-section--light, --pg-surface-light #F8F8F8, over the whole screen), the cards white with their line as in
 * the catalogue. Two whole rows: the block loads 10 cards and hides the ones of a third row (8, 6, 4), as Podobné produkty
 * hide a row that is not whole; fewer products are fewer cards. */
.pg-home-top .pg-grid > :nth-child(n + 11) { display: none; }

@media (min-width: 768px) and (max-width: 1279px) {
	.pg-home-top .pg-grid > :nth-child(n + 9) { display: none; }
}

@media (min-width: 768px) and (max-width: 1024px) {
	.pg-home-top .pg-grid > :nth-child(n + 7) { display: none; }
}

/* A phone (zadanie 11, pripomienka 5): two rows of two, the rest of the 10 cards unrolls by 4 with the quiet text button
   under the list (Zobraziť viac, then Zobraziť menej; more.js marks the cards it has shown with is-shown). The button is
   there from the start, on a phone only, so nothing moves when the script runs; without JavaScript every card is shown
   and the button is not. */
.pg-home-top__more { display: none; }

@media (max-width: 767px) {
	.pg-home-top .pg-grid > :nth-child(n + 5):not(.is-shown) { display: none; }

	.pg-home-top__more {
		display: flex;
		justify-content: center;
		margin: 0;
	}
}

@media (max-width: 767px) and (scripting: none) {
	.pg-home-top .pg-grid > :nth-child(n + 5):not(.is-shown) { display: flex; }
	.pg-home-top__more { display: none; }
}

/* The cards Zobraziť viac has added fade in where they stand (nothing moves, so not with reduced motion). */
@media (prefers-reduced-motion: no-preference) {
	.pg-home-top .pg-grid > .is-shown { animation: pg-home-top-in var(--pg-dur) var(--pg-ease); }
}

@keyframes pg-home-top-in {
	from { opacity: 0; }
}

.pg-more-btn {
	min-height: var(--pg-control-h-s);
	padding: 0 var(--pg-space-8);
	border: 0;
	background: none;
	color: var(--pg-text-2);
	font: inherit;
	font-size: var(--pg-text-s);
	text-decoration: underline;
	text-decoration-color: var(--pg-line-control);
	text-underline-offset: .2em;
	cursor: pointer;
	transition: color var(--pg-dur-fast) var(--pg-ease), text-decoration-color var(--pg-dur-fast) var(--pg-ease);
}

.pg-more-btn:hover { color: var(--pg-text); text-decoration-color: currentColor; }

/* ---------- Note for administrators (.pg-home-note) ---------- */
.pg-home-note {
	padding: var(--pg-space-12) var(--pg-space-16);
	border: 1px dashed currentColor;
	font-size: var(--pg-text-s);
}
