/* Long-form paper pages — deep dives, worked examples, glossaries */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222633;
  --text: #f0f2f8;
  --muted: #8b92a8;
  --accent: #6c8cff;
  --accent2: #56d4a0;
  --warn: #ffb347;
  --gap: #ff6b8a;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 1rem;
}

/* ── Top nav (links between deliverables) ── */
.pack-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--surface2);
  font-size: 0.85rem;
}

.pack-nav a {
  color: var(--muted);
  text-decoration: none;
}

.pack-nav a:hover,
.pack-nav a.active {
  color: var(--accent);
}

.pack-nav .brand {
  color: var(--text);
  font-weight: 600;
  margin-right: auto;
}

/* ── Page shell ── */
.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-hero {
  margin-bottom: 2.5rem;
}

.page-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.page-hero .subtitle {
  color: var(--muted);
  font-size: 1.05rem;
}

.page-hero .meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--accent);
}

/* ── Section blocks (deep dives) ── */
.section-block {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.75rem 2rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--accent);
}

.section-block h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.section-block .section-num {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.section-block .plain {
  margin: 1rem 0;
  font-size: 1.05rem;
}

.section-block .visual {
  background: var(--surface2);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0;
  text-align: center;
}

.section-block .from-paper {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--surface2);
  font-size: 0.9rem;
  color: var(--muted);
}

.section-block .from-paper strong {
  color: var(--warn);
  font-weight: 600;
}

/* ── Worked example steps ── */
.steps {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.step {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 1rem;
  align-items: start;
}

.step-num {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.step-body h3 {
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.step-body p {
  color: var(--muted);
  font-size: 0.95rem;
}

.step-body .highlight-box {
  background: var(--surface2);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-top: 0.75rem;
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  color: var(--accent2);
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.75rem 0;
}

.token {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: var(--surface2);
  font-size: 0.95rem;
}

.token.center {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.token.context {
  border: 2px solid var(--accent2);
  color: var(--accent2);
}

.token.predict {
  border: 2px dashed var(--warn);
  color: var(--warn);
}

/* ── TOC for deep dives ── */
.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.toc a {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.toc a:hover {
  background: var(--surface2);
  color: var(--accent);
}

/* ── Glossary flip cards ── */
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.glossary-card {
  perspective: 800px;
  height: 180px;
  cursor: pointer;
}

.glossary-card .card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}

.glossary-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-front {
  background: var(--surface);
  border: 2px solid var(--accent);
  align-items: center;
  text-align: center;
}

.card-front .term {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.card-front .hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.card-back {
  background: var(--surface2);
  border: 2px solid var(--accent2);
  transform: rotateY(180deg);
}

.card-back .def {
  font-size: 0.92rem;
  line-height: 1.45;
  margin-bottom: 0.6rem;
}

.card-back .analogy {
  font-size: 0.82rem;
  color: var(--warn);
  font-style: italic;
}

.card-back .where {
  margin-top: auto;
  font-size: 0.72rem;
  color: var(--muted);
}

.glossary-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

@media print {
  .glossary-card {
    height: auto;
    break-inside: avoid;
  }

  .glossary-card .card-inner {
    transform: none !important;
  }

  .card-front { display: none; }

  .card-back {
    position: static;
    transform: none;
    border-color: #ccc;
  }
}

/* ── Print ── */
@media print {
  body {
    background: white;
    color: #111;
    font-size: 9pt;
  }

  .pack-nav { display: none; }

  .page { max-width: 100%; padding: 0.5in; }
}
