/* ============================================================
   pixtuoid — "Cozy Terminal" skin
   Claude warmth (paper #faf9f5 · ink #141413 · coral #d97757) kept as the base,
   pushed toward terminal/pixel character:
   Display: Jersey 10  ·  UI/code: JetBrains Mono  ·  Body: Lora
   coral→amber accent gradient · blinking cursor · ASCII dividers · CRT scanlines
   ============================================================ */

:root {
  /* Brand constants */
  /* Warm "Coworking" palette — cream lightened from the office carpet (#8A765F)
     + Claude coral. Analogous warm harmony so the office art sits INTO the page. */
  --paper: #f4eee2; /* warm cream (carpet hue, lifted) */
  --ink: #241c14; /* deep warm wood */
  --gray: #b3a892;
  --coral: #d97757; /* Claude coral */
  --coral-deep: #a8431f; /* darkened for WCAG AA: ~5:1 on the cream --paper */
  --amber: #e6a356; /* warm amber — gradient end */
  --blue: #6a9bcc;
  --green: #788c5d;
  --ok: #556b2f; /* AA "ok" green for the boot log — 5.15:1 on cream (raw --green is 3.18:1) */
  /* Gradient-headline stops, AA-tuned and theme-aware via --grad-2, so the .hl
     word stays legible (deep coral → deep amber) and — unlike --coral/--amber —
     is NOT dragged below contrast by the gallery retint. */
  --grad-2: #9c5a12; /* deep amber — 4.68:1 on the cream --bg */
  --grad: linear-gradient(100deg, var(--coral-deep), var(--grad-2));
  /* Focus ring — kept a LITERAL (not `var(--coral-deep)`) and theme-aware, so no
     retint / theme override can drag the focus affordance below WCAG 1.4.11's
     3:1 on the cream bg. */
  --focus-ring: #a8431f;

  /* Semantic tokens — DAY (warm cream) */
  --bg: var(--paper);
  --bg-tint: #ede3d1;
  --surface: #fdf9ef;
  --surface-2: #ece1cd;
  --fg: var(--ink);
  --fg-muted: #6f6453;
  --border: color-mix(in srgb, var(--ink) 12%, transparent);
  --border-strong: color-mix(in srgb, var(--ink) 20%, transparent);
  --shadow: 0 1px 2px rgba(36, 28, 20, 0.05), 0 8px 24px rgba(36, 28, 20, 0.09);
  --shadow-lg: 0 2px 4px rgba(36, 28, 20, 0.06), 0 20px 50px rgba(36, 28, 20, 0.13);
  --glow: color-mix(in srgb, var(--coral) 15%, transparent);

  /* Type */
  --font-display: 'Jersey 10', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Lora', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Scale */
  --maxw: 1120px;
  --radius: 16px;
  --radius-sm: 10px;
}

:root[data-theme='night'] {
  /* warm "after-hours office" dark — pairs with the night-office renders */
  --coral: #e3845f;
  --coral-deep: #f0a07f;
  --amber: #ecae66;
  --ok: #788c5d; /* 4.79:1 on the night --bg */
  --grad-2: #ecae66; /* light amber — high contrast on the dark night --bg */
  --focus-ring: #e3845f; /* literal; matches the night --coral (see :root note) */
  --bg: #1d1813;
  --bg-tint: #18130f;
  --surface: #271f17;
  --surface-2: #322820;
  --fg: #f4eee2;
  --fg-muted: #b3a890;
  --border: color-mix(in srgb, #f4eee2 13%, transparent);
  --border-strong: color-mix(in srgb, #f4eee2 24%, transparent);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 60px rgba(0, 0, 0, 0.6);
  --glow: color-mix(in srgb, var(--coral) 24%, transparent);
}

/* ---------- reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  font-size: clamp(1rem, 0.95rem + 0.2vw, 1.115rem);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition:
    background-color 0.5s ease,
    color 0.5s ease;
  overflow-x: hidden;
}

/* warm dawn-glow atmosphere */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 80% -10%, var(--glow), transparent 60%),
    radial-gradient(
      90% 60% at 6% 0%,
      color-mix(in srgb, var(--amber) 9%, transparent),
      transparent 55%
    );
}

img {
  max-width: 100%;
  display: block;
}
a {
  color: var(--coral-deep);
  text-underline-offset: 2px;
}
:root[data-theme='night'] a {
  color: var(--coral);
}

