/* ============================================================================
   rsociety — Brand Identity & Design System Tokens ("The Mint")
   Canonical source: docs/brand/RSOCIETY-BRAND.md
   Architecture: One obsidian-slate & bone-ivory house, six material tab rooms.
   WCAG AA verified: every text/surface pair >= 4.5:1 (primary >= 15:1).
   Zero purple/indigo glow, zero drop-shadows at rest, zero gradients on UI.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. Font Loading Reference
   Production shell should self-host Cabinet Grotesk (500, 700, 800) and
   General Sans (400, 500, 600, 700) as .woff2 under /fonts/.
   Verified Fontshare stylesheet (OFL / ITF Free Font License):
   https://api.fontshare.com/v2/css?f[]=cabinet-grotesk@500,700,800&f[]=general-sans@400,500,600,700&display=swap
   ---------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  /* ── Brand Core Palette (Neutral Obsidian Slate + Struck Brass + Bone Paper) ── */
  --rs-void: #0B0C0A;          /* Deepest outer frame / full-screen stage backing */
  --rs-ground: #111210;        /* Primary page ground (70-90% of viewport) */
  --rs-surface: #1A1B18;       /* Elevated card / nav bar / panel (+4 L* step) */
  --rs-surface-hi: #242621;    /* Hover / active plate / interactive recess (+8 L*) */
  --rs-surface-pressed: #2D302A;

  /* ── Ink Hierarchy (Archival Limestone Bone — neutral, never sterile #FFF or yellow cream) ── */
  --rs-ink: #F2F1ED;           /* Primary text, headlines, live figures (17.7:1 on ground) */
  --rs-ink-soft: #C5C3BC;      /* Secondary descriptions, inactive nav labels (10.7:1) */
  --rs-ink-quiet: #95938C;     /* Metadata, units, timestamps, placeholders (6.2:1) */

  /* ── Tactile Paper Surface (Passkey ticket, receipts, recovery words, plaques) ── */
  --rs-paper: #F2F1ED;         /* Archival bone-stone slip */
  --rs-paper-alt: #E5E3DD;     /* Recessed paper cell / input on paper */
  --rs-on-paper: #111210;      /* Obsidian ink on paper (17.7:1) */
  --rs-on-paper-soft: #474642; /* Secondary ink on paper (8.7:1) */

  /* ── House Primary Accent (Struck Brass — MINE & default shell accent) ── */
  --rs-brass: #D9A441;         /* Struck bullion brass (8.6:1 on ground) */
  --rs-brass-hi: #E8BC62;      /* Hover / lit brass peak (10.9:1 on ground) */
  --rs-brass-deep: #9C7225;    /* Structural brass trim / engraved rule */
  --rs-on-brass: #111210;      /* Ink on brass CTA (9.1:1) */

  /* ── Active Tab Accent (overridden cleanly by [data-tab="..."]) ── */
  --rs-accent: var(--rs-brass);
  --rs-accent-hi: var(--rs-brass-hi);
  --rs-on-accent: var(--rs-on-brass);
  --rs-accent-wash: rgba(217, 164, 65, 0.12);
  --rs-tab-ground: var(--rs-ground);
  --rs-tab-surface: var(--rs-surface);

  /* ── Semantic Status (CVD-safe pairs — always paired with sign or label) ── */
  --rs-good: #49B886;          /* Positive delta / live / backed up (8.4:1 on ground) */
  --rs-on-good: #0D1511;       /* Ink on good fill (8.9:1) */
  --rs-good-wash: rgba(73, 184, 134, 0.14);
  --rs-warn: #F09A36;          /* Pending / attention / mining active (8.8:1 on ground) */
  --rs-on-warn: #111210;       /* Ink on warn fill (9.2:1) */
  --rs-bad: #E56B6F;           /* Error / negative delta / risk (6.5:1 on ground) */
  --rs-on-bad: #140B0B;        /* Ink on bad fill (6.8:1) */
  --rs-bad-wash: rgba(229, 107, 111, 0.14);
  --rs-info: #6B9EFF;          /* Neutral highlight / secondary series (7.5:1 on ground) */

  /* ── Borders & Focus (Tone steps first; crisp 1px seams only for real UI) ── */
  --rs-hair: rgba(244, 240, 230, 0.12);
  --rs-hair-strong: rgba(244, 240, 230, 0.24);
  --rs-focus: var(--rs-accent);
  --rs-backdrop: rgba(11, 12, 10, 0.82);

  /* ── Typography ── */
  --rs-font-display: 'Cabinet Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --rs-font-ui: 'General Sans', 'Helvetica Neue', Arial, sans-serif;
  --rs-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Five clear scale steps — big things big, small things crisp, zero mush */
  --rs-text-display: clamp(2.5rem, 1.4rem + 4.4vw, 4.75rem);   /* 40px -> 76px hero */
  --rs-text-head: clamp(1.625rem, 1.25rem + 1.4vw, 2.5rem);    /* 26px -> 40px section */
  --rs-text-title: clamp(1.1875rem, 1.08rem + 0.4vw, 1.375rem);/* 19px -> 22px card/panel */
  --rs-text-body: 1rem;                                         /* 16px body & controls */
  --rs-text-label: 0.875rem;                                    /* 14px nav, tabs, table */
  --rs-text-small: 0.75rem;                                     /* 12px units, timestamps */

  --rs-figure-hero: clamp(2.25rem, 1.5rem + 3vw, 3.5rem);      /* 36px -> 56px balance/FDV */
  --rs-figure-kpi: clamp(1.375rem, 1.2rem + 0.6vw, 1.75rem);   /* 22px -> 28px KPIs */

  --rs-lh-display: 0.96;
  --rs-lh-head: 1.08;
  --rs-lh-body: 1.5;
  --rs-lh-tight: 1.2;

  --rs-track-display: -0.035em;
  --rs-track-head: -0.02em;
  --rs-track-wordmark: -0.03em;
  --rs-track-caps: 0.08em;

  /* ── Spacing Scale (4px base unit) ── */
  --rs-sp-1: 4px;
  --rs-sp-2: 8px;
  --rs-sp-3: 12px;
  --rs-sp-4: 16px;
  --rs-sp-5: 24px;
  --rs-sp-6: 32px;
  --rs-sp-7: 48px;
  --rs-sp-8: 64px;
  --rs-sp-9: 96px;

  /* ── Layout & Touch Targets ── */
  --rs-max: 1360px;
  --rs-gutter: clamp(16px, 2.5vw, 32px);
  --rs-nav-h: 64px;
  --rs-tabs-h: 64px;
  --rs-tap: 44px;              /* Minimum WCAG/Impeccable interactive target */
  --rs-tap-main: 52px;         /* Primary action button height */

  /* ── Radii (Architectural & Crisp — never bubbly 16px pillows everywhere) ── */
  --rs-r-none: 0px;            /* Artwork, card plates (D-242), full-bleed bands */
  --rs-r-sm: 4px;              /* Inputs, buttons, chips, small badges */
  --rs-r-md: 8px;              /* Panels, drawers, slips, modals */
  --rs-r-pill: 999px;          /* Status dots & live wallet pill only */

  /* ── Elevation (Tone steps at rest; subtle offset shadow ONLY on floating overlays) ── */
  --rs-shadow-none: none;
  --rs-shadow-float: 0 12px 32px rgba(0, 0, 0, 0.48);

  /* ── Motion (Decisive, physical, never bouncy; reduced-motion removes travel) ── */
  --rs-ease-out: cubic-bezier(0.22, 0.72, 0.18, 1);
  --rs-ease-in: cubic-bezier(0.4, 0, 1, 1);
  --rs-ease-move: cubic-bezier(0.35, 0, 0.25, 1);
  --rs-t-micro: 90ms;
  --rs-t-fast: 150ms;
  --rs-t-base: 240ms;
  --rs-t-slow: 420ms;
}

