/*
 * UI-001 proposed tokens. Palette values follow the current site green (owner decision 2026-11-16).
 * Layer 1: primitives (raw palette and scales) — never referenced by components.
 * Layer 2: semantic roles — what components use. Existing --gs-* names are kept
 * so the canonical website/design/tokens.css can be replaced in place.
 * Surfaces (.gs-surface-inverse, .gs-surface-light) remap the semantic roles,
 * so the same component markup works on paper and on forest.
 */
:root {
  /* Tool layout geometry contracts, shared by article and standalone renderers. */
  --gs-tool-inset: max(var(--gs-space-1), min(var(--gs-space-5), 10vw - var(--gs-space-4)));
  --gs-tool-gutter: max(var(--gs-space-1), min(var(--gs-gutter), 10vw - var(--gs-space-4)));
  /* App illustration colours stay recognisable across site themes. */
  --gs-forest-125: #d8ebdf;
  --gs-clay-125: #f7e2d5;
  --gs-mist-125: #d9eaf3;
  --gs-paper-125: #eae1f3;
  --gs-color-diagram-diaphragm: #17695f;
  --gs-color-diagram-diaphragm-fill: #d7efeb;
  --gs-color-diagram-floor: #9a442a;
  --gs-color-illustration-plan: var(--gs-forest-125);
  --gs-color-illustration-care: var(--gs-clay-125);
  --gs-color-illustration-change: var(--gs-mist-125);
  --gs-color-illustration-history: var(--gs-paper-125);
  /* Primitives: forest scale */
  --gs-forest-950: #10170e;
  --gs-forest-900: #1b2716;
  --gs-forest-800: #26361f;
  --gs-forest-700: #314329;
  --gs-forest-600: #445c37;
  --gs-forest-500: #4d6242;
  --gs-forest-400: #66795a;
  --gs-forest-300: #93a482;
  --gs-forest-200: #c2d1b4;
  --gs-line-200: #cdd5c4;   /* current site border */
  --gs-forest-150: #d9e2cf;
  --gs-forest-100: #e0e7d7;
  --gs-forest-50: #eef1e8;
  /* Primitives: paper and ink */
  --gs-paper-100: #ffffff;
  --gs-paper-50: #ffffff;
  --gs-ink-900: #171d14;
  --gs-ink-600: #5d6954;
  --gs-ink-550: #5f6b57;
  --gs-forest-850: #3a4b33;
  --gs-forest-350: #8a977d;
  --gs-forest-650: #4c5d44;
  --gs-mist-50: #f4f5ee;
  --gs-mist-100: #e9eedf;
  --gs-mist-300: #c3cfb8;
  /* Primitive: the single warm accent, reserved for the wordmark mark */
  --gs-clay-300: #e0a37f;
  --gs-clay-600: #a5512b;

  /* Shared primitive state/decoration scales. */
  --gs-neutral-0: #ffffff;
  --gs-neutral-900: #111111;
  --gs-neutral-400: #999999;
  --gs-text-wordmark: clamp(1.5rem, 1.2rem + 1.5vw, 1.875rem);
  --gs-tracking-eyebrow: .06em;
  --gs-tracking-wordmark: -.06em;
  --gs-current-bar: 2px;
  --gs-current-rail: 3px;
  --gs-text-decoration-strong: 2px;
  --gs-print-canvas: var(--gs-neutral-0);
  --gs-print-text: var(--gs-neutral-900);
  --gs-print-border: var(--gs-neutral-400);

  /* Typography */
  --gs-font-body: 'DM Sans', Arial, sans-serif;
  --gs-font-heading: Manrope, Arial, sans-serif;
  --gs-text-xs: .8125rem;   /* 13px: metadata only, never body or controls */
  --gs-text-sm: .875rem;    /* 14px: footer notes, captions */
  --gs-text-md: 1rem;       /* 16px: controls, navigation, UI body */
  --gs-text-lg: 1.125rem;   /* 18px: reading body, leads */
  --gs-text-xl: 1.375rem;
  --gs-text-2xl: clamp(1.625rem, 1.3rem + 1.2vw, 2rem);
  --gs-text-3xl: clamp(2rem, 1.45rem + 2.2vw, 2.875rem);
  --gs-text-4xl: clamp(2.5rem, 1.5rem + 4vw, 4.5rem);
  --gs-leading-tight: 1.1;
  --gs-leading-snug: 1.3;
  --gs-leading-body: 1.65;
  --gs-tracking-display: -.045em;
  --gs-tracking-heading: -.02em;
  --gs-weight-regular: 400;
  --gs-weight-medium: 500;
  --gs-weight-bold: 700;

  /* Spacing: 4px base; existing names keep their existing values */
  --gs-space-1: .25rem;
  --gs-space-2: .5rem;
  --gs-space-3: .75rem;
  --gs-space-4: 1rem;
  --gs-space-5: 1.25rem;
  --gs-space-6: 1.5rem;
  --gs-space-8: 2rem;
  --gs-space-10: 2.5rem;
  --gs-space-12: 3rem;
  --gs-space-16: 4rem;

  /* Shape, layout and motion */
  --gs-radius-sm: .25rem;
  --gs-radius-card: .375rem;
  --gs-radius-md: .5rem;
  --gs-radius-control: 999px;
  --gs-key-depth: 3px;          /* app keycap edge under buttons; pressed buttons move down by it */
  --gs-border-width: 1px;
  --gs-content-width: 80rem;   /* 1280px */
  --gs-gutter: clamp(1rem, .5rem + 2.5vw, 1.5rem);
  --gs-control-height: 2.75rem; /* 44px, grows with text size */
  --gs-focus-width: 3px;
  --gs-focus-offset: 3px;
  --gs-duration-fast: 120ms;
}

