/* ==========================================================
   LOOPFORGE — A Field Guide to AI Loop Engineering
   Identity: the conductor's stage. Violet-black ground,
   purple for the players (agents), gold for the podium
   (human direction). Demo consoles are warm paper — sheet
   music under stage light. Dark by design: house lights down.
========================================================== */

/* ----------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, svg, video { display: block; max-width: 100%; }
input, button, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.12; text-wrap: balance; overflow-wrap: break-word; }
p { overflow-wrap: break-word; }
ul { padding: 0; }

/* ----------------------------- Tokens */
:root {
  /* Stage */
  --bg: #14101c;
  --surface: #1c1726;
  --surface-2: #241d31;
  --surface-3: #2d2440;
  --line: #332b47;
  --line-strong: #453a61;

  /* Ink */
  --ink: #efeaf7;
  --muted: #a89bc0;
  --faint: #6f6488;

  /* The players */
  --violet: #9b8cf5;
  --violet-deep: #6a58d8;
  /* The podium */
  --gold: #d9a94e;
  --gold-bright: #edc272;
  --gold-ink: #14101c;

  /* Paper (demo consoles — the score) */
  --paper: #f2ecdd;
  --paper-2: #e9e1cd;
  --paper-line: #d8cdb2;
  --paper-ink: #241d31;
  --paper-muted: #6d6353;

  /* Semantic */
  --ok: #7fc98f;
  --warn: #e0b34c;
  --bad: #e0808f;
  --info: #7fb3e0;

  /* Type */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --text-sm: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.15rem, 1.05rem + 0.5vw, 1.45rem);
  --text-xl: clamp(1.6rem, 1.3rem + 1.4vw, 2.4rem);
  --text-2xl: clamp(2.1rem, 1.5rem + 2.8vw, 3.4rem);
  --text-hero: clamp(2.6rem, 1.6rem + 5vw, 5.2rem);

  --radius: 10px;
  --radius-lg: 16px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

::selection { background: var(--violet-deep); color: var(--ink); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
}

a { color: var(--violet); text-decoration: none; }
a:hover { color: var(--gold-bright); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}
.container-narrow { max-width: 900px; }

/* ----------------------------- Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 0.85rem;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  color: var(--ink);
}
.brand svg { align-self: center; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}
.brand-tag {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.nav-links {
  display: flex;
  gap: 0.1rem;
  list-style: none;
}
.nav-links a {
  display: block;
  white-space: nowrap;
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  border-radius: 999px;
  transition: color 150ms var(--ease), background 150ms var(--ease);
}
.nav-links a:hover { color: var(--ink); background: var(--surface-2); }
.nav-links a.is-current { color: var(--gold-bright); }

@media (max-width: 980px) {
  .brand-tag { display: none; }
  .nav-links { display: none; }
}

/* ----------------------------- Sections */
section { padding-block: clamp(4rem, 9vw, 7rem); }
section[id] { scroll-margin-top: 76px; }
.section-alt { background: var(--surface); }

.section-head { max-width: 640px; margin-bottom: clamp(2.5rem, 5vw, 4rem); }
.section-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.section-topline .section-eyebrow { margin-bottom: 0; }
.to-top {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.to-top:hover { color: var(--gold-bright); border-color: var(--gold); }
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
}
.section-eyebrow::before {
  content: attr(data-num);
  display: inline-grid;
  place-items: center;
  padding: 0.15rem 0.5rem;
  background: var(--gold);
  color: var(--gold-ink);
  border-radius: 6px;
  letter-spacing: 0.05em;
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-2xl);
  letter-spacing: -0.015em;
  margin-bottom: 1rem;
}
.section-head p { color: var(--muted); font-size: var(--text-lg); line-height: 1.55; }

/* ----------------------------- Reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 600ms var(--ease), transform 600ms var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }

/* ----------------------------- Hero */
.hero { padding-block: clamp(4rem, 9vw, 7.5rem) clamp(3rem, 6vw, 5rem); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { max-width: 420px; margin-inline: auto; width: 100%; }
}
.hero-visual svg { width: 100%; height: auto; aspect-ratio: 1 / 1; }
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1.4rem;
}
.hero-eyebrow::before { content: ''; width: 2.2rem; height: 1px; background: var(--gold); }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-hero);
  letter-spacing: -0.02em;
  margin-bottom: 1.4rem;
}
.hero h1 .accent {
  color: var(--gold-bright);
  font-style: italic;
}
.hero-lede {
  max-width: 34rem;
  color: var(--muted);
  font-size: var(--text-lg);
  line-height: 1.6;
  margin-bottom: 2.2rem;
}
.hero-lede em { color: var(--ink); font-style: italic; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.9rem; }

