/* Cabinhub News — Ember design tokens. SINGLE SOURCE for colour, type and rhythm.
   Every other file reads these variables; never hard-code a hex outside this file.

   Colour values are read from OUR products, not invented (2026-11-06):
     ~/ember-desktop/apps/desktop/design/tokens.json            (palette.light / palette.dark)
     ~/Documents/GitHub/ember-gateway/packages/ember-design/src/tokens.css
     ~/Documents/GitHub/ember-legal/docs/DESIGN_SYSTEM.md
   Mapping, source file, value and the variable it drives is recorded in docs/DESIGN.md.

   LIGHT IS THE DEFAULT (Han 11-06). Dark is a real option, reached two ways:
   the OS preference (prefers-color-scheme: dark) or an explicit choice
   (html[data-theme="dark"] / html[data-theme="light"]), which always wins. */

:root {
  /* ---- Ember light: the default ground ---------------------------------
     canvas / surface1 / border / text / brand are the Ember Desktop light
     palette, unmodified. Do not substitute a "close" value: the contrast
     record behind them (Han-approved 2026-08-02) is what makes them safe. */
  --paper: #F7F5F2;        /* canvas  — the page */
  --paper-2: #F1ECE7;      /* surface2 — inset wells, skeletons */
  --paper-3: #E7DED6;      /* surface3 — plate fill */
  --canvas: #FFFFFF;       /* surface1 — raised: cards, fields, article sheet */
  --rule: #D6CBC2;         /* border — hairline */
  --rule-soft: #E4DCD4;    /* hairline, secondary (border softened 30%) */
  --rule-strong: #8F7B6D;  /* borderStrong — a rule that must be seen */

  /* ---- ink ------------------------------------------------------------- */
  --ink: #1C1714;          /* text */
  --ink-soft: #514942;     /* textMuted */
  --ink-faint: #6D6259;    /* textSubtle — 5.2:1 on --paper */
  --ink-2: var(--paper-2); /* legacy alias */
  --ink-3: var(--paper-3); /* legacy alias */

  /* ---- one accent: Ember brand ----------------------------------------- */
  --accent: #BC3E0D;       /* brand — 5.0:1 on --paper, 5.7:1 on white */
  --accent-hover: #D64221; /* brandHover */
  --accent-press: #8E2D00;
  --accent-ink: #FFFFFF;   /* brandInk */
  --accent-soft: #FCE6DB;  /* softBrand */
  --focus: #D64221;        /* focus */

  /* ---- semantic (used by states, ops, claims) --------------------------- */
  --success: #176B3A;
  --success-soft: #E3F5E9;
  --warning: #765000;
  --warning-soft: #FFF1C6;
  --danger: #B42318;
  --danger-soft: #FDE7E5;
  --info: #075985;
  --info-soft: #E2F1FA;
  --signal: #177E43;       /* Ember signal green */
  --ion: #007793;          /* Ember ion */

  /* ---- the one dark surface we keep: the operator page ----------------
     It is deliberately a different room from the newsroom; an operator
     must not mistake the two at a glance. */
  --on-dark: #F7FAFC;
  --on-dark-muted: #B8C4CB;
  --on-dark-faint: #8FA1AB;
  --on-dark-dim: #2B3B45;
  --on-dark-bg: #0B1014;
  --on-dark-bg-2: #11181E;

  /* ---- families --------------------------------------------------------
     System type only: China blocks Google Fonts, and Han's law is the Apple
     way — the platform's own face at the platform's own metrics. Inter is
     used only where it is already installed. CJK: PingFang SC (Apple),
     Hiragino Sans GB, Noto Sans CJK SC, Microsoft YaHei. */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", "Songti SC", "Noto Serif CJK SC", serif;
  /* The wordmark is a Latin logotype and keeps this face in every edition —
     zh swaps --font-display to Songti for Chinese copy, which made the same
     "Cabinhub News" set 201px wide at 22px (vs 173 in the Latin face) and
     pushed the masthead controls out of a 360px row. A brand lockup does not
     change typeface per UI language; tokens.css deliberately does NOT re-point
     this token under html[lang="zh-Hans"]. */
  --font-brand: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* ---- insets ---------------------------------------------------------- */
  --gutter: clamp(1rem, 3.2vw, 2.5rem);
  --pad-l: max(var(--gutter), env(safe-area-inset-left, 0px));
  --pad-r: max(var(--gutter), env(safe-area-inset-right, 0px));
  --pad-b: max(0px, env(safe-area-inset-bottom, 0px));
  --page: 1120px;

  /* ---- measures -------------------------------------------------------- */
  /* A reader's own text size, as a multiplier on the body scale. 1 = the
     design's own size; article.js raises/lowers it and persists the choice.
     Only .prose reads it, so the chrome never reflows with the story. */
  --reading-scale: 1;
  --measure: 68ch;   /* 64-72ch is the comfortable reading range (brief 5) */
  --measure-deck: 52ch;
  --measure-tight: 40ch;

  /* ---- type scale -----------------------------------------------------
     Four sizes carry the whole newsroom: 13 meta, 15 body/small, 17 body,
     28/40 display. Apple's own ramp is short; a long one reads as a template.
     Display sizes are fluid, but the phone end is 28px, not 46 (HEAD 15:19Z). */
  --fs-micro: 0.75rem;     /* 12 — the smallest thing a reader must read */
  --fs-label: 0.8125rem;   /* 13 — meta line, labels */
  --fs-meta: 0.875rem;     /* 14 — bylines, timestamps, chips */
  --fs-small: 0.9375rem;   /* 15 — card decks */
  --fs-body: clamp(1.0625rem, 1rem + 0.22vw, 1.1875rem); /* 17 phone -> 19 desktop */
  --fs-deck: clamp(1.03rem, 0.97rem + 0.3vw, 1.25rem);
  --fs-title: clamp(1.0625rem, 1rem + 0.2vw, 1.125rem);  /* 17-18 cards (brief 5) */
  --fs-sub: clamp(1.1875rem, 1.05rem + 0.6vw, 1.4375rem);  /* 19-23 second tier */
  --fs-lead: clamp(1.75rem, 1.15rem + 2.1vw, 2.5rem);      /* 28 phone -> 40 @1440 */
  --fs-detail: clamp(1.75rem, 1.1rem + 2.4vw, 2.75rem);    /* 28 -> 44 article H1 */
  --fs-mark: clamp(1.375rem, 1.05rem + 1.1vw, 1.75rem);    /* 22-28 wordmark */

  /* ---- rhythm ---------------------------------------------------------- */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2.25rem;
  --sp-7: 3rem;

  /* ---- shape and motion ------------------------------------------------
     Ember radius ramp: 4 / 6 / 8 / 12 / 18. The newsroom uses the small end
     (a newsprint page has square corners; controls get 6-8, never a bubble). */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 18px;
  --radius: var(--r-sm);

  --tap: 44px;
  --ease: cubic-bezier(0.22, 0.68, 0.16, 1);
  --dur-1: 150ms;          /* Ember duration ramp */
  --dur-2: 250ms;
  --dur-3: 400ms;
  --dur: var(--dur-2);

  --filters-h: 44px;

  /* ---- the sticky bars are glass --------------------------------------
     chrome.css has always asked for `backdrop-filter: saturate(180%)
     blur(20px)`, but it painted an OPAQUE --paper behind it, so the blur had
     nothing to show and the bars were simply flat. The material needs a
     translucent fill to exist at all.

     --bar is that fill: the paper at 92%, so content scrolling underneath
     reads as a soft wash rather than a hard cut, while nothing behind it can
     still be READ through a navigation row.

     The 92 is a MEASUREMENT, not a taste value. On the rendered page
     (hk-fold-gate, 1440 and 390, scrolled to 700) a headline scrolling under
     the bar is 8% of the composite at 92% — a faint texture. At 86% the same
     headline resolved into readable ghost text through the filter row, and at
     72% (the first attempt) it competed with the bar's own labels. A
     navigation row is a control surface: clutter behind a control is a
     legibility defect, not a material effect. The number is also sized for the
     case where the blur does NOT composite (hardware acceleration off, some
     VMs, headless) — that path has to be clean on its own, because the
     @supports gate in chrome.css can only test that a browser UNDERSTANDS
     backdrop-filter, not that it is currently using the GPU.

     --bar-solid is the same surface at full opacity. It is what a reader who
     asked for less transparency gets, and also what every engine with no
     backdrop-filter at all gets. */
  --bar: color-mix(in srgb, var(--paper) 92%, transparent);
  --bar-solid: var(--paper);

  /* ---- elevation: the tier a surface is LIFTED to --------------------
     A card in the column is still a hairline (cards.css: no frame, no fill, no
     shadow) and --shadow-card stays `none`. Depth is reserved for the surfaces
     that genuinely leave the page plane and float over content — the command
     palette sheet, the update toast, the live pill — where a hairline alone
     cannot separate a sheet from the sheet under it.

     The model is the one Open Props (MIT, argyleink/open-props, src/props.
     shadows.css) uses and Apple's HIG describes: a light source directly above,
     so every tier is a STACK of (a) a tight contact shadow that gives the
     surface its edge and (b) wider ambient shadows that give it height. One
     soft blob reads as a smudge; a stack reads as a real object.

     Values are expressed in terms of the product's own warm ink --ink (#1C1714)
     through color-mix, so the shadow is warm like the paper it falls on, never
     a neutral grey from a template, and it follows the theme when --ink flips.
     An alpha-only colour (rgb(0 0 0 / 8%)) is what a generic theme ships; a
     tinted one is what a designed one ships. */
  --shadow-color: var(--ink);
  --shadow-1:
    0 1px 2px -1px color-mix(in srgb, var(--shadow-color) 12%, transparent),
    0 2px 4px -2px color-mix(in srgb, var(--shadow-color) 8%, transparent);
  --shadow-2:
    0 1px 2px -1px color-mix(in srgb, var(--shadow-color) 14%, transparent),
    0 4px 8px -3px color-mix(in srgb, var(--shadow-color) 10%, transparent),
    0 10px 20px -8px color-mix(in srgb, var(--shadow-color) 8%, transparent);
  --shadow-3:
    0 2px 4px -2px color-mix(in srgb, var(--shadow-color) 16%, transparent),
    0 8px 16px -6px color-mix(in srgb, var(--shadow-color) 12%, transparent),
    0 24px 48px -20px color-mix(in srgb, var(--shadow-color) 12%, transparent);
  /* The one lit edge on a raised surface: a 1px top highlight, the way a
     physical card catches the light on its near edge. Drawable as an inset
     shadow, so it costs no extra element. */
  --bevel-top: inset 0 1px 0 color-mix(in srgb, #FFFFFF 60%, transparent);
  --shadow-card: none;   /* a card in the column is still a hairline */
}

/* ---- dark: an option, never the default -------------------------------
   Two switch points, one palette:
   - html[data-theme="dark"]: the reader chose dark in the header switch.
   - @media (prefers-color-scheme: dark) with no explicit choice: the OS asked.
   [data-theme="light"] always wins over the OS, so an explicit light choice is
   never overridden by a dark-set phone.
   Warm dark, per the Ember identity: ground #15110E, surface #1E1915. It is
   warm on purpose; a navy or blue-black ground reads as a template default. */
html[data-theme="dark"] {
  --paper: #15110E;      /* warm dark ground, Ember identity (HEAD brief 2) */
  --paper-2: #1E1915;    /* surface */
  --paper-3: #2A2320;
  --canvas: #1E1915;
  --rule: #3A3129;
  --rule-soft: #2A2320;
  --rule-strong: #6E6055;

  --ink: #F3EEE9;
  --ink-soft: #C9BFB6;
  --ink-faint: #9F948A;
  --ink-2: var(--paper-2);
  --ink-3: var(--paper-3);

  --accent: #FA8054;     /* lifted so it passes AA on the warm dark */
  --accent-hover: #FF9C6B;
  --accent-press: #E2663C;
  --accent-ink: #241006;
  --accent-soft: #3B1B10;
  --focus: #FF9C6B;

  --success: #4ADE80;
  --success-soft: #10271D;
  --warning: #FBBF24;
  --warning-soft: #2A2110;
  --danger: #FF7B72;
  --danger-soft: #2B1616;
  --info: #60A5FA;
  --info-soft: #10243A;
  --signal: #65C281;
  --ion: #51B3D0;

  /* A dark ground swallows a shadow, so it needs a touch more strength to read
     as the same height — the same reason Open Props raises its own
     shadow-strength from 1% to 25% under dark. On warm dark the shadow is
     black, not tinted ink (tinted ink on a #15110E ground is invisible), and a
     white bevel would be a seam of light along the sheet's edge, so it drops to
     a whisper. */
  --shadow-1:
    0 1px 2px -1px color-mix(in srgb, #000 45%, transparent),
    0 2px 5px -2px color-mix(in srgb, #000 35%, transparent);
  --shadow-2:
    0 1px 2px -1px color-mix(in srgb, #000 50%, transparent),
    0 5px 10px -3px color-mix(in srgb, #000 40%, transparent),
    0 12px 24px -8px color-mix(in srgb, #000 35%, transparent);
  --shadow-3:
    0 2px 5px -2px color-mix(in srgb, #000 55%, transparent),
    0 10px 20px -6px color-mix(in srgb, #000 45%, transparent),
    0 28px 56px -20px color-mix(in srgb, #000 45%, transparent);
  --bevel-top: inset 0 1px 0 color-mix(in srgb, #FFFFFF 8%, transparent);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --paper: #15110E;      /* warm dark ground, Ember identity (HEAD brief 2) */
    --paper-2: #1E1915;    /* surface */
    --paper-3: #2A2320;
    --canvas: #1E1915;
    --rule: #3A3129;
    --rule-soft: #2A2320;
    --rule-strong: #6E6055;

    --ink: #F3EEE9;
    --ink-soft: #C9BFB6;
    --ink-faint: #9F948A;
    --ink-2: var(--paper-2);
    --ink-3: var(--paper-3);

    --accent: #FA8054;     /* lifted so it passes AA on the warm dark */
    --accent-hover: #FF9C6B;
    --accent-press: #E2663C;
    --accent-ink: #241006;
    --accent-soft: #3B1B10;
    --focus: #FF9C6B;

    --success: #4ADE80;
    --success-soft: #10271D;
    --warning: #FBBF24;
    --warning-soft: #2A2110;
    --danger: #FF7B72;
    --danger-soft: #2B1616;
    --info: #60A5FA;
    --info-soft: #10243A;
    --signal: #65C281;
    --ion: #51B3D0;

    /* dark elevation, as in the explicit-choice block above */
    --shadow-1:
      0 1px 2px -1px color-mix(in srgb, #000 45%, transparent),
      0 2px 5px -2px color-mix(in srgb, #000 35%, transparent);
    --shadow-2:
      0 1px 2px -1px color-mix(in srgb, #000 50%, transparent),
      0 5px 10px -3px color-mix(in srgb, #000 40%, transparent),
      0 12px 24px -8px color-mix(in srgb, #000 35%, transparent);
    --shadow-3:
      0 2px 5px -2px color-mix(in srgb, #000 55%, transparent),
      0 10px 20px -6px color-mix(in srgb, #000 45%, transparent),
      0 28px 56px -20px color-mix(in srgb, #000 45%, transparent);
    --bevel-top: inset 0 1px 0 color-mix(in srgb, #FFFFFF 8%, transparent);

    color-scheme: dark;
  }
}

/* zh-Hans sets its own faces and measures; sizes and colour are shared. */
html[lang="zh-Hans"] {
  --font-display: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", ui-monospace, Menlo, monospace;
  --measure: 40em;
  --measure-deck: 34em;
  --measure-tight: 26em;
}
