/* =====================================================================
 * THE ROCK — shared design tokens.
 *
 * Single source of truth for colour, typography, spacing and surface
 * treatment across every UI in the system: kiosk wall, cash-up app,
 * tip station, admin, EPOS (when it lands).
 *
 * Importing pages put <link rel="stylesheet" href="/assets/tokens.css">
 * in their <head> BEFORE any per-page styles. This file only declares
 * variables on :root — it doesn't paint anything. Per-page styles read
 * the variables to compose their look.
 *
 * Why CSS vars not Sass: lets us flip dark→light at runtime by toggling
 * a single attribute on <html>, no recompile, no FOUC. Same approach
 * the cash-up app already uses; this just centralises it.
 *
 * Naming convention:
 *   --bg            page background
 *   --surface       primary card / panel surface
 *   --surface2      secondary surface (nested cards, hover states)
 *   --border        subtle line between surfaces
 *   --border2       slightly stronger line for emphasis
 *   --fg            primary text
 *   --fg-dim        de-emphasised text (labels, hints, metadata)
 *   --muted         placeholder / disabled / "not yet configured"
 *   --accent        the Rock gold (logo, hover focus, primary CTA)
 *   --accent-hover  pressed/hover state for primary buttons
 *   --tip-green     success states (paid, OK, connected)
 *   --danger        errors, destructive actions
 *   --warn          variance alerts, "needs attention" banners
 *   --loros         LOROS hospice donation accent (charity branding)
 *   --mono          monospace stack for receipts, hex codes, IDs
 *   --display       Handel Gothic — for branding and PIN keypad keys
 *   --body          system stack — UI text
 *
 * The Handel Gothic font is hosted at /assets/handel-gothic.ttf and
 * gets a single @font-face declaration here so every consumer page
 * picks it up without redefining it.
 * ===================================================================== */

@font-face {
  font-family: 'Handel Gothic';
  src: url('/assets/handel-gothic.ttf?v=2') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  /* --- Typography --- */
  --display: 'Handel Gothic', 'Helvetica Neue', sans-serif;
  --body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text',
             'Segoe UI', Roboto, sans-serif;
  --mono:    'SF Mono', Menlo, Consolas, 'Courier New', monospace;

  /* --- Brand --- */
  --accent:       #d4a017;       /* Rock gold — the colour from the logo, the slides, the warm wood of the bar */
  --accent-hover: #b8860b;
  --accent-fg:    #1a1a1a;       /* text colour on top of --accent (gold buttons) */
  --tip-green:    #2ecc71;
  --loros:        #d4a017;       /* same as accent — LOROS branding fits */
  --warn:         #e8a020;
  --danger:       #cf5c5c;
  --info:         #4a9eff;

  /* -------------------------------------------------------------
     SITE THEME OVERRIDE
     -------------------------------------------------------------
     The brand values above are the Rock's. A second venue sets
     html[data-site="boar"] and only the brand block changes —
     everything else (surfaces, sizing, typography) is shared, so a
     new site is a palette, not a stylesheet.

     Applied by assets/branding.js from the /api/v1/branding endpoint,
     alongside the trading name it already paints. Absent attribute =
     the Rock, so nothing changes at a venue that never sets it.

     Blue Boar values sampled from the pub's own artwork
     (boar_scroll.webp): #0271bb is the boar itself, #c9e9f7 the
     highlight strokes on the fur and tusks, #e5e5e5 the scroll text.
     ------------------------------------------------------------- */

  /* --- Sizing --- */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);

  /* PIN keypad consumer hooks — set on :root so the keypad inherits
     the surface vars without each consumer page having to wire them
     manually. The keypad component reads these names. */
  --pinpad-font:         var(--body);
  --pinpad-display-font: var(--display);
}

/* =====================================================================
   THE BLUE BOAR
   Sampled from the pub's artwork rather than picked by eye:
     #0271bb  the boar — primary
     #c9e9f7  highlight strokes (fur, tusks)
     #e5e5e5  scroll lettering
   The linework in the logo is near-black, which is why the shared dark
   surfaces suit it without alteration.
   ===================================================================== */
