/**
 * PoppyOS — front page composer (v2.28).
 *
 * Deliberately not a new visual language: cards reuse the radius, shadow, hover lift,
 * uppercase display category, mono meta line and accent colours of the existing
 * `.pos-sponsored` / `.pos-card` tiles. Anything that looks new here (the calculator
 * strip, the search band) is built from the same tokens.
 *
 * Mobile-first. Main breakpoint 900px, with 600px kept for the two-column step so the
 * rhythm matches the rest of the theme.
 *
 * Loaded only on pages where the composer can actually render.
 */

/* ═══════════════════════════════════════════════════════════
   SECTION FRAME
   ═══════════════════════════════════════════════════════════ */

.pos-home {
	display: block;
	/*
	 * The screen-reader <h1> above makes this the *second* child of <main>, so the layout's
	 * block gap gave it a 24px top margin — pure dead space under the header. The composer
	 * spaces its own sections; it needs nothing from the outside.
	 */
	margin-block-start: 0 !important;
}

/*
 * Spacing is applied to every child, not to `.pos-home__section + .pos-home__section`:
 * the featured section renders as `.pos-sponsored` and ad slots sit between sections, so
 * an adjacent-sibling rule would silently drop the gap wherever either appears.
 */
.pos-home > * + * {
	margin-top: var(--wp--preset--spacing--70, 4rem);
}

/* A slot the ad network never filled collapses itself; it must not leave a gap behind. */
.pos-home > .pos-slot.is-empty {
	margin-top: 0;
}

.pos-home > .pos-slot.is-empty + * {
	margin-top: var(--wp--preset--spacing--70, 4rem);
}

.pos-home__head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.5rem 1rem;
	margin-bottom: 1.5rem;
}

.pos-home__title {
	font-family: var(--wp--preset--font-family--display);
	font-size: clamp(1.5rem, 1.25rem + 1vw, 2rem);
	font-weight: 700;
	line-height: 1.2;
	color: var(--poppyos-ink);
	margin: 0;
}

.pos-home__more-wrap {
	margin: 0;
}

.pos-home__more {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--poppyos-accent);
	text-decoration: none !important;
	/* WCAG 2.5.8 — the theme keeps small links tappable. */
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	min-height: 44px;
}

.pos-home__more:hover {
	color: var(--poppyos-accent-hover);
}

/* ═══════════════════════════════════════════════════════════
   CARDS — same tile as .pos-sponsored__card
   ═══════════════════════════════════════════════════════════ */

.pos-home__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1.25rem;
	align-items: stretch;
}

.pos-home__card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	background: var(--poppyos-bg);
	border-radius: var(--poppyos-radius-lg);
	overflow: hidden;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
	-webkit-tap-highlight-color: transparent;
	/* The stretched link owns every pointer event, so text cannot be selected anyway —
	   say so with the cursor instead of showing a text caret that does nothing. */
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
}

/* The whole tile is one link. The title anchor is stretched over the card instead of
   wrapping everything in an <a>, which would put a heading and a paragraph inside a link. */
.pos-home__card-title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

/*
 * Focus ring on the overlay, not on the anchor. The anchor is an inline box inside a
 * clipped heading, so the default outline was drawn around the text lines and then cut
 * off by overflow:hidden — a keyboard user could not see which card was focused. Negative
 * offset keeps the ring inside the card's own clipping box.
 */
.pos-home__card-title a:focus-visible {
	outline: none;
}

.pos-home__card-title a:focus-visible::after {
	outline: 3px solid var(--poppyos-accent-text, var(--poppyos-accent));
	outline-offset: -3px;
	border-radius: var(--poppyos-radius-lg);
}

@media (forced-colors: active) {
	.pos-home__card-title a:focus-visible::after {
		outline-color: Highlight;
	}
}

/* Touch devices get no hover; the native tap highlight is off, so give the press its own
   feedback — otherwise a slow connection looks like the tap did nothing. */
