/**
 * Tier 2 - Semantic tokens (intent). Components consume these via Tailwind @theme.
 * Tier 3 - Component aliases at bottom (hub card, prototype controller).
 */
:root {
  /* Surfaces */
  --puk-semantic-surface-canvas: var(--puk-primitive-warm-white);
  --puk-semantic-surface-subtle: var(--puk-primitive-light-navy);
  --puk-semantic-surface-card: var(--puk-primitive-white);
  --puk-semantic-surface-elevated: var(--puk-primitive-white);

  /** Native inputs, textareas, selects in their resting editable state. */
  --puk-semantic-field-control-surface: var(--puk-semantic-surface-card);
  /** Native inputs, textareas, selects when `[disabled]` (or read-only later). */
  --puk-semantic-field-disabled-surface: var(--puk-primitive-neutral-100);

  /**
   * Text
   *   default - brand navy. Reserved for headings (h1, h2), the "Step X"
   *             number, review-value <dd>, card titles, and other top-of-
   *             hierarchy emphasis. Matches the live site's heading colour
   *             convention.
   *   muted   - neutral dark grey. The DEFAULT body / supporting-copy
   *             colour: paragraphs, hints, form labels, "(optional)" tags,
   *             secondary card text, `<strong>` runs inside body copy
   *             (inherited from the parent <p>). The name is historical;
   *             this is now functionally `text-body` matching
   *             `--body_typography-color` on the live site.
   */
  --puk-semantic-text-default: var(--puk-primitive-dark-navy);
  --puk-semantic-text-muted: var(--puk-primitive-text-body);
  --puk-semantic-text-inverse: var(--puk-primitive-warm-white);
  --puk-semantic-text-on-inverse: var(--puk-primitive-warm-white);

  /* Interactive (brand-wide primary actions, links, primary buttons) */
  --puk-semantic-interactive-primary: var(--puk-primitive-mid-navy);
  --puk-semantic-interactive-primary-hover: var(--puk-primitive-dark-navy);
  --puk-semantic-interactive-on-primary: var(--puk-primitive-white);

  /* Borders (solid rgba for broad browser support; avoid color-mix in tokens) */
  --puk-semantic-border-default: rgb(5 20 74 / 0.12);
  --puk-semantic-border-strong: rgb(5 20 74 / 0.22);
  /* A stronger, clearly-visible line (e.g. the step-timeline connector). */
  --puk-semantic-border-emphasis: rgb(5 20 74 / 0.5);
  --puk-semantic-border-interactive: rgb(28 43 112 / 0.55);

  /* Focus (visible ring; verify 3:1 vs adjacent on focus) */
  --puk-semantic-focus-ring: var(--puk-primitive-mid-navy);
  --puk-semantic-focus-ring-offset: var(--puk-primitive-white);

  /* Icons */
  --puk-semantic-icon-muted: rgb(28 43 112 / 0.72);
  --puk-semantic-icon-strong: var(--puk-primitive-dark-navy);

  /* Feedback */
  --puk-semantic-feedback-error: var(--puk-primitive-error-red);

  /* Consent / legal agreement pattern */
  --puk-semantic-consent-surface: var(--puk-primitive-consent-yellow-surface);
  --puk-semantic-consent-border: var(--puk-primitive-consent-yellow-border);
  --puk-semantic-consent-text: var(--puk-primitive-consent-yellow-text);
  --puk-semantic-upload-surface: var(--puk-primitive-light-navy);
  --puk-semantic-upload-border: var(--puk-primitive-upload-blue-border);

  /* Layout max width (hub content column) */
  --puk-semantic-layout-content-max: 40rem;

  /* Density (mobile-first; step at md) */
  --puk-space-page-inline: var(--puk-primitive-space-4);
  --puk-space-page-block: var(--puk-primitive-space-12);
  --puk-space-section-gap: var(--puk-primitive-space-8); /* 32 - between sections inside a step */
  --puk-space-stack-gap: var(--puk-primitive-space-3);
  --puk-space-card-padding: var(--puk-primitive-space-5);
  --puk-space-hub-card-inner-gap: var(--puk-primitive-space-5);
  /** Pill → title vertical offset on hub prototype cards. */
  --puk-space-hub-card-title-margin-top: var(--puk-primitive-space-5);
  --puk-space-fab-inset: var(--puk-primitive-space-5);

  /* Registration step rhythm (one canonical token per role) */
  --puk-space-step-head-stack: var(--puk-primitive-space-3); /* 12 - StepHead title <-> description */
  --puk-space-step-head-end: var(--puk-primitive-space-8); /* 32 - StepHead bottom (header <-> body) */
  --puk-space-step-section-head: var(--puk-primitive-space-5); /* 20 - SectionLabel <-> first child */
  --puk-space-step-nav-top: var(--puk-primitive-space-12); /* 48 - body <-> NavRow */

  /* Radius / shadow semantic */
  --puk-semantic-radius-card: var(--puk-primitive-radius-lg);
  --puk-semantic-radius-pill: var(--puk-primitive-radius-pill);
  --puk-semantic-shadow-elevated: var(--puk-primitive-shadow-card);

  /**
   * Type weight (intent-based). Components should consume these — not the primitives
   * and not Tailwind's stock `font-medium` / `font-semibold` / `font-bold` utilities.
   *
   *   body     - default paragraph copy
   *   label    - quiet emphasis (checkbox / radio labels, single-line micro-headings)
   *   emphasis - strong emphasis (field labels, h2 sub-section headings, sub-card titles)
   *   strong   - top-of-hierarchy (h1 page titles, `<strong>` runs, back-link)
   */
  --puk-semantic-font-weight-body: var(--puk-primitive-font-weight-regular);
  --puk-semantic-font-weight-label: var(--puk-primitive-font-weight-medium);
  --puk-semantic-font-weight-emphasis: var(--puk-primitive-font-weight-semibold);
  --puk-semantic-font-weight-strong: var(--puk-primitive-font-weight-bold);

  /**
   * Monospace numeric / code fields (`Input` with `mono`): digit separation
   * without approaching display caps-lock spacing.
   */
  --puk-semantic-letter-spacing-mono-input: var(--puk-primitive-letter-spacing-mono-input);

  /* Tier 3 - Component */
  --puk-component-prototype-controller-surface: var(--puk-semantic-surface-elevated);
  --puk-component-prototype-controller-border: var(--puk-semantic-border-default);
  --puk-component-prototype-controller-shadow: var(--puk-semantic-shadow-elevated);
  --puk-component-prototype-controller-link-gap: var(--puk-primitive-layout-prototype-controller-link-gap);

  /* InfoCard (Tier 3) - warm-white surface; dark/mid navy text per contrast matrix */
  --puk-component-info-card-surface: var(--puk-semantic-surface-canvas); /* warm-white #FFFAF7 */
  --puk-component-info-card-border: var(--puk-semantic-border-default);
  --puk-component-info-card-title: var(--puk-semantic-text-default); /* dark navy, > 12:1 on warm white */
  --puk-component-info-card-description: var(--puk-semantic-text-muted); /* mid navy, > 9:1 on warm white */
  --puk-component-info-card-icon: var(--puk-semantic-text-default); /* dark navy, > 12:1 on warm white */
  /** Vertical gap between title and description (one primitive step below step-head stack). */
  --puk-component-info-card-title-description-gap: var(--puk-primitive-space-2);
  /** Gap between paragraphs inside the description (~half a blank line at sm body size). */
  --puk-component-info-card-paragraph-gap: var(--puk-primitive-space-3);

  /**
   * IntroCard (Tier 3) - hero spotlight for the registration intro screen.
   * Mid-green surface, white copy, larger radius; contrast in `docs/contrast-matrix.md`.
   */
  --puk-component-intro-card-surface: var(--puk-primitive-mid-green);
  --puk-component-intro-card-foreground: var(--puk-primitive-white);
  --puk-component-intro-card-radius: var(--puk-primitive-radius-xl);

  /**
   * Progress bar (registration shell) — full-width track is a solid fill
   * (light navy), not a bordered empty capsule; completed segment uses
   * default heading / emphasis navy.
   */
  --puk-component-progress-bar-track: var(--puk-semantic-surface-subtle);
  --puk-component-progress-bar-fill: var(--puk-semantic-text-default);

  /** Payment screen — carrier mark framing (`radius-sm` / 4px primitive). */
  --puk-component-payment-carrier-radius: var(--puk-primitive-radius-sm);

  /**
   * Summary list (NHS summary list–inspired; review + confirmation screens).
   * https://service-manual.nhs.uk/design-system/components/summary-list
   */
  --puk-component-summary-list-border: var(--puk-semantic-border-default);
  --puk-component-summary-list-surface: var(--puk-semantic-surface-card);
  --puk-component-summary-list-divider: var(--puk-component-summary-list-border);
  --puk-component-summary-list-key-color: var(--puk-semantic-text-muted);
  --puk-component-summary-list-value-color: var(--puk-semantic-text-default);
  /** Vertical rhythm per row cell (key, value, actions). */
  --puk-component-summary-list-cell-padding-block: var(--puk-primitive-space-6);
  /** Extra inset at the start of the key column (left). */
  --puk-component-summary-list-key-padding-inline-start: var(--puk-primitive-space-5);
  /** Extra inset at the end of the actions column (right), and trailing edge for value-only rows. */
  --puk-component-summary-list-actions-padding-inline-end: var(--puk-primitive-space-5);
  --puk-component-summary-list-key-value-gap: var(--puk-primitive-space-4);
  /** Below `sm`, label + Change row → value row: total vertical space between rows (no double cell padding). */
  --puk-component-summary-list-mobile-label-value-gap: var(--puk-primitive-space-4);
  --puk-component-summary-list-key-column-default: 20rem;
  --puk-component-summary-list-key-column-compact: 10rem;

  /**
   * Process step marker — dot variant (loose sequence): outer ring + inner fill.
   * Outer matches timeline “bubble”; inner is brand navy.
   */
  --puk-component-process-step-dot-outer: var(--puk-semantic-surface-subtle);
  --puk-component-process-step-dot-inner: var(--puk-semantic-text-default);

  /**
   * Help tooltip — navy circular trigger, dark popover with inverse copy.
   */
  --puk-component-help-tooltip-trigger-surface: var(--puk-semantic-interactive-primary);
  --puk-component-help-tooltip-trigger-icon: var(--puk-semantic-interactive-on-primary);
  --puk-component-help-tooltip-popover-surface: var(--puk-semantic-interactive-primary-hover);
  --puk-component-help-tooltip-popover-text: var(--puk-semantic-text-inverse);

  /**
   * Button (Tier 3): default block padding is `py-3.5` (0.875rem) plus one
   * step of `--puk-primitive-space-1` on top and bottom for slightly more
   * vertical breathing room. Inline padding matches the previous `px-5`.
   */
  --puk-component-button-padding-block-default: calc(0.875rem + var(--puk-primitive-space-1));
  --puk-component-button-padding-inline-default: var(--puk-primitive-space-5);
  /**
   * Compact button — optional `size="sm"` on `<Button>`; tighter axis padding
   * and `text-puk-sm`; `min-h-11` is unchanged so the 44px touch minimum holds.
   */
  --puk-component-button-padding-block-sm: calc(0.5rem + var(--puk-primitive-space-1));
  --puk-component-button-padding-inline-sm: var(--puk-primitive-space-4);
}