html[data-site="boar"] {
  /* Bitter (SIL OFL) stands in for the pub's Clarendon, which cannot be
     served publicly — see deploy/boar/board/fonts/README.md. The Rock
     keeps Handel Gothic; only the Boar overrides.

     Not self-hosted here yet: the POS surfaces would need the woff2
     copying into public/assets/fonts and an @font-face block. Listed
     first so it takes effect the moment it is, and falls through to the
     shared stack until then. */
  --display:      'Bitter', 'Handel Gothic', 'Helvetica Neue', sans-serif;

  --accent:       #0271bb;
  --accent-hover: #0a86d8;
  /* Measured: white on this blue is 5.14:1, near-black 3.38:1. Both
     clear AA for large text, but white is the clearly better pairing —
     so unlike the Rock's gold, which takes dark text, this accent
     takes LIGHT foreground text. */
  --accent-fg:    #ffffff;
  --brand-tint:   #c9e9f7;
  --brand-paper:  #e5e5e5;
  --info:         #4aa8ff;
}


/* --- Dark theme (default) ----------------------------------------- */
:root,
:root[data-theme="dark"] {
  --bg:        #0d0d0d;
  --surface:   #161616;
  --surface2:  #232323;
  --border:    #2a2a2a;
  --border2:   #3a3a3a;
  --fg:        #f5f0e8;
  --fg-dim:    #a8998a;
  --muted:     #5a5245;

  /* PIN keypad in dark mode */
  --pinpad-surface:   var(--surface);
  --pinpad-fg:        var(--fg);
  --pinpad-border:    var(--border);
  --pinpad-muted:     var(--muted);
  --pinpad-key-bg:    var(--surface2);
  --pinpad-key-hover: #2c2c2c;
  --pinpad-accent:    var(--accent);
  --pinpad-danger:    var(--danger);

  /* Staff personal colours.
   *
   * Used on staff chips + login tiles to give each person a colour
   * for quick visual identification at the till. Picked for high
   * contrast against the dark surface AND distinguishable from each
   * other even at small chip sizes (~80×30px).
   *
   * Token keys MUST match the ACCENT_COLORS list in
   * services/admin/staff-colors.js — if they drift, chips will fall
   * back to the default gold accent. */
  /* 30 colours: two 15-hue RINGS on the same wheel, bright and deep,
   * not 30 points on one ring — a single ring cannot hold 30
   * distinguishable colours (measured: worst pair fell to 18 RGB units,
   * imperceptible, before reaching 20). The deep ring alternates
   * lightness/saturation between adjacent hues rather than being
   * uniformly darker, because flat darkening compresses everything
   * toward black and LOSES separation.
   *
   * Verified: RGB Euclidean distance on every adjacent pair and on all
   * 435 pairwise combinations (worst case 37, crimson vs rust), cross-
   * checked with CIE76 deltaE — the closer-to-perceptual metric — which
   * scored the same pair at 25 and amber/gold at 29, both clear of the
   * ~10 threshold generally used for "tell apart at a glance". */
  --staff-red:      #e35858;
  --staff-orange:   #e38658;
  --staff-amber:    #e3b558;
  --staff-gold:     #e3e358;
  --staff-lime:     #a9e358;
  --staff-green:    #6fe358;
  --staff-emerald:  #58e37b;
  --staff-teal:     #58e3b5;
  --staff-cyan:     #58d8e3;
  --staff-sky:      #589ee3;
  --staff-blue:     #5863e3;
  --staff-indigo:   #8658e3;
  --staff-violet:   #c058e3;
  --staff-purple:   #e358cc;
  --staff-magenta:  #e35892;
  --staff-crimson:  #9a4f1d;
  --staff-rust:     #7a611e;
  --staff-olive:    #919a1d;
  --staff-mustard:  #557a1e;
  --staff-moss:     #349a1d;
  --staff-forest:   #1e7a34;
  --staff-jade:     #1d9a6e;
  --staff-pine:     #1e747a;
  --staff-ocean:    #1d5d9a;
  --staff-navy:     #1e277a;
  --staff-cobalt:   #441d9a;
  --staff-plum:     #611e7a;
  --staff-grape:    #9a1d87;
  --staff-wine:     #7a1e46;
  --staff-berry:    #9a1d1f;
  --staff-slate:    #8a99ad;
}