/* ----------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 150ms var(--ease), background 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--gold); color: var(--gold-ink); }
.btn-primary:hover { background: var(--gold-bright); color: var(--gold-ink); }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--violet); color: var(--ink); background: var(--surface-2); }
.btn-warn { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-warn:hover { background: color-mix(in oklab, var(--bad) 14%, transparent); color: var(--bad); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ----------------------------- Marquee */
.marquee {
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: var(--surface);
  padding-block: 0.8rem;
}
.marquee-track {
  display: flex;
  gap: 2.75rem;
  width: max-content;
  animation: marquee 36s linear infinite;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}
.marquee-track span::after { content: '·'; margin-left: 2.75rem; color: var(--gold); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ----------------------------- Anatomy */
.anatomy { overflow-x: auto; }
.anatomy-diagram { min-width: 640px; width: 100%; height: auto; }

/* ----------------------------- Pattern cards */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
}
.pattern-card {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.4rem 1.2rem;
  transition: transform 200ms var(--ease), border-color 200ms var(--ease);
}
.pattern-card:hover { transform: translateY(-4px); border-color: var(--line-strong); }
.pattern-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}
.pattern-card__num { font-family: var(--font-mono); font-size: 0.8rem; color: var(--faint); letter-spacing: 0.1em; }
.pattern-card__tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  border: 1px solid;
}
.pattern-card__tag[data-cat="foundation"] { color: var(--gold-bright); border-color: color-mix(in oklab, var(--gold) 55%, transparent); }
.pattern-card__tag[data-cat="pattern"]    { color: var(--violet);      border-color: color-mix(in oklab, var(--violet) 55%, transparent); }
.pattern-card__tag[data-cat="advanced"]   { color: var(--info);        border-color: color-mix(in oklab, var(--info) 55%, transparent); }
.pattern-card__tag[data-cat="production"] { color: var(--ok);          border-color: color-mix(in oklab, var(--ok) 55%, transparent); }
.pattern-card__fig {
  width: 100%;
  height: 76px;
  margin-bottom: 1rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
}
.pattern-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}
.pattern-card p { color: var(--muted); font-size: var(--text-sm); line-height: 1.55; flex-grow: 1; }
.pattern-card__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.pattern-card__meta span:first-child { color: var(--faint); }
.pattern-card__meta span:last-child { color: var(--gold-bright); text-align: right; }

/* ----------------------------- Timescale rings */
.rings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
@media (max-width: 860px) {
  .rings-layout { grid-template-columns: 1fr; }
  .rings-diagram { max-width: 420px; margin-inline: auto; }
}
.ring { transition: opacity 200ms var(--ease), stroke-width 200ms var(--ease); }
.ring.lit { opacity: 1 !important; stroke-width: 5; }
.rings-legend { display: flex; flex-direction: column; gap: 1rem; }
.rings-legend__item {
  padding: 1rem 1.2rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: default;
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
}
.rings-legend__item:hover, .rings-legend__item.lit {
  border-color: var(--line-strong);
  background: var(--surface-3);
}
.rings-legend__row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.rings-legend__row strong { font-weight: 600; }
.rings-legend__time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.rings-legend__item p { color: var(--muted); font-size: var(--text-sm); line-height: 1.5; }
.rings-legend__item p em { color: var(--gold-bright); font-style: italic; }
.dot { width: 9px; height: 9px; border-radius: 50%; align-self: center; flex-shrink: 0; }
.dot--gold { background: var(--gold); }
.dot--violet { background: var(--violet); }
.rings-note { font-size: var(--text-sm); color: var(--muted); padding-inline: 0.2rem; }
.rings-note .gold { color: var(--gold-bright); font-weight: 600; }
.rings-note .violet { color: var(--violet); font-weight: 600; }

/* ----------------------------- Use cases */
.usecase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
}
.usecase {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 200ms var(--ease), border-color 200ms var(--ease);
}
.usecase:hover { transform: translateY(-4px); border-color: var(--line-strong); }
.usecase__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--gold-bright);
  margin-bottom: 1rem;
}
.usecase__icon svg { width: 22px; height: 22px; }
.usecase h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; margin-bottom: 0.5rem; }
.usecase p { color: var(--muted); font-size: var(--text-sm); line-height: 1.55; flex-grow: 1; }
.usecase__stack {
  margin-top: 1.1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--violet);
}

/* ----------------------------- Trade-offs */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 780px) { .split { grid-template-columns: 1fr; } }
.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 1.6rem;
}
.panel h3 { margin-bottom: 1.2rem; }
.panel .glyph {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
}
.panel--pro .glyph { background: color-mix(in oklab, var(--ok) 16%, transparent); color: var(--ok); }
.panel--con .glyph { background: color-mix(in oklab, var(--bad) 16%, transparent); color: var(--bad); }
.panel ul { list-style: none; display: flex; flex-direction: column; gap: 1.1rem; }
.panel li { display: flex; flex-direction: column; gap: 0.2rem; padding-left: 1rem; border-left: 2px solid; }
.panel--pro li { border-color: color-mix(in oklab, var(--ok) 55%, transparent); }
.panel--con li { border-color: color-mix(in oklab, var(--bad) 55%, transparent); }
.panel li strong { font-weight: 600; }
.panel li span { color: var(--muted); font-size: var(--text-sm); line-height: 1.5; }

