/* Fonts */

/* Site woff2 subsets (~60KB each) — the shipped Nerd-Font TTFs are ~11MB each
   (thousands of unused PUA icon glyphs). Built by api/scripts/subset_cv_fonts.py
   to the exact glyph set the chrome UI renders. font-display:swap = text paints
   immediately in the monospace fallback, no invisible-text stall on first load. */
@font-face {
  font-family: 'Iosevka Mayukai Monolite';
  src: url('/fonts/iosevka-500.woff2?v=1') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Iosevka Mayukai Monolite';
  src: url('/fonts/iosevka-700.woff2?v=1') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: BitLight;
  src: url('/fonts/bitlight.1fe0875b.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "04b25";
  src: url('/fonts/04b25.95438b7a.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ── Palette ─────────────────────────────────────────────────────────────────
   Hue-based: every color is an H S% L% channel token. Consume as
   hsl(var(--X-hsl)) solid, or hsl(var(--X-hsl) / α) for opacity variants.
   α snaps to the scale 0 / 0.06 / 0.12 / 0.25 / 0.45 / 0.6 / 0.8 / 1 —
   no freehand alphas at use sites, and each token uses at most 4
   non-zero steps from it.
   ────────────────────────────────────────────────────────────────────────── */
:root {
  /* ── Cools ───────────────────────────────────────────────────────────── */
  --green-hsl:           135 100% 50%;  /* [Ono-Sendai] Phosphor green—the interface's mother tongue. Body text, accents, the system's own murmur in the chat. */
  --cyan-hsl:            188 100% 50%;  /* [Hack] Cold cathode blue. The exec's signature, and every link that jacks you elsewhere. */

  /* ── Warms ───────────────────────────────────────────────────────────── */
  --orange-hsl:          33 100% 68%;   /* [Marigold] Sodium glare. The now-clock, the dive, overdue warnings, mentions, the tarot card come up reversed. */
  --orange-glow-hsl:     24 100% 50%;   /* [Ember] Heat off the clock, and the red under everything—overdue dates, drop zones, the exile switch, every error. */
  --pink-hsl:            340 71% 58%;   /* [Lizzie's] Neon at 3 a.m. The exec bubble's skin, the vain empress, the admin door. */

  /* ── Neutrals ────────────────────────────────────────────────────────── */
  --bg-hsl:              0 0% 0%;       /* [Smoked Glass] always solid. The ground it all stands on—pages, columns, input slabs, the buried past. */
  --surface-hsl:         0 0% 0%;       /* [Smoked Glass] Where dialogs and popups surface from nothing. */
  --scrim-hsl:           0 0% 0%;       /* [Smoked Glass] Frosted dark you read the room through—behind the nav, behind the modals. */
  --gray-hsl:            0 0% 78%;      /* [Silver] Thin chrome. The hours ticking down the timeline. */

  /* ── Category cards (base H S% L% channels per category — same units as
        the palette tokens; size variants = calc offsets from the base,
        computed once here, fetched by card-style.js) ──────────────────────── */
  --cat-self-h:         188;  --cat-self-s:         100%;  --cat-self-l:         50%;  /* [Hack] = --cyan-hsl */
  --cat-social-h:       125;  --cat-social-s:       55%;  --cat-social-l:       68%;  /* [Chatsubo] */
  --cat-interfacing-h:  33;  --cat-interfacing-s:  100%;  --cat-interfacing-l:  68%;  /* [Marigold] = --orange-hsl */
  --cat-hobby-h:        8;  --cat-hobby-s:        85%;  --cat-hobby-l:        68%;  /* [Coral] */
  --card-self-text:                  hsl(var(--cat-self-h) var(--cat-self-s) var(--cat-self-l));
  --card-self-wisp:                 color-mix(in srgb, hsl(var(--cat-self-h) var(--cat-self-s) var(--cat-self-l)) 15%, hsl(var(--bg-hsl)));
  --card-self-idea:                  color-mix(in srgb, hsl(var(--cat-self-h) var(--cat-self-s) var(--cat-self-l)) 25%, hsl(var(--bg-hsl)));
  --card-self-plan:               color-mix(in srgb, hsl(var(--cat-self-h) var(--cat-self-s) var(--cat-self-l)) 80%, hsl(var(--bg-hsl)));
  --card-self-commitment:                 hsl(var(--cat-self-h) var(--cat-self-s) var(--cat-self-l) / 1);
  --card-self-border:                hsl(var(--cat-self-h) calc(var(--cat-self-s) - 10%) calc(var(--cat-self-l) - 8%));
  --card-self-border-bright:         hsl(var(--cat-self-h) calc(var(--cat-self-s) + 15%) calc(var(--cat-self-l) + 10%));
  --card-self-wisp-solid:           color-mix(in srgb, hsl(var(--cat-self-h) var(--cat-self-s) var(--cat-self-l)) 15%, #0a0a0a);
  --card-self-idea-solid:            color-mix(in srgb, hsl(var(--cat-self-h) var(--cat-self-s) var(--cat-self-l)) 25%, #0a0a0a);
  --card-social-text:                hsl(var(--cat-social-h) var(--cat-social-s) var(--cat-social-l));
  --card-social-wisp:               color-mix(in srgb, hsl(var(--cat-social-h) var(--cat-social-s) var(--cat-social-l)) 15%, hsl(var(--bg-hsl)));
  --card-social-idea:                color-mix(in srgb, hsl(var(--cat-social-h) var(--cat-social-s) var(--cat-social-l)) 25%, hsl(var(--bg-hsl)));
  --card-social-plan:             hsl(var(--cat-social-h) calc(var(--cat-social-s) - 25%) calc(var(--cat-social-l) - 14%));
  --card-social-commitment:               hsl(var(--cat-social-h) calc(var(--cat-social-s) - 20%) calc(var(--cat-social-l) + 4%));
  --card-social-border:              hsl(var(--cat-social-h) calc(var(--cat-social-s) - 10%) calc(var(--cat-social-l) - 8%));
  --card-social-border-bright:       hsl(var(--cat-social-h) calc(var(--cat-social-s) + 15%) calc(var(--cat-social-l) + 10%));
  --card-social-wisp-solid:         color-mix(in srgb, hsl(var(--cat-social-h) var(--cat-social-s) var(--cat-social-l)) 15%, #0a0a0a);
  --card-social-idea-solid:          color-mix(in srgb, hsl(var(--cat-social-h) var(--cat-social-s) var(--cat-social-l)) 25%, #0a0a0a);
  --card-interfacing-text:           hsl(var(--cat-interfacing-h) var(--cat-interfacing-s) var(--cat-interfacing-l));
  --card-interfacing-wisp:          color-mix(in srgb, hsl(var(--cat-interfacing-h) var(--cat-interfacing-s) var(--cat-interfacing-l)) 15%, hsl(var(--bg-hsl)));
  --card-interfacing-idea:           color-mix(in srgb, hsl(var(--cat-interfacing-h) var(--cat-interfacing-s) var(--cat-interfacing-l)) 25%, hsl(var(--bg-hsl)));
  --card-interfacing-plan:        hsl(var(--cat-interfacing-h) calc(var(--cat-interfacing-s) - 25%) calc(var(--cat-interfacing-l) - 14%));
  --card-interfacing-commitment:          hsl(var(--cat-interfacing-h) var(--cat-interfacing-s) var(--cat-interfacing-l) / 1);
  --card-interfacing-border:         hsl(var(--cat-interfacing-h) calc(var(--cat-interfacing-s) - 10%) calc(var(--cat-interfacing-l) - 8%));
  --card-interfacing-border-bright:  hsl(var(--cat-interfacing-h) calc(var(--cat-interfacing-s) + 15%) calc(var(--cat-interfacing-l) + 10%));
  --card-interfacing-wisp-solid:    color-mix(in srgb, hsl(var(--cat-interfacing-h) var(--cat-interfacing-s) var(--cat-interfacing-l)) 15%, #0a0a0a);
  --card-interfacing-idea-solid:     color-mix(in srgb, hsl(var(--cat-interfacing-h) var(--cat-interfacing-s) var(--cat-interfacing-l)) 25%, #0a0a0a);
  --card-hobby-text:                 hsl(var(--cat-hobby-h) var(--cat-hobby-s) var(--cat-hobby-l));
  --card-hobby-wisp:                color-mix(in srgb, hsl(var(--cat-hobby-h) var(--cat-hobby-s) var(--cat-hobby-l)) 15%, hsl(var(--bg-hsl)));
  --card-hobby-idea:                 color-mix(in srgb, hsl(var(--cat-hobby-h) var(--cat-hobby-s) var(--cat-hobby-l)) 25%, hsl(var(--bg-hsl)));
  --card-hobby-plan:              hsl(var(--cat-hobby-h) calc(var(--cat-hobby-s) - 25%) calc(var(--cat-hobby-l) - 14%));
  --card-hobby-commitment:                hsl(var(--cat-hobby-h) calc(var(--cat-hobby-s) - 20%) calc(var(--cat-hobby-l) - 6%));
  --card-hobby-border:               hsl(var(--cat-hobby-h) calc(var(--cat-hobby-s) - 10%) calc(var(--cat-hobby-l) - 8%));
  --card-hobby-border-bright:        hsl(var(--cat-hobby-h) calc(var(--cat-hobby-s) + 15%) calc(var(--cat-hobby-l) + 10%));
  --card-hobby-wisp-solid:          color-mix(in srgb, hsl(var(--cat-hobby-h) var(--cat-hobby-s) var(--cat-hobby-l)) 15%, #0a0a0a);
  --card-hobby-idea-solid:           color-mix(in srgb, hsl(var(--cat-hobby-h) var(--cat-hobby-s) var(--cat-hobby-l)) 25%, #0a0a0a);

  /* ════════════════════════════════════════════════════════════════════════
     STRUCTURAL SCALE TOKENS — the same move color made, for every other
     design choice. Scales are SNAP scales (like the color/alpha snap scale):
     values derived from real usage across the app, anchored on RD + HQ (the
     reference pages), outliers snap in. Everything not a colour references
     these. Enforced by scripts/lint-scale.py the way lint-colors.py guards
     the palette. Edit here; the whole UI follows.
     ════════════════════════════════════════════════════════════════════════ */

  /* ── Spacing (px; fine at the bottom for dense card layouts, coarse up
        top). Used by padding / margin / gap. ──────────────────────────── */
  --space-0:    0;
  --space-px:   1px;   /* hairline gaps between stacked cards (RD/HQ) */
  --space-0-5:  2px;
  --space-1:    3px;
  --space-1-5:  4px;
  --space-2:    6px;
  --space-2-5:  8px;
  --space-3:    10px;
  --space-4:    12px;
  --space-5:    14px;
  --space-6:    16px;
  --space-7:    20px;
  --space-8:    24px;
  --space-10:   32px;

  /* ── Radius ──────────────────────────────────────────────────────────── */
  --radius-0:      0;
  --radius-1:      2px;   /* RD chips/inputs */
  --radius-2:      4px;   /* HQ cards, default */
  --radius-3:      6px;
  --radius-4:      8px;
  --radius-pill:   999px;
  --radius-round:  50%;

  /* ── Type: family ────────────────────────────────────────────────────── */
  --font-mono:   'Iosevka Mayukai Monolite', monospace;  /* the interface's body */
  --font-pixel:  '04b25', monospace;                     /* pixel display */
  --font-bit:    'BitLight', monospace;                  /* nightfall-adjacent */
  --font-ui:     system-ui, sans-serif;                  /* recruiter light page */

  /* ── Type: size (rem) — 4 steps; fluid clamp() sizes stay bespoke ─────── */
  --fs-2xs:   0.6rem;    /* meta / dim labels */
  --fs-sm:    0.72rem;   /* the body default (live count on /color) */
  --fs-xl:    1rem;      /* emphasis / titles */
  --fs-3xl:   1.7rem;    /* display */

  /* ── Type: weight — normal + bold only ───────────────────────────────── */
  --fw-normal:   400;
  --fw-bold:     700;

  /* ── Type: line-height ───────────────────────────────────────────────── */
  --lh-none:    1;
  --lh-tight:   1.2;
  --lh-snug:    1.35;
  --lh-normal:  1.45;
  --lh-relaxed: 1.6;
  --lh-loose:   1.7;

  /* ── Type: letter-spacing (caps labels) ──────────────────────────────── */
  --tracking-tight:  -0.01em;
  --tracking-wide:   0.05em;
  --tracking-wider:  0.08em;
  --tracking-x:      0.1em;
  --tracking-widest: 0.12em;
  --tracking-caps:   0.15em;
  --tracking-mega:   0.18em;

  /* ── Blur ────────────────────────────────────────────────────────────── */
  --blur-sm: 6px;
  --blur:    14px;

  /* ── Z layers (semantic; small in-component stacking stays local) ────── */
  --z-raised:  2;
  --z-sticky:  10;
  --z-nav:     60;
  --z-overlay: 100;
  --z-bubble:  8999;
  --z-modal:   9990;
  --z-top:     9999;
  --z-max:     10000;

  /* ── Document theme — the reading-page skin (card + ruled headers + chips)
        for /debug, /emet, /color, /mtg, /tarot chat, /security. Built ENTIRELY
        from the palette tokens above (no new colours): the app's phosphor green
        on black, plus cyan links + pink for destructive. Surfaces are green
        mixed into the black ground; every alpha is on the snap scale and within
        green's 4-step budget (0.12/0.45/0.8/1). ──────────────────────────── */
  --doc-bg:        color-mix(in srgb, hsl(var(--green-hsl)) 5%, hsl(var(--bg-hsl)));
  --doc-surface:   color-mix(in srgb, hsl(var(--green-hsl)) 9%, hsl(var(--bg-hsl)));
  --doc-ink:       hsl(var(--green-hsl) / 0.8);
  --doc-ink-soft:  hsl(var(--green-hsl) / 0.45);
  --doc-green:     hsl(var(--green-hsl));
  --doc-green-dim: hsl(var(--green-hsl) / 0.45);
  --doc-cyan:      hsl(var(--cyan-hsl) / 0.8);
  --doc-pink:      hsl(var(--pink-hsl));
  --doc-rule:      hsl(var(--green-hsl) / 0.12);
  --doc-chip:      hsl(var(--green-hsl) / 0.12);
}

/* Document-theme components — apply these classes on a reading page's wrapper /
   section headers / tags; the page's own CSS keeps only page-specific layout
   and references the --doc-* tokens for any extra colour. */
.doc-page { background: var(--doc-bg); }

.doc-card {
  width: min(780px, 92vw);
  margin: var(--space-10) auto calc(var(--nav-h, 64px) + var(--space-8));
  position: relative;
  z-index: var(--z-raised);
  background: var(--doc-surface);
  border: 1px solid var(--doc-rule);
  border-radius: var(--radius-4);
  box-shadow: 0 0 0 1px hsl(var(--green-hsl) / 0.12), 0 0 50px hsl(var(--green-hsl) / 0.12);
  text-shadow: 0 0 2px hsl(var(--green-hsl) / 0.12);
  padding: 52px clamp(28px, 6vw, 60px) 44px;
  color: var(--doc-ink);
  font-family: var(--font-mono);
  font-weight: var(--fw-normal);
  font-size: var(--fs-xl);
  line-height: var(--lh-relaxed);
}
.doc-card a { color: var(--doc-cyan); text-decoration: none; }
.doc-card a:hover { text-decoration: underline; }
.doc-card strong { color: var(--doc-green); font-weight: var(--fw-bold); }

.doc-h2 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-mega);
  color: var(--doc-green);
  margin: 0 0 var(--space-7);
  padding-bottom: var(--space-2-5);
  border-bottom: 1px solid var(--doc-rule);
}

.doc-chip {
  display: inline-block;
  background: var(--doc-chip);
  color: var(--doc-green);
  font-size: var(--fs-sm);
  padding: var(--space-px) var(--space-2);
  border-radius: var(--radius-2);
  white-space: nowrap;
}

/* Ambient cyberpunk background — injected on every page via _render_page
   (nightfall is composed separately and never gets the markup). */
.cyber-bg {
  position: fixed; inset: 0; z-index: var(--z-modal); pointer-events: none;
  mix-blend-mode: screen;
  background:
    repeating-linear-gradient(0deg, hsl(var(--green-hsl) / 0.12) 0,
      hsl(var(--green-hsl) / 0.12) 1px, transparent 1px, transparent 3px),
    radial-gradient(circle at 50% 45%, hsl(var(--green-hsl) / 0.12), transparent 70%);
  animation: cyber-flicker 5s steps(60) infinite, cyber-drift 0.5s linear infinite;
}

@keyframes cyber-flicker {
  0%,100%{opacity:1} 48%{opacity:0.96} 50%{opacity:0.8}
  51%{opacity:0.96} 70%{opacity:1} 72%{opacity:0.85} 73%{opacity:1}
}

@keyframes cyber-drift { from{background-position:0 0,0 0} to{background-position:0 3px,0 0} }

.cyber-scan {
  position: fixed; left: 0; right: 0; top: 0; height: 160px; z-index: var(--z-modal); pointer-events: none;
  mix-blend-mode: screen;
  background: linear-gradient(hsl(var(--green-hsl) / 0) 0%,
    hsl(var(--green-hsl) / 0.12) 50%, hsl(var(--green-hsl) / 0) 100%);
  animation: cyber-sweep 7s linear infinite;
}

@keyframes cyber-sweep { 0%{transform:translateY(-160px)} 100%{transform:translateY(100vh)} }

@media (prefers-reduced-motion: reduce) { .cyber-bg, .cyber-scan { animation: none !important; } }

/* Base */
html {
  background: hsl(var(--bg-hsl));

  /* bottom-chrome anchor for chat pages: clears the nav by default (see the
     html.kb-open override below for the keyboard-up case) */
  --kb-anchor: max(var(--nav-h, 56px), var(--kb, 0px));
}

body {
  font-family: var(--font-mono);
  font-weight: var(--fw-normal);
  font-style: normal;
  display: block;
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
  background: hsl(var(--bg-hsl));
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--green-hsl) / 0.45); border-radius: var(--radius-1); }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--green-hsl) / 0.8); }
* { scrollbar-width: thin; scrollbar-color: hsl(var(--green-hsl) / 0.45) transparent; }

/* Nav */
.exec-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: var(--space-3) 0;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  background: hsl(var(--scrim-hsl) / 0.45);
  backdrop-filter: blur(var(--blur));
  border-top: 1px solid hsl(var(--green-hsl) / 0.12);
}

/* keyboard up (input focused) — let the soft keyboard cover the nav */
html.kb-open .exec-nav { visibility: hidden; }

/* Keyboard up: the nav is hidden, so anchor the chat chrome flush to the
   keyboard (--kb, which is 0 in the standalone model where the layout bottom
   already meets the keyboard) — no reserved nav-h gap. Base value on `html`
   above. Consumed by #input-bar / #terminal / #spread-area. */
html.kb-open { --kb-anchor: var(--kb, 0px); }

.exec-nav a {
  color: hsl(var(--green-hsl) / 0.45);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-0-5);
  transition: color 0.2s;
  flex: 1;
  max-width: 72px;
}

.exec-nav a:hover { color: hsl(var(--green-hsl)); }
.exec-nav a.active { color: hsl(var(--green-hsl)); }

.exec-nav a img { border-radius: var(--radius-2); }

.exec-nav .nav-label {
  font-family: var(--font-pixel);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-x);
}

/* Standalone (home-screen / installed) launch: two rows, one empty cell of
   padding each side. --per-row set by the nav script (= ceil(item count / 2)).
   Cell width = W/(per-row + 2); the 2 extra cells are the side padding. */
html.standalone .exec-nav {
  flex-wrap: wrap;
  justify-content: center;
  row-gap: var(--space-2-5);
  padding-left: calc(100% / (var(--per-row) + 2));
  padding-right: calc(100% / (var(--per-row) + 2));
}

html.standalone .exec-nav a {
  flex: 0 0 calc(100% / var(--per-row));
  max-width: none;
}

/* Mobile (touch primary, standalone included): nav scaled to 120% — bigger tap
   targets + label. pointer:coarse catches phone/tablet, tab or home-screen alike;
   desktop mouse (fine) keeps the base size. Icons are sized inline (20px) in the
   nav markup, so the bump needs !important. --nav-h tracks the taller nav live. */
@media (pointer: coarse) {
  .exec-nav { padding: var(--space-4) 0; }
  .exec-nav a { gap: var(--space-1); max-width: 86px; }
  .exec-nav a img { width: 24px !important; height: 24px !important; }
  .exec-nav .nav-label { font-size: var(--fs-2xs); }
  html.standalone .exec-nav { row-gap: var(--space-3); }
}

/* Content pages */
#content {
  position: relative;
  z-index: var(--z-raised);
  width: min(720px, 90vw);

  /* track the live nav height (taller in two-row standalone) so scroll-page
     content clears the nav instead of sliding behind it */
  margin: 64px auto calc(var(--nav-h, 80px) + 24px);
  font-family: var(--font-mono);
  font-weight: var(--fw-normal);
  color: hsl(var(--green-hsl));
}

#content h2 {
  font-family: var(--font-pixel);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  opacity: 0.65;
  margin: var(--space-8) 0 var(--space-2-5);
  border-bottom: 1px solid hsl(var(--green-hsl) / 0.12);
  padding-bottom: var(--space-1-5);
}

#content .item {
  font-size: var(--fs-sm);
  padding: var(--space-1-5) 0;
  border-bottom: 1px solid hsl(var(--green-hsl) / 0.12);
}

#content button {
  background: none;
  border: 1px solid hsl(var(--green-hsl) / 0.45);
  color: hsl(var(--green-hsl) / 0.8);
  font-family: var(--font-mono);
  font-weight: var(--fw-normal);
  font-size: var(--fs-sm);
  padding: var(--space-1-5) var(--space-4);
  cursor: pointer;
  transition: all 0.2s;
}

#content button:hover { border-color: hsl(var(--green-hsl)); color: hsl(var(--green-hsl)); }
#content button:disabled { opacity: 0.35; cursor: default; }
#content .ts { font-size: var(--fs-sm); opacity: 0.5; margin-top: var(--space-6); }
