/* ==========================================================================
   ZettaForge design system
   Obsidian + ember (amber/copper). Editorial typography, hairlines, depth by
   luminance. Deliberately NOT the purple-gradient / centered-hero / emoji-card
   template — layout is asymmetric, copy is specific, motion is restrained.
   ========================================================================== */

@font-face {
  font-family: 'Inter Tight';
  src: url('../fonts/inter-tight-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jetbrains-mono-latin.woff2') format('woff2');
  font-weight: 400 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF;
}

:root {
  color-scheme: dark;

  /* Surfaces — luminance stack, near-black with a warm coal undertone */
  --bg: #0a0908;
  --bg-2: #0e0d0b;
  --panel: #12110e;
  --raise: #191713;
  --raise-2: #211e18;
  --line: rgba(255, 241, 222, 0.07);
  --line-strong: rgba(255, 241, 222, 0.13);
  /* Interaction surfaces. A white overlay only reads on a dark backdrop; in
     light mode these must become a *dark* wash, otherwise hover/pressed states
     are invisible. Everything that tints a surface uses these. */
  --hover: rgba(255, 241, 222, 0.06);
  --hover-strong: rgba(255, 241, 222, 0.10);
  --raise-soft: rgba(255, 241, 222, 0.035);
  --card-grad: linear-gradient(180deg, rgba(255, 241, 222, 0.045), rgba(255, 241, 222, 0.015));
  --card-grad-hover: linear-gradient(180deg, rgba(255, 241, 222, 0.07), rgba(255, 241, 222, 0.025));
  --btn-face: rgba(255, 241, 222, 0.04);
  --inset-hi: rgba(255, 246, 234, 0.06);
  /* Inverted "feature" panel (the closing CTA): dark in both themes by design,
     so it carries its own ink ramp. */
  --band-bg: linear-gradient(140deg, #17130e, #0d0b09 60%);
  --band-ink: #f4efe6;
  --band-ink-dim: #c9c2b5;
  --band-line: rgba(255, 241, 222, 0.13);

  /* Ink */
  --ink: #f4efe6;
  --ink-2: #c9c2b5;
  --ink-3: #8d877c;
  --ink-4: #8b857a; /* ≥4.5:1 on --bg for small text (WCAG 1.4.3) */
  /* Code blocks keep a dark surface in both themes, so they need their own
     foreground ramp; using --ink-* here made text invisible in light mode. */
  --code-bg: #0c0a08;
  --code-ink: #d9d2c5;
  --code-ink-dim: #a49c8d;
  --code-head: rgba(255, 241, 222, 0.06);
  --code-border: rgba(255, 241, 222, 0.16);
  --code-k: #ff9d5c;
  --code-s: #93d8a8;
  --code-c: #8a8378;
  --code-f: #8fb6ff;
  --mini-bg: #0c0a08;
  --mini-ink: #d9d2c5;
  --mini-ink-dim: #a49c8d;
  --mini-k: #ff9d5c;
  --mini-s: #7ee0b0;

  /* Ember accent — the only saturated hue */
  --ember: #ff8a3d;
  --ember-hi: #ffa76b;
  --ember-lo: #c2581c;
  --ember-glow: rgba(255, 138, 61, 0.16);
  --ember-on-tint: #ffb27a;
  --copper: #b87333;
  --mint: #74d6a7;
  --rose: #f0707f;
  --sky: #8fb6ff;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-pill: 999px;

  --sans: 'Inter Tight', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* Motion scale: long, soft, consistent. Hover feedback stays snappy; layout
     and entrance motion use --ease-slow. */
  --dur-fast: 240ms;
  --dur: 380ms;
  --dur-slow: 900ms;
  --ease-slow: cubic-bezier(0.16, 1, 0.3, 1);
  --max: 1240px;
  --gutter: clamp(18px, 4vw, 48px);

  --nav-h: 64px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f6f3ec;
  --bg-2: #efeae0;
  --panel: #fbf9f5;
  --raise: #ffffff;
  --raise-2: #f2ece1;
  --line: rgba(42, 32, 20, 0.10);
  --line-strong: rgba(42, 32, 20, 0.18);
  --hover: rgba(42, 32, 20, 0.055);
  --hover-strong: rgba(42, 32, 20, 0.09);
  --raise-soft: rgba(255, 255, 255, 0.70);
  --card-grad: linear-gradient(180deg, #fbf9f5, #f7f3ea);
  --card-grad-hover: linear-gradient(180deg, #ffffff, #faf7f0);
  --btn-face: #ffffff;
  --inset-hi: rgba(255, 255, 255, 0.85);
  --band-bg: linear-gradient(140deg, #201a13, #120f0b 60%);
  --band-ink: #f4efe6;
  --band-ink-dim: #c9c2b5;
  --band-line: rgba(255, 241, 222, 0.16);
  --ink: #1b1712;
  --ink-2: #4a4238;
  --ink-3: #6b6357;
  --ink-4: #6f665a; /* ≥4.5:1 on --bg (was #a59c8e = 2.45:1) */
  --ember: #a8450c; /* ≥4.5:1 on --bg for link/accent text */
  --ember-hi: #c2540f;
  --ember-lo: #8a3606;
  --ember-glow: rgba(210, 90, 18, 0.12);
  /* Text on a tinted ember wash needs a darker tone than --ember-hi, which is
     tuned for solid accents. 3.96:1 -> 5.3:1 on the callout background. */
  --ember-on-tint: #7d3208;
  --mint: #0f7a4e;
  --rose: #c03a4d;
  --sky: #2f62c4;
  /* The big install snippet stays dark in both themes (it is a terminal).
     The small inline "viz" boxes inside light cards follow the page instead,
     otherwise two black slabs dominate an otherwise light layout. */
  --code-bg: #fbf9f5;
  --code-ink: #241f19;
  --code-ink-dim: #5f574b;
  --code-head: rgba(42, 32, 20, 0.05);
  --code-border: rgba(42, 32, 20, 0.22);
  --code-k: #9a4409;
  --code-s: #166b45;
  --code-c: #6b6357;
  --code-f: #1f4f9c;
  --mini-bg: #f3eee4;
  --mini-ink: #3d352a;
  --mini-ink-dim: #6b6357;
  --mini-k: #a8450c;
  --mini-s: #0f7a4e;
}

/* Light theme: a mid ember under near-black text is only 3.2:1, so the primary
   button switches to white text on the deeper ember (5.4:1). */
:root[data-theme='light'] .btn-primary { background: #a8450c; color: #fff; }
:root[data-theme='light'] .btn-primary:hover { background: #8f3a08; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  /* Entrance animations start from opacity:0; with transitions disabled they
     would never become visible, so reveal elements must be shown outright. */
  .reveal { opacity: 1 !important; transform: none !important; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: 'cv01', 'ss03';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--ember); color: #160c05; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; border-radius: 6px; }
/* Buttons get a faint inner highlight so they read as pressed metal, not flat boxes. */
.btn { box-shadow: inset 0 1px 0 var(--inset-hi); }
.btn-primary { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 10px 30px -12px rgba(255, 138, 61, 0.55); }


/* Scrollbar (subtle, native on mobile) */
@media (pointer: fine) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: var(--raise-2); border-radius: 8px; border: 2px solid var(--bg); }
  ::-webkit-scrollbar-track { background: transparent; }
}

/* ── Typography ───────────────────────────────────────────────────────── */
h1, h2, h3, h4 { margin: 0; font-weight: 560; letter-spacing: -0.02em; line-height: 1.08; }
.display {
  font-size: clamp(2.6rem, 6.4vw, 5.2rem);
  font-weight: 560;
  letter-spacing: -0.045em;
  line-height: 0.98;
}
.display em { font-style: normal; color: var(--ember); }
h2.section { font-size: clamp(1.7rem, 3.2vw, 2.6rem); letter-spacing: -0.03em; }
h3 { font-size: 1.125rem; letter-spacing: -0.015em; }
.lead { color: var(--ink-2); font-size: clamp(1rem, 1.4vw, 1.18rem); line-height: 1.6; max-width: 58ch; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-variant-ligatures: none; }
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: ''; width: 18px; height: 1px; background: var(--ember); }

/* ── Layout ───────────────────────────────────────────────────────────── */
.wrap { width: min(var(--max), 100% - var(--gutter) * 2); margin-inline: auto; }
.section-pad { padding-block: clamp(64px, 10vw, 128px); }
.grid { display: grid; gap: clamp(14px, 2vw, 22px); }
.hairline { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ── Navigation ───────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.nav[data-stuck='true'] { border-bottom-color: var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); }
.nav-inner { display: flex; align-items: center; gap: 28px; width: min(var(--max), 100% - var(--gutter) * 2); margin-inline: auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 620; letter-spacing: -0.03em; font-size: 17px; }
.brand-mark { width: 26px; height: 26px; }
.nav-links { display: flex; gap: 22px; margin-left: 8px; }
.nav-links a { font-size: 14px; color: var(--ink-3); transition: color .2s var(--ease); }
.nav-links a:hover, .nav-links a[aria-current] { color: var(--ink); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* Mobile menu */

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  --bg-btn: var(--btn-face);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-btn);
  color: var(--ink);
  font-size: 14px; font-weight: 540; letter-spacing: -0.01em;
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:hover { background: var(--hover); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .5; pointer-events: none; }
.btn-primary {
  background: var(--ember); border-color: transparent; color: #170b04;
  box-shadow: 0 0 0 0 var(--ember-glow), 0 10px 30px -12px rgba(255, 138, 61, .55);
}
.btn-primary:hover { background: var(--ember-hi); box-shadow: 0 0 0 5px var(--ember-glow), 0 14px 34px -12px rgba(255, 138, 61, .6); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); background: var(--hover); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-xs); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-icon { width: 36px; padding: 0; }
.btn-danger { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 35%, transparent); }

/* Placed after the `.btn` rules so it wins the cascade — otherwise the
   hamburger button shows up on desktop. */
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav[data-open='true'] .nav-links {
    display: flex; flex-direction: column; gap: 4px;
    position: absolute; inset: var(--nav-h) 0 auto 0;
    padding: 12px var(--gutter) 20px;
    background: var(--bg-2); border-bottom: 1px solid var(--line);
  }
  .nav[data-open='true'] .nav-links a { padding: 12px 0; font-size: 17px; color: var(--ink); border-bottom: 1px solid var(--line); }
  .nav-actions .hide-sm { display: none; }
}


