/*
 * ONBOARDING-TUTORIAL-ENDUSER-001 (2026-10-26 pivot):
 * Plain HTML/CSS long-form tutorial document.
 *
 * Replaces the earlier reveal.js slide-deck CSS. The old file had ~250 lines
 * of selectors against `.reveal`, `.scroll-page*`, `section.present` etc.;
 * none of that is relevant now — this page is a vanilla <main class="deck">
 * served as one continuous HTML document. Everything below is the real
 * document theme.
 */

/* ---------------------------------------------------------------- *
 * Design tokens
 * ---------------------------------------------------------------- */
:root {
  --bg: #0f1419;
  --bg-elevated: #181d24;
  --bg-code: #0a0d12;
  --fg: #e6e9ef;
  --fg-muted: #94a3b8;
  --fg-subtle: #64748b;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --rule: #1f2937;
  --rule-soft: #2a3340;
  --warn: #f59e0b;
  --slide-break: #1f2937;

  --font-sans: -apple-system, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Monaco", "Cascadia Code", monospace;

  --page-max: 1400px;
  --page-pad: 24px;
  --toc-width: 260px;

  --radius: 8px;
  --radius-small: 4px;
}

/* ---------------------------------------------------------------- *
 * Reset + base
 * ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color-scheme: dark;
  scroll-behavior: smooth;
}

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

/* Breathing room above anchor targets so headings never land flush against
 * browser chrome when a TOC link jumps to them.
 */
:target,
[id] {
  scroll-margin-top: 32px;
}

/* ---------------------------------------------------------------- *
 * Page layout
 * ---------------------------------------------------------------- */
.deck {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 48px var(--page-pad) 96px;
}

/* ---------------------------------------------------------------- *
 * Persistent TOC sidebar (body.has-toc)
 * ---------------------------------------------------------------- */
body.has-toc {
  display: grid;
  grid-template-columns: var(--toc-width) minmax(0, 1fr);
  min-height: 100vh;
}

.deck-toc {
  grid-column: 1;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-right: 1px solid var(--rule);
  padding: 24px 18px 24px 22px;
  font-size: 0.88em;
  line-height: 1.4;
}
.deck-toc .deck-toc-head {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--fg-subtle);
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.deck-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.deck-toc li { margin: 0; }
.deck-toc a {
  display: block;
  color: var(--fg-muted);
  text-decoration: none;
  border: 0;
  padding: 5px 10px 5px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
  transition: color 0.1s, background-color 0.1s, border-color 0.1s;
  word-break: break-word;
}
.deck-toc a:hover,
.deck-toc a:focus-visible {
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left-color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.deck-toc a.deck-toc-active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.deck-toc .deck-toc-subhead {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--fg-subtle);
  padding: 18px 10px 8px 12px;
  margin-top: 10px;
  border-top: 1px solid var(--rule);
}
.deck-toc .deck-toc-graph > a {
  padding-left: 12px;
  font-size: 0.9em;
}
.deck-toc .deck-toc-l1 > a {
  font-weight: 600;
  color: var(--fg);
  padding-top: 10px;
}
.deck-toc .deck-toc-l2 > a { padding-left: 20px; }
.deck-toc .deck-toc-l3 > a { padding-left: 30px; font-size: 0.95em; }
.deck-toc .deck-toc-l4 > a { padding-left: 40px; font-size: 0.92em; color: var(--fg-subtle); }
.deck-toc .deck-toc-l5 > a,
.deck-toc .deck-toc-l6 > a { padding-left: 50px; font-size: 0.9em; color: var(--fg-subtle); }

body.has-toc .deck { grid-column: 2; }

@media (max-width: 980px) {
  body.has-toc { display: block; }
  .deck-toc { display: none; }
}

@media (max-width: 880px) {
  body { font-size: 16px; }
  .deck { padding: 24px 16px 64px; }
}