/* Visible keyboard focus on every interactive control (WCAG 2.4.7) — the design
   defined :hover but had no focus affordance. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 3px;
}

/* skip-to-content: off-screen until focused (WCAG 2.4.1 Bypass Blocks) */
.skip-link {
  position: fixed;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 10000;
  transform: translateY(-150%);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.skip-link:focus {
  transform: none;
}

/* ---------- type ---------- */
h1,
h2,
h3 {
  font-family: var(--font-display);
  /* Jersey 10 ships a single weight — request 400 and forbid synthesis so the
     browser never fake-bolds it (faux-bold smears a pixel font's crisp edges). */
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.04;
  letter-spacing: 0;
  color: var(--fg);
}
h1 {
  font-size: clamp(2.5rem, 1.7rem + 3.6vw, 4.6rem);
}
h2 {
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.9rem);
}
h3 {
  font-size: clamp(1.15rem, 1.04rem + 0.5vw, 1.4rem);
  /* stays 400: Jersey 10 is single-weight, and a 600 here would only be a dead
     declaration (the h1,h2,h3 font-synthesis:none guard already blocks faux-bold)
     until someone relaxes that guard — then h3 would smear. Keep them in sync. */
  font-weight: 400;
}
/* terminal-prompt eyebrow */
.eyebrow {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--coral-deep);
}
.eyebrow::before {
  content: '› ';
  opacity: 0.7;
}
:root[data-theme='night'] .eyebrow {
  color: var(--coral);
}
.lead {
  font-size: clamp(1.08rem, 1rem + 0.5vw, 1.34rem);
  color: var(--fg-muted);
  max-width: 42ch;
}
/* coral→amber gradient headline word */
.hl {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* blinking block cursor */
.cursor {
  display: inline-block;
  width: 0.55ch;
  height: 0.92em;
  margin-left: 0.08em;
  transform: translateY(0.08em);
  background: var(--coral);
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- layout ---------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem);
}
section {
  padding-block: clamp(3.2rem, 7vw, 6rem);
}
.section-head {
  max-width: 48ch;
  margin-bottom: clamp(1.8rem, 4vw, 3rem);
}
.section-head .lead {
  margin-top: 0.9rem;
}