/* ============================================================================
   2. Per-Tab Material Subthemes
   One shared obsidian-and-ivory house; six rooms with distinct pigment,
   subtle surface tint, craft texture, and ambient motion character.
   Apply via data-tab="<id>" on <main>, .shell, or a tab container.
   ============================================================================ */

/* EDGE — House Casino: Struck Brass & Smoked Bronze Slate (Knurled Dial) */
[data-tab='edge'] {
  --rs-accent: #D9A441;
  --rs-accent-hi: #E8BC62;
  --rs-on-accent: #111210;
  --rs-accent-wash: rgba(217, 164, 65, 0.13);
  --rs-tab-ground: #12110E;
  --rs-tab-surface: #1C1A15;
  --rs-tab-motif: repeating-linear-gradient(
    90deg,
    rgba(217, 164, 65, 0.32) 0 1px,
    transparent 1px 12px
  );
}

/* RAKE — Live Tables & Poker: Club Baize Emerald & Tournament Spruce */
[data-tab='rake'] {
  --rs-accent: #3DB882;
  --rs-accent-hi: #58CE99;
  --rs-on-accent: #0B1510;
  --rs-accent-wash: rgba(61, 184, 130, 0.13);
  --rs-tab-ground: #0E1411;
  --rs-tab-surface: #151F1A;
  --rs-tab-motif: repeating-linear-gradient(
    -45deg,
    rgba(61, 184, 130, 0.05) 0 2px,
    transparent 2px 10px
  );
}

/* MYTH — Ten-Mythology Card Game: Burnished Carmine + Gilded Foil Bridge
   (Never places frames or rounded corners on card artwork itself — D-242.) */
[data-tab='myth'] {
  --rs-accent: #E36957;        /* 6.1:1 on ground; large/button & text safe */
  --rs-accent-hi: #EF8575;
  --rs-on-accent: #140C0A;     /* 5.9:1 on #E36957 */
  --rs-accent-2: #DFB45F;      /* MYTH Gilded foil bridge */
  --rs-accent-wash: rgba(227, 105, 87, 0.14);
  --rs-tab-ground: #141110;
  --rs-tab-surface: #1E1917;
  --rs-tab-motif: linear-gradient(
    90deg,
    #E36957 0 28%,
    transparent 28% 30%,
    #DFB45F 30% 62%,
    transparent 62% 64%,
    rgba(244, 240, 230, 0.25) 64% 100%
  );
}