/* ---------------------------------------------------------------- *
 * Typography
 * ---------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin: 1.6em 0 0.5em;
  color: var(--fg);
  letter-spacing: -0.01em;
}
h1:first-child, h2:first-child, h3:first-child { margin-top: 0; }

h1 { font-size: 2.4em; margin-top: 0.6em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.35em; }
h4 { font-size: 1.1em; color: var(--fg-muted); }
h5, h6 { font-size: 1em; color: var(--fg-muted); font-weight: 600; }

p { margin: 0 0 1em; }

strong, b { color: var(--fg); font-weight: 700; }
em, i { font-style: italic; color: var(--fg); }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.1s ease, color 0.1s ease;
}
a:hover,
a:focus-visible {
  color: var(--accent-strong);
  border-bottom-color: var(--accent-strong);
}

/* ---------------------------------------------------------------- *
 * Lists
 * ---------------------------------------------------------------- */
ul, ol {
  margin: 0 0 1em;
  padding-left: 1.8em;
}
li { margin: 0.2em 0; }
li > ul, li > ol { margin: 0.3em 0 0.4em; }

/* ---------------------------------------------------------------- *
 * Blockquote
 * ---------------------------------------------------------------- */
blockquote {
  margin: 1em 0;
  padding: 0.5em 1.2em;
  border-left: 3px solid var(--accent);
  background: var(--bg-elevated);
  color: var(--fg-muted);
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
}
blockquote p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- *
 * Code
 * ---------------------------------------------------------------- */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-code);
  color: var(--fg);
  padding: 0.12em 0.4em;
  border-radius: var(--radius-small);
  border: 1px solid var(--rule);
}

pre {
  margin: 1em 0;
  padding: 0;
  background: transparent;
  border: 0;
}
pre > code {
  display: block;
  padding: 1em 1.2em;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--bg-code);
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.5;
  white-space: pre;
}

/* ---------------------------------------------------------------- *
 * Tables
 * ---------------------------------------------------------------- */
table {
  width: 100%;
  margin: 1em 0;
  border-collapse: collapse;
  font-size: 0.95em;
}
th, td {
  padding: 0.5em 0.85em;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  color: var(--fg);
  font-weight: 700;
  border-bottom: 2px solid var(--rule-soft);
  background: var(--bg-elevated);
}
tbody tr:hover { background: color-mix(in srgb, var(--bg-elevated) 60%, transparent); }

/* ---------------------------------------------------------------- *
 * Horizontal rules
 * ---------------------------------------------------------------- */
hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.4em 0;
}

/* Slide-break separator between source slides — subtle, non-distracting. */
hr.slide-break {
  border-top: 1px dashed var(--slide-break);
  margin: 3em 0;
  opacity: 0.6;
}

/* ---------------------------------------------------------------- *
 * Speaker notes (collapsible)
 * ---------------------------------------------------------------- */
details.speaker-notes {
  margin: 1em 0;
  padding: 0.4em 0.9em;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 0.95em;
  color: var(--fg-muted);
}
details.speaker-notes > summary {
  cursor: pointer;
  color: var(--fg-subtle);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  user-select: none;
  padding: 0.3em 0;
  list-style: none;
}
details.speaker-notes > summary::marker { display: none; }
details.speaker-notes > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
  margin-right: 0.3em;
}
details.speaker-notes[open] > summary::before { transform: rotate(90deg); }
details.speaker-notes > summary:hover { color: var(--fg); }
details.speaker-notes > *:not(summary) { margin-top: 0.5em; }
details.speaker-notes ul { padding-left: 1.4em; }

/* ---------------------------------------------------------------- *
 * Mermaid diagrams
 * ---------------------------------------------------------------- */
.mermaid {
  margin: 1em 0;
  text-align: center;
  background: #ffffff;
  border-radius: var(--radius);
  padding: 1em;
  overflow-x: auto;
}
.mermaid svg { max-width: 100%; height: auto; }

/* ---------------------------------------------------------------- *
 * Interactive SVG viewer (upgraded at runtime by assets/js/svg-viewer.js)
 *
 * Each <figure class="svg-figure"> becomes a bounded, zoom/pan-able frame.
 * svg-viewer.js attaches toolbar + wheel/drag handlers; CSS owns baseline
 * layout + styling.
 * ---------------------------------------------------------------- */