@media (hover: none) and (pointer: coarse) {
	.pos-home__card:active,
	.pos-calc__link:active {
		transform: scale(0.98);
		transition: transform 0.1s ease;
	}
}

.pos-home__card-media {
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var(--poppyos-surface);
}

/* wpautop may still wrap the image in a paragraph — it must not add height. */
.pos-home__card-media p {
	margin: 0;
	line-height: 0;
}

.pos-home__card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.pos-home__card-body {
	display: flex;
	flex-direction: column;
	flex: 1;
	padding: 0.5rem 1rem 0.75rem;
}

.pos-home__card-cat {
	display: block;
	font-family: var(--wp--preset--font-family--display);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--poppyos-accent);
	margin: 0;
}

.pos-home__card-title {
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1.3;
	margin: 0.5rem 0 0.25rem;
}

.pos-home__card-title a {
	color: var(--poppyos-ink);
	text-decoration: none !important;
}

/* Hover uses the darker accent, never the raw one: with a yellow brand colour a raw-accent
   title on white is ~2:1 and the headline effectively disappears under the cursor. */
.pos-home__card-title a:hover {
	color: var(--poppyos-accent-hover);
}

/*
 * The title is deliberately NOT clamped. Rows stay aligned anyway — the footer's
 * `margin-top: auto` does that — and clamping the title would cut headlines mid-sentence
 * for anyone using the A+ font switcher, i.e. exactly the readers this theme targets.
 */
.pos-home__card-title {
	overflow-wrap: break-word;
}

.pos-home__card-excerpt {
	font-size: 0.875rem;
	line-height: 1.6;
	color: var(--poppyos-muted);
	margin: 0 0 0.75rem;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	/* Belt and braces: some CSS minifiers drop -webkit-box-orient, which would leave a
	   horizontal box and clip the text to a single line. em keeps it in step with the
	   A-/A/A+ font switcher. */
	max-height: calc(1.6em * 3);
	overflow: hidden;
}

/* Footer: rule, date left, "czytaj więcej" right — identical to the archive tiles. */
.pos-home__card-footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.35rem 0.75rem;
	margin-top: auto;
	padding-top: 0.5rem;
	border-top: 1px solid var(--poppyos-border);
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.7rem;
	color: var(--poppyos-muted);
}

.pos-home__date {
	color: var(--poppyos-muted);
	white-space: nowrap;
}

.pos-home__card-more {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	color: var(--poppyos-accent);
	white-space: nowrap;
	transition: color var(--poppyos-transition);
}

.pos-home__card:hover .pos-home__card-more {
	color: var(--poppyos-accent-hover);
}

/* ═══════════════════════════════════════════════════════════
   LEAD
   ═══════════════════════════════════════════════════════════ */

.pos-lead {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1.25rem;
}

/* Grid and flex items default to min-width:auto, so one long unbroken word (a URL in a
   title) would push the column past its track instead of wrapping. */
.pos-lead__main,
.pos-home__card,
.pos-home__card-body {
	min-width: 0;
}

/* Two equal rows that fill the height of the lead image beside them — `align-content:start`
   left a block of dead space under the second card on desktop. */
.pos-lead__side {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1.25rem;
}

/* Heavier and larger than any other card title — this is the one article the front page
   is built around, and at 700 it read as just another tile. The weight and tracking match
   the post-title scale, so the lead looks like a headline rather than a big teaser. */
.pos-home__card--lead .pos-home__card-title {
	font-size: clamp(1.45rem, 1.1rem + 1.6vw, 2.25rem);
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1.18;
}

/*
 * Bottom padding matches the standard card. It used to be 1rem against 0.75rem, which put
 * the rule above the footer 4px higher in the lead card than in the side cards next to it
 * — the two never lined up even though the cards were the same height.
 */
.pos-home__card--lead .pos-home__card-body {
	padding: 0.75rem 1.25rem 0.75rem;
}

.pos-home__card--lead .pos-home__card-excerpt {
	font-size: 0.95rem;
}

.pos-home__card--side .pos-home__card-title {
	font-size: 1rem;
}