.mitigation {
  margin-top: 1.25rem;
  padding: 1.3rem 1.5rem;
  border: 1px solid color-mix(in oklab, var(--gold) 45%, transparent);
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--gold) 7%, var(--bg));
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.mitigation strong { color: var(--gold-bright); font-weight: 600; }

/* ----------------------------- Failure table */
.failure-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
}
.failure-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.failure-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line-strong);
}
.failure-table td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--muted);
  line-height: 1.5;
}
.failure-table tbody tr:last-child td { border-bottom: none; }
.failure-table tbody tr:hover td { background: var(--surface); }
.failure-table td:first-child { color: var(--ink); font-weight: 600; }
.sev {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.sev--high { background: color-mix(in oklab, var(--bad) 18%, transparent); color: var(--bad); }
.sev--med  { background: color-mix(in oklab, var(--warn) 18%, transparent); color: var(--warn); }
.sev--low  { background: color-mix(in oklab, var(--info) 18%, transparent); color: var(--info); }

/* ----------------------------- Demos */
.demo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.demo-tab {
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 150ms var(--ease);
}
.demo-tab:hover { color: var(--ink); border-color: var(--violet); }
.demo-tab.is-active { background: var(--violet); border-color: var(--violet); color: var(--gold-ink); }
.demo-tab--warn.is-active { background: var(--bad); border-color: var(--bad); }

.demo-panel { display: none; }
.demo-panel.is-active {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 860px) { .demo-panel.is-active { grid-template-columns: 1fr; } }

.demo-controls {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.demo-controls h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; margin-bottom: 0.6rem; }
.demo-controls > p { color: var(--muted); font-size: var(--text-sm); line-height: 1.55; margin-bottom: 1.3rem; }
.demo-field { margin-bottom: 1rem; }
.demo-field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.4rem;
}
.demo-field select, .demo-field input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 0.92rem;
}
.demo-field select:focus, .demo-field input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.demo-controls .btn { margin-top: 0.4rem; }

/* The score: warm paper console on the dark stage */
.demo-output {
  background: var(--paper);
  border-radius: var(--radius-lg);
  border: 1px solid var(--paper-line);
  overflow: hidden;
}
.demo-output__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--paper-line);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--paper-muted);
  font-variant-numeric: tabular-nums;
}
.demo-output__header span:first-child { display: inline-flex; align-items: center; gap: 0.5rem; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--paper-line);
  flex-shrink: 0;
}
.demo-output.is-running .status-dot { background: var(--gold); animation: pulse 1s ease-in-out infinite; }
.demo-output.is-done .status-dot { background: var(--ok); }
@keyframes pulse { 50% { opacity: 0.35; } }

