/* Design tokens shared by every app. App stylesheets use these, never literal colors. */
:root {
  /* Visual colors: references to the SAPER roles defined below (OD-UI-001, Claro: OD-UI-002). */
  --color-text: var(--saper-ink-body);
  --color-text-muted: var(--saper-ink-muted);
  --color-page: var(--saper-surface); /* page background */
  --color-surface: var(--saper-surface-raised); /* tiles, cart lines, controls */
  --color-surface-alt: var(--saper-surface); /* cart panel, catalog messages */
  --color-border: var(--saper-line-strong); /* borders of controls and cards */
  --color-divider: var(--saper-line); /* decorative separators only */
  --color-primary: var(--saper-primary);
  --color-primary-text: var(--saper-on-primary);
  --color-focus: var(--saper-focus-ring);
  --color-heading: var(--saper-ink); /* headings */
  --color-qr-surface: var(--saper-white); /* the wallet QR panel stays white around the quiet zone */
  --color-accent: var(--saper-soft-gold); /* gold: accent and graphics only, never text on light */

  /*
   * Operational state colors (OD-UI-003), on the SAPER Claro palette restored by OD-UI-014.
   * Palette references, not theme roles: Verde is never applied. Every pair reaches 4.5:1, and
   * every state keeps its words, so state is never conveyed by color alone.
   */
  --color-warning-surface: var(--saper-soft-gold); /* test mode, unknown, rate limit: 5.12:1 */
  --color-warning-text: var(--saper-brunette);
  --color-error-surface: var(--saper-brunette); /* declined, not charged, errors: 12.50:1 */
  --color-error-text: var(--saper-off-white);
  --color-success-surface: var(--saper-green-field); /* approved, confirmed: 7.76:1 */
  --color-success-text: var(--saper-off-white);
  --color-disabled-surface: var(--saper-line-light); /* 5.56:1, plus a dashed border */
  --color-disabled-text: var(--saper-green-field);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /*
   * Typefaces, vendored locally and declared in base.css: Bodoni Moda for headings (saper.club,
   * OD-UI-012, superseding Literata of OD-UI-004) and Lato for the interface and the POS figures.
   */
  --font-family: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-family-heading: "Bodoni Moda", Georgia, "Times New Roman", serif;
  --font-size-small: 0.875rem; /* 14 px, line 20 px */
  --font-size-base: 1rem; /* 16 px, line 24 px */
  --font-size-large: 1.25rem;
  --font-size-xlarge: 1.5rem; /* also the POS heading maximum, 24 px */

  /*
   * saper.club type scale (OD-UI-012): fluid from a 360 px phone to a 1280 px desktop, in rem plus
   * vw so it still follows the user's font size. Line heights are the pairs Miguel approved.
   */
  --font-size-h1: clamp(2rem, 1.413rem + 2.6087vw, 3.5rem); /* 32 -> 56 px */
  --line-height-h1: clamp(2.25rem, 1.712rem + 2.3913vw, 3.625rem); /* 36 -> 58 px */
  --font-size-h2: clamp(1.625rem, 1.2826rem + 1.5217vw, 2.5rem); /* 26 -> 40 px */
  --line-height-h2: clamp(1.875rem, 1.5326rem + 1.5217vw, 2.75rem); /* 30 -> 44 px */
  --font-size-h3: clamp(1.3125rem, 1.1413rem + 0.7609vw, 1.75rem); /* 21 -> 28 px */
  --line-height-h3: clamp(1.625rem, 1.4293rem + 0.8696vw, 2.125rem); /* 26 -> 34 px */
  --font-size-figure: clamp(2.75rem, 2.3587rem + 1.7391vw, 3.75rem); /* 44 -> 60 px */
  --line-height-figure: clamp(3rem, 2.6087rem + 1.7391vw, 4rem); /* 48 -> 64 px */
  --font-size-lead: clamp(1.125rem, 1.0761rem + 0.2174vw, 1.25rem); /* 18 -> 20 px */
  --line-height-lead: clamp(1.625rem, 1.5761rem + 0.2174vw, 1.75rem); /* 26 -> 28 px */
  --line-height-base: 1.5rem;
  --line-height-small: 1.25rem;
  --heading-letter-spacing: -0.02em; /* serif headings are set slightly tight */

  /* saper.club buttons (OD-UI-012): pills with small, tracked capitals in Lato Bold. */
  --font-size-button: 0.875rem; /* 14 px: small, still readable in daylight */
  --button-font-weight: 700;
  --button-letter-spacing: 0.14em; /* about 2 px at 14 px */

  --radius: 0.125rem; /* SAPER small radius for controls and cards (OD-UI-005) */
  --radius-large: 1.5rem; /* 24 px cards, such as the wallet QR panel */
  --radius-pill: 999px; /* every action button and badge (OD-UI-012) */
  --touch-target-min: 2.75rem; /* 44 CSS px */
  --focus-ring-width: 2px; /* OD-UI-012, from 3 px; every ring color reaches 3:1 */
  --focus-ring-offset: 2px;

  /*
   * UI v2 motion tokens, exact values from design/ui-proposals/v2.html, approved by Miguel on
   * 2026-10-02 (OD-UI-006). Durations and curves only: nothing animates here. Reduced motion is
   * honored by the global prefers-reduced-motion rule in base.css.
   */
  --motion-press: 120ms; /* button press */
  --motion-quick: 180ms; /* state changes, messages */
  --motion-sheet: 280ms; /* sheets entering and leaving */
  --motion-moment: 520ms; /* the approval moment */
  --motion-ease: cubic-bezier(.2, .7, .2, 1);
  --motion-ease-out: cubic-bezier(.16, 1, .3, 1);

  /* Brand rule, not a layout size: the logo is shown at 115 px wide or more (OD-UI-006). */
  --brand-logo-min-width: 115px;

  /* Phone cart sheet (ui-v2-cart-sheet, OD-UI-006): derived from the palette, no new color. */
  --color-scrim: color-mix(in srgb, var(--saper-brunette) 45%, transparent);
  --shadow-sheet: 0 -0.25rem 1rem color-mix(in srgb, var(--saper-brunette) 20%, transparent);

  /* Focus ring on the green approval surface: off-white, 7.76:1 (ui-v2-charge-sheet, OD-UI-014). */
  --color-focus-on-success: var(--saper-off-white);

  /*
   * Dark green admin sidebar (admin-shell-v2, OD-UI-007), back on the Claro primary green
   * (OD-UI-014), used as a surface, not the Verde theme. Ratios: text 7.76:1 and muted text 5.56:1
   * on the surface, text 5.73:1 on the active surface, gold indicator 3.18:1 and off-white focus
   * 7.76:1 on the surface.
   */
  --color-nav-surface: var(--saper-green-field);
  --color-nav-text: var(--saper-off-white);
  --color-nav-text-muted: var(--saper-muted-verde);
  --color-nav-active-surface: color-mix(in srgb, var(--saper-off-white) 12%, var(--saper-green-field));
  --color-nav-indicator: var(--saper-soft-gold);
  --color-nav-focus: var(--saper-off-white);
  --nav-width-desk: 20rem; /* desk sidebar, so the vertical imagotype fits at 280 px */
  --brand-sidebar-logo-width: 17.5rem; /* 280 px: white vertical imagotype on the desk sidebar */
}