/* ═══════════════════════════════════════════════════════════
   CALCULATOR STRIP — navigation, not articles: no images
   ═══════════════════════════════════════════════════════════ */

.pos-calc__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.75rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.pos-calc__item {
	margin: 0;
}

.pos-calc__link {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 0.25rem;
	height: 100%;
	min-height: 64px;
	padding: 0.9rem 0.75rem;
	text-align: center;
	text-decoration: none !important;
	background: var(--poppyos-bg);
	border: 1px solid var(--poppyos-border);
	border-radius: var(--poppyos-radius-md);
	color: var(--poppyos-ink);
	transition: border-color var(--poppyos-transition), box-shadow var(--poppyos-transition), transform var(--poppyos-transition);
}

.pos-calc__link:hover,
.pos-calc__link:focus-visible {
	border-color: var(--poppyos-accent);
	box-shadow: var(--poppyos-shadow-sm);
}

.pos-calc__label {
	font-family: var(--wp--preset--font-family--display);
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.3;
}

.pos-calc__sub {
	font-size: 0.75rem;
	line-height: 1.3;
	color: var(--poppyos-muted);
}

/* ═══════════════════════════════════════════════════════════
   IN-CONTENT SEARCH BAND
   ═══════════════════════════════════════════════════════════ */

/*
 * A panel in the content column, not a full-bleed band. The bleed relied on negative
 * viewport-width margins, which behaved differently depending on where the composer sat,
 * and zeroing the top margin to compensate glued the panel to the cards above it. A panel
 * with the same radius as the tiles is calmer and behaves predictably everywhere.
 */
.pos-searchband {
	padding: 3rem var(--wp--preset--spacing--40, 1.5rem);
	background: var(--poppyos-surface);
	border: 1px solid var(--poppyos-border);
	border-radius: var(--poppyos-radius-lg);
}

.pos-searchband__inner {
	max-width: 720px;
	margin: 0 auto;
	text-align: center;
}

.pos-searchband__title {
	font-family: var(--wp--preset--font-family--display);
	font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.6rem);
	font-weight: 700;
	color: var(--poppyos-ink);
	margin: 0 0 1rem;
}

/* Field styled like the hero search: one rounded shell, no inner border, accent button.
   The block's own default is a thin grey rectangle around a rounded button, which looked
   like two unrelated controls glued together. */
.pos-searchband__form {
	margin: 0 auto;
	max-width: 520px;
}

.pos-searchband__form .wp-block-search__inside-wrapper {
	display: flex;
	border: none !important;
	border-radius: var(--poppyos-radius-lg) !important;
	overflow: hidden;
	padding: 0 !important;
	background: var(--poppyos-bg) !important;
	box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
}

.pos-searchband__form .wp-block-search__input {
	border: none !important;
	background: transparent !important;
	padding: 0.85rem 1.25rem !important;
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.95rem;
	text-align: left;
	color: var(--poppyos-ink);
	min-width: 0;
	flex: 1;
}

.pos-searchband__form .wp-block-search__input::placeholder {
	color: var(--poppyos-muted);
}

.pos-searchband__form .wp-block-search__input:focus {
	outline: none;
	box-shadow: none;
}

/* The ring goes around the whole pill — an outline on the input itself would be clipped
   by the wrapper's overflow:hidden. */
.pos-searchband__form .wp-block-search__inside-wrapper:focus-within {
	box-shadow: 0 0 0 3px var(--poppyos-accent-light), 0 0 0 5px var(--poppyos-accent);
}

.pos-searchband__form .wp-block-search__button {
	margin: 0 !important;
	border: none !important;
	border-radius: 0 !important;
	padding: 0.85rem 1.4rem !important;
	background: var(--poppyos-accent) !important;
	color: var(--poppyos-ink) !important;
	cursor: pointer;
}

.pos-searchband__form .wp-block-search__button:hover {
	background: var(--poppyos-accent-hover) !important;
}

.pos-searchband__form .wp-block-search__button svg {
	fill: currentColor;
}

