/* ==========================================================================
   Ambient — site design system (v2)
   Near-black canvas, hairline grid frame with "+" marks at intersections,
   Geist display/body, Geist Mono for labels. One accent: Ambient orange,
   used sparingly (live dots, cursor, highlights).
   Loaded by layouts/Site.astro (landing page + blog). The docs mirror these
   tokens in src/styles/starlight.css; the replay app in replay/src/globals.css.
   ========================================================================== */

/* ----- Tokens ----------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg:          #0a0a0a;
  --bg-2:        #0e0e0e;
  --panel:       #111111;
  --panel-2:     #161616;
  --panel-3:     #1c1c1c;

  /* Lines */
  --line:        rgba(255, 255, 255, 0.08);
  --line-2:      rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.16);
  --hairline:    var(--line);            /* names the blog components and AgentSetupModal use */
  --hairline-2:  var(--line-2);
  --ink-panel:   #1f1f1f;                /* tooltips, video backdrops */
  --on-ink:      #ededed;
  --on-ink-muted:#a0a0a0;
  --ink-2:       #b4b4b4;                /* body text inside components */
  --accent-soft: rgba(255, 90, 20, 0.14);
  --wash:        rgba(255, 255, 255, 0.06);  /* hover fills, dotted backdrops */
  --wash-2:      rgba(255, 255, 255, 0.10);
  --nav-bg:      rgba(10, 10, 10, 0.78);
  --btn-bg:      #f2f2f2;                /* primary button: inverts with the theme */
  --btn-bg-hover:#ffffff;
  --btn-fg:      #0a0a0a;

  /* Chart / diagram colours that must flip with the theme */
  --c-contrast:  #e5e5e5;                /* strongest neutral mark */
  --c-ink:       #5e5e5e;                /* neutral bar that carries white text */
  --c-hatch-1:   #262626;
  --c-hatch-2:   #303030;
  --c-ghost:     #4a4a4a;
  --c-good:      #6fcf97;
  --c-bad:       #f0785f;
  --c-err:       #f07067;

  /* Text */
  --text:        #ededed;
  --text-2:      #b4b4b4;
  --text-muted:  #8a8a8a;
  --text-faint:  #5c5c5c;

  /* Accent */
  --accent:      #ff5a14;
  --accent-2:    #ff7a2e;
  --accent-dim:  rgba(255, 90, 20, 0.14);

  /* Fonts */
  --font-display: "Geist", "Inter", system-ui, sans-serif;
  --font-body:    "Geist", "Inter", system-ui, -apple-system, sans-serif;
  --font-mono:    "Geist Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Layout */
  --frame:       1200px;
  --pad:         clamp(20px, 3.2vw, 40px);  /* inner padding of the frame */
  --radius:      6px;
  --radius-sm:   4px;
  --shadow:      0 24px 60px -30px rgba(0, 0, 0, 0.9);
  --nav-h:       56px;
}

/* ----- Light theme ----------------------------------------------------- */
/* Blog pages default to light (layouts/Site.astro sets data-theme); the
   toggle in their nav switches between the two. */
:root[data-theme="light"] {
  --bg:          #fbfbfa;
  --bg-2:        #f5f5f3;
  --panel:       #ffffff;
  --panel-2:     #f4f4f2;
  --panel-3:     #ececea;
  --line:        rgba(0, 0, 0, 0.09);
  --line-2:      rgba(0, 0, 0, 0.05);
  --line-strong: rgba(0, 0, 0, 0.18);
  --ink-panel:   #1a1a1a;
  --on-ink:      #f2f2f2;
  --on-ink-muted:#a8a8a8;
  --ink-2:       #3a3a3a;
  --text:        #0a0a0a;
  --text-2:      #3a3a3a;
  --text-muted:  #6b6b6b;
  --text-faint:  #9a9a9a;
  --accent-2:    #e24e0e;
  --accent-soft: rgba(255, 90, 20, 0.10);
  --wash:        rgba(0, 0, 0, 0.04);
  --wash-2:      rgba(0, 0, 0, 0.08);
  --nav-bg:      rgba(251, 251, 250, 0.82);
  --btn-bg:      #0a0a0a;
  --btn-bg-hover:#262626;
  --btn-fg:      #fafafa;
  --shadow:      0 20px 50px -30px rgba(0, 0, 0, 0.25);
  --c-contrast:  #1a1a1a;
  --c-ink:       #2e2e2e;
  --c-hatch-1:   #e4e4e2;
  --c-hatch-2:   #efefed;
  --c-ghost:     #c4c4c4;
  --c-good:      #2f6b45;
  --c-bad:       #b4321a;
  --c-err:       #b3261e;
  color-scheme: light;
}

