/* HAP — shared design tokens (dark default + light toggle) */
:root {
  --bg: #0b0d12;
  --bg-elev: #12151c;
  --bg-elev2: #171b24;
  --line: #242a36;
  --line-soft: #1c2230;
  --text: #e6e8ee;
  --text-strong: #f6f7fb;
  --muted: #8b94a7;
  --dim: #555c6d;
  --accent: #7c5cff;       /* purple — primary CTA, structural */
  --accent-soft: rgba(124,92,255,0.12);
  --cyan: #22d3ee;          /* HAP wordmark, links, hero accent */
  --cyan-soft: rgba(34,211,238,0.10);
  --green: #4ade80;
  --yellow: #facc15;
  --red: #f87171;
  --pink: #f472b6;

  --selection: rgba(124,92,255,0.32);

  --radius: 8px;
  --radius-lg: 12px;

  --font-sans: "Inter", "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: "Newsreader", "Source Serif Pro", "Iowan Old Style", Georgia, serif;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fbfaf6;
  --bg-elev: #ffffff;
  --bg-elev2: #f3f1ea;
  --line: #e3dfd3;
  --line-soft: #ece9de;
  --text: #1c1f25;
  --text-strong: #0a0c10;
  --muted: #5a6271;
  --dim: #9ca3ad;
  --accent: #5b3ee0;
  --accent-soft: rgba(91,62,224,0.10);
  --cyan: #0891b2;
  --cyan-soft: rgba(8,145,178,0.10);
  --green: #16a34a;
  --yellow: #ca8a04;
  --red: #dc2626;
  --pink: #db2777;

  color-scheme: light;
}

* { box-sizing: border-box; }
::selection { background: var(--selection); }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
code, pre, kbd, samp { font-family: var(--font-mono); }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }

/* ---------- shared chrome ---------- */
.hap-wrap { max-width: 1180px; margin: 0 auto; padding: 0 32px; }
.hap-wrap--narrow { max-width: 920px; }
.hap-wrap--wide { max-width: 1280px; }

.hap-nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.hap-nav__inner {
  display: flex; align-items: center; gap: 28px;
  height: 56px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.hap-wordmark {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}
.hap-wordmark .hap-wordmark__h { color: var(--cyan); }
.hap-wordmark .hap-wordmark__v { color: var(--muted); font-weight: 400; }

.hap-nav__links { display: flex; gap: 20px; color: var(--muted); }
.hap-nav__links a { color: inherit; }
.hap-nav__links a:hover { color: var(--text-strong); text-decoration: none; }
.hap-nav__spacer { flex: 1; }
.hap-nav__meta { display: flex; gap: 12px; align-items: center; color: var(--muted); }

.hap-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-elev);
}
.hap-pill--cyan { color: var(--cyan); border-color: color-mix(in oklab, var(--cyan) 35%, var(--line)); background: var(--cyan-soft); }
.hap-pill--green { color: var(--green); border-color: color-mix(in oklab, var(--green) 35%, var(--line)); }
.hap-pill--yellow { color: var(--yellow); border-color: color-mix(in oklab, var(--yellow) 35%, var(--line)); }
.hap-pill--red { color: var(--red); border-color: color-mix(in oklab, var(--red) 35%, var(--line)); }
.hap-pill--dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.hap-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-strong);
  transition: background .12s, border-color .12s, transform .08s;
}
.hap-btn:hover { background: var(--bg-elev2); border-color: var(--dim); }
.hap-btn:active { transform: translateY(1px); }
.hap-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.hap-btn--primary:hover { background: color-mix(in oklab, var(--accent) 85%, white); }
.hap-btn--cyan {
  background: transparent;
  border-color: color-mix(in oklab, var(--cyan) 45%, var(--line));
  color: var(--cyan);
}
.hap-btn--cyan:hover { background: var(--cyan-soft); border-color: var(--cyan); }
.hap-btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.hap-btn--ghost:hover { color: var(--text-strong); background: var(--bg-elev); }

.hap-kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-mono); font-size: 11px;
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg-elev);
}

/* code blocks */
.hap-code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow: auto;
  position: relative;
}
.hap-code .c-key { color: var(--cyan); }
.hap-code .c-str { color: var(--green); }
.hap-code .c-num { color: var(--yellow); }
.hap-code .c-bool { color: var(--pink); }
.hap-code .c-null { color: var(--muted); }
.hap-code .c-com { color: var(--dim); font-style: italic; }
.hap-code .c-fn { color: var(--accent); }
.hap-code .c-kw { color: var(--pink); }
.hap-code .c-dim { color: var(--muted); }
.hap-code .c-prompt { color: var(--accent); user-select: none; }

.hap-section { padding: 96px 0; border-top: 1px solid var(--line); }
.hap-section--compact { padding: 64px 0; }

.hap-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.hap-eyebrow::before {
  content: ""; width: 24px; height: 1px; background: var(--dim);
}

