/* ============================================================================
   CareHaven brand tokens for the scroll-craft duplicate.
   ----------------------------------------------------------------------------
   Link order in every rebuilt page <head> (this order matters):

     <link rel="stylesheet" href="/fonts/fonts.css?v=445cb659">   the @font-face rules (do NOT copy them here)
     <link rel="stylesheet" href="/sc/scrollcraft.css">           the engine floor (never edited)
     <link rel="stylesheet" href="/sc/brand.css">                 THIS FILE (after the engine, so it wins)
     <style> ...the page's own classes... </style>

   How the theme switches (same as the live site, verified in the originals):
     html[data-theme="dark"|"light"]  set by the head bootstrap from localStorage
     "ch_theme", else prefers-color-scheme. LIGHT is the default (:root); DARK is
     html[data-theme="dark"]. A prefers-color-scheme fallback is added only for the
     case where the bootstrap never ran (no data-theme attribute at all).

   Every brand colour here is a real value from the site's own CSS variables
   (index.html :root and html[data-theme="dark"]). Nothing is invented.

   Source of the colours  ->  the --sc-* role they fill
     --bg #FAF6F0 / #1C1B18        -> --sc-canvas
     --bg-subtle / --bg-raised     -> --sc-surface
     --text                        -> --sc-ink
     --text-2                      -> --sc-ink-soft
     --hv-d (light) / --hv (dark)  -> --sc-accent     (see the contrast note below)
     --bd / --bd-2                 -> --sc-hairline / --sc-hairline-strong

   CONTRAST NOTE (measured, WCAG): the brand sage #7A8B5C is only 3.44:1 on cream
   and cream-on-sage text is 3.44:1, so it is fine for large text and decoration
   but not for small text or a small button label. In LIGHT the accent role
   therefore uses the site's darker sage --hv-d #5E6E45 (5.14:1 against cream
   text on it, 5.14:1 as text on the canvas). The lighter sage is kept as
   --ch-sage for big display type, rules and illustration. In DARK the site's
   own accent #9DAE7A is 7.19:1 on the canvas, and dark ink on it is 7.19:1.
   ========================================================================== */

