/* ==========================================================================
   Phantom — the guide panel
   ==========================================================================

   A follow-along guide docked on the RIGHT, not a modal. The brief was a panel
   you can read while you use the app, so two rules follow:

   1. Docked, not overlaid. On a wide screen the page shrinks to make room and
      stays fully usable — no scrim, no focus trap. A guide that dims the thing
      it is explaining makes you close it before you can do what it says.
   2. Persistent across navigation. It lives beside #root, not inside it, so a
      route change re-renders the page and leaves the guide exactly where you
      were reading.

   Below 960px there is no room to dock, so it becomes an overlay sheet — the
   one place a scrim is justified, because the page underneath is covered.
   ========================================================================== */

:root {
  --guide-w: clamp(340px, 30vw, 420px);
}

/* ── Docking ─────────────────────────────────────────────────────────── */

@media (min-width: 960px) {
  html.guide-open #root {
    margin-right: var(--guide-w);
    transition: margin-right var(--dur-slow) var(--ease-out);
  }
  html.guide-open #toasts {
    right: calc(var(--guide-w) + var(--sp-5));
  }
}

/* ── The panel ───────────────────────────────────────────────────────── */

.guide {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 40;
  width: var(--guide-w);
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  box-shadow:
    -1px 0 0 var(--line),
    -24px 0 48px -32px rgb(20 23 26 / 0.18);
  transform: translateX(100%);
  visibility: hidden;
  transition:
    transform var(--dur-slow) var(--ease-out),
    visibility 0s linear var(--dur-slow);
}
html.guide-open .guide {
  transform: none;
  visibility: visible;
  transition: transform var(--dur-slow) var(--ease-out), visibility 0s;
}

@media (max-width: 959px) {
  .guide { width: min(100vw, 440px); }
  .guide-scrim {
    position: fixed; inset: 0; z-index: 39;
    background: rgb(14 16 18 / 0.32);
    opacity: 0; pointer-events: none;
    transition: opacity var(--dur-base) var(--ease);
  }
  html.guide-open .guide-scrim { opacity: 1; pointer-events: auto; }
}
@media (min-width: 960px) {
  .guide-scrim { display: none; }
}

.guide__head {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--topbar-h);
  padding: 0 var(--sp-3) 0 var(--sp-5);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.guide__brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--t-md);
  letter-spacing: -0.015em;
}
.guide__brand svg { color: var(--accent); }

/* "This page" — the section that matches where you are right now. Offered,
   never forced: jumping the reader's place every time they click a tab would
   make the guide impossible to follow. */
.guide__context {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-3) var(--sp-4) 0;
  padding: 9px 10px 9px 14px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-line);
  font-size: var(--t-xs);
  color: var(--text-2);
}
.guide__context strong { color: var(--text-1); font-weight: 600; }

.guide__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-5) var(--sp-5) var(--sp-8);
}

.guide__foot {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.guide__progress {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: var(--t-2xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.guide__bar {
  width: 100%; max-width: 120px; height: 4px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}
.guide__bar > i {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--dur-slow) var(--ease-out);
}

/* ── Contents ────────────────────────────────────────────────────────── */

.guide-toc__intro { margin-bottom: var(--sp-5); }
.guide-toc__group { margin-bottom: var(--sp-5); }
.guide-toc__group > .label { display: block; margin-bottom: var(--sp-2); }
.guide-toc__item {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
}
.guide-toc__item:hover { background: var(--surface-2); }
.guide-toc__item[aria-current="true"] { background: var(--accent-soft); }
.guide-toc__num {
  display: grid; place-items: center;
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: var(--r-full);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  font-size: var(--t-2xs); font-weight: 650;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.guide-toc__item.is-read .guide-toc__num {
  background: var(--accent);
  box-shadow: none;
  color: var(--accent-ink);
}
.guide-toc__title { font-size: var(--t-sm); font-weight: 600; color: var(--text-1); }
.guide-toc__sub { font-size: var(--t-xs); color: var(--text-3); line-height: 1.45; margin-top: 1px; }

/* ── A section ───────────────────────────────────────────────────────── */

.guide-sec__eyebrow { display: block; margin-bottom: 6px; color: var(--accent); }
.guide-sec__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--t-xl);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
}
.guide-sec__lead {
  font-size: var(--t-sm);
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: var(--sp-5);
}

.guide__figure {
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4) var(--sp-3);
  border-radius: var(--r-lg);
  background: var(--canvas);
  box-shadow: var(--ring);
}
.guide__figure svg { display: block; width: 100%; height: auto; overflow: visible; }
.guide__figure figcaption {
  margin-top: var(--sp-3);
  font-size: var(--t-2xs);
  color: var(--text-3);
  text-align: center;
  line-height: 1.5;
}