/* ART — Limited Generative Art Drops: Pure Gallery Charcoal + Cobalt Mark */
[data-tab='art'] {
  --rs-accent: #6B9EFF;        /* 7.5:1 on charcoal */
  --rs-accent-hi: #8EB6FF;
  --rs-on-accent: #0B111C;     /* 7.4:1 on #6B9EFF */
  --rs-accent-wash: rgba(107, 158, 255, 0.13);
  --rs-tab-ground: #131416;    /* Zero warm/cool cast: artwork colours read true */
  --rs-tab-surface: #1B1D20;
  --rs-tab-motif: radial-gradient(
    rgba(244, 240, 230, 0.06) 1px,
    transparent 0
  );
}

/* MINE — Free Browser & Android Mining: Molten Amber & Foundry Iron */
[data-tab='mine'] {
  --rs-accent: #F09A36;        /* 8.8:1 on ground */
  --rs-accent-hi: #F6B25E;
  --rs-on-accent: #140F09;     /* 9.2:1 on #F09A36 */
  --rs-accent-wash: rgba(240, 154, 54, 0.14);
  --rs-tab-ground: #13110E;
  --rs-tab-surface: #1D1914;
  --rs-tab-motif: repeating-linear-gradient(
    180deg,
    rgba(240, 154, 54, 0.08) 0 1px,
    transparent 1px 16px
  );
}

/* TRADE — MINE/USD Market: Ledger Steel-Cyan & Cool Slate Graphite */
[data-tab='trade'] {
  --rs-accent: #4CB8C4;        /* 8.9:1 on ground */
  --rs-accent-hi: #70CDD7;
  --rs-on-accent: #0B1517;     /* 9.3:1 on #4CB8C4 */
  --rs-accent-wash: rgba(76, 184, 196, 0.13);
  --rs-tab-ground: #0F1315;
  --rs-tab-surface: #171D20;
  --rs-tab-motif: repeating-linear-gradient(
    180deg,
    rgba(244, 240, 230, 0.06) 0 1px,
    transparent 1px 36px
  );
}

/* ============================================================================
   3. Shell Compatibility Bridge (for app/platform/shell adoption)
   Maps legacy --adit-* and --c-* names cleanly onto rsociety tokens so
   downstream lane rsociety-apply-identity can drop this file in with zero
   broken selectors while retiring indigo-violet Adit colours.
   ============================================================================ */
:root {
  --c-page: var(--rs-tab-ground);
  --c-page-deep: var(--rs-void);
  --c-surface: var(--rs-tab-surface);
  --c-surface-hi: var(--rs-surface-hi);
  --plate: var(--rs-tab-surface);
  --c-plate: var(--rs-tab-surface);
  --c-text: var(--rs-ink);
  --c-text-dim: var(--rs-ink-soft);
  --c-accent: var(--rs-accent);
  --c-on-accent: var(--rs-on-accent);
  --c-gold: var(--rs-brass);
  --c-on-gold: var(--rs-on-brass);
  --c-panel: var(--rs-paper);
  --c-on-panel: var(--rs-on-paper);
  --c-good: var(--rs-good);
  --c-on-good: var(--rs-on-good);
  --c-hot: var(--rs-bad);
  --c-on-hot: var(--rs-on-bad);
  --c-focus: var(--rs-focus);
  --hair: var(--rs-hair);
  --foot-bg: var(--rs-surface);
  --foot-fg: var(--rs-ink-quiet);
  --r-1: var(--rs-r-sm);
  --r-2: var(--rs-r-md);
  --r-round: var(--rs-r-pill);
  --sp-1: var(--rs-sp-1);
  --sp-2: var(--rs-sp-2);
  --sp-3: var(--rs-sp-3);
  --sp-4: var(--rs-sp-4);
  --sp-5: var(--rs-sp-5);
  --sp-6: var(--rs-sp-6);
  --sp-7: var(--rs-sp-7);
  --sp-8: var(--rs-sp-8);
  --t-fast: var(--rs-t-fast);
  --t-base: var(--rs-t-base);
  --t-slow: var(--rs-t-slow);
  --ease-out: var(--rs-ease-out);
}

/* ============================================================================
   4. Shared Numerals, Focus & Reduced-Motion Guarantees (Impeccable Floor)
   ============================================================================ */
.rs-num,
.num {
  font-variant-numeric: tabular-nums lining-nums;
}

:focus-visible {
  outline: 2px solid var(--rs-focus);
  outline-offset: 2px;
}

::selection {
  background: var(--rs-accent);
  color: var(--rs-on-accent);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

:root[data-still] *,
:root[data-still] *::before,
:root[data-still] *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
}