.hap-h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  margin: 0 0 16px;
  max-width: 28ch;
  text-wrap: balance;
}
.hap-lead {
  color: var(--muted);
  font-size: 17px;
  max-width: 62ch;
  margin: 0 0 32px;
}

/* ---------- transcript engine styling ---------- */
.hap-tx {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.hap-tx__bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev2);
  font-size: 11.5px;
  color: var(--muted);
}
.hap-tx__bar-dots { display: flex; gap: 6px; }
.hap-tx__bar-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.hap-tx__bar-dot--g { background: color-mix(in oklab, var(--green) 60%, var(--line)); }
.hap-tx__bar-dot--y { background: color-mix(in oklab, var(--yellow) 60%, var(--line)); }
.hap-tx__bar-dot--r { background: color-mix(in oklab, var(--red) 60%, var(--line)); }
.hap-tx__bar-mid { flex: 1; text-align: center; color: var(--dim); }
.hap-tx__bar-id { color: var(--muted); }

.hap-tx__feed {
  padding: 18px 16px;
  display: flex; flex-direction: column;
  gap: 14px;
  flex: 1;
}

.hap-tx__row {
  display: flex; gap: 12px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .35s ease, transform .35s ease;
}
.hap-tx__row--in { opacity: 1; transform: translateY(0); }
.hap-tx__row--cand { flex-direction: row-reverse; }
.hap-tx__row--cand .hap-tx__card { background: var(--bg); }

.hap-tx__avatar {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 6px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  font-size: 10.5px; font-weight: 600;
  color: var(--text-strong);
  background: var(--bg);
}
.hap-tx__avatar--hr { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 50%, var(--line)); background: var(--accent-soft); }
.hap-tx__avatar--cand { color: var(--cyan); border-color: color-mix(in oklab, var(--cyan) 50%, var(--line)); background: var(--cyan-soft); }

.hap-tx__card {
  flex: 1 1 auto;
  max-width: 100%;
  min-width: 0;
  background: var(--bg-elev2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.hap-tx__head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--muted);
  background: color-mix(in oklab, var(--bg-elev) 60%, transparent);
}
.hap-tx__kind {
  color: var(--text-strong);
  font-weight: 500;
}
.hap-tx__kind .hap-tx__k-prefix { color: var(--dim); }
.hap-tx__head-spacer { flex: 1; }
.hap-tx__status {
  color: var(--green); font-size: 11px;
}
.hap-tx__status--decline { color: var(--yellow); }

.hap-tx__body {
  padding: 10px 12px 12px;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.55;
  display: flex; flex-direction: column;
  gap: 8px;
}
.hap-tx__field {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  font-size: 12px;
}
.hap-tx__field-k { color: var(--muted); }
.hap-tx__field-v { color: var(--text); word-break: break-word; }
.hap-tx__field-v .hap-tx__strong { color: var(--text-strong); }
.hap-tx__quote {
  border-left: 2px solid var(--line);
  padding: 1px 0 1px 10px;
  color: var(--text-strong);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
}

.hap-tx__ev {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 2px;
}
.hap-tx__ev-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-elev);
  font-size: 11.5px;
  color: var(--muted);
}
.hap-tx__ev-type {
  color: var(--cyan);
  font-weight: 500;
  flex-shrink: 0;
}
.hap-tx__ev-url {
  color: var(--text);
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11.5px;
}
.hap-tx__ev-verify {
  font-size: 10.5px;
  color: var(--green);
  display: inline-flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.hap-tx__ev-verify::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--green) 25%, transparent);
}

.hap-tx__caret {
  display: inline-block; width: 7px; height: 14px;
  background: var(--cyan);
  vertical-align: -2px;
  margin-left: 2px;
  animation: hap-caret 1.05s steps(2,end) infinite;
}
@keyframes hap-caret { 50% { opacity: 0; } }

.hap-tx__typing {
  display: inline-flex; gap: 3px; padding-left: 2px;
}
.hap-tx__typing span {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--muted);
  animation: hap-dot 1.1s infinite ease-in-out;
}
.hap-tx__typing span:nth-child(2) { animation-delay: 0.15s; }
.hap-tx__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes hap-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.hap-tx__foot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev2);
  font-size: 11.5px;
  color: var(--muted);
}
.hap-tx__foot-spacer { flex: 1; }
.hap-tx__replay {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.hap-tx__replay:hover { border-color: var(--cyan); color: var(--cyan); }
.hap-tx__pause {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
}
.hap-tx__pause:hover { color: var(--text-strong); }

/* footer */
.hap-footer { padding: 64px 0 56px; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; }
.hap-footer__row { display: flex; flex-wrap: wrap; gap: 24px; }
.hap-footer__col h4 { color: var(--text-strong); font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 500; margin: 0 0 10px; }
.hap-footer__col { display: flex; flex-direction: column; gap: 6px; min-width: 140px; }
.hap-footer__col a { color: var(--muted); }
.hap-footer__col a:hover { color: var(--text-strong); text-decoration: none; }
.hap-footer__bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--dim); }