/*
 * SAPER visual direction, approved by the user on 2026-10-02 (OD-UI-001). The initial theme is
 * Claro, chosen the same day (OD-UI-002). On 2026-10-03 Miguel adopted saper.club buttons, headings
 * and type scale (OD-UI-012) and then restored the SAPER Claro colors (OD-UI-014): off-white page,
 * white cards, brunette body text, gold as an accent only. Spacing and the type scale stay in rem so they follow the font
 * size. Verde is defined below and never applied: no selector, no script and no automatic switch.
 *
 * Palette: exact values, defined once.
 */
:root {
  --saper-green-field: #414f24;
  --saper-soft-gold: #bc945b;
  --saper-off-white: #eff0ef;
  --saper-pistachio: #6f8566;
  --saper-olive-grass: #404e39;
  --saper-brunette: #3f231e;
  --saper-white: #ffffff;
  --saper-muted-light: #56664e;
  --saper-muted-verde: #c9cfbf;
  --saper-line-light: #c9cfbf;
  --saper-line-strong-verde: #a9b59c;
}

/*
 * Semantic roles per theme, from the palette only. Text roles reach 4.5:1 and the focus ring and
 * the strong line 3:1 on the surfaces they are used on; `line` is decorative.
 * Claro applies by default (the :root selector), so a page that forgets the attribute still gets
 * its colors, and through the data-saper-theme hook, which each app sets on its root element.
 */
:root,
:root[data-saper-theme="claro"] {
  --saper-surface: var(--saper-off-white);
  --saper-surface-raised: var(--saper-white);
  --saper-ink: var(--saper-green-field);
  --saper-ink-body: var(--saper-brunette);
  --saper-ink-muted: var(--saper-muted-light);
  --saper-line: var(--saper-line-light);
  --saper-line-strong: var(--saper-pistachio);
  --saper-primary: var(--saper-green-field);
  --saper-on-primary: var(--saper-off-white);
  --saper-focus-ring: var(--saper-green-field);
  color-scheme: light;
}

/* Defined for later; nothing sets data-saper-theme="verde". */
:root[data-saper-theme="verde"] {
  --saper-surface: var(--saper-green-field);
  --saper-surface-raised: var(--saper-olive-grass);
  --saper-ink: var(--saper-off-white);
  --saper-ink-body: var(--saper-off-white);
  --saper-ink-muted: var(--saper-muted-verde);
  --saper-line: var(--saper-pistachio);
  --saper-line-strong: var(--saper-line-strong-verde);
  --saper-primary: var(--saper-soft-gold);
  --saper-on-primary: var(--saper-brunette);
  --saper-focus-ring: var(--saper-soft-gold);
  color-scheme: dark;
}
