/* styles.css - base, components, layout, responsive
 * One organized sheet. Spacing comes only from the token scale, so the
 * vertical and horizontal rhythm stays consistent everywhere.
 */

/* ───────────────────────── Reset ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
img, svg { display: block; max-width: 100%; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

/* ─────────────────────── Typography ────────────────────── */
h1, h2, h3, h4 { color: var(--ink); text-wrap: balance; line-height: 1.05; }
/* Serif (Fraunces) is reserved for the big display moments; hierarchy comes
   from weight, not just color. Everything else stays in the grotesque. */
h1, h2 { font-family: var(--font-display); font-optical-sizing: auto; }
h3, h4 { font-family: var(--font-body); }
h1 { font-size: var(--text-2xl); font-weight: 400; letter-spacing: -0.018em; line-height: 1.0; }
h2 { font-size: var(--text-xl); font-weight: 500; letter-spacing: -0.012em; }
h3 { font-size: var(--text-md); font-weight: 600; letter-spacing: -0.01em; }

p { color: var(--ink-2); }
strong, b { font-weight: 600; color: var(--ink); }

a { color: var(--ink); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--accent); }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--code-ink);
  background: var(--bg);
  box-shadow: var(--nm-inset-sm);
  padding: 0.1em 0.45em;
  border-radius: 6px;
}

::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible {
  outline: 2.5px solid var(--accent-ring);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Skip link */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--bg); color: var(--ink);
  box-shadow: var(--nm-raised); border-radius: var(--radius-sm);
}
.skip-link:focus { position: fixed; left: var(--space-4); top: var(--space-4); }

/* ──────────────────── Layout primitives ────────────────── */
.container { width: 100%; max-width: var(--container-max); margin-inline: auto; padding-inline: var(--container-pad); }

.section { padding-top: var(--section-y); }
main { padding-bottom: var(--section-y); }

.section__head { max-width: 46rem; margin-bottom: var(--space-6); }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--space-4);
}
.eyebrow::before {
  content: ""; width: 7px; height: 7px; border-radius: var(--radius-full);
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); flex-shrink: 0;
}
.section__lead {
  font-size: var(--text-md);
  color: var(--ink-2);
  max-width: 42rem;
  margin-top: var(--space-4);
  line-height: 1.55;
}

/* ─────────────── Neumorphic primitives ─────────────────── */
.nm-raised {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--nm-raised);
}
.nm-inset {
  background: var(--bg);
  border-radius: var(--radius-md);
  box-shadow: var(--nm-inset);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font-body); font-weight: 500; font-size: var(--text-base);
  letter-spacing: -0.01em;
  min-height: var(--touch-min); padding: 0 var(--space-5);
  border: 0; border-radius: var(--radius-full); cursor: pointer;
  background: var(--bg); color: var(--ink);
  box-shadow: var(--nm-raised-sm);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--nm-raised); }
.btn:active { transform: translateY(0); box-shadow: var(--nm-inset-sm); }
.btn--accent {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 20px var(--accent-soft), inset 0 1px 0 oklch(100% 0 0 / 0.22);
}
.btn--accent:hover { background: var(--accent-hover); color: var(--accent-ink); transform: translateY(-2px); box-shadow: 0 12px 26px var(--accent-soft), inset 0 1px 0 oklch(100% 0 0 / 0.22); }
.btn--accent:active { transform: translateY(0); box-shadow: 0 4px 10px var(--accent-soft); }

/* ────────────────────────── Header ─────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
}
.site-header__inner {
  display: flex; align-items: center; gap: var(--space-5);
  height: 64px;
}
.brand {
  display: inline-flex; align-items: center; gap: var(--space-3);
  font-family: var(--font-body); font-weight: 600; font-size: var(--text-md);
  letter-spacing: -0.02em; color: var(--ink); margin-right: auto;
}
.brand:hover { color: var(--ink); }
.brand__mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg); color: var(--accent); box-shadow: var(--nm-raised-sm);
  font-size: 16px;
}
.brand__name b { color: var(--accent); font-weight: 600; padding-inline: 0.1em; }

.nav { position: relative; }
.nav__toggle {
  display: grid; place-items: center; list-style: none; cursor: pointer;
  width: var(--touch-min); height: var(--touch-min); border-radius: var(--radius-full);
  background: var(--bg); color: var(--ink-2); box-shadow: var(--nm-raised-sm);
}
.nav__toggle::-webkit-details-marker { display: none; }
.nav__toggle .i-close { display: none; }
.nav[open] .nav__toggle .i-open { display: none; }
.nav[open] .nav__toggle .i-close { display: block; }

.nav__links { list-style: none; display: none; }
.nav[open] .nav__links {
  display: flex; flex-direction: column;
  position: absolute; right: 0; top: calc(100% + var(--space-3));
  min-width: 210px; padding: var(--space-3);
  background: var(--bg); border-radius: var(--radius-md); box-shadow: var(--nm-raised-lg);
  z-index: 60;
}
.nav__links a {
  display: block; padding: var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-base); font-weight: 500; color: var(--ink-2);
}
.nav__links a:hover { color: var(--ink); box-shadow: var(--nm-inset-sm); }

.header-tools { display: flex; align-items: center; gap: var(--space-3); }
.icon-link {
  display: inline-grid; place-items: center;
  width: var(--touch-min); height: var(--touch-min); border-radius: var(--radius-full);
  color: var(--ink-2);
}
.icon-link:hover { color: var(--ink); }

/* Theme toggle */
.toggle {
  position: relative; width: 58px; height: 32px; border: 0; cursor: pointer; flex-shrink: 0;
  border-radius: var(--radius-full); background: var(--bg); box-shadow: var(--nm-inset-sm);
}
.toggle::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px;
  border-radius: var(--radius-full); background: var(--bg); box-shadow: var(--nm-raised-sm);
  transition: transform var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}
