/*
Theme Name: Stencibility
Theme URI: https://stencibility.ee
Author: Flowen AI OÜ
Description: Block theme for the Stencibility street art festival, tours and shop. Design tokens live in theme.json. Business logic lives in the stencibility-functionality plugin, never here.
Version: 0.1.0
Requires at least: 6.5
Requires PHP: 8.1
License: GPL-2.0-or-later
Text Domain: stencibility
*/

/* Shared parts: header, phone menu, footer, patterns. Tokens come from theme.json. */

:root {
	--st-ink: var(--wp--preset--color--ink);
	--st-ink-2: var(--wp--preset--color--ink-2);
	--st-ink-3: var(--wp--preset--color--ink-3);
	--st-hairline: var(--wp--preset--color--hairline);
	--st-hairline-dark: var(--wp--preset--color--hairline-dark);
	--st-subtle: var(--wp--preset--color--canvas-subtle);
	--st-ease: 150ms ease;
	/* Same pixels as the old rgba(0,0,0,.85) while ink is black; follows ink in the dark theme. */
	--st-ink-hover: color-mix(in srgb, var(--wp--preset--color--ink) 85%, transparent);
	--st-error-bg: #fff;
	--st-error-line: #b3261e;
	--st-error-text: #8c1d18;
	/* Background behind product and poster photos. Photos sit on white, so the dark theme keeps this tile light. */
	--st-tile: var(--wp--preset--color--canvas-subtle);
	--st-pcard-air: 8%; /* space between a card picture and the edge of its frame, share of the card width; shop cards and home strip cards */
}
html.st-menu-open { overflow: hidden; }
/* WooCommerce's mini-cart drawer writes body { padding-right: 0 } inline (scrollbar compensation), which ate the right gutter on phone. Keep the gutter. */
body { padding-right: var(--wp--custom--gutter) !important; }
.st-small { font-size: var(--wp--preset--font-size--small); color: var(--st-ink-2); }
.st-small a { text-decoration: none; }
.st-small a:hover { text-decoration: underline; }

/* Page content lines up with the header logo: the header row is 72rem wide with the gutter inside, so main is narrower by two gutters */
/* main runs edge to edge (like the header; the product page nests it in one WooCommerce div), so a tinted band can reach both browser edges. Everything else in main
   keeps the narrow column (72rem less two gutters, centred). Bands set margin 0 and use --st-edge, the same inset,
   as their own side padding, so their content lines up with the column (FLO-996). */
.wp-site-blocks main { --st-edge: max(var(--wp--custom--gutter), calc((100% - var(--wp--style--global--wide-size, 72rem)) / 2 + var(--wp--custom--gutter))); width: calc(100% + 2 * var(--wp--custom--gutter)); max-width: none; margin-inline: calc(var(--wp--custom--gutter) * -1); }
.wp-site-blocks main > :not(.artists-dir),
.wp-site-blocks main > .artists-dir > * { width: min(100% - 2 * var(--wp--custom--gutter), var(--wp--style--global--wide-size, 72rem) - 2 * var(--wp--custom--gutter)); box-sizing: border-box; margin-inline: auto; }
.wp-site-blocks main > :is(.st-section, .section--subtle, .more),
.wp-site-blocks main > .artists-dir > .section--subtle { width: auto; margin-inline: 0; padding-inline: var(--st-edge); }

/* One gap between the sticky header and the first content on every page (FLO-998). The root block gap above main is off; the page head and the home hero take --st-head-gap as their top padding. */
:root { --st-head-gap: clamp(32px, 3.5vw, 48px); }
.wp-site-blocks > main,
.wp-site-blocks > :has(> main) { margin-block-start: 0; } /* the product page nests main in one WooCommerce div */
.wp-site-blocks main :is(.pagehead, .np__head) { padding-top: var(--st-head-gap); } /* .np__head is the news plugin's page head */

