/* ================================================================
   Klaros — Design tokens (single source of truth)

   Every uni-cloud surface loads this FIRST, then its own stylesheet:
     creator-dashboard.html -> tokens.css + dashboard.css
     page.css pages         -> tokens.css + page.css
     content.css pages      -> tokens.css + content.css

   Before this file existed the token block was copied into dashboard.css,
   page.css and content.css, and had already drifted: --radius was 8px in the
   app and 12px on marketing pages, so the same card had different corners
   depending which surface you were on. Change a value HERE, once.

   Load it with <link>, never @import. An @import cannot start downloading
   until the file containing it has been fetched and parsed.
   ================================================================ */

:root {
  /* Tells the browser to paint its OWN widgets (checkboxes, radios, range tracks,
     select popups, scrollbars, date pickers) in the matching scheme. Without it those stay
     stubbornly light on a dark page no matter what CSS says, because they are UA-rendered. */
  color-scheme: light;

  /* —— Surfaces —— */
  --bg: #f8f9fa;
  --bg-body: var(--bg);
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e9ecef;
  /* Behind QR art, in every theme: cameras need dark modules on a light ground. Never redefine
     this in a dark block. */
  --qr-ground: #ffffff;
  --bg-surface: var(--surface);
  --bg-surface-elevated: var(--surface-2);
  --bg-subtle: var(--surface-2);

  /* —— Lines —— */
  --border: #e5e7eb;
  --border-light: #d1d5db;
  --border-subtle: var(--border);

  /* —— Text —— */
  --text: #111827;
  --text-primary: var(--text);
  --text-secondary: #4b5563;
  --dim: #6b7280;

  /* —— Brand: green is Klaros (send / success / brand) —— */
  --primary: #059669;
  --channel-instagram: #c13584; /* Instagram messages and routes in the inbox */
  --primary-dark: #047857;
  --primary-glow: rgba(5, 150, 105, 0.10);

  /* —— Accent —— */
  --accent: #6d28d9;
  --accent-glow: rgba(124, 58, 237, 0.10);

  /* —— Semantic: amber is ACTION, red is failure, blue is information —— */
  --amber: #d97706;
  --amber2: #f59e0b;
  --red: #dc2626;
  --error: var(--red);
  --blue: #3b82f6;

  /* —— Editorial accents: brass and verdigris ——
     Added for the long-form customer strategy guides, which need a warm accent and an aged-green
     counterpart. Neither --amber (ACTION) nor --primary (BRAND) should be borrowed for this:
     using the action colour for decorative rules teaches readers the wrong thing about what is
     clickable. Declared here rather than inlined on the page, per the rule at the top of this file. */
  --brass: #8f6522;
  --brass-tint: #f0e4cf;
  --verdigris: #3d6153;
  --verdigris-tint: #dfe9e3;
  /* Focus/attention rings for the semantic pair, matching --primary-glow's job and opacity. A
     translucent ring cannot come from --danger-bg/--warn-bg (those are opaque fills), so without
     these the only way to ring a card in red was a pasted rgba literal. */
  --red-glow: rgba(220, 38, 38, 0.10);
  --amber-glow: rgba(217, 119, 6, 0.10);

  /* The moving knob of a toggle switch. Deliberately near-white in BOTH themes — a switch knob
     reads as a physical object sliding on a coloured track, so it does not invert with the
     surface; naming it stops that intent looking like a stray #fff someone forgot. */
  --switch-knob: #ffffff;
  --switch-knob-shadow: rgba(0, 0, 0, 0.28);

  /* Text/icons sitting ON a --primary fill (badges, solid buttons). Unlike the knob above this
     one DOES flip: --primary is a deep green on light but a bright #10b981 on dark, where white
     text drops to roughly 2.4:1. Pinning it to #fff — which 22 places in dashboard.css currently
     do by hand — is therefore a contrast bug on dark, not just an un-named colour. */
  --on-primary: #ffffff;

  /* —— External brand constants ——
     WhatsApp's green is WhatsApp's. It must not follow our palette or our theme — a mockup of the
     WhatsApp UI is wrong if it is Klaros green, and it stays the same green on dark. Deliberately
     has NO dark override for that reason. Named so it reads as a decision rather than a stray hex,
     which is the only thing separating it from the literals this sweep removed. */
  --whatsapp-green: #25d366;
  --on-whatsapp: #ffffff;

  /* —— Status tints ——
     Callout blocks (success / warning / danger / info) were built from raw
     Tailwind-ish hex in three different stylesheets: #ecfdf5 alone appeared
     11 times in dashboard.css. Naming them is what lets those surfaces have a
     dark theme at all, since a hardcoded #ecfdf5 panel stays glaring white. */
  --ok-bg: #ecfdf5;
  --ok-bg-2: #f0fdf9;
  --ok-border: #a7f3d0;
  --ok-fg: #047857;

  --warn-bg: #fef3c7;
  --warn-border: #fde68a;
  --warn-fg: #92400e;

  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-fg: #991b1b;
  --danger-fg-strong: #b91c1c;

  --info-bg: #eff6ff;
  --info-border: #93c5fd;
  --info-fg: #1e40af;

  /* —— Gradients —— */
  --gradient-primary: linear-gradient(135deg, #059669, #047857);
  --gradient-accent: linear-gradient(135deg, #6d28d9, #7c3aed);
  --gradient-warm: linear-gradient(135deg, #d97706, #ea580c);

  /* —— Elevation —— */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(5, 150, 105, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  /* Behind a side sheet or a modal: dims the page without hiding it. */
  --scrim: rgba(10, 22, 16, 0.38);
  /* A label laid over a photo (a slide count, "Cover"): the photo is the same in either theme, so one value. */
  --media-badge-bg: rgba(0, 0, 0, 0.6);
  --media-badge-fg: #ffffff;

  /* —— Radius: ONE scale product-wide ——
     Resolved to the app's 8/6/4 rather than the marketing 12/8/6: dashboard.css
     consumed these 54 times against page.css's 15, and 8px was already the
     de-facto product radius (hardcoded 40 times). */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  /* —— Type ——
     Three faces, three jobs: Fraunces displays, Inter reads, Plex Mono holds
     data (phone numbers, API keys, IDs). Named so a phone number in the inbox
     and one in the contact panel cannot drift apart. */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* The background the walkthrough videos are rendered on (scripts/build-extension-video.mjs),
     so the letterbox around a player matches its frames in every theme. */
  --video-letterbox: #0b0f19;

  /* —— Type scale ——
     dashboard.css alone carried 79 distinct font-size values across 623 declarations, 26 of
     them used exactly once. Thirty of those sat between 0.6rem and 0.98rem, where the step
     between 0.72rem and 0.73rem is 0.15px: invisible, so it was never a decision, just
     someone needing "a bit smaller".

     These eight cover every real use. Root is 15px, so the px equivalents are in comments.
     Use them for new work and convert files as you touch them. Deliberately NOT applied by
     sweep: a global find-replace would change hundreds of rendered sizes in one unreviewable
     commit.

     Floor: any text INPUT must be >= 16px at mobile widths or iOS Safari zooms the page on
     focus and never zooms back. See the mobile block at the end of dashboard.css.

     TWO ROOTS, so the px equivalents above are only true on one of them. The dashboard sets
     root to 15px; the marketing pages never do, so they inherit the browser default of 16px and
     every --text-* there renders ~6.7% larger (--text-md is 14.3px in the dashboard and 15.2px
     on /pricing). Both are fine — the scale still keeps sizes relative to each other, which is
     the point — but do not read the comments as absolute px when working on marketing. */
  --text-2xs: 0.68rem;   /* 10.2px — micro labels, badge counts */
  --text-xs: 0.72rem;    /* 10.8px — dense metadata, timestamps */
  --text-sm: 0.8rem;     /* 12px   — secondary text, chips */
  --text-base: 0.86rem;  /* 12.9px — body text in dense UI */
  --text-md: 0.95rem;    /* 14.3px — comfortable body */
  --text-lg: 1.1rem;     /* 16.5px — card titles */
  --text-xl: 1.4rem;     /* 21px   — section headings */
  --text-2xl: 1.9rem;    /* 28.5px — page titles */

  /* —— Spacing ——
     A 4px ramp. There was no spacing scale here before, which is why chrome.css arrived with
     7px, 10px, 28px and 36px sitting next to each other: with nothing to reach for, every gap
     became a fresh judgement call, and the mega-menu ended up spacing items in the SAME group
     (40px) further apart than items in adjacent groups (36px) — proximity inverted, so nothing
     read as grouped.

     Every step is a multiple of 4. Values off the ramp are a smell: if a gap genuinely needs
     6px or 18px, that is usually a line-height problem wearing a padding costume — which is
     exactly what the 40px pitch was (prose line-height 1.65 inherited into a UI list).

     Same rule as the type scale: use them for new work, convert files as you touch them, no
     global sweep. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* —— Motion & layout —— */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  /* --maxw is deliberately NOT here: content pages want a 760px reading measure,
     app and marketing pages want a wide container. It stays surface-local. */

  /* —— Compatibility aliases ——
     content.css named the brand colour --green and the hairline --muted. Kept
     as aliases so 27 marketing pages did not need rewriting, and so there is
     exactly one green in the product rather than two spellings of it. */
  --green: var(--primary);
  --green2: var(--primary-dark);
  --muted: var(--border-light);

  /* —— Aliases for names the app already writes but nothing ever defined ——
     22 call sites across dashboard.css and the dashboard modules were written with a fallback:
     var(--danger), var(--success), var(--bg-alt) and so on.
     None of those tokens existed, so the FALLBACK is what has always rendered — a fixed hex that
     cannot invert, which is exactly the failure this file was created to end. Several were not
     even the product's colour: --danger fell back to #ff3366, a pink-red that is not --red.

     Defining them here fixes every one of those call sites at once, in both themes, without
     touching a single one. They are aliases rather than new colours on purpose: the point is that
     there is one red, not a second spelling of it.

     (--tier-color, --label-color and --verdict-color are deliberately NOT here: those are set
     per-element at runtime, e.g. style="--tier-color:${color}", so their fallbacks are real
     defaults rather than dead references.) */
  --danger: var(--red);
  --err-bg: var(--danger-bg);
  --err-fg: var(--danger-fg);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --border-hover: #cbd5e1;
  --text-tertiary: #94a3b8;
  --success: var(--primary);
  --warning: var(--amber);
  --bg-alt: var(--surface-2);
  --surface-alt: var(--surface-2);
  --surface-raised: var(--surface);
  /* page.css:235 writes var(--surface-solid, var(--surface)), so this is exactly what already
     renders — declaring it changes no pixel and stops the audit blocking every commit in the tree. */
  --surface-solid: var(--surface);
  --radius-lg: var(--radius);

  /* A second batch, found by scripts/audit-tokens.mjs once it scanned the whole repo rather than
     the dashboard modules. These were worse than the first: several had NO fallback at all, so
     the declaration was simply invalid and the property fell away.

       .connect-provider-tab.active { background: var(--bg-card) } — the active provider tab had
         no background, leaving the selected state almost invisible.
       developers.js's API-key <code> block — background: var(--bg-secondary), i.e. transparent.
       A Connect panel pinned to var(--surface-1): a dark navy box on the LIGHT theme. */
  --bg-card: var(--surface);
  --surface-1: var(--surface);
  --bg-secondary: var(--surface-2);
  --color-brand: var(--primary);
}

/* ================================================================
   Dark theme. Applied on OS preference unless the user explicitly chose
   light, and always when data-theme="dark" is set. Both blocks must carry
   the same values; they are separate because a media query cannot be
   overridden by an attribute selector alone.
   ================================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --surface-3: #272c37;

    --border: #2b303b;
    --border-light: #3a4150;

    --text: #e8eaed;
    --text-secondary: #b3b9c4;
    --dim: #8b919d;

    --primary: #10b981;
    --channel-instagram: #e1659f;
    --primary-dark: #34d399;
    --primary-glow: rgba(16, 185, 129, 0.16);

    --accent: #a78bfa;
    --accent-glow: rgba(167, 139, 250, 0.16);

    --amber: #f59e0b;
    --amber2: #fbbf24;
    --red: #f87171;
    --blue: #60a5fa;

    /* —— Editorial accents (dark) —— */
    --brass: #d3a05c;
    --brass-tint: #2c2618;
    --verdigris: #82a697;
    --verdigris-tint: #1a2622;
    --red-glow: rgba(248, 113, 113, 0.16);
    --amber-glow: rgba(245, 158, 11, 0.16);
    --on-primary: #0f1115;

    /* Tints invert to a low-luminance wash with a legible foreground rather
       than the light-theme pastel, which reads as a glaring panel on dark. */
    --ok-bg: rgba(16, 185, 129, 0.12);
    --ok-bg-2: rgba(16, 185, 129, 0.08);
    --ok-border: rgba(16, 185, 129, 0.35);
    --ok-fg: #6ee7b7;

    --warn-bg: rgba(245, 158, 11, 0.13);
    --warn-border: rgba(245, 158, 11, 0.35);
    --warn-fg: #fcd34d;

    --danger-bg: rgba(248, 113, 113, 0.12);
    --danger-border: rgba(248, 113, 113, 0.35);
    --danger-fg: #fca5a5;
    --danger-fg-strong: #f87171;

    --info-bg: rgba(96, 165, 250, 0.12);
    --info-border: rgba(96, 165, 250, 0.35);
    --info-fg: #93c5fd;

    --gradient-primary: linear-gradient(135deg, #10b981, #34d399);
    --gradient-accent: linear-gradient(135deg, #a78bfa, #c4b5fd);
    --gradient-warm: linear-gradient(135deg, #f59e0b, #f97316);

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.16);
    --shadow-glow: 0 0 24px rgba(16, 185, 129, 0.06);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.16);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --scrim: rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --surface-3: #272c37;

  --border: #2b303b;
  --border-light: #3a4150;

  --text: #e8eaed;
  --text-secondary: #b3b9c4;
  --dim: #8b919d;

  --primary: #10b981;
  --channel-instagram: #e1659f;
  --primary-dark: #34d399;
  --primary-glow: rgba(16, 185, 129, 0.16);

  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.16);

  --amber: #f59e0b;
  --amber2: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;

  /* —— Editorial accents (dark) —— */
  --brass: #d3a05c;
  --brass-tint: #2c2618;
  --verdigris: #82a697;
  --verdigris-tint: #1a2622;
  --red-glow: rgba(248, 113, 113, 0.16);
  --amber-glow: rgba(245, 158, 11, 0.16);
  --on-primary: #0f1115;

  --ok-bg: rgba(16, 185, 129, 0.12);
  --ok-bg-2: rgba(16, 185, 129, 0.08);
  --ok-border: rgba(16, 185, 129, 0.35);
  --ok-fg: #6ee7b7;

  --warn-bg: rgba(245, 158, 11, 0.13);
  --warn-border: rgba(245, 158, 11, 0.35);
  --warn-fg: #fcd34d;

  --danger-bg: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.35);
  --danger-fg: #fca5a5;
  --danger-fg-strong: #f87171;

  --info-bg: rgba(96, 165, 250, 0.12);
  --info-border: rgba(96, 165, 250, 0.35);
  --info-fg: #93c5fd;

  --gradient-primary: linear-gradient(135deg, #10b981, #34d399);
  --gradient-accent: linear-gradient(135deg, #a78bfa, #c4b5fd);
  --gradient-warm: linear-gradient(135deg, #f59e0b, #f97316);

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.16);
  --shadow-glow: 0 0 24px rgba(16, 185, 129, 0.06);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.16);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --scrim: rgba(0, 0, 0, 0.55);
}
