/*
 * _tokens.css — design tokens for joncik.dev
 *
 * THIS FILE IS DOCTRINE, NOT CODE.
 *
 * Every page on the site links to this file. No value here changes without
 * changing the visual identity. The anti-references (PRODUCT.md) apply here
 * too: no gradients, no glass effects, no decorative use of color.
 *
 * Source-of-truth: extracted from essays/index.html and
 * essays/context-as-cognitive-substrate/index.html, 2026-05-13.
 * If a future page diverges from these values it is wrong, not novel.
 */

/* ================================================================
   SUBSTRATE
   The dark identity. Light-mode users get this too — the work is
   the brand, this is not a doc-themed page.
   ================================================================ */
:root {
  --bg:           #0E0E0F;   /* page background — deepest */
  --bg-elev-1:    #16161A;   /* first elevation: cards, panels */
  --bg-elev-2:    #1C1C20;   /* second elevation: code bg, table headers */
  --line:         #2A2A30;   /* visible dividers, borders */
  --line-soft:    #1F1F25;   /* subtle separators inside panels */

  /* ================================================================
     TYPE COLOR
     Three tiers. fg is for headings and UI text that must read.
     fg-soft is for body copy — slightly softened so it sits behind
     strong and accent. fg-faint is for metadata, labels, captions —
     never for paragraph text.
     ================================================================ */
  --fg:           #ECECED;   /* primary text: headings, strong, UI */
  --fg-soft:      #A8A8AC;   /* body copy, descriptions */
  --fg-faint:     #5F5F66;   /* metadata, mono labels, captions */

  /* ================================================================
     ACCENT — terminal amber
     One accent color. Never another. Used for: the glowing dot,
     section markers (§, //), the accent-line bottom-border on links,
     the narrow underline on hero headers. Never used as a fill on
     large areas; --accent-soft is the only large-area amber surface.
     ================================================================ */
  --accent:       #E8954A;               /* terminal amber — the brand */
  --accent-soft:  #2B1F12;               /* large amber surface (coda blocks, callouts) */
  --accent-line:  rgba(232,149,74,0.32); /* amber link underline, faint borders */

  /* ================================================================
     STATE — used sparingly, never as decoration
     ok  → live/healthy indicators only
     warn → caution indicators only
     Neither should appear as a background fill or decorative element.
     ================================================================ */
  --ok:    #5FA88A;   /* online / live / healthy */
  --warn:  #C9A352;   /* caution / degraded */

  /* ================================================================
     TYPE STACK
     sans: Inter for UI and body copy. Falls back to system UI.
     mono: JetBrains Mono for all code, labels, eyebrows, topbar.
           The mono stack is the visual signature — monospace = technical.
     serif: System serif for essay body and long-form headings.
            Used only in essay-style pages. Never on the portfolio home.
     ================================================================ */
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: ui-serif, 'Iowan Old Style', 'Apple Garamond', Baskerville, 'Times New Roman', serif;

  /* ================================================================
     FLUID CONTAINER
     720px on phones → ~1200px on 13" laptops → 1600px cap at 4K.
     Matches home page width on 27" 4K viewports.
     For individual article pages, --max-article is narrower (65ch cap).
     ================================================================ */
  --max:         clamp(720px, 70vw, 1600px);
  --max-article: clamp(640px, 52vw, 780px);
}

/* ================================================================
   FLUID ROOT FONT-SIZE
   Single source of truth for every rem in the system.
   Phone: 16px. Laptop: ~17px. 4K monitor: ~22px.
   ================================================================ */
html {
  font-size: clamp(16px, calc(0.875rem + 0.25vw), 22px);
}

/* ================================================================
   BASE RESET + BODY
   ================================================================ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  font-feature-settings: "ss01", "cv11", "cv02";
  font-size: 1rem;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* ================================================================
     GENERATIVE GRID SUBSTRATE
     Single CSS gradient, no image asset.
     The grid is the visual signature of this site — same idea as the
     rule-router's predicate field: structure that guides without
     constraining. Amber at 3.5% opacity so it reads as texture, not
     as color. The grid-cell size scales with viewport.
     ================================================================ */
  background-image:
    linear-gradient(to right,  rgba(232,149,74,0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(232,149,74,0.035) 1px, transparent 1px);
  background-size: clamp(48px, 4vw, 88px) clamp(48px, 4vw, 88px);
  background-position: -1px -1px;
}