/* ASCII pixel divider between sections */
.px-rule {
  height: 6px;
  width: min(100%, var(--maxw));
  margin: 0 auto;
  border: 0;
  background: repeating-linear-gradient(90deg, var(--coral) 0 6px, transparent 6px 14px);
  image-rendering: pixelated;
  opacity: 0.4;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

/* ---------- buttons (mono, terminal) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.72rem 1.3rem;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease;
}
.btn:hover {
  transform: translateY(-2px);
}
.btn-primary {
  /* deep-coral gradient (NOT the light amber end of --grad) + a text-shadow so
     the white label stays legible in both day and night. The glow uses a FIXED
     coral (not var(--coral)) so it matches the baked fill in every theme and
     gallery retint instead of drifting to the theme hue. */
  background: linear-gradient(100deg, #ad5230, #c96a45);
  color: #fff;
  text-shadow: 0 1px 2px rgba(35, 14, 5, 0.4);
  box-shadow: 0 8px 20px color-mix(in srgb, #c96a45 42%, transparent);
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  background: color-mix(in srgb, var(--fg) 5%, transparent);
}

/* ---------- surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* faux terminal window + subtle CRT scanlines on the screen */
.terminal {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.terminal__bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.terminal__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gray);
}
.terminal__dot--r {
  background: #e06a5a;
}
.terminal__dot--y {
  background: #e3b341;
}
.terminal__dot--g {
  background: var(--green);
}
.terminal__title {
  margin-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.terminal__screen {
  display: block;
  width: 100%;
  background: #0e0d0c;
}
/* scanline overlay — very faint, only reads as CRT texture up close */
.terminal__scan {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 38px; /* below the title bar */
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

/* crisp pixel art at any scale */
.px {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* ---------- reveal-on-scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.7s ease,
    transform 0.7s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
  .cursor,
  .hl {
    animation: none;
  }
  .crt.crt-on .terminal__screen {
    animation: none;
  }
}

/* ============================================================
   FX layer — tasteful flair, all reduced-motion-safe above
   ============================================================ */

/* animated shimmer across the gradient headline word */
.hl {
  background-size: 220% 100%;
  animation: shimmer 7s ease-in-out infinite;
}
@keyframes shimmer {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* CRT power-on when a terminal scrolls into view */
.crt.crt-on .terminal__screen {
  animation: crt-on 0.9s ease-out both;
}
@keyframes crt-on {
  0% {
    opacity: 0;
    filter: brightness(3) saturate(0) blur(2px);
    transform: scaleY(0.7);
  }
  9% {
    opacity: 1;
    transform: scaleY(1.02);
  }
  14% {
    filter: brightness(1.5) saturate(1.2);
  }
  22% {
    filter: brightness(0.75);
    transform: scaleY(1);
  }
  40% {
    filter: brightness(1.25);
  }
  100% {
    filter: none;
  }
}

/* retint pulse on the theme preview */
@keyframes retint-pulse {
  0% {
    box-shadow:
      var(--shadow-lg),
      0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  }
  100% {
    box-shadow:
      var(--shadow-lg),
      0 0 0 24px transparent;
  }
}
.retint-pulse {
  animation: retint-pulse 0.6s ease-out;
}

/* Dracula — hidden easter-egg theme (type "dracula"; Esc restores) */
:root[data-theme='dracula'] {
  --coral: #bd93f9;
  --coral-deep: #caa6fb;
  --amber: #ff79c6;
  --ok: #9db87e; /* 6.50:1 on the dracula --bg */
  --grad-2: #ff79c6; /* light pink — high contrast on the dark dracula --bg */
  --focus-ring: #caa6fb; /* literal; matches the dracula --coral-deep (see :root note) */
  --bg: #282a36;
  --bg-tint: #21222c;
  --surface: #343746;
  --surface-2: #44475a;
  --fg: #f8f8f2;
  --fg-muted: #8b92bd;
  --border: color-mix(in srgb, #f8f8f2 13%, transparent);
  --border-strong: color-mix(in srgb, #f8f8f2 24%, transparent);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 60px rgba(0, 0, 0, 0.6);
  --glow: color-mix(in srgb, var(--coral) 26%, transparent);
}

/* ---------- boot intro overlay ---------- */
.boot {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: var(--font-mono);
  color: var(--fg-muted);
  font-size: clamp(0.82rem, 0.74rem + 0.4vw, 1rem);
  line-height: 1.95;
  transition: opacity 0.45s ease;
}
:root[data-booting='1'] .boot {
  display: flex;
}
.boot.is-done {
  opacity: 0;
  pointer-events: none;
}
.boot__log {
  width: min(86vw, 420px);
}
.boot__line {
  opacity: 0;
  transition: opacity 0.25s ease;
}
.boot__line.in {
  opacity: 1;
}
.boot__line b {
  color: var(--fg);
}
.boot__ok {
  color: var(--ok);
}
.boot__hint {
  margin-top: 1.4rem;
  font-size: 0.72rem;
  opacity: 0.55;
}

/* ---------- prose: rendered markdown (the /config page) ---------- */
.prose {
  line-height: 1.7;
}
.prose h1 {
  font-size: clamp(2.2rem, 1.6rem + 2.2vw, 3.1rem);
  margin-bottom: 0.5rem;
}
.prose h2 {
  font-size: clamp(1.45rem, 1.2rem + 1.3vw, 1.95rem);
  margin: 2.2rem 0 0.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}
.prose h3 {
  margin: 1.6rem 0 0.5rem;
}
.prose p,
.prose li {
  color: var(--fg);
}
.prose a {
  color: var(--coral-deep);
  font-weight: 600;
}
:root[data-theme='night'] .prose a,
:root[data-theme='dracula'] .prose a {
  color: var(--coral);
}
.prose ul {
  padding-left: 1.3rem;
}
.prose li {
  margin: 0.3rem 0;
}
/* inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.08rem 0.34rem;
}
/* fenced code blocks (Shiki sets the colors; we frame them) */
.prose pre {
  margin: 1.2rem 0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}
.prose pre code {
  font-family: var(--font-mono);
}
/* tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.95rem;
}
.prose th,
.prose td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  vertical-align: top;
}
.prose th {
  background: var(--surface-2);
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
}
/* architecture diagram (```mermaid → build-time inline SVG): frame it in a fixed
   light "terminal screen" so the day-palette SVG stays legible on night/dracula,
   and make it responsive (the SVG keeps its viewBox aspect). */
.prose svg {
  display: block;
  width: 100%;
  max-width: 820px;
  height: auto;
  margin: 1.8rem auto;
  padding: clamp(0.8rem, 2vw, 1.4rem);
  background: #fbfaf6;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
/* mermaid renders labels as HTML inside <foreignObject> (htmlLabels), so the
   page's `.prose p{color:var(--fg)}` / `.prose a{color:coral}` / `.prose code
   {background:surface-2}` cascade leaks in and makes the labels invisible on the
   light frame in night/dracula. The frame is always light, so pin every label to
   dark ink on a light backing — readable on all themes. (Scope fill: to text
   elements only; arrowheads/edges are <path> and keep mermaid's stroke colors.) */
.prose svg .nodeLabel,
.prose svg .nodeLabel p,
.prose svg .edgeLabel,
.prose svg .edgeLabel p,
.prose svg .cluster-label,
.prose svg .cluster-label p,
.prose svg span,
.prose svg p,
.prose svg text,
.prose svg tspan {
  color: #241c14 !important;
  fill: #241c14 !important;
}
.prose svg .edgeLabel,
.prose svg .edgeLabel p,
.prose svg .edgeLabel rect,
.prose svg .labelBkg,
.prose svg foreignObject code {
  background: #fbfaf6 !important;
  fill: #fbfaf6 !important;
  border-color: transparent !important;
}
/* mermaid bakes edge @keyframes into the SVG — keep them inert for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .prose svg [class*='edge'] {
    animation: none !important;
  }
}
