/* ==========================================================
   nickdesro — design tokens
   1. Brand tokens: the raw palette. Used ONLY in this file
      (and in brand.html swatches / logo demo cards).
   2. Semantic tokens: redefined per theme. Components use these only.
   Themes: [data-theme="light"|"dark"] on <html>. Default = light.
   ========================================================== */

/*! Fonts: Chicago Kare, Fira Sans, Bagel Fat One. Licenses: /licenses.txt */
/* ---------- Self-hosted fonts (no external requests). Licenses in Assets/fonts/<font>/ ---------- */
/* Fira Sans (Carrois Apostrophe, SIL OFL 1.1): body text, and plain-mode headings at 800 */
@font-face { font-family: "Fira Sans"; src: url("../Assets/fonts/fira-sans/fira-sans-400-latin.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans"; src: url("../Assets/fonts/fira-sans/fira-sans-700-latin.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans"; src: url("../Assets/fonts/fira-sans/fira-sans-800-latin.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
/* Bagel Fat One (Kyungwon Kim, JAMO; SIL OFL 1.1): fun-mode headings. Single weight (400), never faked bold */
@font-face { font-family: "Bagel Fat One"; src: url("../Assets/fonts/bagel-fat-one/bagel-fat-one-400-latin.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
/* Metric-matched local fallbacks (measured against the real fonts), so text barely moves while the web fonts load (swap) */
@font-face { font-family: "Fira Sans Fallback"; src: local("Arial"), local("Helvetica"); size-adjust: 102.8%; ascent-override: 91%; descent-override: 25.8%; line-gap-override: 0%; }
@font-face { font-family: "Bagel Fat One Fallback"; src: local("Arial Black"), local("ArialMT-Black"), local("Arial Bold"); size-adjust: 83.5%; ascent-override: 139%; descent-override: 34.7%; line-gap-override: 0%; }

/* ---------- 1. Brand tokens (raw palette) ---------- */
:root {
  --blue: #004aad;
  --paper: #f0f1f1;
  --charcoal: #2d2d2d;
  --orange: #ff5b22;
  --pink: #ff4081;
  --white: #ffffff;
  --ink: #121214;         /* near-black, darker than charcoal */
  --blue-light: #6ea8ff;  /* blue for text/links on dark */
  --charcoal-hi: #3a3a3d; /* raised charcoal (dark theme) */
}

/* ---------- Paper document (the About page resume): paper-colored in BOTH themes, like a printed page ---------- */
:root {
  --doc-bg: var(--paper);       /* #f0f1f1 */
  --doc-text: var(--charcoal);  /* #2d2d2d: 12.17:1 on --doc-bg */
  --doc-muted: #50555a;         /* dates, places: 6.66:1 on --doc-bg */
  --doc-accent: var(--blue);    /* the name, links: 7.18:1 on --doc-bg */
  --doc-rule: #c4c8ca;          /* column rule + hairlines (decorative) */
  --doc-edge: rgb(0 0 0 / 0.28);/* faint soft edge so the page lifts off a dark window */
  --doc-shadow: rgb(0 0 0 / 0.16);/* wide, soft second shadow layer */
}

/* ---------- Non-color tokens (shared by both themes) ---------- */
:root {
  /* Fonts. See "Fonts" in CLAUDE.md. Anton is retired; --font-display stays as an alias for old markup. */
  --font-body: "Fira Sans", "Fira Sans Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: "Pixelify Sans", "Courier New", monospace; /* old brand.html tile only (not loaded any more) */

  /* Headings: data-font on <html> = "fun" (default, decorative) or "plain" (Fira Sans heavy).
     The inline script in each page's <head> sets it before first paint; components/font-mode.js toggles it.
     Per-mode scale / tracking / leading keep headings in roughly the same box in both modes. */
  --font-heading-fun: "Bagel Fat One", "Bagel Fat One Fallback", "Arial Black", sans-serif; /* decorative headings */
  --font-heading-plain: "Fira Sans", "Fira Sans Fallback", system-ui, sans-serif;
  --font-heading: var(--font-heading-fun);
  --heading-weight: 400;     /* the decorative font's only (real) weight */
  --heading-scale: 1;
  --heading-tracking: 0em;
  --heading-leading: 1.08;
  --font-display: var(--font-heading);

  /* Interface (chrome) text: the same in both modes */
  --font-chrome: "Chicago Kare", Geneva, Verdana, sans-serif; /* window titles, menu bar, buttons, dock tooltips, labels */
  --font-chrome-text: Geneva, Verdana, sans-serif;            /* small interface text (address bar, list text) */
  --chrome-scale: 1;
  --chrome-tracking: 0em;

  /* Type scale (fluid, ~1.333 ratio) */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.25rem;
  --text-lg: clamp(1.5rem, 1.3rem + 0.8vw, 2rem);
  --text-xl: clamp(2rem, 1.6rem + 1.6vw, 3rem);
  --text-2xl: clamp(3rem, 2.2rem + 3.2vw, 5rem);
  --text-3xl: clamp(4.5rem, 3rem + 6vw, 9rem);

  --leading-tight: 0.92; /* Anton display */
  --leading-snug: 1.2;
  --leading-body: 1.6;

  --tracking-display: -0.01em;
  --tracking-ui: 0.02em;

  /* Spacing scale (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: 8rem;

  /* Border widths + hard edges */
  --border-thin: 1px;
  --border-width: 2px;
  --border-thick: 4px;
  --radius: 0;

  /* Layout */
  --container: 72rem;
  --col-side: 12.5rem;
  --col-widgets: 17rem;
  --titlebar-h: 2.25rem;

  /* Z layers */
  --z-window: 10;
  --z-dragging: 100;
  --z-crt: 9000;
  --z-taskbar-btn: 9001; /* theme + CRT toggles sit above the CRT overlay */
}

/* Plain headings mode (opt-in via the menu bar "headings" toggle) */
:root[data-font="plain"] {
  --font-heading: var(--font-heading-plain);
  --heading-weight: 800;
  --heading-scale: 1;        /* Fira Sans heavy is within ~0-6% of Bagel Fat One's width: no boost needed */
  --heading-tracking: 0em;
  --heading-leading: 1.08;   /* same px line height as fun mode */
}

/* ---------- 2a. Semantic tokens: LIGHT (default) ---------- */
:root,
:root[data-theme="light"] {
  color-scheme: light;

  /* Surfaces */
  --bg: var(--paper);                  /* never pure white */
  --surface: var(--paper);
  --surface-alt: #e3e5e5;              /* raised controls */
  --surface-sunken: #f9fafa;           /* wells, inputs */
  --float-shadow: rgba(0, 0, 0, 0.28); /* page system: the levitating shadow under floating figures */
  --float-rim: transparent;            /* page system: no rim on floating figures in light */

  /* Text */
  --text: var(--charcoal);             /* 12.2:1 on bg */
  --text-muted: #4b4f52;               /* 7.3:1 on bg */
  --heading: var(--blue);              /* hero/display (7.2:1) */
  --heading-accent: var(--blue);       /* panel titles */
  --link: var(--blue);                 /* 7.2:1 */
  --focus: var(--blue);

  /* Lines + shadows (hard offset, no blur) */
  --border: var(--charcoal);
  --shadow: var(--charcoal);           /* panels, windows */
  --shadow-small: var(--charcoal);     /* buttons, cards */
  --shadow-drag: var(--blue);          /* window while dragging */
  --shadow-accent: var(--charcoal);    /* banner / hero fills */
  --scene-shadow: color-mix(in srgb, var(--charcoal) 26%, transparent); /* soft ground shadow under the scene islands */
  --scene-screen-off: #0d1013;         /* the screens island's glass: an off screen / its CRT shading (artwork, both themes) */
  --scene-screen-glow: #d6ecff;        /* the screens island's glass: edge glow and glare (artwork, both themes) */

  /* Fills (blue is the big color on light) */
  --fill: var(--blue);
  --on-fill: var(--white);             /* 8.1:1 */
  --fill-highlight: rgb(255 255 255 / 0.25);
  --side-bg: var(--blue);              /* sidebar panels */
  --on-side: var(--white);
  --bar-bg: var(--blue);               /* taskbar / tab strip */

  /* Small accents (~5%) */
  --accent: var(--orange);
  --accent-2: var(--pink);
  --on-accent: var(--ink);             /* text on orange/pink fills, 5.6-6.0:1 */
  --glow-accent: 0 0 0 0 transparent;  /* glows are dark-theme only */
  --glow-accent-2: 0 0 0 0 transparent;
  --glow-text-accent: 0 0 0 transparent;

  /* Misc component colors */
  --label-bg: var(--charcoal);
  --label-text: var(--paper);
  --display-bg: var(--charcoal);       /* LED counter, clock window */
  --bevel-hi: var(--white);
  --bevel-lo: #c4c7c8;
  --inset-shadow: rgb(0 0 0 / 0.18);

  /* Stickers: always white-bordered; paper card is the light surface */
  --sticker-bg: var(--paper);
  --sticker-text: var(--charcoal);
  --sticker-accent: var(--blue);
  --sticker-border: var(--white);
  --sticker-filter: drop-shadow(2px 0 0 var(--white)) drop-shadow(-2px 0 0 var(--white))
    drop-shadow(0 2px 0 var(--white)) drop-shadow(0 -2px 0 var(--white)) drop-shadow(4px 4px 0 var(--charcoal));
  /* Flat variant: white border + a tight, faint shadow (sits flat on a panel, like the player's stickers) */
  --sticker-filter-flat: drop-shadow(2px 0 0 var(--white)) drop-shadow(-2px 0 0 var(--white))
    drop-shadow(0 2px 0 var(--white)) drop-shadow(0 -2px 0 var(--white)) drop-shadow(1px 1px 0 rgb(0 0 0 / 0.22));

  /* Gradient title bars (components/titlebar-grad.css). White title text stays >= 5:1 over the
     left 40% of the bar, where the short titles sit */
  --titlebar-from: var(--blue);
  --titlebar-to: #7fa6dc;
  --titlebar-text: var(--white);
  --titlebar-line: var(--white);       /* 1px highlight under the bar */
  --titlebar-ctl: var(--white);        /* decorative corner boxes */
  --titlebar-ctl-edge: var(--charcoal);

  /* Page background: paper + grain + low-contrast stars */
  --bg-stars: url("../Assets/star-tile-light.png");
  --bg-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");

  /* CRT effect tuning */
  --crt-split-a: rgb(0 74 173 / 0.35);
  --crt-split-b: rgb(255 64 129 / 0.3);
  --crt-scan: rgba(0, 0, 0, 0.1);
  --crt-flicker: rgba(18, 16, 16, 0.05);
}

/* ---------- 2b. Semantic tokens: DARK (opt-in) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: var(--ink);
  --surface: var(--charcoal);
  --surface-alt: var(--charcoal-hi);
  --surface-sunken: var(--ink);
  --float-shadow: rgba(0, 0, 0, 0.6);
  --float-rim: rgba(255, 255, 255, 0.25); /* a faint light edge so a black phone bezel doesn't vanish */

  --text: var(--paper);                /* 12.2:1 on charcoal */
  --text-muted: #b9bcc0;               /* 7.2:1 on charcoal */
  --heading: var(--paper);
  --heading-accent: var(--blue-light); /* 5.7:1 on charcoal */
  --link: var(--blue-light);
  --focus: var(--orange);

  --border: var(--ink);
  --shadow: var(--blue);
  --shadow-small: var(--ink);
  --shadow-drag: var(--pink);
  --shadow-accent: var(--pink);
  --scene-shadow: rgb(0 0 0 / 0.5);
  --scene-screen-off: #0d1013;
  --scene-screen-glow: #d6ecff;

  --fill: var(--blue);                 /* fills only, white text */
  --on-fill: var(--white);
  --fill-highlight: rgb(255 255 255 / 0.25);
  --side-bg: var(--charcoal);
  --on-side: var(--paper);
  --bar-bg: var(--charcoal);

  --accent: var(--orange);
  --accent-2: var(--pink);
  --on-accent: var(--ink);
  --glow-accent: 0 0 6px rgb(255 91 34 / 0.75), 0 0 16px rgb(255 91 34 / 0.35);
  --glow-accent-2: 0 0 6px rgb(255 64 129 / 0.75), 0 0 16px rgb(255 64 129 / 0.35);
  --glow-text-accent: 0 0 6px rgb(255 91 34 / 0.75), 0 0 16px rgb(255 91 34 / 0.35);

  --label-bg: var(--ink);
  --label-text: var(--paper);
  --display-bg: var(--ink);
  --bevel-hi: var(--charcoal-hi);
  --bevel-lo: var(--ink);
  --inset-shadow: rgb(0 0 0 / 0.6);

  --sticker-bg: var(--paper);
  --sticker-text: var(--charcoal);
  --sticker-accent: var(--blue);
  --sticker-border: var(--white);
  --sticker-filter: drop-shadow(2px 0 0 var(--white)) drop-shadow(-2px 0 0 var(--white))
    drop-shadow(0 2px 0 var(--white)) drop-shadow(0 -2px 0 var(--white)) drop-shadow(4px 4px 0 var(--ink));
  --sticker-filter-flat: drop-shadow(2px 0 0 var(--white)) drop-shadow(-2px 0 0 var(--white))
    drop-shadow(0 2px 0 var(--white)) drop-shadow(0 -2px 0 var(--white)) drop-shadow(1px 1px 0 rgb(0 0 0 / 0.45));

  /* Both gradient ends darker so the bar doesn't glow; white text >= 6.4:1 everywhere */
  --titlebar-from: #06336f;
  --titlebar-to: #3b5f97;
  --titlebar-text: var(--white);
  --titlebar-line: rgb(255 255 255 / 0.3);
  --titlebar-ctl: #d6d8dc;
  --titlebar-ctl-edge: var(--ink);

  --bg-stars: url("../Assets/star-tile-dark.png");
  --bg-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");

  --crt-split-a: rgb(110 168 255 / 0.4);
  --crt-split-b: rgb(255 64 129 / 0.35);
  --crt-scan: rgba(0, 0, 0, 0.25);
  --crt-flicker: rgba(18, 16, 16, 0.1);
}

/* ---------- Composite tokens (resolve per theme on <html>) ---------- */
:root {
  --line: var(--border-width) solid var(--border);
  --shadow-sm: 3px 3px 0 var(--shadow-small);
  --shadow-window: 6px 6px 0 var(--shadow);
  --shadow-lg: 10px 10px 0 var(--shadow-drag);
  --bevel: inset 2px 2px 0 var(--bevel-hi), inset -2px -2px 0 var(--bevel-lo);
  --shadow-panel: var(--bevel), 4px 4px 0 var(--shadow);
}

/* ---------- Minimal base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 100%;
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background:
    var(--bg-grain) 0 0 / 200px 200px repeat,
    var(--bg-stars) 0 0 / 160px 160px repeat,
    var(--bg);
  font-size: var(--text-base);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--link);
}

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

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

/* ---- Type roles ---- */
/* Headings: --font-heading in its real weight (never faked). Chrome headings (window titles, title bars)
   set their own font in their components. */
h1, h2, h3, .display {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-synthesis: none;
}

/* Big display headings (stub page titles) */
.display {
  letter-spacing: var(--heading-tracking);
  line-height: var(--heading-leading);
  color: var(--heading);
}

.ui {
  font-family: var(--font-ui);
  letter-spacing: var(--tracking-ui);
}