/* ================================================================
   SHARED LAYOUT
   ================================================================ */
main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 clamp(20px, 2vw, 48px) clamp(64px, 6vh, 128px);
}

/* ================================================================
   TOPBAR
   Full-width sticky strip. Content centered to --max via
   .topbar-inner. Monospace, uppercase, small.
   Left: glowing dot + page identifier. Right: nav links.
   ================================================================ */
.topbar {
  width: 100%;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(14,14,15,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px clamp(20px, 2vw, 48px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar .left { display: flex; gap: 18px; align-items: center; }
.topbar .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(232,149,74,0.6);
  display: inline-block;
}
.topbar a {
  color: var(--fg-soft);
  text-decoration: none;
  border-bottom: 1px dotted var(--fg-faint);
}
.topbar a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ================================================================
   HAMBURGER BUTTON + MOBILE DRAWER
   Shared across every page. Hidden on desktop, visible ≤640px.
   ================================================================ */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg-soft);
  padding: 8px 10px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 2px;
  transition: border-color 160ms ease, color 160ms ease;
}
.nav-toggle:hover { color: var(--accent); border-color: var(--accent-line); }
.nav-toggle:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.nav-toggle .bars {
  display: inline-flex; flex-direction: column; gap: 3px;
  margin-right: 6px; vertical-align: middle;
}
.nav-toggle .bars span { width: 14px; height: 1.5px; background: currentColor; display: block; }

.nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(14,14,15,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  flex-direction: column;
  padding: 64px clamp(24px, 6vw, 48px) 32px;
  opacity: 0;
  transition: opacity 260ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.nav-drawer.is-open { display: flex; opacity: 1; }
.nav-drawer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg-soft);
  padding: 6px 10px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  border-radius: 2px;
}
.nav-drawer-close:hover { color: var(--accent); border-color: var(--accent-line); }
.nav-drawer ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.nav-drawer a {
  display: block;
  padding: 18px 4px;
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
  transition: color 160ms ease, padding-left 200ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.nav-drawer a:hover, .nav-drawer a:focus-visible { color: var(--accent); padding-left: 12px; outline: none; }

/* ================================================================
   FOOTER — full-width with .footer-inner centered to --max
   ================================================================ */
footer {
  width: 100%;
  margin-top: 80px;
  border-top: 1px solid var(--line);
  color: var(--fg-faint);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  background: var(--bg);
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px clamp(20px, 2vw, 48px);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}
footer a { color: var(--fg-soft); border-bottom: 1px dotted var(--fg-faint); text-decoration: none; }
footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ================================================================
   HERO HEADER
   Shared structure. The amber accent-line on the bottom border
   is the visual handshake between pages.
   ================================================================ */
header.hero {
  padding: 80px 0 40px;
  border-bottom: 1px solid var(--line);
  position: relative;
  margin-bottom: 32px;
}
header.hero::after {
  content: "";
  position: absolute;
  left: 0; bottom: -1px;
  width: 88px; height: 1px;
  background: var(--accent);
}
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
h1 {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(2rem, 2rem + 1.4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 0.4em;
  color: var(--fg);
}
.lede {
  font-size: clamp(1.02rem, 1.02rem + 0.15vw, 1.2rem);
  line-height: 1.55;
  color: var(--fg-soft);
  max-width: 60ch;
  margin: 0;
}

/* ================================================================
   SHARED BODY ELEMENTS
   ================================================================ */
p { margin: 0 0 1rem; color: var(--fg-soft); }
p strong { color: var(--fg); font-weight: 600; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: border-color 120ms ease;
}
a:hover { border-bottom-color: var(--accent); }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-elev-2);
  color: var(--fg);
  padding: 0.1em 0.45em;
  border-radius: 3px;
  border: 1px solid var(--line);
}

em { color: var(--fg); font-style: italic; }

/* ================================================================
   MOBILE OVERRIDES
   ================================================================ */
@media (max-width: 640px) {
  main { padding: 0 18px 64px; }
  .topbar-inner { padding: 10px 18px; }
  .topbar .right { display: none; }
  .nav-toggle { display: inline-flex; align-items: center; }
  .footer-inner { padding: 22px 18px; gap: 8px; }
  header.hero { padding: 56px 0 32px; }
  .lede { font-size: 1.05rem; }
}
