/* ============================================================
   Polter Click — guide.html only.
   Everything shared (tokens, nav, buttons, .card-material,
   footer) lives in style.css; this sheet is the documentation
   layout on top of it: the two-column shell, the figures, the
   numbered steps and the callouts.
   ============================================================ */

/* ---------- shell ---------- */
.doc {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 56px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 28px 120px;
}
@media (max-width: 960px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 28px; }
}

/* ---------- table of contents ---------- */
.toc {
  position: sticky;
  top: 92px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 6px;
  font-size: 0.88rem;
  scrollbar-width: thin;
}
.toc h2 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}
.toc li { counter-increment: toc; }
.toc ol a {
  display: block;
  padding: 6px 0 6px 26px;
  color: var(--ink-muted);
  border-left: 2px solid transparent;
  position: relative;
  line-height: 1.35;
}
.toc ol a::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute;
  left: 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
}
.toc ol a:hover { color: var(--ink); }
.toc ol a.active {
  color: var(--ghost-glow);
  border-left-color: var(--ghost);
}
.toc ol a.active::before { color: var(--ghost-glow); }
.toc .toc-foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
@media (max-width: 960px) {
  .toc {
    position: static;
    max-height: none;
    margin-bottom: 40px;
    padding: 18px 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }
  .toc ol { columns: 2; column-gap: 24px; }
  .toc .toc-foot { margin-top: 16px; padding-top: 14px; }
  @media (max-width: 560px) {
    /* one column on a phone, so tighten the rows — otherwise the contents
       alone are a whole screen before the guide starts */
    .toc ol { columns: 1; font-size: 0.85rem; }
    .toc ol a { padding: 3px 0 3px 24px; }
  }
}

/* ---------- page head ---------- */
.doc-head { margin-bottom: 8px; }
.doc-head h1 {
  font-size: clamp(2rem, 4vw, 2.9rem);
  line-height: 1.1;
  margin-bottom: 16px;
}
.doc-head .lede {
  font-size: 1.08rem;
  color: var(--ink-muted);
  max-width: 62ch;
  margin: 0;
}

/* ---------- sections ---------- */
.doc-body > section {
  padding-top: 66px;
  scroll-margin-top: 88px;
}
.doc-body > section > h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.doc-body > section > h2 .n {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--ghost);
  letter-spacing: 0.08em;
}
.doc-body h3 {
  font-size: 1.06rem;
  margin: 34px 0 10px;
}
.doc-body p {
  color: var(--ink-muted);
  margin: 0 0 14px;
  max-width: 70ch;
}
.doc-body p.tight { margin-bottom: 6px; }
.doc-body strong { color: var(--ink); font-weight: 600; }
.doc-body a:not(.btn) {
  color: var(--ghost-glow);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(143, 177, 255, 0.4);
}
.doc-body a:not(.btn):hover { text-decoration-color: var(--ghost-glow); }

.doc-body ul, .doc-body ol.plain {
  color: var(--ink-muted);
  margin: 0 0 16px;
  padding-left: 20px;
  max-width: 70ch;
}
.doc-body li { margin-bottom: 7px; }
.doc-body li::marker { color: var(--ink-faint); }

/* ---------- inline vocabulary ---------- */
kbd {
  font-family: var(--font-mono);
  font-size: 0.82em;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-bottom-width: 2px;
  color: var(--ink);
  white-space: nowrap;
}
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--ghost-glow);
  background: rgba(61, 123, 255, 0.09);
  border-radius: 4px;
  padding: 1px 5px;
}
.doc-body .node {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--ink);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 1px 7px;
  white-space: nowrap;
}

/* ---------- figures ---------- */
figure {
  margin: 22px 0 26px;
}
figure img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--void-2);
}
figure.inset img {
  max-width: 620px;
}
figcaption {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--ink-faint);
  line-height: 1.5;
  max-width: 70ch;
}
figcaption b {
  color: var(--ink-muted);
  font-weight: 500;
}

/* ---------- numbered walkthrough ---------- */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 26px 0 8px;
  padding: 0;
}
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 30px 52px;
  margin: 0;
  border-left: 1px solid var(--border);
}
.steps > li:last-child { border-left-color: transparent; padding-bottom: 6px; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: -16px;
  top: -2px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--ghost-glow);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps > li h3 {
  margin: 3px 0 8px;
  font-size: 1.02rem;
}
.steps > li p:last-child { margin-bottom: 0; }
.steps figure { margin-bottom: 4px; }