[data-puk-theme="dark"] {
  /* Surfaces */
  --puk-semantic-surface-canvas: var(--puk-primitive-invert-surface-canvas);
  --puk-semantic-surface-subtle: var(--puk-primitive-invert-surface-page);
  --puk-semantic-surface-card: var(--puk-primitive-invert-surface-card);
  --puk-semantic-surface-elevated: var(--puk-primitive-invert-surface-elevated);

  --puk-semantic-field-control-surface: var(--puk-primitive-invert-field-control-surface);
  --puk-semantic-field-disabled-surface: var(--puk-primitive-invert-field-disabled-surface);

  /* Text */
  --puk-semantic-text-default: var(--puk-primitive-warm-white);
  --puk-semantic-text-muted: var(--puk-primitive-invert-text-body);
  --puk-semantic-text-inverse: var(--puk-primitive-dark-navy);
  --puk-semantic-text-on-inverse: var(--puk-primitive-dark-navy);

  /* Interactive */
  --puk-semantic-interactive-primary: var(--puk-primitive-mid-purple);
  --puk-semantic-interactive-primary-hover: var(--puk-primitive-light-purple);
  --puk-semantic-interactive-on-primary: var(--puk-primitive-dark-navy);

  /* Borders */
  --puk-semantic-border-default: var(--puk-primitive-invert-border-default);
  --puk-semantic-border-strong: var(--puk-primitive-invert-border-strong);
  --puk-semantic-border-emphasis: var(--puk-primitive-invert-border-strong);
  --puk-semantic-border-interactive: var(--puk-primitive-mid-purple);

  /* Focus */
  --puk-semantic-focus-ring: var(--puk-primitive-mid-purple);
  --puk-semantic-focus-ring-offset: var(--puk-primitive-invert-surface-card);

  /* Icons */
  --puk-semantic-icon-muted: var(--puk-primitive-invert-text-muted);
  --puk-semantic-icon-strong: var(--puk-primitive-warm-white);

  /* Feedback */
  --puk-semantic-feedback-error: var(--puk-primitive-invert-error-red);

  /* Consent / legal agreement pattern */
  --puk-semantic-consent-surface: var(--puk-primitive-invert-consent-surface);
  --puk-semantic-consent-border: var(--puk-primitive-invert-consent-border);
  --puk-semantic-consent-text: var(--puk-primitive-invert-consent-text);
  --puk-semantic-upload-surface: var(--puk-primitive-invert-upload-blue-surface);
  --puk-semantic-upload-border: var(--puk-primitive-invert-upload-blue-border);

  /* Radius / shadow semantic */
  --puk-semantic-shadow-elevated: none;

  /* Tier 3 - Component */
  --puk-component-prototype-controller-surface: var(--puk-semantic-surface-elevated);
  --puk-component-prototype-controller-border: var(--puk-semantic-border-default);
  --puk-component-prototype-controller-shadow: none;

  --puk-component-info-card-surface: var(--puk-semantic-surface-elevated);
  --puk-component-info-card-border: var(--puk-semantic-border-default);
  --puk-component-info-card-title: var(--puk-semantic-text-default);
  --puk-component-info-card-description: var(--puk-semantic-text-muted);
  --puk-component-info-card-icon: var(--puk-semantic-text-default);

  --puk-component-intro-card-surface: var(--puk-primitive-mid-green);
  --puk-component-intro-card-foreground: var(--puk-primitive-white);

  --puk-component-progress-bar-track: var(--puk-semantic-surface-elevated);
  --puk-component-progress-bar-fill: var(--puk-semantic-interactive-primary);

  --puk-component-summary-list-border: var(--puk-semantic-border-default);
  --puk-component-summary-list-surface: var(--puk-semantic-surface-card);
  --puk-component-summary-list-divider: var(--puk-component-summary-list-border);
  --puk-component-summary-list-key-color: var(--puk-semantic-text-muted);
  --puk-component-summary-list-value-color: var(--puk-semantic-text-default);

  --puk-component-process-step-dot-outer: var(--puk-semantic-surface-elevated);
  --puk-component-process-step-dot-inner: var(--puk-semantic-interactive-primary);

  --puk-component-help-tooltip-trigger-surface: var(--puk-semantic-interactive-primary);
  --puk-component-help-tooltip-trigger-icon: var(--puk-semantic-interactive-on-primary);
  --puk-component-help-tooltip-popover-surface: var(--puk-semantic-interactive-primary-hover);
  --puk-component-help-tooltip-popover-text: var(--puk-semantic-text-inverse);
}

@media (min-width: 48rem) {
  :root {
    --puk-space-page-inline: var(--puk-primitive-space-6);
    --puk-space-page-block: var(--puk-primitive-space-16);
    --puk-space-section-gap: var(--puk-primitive-space-10); /* 40 at md+ */
    --puk-space-stack-gap: var(--puk-primitive-space-4);
    --puk-space-card-padding: var(--puk-primitive-space-8);
    --puk-space-hub-card-inner-gap: var(--puk-primitive-space-6);
    --puk-space-step-head-end: var(--puk-primitive-space-10); /* 40 at md+ */
  }
}