.svg-figure,
figure.svg-figure {
  display: block;
  position: relative;
  width: 100%;
  max-width: 100%;
  height: min(70vh, 820px);
  margin: 1.2em auto;
  padding: 0;
  overflow: hidden;
  background: #ffffff;
  border-radius: var(--radius);
  user-select: none;
  touch-action: none;
  cursor: grab;
}
.svg-figure.svg-viewer-grabbing { cursor: grabbing; }

.svg-figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  transform-origin: 50% 50%;
  will-change: transform;
  pointer-events: none;
}
.svg-figure figcaption {
  font-size: 0.85em;
  color: var(--fg-muted);
  text-align: center;
  margin-top: 0.4em;
  font-style: italic;
}

.svg-figure .svg-viewer-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.8);
  padding: 4px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 5;
  pointer-events: none;
}
.svg-figure:hover .svg-viewer-toolbar,
.svg-figure:focus-within .svg-viewer-toolbar,
.svg-figure.svg-viewer-grabbing .svg-viewer-toolbar {
  opacity: 1;
  pointer-events: auto;
}
.svg-figure .svg-viewer-toolbar button {
  width: 32px;
  height: 32px;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-small);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.svg-figure .svg-viewer-toolbar button:hover { background: rgba(255, 255, 255, 0.28); }
.svg-figure .svg-viewer-toolbar button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.svg-figure .svg-viewer-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.75);
  color: #e2e8f0;
  font-size: 11px;
  font-family: var(--font-sans);
  padding: 4px 10px;
  border-radius: var(--radius-small);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}
.svg-figure:hover .svg-viewer-hint { opacity: 0.9; }
.svg-figure:fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  margin: 0;
  background: #ffffff;
}

/* Fallback for standalone SVG <img> that didn't get wrapped in .svg-figure. */
.deck p > img[src$=".svg"] {
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  display: block;
  margin: 1em auto;
  border-radius: var(--radius);
  background: #ffffff;
  padding: 0.5em;
}

/* ---------------------------------------------------------------- *
 * Acronym links + glossary + return-to-previous button
 * ---------------------------------------------------------------- */
/* Subtle styling for inline acronym links: dotted underline so a reader
 * sees they are clickable without visual clutter around every acronym.
 */
.acronym-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--fg-subtle);
  padding-bottom: 1px;
  cursor: help;
  transition: border-color 0.1s, color 0.1s;
}
.acronym-link:hover,
.acronym-link:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}

/* Glossary section at the bottom of the deck. */
.glossary {
  margin-top: 3em;
  padding-top: 2em;
  border-top: 1px solid var(--rule);
}
.glossary .glossary-intro {
  color: var(--fg-muted);
  font-size: 0.95em;
  max-width: 820px;
}
.glossary-list {
  display: grid;
  grid-template-columns: minmax(80px, 160px) 1fr;
  gap: 10px 20px;
  margin: 2em 0 0;
  padding: 0;
}
.glossary-entry {
  display: contents;
}
.glossary-list dt {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  background: var(--bg-elevated);
  padding: 10px 12px;
  border-radius: var(--radius-small);
  border-left: 3px solid var(--accent);
  scroll-margin-top: 32px;
  align-self: start;
}
.glossary-list dt:target {
  background: color-mix(in srgb, var(--accent) 20%, var(--bg-elevated));
  box-shadow: 0 0 0 2px var(--accent);
}
.glossary-list dd {
  margin: 0;
  padding: 10px 0;
  align-self: center;
  color: var(--fg);
}

/* Floating "Return to Previous" button. Fixed top-right, high contrast
 * so a reader scanning the glossary notices it immediately. Hidden by
 * default via [hidden]; the inline script unhides when the current hash
 * points at a glossary entry.
 */
.glossary-back-btn {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 50;
  background: var(--accent);
  color: #0b1220;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95em;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  letter-spacing: 0.01em;
  animation: glossary-back-pulse 0.6s ease-out 1;
}
.glossary-back-btn:hover {
  background: var(--accent-strong);
  color: #fff;
}
.glossary-back-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
@keyframes glossary-back-pulse {
  0% { transform: scale(0.85); opacity: 0.4; }
  60% { transform: scale(1.07); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------- *
 * Keyboard focus
 * ---------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-small);
}