/* Footer sits at the bottom on short pages */
.wp-site-blocks { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.wp-site-blocks > main { flex: 1 0 auto; }

/* Header and footer run edge to edge; the root gutter is re-applied inside them */
header.wp-block-template-part,
footer.wp-block-template-part { margin-inline: calc(var(--wp--custom--gutter) * -1); }

/* Header: the template part itself is sticky so the phone menu can sit beside the bar */
header.wp-block-template-part { position: sticky; top: var(--wp-admin--admin-bar--height, 0px); z-index: 30; }
@media (max-width: 600px) { header.wp-block-template-part { top: 0; } } /* the admin bar scrolls away on phones */
header.wp-block-template-part::before { content: ""; position: absolute; inset: 0; z-index: -1; background: color-mix(in srgb, var(--wp--preset--color--canvas) 92%, transparent); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--st-hairline); }
.st-header__row { height: 60px; max-width: var(--wp--style--global--wide-size, 72rem); margin-inline: auto; padding-inline: var(--wp--custom--gutter); gap: 16px; align-items: center; }
.st-logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.03em; font-size: 1.125rem; text-decoration: none; }
.st-logo:hover { text-decoration: none; }
.st-logo img { width: 38px; height: 38px; max-width: none; display: block; }
.st-nav { display: none; }
.st-nav .wp-block-navigation__container { gap: 28px; }
.wp-block-navigation.st-nav .wp-block-navigation-item__content.wp-block-navigation-item__content { font-size: var(--wp--preset--font-size--small); font-weight: 500; color: var(--st-ink-2); text-decoration: none; }
.wp-block-navigation.st-nav .wp-block-navigation-item__content.wp-block-navigation-item__content:hover,
.wp-block-navigation.st-nav .current-menu-item > .wp-block-navigation-item__content.wp-block-navigation-item__content { color: var(--st-ink); }
.st-header__tools { gap: 8px; }

.st-lang { display: inline-flex; border: 1px solid var(--st-hairline-dark); border-radius: var(--wp--custom--radius--pill); overflow: hidden; }
.st-lang a { padding: 6px 12px; font: 600 var(--wp--preset--font-size--xs)/1 var(--wp--preset--font-family--inter); text-decoration: none; color: var(--st-ink); }
.st-lang a[aria-current="true"] { background: var(--st-ink); color: var(--wp--preset--color--canvas); }