/* ---------- callout ---------- */
.note {
  border-left: 2px solid var(--ghost);
  background: rgba(61, 123, 255, 0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 20px 0;
  max-width: 72ch;
}
.note p { margin: 0; color: var(--ink-muted); font-size: 0.94rem; }
.note p + p { margin-top: 8px; }
.note .tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ghost-glow);
  margin-bottom: 6px;
}
.note.warn { border-left-color: #e0a35a; background: rgba(224, 163, 90, 0.07); }
.note.warn .tag { color: #e5b479; }

/* ---------- the model diagram ---------- */
.model {
  padding: 26px 26px 22px;
  margin: 24px 0 28px;
}
.model svg { width: 100%; height: auto; }

/* ---------- node reference grid ---------- */
.kinds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 26px;
}
@media (max-width: 700px) { .kinds { grid-template-columns: minmax(0, 1fr); } }
.kind {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
}
.kind b {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
  margin-bottom: 3px;
}
.kind span {
  color: var(--ink-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.kind i {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ghost);
  display: block;
  margin-bottom: 8px;
}

/* ---------- closing band ---------- */
.doc-cta {
  margin-top: 76px;
  padding: 40px 34px;
  text-align: center;
  background: radial-gradient(120% 140% at 50% -10%, rgba(61, 123, 255, 0.16), transparent 60%), var(--panel-2);
}
.doc-cta h2 { font-size: 1.5rem; margin-bottom: 10px; }
.doc-cta p { color: var(--ink-muted); margin: 0 auto 22px; max-width: 46ch; }

/* ---------- how do I: task recipes ---------- */
.recipes { margin: 26px 0 0; }
.recipe + .recipe {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}
.recipe > h3:first-child { margin-top: 0; color: var(--ghost-glow); }
.recipe .model { margin: 20px 0 6px; }
.recipe .kinds { margin-bottom: 18px; }
.recipe .note { margin-bottom: 0; }

/* ---------- motion inside those diagrams ----------
   Every moving part sits on top of a drawing that already reads correctly standing
   still: the pulses are fully transparent at rest and the wires are plain dashed
   lines. That is what makes the blanket prefers-reduced-motion rule in style.css safe
   here — it flattens the animation and leaves an intact diagram behind. */
.fx { --cycle: 5s; }
.fx .fx-wire { stroke-dasharray: 5 5; animation: fx-flow 1.2s linear infinite; }
@keyframes fx-flow { to { stroke-dashoffset: -10; } }

/* one node lighting up as the flow reaches it — --d is its place in the chain */
.fx .fx-pulse {
  opacity: 0;
  animation: fx-pulse var(--cycle) ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes fx-pulse {
  0%, 3% { opacity: 0; }
  9%     { opacity: 1; }
  27%    { opacity: 0; }
  100%   { opacity: 0; }
}

/* a stage holding the floor for its half of the cycle, rather than blinking once */
.fx .fx-hold {
  opacity: 0;
  animation: fx-hold var(--cycle) linear infinite;
  animation-delay: var(--d, 0s);
}
@keyframes fx-hold {
  0%        { opacity: 0; }
  2%, 42%   { opacity: 1; }
  46%, 100% { opacity: 0; }
}

/* the sweep inside the capture track — 136 = track width 170 less the sweep's own 34 */
.fx .fx-scan { animation: fx-scan var(--cycle) linear infinite; }
@keyframes fx-scan {
  from { transform: translateX(0); }
  to   { transform: translateX(136px); }
}

/* An 880-unit diagram squeezed into a phone column renders its labels at about 4px.
   Give it a floor and let the card scroll sideways instead — legible beats complete.
   This covers the model diagram in section 02 as well, which had the same problem. */
@media (max-width: 700px) {
  .model { overflow-x: auto; padding: 20px 16px 16px; }
  .model svg { min-width: 720px; }
}

/* The running line — where a flow is in its lane right now. #f38ba8 is the one tone that
   is not a node colour, so it always reads as "position in time" rather than as a step. */
.fx .fx-bar {
  transform: scaleX(0);
  transform-box: fill-box;
  transform-origin: left center;
  animation: fx-bar var(--cycle) linear infinite;
  animation-delay: var(--d, 0s);
}
@keyframes fx-bar {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.fx .fx-head {
  opacity: 0;
  animation: fx-head var(--cycle) linear infinite;
  animation-delay: var(--d, 0s);
}
@keyframes fx-head {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 1; transform: translateX(var(--travel, 0px)); }
}

/* Flows belong to a stage, so their running lines only move while that stage is the live
   one. The gate reuses fx-hold and carries the diagram's own --cycle; the bars inside it
   override --cycle with their own, much shorter, lap time. */
.fx .fx-gate {
  opacity: 0;
  animation: fx-hold var(--cycle) linear infinite;
  animation-delay: var(--d, 0s);
}

/* ---------- the four words ---------- */
.terms { margin: 24px 0 28px; }
.term + .term {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}
.term > h3:first-child {
  margin: 0 0 10px;
  font-size: 1.24rem;
  color: var(--ghost-glow);
}
.term .model { margin: 20px 0 6px; }
.term > p:last-child { margin-bottom: 0; }
