/* You Be the Judge — front-end styles. Tokens scoped to .ybtj so nothing
   leaks into the host theme. Mirrors the prototype's assets/4h.css. */

@import url("https://fonts.googleapis.com/css2?family=Archivo+Expanded:wght@500;600;700;800;900&family=Archivo:wght@400;500;600;700;800&family=Mulish:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap");

.ybtj {
	--green: #339966;
	--green-700: #2a7d52;
	--green-800: #1f5e3e;
	--forest: #163a2a;
	--yellow: #fdc82f;
	--yellow-deep: #f0b400;
	--coral: #f54359;
	--coral-700: #d92c43;
	--sage: #c9e3dc;
	--sage-soft: #e4f0eb;
	--ink: #16241d;
	--ink-soft: #44544c;
	--line: #e7e9e4;
	--font-display: "Archivo Expanded", "Archivo", system-ui, sans-serif;
	--font-head: "Archivo", system-ui, sans-serif;
	--font-body: "Mulish", system-ui, sans-serif;
	--sh-sm: 0 1px 2px rgba(22,58,42,.08), 0 2px 8px rgba(22,58,42,.06);
	--sh-md: 0 6px 18px rgba(22,58,42,.10), 0 2px 6px rgba(22,58,42,.06);
	--sh-lg: 0 18px 44px rgba(22,58,42,.16), 0 6px 14px rgba(22,58,42,.08);

	font-family: var(--font-body);
	color: var(--ink);
	-webkit-font-smoothing: antialiased;
}

.ybtj * { box-sizing: border-box; }

/* blank canvas: plugin owns the whole page (no theme chrome). No page-wide
   colour by default (each screen's desk/panel paints its own); only the
   results/TY screen bleeds forest green to the page edges. */