/* --- Light theme -------------------------------------------------- */
:root[data-theme="light"] {
  --bg:        #faf7f0;
  --surface:   #ffffff;
  --surface2:  #f5f1ea;
  --border:    #d4d0c8;
  --border2:   #b8b3a8;
  --fg:        #1a1a1a;
  --fg-dim:    #5a5245;
  --muted:     #8a7a60;

  --accent:       #b8860b;
  --accent-hover: #9a720a;
  --accent-fg:    #ffffff;

  /* PIN keypad in light mode */
  --pinpad-surface:   var(--surface);
  --pinpad-fg:        var(--fg);
  --pinpad-border:    var(--border);
  --pinpad-muted:     var(--muted);
  --pinpad-key-bg:    var(--surface2);
  --pinpad-key-hover: #ebe6dd;
  --pinpad-accent:    var(--accent);
  --pinpad-danger:    var(--danger);

  /* Staff palette in light theme.
   *
   * Slightly darker than the dark-theme equivalents so they read
   * cleanly against the cafe's cream surface. Same hue family —
   * `'blue'` is recognisably the same person across themes. */
  /* Same two-ring structure as dark, but re-derived and re-verified for
   * this theme rather than reusing dark's lightness values directly —
   * a light background compresses the usable range and the first
   * attempt at carrying dark's numbers over only cleared ~29 (below the
   * ~35 bar). Found by a small parameter search: worst adjacent pair
   * 40, worst of all 435 pairs 39, faintest swatch still 76/255 below
   * white so every circle reads as filled rather than washing out. */
  --staff-red:      #be2121;
  --staff-orange:   #be5621;
  --staff-amber:    #be8a21;
  --staff-gold:     #bebe21;
  --staff-lime:     #7dbe21;
  --staff-green:    #3bbe21;
  --staff-emerald:  #21be48;
  --staff-teal:     #21be8a;
  --staff-cyan:     #21b1be;
  --staff-sky:      #2170be;
  --staff-blue:     #212ebe;
  --staff-indigo:   #5621be;
  --staff-violet:   #9721be;
  --staff-purple:   #be21a4;
  --staff-magenta:  #be2163;
  --staff-crimson:  #974f20;
  --staff-rust:     #705a1e;
  --staff-olive:    #8f9720;
  --staff-mustard:  #4f701e;
  --staff-moss:     #369720;
  --staff-forest:   #1e7031;
  --staff-jade:     #20976d;
  --staff-pine:     #1e6a70;
  --staff-ocean:    #205d97;
  --staff-navy:     #1e2670;
  --staff-cobalt:   #452097;
  --staff-plum:     #5a1e70;
  --staff-grape:    #972085;
  --staff-wine:     #701e41;
  --staff-berry:    #972022;
  --staff-slate:    #5a6878;
}

/* --- Auto-light when the OS asks for it (and no explicit theme set) ----- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg:        #faf7f0;
    --surface:   #ffffff;
    --surface2:  #f5f1ea;
    --border:    #d4d0c8;
    --border2:   #b8b3a8;
    --fg:        #1a1a1a;
    --fg-dim:    #5a5245;
    --muted:     #8a7a60;
    --accent:       #b8860b;
    --accent-hover: #9a720a;
    --accent-fg:    #ffffff;
    --pinpad-surface:   var(--surface);
    --pinpad-fg:        var(--fg);
    --pinpad-border:    var(--border);
    --pinpad-muted:     var(--muted);
    --pinpad-key-bg:    var(--surface2);
    --pinpad-key-hover: #ebe6dd;
    --pinpad-accent:    var(--accent);
  }
}

/* --- Utility resets that every UI wants -------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Brand text class — for "THE ROCK" wordmarks etc. */
.brand-display {
  font-family: var(--display);
  letter-spacing: 0.04em;
}