/* Semantic roles: light (paper) surface is the default. */
:root,
.gs-surface-light,
.gs-analytics-choices,
body.gs-unified .hero :is(.demo-canvas,.hero-preview),
body.gs-unified .whole-picture .care-panel {
  --gs-color-canvas: var(--gs-paper-100);
  --gs-color-surface: var(--gs-paper-50);
  --gs-color-soft: var(--gs-forest-100);
  --gs-color-sage: var(--gs-forest-150);
  --gs-color-text: var(--gs-ink-900);
  --gs-color-text-muted: var(--gs-ink-600);
  --gs-color-border: var(--gs-line-200);
  --gs-color-border-strong: var(--gs-forest-400);
  --gs-color-brand: var(--gs-forest-500);
  --gs-color-on-brand: var(--gs-mist-50);
  --gs-color-mark: var(--gs-clay-600);
  --gs-color-link: var(--gs-forest-700);
  --gs-color-action: var(--gs-forest-700);
  --gs-color-action-hover: var(--gs-forest-600);
  --gs-color-action-pressed: var(--gs-forest-900);
  --gs-color-on-action: var(--gs-mist-50);
  --gs-color-secondary-bg: transparent;
  --gs-color-secondary-hover: var(--gs-forest-100);
  --gs-color-current: var(--gs-forest-700);
  --gs-color-disabled-bg: var(--gs-forest-50);
  --gs-color-disabled-text: var(--gs-ink-550);
  --gs-color-disabled-border: var(--gs-forest-200);
  --gs-color-focus: var(--gs-forest-950);
  --gs-color-notice-bg: var(--gs-forest-50);
  --gs-color-notice-rule: var(--gs-forest-500);

  /* Aliases consumed unchanged by dist/assets/measurement/choices.css */
  --gs-content-primary: var(--gs-color-text);
  --gs-surface-raised: var(--gs-color-surface);
  --gs-border-default: var(--gs-color-border-strong);
}

/* Inverse (forest) surface: header, footer, dark hero. */
.gs-surface-inverse,
body.gs-unified :is(.whole-picture,.closing.wrap,.offer,.rs-recognition),
body.gs-unified:has(#hero-title) .hero.wrap {
  --gs-color-canvas: var(--gs-forest-950);
  --gs-color-surface: var(--gs-forest-900);
  --gs-color-soft: var(--gs-forest-800);
  --gs-color-sage: var(--gs-forest-800);
  --gs-color-text: var(--gs-mist-100);
  --gs-color-text-muted: var(--gs-mist-300);
  --gs-color-border: var(--gs-forest-850);
  --gs-color-border-strong: var(--gs-forest-300);
  --gs-color-mark: var(--gs-clay-300);
  --gs-color-link: var(--gs-mist-100);
  --gs-color-action: var(--gs-mist-100);
  --gs-color-action-hover: var(--gs-neutral-0);
  --gs-color-action-pressed: var(--gs-forest-150);
  --gs-color-on-action: var(--gs-forest-950);
  --gs-color-secondary-bg: transparent;
  --gs-color-secondary-hover: var(--gs-forest-800);
  --gs-color-current: var(--gs-clay-300);
  --gs-color-disabled-bg: transparent;
  --gs-color-disabled-text: var(--gs-forest-350);
  --gs-color-disabled-border: var(--gs-forest-650);
  --gs-color-focus: var(--gs-mist-100);
  --gs-color-notice-bg: var(--gs-forest-900);
  --gs-color-notice-rule: var(--gs-forest-300);
}

