/* Brand-book site shell. Structure + base typography live here; the sticky navigation,
 * focus states, responsive collapse, and embed chrome are filled in by U6. Authored as a
 * tracked source (not emitted only into site/) so the lint:css raw-hex guard covers it.
 * Token-only; no raw hex. */

html, body { margin: 0; background: var(--aq-bg); color: var(--aq-ink); }

body {
  font-family: var(--font-body), "Open Sans", system-ui, sans-serif;
  font-size: var(--text-md);
  line-height: var(--lh-base);
}

.book { max-width: 960px; margin: 0 auto; padding: 0 var(--s-6) var(--s-24); }

.book-cover {
  padding: var(--s-24) 0 var(--s-16);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--s-12);
}

.book-cover h1 {
  font-family: var(--font-display), "Lexend", system-ui, sans-serif;
  font-weight: var(--fw-medium);
  font-size: var(--text-5xl);
  line-height: var(--lh-5xl);
  letter-spacing: -0.02em;
  color: var(--aq-purple);
  margin: 0 0 var(--s-3);
}

.book-cover .lede { color: var(--aq-gray); font-size: var(--text-lg); margin: 0; }

/* Stitched specimen cards are authored at a fixed 700px width; let an oversized
 * section scroll within its own column on narrow screens rather than forcing the whole
 * page to scroll horizontally. */
.book-section { margin: 0 0 var(--s-16); overflow-x: auto; }

.book-section > h2 {
  font-family: var(--font-heading), "Lexend", system-ui, sans-serif;
  font-weight: var(--fw-bold);
  font-size: var(--text-2xl);
  letter-spacing: -0.01em;
  color: var(--aq-purple);
  margin: 0 0 var(--s-5);
  padding-top: var(--s-4);
}

.book-section--pending .pending-note {
  color: var(--aq-gray-mid);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: var(--text-sm);
}

/* ── Rendered markdown prose (U4) ─────────────────────────────────────── */
.md-content { color: var(--aq-ink); max-width: 720px; }

.md-content h3,
.md-content h4,
.md-content h5,
.md-content h6 {
  font-family: var(--font-heading), "Lexend", system-ui, sans-serif;
  font-weight: var(--fw-semi);
  color: var(--aq-purple-deep);
  line-height: var(--lh-2xl);
  margin: var(--s-8) 0 var(--s-2);
}

.md-content h3 { font-size: var(--text-xl); }
.md-content h4 { font-size: var(--text-lg); }
.md-content h5, .md-content h6 { font-size: var(--text-base); }

.md-content p { margin: 0 0 var(--s-4); }
.md-content a { color: var(--aq-blue-bright); }

.md-content ul, .md-content ol { margin: 0 0 var(--s-4); padding-left: var(--s-6); }
.md-content li { margin: var(--s-1) 0; }

.md-content code {
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.9em;
  color: var(--aq-purple-ink);
  background: var(--aq-violet-light);
  padding: 0.1em 0.35em;
  border-radius: var(--r-xs);
}

.md-content pre {
  background: var(--surface-code);
  color: var(--on-dark-1);
  padding: var(--s-5);
  border-radius: var(--r-lg);
  overflow-x: auto;
  font-size: var(--text-sm);
}
.md-content pre code { background: none; color: inherit; padding: 0; }

.md-content blockquote {
  margin: 0 0 var(--s-4);
  padding: var(--s-2) var(--s-5);
  border-left: 3px solid var(--aq-pink);
  color: var(--aq-gray);
}

.md-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 var(--s-5);
  font-size: var(--text-sm);
}
.md-content th, .md-content td {
  text-align: left;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.md-content th { color: var(--aq-purple); font-weight: var(--fw-semi); }

.md-sep { border: 0; border-top: 1px dashed var(--border-strong); margin: var(--s-10) 0; }

/* ── Layout, navigation, and chrome (U6) ─────────────────────────────── */
body.book-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr); /* minmax(0,…) prevents h-overflow */
  align-items: start;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--aq-purple);
  color: var(--on-dark-1);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm);
  z-index: 20;
}
.skip-link:focus { left: var(--s-4); top: var(--s-4); }

a:focus-visible,
button:focus-visible { outline: 3px solid var(--aq-blue); outline-offset: 2px; border-radius: var(--r-xs); }

.booknav {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: var(--s-8) var(--s-5);
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: var(--text-sm);
}
.booknav-title {
  font-family: var(--font-heading), "Lexend", system-ui, sans-serif;
  font-weight: var(--fw-bold);
  color: var(--aq-purple);
  margin: 0 0 var(--s-3);
}

.download-pdf {
  font-family: var(--font-heading), "Lexend", system-ui, sans-serif;
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  color: var(--on-dark-1);
  background: var(--aq-blue-bright);
  border: 0;
  border-radius: var(--r-pill);
  padding: var(--s-2) var(--s-4);
  margin: 0 0 var(--s-5);
  cursor: pointer;
}
.download-pdf:hover { background: var(--aq-purple); }

/* The print table of contents is print-only (shown by print.css). */
.print-toc { display: none; }
.booknav-group { margin: 0 0 var(--s-5); }
.booknav-group__label {
  font-family: var(--font-heading), "Lexend", system-ui, sans-serif;
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--aq-gray-mid);
  margin: 0 0 var(--s-2);
}
.booknav a {
  display: block;
  padding: var(--s-1) var(--s-2);
  color: var(--aq-gray);
  text-decoration: none;
  border-radius: var(--r-xs);
  border-left: 2px solid transparent;
}
.booknav a:hover { color: var(--aq-purple); }
.booknav a.is-active {
  color: var(--aq-purple);
  border-left-color: var(--aq-pink);
  background: var(--aq-violet-light);
}

/* ── Interactive specimen embeds (U5/U6) ─────────────────────────────── */
.embed {
  position: relative;
  margin: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}
.embed iframe {
  display: block;
  width: 100%;
  aspect-ratio: var(--embed-ar, 4 / 3);
  max-height: 78vh;
  border: 0;
  background: var(--bg-surface);
}
.embed::after { /* loading affordance until the health probe resolves */
  content: "Loading specimen…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--aq-gray-mid);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: var(--text-sm);
  pointer-events: none;
}
.embed.is-ready::after, .embed.is-degraded::after { content: none; }
.embed-fallback {
  display: none;
  padding: var(--s-8) var(--s-6);
  color: var(--aq-blue-bright);
  font-weight: var(--fw-semi);
}
.embed.is-degraded iframe { display: none; }
.embed.is-degraded .embed-fallback { display: block; }

/* ── Narrow viewports: nav collapses to a scrollable top strip ───────── */
@media (max-width: 880px) {
  body.book-layout { display: block; } /* nav + main stack as full-width blocks */
  .booknav {
    height: auto;
    max-height: 38vh;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
    z-index: 5;
  }
  .book { max-width: 100%; padding: 0 var(--s-4) var(--s-16); }
  .book-cover h1 { font-size: var(--text-4xl); line-height: var(--lh-4xl); }
}