.st-iconbtn, .st-burger, .st-header__tools .wc-block-mini-cart__button { position: relative; width: 40px; height: 40px; min-width: 40px; border-radius: 50%; border: 1px solid var(--st-hairline-dark); background: var(--wp--preset--color--canvas); cursor: pointer; font-size: 1rem; color: var(--st-ink); padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.st-header__tools .wc-block-mini-cart__button { padding: 0; }
.st-cartlink { position: relative; width: 40px; height: 40px; min-width: 40px; border-radius: 50%; border: 1px solid var(--st-hairline-dark); background: var(--wp--preset--color--canvas); color: var(--st-ink); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.st-cartlink:hover { text-decoration: none; border-color: var(--st-ink); }
.st-header__tools .wc-block-mini-cart__quantity-badge { position: static; display: inline-flex; padding: 0; }
.st-header__tools .wc-block-mini-cart__icon { width: 20px; height: 20px; }
/* Badge as in the design: always shown, 0 included. !important beats the inline colours WooCommerce sets and its hidden attribute at 0. */
.st-header__tools .wc-block-mini-cart__badge { position: absolute; top: -4px; right: -4px; left: auto; transform: none; animation: none; transition: none; min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box; border-radius: 9px; background: var(--st-ink) !important; color: var(--wp--preset--color--canvas) !important; font-size: 10px; font-weight: 700; line-height: 1; display: grid !important; place-items: center; margin: 0; }
.st-cartlink .wc-block-mini-cart__badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box; border-radius: 9px; background: var(--st-ink); color: var(--wp--preset--color--canvas); font-size: 10px; font-weight: 700; line-height: 1; display: grid; place-items: center; }
.st-header__tools .wc-block-mini-cart__badge:empty { display: none !important; }
.st-burger { flex-direction: column; gap: 5px; padding: 0 11px; }
.st-burger span { display: block; width: 100%; height: 2px; background: var(--st-ink); border-radius: 2px; }
@media (min-width: 900px) {
	.st-nav { display: flex; }
	.st-burger { display: none; }
}

/* Phone menu: full screen, big tap targets. [data-open] drives it, JS sets it. */
.st-menu { position: fixed; inset: 0; z-index: 50; background: var(--wp--preset--color--canvas); display: none; flex-direction: column; padding: 0 var(--wp--custom--gutter) 32px; overflow-y: auto; }
.st-menu[data-open="true"] { display: flex; }
.st-menu__top { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.st-menu__links { display: grid; margin-top: 16px; }
.st-menu__links a { font-size: 2rem; font-weight: 700; letter-spacing: -0.025em; padding: 14px 0; min-height: 56px; border-bottom: 1px solid var(--st-hairline); text-decoration: none; display: flex; justify-content: space-between; align-items: baseline; }
.st-menu__links a small { font-size: var(--wp--preset--font-size--xs); font-weight: 500; color: var(--st-ink-3); letter-spacing: 0; }
.st-menu__foot { margin-top: auto; padding-top: 24px; align-items: center; }
.st-menu__foot > p { margin: 0; }
@media (min-width: 900px) { .st-menu { display: none !important; } }

/* Footer: reversed, black */
footer.wp-block-template-part { background: #000; color: #fff; margin-block-start: 0; }
.st-footer__inner { max-width: var(--wp--style--global--wide-size, 72rem); margin-inline: auto; padding: 56px var(--wp--custom--gutter) 32px; }
.st-footer__row { display: grid; gap: 32px; }
.st-footer a { color: inherit; }
footer.wp-block-template-part a { text-decoration: none; color: #fff; }
footer.wp-block-template-part .st-small { color: rgba(255, 255, 255, 0.6); }
footer.wp-block-template-part .st-logo img { filter: invert(1); }
.st-footer__org { margin: 8px 0 20px; }
.st-footer__links { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: var(--wp--preset--font-size--small); align-items: center; }
.st-footer__links a { color: rgba(255, 255, 255, 0.7); }
.st-footer__links a:hover { color: #fff; }
.st-social { gap: 10px; }
.st-social .wp-social-link a { width: 42px; height: 42px; padding: 0; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.3); display: grid; place-items: center; color: #fff; background: transparent; transition: background var(--st-ease), color var(--st-ease); }
.st-social .wp-social-link { background: transparent !important; color: #fff !important; }
.st-social .wp-social-link a:hover { background: #fff; color: #000; }
.st-social .wp-social-link svg { width: 20px; height: 20px; }
.st-news { display: flex; gap: 8px; max-width: 380px; }
.st-news input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid rgba(255, 255, 255, 0.3); background: transparent; color: #fff; border-radius: var(--wp--custom--radius--pill); font: inherit; font-size: var(--wp--preset--font-size--small); }
.st-news input::placeholder { color: rgba(255, 255, 255, 0.5); }
.st-btn { padding: 10px 18px; border-radius: var(--wp--custom--radius--pill); border: 1px solid transparent; background: #fff; color: #000; font: 600 var(--wp--preset--font-size--xs)/1 var(--wp--preset--font-family--inter); cursor: pointer; white-space: nowrap; transition: background var(--st-ease); }
.st-btn:hover { background: rgba(255, 255, 255, 0.85); }
footer.wp-block-template-part :focus-visible { outline-color: #fff; }
.st-legal { margin-top: 40px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, 0.15); font-size: var(--wp--preset--font-size--xs); color: rgba(255, 255, 255, 0.5); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.st-legal a { color: rgba(255, 255, 255, 0.5); }
.st-legal a:hover { color: #fff; }
@media (min-width: 900px) {
	.st-footer__row { grid-template-columns: 1fr auto; align-items: end; }
	.st-footer__right { display: grid; gap: 20px; justify-items: end; }
}
.screen-reader-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Patterns */
.st-section-head { margin-bottom: 24px; gap: 16px; }
.st-section-head h2 { margin: 0; }
.st-card { background: var(--wp--preset--color--canvas); border: 1px solid var(--st-hairline); border-radius: var(--wp--custom--radius--card); overflow: hidden; transition: border-color var(--st-ease); }
.st-card:hover { border-color: var(--st-ink); }
.st-card .wp-block-image { margin: 0; background: var(--st-tile); overflow: hidden; }
.st-card .wp-block-image img { border-radius: 0; width: 100%; transition: transform 300ms ease; }
.st-card:hover .wp-block-image img { transform: scale(1.05); }
.st-card__body { padding: 14px; }
.st-card__title { font-size: var(--wp--preset--font-size--small); font-weight: 700; line-height: 1.3; margin: 0 0 4px; }
.st-pills { gap: 8px; }
.st-pills .wp-block-button__link { padding: 6px 14px; font-size: var(--wp--preset--font-size--xs); border: 1px solid var(--st-hairline-dark); background: var(--wp--preset--color--canvas); color: var(--st-ink); }
.st-pills .wp-block-button__link:hover { border-color: var(--st-ink); background: var(--wp--preset--color--canvas); color: var(--st-ink); }
.st-pills .is-style-fill .wp-block-button__link,
.st-pills .wp-block-button__link[aria-current="true"] { background: var(--st-ink); color: var(--wp--preset--color--canvas); border-color: var(--st-ink); }
.st-facts__row { padding: 12px 0; border-top: 1px solid var(--st-hairline); gap: 16px; }
.st-facts__row:last-child { border-bottom: 1px solid var(--st-hairline); }
.st-facts__row p { margin: 0; }

/* Filter pills keep one size and weight in every state (FLO-996): no state rule may touch metrics, and white-on-black text
   is smoothed like black-on-white so the pressed pill does not read bolder. */
.pill, .st-home-pill { font-weight: 600; letter-spacing: 0; text-decoration: none; transform: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Tap targets on phones: at least 40px high (FLO-995). border-box so padding never adds to the 40px. */
@media (max-width: 600px) {
	html body .st-lang a, html body .pill, html body .st-btn-small, html body .st-shop--cart .wc-block-components-quantity-selector__button, html body .st-shop--cart .wc-block-cart-item__remove-link { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; }
	html body .st-shop--cart .wc-block-components-quantity-selector__button { min-width: 40px; }
	/* The mini cart drawer sits outside .st-shop--cart; its plus, minus and remove were 30x27 and 24x24 (shop review, 15 Nov 2026). */
	html body .wc-block-mini-cart__drawer .wc-block-components-quantity-selector__button, html body .wc-block-mini-cart__drawer .wc-block-cart-item__remove-link { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; }
}

/* Mini cart drawer (shop review, 15 Nov 2026). WooCommerce paints the panel #fff and writes the page colour inline on the contents when
   the drawer first renders, so after a theme switch the panel kept the old colour (white under near-white text in dark). */
.wc-block-mini-cart__drawer.wc-block-components-drawer, .wc-block-mini-cart__drawer .wp-block-woocommerce-mini-cart-contents { background-color: var(--wp--preset--color--canvas) !important; }
/* The product blurb under each line is long and in Estonian on EN pages; the name and price are enough here, as in the checkout summary. */
.wc-block-mini-cart__drawer .wc-block-components-product-metadata__description { display: none; }
/* The closed drawer stays in the page under aria-hidden with its buttons in the Tab order. Hide it once the 0.3s fade and slide end. */
.wc-block-components-drawer__screen-overlay--is-hidden { visibility: hidden; transition: opacity 300ms, visibility 0s linear 300ms; }

/* Small screens and big text. The header fits at 320px, long words wrap, and form fields never push the page wider than the screen. */
@media (max-width: 480px) {
	.st-header__row { gap: 8px; }
	.st-header__row .st-logo span { display: none; } /* the mark already spells the name */
	.st-header__tools { gap: 6px; flex-shrink: 0; }
	.st-lang a { padding: 6px 10px; }
}
main h1, main h2, main h3, main h4, main p, main li, main td, footer p, footer a { overflow-wrap: break-word; }
main input, main select, main textarea, main fieldset, main .wc-block-components-text-input { max-width: 100%; min-width: 0; box-sizing: border-box; }
@media (max-width: 600px) { main .wp-block-group, footer .wp-block-group { min-width: 0; } }
.empty { grid-template-columns: minmax(0, 1fr); }
.empty > * { min-width: 0; }
.wc-block-components-radio-control__option, .wc-block-components-radio-control__option-layout { min-width: 0; }
.wc-block-components-radio-control__option-layout { flex-wrap: wrap; }
.btn, .st-btn-small { white-space: normal; max-width: 100%; text-align: center; }
.wc-block-components-radio-control__label, .wc-block-components-radio-control__label-group { min-width: 0; overflow-wrap: anywhere; }

/* Dark theme. Opt-in: the header toggle sets data-theme="dark" on <html> (assets/js/theme.js, set before first paint by the inline
   script in functions.php). Light stays the default. Only token values change here; components read the tokens. */
html[data-theme="dark"] {
	color-scheme: dark;
	--wp--preset--color--canvas: #1b1b1b;
	--wp--preset--color--canvas-subtle: #222222;
	--wp--preset--color--canvas-surface: #2c2c2c;
	--wp--preset--color--ink: #f7f7f7;
	--wp--preset--color--ink-2: #b4b4b4;
	--wp--preset--color--ink-3: #8a8a8a;
	--wp--preset--color--hairline: #3a3a3a;
	--wp--preset--color--hairline-dark: #5c5c5c;
	--wp--preset--color--success: #6fbf8a;
	--st-tile: #f7f7f7;
	--st-error-bg: #2a1412;
	--st-error-line: #f2796f;
	--st-error-text: #ffb4ab;
}
/* Light version: the light greys a notch darker (Märkused, 11 Nov 2026). */
html:not([data-theme="dark"]) {
	--wp--preset--color--canvas-subtle: #ededf0;
	--wp--preset--color--canvas-surface: #f2f2f5;
	--wp--preset--color--hairline: #dcdce1;
	--wp--preset--color--hairline-dark: #c6c6cc;
}
html[data-theme="dark"] header.wp-block-template-part .st-logo img { filter: invert(1); }
html[data-theme="dark"] footer.wp-block-template-part { background: var(--wp--preset--color--canvas); border-top: 1px solid var(--st-hairline); }
html[data-theme="dark"] .st-theme .st-theme__moon { display: none; }
html:not([data-theme="dark"]) .st-theme .st-theme__sun { display: none; }
.st-theme svg { width: 18px; height: 18px; }

/* Safari before 16.2 cannot read color-mix(). A declaration that uses color-mix() and var() still wins the cascade there and computes to nothing, so the literal values are restated here. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
	:root { --st-ink-hover: rgba(0, 0, 0, 0.85); }
	html[data-theme="dark"] { --st-ink-hover: rgba(247, 247, 247, 0.85); }
	header.wp-block-template-part::before { background: rgba(255, 255, 255, 0.92); }
	html[data-theme="dark"] header.wp-block-template-part::before { background: rgba(27, 27, 27, 0.92); }
}