/* ── Surfaces ─────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.card {
  background: var(--card-grad);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 22px;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { border-color: var(--line-strong); background: var(--card-grad-hover); }
/* corner-tick detail (precision-engineered feel) */
.tick { position: relative; }
.tick::before, .tick::after {
  content: ''; position: absolute; width: 9px; height: 9px; pointer-events: none;
  border-color: color-mix(in srgb, var(--ember) 60%, transparent); border-style: solid;
}
.tick::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; border-top-left-radius: 4px; }
.tick::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; border-bottom-right-radius: 4px; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 8px; margin-bottom: 2px; }
.field > label { font-size: 13px; line-height: 1.5; color: var(--ink-2); font-weight: 520; }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 10px 12px;
  background: var(--raise-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
  font-size: 14px;
}
html[data-theme='light'] .input, html[data-theme='light'] .select, html[data-theme='light'] .textarea { background: #fff; }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--ember);
  box-shadow: 0 0 0 3px var(--ember-glow);
  /* Do not rely on box-shadow alone: Windows High Contrast and forced-colors
     mode drop shadows, leaving a focused field with no visible indicator.
     A transparent outline keeps the default ring available to those modes. */
  outline: 2px solid transparent;
  outline-offset: 1px;
}
@media (forced-colors: active) {
  .input:focus, .select:focus, .textarea:focus,
  .btn:focus-visible, a:focus-visible, [data-theme-toggle]:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.hint { font-size: 12px; color: var(--ink-3); }
.error-text { font-size: 12.5px; color: var(--rose); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 520; border: 1px solid var(--line-strong); color: var(--ink-2);
  background: var(--raise-soft);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.badge-warn .badge-dot { background: var(--ember); box-shadow: 0 0 8px var(--ember); }
.badge-bad .badge-dot { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
/* Tint the label, not just the dot: a failed request must be readable at a
   glance in a dense table, and colour alone fails WCAG 1.4.1 for the ~8% of
   men with red-green deficiency, so the text spells out the status too. */
.badge-warn { color: var(--ember); border-color: rgba(255, 138, 61, 0.34); background: rgba(255, 138, 61, 0.09); }
.badge-bad { color: var(--rose); border-color: rgba(240, 112, 127, 0.34); background: rgba(240, 112, 127, 0.09); }
.badge-ok { color: var(--mint); border-color: rgba(126, 217, 173, 0.28); background: rgba(126, 217, 173, 0.07); }

/* ── Table ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--raise-2); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }

/* ── Toast / dialog ───────────────────────────────────────────────────── */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--raise); border: 1px solid var(--line-strong);
  box-shadow: 0 18px 40px -18px rgba(0,0,0,.8);
  font-size: 13.5px; color: var(--ink);
  animation: toast-in .28s var(--ease);
}
.toast::before { content: ''; width: 3px; align-self: stretch; border-radius: 2px; background: var(--ember); }
.toast[data-kind='error']::before { background: var(--rose); }
.toast[data-kind='ok']::before { background: var(--mint); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

dialog.modal {
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  background: var(--panel); color: var(--ink);
  padding: 0; width: min(520px, calc(100vw - 32px));
  box-shadow: 0 40px 100px -30px rgba(0,0,0,.9);
}
dialog.modal::backdrop { background: rgba(5, 4, 3, 0.72); backdrop-filter: blur(4px); }
.modal-head { padding: 20px 22px 0; }
.modal-body { padding: 16px 22px; display: grid; gap: 14px; }
.modal-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ── Utilities ────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }
.wrap-flex { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
/* The `hidden` attribute must win over component display rules.
   `[hidden]` in the UA sheet loses to `.field { display: grid }`, which made
   the two-factor field visible on every sign-in. */
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos { color: var(--mint); }
.neg { color: var(--rose); }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--raise) 25%, var(--raise-2) 37%, var(--raise) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.reveal { opacity: 0; transform: translateY(26px); transition: opacity var(--dur-slow) var(--ease-slow), transform var(--dur-slow) var(--ease-slow); will-change: opacity, transform; }
.reveal.in { will-change: auto; }
.reveal.in { opacity: 1; transform: none; }

/* ── Responsive type/space ───────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .card { padding: 16px; }
  .btn { height: 42px; }
}