html:has(body.ybtj-canvas), body.ybtj-canvas { margin: 0; }
html:has(.ybtj-desk--forest), html:has(.ybtj-panel--forest),
body.ybtj-canvas:has(.ybtj-desk--forest), body.ybtj-canvas:has(.ybtj-panel--forest) { background: #163a2a; }
.ybtj-canvas-main { width: 100%; }
/* each desktop screen fills the viewport so its colour bleeds full-height */
.ybtj-canvas .ybtj-desk { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
/* center the mobile panel on the open canvas */
.ybtj-canvas .ybtj-panel { margin: 24px auto; }

/* desktop chrome shell: header + body (fills) + footer = full viewport height */
.ybtj-deskshell { display: flex; flex-direction: column; min-height: 100vh; }
.ybtj-deskshell .ybtj-header, .ybtj-deskshell .ybtj-footer { flex: 0 0 auto; }
.ybtj-deskshell .ybtj-desk { min-height: 0; flex: 1 1 auto; }

/* horizontal padding (vertical is inline); tightened on mobile so the brandlock
   and header button aren't squished against the edges */
.ybtj-header { padding-left: 40px; padding-right: 40px; }
@media (max-width: 819px) {
	.ybtj-header { padding-left: 12px; padding-right: 12px; }
	.ybtj-footer { display: none; }
}
/* archive's sticky category nav sits below the sticky header on desktop */
@media (min-width: 820px) {
	.ybtj-arch-nav { top: 71px; }
}

/* the centered experience column (mobile-first, primary experience) */
.ybtj-panel {
	position: relative;
	max-width: 460px;
	margin: 0 auto;
	border-radius: 22px;
	padding: 24px 22px 86px;
	overflow: hidden;
	min-height: 540px;
	display: flex;
	flex-direction: column;
}
.ybtj-panel--yellow { background: var(--yellow); }
.ybtj-panel--forest { background: var(--forest); }
.ybtj-panel--mist { background: #f3f5f1; }

/* On a real phone/tablet viewport the experience is full-bleed (fills the
   viewport, no card framing). The rounded centered card is only for the
   desktop preview-of-mobile (narrow container on a wide viewport). */
@media (max-width: 819px) {
	.ybtj-panel,
	.ybtj-canvas .ybtj-panel {
		max-width: none;
		margin: 0;
		border-radius: 0;
		min-height: 100vh;
		min-height: 100dvh;
	}

	/* Vote screen: pin the whole thing to one viewport height so the two cards
	   AND the "Next matchup" button are always above the fold (no scrolling to
	   reach it). Header, progress bar and button keep their natural size; the
	   cards region takes the leftover height and the card photos flex to fill
	   it — big on tall phones, compact on short ones. */
	.ybtj-panel--mist.ybtj-vote {
		height: 100vh;
		height: 100dvh;
		min-height: 0;
		padding-bottom: 20px;
		overflow: hidden;
	}
	.ybtj-vote-cards { flex: 1 1 auto; min-height: 0; }
	.ybtj-vote-cards > .ybtj-match-in { flex: 1 1 0; min-height: 0; display: flex; }
	/* !important beats the card's inline display:block so it becomes a flex column */
	.ybtj-vote-cards > .ybtj-match-in > .ybtj-card { height: 100%; display: flex !important; flex-direction: column; }
	/* flex-basis 0 makes the photo's height flexible (ignores its inline height:130).
	   width:100% because WebKit won't cross-stretch a flex item whose only content
	   is absolutely positioned — without it the photo box collapses to 0 width. */
	.ybtj-vote-cards > .ybtj-match-in > .ybtj-card > :first-child { flex: 1 1 0; min-height: 56px; width: 100%; }
	/* iOS Safari won't treat a flex-grown item's height as definite, so the photo's
	   height:100% collapses (blank image / shrunken placeholder). Absolutely fill
	   the position:relative photo box instead so it always covers the area. */
	.ybtj-vote-cards > .ybtj-match-in > .ybtj-card > :first-child > :first-child { position: absolute !important; inset: 0; width: auto !important; height: auto !important; }
	.ybtj-vote-cards > .ybtj-match-in > .ybtj-card > :last-child { flex: 0 0 auto; }
	.ybtj-vote-actions { flex: 0 0 auto; }
}

/* Desktop: the two match cards sit side by side. The row is align-items:stretch
   (see view.js) so both cards match the taller one's height; make each card a
   flex column and push its last line (the "Swipe/tap to vote" CTA or "Your pick")
   to the bottom so the card bottoms line up. .ybtj-desk--mist only renders in the
   desktop (>=820px container) vote view, so this never affects the stacked phone
   layout. */
.ybtj-desk--mist .ybtj-match-in { display: flex; }
.ybtj-desk--mist .ybtj-match-in > .ybtj-card { flex: 1 1 auto; display: flex !important; flex-direction: column; }
/* photo keeps its height; width:100% + absolute-fill so WebKit doesn't collapse it
   now that the card is a flex column (same fix as the mobile vote cards) */
.ybtj-desk--mist .ybtj-card > :first-child { flex: 0 0 auto; width: 100%; }
.ybtj-desk--mist .ybtj-card > :first-child > :first-child { position: absolute !important; inset: 0; width: auto !important; height: auto !important; }
.ybtj-desk--mist .ybtj-card > :last-child { flex: 1 1 auto; display: flex; flex-direction: column; }
.ybtj-desk--mist .ybtj-card > :last-child > :last-child { margin-top: auto; }

.ybtj-eyebrow {
	font-family: var(--font-head); font-weight: 800; font-size: 12px;
	letter-spacing: .12em; text-transform: uppercase; color: #9a3520;
}

/* ---- desktop layout (>= ~820px container) ---- */
.ybtj-desk { position: relative; overflow: hidden; width: 100%; }
.ybtj-desk--hero { background: var(--yellow); padding: 56px 0 44px; }
.ybtj-desk--mist { background: #f3f5f1; padding: 40px 0 56px; }
.ybtj-desk--forest { background: var(--forest); padding: 46px 40px 60px; }
/* TY page: header floats over it, so start content below the header and top-align */
.ybtj-canvas .ybtj-desk--forest { justify-content: flex-start; padding-top: 96px; }
.ybtj-wrap { max-width: 1280px; margin: 0 auto; padding: 0 44px; position: relative; }
.ybtj-desk--hero .ybtj-wrap + .ybtj-wrap { padding-top: 30px; }

.ybtj-sticker {
	display: inline-block; background: var(--coral); color: #fff;
	padding: .02em .16em .08em; border-radius: 14px;
	transform: rotate(-2.5deg); box-shadow: var(--sh-md); margin-top: 8px;
}

.ybtj-pill {
	background: rgba(255,255,255,.6); border: 1.5px solid rgba(22,58,42,.12);
	border-radius: 999px; padding: 7px 13px;
	font-family: var(--font-head); font-weight: 700; font-size: 12.5px; color: #3a3320;
}

/* ---- projects archive ---- */
.ybtj-arch-hero { background: var(--forest); padding: 52px 0 44px; }
.ybtj-arch-nav { position: sticky; top: 0; z-index: 20; background: rgba(248,250,246,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.ybtj-arch-chip {
	flex-shrink: 0; cursor: pointer; border: 1px solid var(--line); background: #fff;
	color: #44544c; font-family: var(--font-head); font-weight: 700; font-size: 12.5px;
	padding: 8px 14px; border-radius: 999px; white-space: nowrap; transition: all .15s ease;
}
.ybtj-arch-chip.is-active { background: var(--green); border-color: var(--green); color: #fff; }
.ybtj-arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }

/* match cards: coral ring on hover so it's clear any card is clickable — including
   switching your pick before hitting Next (pointer devices only) */
@media (hover: hover) {
	.ybtj-card:hover { box-shadow: 0 0 0 3px var(--coral), var(--sh-md) !important; }
}

/* results leaderboard: rows aren't links, so the whole board is one focusable,
   labelled scroll region — keyboard users tab to it once and arrow/Page-scroll
   through the ranking (WCAG 2.1.1) instead of tabbing through dead row stops.
   Focus outline is inset so it isn't clipped by the board's own overflow. */
.ybtj-board:focus-visible { outline-offset: -3px; border-radius: 18px; }

/* buttons (mirrors .btn / .btn--block / .btn--ghost) */
.ybtj-btn {
	display: inline-flex; align-items: center; justify-content: center;
	border: 0; cursor: pointer; border-radius: 999px;
	font-family: var(--font-head); font-weight: 800; font-size: 15px;
	padding: 13px 22px;
	/* Fill + label flow through vars and are forced !important on every state so a
	   host theme's button colours (incl. its :hover/:focus/:active) can't override
	   them. Coloured buttons set --btn-bg / --btn-fg inline. */
	color: var(--btn-fg, #fff) !important;
	background-color: var(--btn-bg, var(--green)) !important;
	text-decoration: none; transition: background-color .15s ease, transform .05s ease;
}
/* press feedback works on touch too (fires on first tap) */
.ybtj-btn:active { transform: translateY(1px); background-color: var(--btn-bg, var(--green)) !important; background-image: linear-gradient(rgba(0,0,0,.24), rgba(0,0,0,.24)) !important; }
.ybtj-btn:disabled { opacity: .45; cursor: not-allowed; }
.ybtj-btn--block { display: flex; width: 100%; }
.ybtj-btn--ghost { --btn-bg: transparent; --btn-fg: var(--green-800); box-shadow: inset 0 0 0 2px var(--green); }

/* Darken the button shade on hover/focus (like the buttons on 4-h.org) WITHOUT
   dimming the label: overlay a translucent black as a background layer, which
   paints above the background colour but below the text. A linear-gradient is
   used as that layer; !important lets it sit over buttons whose background colour
   is set via inline styles. Keyboard focus (focus-visible) darkens too. */
.ybtj-btn:focus-visible { background-color: var(--btn-bg, var(--green)) !important; color: var(--btn-fg, #fff) !important; background-image: linear-gradient(rgba(0,0,0,.18), rgba(0,0,0,.18)) !important; }
/* Hover only on devices with a real pointer. On touch, :hover is "sticky" and
   the first tap just applies it (needing a second tap to click); gating it here
   makes the first tap a real click. */
@media (hover: hover) {
	.ybtj-btn:hover { background-color: var(--btn-bg, var(--green)) !important; color: var(--btn-fg, #fff) !important; background-image: linear-gradient(rgba(0,0,0,.18), rgba(0,0,0,.18)) !important; }
	.ybtj-arch-chip:hover { border-color: var(--green) !important; color: var(--green-800) !important; background-color: #fff !important; }
}

/* Light-fill buttons with dark text (yellow, sage) lighten instead of darken —
   darkening a pale fill under dark text looks muddy. Higher specificity than the
   base rules above, so this wins for .ybtj-btn--light regardless of order. */
.ybtj-btn--light:focus-visible { background-image: linear-gradient(rgba(255,255,255,.32), rgba(255,255,255,.32)) !important; }
.ybtj-btn--light:active { background-image: linear-gradient(rgba(255,255,255,.44), rgba(255,255,255,.44)) !important; }
@media (hover: hover) {
	.ybtj-btn--light:hover { background-image: linear-gradient(rgba(255,255,255,.32), rgba(255,255,255,.32)) !important; }
}

/* keyboard focus ring — dark by default, light on dark surfaces */
/* keep each element's own border-radius so pill buttons stay pill-shaped on focus */
.ybtj :focus-visible { outline: 3px solid #16241d; outline-offset: 2px; }
.ybtj-desk--forest :focus-visible,
.ybtj-panel--forest :focus-visible,
.ybtj-footer :focus-visible { outline-color: #fff; }
/* don't show the ring on the programmatically-focused screen headings */
.ybtj h1:focus, .ybtj h2:focus { outline: none; }

/* Accessibility: keep text on the forest (dark) surfaces light for contrast even
   if a host theme tries to set its own heading/paragraph colours. */
.ybtj-panel--forest h1, .ybtj-canvas .ybtj-desk--forest h1 { color: #eaf3ee !important; }
.ybtj-panel--forest p, .ybtj-canvas .ybtj-desk--forest p { color: #cfe0d7 !important; }

/* let the vote "next"/CTA push to the bottom of the panel */
.ybtj-panel > .ybtj-btn--block:last-child,
.ybtj-panel > div:last-of-type { margin-top: auto; }

@keyframes ybtjFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ybtjPop { from { opacity: 0; transform: scale(.92) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes ybtjSlide { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ybtjStamp { 0% { opacity: 0; transform: scale(1.8) rotate(-18deg); } 60% { opacity: 1; transform: scale(.92) rotate(-8deg); } 100% { transform: scale(1) rotate(-8deg); } }
@keyframes ybtjFlash { 0% { opacity: .95; transform: scale(.2); } 45% { opacity: .5; } 100% { opacity: 0; transform: scale(1.85); } }
/* staggered matchup entrance: first card, VS badge, second card animate in.
   `both` holds the hidden start state through animation-delay so the stagger reads. */
@keyframes ybtjMatchIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
/* `backwards` (not `both`): holds the hidden start state through the stagger delay,
   then reverts to the element's natural style once done — leaving a `both` fill in
   place left the scaled/animated cards in a faded, half-composited state. */
.ybtj-match-in { animation: ybtjMatchIn .34s cubic-bezier(.2,.7,.2,1) backwards; }

/* Project story: preserve the paragraph/line-break structure the editor entered.
   Content is filtered + kses-sanitized server-side, so it's just post markup. */
.ybtj-story > :first-child { margin-top: 0; }
.ybtj-story > :last-child { margin-bottom: 0; }
.ybtj-story p { margin: 0 0 0.9em; }
.ybtj-story ul, .ybtj-story ol { margin: 0 0 0.9em; padding-left: 1.4em; }
.ybtj-story li { margin: 0.2em 0; }
.ybtj-story a { color: var(--green); }

@media (prefers-reduced-motion: reduce) {
	.ybtj * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
	.ybtj-hero-layer { transition: none !important; }
}
