/**
 * Villa Store: design tokens
 *
 * The single source of truth for colour, type, space, radius, elevation and
 * motion. Everything downstream (theme CSS, login CSS, GSAP defaults read via
 * getComputedStyle in animations.js) resolves against these custom properties.
 *
 * Conventions
 *   --villa-*   raw brand values. Do not use directly in component CSS when a
 *               semantic token exists. Go through the semantic layer so a
 *               palette change stays a one-line edit.
 *   --color-*   semantic roles mapped onto the raw palette.
 *
 * Contrast ratios below are against --color-bg (#ffffff) and were checked to
 * WCAG 2.1 AA. Keep them passing when editing.
 */

:root {
	/* ---------------------------------------------------------------------
	 * 1. Brand palette
	 * ------------------------------------------------------------------ */

	--villa-blue: #003da5;   /* 9.5:1 on white, AAA for body text */
	--villa-red: #e30613;    /* 4.9:1 on white, AA for body text, AAA for large only */
	--villa-slate: #274149;  /* 10.9:1 on white, AAA */
	--villa-grey: #dadada;   /* Borders and rules only. Never text on white. */

	/* Neutrals derived from the brand grey/slate for surfaces and muted text. */
	--villa-white: #ffffff;
	--villa-off-white: #f5f7f8; /* Slate-tinted surface tint. */
	--villa-grey-mid: #5b6a70;  /* 5.6:1 on white, AA for body text. */

	/* Brand blue darkened ~15% for hover/active states. */
	--villa-blue-dark: #00348c; /* 11.1:1 on white */

	/* ---------------------------------------------------------------------
	 * 2. Category accents
	 *
	 * One per product category. Reach for these via a category-scoped class
	 * or --category-accent override rather than hard-coding them per component.
	 * Named --villa-cat-* to keep them clearly distinct from the brand palette
	 * (note --villa-cat-blue is a different blue to --villa-blue).
	 * ------------------------------------------------------------------ */

	--villa-cat-orange: #ec6607;
	--villa-cat-greyblue: #53606b;
	--villa-cat-purple: #902082;
	--villa-cat-blue: #0066b1;
	--villa-cat-brown: #6f4608;
	/* 3.65:1 on white. Fine as a tint behind slate text, which is how the tags
	 * and status badges use it. Not safe as a fill behind white text, and not
	 * safe as text: both need 4.5:1. */
	--villa-cat-green: #009b3d;
	--villa-cat-magenta: #e6007e;
	--villa-cat-lightblue: #b5e0f1; /* Light tint: backgrounds only, not text. */

	/* ---------------------------------------------------------------------
	 * 2a. Medals
	 *
	 * The leaderboard's top three places. Each medal is a fill behind slate
	 * text (5:1 or better), and its tint is a row background only.
	 * ------------------------------------------------------------------ */

	--villa-gold: #d4af37;          /* 5.3:1 behind slate text */
	--villa-gold-tint: #fcf5dc;
	--villa-silver: #c0c7cc;        /* 6.3:1 behind slate text */
	--villa-silver-tint: #f0f2f4;
	--villa-bronze: #e0a46e;        /* 5.0:1 behind slate text */
	--villa-bronze-tint: #fbeee2;

	/* Default accent, overridden per category scope. */
	--category-accent: var(--villa-blue);

	/* ---------------------------------------------------------------------
	 * 3. Semantic colour
	 * ------------------------------------------------------------------ */

	--color-text: var(--villa-slate);
	--color-text-inverse: var(--villa-white);
	--color-muted: var(--villa-grey-mid);

	--color-bg: var(--villa-white);
	--color-surface: var(--villa-off-white);
	--color-surface-raised: var(--villa-white);

	--color-primary: var(--villa-blue);
	--color-primary-hover: var(--villa-blue-dark);
	--color-on-primary: var(--villa-white); /* 9.5:1 on --color-primary */

	--color-accent: var(--villa-red);
	--color-on-accent: var(--villa-white); /* 4.9:1 on --color-accent */

	--color-border: var(--villa-grey);
	--color-border-strong: var(--villa-grey-mid);

	--color-focus: var(--villa-blue);

	/* ---------------------------------------------------------------------
	 * 4. Typography
	 *
	 * Open Sans is self-hosted in assets/css/fonts.css. The system fallbacks
	 * carry the page during the swap period.
	 * ------------------------------------------------------------------ */

	--font-family-base: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	--font-family-heading: var(--font-family-base);
	--font-family-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

	--font-weight-light: 300;
	--font-weight-regular: 400;
	--font-weight-semibold: 600;
	--font-weight-bold: 700;

	/* Fluid modular scale, ~1.2 at the small end widening to ~1.28 at the
	 * large end. Each clamp interpolates between a 360px and a 1280px
	 * viewport; the rem-based minimums keep the scale honest when a user
	 * raises their browser font size. */
	--font-size-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);   /* 12 → 13 */
	--font-size-sm: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);  /* 14 → 15 */
	--font-size-base: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);      /* 16 → 18 */
	--font-size-md: clamp(1.125rem, 1.07rem + 0.28vw, 1.3125rem);  /* 18 → 21 */
	--font-size-lg: clamp(1.375rem, 1.28rem + 0.45vw, 1.625rem);   /* 22 → 26 */
	--font-size-xl: clamp(1.625rem, 1.45rem + 0.85vw, 2.125rem);   /* 26 → 34 */
	--font-size-2xl: clamp(2rem, 1.72rem + 1.4vw, 2.75rem);        /* 32 → 44 */
	--font-size-3xl: clamp(2.375rem, 1.9rem + 2.4vw, 3.5rem);      /* 38 → 56 */

	--line-height-tight: 1.15;  /* Display headings */
	--line-height-snug: 1.3;    /* Sub-headings, UI labels */
	--line-height-base: 1.6;    /* Body copy */
	--line-height-relaxed: 1.75;/* Long-form prose */

	--letter-spacing-tight: -0.01em;
	--letter-spacing-normal: 0;
	--letter-spacing-wide: 0.04em; /* Eyebrows and small caps */

	/* ---------------------------------------------------------------------
	 * 5. Spacing
	 *
	 * 4px base, rem-expressed so it scales with the root font size.
	 * ------------------------------------------------------------------ */

	--space-3xs: 0.25rem; /* 4 */
	--space-2xs: 0.5rem;  /* 8 */
	--space-xs: 0.75rem;  /* 12 */
	--space-sm: 1rem;     /* 16 */
	--space-md: 1.5rem;   /* 24 */
	--space-lg: 2rem;     /* 32 */
	--space-xl: 3rem;     /* 48 */
	--space-2xl: 4rem;    /* 64 */
	--space-3xl: 6rem;    /* 96 */

	/* Fluid vertical rhythm between page sections. */
	--space-section: clamp(2.5rem, 6vw, 6rem);

	/* ---------------------------------------------------------------------
	 * 6. Layout
	 * ------------------------------------------------------------------ */

	--container-max: 80rem;    /* 1280px */
	--container-narrow: 46rem; /* 736px, prose measure */
	--container-gutter: clamp(1rem, 4vw, 2.5rem);

	--z-base: 1;
	--z-dropdown: 100;
	--z-sticky: 200;
	--z-overlay: 300;
	--z-modal: 400;
	--z-skip-link: 500;

	/* ---------------------------------------------------------------------
	 * 7. Border radius
	 * ------------------------------------------------------------------ */

	--radius-xs: 2px;
	--radius-sm: 4px;
	--radius-md: 8px;
	--radius-lg: 16px;
	--radius-pill: 999px;
	--radius-circle: 50%;

	/* ---------------------------------------------------------------------
	 * 8. Elevation
	 *
	 * Tinted with the brand slate rather than neutral black so shadows sit in
	 * the palette instead of greying it down.
	 * ------------------------------------------------------------------ */

	--shadow-xs: 0 1px 2px rgba(39, 65, 73, 0.06);
	--shadow-sm: 0 1px 3px rgba(39, 65, 73, 0.08), 0 1px 2px rgba(39, 65, 73, 0.06);
	--shadow-md: 0 4px 12px rgba(39, 65, 73, 0.1);
	--shadow-lg: 0 12px 32px rgba(39, 65, 73, 0.14);
	--shadow-focus: 0 0 0 3px rgba(0, 61, 165, 0.35);

	/* ---------------------------------------------------------------------
	 * 9. Motion
	 *
	 * animations.js reads --duration-base and mirrors --ease-out with GSAP's
	 * power2.out, so CSS and JS motion stay in step.
	 * ------------------------------------------------------------------ */

	--ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
	--ease-in: cubic-bezier(0.55, 0.06, 0.68, 0.19);
	--ease-in-out: cubic-bezier(0.65, 0.05, 0.36, 1);

	--duration-fast: 150ms;
	--duration-base: 250ms;
	--duration-slow: 400ms;

	/* ---------------------------------------------------------------------
	 * 10. Header bar and navigation
	 *
	 * Exact values from the approved header design. They live here rather than
	 * in header-footer.css so the bar can be retuned in one place, and so the
	 * condense behaviour has a single source of truth that both the stylesheet
	 * and header.js read.
	 * ------------------------------------------------------------------ */

	/* Lines and surfaces specific to the bar. Neither matches --villa-grey
	 * (#dadada), which is heavier than this design wants. */
	--villa-line: #e7e9ea;        /* bar bottom border */
	--villa-line-soft: #f0f1f2;   /* dropdown panel top border */

	/*
	 * Secondary text in the utilities area.
	 *
	 * WARNING: 3.06:1 on white. That clears the 3:1 non-text threshold but FAILS
	 * WCAG AA for body text, which needs 4.5:1. Safe for large text (24px, or
	 * 18.66px bold) and for icons; not safe for small secondary lines. Use
	 * --color-muted (#5b6a70, 5.61:1) where the text is small and must pass AA.
	 */
	--villa-grey-soft: #8b959a;

	--villa-backdrop: rgba(39, 65, 73, 0.45); /* slate, for the drawer scrim */
	--shadow-panel: 0 16px 28px rgba(39, 65, 73, 0.09);

	/*
	 * Pressed red, for the cart button's hover and active states.
	 *
	 * The same value .villa-btn--accent:hover already resolves to in global.css,
	 * where it is produced by color-mix(in srgb, var(--color-accent) 85%,
	 * var(--villa-slate)). Stated literally here because the bar needs it in a
	 * plain background-color and should not depend on color-mix support for a
	 * hover state. 5.98:1 against white text.
	 */
	--villa-red-dark: #c70f1b;

	/*
	 * The cart button's hover needs no token of its own.
	 *
	 * It was a darker slate, --villa-slate-dark: #1b2e34, until the approved
	 * behaviour became a move to Villa blue instead, which --color-primary already
	 * carries. The token was removed rather than left declared and unused. White on
	 * --color-primary is 9.50:1, and the slate resting fill is 10.83:1 against the
	 * white bar, so the button's own edge stays identifiable in both states (1.4.11).
	 */

	/*
	 * Cart line thumbnail. Square, per the cart design, unlike the catalogue card's
	 * 4:3. Section 2.12 of account-checkout.css shrinks it on a narrow screen.
	 */
	--villa-cart-thumb: 8.75rem;

	/* Cart button padding, from the mockup's button metrics. */
	--villa-cart-pad: 9px 15px;

	/* Bar geometry. */
	--villa-bar-max: 1180px;
	--villa-bar-gutter: 40px;
	--villa-bar-gap: 44px;
	--villa-bar-height: 72px;
	--villa-bar-height-condensed: 56px;
	--villa-bar-logo-height: 40px;
	--villa-bar-logo-height-condensed: 30px;

	/* The footer logo keeps its own fluid size: it is not part of the bar and
	 * does not condense. Previously declared in header-footer.css, moved here
	 * when the bar was rebuilt so it sits with the other logo heights. */
	--villa-footer-logo-height: clamp(2rem, 1.75rem + 1vw, 2.5rem);

	/* Scroll distance after which the bar condenses. header.js reads this
	 * property so the threshold is not duplicated in JavaScript. */
	--villa-condense-threshold: 40px;

	/*
	 * The bar expands again below this, not below the threshold above. The gap
	 * between the two is a dead zone, and it is what stops the bar pulsing when
	 * someone scrolls back and forth near the top of the page. See section 1 of
	 * header.js for the measurements that produced these numbers.
	 *
	 * Must stay lower than --villa-condense-threshold. header.js falls back to
	 * half the threshold if it is not.
	 */
	--villa-condense-release: 8px;

	/*
	 * Clearance for anything else that pins itself: the product gallery and the
	 * FAQ category rail.
	 *
	 * It must clear the bar as it is WHEN SCROLLED, which is the only time a
	 * sticky element is pinned, so it is measured from the CONDENSED height, not
	 * --villa-bar-height. Getting this wrong is quiet: the element still sticks,
	 * it just sits behind the bar, which reads as "it does not stay in place" and
	 * clips anything positioned near its top edge, such as the gallery's zoom
	 * button.
	 *
	 * Use this token rather than writing the sum again. Two elements previously
	 * hardcoded their own and both were short.
	 *
	 * The admin bar is folded in here rather than in a body.admin-bar override.
	 * WordPress enqueues admin-bar.css, and with it
	 * --wp-admin--admin-bar--height, ONLY when the bar is actually rendered, so
	 * the fallback of 0px is what applies for everyone else. Note this differs
	 * from the 32px fallback used elsewhere in the theme: those rules are already
	 * scoped to body.admin-bar, where the bar is known to exist. This one is not.
	 *
	 * It matters in practice because an administrator sees the bar and a staff
	 * member does not, so a hardcoded offset is correct for exactly one of them.
	 */
	--villa-sticky-offset: calc(
		var(--wp-admin--admin-bar--height, 0px) +
		var(--villa-bar-height-condensed) +
		var(--space-lg)
	);

	/* Dropdown panel. One token carries the asymmetric block padding. */
	--villa-panel-gap: 64px;
	--villa-panel-column-min: 150px;
	--villa-panel-pad-block: 22px 26px;

	/* Mobile drawer. */
	--villa-drawer-width: 85%;
	--villa-drawer-max: 360px;

	/* Nav type. Sizes are fixed px by design: the bar must not reflow with the
	 * fluid body scale. */
	--font-size-nav: 13.5px;
	--font-size-nav-link: 13px;
	--font-size-nav-label: 11px;
	--letter-spacing-nav: 0.01em;
	--letter-spacing-nav-label: 0.09em;

	/* Bar condense and drawer slide. */
	--duration-condense: 0.22s;
}

/**
 * Reduced motion.
 *
 * Zeroing the duration tokens at the root makes every token-driven transition
 * and animation instant, so individual components do not each need to repeat
 * the media query. animations.js watches the same query for GSAP.
 */
@media (prefers-reduced-motion: reduce) {
	:root {
		--duration-fast: 0ms;
		--duration-base: 0ms;
		--duration-slow: 0ms;

		/* The bar condense and the drawer slide both time off this, so zeroing it
		 * makes each of them instant rather than animated. */
		--duration-condense: 0s;
	}
}