/* ----------------------------------------------------------------- LIGHT -- */
:root {
  /* the six colour roles */
  --sc-canvas:      #FAF6F0;
  --sc-surface:     #F4EFE7;
  --sc-ink:         #2C2621;
  --sc-ink-soft:    #534A42;
  --sc-accent:      #5E6E45;
  --sc-accent-ink:  #FAF6F0;

  --sc-hairline:        #E4DDD3;   /* between --bd #EDE8E3 and --bd-2 #D9D1C4 */
  --sc-hairline-strong: #D9D1C4;

  /* type: Brygada 1918 voices the page, Lexend carries UI and small text.
     Both are self-hosted by /fonts/fonts.css. No mono face is shipped, so the
     mono stack is the system one. */
  --sc-font-display: "Brygada 1918", Georgia, "Times New Roman", serif;
  --sc-font-text:    "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sc-font-mono:    ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Brygada is a text serif and Lexend is wide: loosen the engine's tight
     tracking and trim the two largest steps so headlines wrap like the site. */
  --sc-t-3xl:  clamp(2.6rem, 1.8rem + 3.8vw, 4.5rem);
  --sc-t-4xl:  clamp(3.1rem, 1.9rem + 5.6vw, 6.5rem);
  --sc-track-tight:  -0.022em;
  --sc-track-snug:   -0.012em;
  --sc-track-normal:  0;
  --sc-track-wide:    0.06em;
  --sc-leading-none:  1;
  --sc-leading-tight: 1.1;
  --sc-leading-body:  1.65;
  --sc-measure: 58ch;

  /* shape: the site's own radii (14 / 22), softened for a calm, rounded feel */
  --sc-r-sm: 8px;  --sc-r-md: 14px;  --sc-r-lg: 22px;  --sc-r-pill: 999px;

  /* elevation on a light canvas: tinted warm (the site's shadow tint is about
     hsl(25 14% 16%)), alphas roughly halved from the dark-canvas engine values */
  --sc-shadow-color: 25 14% 16%;
  --sc-e1: 0 1px 2px hsl(var(--sc-shadow-color) / 0.10),
           0 2px 6px -1px hsl(var(--sc-shadow-color) / 0.08);
  --sc-e2: 0 2px 4px hsl(var(--sc-shadow-color) / 0.09),
           0 8px 18px -4px hsl(var(--sc-shadow-color) / 0.13);
  --sc-e3: 0 4px 8px hsl(var(--sc-shadow-color) / 0.08),
           0 18px 40px -8px hsl(var(--sc-shadow-color) / 0.16),
           0 48px 90px -24px hsl(var(--sc-shadow-color) / 0.13);
  /* on a light canvas the lip highlight is white, not a tint of the ink */
  --sc-edge: inset 0 1px 0 rgba(255, 255, 255, 0.75);

  /* ---- the full CareHaven palette, for page-level use (prefix --ch-) ------
     Use these for the page's own classes. Roles: sage = the brand (one accent
     region per page); amber / coral / sky / blossom are the site's secondary
     tints, used sparingly as small signals (a chip, a dot), never as a second
     accent region. */
  --ch-bg:        #FAF6F0;
  --ch-raised:    #FFFFFF;
  --ch-subtle:    #F4EFE7;
  --ch-text:      #2C2621;
  --ch-text-2:    #534A42;
  --ch-text-3:    #6B5F55;   /* 5.75:1 on cream (was #7D7065, 4.46:1) */
  --ch-bd:        #EDE8E3;
  --ch-bd-2:      #D9D1C4;
  --ch-sage:      #7A8B5C;   /* the brand sage; large type and decoration */
  --ch-sage-d:    #5E6E45;   /* sage for small text and button fills */
  --ch-sage-l:    #EEF2E5;
  --ch-sage-l2:   #E4EBD6;
  --ch-logo-sage: #4A6741;   /* the logo disc and favicon */
  --ch-amber:     #C08B5C;
  --ch-amber-l:   #FBF0E6;
  --ch-coral:     #C25B4D;
  --ch-coral-l:   #FBEAE6;
  --ch-sky:       #6B8CAE;
  --ch-sky-l:     #E7EEF6;
  --ch-blossom:   #D88BA1;
  --ch-blossom-l: #FBEAEF;
  --ch-nav-bg:    rgba(250, 246, 240, 0.92);

  color-scheme: light;
}

/* ------------------------------------------------------------------ DARK -- */
html[data-theme="dark"] {
  --sc-canvas:      #1C1B18;
  --sc-surface:     #262420;
  --sc-ink:         #F2EDE6;
  --sc-ink-soft:    #C0B8AE;
  --sc-accent:      #9DAE7A;
  --sc-accent-ink:  #1C1B18;

  --sc-hairline:        #36332F;
  --sc-hairline-strong: #48433D;

  /* shadows on a dark canvas: warm near-black, engine-strength alphas */
  --sc-shadow-color: 35 12% 4%;
  --sc-e1: 0 1px 2px hsl(var(--sc-shadow-color) / 0.34),
           0 2px 6px -1px hsl(var(--sc-shadow-color) / 0.26);
  --sc-e2: 0 2px 4px hsl(var(--sc-shadow-color) / 0.30),
           0 8px 18px -4px hsl(var(--sc-shadow-color) / 0.38);
  --sc-e3: 0 4px 8px hsl(var(--sc-shadow-color) / 0.28),
           0 18px 40px -8px hsl(var(--sc-shadow-color) / 0.46),
           0 48px 90px -24px hsl(var(--sc-shadow-color) / 0.38);
  --sc-edge: inset 0 1px 0 color-mix(in oklab, var(--sc-ink) 9%, transparent);

  --ch-bg:        #1C1B18;
  --ch-raised:    #262420;
  --ch-subtle:    #2D2B27;
  --ch-text:      #F2EDE6;
  --ch-text-2:    #C0B8AE;
  --ch-text-3:    #A9A198;   /* 6.76:1 on the canvas, 5.54:1 on --ch-subtle (was #8E867E) */
  --ch-bd:        #36332F;
  --ch-bd-2:      #48433D;
  --ch-sage:      #9DAE7A;
  --ch-sage-d:    #B8C68F;
  --ch-sage-l:    #2B3520;
  --ch-sage-l2:   #36402A;
  /* --ch-logo-sage, --ch-amber, --ch-coral, --ch-sky, --ch-blossom keep their
     light values in dark, exactly as the site does (it never redefines them) */
  --ch-amber-l:   #3A2D20;
  --ch-coral-l:   #3A201D;
  --ch-sky-l:     #1F2A37;
  --ch-blossom-l: #3A2027;
  --ch-nav-bg:    rgba(28, 27, 24, 0.92);

  color-scheme: dark;
}