/* ----- Reset ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }

/* ----- Typography ------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 6.4vw, 4.6rem); letter-spacing: -0.045em; }
h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); }
h3 { font-size: 1.05rem; letter-spacing: -0.015em; line-height: 1.3; }
p  { margin: 0; }

.mono, .label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-muted);
}
.label.live::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px;
  border-radius: 50%; background: var(--accent); vertical-align: 1px;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.accent { color: var(--accent); }
.muted  { color: var(--text-muted); }

/* ----- Frame: the hairline column every band sits in ------------------- */
/* A band spans the viewport with a hairline on top; its .frame is the
   centered column with hairlines left and right and "+" marks where the
   lines cross. */
.band { position: relative; border-top: 1px solid var(--line); }
.band.flush { border-top: 0; }
.frame {
  position: relative;
  max-width: var(--frame);
  margin-inline: auto;
  border-inline: 1px solid var(--line);
  padding-inline: var(--pad);
}
.band > .frame::before,
.band > .frame::after,
.plus {
  content: "";
  position: absolute;
  top: -6px;
  width: 11px;
  height: 11px;
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) center / 1px 100% no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) center / 100% 1px no-repeat;
  pointer-events: none;
  z-index: 2;
}
.band > .frame::before { left: -6px; }
.band > .frame::after  { right: -6px; }
.band.flush > .frame::before, .band.flush > .frame::after { display: none; }

.pad-y    { padding-block: clamp(64px, 9vw, 112px); }
.pad-y-sm { padding-block: clamp(40px, 5vw, 64px); }

/* Section heading: mono label, title, lede */
.sec-head { max-width: 40rem; margin-bottom: clamp(32px, 4vw, 48px); }
.sec-head .label { display: block; margin-bottom: 18px; }
.sec-head p { margin-top: 16px; color: var(--text-muted); font-size: 1rem; max-width: 34rem; }
.sec-head.center { margin-inline: auto; text-align: center; }
.sec-head.center p { margin-inline: auto; }

/* ----- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn .arr { transition: transform 0.15s ease; }
.btn:hover .arr { transform: translateX(2px); }
.btn-light { background: var(--btn-bg); color: var(--btn-fg); }
.btn-light:hover { background: var(--btn-bg-hover); }
.btn-dark  { background: var(--panel-2); color: var(--text); border-color: var(--line-strong); }
.btn-dark:hover { border-color: var(--text-faint); background: var(--panel-3); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 0.8rem; }
.btn svg { width: 15px; height: 15px; }

/* Text link with arrow */
.tlink { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-2); transition: color .15s; }
.tlink:hover { color: var(--text); }
.tlink .arr { transition: transform 0.15s ease; }
.tlink:hover .arr { transform: translateX(2px); }

/* ----- Nav -------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav .frame { border-inline-color: transparent; }
.nav-inner { display: flex; align-items: center; gap: 28px; height: var(--nav-h); }
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 600; font-size: 1rem; letter-spacing: -0.02em; }
.brand svg { width: 20px; height: 20px; flex: none; fill: currentColor; }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { font-size: 0.82rem; color: var(--text-muted); transition: color 0.15s ease; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-gh { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--text-muted); padding: 0 6px; transition: color .15s; }
.nav-gh:hover { color: var(--text); }
.nav-gh svg { width: 16px; height: 16px; fill: currentColor; }
/* Light / dark switch (blog pages) */
.theme-toggle { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: transparent; color: var(--text-muted); cursor: pointer; transition: color .15s, border-color .15s; }
.theme-toggle:hover { color: var(--text); border-color: var(--text-faint); }
.theme-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .moon { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line-strong); border-radius: var(--radius); width: 34px; height: 34px; place-items: center; cursor: pointer; }
.nav-toggle svg { width: 16px; height: 16px; }