.demo-output__log {
  height: 420px;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.log-entry {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 0.9rem;
  background: var(--paper-2);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  animation: entry-in 300ms var(--ease);
}
@keyframes entry-in { from { opacity: 0; transform: translateY(6px); } }
.log-entry__step {
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--paper-muted);
  padding-top: 0.15rem;
}
.log-entry__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-muted);
  margin-bottom: 0.15rem;
}
.log-entry__content { color: var(--paper-ink); }
.log-entry__content .mono { font-weight: 500; }
.log-entry--goal { border-left: 3px solid var(--violet-deep); }
.log-entry--goal .log-entry__label { color: var(--violet-deep); }
.log-entry--tool .log-entry__label { color: #2a7d74; }
.log-entry--verify { border-left: 3px solid var(--gold); }
.log-entry--verify .log-entry__label { color: #9c7020; }
.log-entry--critique .log-entry__label { color: #a04b58; }
.log-entry--stop { border-left: 3px solid var(--gold); background: #efe5c8; }
.log-entry--stop .log-entry__label { color: #9c7020; }
.log-entry--warn { border-left: 3px solid var(--bad); background: #f0dcd6; }
.log-entry--warn .log-entry__label { color: #a04b58; }
.log-entry--slop .log-entry__content { color: #8a7d68; font-style: italic; }

/* ----------------------------- Practice path */
.path-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
/* Tablet: two columns, with the final rehearsal as a full-width coda */
@media (min-width: 560px) {
  .path-grid { grid-template-columns: repeat(2, 1fr); }
  .path-step:last-child { grid-column: 1 / -1; }
}
/* Desktop: all five rehearsals in one row */
@media (min-width: 920px) {
  .path-grid { grid-template-columns: repeat(5, 1fr); }
  .path-step:last-child { grid-column: auto; }
}
.path-step {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.3rem;
  position: relative;
}
.path-step__num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: 0.8rem;
}
.path-step__num::before { content: 'REHEARSAL '; color: var(--faint); }
.path-step h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; margin-bottom: 0.5rem; }
.path-step p { color: var(--muted); font-size: var(--text-sm); line-height: 1.5; }

/* ----------------------------- Code block */
.code-block {
  background: #0e0b15;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink);
}
.code-block .cm { color: var(--faint); font-style: italic; }
.code-block .kw { color: var(--violet); }
.code-block .fn { color: var(--gold-bright); }
.code-block .str { color: var(--ok); }

/* ----------------------------- Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-block: 3.5rem 2.5rem;
}
.site-footer .container {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 2.5rem;
}
@media (max-width: 780px) { .site-footer .container { grid-template-columns: 1fr; } }
.footer-brand { font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; }
.footer-tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0.4rem 0 1rem;
}
.footer-note { max-width: 44ch; color: var(--faint); font-size: var(--text-sm); line-height: 1.6; margin-bottom: 0.8rem; }
.footer-note--gold { color: var(--muted); }
.footer-note--gold em { color: var(--gold-bright); }
.site-footer h4 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.9rem;
}
.site-footer a { display: block; color: var(--muted); font-size: var(--text-sm); padding-block: 0.25rem; }
.site-footer a:hover { color: var(--gold-bright); }
.fine {
  grid-column: 1 / -1;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ----------------------------- Home: chapter grid (the program) */
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
}
.toc-card {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  color: var(--ink);
  transition: transform 200ms var(--ease), border-color 200ms var(--ease);
}
.toc-card:hover { transform: translateY(-4px); border-color: var(--gold); color: var(--ink); }
.toc-card__num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: 0.8rem;
}
.toc-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin-bottom: 0.45rem;
}
.toc-card p { color: var(--muted); font-size: var(--text-sm); line-height: 1.55; flex-grow: 1; }
.toc-card__go {
  margin-top: 1.1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  transition: color 150ms var(--ease);
}
.toc-card:hover .toc-card__go { color: var(--gold-bright); }

/* ----------------------------- Chapter pager (prev / next) */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: clamp(3rem, 6vw, 5rem);
}
.pager__link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.pager__link:hover { color: var(--gold-bright); border-color: var(--gold); }

/* ----------------------------- Pattern detail view */
.pattern-card { cursor: pointer; }
.pattern-card:hover { border-color: var(--gold); }

.pdetail {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  overflow-y: auto;
  display: none;
}
.pdetail.is-open { display: block; }
body.detail-open { overflow: hidden; }
.pdetail-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem clamp(1.25rem, 4vw, 2.5rem);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.pdetail-bar .to-top { background: none; cursor: pointer; }
.pdetail-idx {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.pdetail-inner {
  max-width: 760px;
  margin-inline: auto;
  padding: clamp(2.5rem, 6vw, 4rem) clamp(1.25rem, 4vw, 2.5rem) 4rem;
}
.pdetail-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.9rem;
}
.pdetail-inner h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 1.6rem + 2.5vw, 3.4rem);
  letter-spacing: -0.015em;
  margin-bottom: 1rem;
}
.pdetail-deck { color: var(--muted); font-size: var(--text-lg); line-height: 1.55; }
.pdetail-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 2.2rem 0 0.9rem;
}
.pdetail-shape {
  list-style: none;
  counter-reset: beat;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.pdetail-shape li {
  counter-increment: beat;
  display: flex;
  gap: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
}
.pdetail-shape li::before {
  content: counter(beat, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  padding-top: 0.2rem;
  flex-shrink: 0;
}
.pdetail-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.pdetail-list li {
  padding-left: 1rem;
  border-left: 2px solid color-mix(in oklab, var(--violet) 55%, transparent);
  color: var(--muted);
  line-height: 1.55;
}
.pdetail-list--watch li { border-left-color: color-mix(in oklab, var(--bad) 55%, transparent); }
.pdetail-pairs { color: var(--muted); line-height: 1.6; }
.fieldnote {
  margin-top: 2.4rem;
  padding: 1.3rem 1.5rem;
  border: 1px solid color-mix(in oklab, var(--gold) 45%, transparent);
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--gold) 7%, var(--bg));
}
.fn-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-bright);
  margin-bottom: 0.5rem;
}
.fieldnote p { color: var(--ink); font-style: italic; line-height: 1.6; }
.pdetail-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}

/* ----------------------------- Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .marquee-track { animation: none; }
  .hero-arc animateTransform { display: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .log-entry { animation: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