/* Fallback ONLY when the head bootstrap did not run (no data-theme at all):
   follow the system, as the bootstrap itself would have. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --sc-canvas:      #1C1B18;
    --sc-surface:     #262420;
    --sc-ink:         #F2EDE6;
    --sc-ink-soft:    #C0B8AE;
    --sc-accent:      #9DAE7A;
    --sc-accent-ink:  #1C1B18;
    --sc-hairline:        #36332F;
    --sc-hairline-strong: #48433D;
    --sc-shadow-color: 35 12% 4%;
    --sc-e1: 0 1px 2px hsl(var(--sc-shadow-color) / 0.34),
             0 2px 6px -1px hsl(var(--sc-shadow-color) / 0.26);
    --sc-e2: 0 2px 4px hsl(var(--sc-shadow-color) / 0.30),
             0 8px 18px -4px hsl(var(--sc-shadow-color) / 0.38);
    --sc-e3: 0 4px 8px hsl(var(--sc-shadow-color) / 0.28),
             0 18px 40px -8px hsl(var(--sc-shadow-color) / 0.46),
             0 48px 90px -24px hsl(var(--sc-shadow-color) / 0.38);
    --sc-edge: inset 0 1px 0 color-mix(in oklab, var(--sc-ink) 9%, transparent);
    --ch-bg: #1C1B18;  --ch-raised: #262420;  --ch-subtle: #2D2B27;
    --ch-text: #F2EDE6;  --ch-text-2: #C0B8AE;  --ch-text-3: #A9A198;
    --ch-bd: #36332F;  --ch-bd-2: #48433D;
    --ch-sage: #9DAE7A;  --ch-sage-d: #B8C68F;  --ch-sage-l: #2B3520;  --ch-sage-l2: #36402A;
    --ch-amber-l: #3A2D20;  --ch-coral-l: #3A201D;  --ch-sky-l: #1F2A37;  --ch-blossom-l: #3A2027;
    --ch-nav-bg: rgba(28, 27, 24, 0.92);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------- theme toggle icons --
   The site's toggle button holds BOTH icons and CSS shows one (landing.css
   lines 207-210). A rebuilt page that does not load /for/landing.css needs this
   so the moon shows in light and the sun shows in dark. Markup is in PRESERVE.md. */
.theme-toggle .moon, .theme-toggle .sun { display: none; }
html[data-theme="dark"]  .theme-toggle .sun  { display: block; width: 16px; height: 16px; }
html[data-theme="light"] .theme-toggle .moon { display: block; width: 16px; height: 16px; }
:root:not([data-theme]) .theme-toggle .moon { display: block; width: 16px; height: 16px; }

/* ---------------------------------------------------------------- basics --
   Minimal, so the engine and the page's own classes do the work. */
html { background: var(--sc-canvas); color-scheme: light dark; }
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"]  { color-scheme: dark; }
body { background: var(--sc-canvas); color: var(--sc-ink); font-family: var(--sc-font-text); }

/* The engine's :focus-visible ring uses --sc-accent, which is already
   AA against the canvas in both themes. */