.toggle[data-state="dark"]::after { transform: translateX(26px); background: var(--accent); }

/* ─────────────────────────── Hero ──────────────────────── */
.hero { padding-top: clamp(3rem, 8vw, 5.5rem); }
.hero__inner { max-width: 48rem; }
.hero h1 { margin-bottom: var(--space-5); }
.hero h1 .accent { color: var(--accent); font-weight: 600; }
.hero__sub {
  font-size: var(--text-md); color: var(--ink-2); max-width: 36rem;
  line-height: 1.55; margin-bottom: var(--space-6);
}
.hero__cta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-7); }

/* Signature: the instrument readout (inset, mono) */
.readout {
  background: var(--bg); border-radius: var(--radius-md); box-shadow: var(--nm-inset);
  padding: var(--space-5);
  font-family: var(--font-mono); font-size: var(--text-sm); line-height: 2;
  max-width: 34rem; color: var(--ink-2);
  overflow-x: auto;
}
.readout b { color: var(--ink); font-weight: 500; }
.readout .arrow { color: var(--accent); font-weight: 600; padding-inline: 0.2em; }
.readout .muted { color: var(--ink-3); }

.hero__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-5);
  margin-top: var(--space-5); font-size: var(--text-sm); color: var(--ink-3);
}
.hero__meta a { color: var(--ink-2); font-weight: 500; }
.hero__meta a:hover { color: var(--accent); }
.hero__meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); opacity: 0.5; }

/* ─────────────────────────── Cards ─────────────────────── */
.grid { display: grid; gap: var(--gap-card); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--nm-raised);
  padding: var(--pad-card);
  display: flex; flex-direction: column;
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.card__mark {
  width: 40px; height: 40px; border-radius: 12px; margin-bottom: var(--space-4);
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg); box-shadow: var(--nm-inset-sm);
  color: var(--accent); font-family: var(--font-body); font-weight: 600; font-size: var(--text-md);
}
.card h3 { margin-bottom: var(--space-2); }
.card p { font-size: var(--text-sm); color: var(--ink-2); line-height: 1.55; }
.card p code { font-size: 0.92em; }
@media (hover: hover) {
  .card:hover { transform: translateY(-4px); box-shadow: var(--nm-raised-lg); }
}

/* Command tier card */
.tier__essence { font-size: var(--text-sm); color: var(--ink-2); margin-bottom: var(--space-4); }
.cmd-list { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.cmd-list li {
  position: relative; padding-left: 1.4em; font-size: var(--text-sm); color: var(--ink-2);
}
.cmd-list li::before { content: "›"; position: absolute; left: 0; color: var(--accent); font-family: var(--font-mono); font-weight: 600; }
.cmd-list li.is-pass::before { content: "→"; color: var(--ink-3); }
.cmd-list li.is-refused::before { content: "×"; color: var(--danger); }
.cmd-list code { background: none; box-shadow: none; padding: 0; color: var(--code-ink); font-size: 0.88em; }

.tier__more { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--hairline); }
.tier__more > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.04em; color: var(--accent);
  min-height: 28px;
}
.tier__more > summary::-webkit-details-marker { display: none; }
.tier__more > summary::after { content: "+"; font-weight: 700; }
.tier__more[open] > summary::after { content: "−"; }
.tier__more[open] > summary { color: var(--ink-3); }
.tier__more .cmd-list { margin-top: var(--space-3); }