.pos-searchband__hints {
	margin: 1rem 0 0;
	font-size: 0.8rem;
	color: var(--poppyos-muted);
	line-height: 2;
}

.pos-searchband__hints-label {
	margin-right: 0.4em;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.7rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.pos-searchband__hints a {
	color: var(--poppyos-accent);
	text-decoration: underline;
	text-underline-offset: 0.2em;
	/* Tap target without breaking the inline flow. */
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0.2rem 0.15rem;
}

.pos-searchband__hints a:hover {
	color: var(--poppyos-accent-hover);
}

/* ═══════════════════════════════════════════════════════════
   AUTHOR BOX
   ═══════════════════════════════════════════════════════════ */

/*
 * Full width, never a column. The same content in a narrow box reads as a widget; across
 * the page it reads as a masthead — which is the whole point of the section. Phone first:
 * photo above the text, one row from 600px up.
 */
.pos-authorbox {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	padding: 1.5rem;
	background: var(--poppyos-surface);
	border: 1px solid var(--poppyos-border);
	border-radius: var(--poppyos-radius-lg);
}

/*
 * Round, and fixed at 104px: big enough to read a face, small enough that it never
 * competes with a card thumbnail. A circle says "person" the way a rectangle — which is
 * what every other image on this page is — does not.
 */
.pos-authorbox__photo-wrap {
	flex: none;
	width: 88px;
	height: 88px;
	border-radius: 50%;
	overflow: hidden;
	background: var(--poppyos-bg);
}

/* Used as a shortcode the section passes through wpautop, which may wrap the image. */
.pos-authorbox__photo-wrap p {
	margin: 0;
}

.pos-authorbox__photo {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.pos-authorbox__body {
	flex: 1;
	min-width: 0;
}

.pos-authorbox__label {
	margin: 0 0 0.35rem;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.7rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--poppyos-muted);
}

.pos-authorbox__name {
	margin: 0;
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--poppyos-ink);
}

.pos-authorbox__role {
	margin: 0.2rem 0 0;
	font-size: 0.85rem;
	line-height: 1.5;
	color: var(--poppyos-muted);
}

/*
 * Miara wiersza, nie szerokość boksu. Pas ciągnie się przez 1200 px, więc notka bez limitu
 * łamała się co ~120 znaków — dwa razy więcej, niż oko wygodnie śledzi przy powrocie do
 * początku linii. Boks zostaje pełnej szerokości, tekst w nim czyta się jak tekst.
 */
.pos-authorbox__role,
.pos-authorbox__bio {
	max-width: 68ch;
}

.pos-authorbox__bio {
	margin: 0.85rem 0 0;
	font-size: 0.95rem;
	line-height: 1.65;
	color: var(--poppyos-ink);
}

.pos-authorbox__bio + .pos-authorbox__bio {
	margin-top: 0.5rem;
}

.pos-authorbox__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	margin-top: 0.85rem;
}

.pos-authorbox__link {
	/* Small text on the surface colour, so the contrast-safe accent — the same variable the
	   card links use. A raw yellow-ish brand accent fails 4.5:1 at this size. */
	color: var(--poppyos-accent-text, var(--poppyos-accent));
	font-family: var(--wp--preset--font-family--display);
	font-size: 0.875rem;
	font-weight: 600;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	/*
	 * Odstęp przed strzałką musi być gapem, nie spacją w treści: strzałka siedzi we własnym
	 * <span>, a we flexie każdy potomek jest osobnym elementem — wiodąca spacja wewnątrz
	 * takiego elementu jest zwijana i tekst sklejał się ze strzałką („o autorze→").
	 */
	gap: 0.3em;
}

.pos-authorbox__link:hover {
	color: var(--poppyos-accent-hover);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* `margin-left: auto` rather than relying on space-between: with no profile link the icons
   would otherwise sit under the note, left-aligned and looking unfinished. */
.pos-authorbox__profiles {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-left: auto;
}

.pos-authorbox__profiles-label {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.7rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--poppyos-muted);
}