/* Legacy names kept during migration; remove once no page uses them. */
:root {
  --gs-color-dark: var(--gs-forest-950);
  --gs-color-on-dark: var(--gs-mist-100);
  --gs-color-dark-muted: var(--gs-mist-300);
}

/* UI-002 form and card roles and geometry. */
:root {
  /* Primitives: a dedicated error red, separate from the brand palette (GOV.UK, NHS, USWDS and
     Material all keep error red distinct from brand colour). Values follow Material 3's error tones;
     the clay accent stays reserved for the wordmark mark. */
  --gs-red-700: #b3261e;
  --gs-red-200: #f2b8b5;
  --gs-red-50: #fdeceb;

  /* Geometry */
  --gs-border-width-strong: 2px;     /* invalid field and error rule: state shown by weight, not hue alone */
  --gs-choice-size: 1.25rem;         /* native checkbox/radio box; the row itself keeps the 44px target */
  --gs-field-width-short: 12rem;     /* date and other short fixed-format values */
  --gs-field-width-medium: 24rem;    /* email, search: one line of expected input */
  --gs-measure-form: 36rem;          /* a single-column form never stretches wider than this */
  --gs-textarea-min-height: 7.5rem;  /* about four lines at 16px/1.65 */
  --gs-card-min: 17rem;              /* collection column minimum before wrapping */
  --gs-card-media-ratio: 16 / 9;     /* optional card image; images are cropped, never stretched */
}

:root,
.gs-surface-light {
  --gs-color-field-bg: var(--gs-paper-50);
  --gs-color-error: var(--gs-red-700);        /* 5.92:1 on canvas, 6.29:1 on surface, 5.72:1 on error-bg */
  --gs-color-error-bg: var(--gs-red-50);
}

.gs-surface-inverse {
  --gs-color-field-bg: var(--gs-forest-900);
  --gs-color-error: var(--gs-red-200);        /* 10.69:1 on forest-950, 9.12:1 on forest-900 */
  --gs-color-error-bg: var(--gs-forest-900);
}

/* UI-003 floating shell and shared layouts. */
:root {
  /* Section frame (carried from UI-003) */
  --gs-section-space: clamp(3rem, 2rem + 4vw, 6rem);
  --gs-section-space-compact: clamp(2rem, 1.5rem + 2vw, 3.5rem);
  --gs-width-narrow: 48rem;          /* tools and reading contexts */
  --gs-measure-lead: 46rem;          /* replaces the literal in .gs-lead */

  /* Floating header geometry */
  --gs-float-inset: var(--gs-space-3);          /* gap between viewport edge and the floating bar */
  --gs-float-width: 72rem;                      /* bar never spans wider than this */
  --gs-float-pad: var(--gs-space-2);            /* inner padding around the control row */
  /* Header block height: two insets + two pads + one control row (grows with text size). */
  --gs-header-block: calc(var(--gs-control-height) + 2 * var(--gs-float-pad) + 2 * var(--gs-float-inset));
  --gs-anchor-offset: calc(var(--gs-header-block) + var(--gs-space-4));

  /* Panels: hero frame, floating menu panel, section media */
  --gs-radius-panel: 1.5rem;
  --gs-section-media-ratio: 4 / 3;
}

/* Elevation and media-fallback roles, light (paper) mapping. */
:root,
.gs-surface-light {
  --gs-color-shadow: color-mix(in srgb, var(--gs-forest-950) 12%, transparent);
  --gs-color-shadow-ring: var(--gs-line-200); /* hairline edge that does not rely on the shadow or blur */
  --gs-shadow-float: 0 0 0 var(--gs-border-width) var(--gs-color-shadow-ring), 0 .75rem 2rem var(--gs-color-shadow);
  --gs-color-float-bg: var(--gs-color-surface);   /* opaque: never depends on backdrop blur */
  --gs-color-media-fallback: var(--gs-color-sage);
}

/* Inverse mapping: forest bands and inverse panels. */
.gs-surface-inverse {
  --gs-color-shadow: #00000066;
  --gs-color-shadow-ring: #e9eedf1f;
  --gs-color-float-bg: var(--gs-color-surface);
  --gs-color-media-fallback: var(--gs-color-soft);
}

:root { --gs-menu-room: calc(100dvh - var(--gs-header-block) - var(--gs-space-4)); }