/* ───────────────────── Flow (how it works) ─────────────── */
.flow { display: flex; align-items: stretch; gap: var(--space-4); margin-top: var(--space-2); }
.flow__node {
  flex: 1; background: var(--bg); border-radius: var(--radius-md); box-shadow: var(--nm-raised);
  padding: var(--space-5); text-align: center;
}
.flow__node.is-dest { box-shadow: 0 10px 28px var(--accent-soft), inset 0 0 0 1.5px var(--accent); }
.flow__node h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.flow__node.is-dest h3 { color: var(--accent); }
.flow__node p { font-size: var(--text-xs); color: var(--ink-3); font-family: var(--font-mono); line-height: 1.5; }
.flow__arrow { display: grid; place-items: center; color: var(--accent); font-size: var(--text-lg); flex-shrink: 0; }
.flow__note { margin-top: var(--space-5); font-size: var(--text-sm); color: var(--ink-3); max-width: 42rem; }

/* ───────────────────────── Steps ───────────────────────── */
.steps { counter-reset: step; display: flex; flex-direction: column; gap: var(--space-5); }
.step { display: grid; grid-template-columns: auto 1fr; gap: var(--space-4); align-items: start; }
.step__n {
  counter-increment: step; width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-content: center; border-radius: var(--radius-full);
  background: var(--bg); box-shadow: var(--nm-raised-sm);
  font-family: var(--font-body); font-weight: 600; color: var(--accent);
}
.step__n::before { content: counter(step); }
.step h3 { margin-bottom: var(--space-2); }
.step p { font-size: var(--text-sm); color: var(--ink-2); margin-bottom: var(--space-3); }
.step pre { margin: 0; }

pre {
  font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.6;
  background: var(--bg); color: var(--code-ink); box-shadow: var(--nm-inset);
  padding: var(--space-4); border-radius: var(--radius-md); overflow-x: auto;
}
pre code { background: none; box-shadow: none; padding: 0; color: inherit; font-size: inherit; }
.tok-prompt { color: var(--ink-3); user-select: none; }
.tok-cmd { color: var(--accent); }

.source-card { margin-top: var(--space-5); }
.source-card > summary {
  list-style: none; cursor: pointer; padding: var(--space-4) var(--pad-card);
  font-family: var(--font-body); font-weight: 500; font-size: var(--text-base);
  display: flex; align-items: center; justify-content: space-between;
}
.source-card > summary::-webkit-details-marker { display: none; }
.source-card > summary::after { content: "›"; color: var(--accent); transition: transform var(--dur-base) var(--ease); }
.source-card[open] > summary::after { transform: rotate(90deg); }
.source-card__body { padding: 0 var(--pad-card) var(--pad-card); }
.source-card__body p { font-size: var(--text-sm); margin-bottom: var(--space-3); }

/* ─────────────────────────── FAQ ───────────────────────── */
.faq { display: flex; flex-direction: column; gap: var(--space-4); }
.faq__item { background: var(--bg); border-radius: var(--radius-md); box-shadow: var(--nm-raised); }
.faq__item > summary {
  list-style: none; cursor: pointer; padding: var(--space-5) var(--pad-card);
  font-family: var(--font-body); font-weight: 500; font-size: var(--text-md);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
}
.faq__item > summary::-webkit-details-marker { display: none; }
.faq__item > summary::after { content: "+"; color: var(--accent); font-size: 1.3em; flex-shrink: 0; }
.faq__item[open] > summary::after { content: "−"; }
.faq__answer { padding: 0 var(--pad-card) var(--space-5); }
.faq__answer p { font-size: var(--text-base); color: var(--ink-2); line-height: 1.6; }

/* ───────────────────────── Footer ──────────────────────── */
.site-footer { border-top: 1px solid var(--hairline); padding-block: var(--space-7); }
.site-footer__top { display: flex; flex-wrap: wrap; gap: var(--space-6); justify-content: space-between; }
.site-footer__brand { font-family: var(--font-body); font-weight: 600; font-size: var(--text-md); margin-bottom: var(--space-2); }
.site-footer__brand b { color: var(--accent); }
.site-footer__tagline { font-size: var(--text-sm); color: var(--ink-3); max-width: 28rem; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); }
.site-footer__links a { color: var(--ink-2); }
.site-footer__links a:hover { color: var(--accent); }
.site-footer__meta {
  margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--hairline);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3);
  font-size: var(--text-xs); color: var(--ink-3);
}

/* ──────────────── Reveal-on-scroll (JS-gated) ──────────── */
html.js .reveal:not(.is-in) { opacity: 0; transform: translateY(10px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1 !important; transform: none !important; } }

/* ─────────────────────── Responsive ────────────────────── */
@media (min-width: 768px) {
  .nav__toggle { display: none; }
  .nav__links, .nav[open] .nav__links {
    display: flex; flex-direction: row; align-items: center; gap: var(--space-5);
    position: static; min-width: 0; padding: 0; background: none; box-shadow: none;
  }
  .nav__links a { padding: 0; font-size: var(--text-sm); }
  .nav__links a:hover { box-shadow: none; }
}

@media (max-width: 1023px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .grid--3, .grid--4, .grid--2 { grid-template-columns: 1fr; }
  .flow { flex-direction: column; }
  .flow__arrow { transform: rotate(90deg); }
}