/* ═══════════════════════════════════════════════════════════
   BREAKPOINTS
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 600px) and (max-width: 899px) {
	.pos-lead__side {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 600px) {
	.pos-home__grid--cols-2,
	.pos-home__grid--cols-3,
	.pos-home__grid--cols-4 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.pos-calc__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.pos-authorbox {
		flex-direction: row;
		align-items: flex-start;
		gap: 1.75rem;
		padding: 2rem;
	}

	.pos-authorbox__photo-wrap {
		width: 104px;
		height: 104px;
	}
}

@media (min-width: 900px) {
	.pos-lead {
		grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
		/* `start` left the side column at its natural height, so the two cards never
		   filled the space beside the lead image. */
		align-items: stretch;
	}

	.pos-lead__side {
		grid-auto-rows: minmax(0, 1fr);
	}

	.pos-lead--solo {
		grid-template-columns: minmax(0, 1fr);
	}

	/*
	 * Only where the card is stretched to the height of the side column, i.e. only where
	 * the empty space existed. On a phone the lead is a normal full-width card and five
	 * lines of teaser would just push the next section further down the page.
	 */
	.pos-home__card--lead .pos-home__card-excerpt {
		-webkit-line-clamp: 5;
		line-clamp: 5;
		max-height: calc(1.6em * 5);
	}

	/* Tiles stay two-up until 1024px, exactly like the featured section that sits between
	   them — otherwise one band was 2-up and the next 4-up in the same window. */
	.pos-home__grid--cols-1,
	.pos-home__grid--cols-2 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		justify-content: start;
	}

	.pos-calc__grid--cols-4 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.pos-calc__grid--cols-5 {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}

	.pos-calc__grid--cols-6 {
		grid-template-columns: repeat(6, minmax(0, 1fr));
	}

}

/* ═══════════════════════════════════════════════════════════
   MOTION — matches the theme's desktop-only hover lift
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 1024px) {
	.pos-home__grid--cols-3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.pos-home__grid--cols-4 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	/* A category left with one or two posts must not blow up into 1200px tiles. */
	.pos-home__grid--cols-1,
	.pos-home__grid--cols-2 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		justify-content: start;
	}
}

@media (hover: hover) and (min-width: 1024px) {
	.pos-home__card {
		transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.3s ease;
	}

	/* Same lift and shadow as .pos-sponsored__card — the tiles sit next to each other. */
	.pos-home__card:hover {
		transform: translateY(-3px);
		box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.1), 0 4px 8px -4px rgba(0, 0, 0, 0.04);
	}

	.pos-home__card-media img {
		transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
	}

	.pos-home__card:hover .pos-home__card-media img {
		transform: scale(1.06);
	}

	.pos-calc__link:hover {
		transform: translateY(-2px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.pos-home__card,
	.pos-calc__link,
	.pos-home__card-media img {
		transition: none;
	}

	.pos-home__card:hover,
	.pos-calc__link:hover {
		transform: none;
	}

	.pos-home__card:hover .pos-home__card-media img {
		transform: none;
	}
}

/* ═══════════════════════════════════════════════════════════
   FALLBACKS / PRINT
   ═══════════════════════════════════════════════════════════ */

/* Engines without aspect-ratio would collapse the media box and shift the layout as
   images arrive; the padding trick reserves the same 16:9 frame. */
@supports not (aspect-ratio: 16 / 9) {
	.pos-home__card-media {
		position: relative;
		height: 0;
		padding-top: 56.25%;
	}

	.pos-home__card-media img {
		position: absolute;
		top: 0;
		left: 0;
	}

}

@media print {
	.pos-searchband {
		display: none;
	}

	.pos-home__card {
		box-shadow: none;
		border: 1px solid var(--poppyos-border);
	}

	/* The masthead is worth keeping on paper, but never split across two pages. */
	.pos-authorbox {
		break-inside: avoid;
		page-break-inside: avoid;
	}

	.pos-home > * + * {
		margin-top: 1.5rem;
	}
}