.guide-block { margin-bottom: var(--sp-4); }
.guide-block:last-child { margin-bottom: 0; }
.guide-block--p { font-size: var(--t-sm); color: var(--text-2); line-height: 1.65; }
.guide-block--p strong { color: var(--text-1); font-weight: 600; }
.guide-block h3 {
  font-family: var(--font-display); font-weight: 750;
  font-size: var(--t-md); letter-spacing: -0.012em;
  margin: var(--sp-6) 0 var(--sp-2);
}

.guide-steps {
  counter-reset: gstep;
  display: flex; flex-direction: column; gap: 10px;
}
.guide-steps > li {
  counter-increment: gstep;
  position: relative;
  padding-left: 34px;
  font-size: var(--t-sm);
  color: var(--text-2);
  line-height: 1.55;
  min-height: 24px;
}
.guide-steps > li::before {
  content: counter(gstep);
  position: absolute; left: 0; top: -1px;
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--t-2xs); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.guide-steps strong { color: var(--text-1); font-weight: 600; }

.guide-note {
  display: flex; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: var(--t-xs);
  line-height: 1.6;
  color: var(--text-2);
  background: var(--tone-soft, var(--accent-soft));
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--tone, var(--accent)) 22%, transparent);
}
.guide-note svg { color: var(--tone, var(--accent)); margin-top: 2px; }
.guide-note strong { color: var(--text-1); font-weight: 600; }

.guide-terms { display: flex; flex-direction: column; gap: 2px; }
.guide-terms > div {
  display: grid; grid-template-columns: minmax(96px, 34%) 1fr; gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: var(--t-xs); line-height: 1.5;
}
.guide-terms > div:first-child { border-top: 0; }
.guide-terms dt { font-weight: 600; color: var(--text-1); }
.guide-terms dd { color: var(--text-2); margin: 0; }

.guide-action { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.guide-action .t-xs { color: var(--text-3); }

.guide-next {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  margin-top: var(--sp-8);
  padding: 14px 16px;
  border-radius: var(--r-lg);
  box-shadow: var(--elev-2);
  text-align: left;
  transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-out);
}
.guide-next:hover { box-shadow: var(--ring), var(--shadow-lift); transform: translateY(-1px); }

/* ── The launcher ────────────────────────────────────────────────────── */

.guide-launch[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line);
}

/* ==========================================================================
   Graphics
   ==========================================================================

   Every diagram in the guide is inline SVG styled ONLY through these classes,
   never with literal colours. That keeps a dozen hand-drawn figures on one
   palette, lets them inherit the design tokens, and means a palette change
   restyles every graphic at once. A figure with a hex code in it is a bug.
   ========================================================================== */

.g text { font-family: var(--font-sans); }

.g-card   { fill: var(--surface-1); stroke: var(--line-strong); stroke-width: 1.25; }
.g-soft   { fill: var(--surface-2); }
.g-soft2  { fill: var(--surface-3); }
.g-tint   { fill: var(--accent-soft); }
.g-tint-stroke { fill: var(--accent-soft); stroke: var(--accent-line); stroke-width: 1.25; }
.g-accent { fill: var(--accent); }
.g-accent-line { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.g-line   { fill: none; stroke: var(--line-strong); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.g-line-strong { fill: none; stroke: var(--text-4); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.g-dash   { stroke-dasharray: 3 4; }
.g-arrow  { fill: var(--text-4); }
.g-arrow-accent { fill: var(--accent); }

.g-ink    { fill: var(--text-1); }
.g-ink2   { fill: var(--text-2); }
.g-ink3   { fill: var(--text-3); }
.g-on-accent { fill: var(--accent-ink); }

.g-success { fill: var(--success); }      .g-success-soft { fill: var(--success-soft); }
.g-warning { fill: var(--warning); }      .g-warning-soft { fill: var(--warning-soft); }
.g-danger  { fill: var(--danger); }       .g-danger-soft  { fill: var(--danger-soft); }
.g-info    { fill: var(--info); }         .g-info-soft    { fill: var(--info-soft); }

.g-slab    { fill: var(--slab); }
.g-on-slab { fill: var(--slab-ink); }

.g-t    { font-size: 11px; font-weight: 500; }
.g-t-sm { font-size: 10px; font-weight: 500; }
.g-t-b  { font-family: var(--font-display); font-weight: 750; font-size: 12px; }
.g-t-lg { font-family: var(--font-display); font-weight: 800; font-size: 15px; }
.g-t-xl { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.g-mono { font-family: var(--font-mono); font-size: 10px; }
.g-mid  { text-anchor: middle; }
.g-end  { text-anchor: end; }

/* A figure can mark one element as "live" — a gentle pulse, off under
   reduced motion by the global rule in base.css. */
.g-pulse { animation: pulse-soft 2.2s var(--ease) infinite; }