/* ----- Cells: a grid of bordered cells that share hairlines ------------ */
.cells { display: grid; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cells > * { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.cells.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cells.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cells.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cell { padding: 24px; background: var(--bg); transition: background 0.2s ease; }
a.cell:hover, .cell.hover:hover { background: var(--bg-2); }
.cell h3 { margin-bottom: 8px; }
.cell p { color: var(--text-muted); font-size: 0.86rem; line-height: 1.55; }

/* Boxed panel with "+" ticks on its corners */
.box { position: relative; border: 1px solid var(--line); background: var(--bg); }
.box > .plus { top: -6px; }
.box > .plus.tl { left: -6px; }
.box > .plus.tr { right: -6px; }
.box > .plus.bl { top: auto; bottom: -6px; left: -6px; }
.box > .plus.br { top: auto; bottom: -6px; right: -6px; }

/* Key/value spec rows (mono) */
.specs { display: grid; margin-top: 22px; }
.specs > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 0.72rem; }
.specs dt, .specs .k { color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.specs dd, .specs .v { margin: 0; color: var(--text-2); text-align: right; }

/* Chip */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); white-space: nowrap; }

/* ----- Code block ------------------------------------------------------- */
/* A raised panel: lighter than the page, a visible border and a tinted header,
   so commands read as the thing to copy. */
.code {
  position: relative; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.code-head { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-bottom: 1px solid var(--line-strong); background: var(--panel-3); }
.code-head .dots { display: none; }
.code-head .file { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.code-head .file::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--text-faint); vertical-align: 1px; }
.code pre { margin: 0; padding: 18px; overflow-x: auto; font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.75; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.code .cp { color: var(--accent-2); }
.code .cc { color: var(--text-muted); }
/* A shell command: "$ " is drawn by CSS so Copy (innerText) leaves it out */
.code .cmd { color: var(--text); font-weight: 500; white-space: pre; }
.code .cmd::before { content: "$ "; color: var(--accent-2); }

/* The main block on a section: orange edge and a soft glow */
.code.primary { border-color: rgba(255, 90, 20, 0.5); box-shadow: 0 0 0 4px rgba(255, 90, 20, 0.07), var(--shadow); }
.code.primary .code-head { background: linear-gradient(90deg, rgba(255, 90, 20, 0.12), transparent 70%), var(--panel-3); }
.code.primary .code-head .file { color: var(--text); }
.code.primary .code-head .file::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.copy-btn {
  position: absolute; top: 7px; right: 8px; height: 24px; padding: 0 9px;
  font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  cursor: pointer; transition: color .15s, border-color .15s;
}
.copy-btn:hover { color: var(--text); border-color: var(--text-faint); }

/* ----- Footer ----------------------------------------------------------- */
.footer .frame { padding-block: 56px 0; }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(3, minmax(0, 1fr)); gap: 32px; }
.footer .brand { margin-bottom: 12px; }
.footer-tag { color: var(--text-muted); font-size: 0.86rem; max-width: 22rem; }
.footer h4 { font-family: var(--font-mono); font-weight: 400; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.66rem; color: var(--text-faint); margin: 0 0 14px; }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.footer ul a { font-size: 0.84rem; color: var(--text-muted); transition: color .15s; }
.footer ul a:hover { color: var(--text); }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 64px; padding-block: 20px; border-top: 1px solid var(--line); margin-inline: calc(var(--pad) * -1); padding-inline: var(--pad); }
.footer-bottom span { font-family: var(--font-mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }

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

/* ----- Responsive ------------------------------------------------------- */
@media (max-width: 960px) {
  .cells.c3, .cells.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .nav-links { display: none; }
  .nav-toggle { display: grid; }
  .nav-gh-label { display: none; }
  .nav-links.open {
    display: flex; position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 16px;
    padding: 20px var(--pad); background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .nav-links.open a { font-size: 0.95rem; }
}
@media (max-width: 600px) {
  .cells.c2, .cells.c3, .cells.c4 { grid-template-columns: minmax(0, 1fr); }
  .footer-grid { grid-template-columns: 1fr; }
  .band > .frame::before, .band > .frame::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
