/*
 * Rush Q Cards — reading surfaces
 * Copyright (c) 2026 Luciano Adonis Villarroel. Code under MIT.
 * Game content all rights reserved (see LICENSE.CONTENT).
 *
 * The docs shell used by rules, rulebook, FAQ, history, balance, analysis and
 * the exercise landing. Three columns on a wide screen: contents on the left
 * where the eye starts, prose in the middle at a fixed measure, and room on
 * the right for tables and asides to break out into.
 */

/* ── Docs shell ────────────────────────────────────────────── */
.content-layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  align-items: start;
  gap: var(--space-12);
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) var(--space-20);
}
.content-main { min-width: 0; }

.content-sidebar {
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
  max-height: calc(100dvh - var(--header-height) - var(--space-10));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: var(--space-2);
}

/* Below the sidebar breakpoint the contents become a disclosure at the top of
   the page rather than disappearing — a long rulebook is unusable without it. */
@media (max-width: 940px) {
  .content-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    padding: var(--space-6) var(--space-4) var(--space-16);
  }
  .content-sidebar {
    position: static;
    max-height: none;
    order: -1;
    padding: var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-1);
  }
}

/* ── Article typography ────────────────────────────────────────
   Prose is capped at a comfortable measure; tables, figures, and callouts
   opt out with .breakout and use the full column. */
.article { max-width: none; }
.article > p,
.article > ul,
.article > ol,
.article > blockquote { max-width: var(--measure); }

.article h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.3rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.022em;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  text-wrap: balance;
}
.article h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.012em;
  color: var(--text-primary);
  margin: var(--space-12) 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
}
.article h3 {
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -.005em;
  color: var(--text-primary);
  margin: var(--space-8) 0 var(--space-2);
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
}
.article h4 {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: var(--space-6) 0 var(--space-2);
}
.article h1 + h2, .article h2 + h3 { margin-top: var(--space-5); }

.article p { line-height: 1.72; margin-bottom: var(--space-4); color: var(--text-secondary); }
.article strong { color: var(--text-primary); font-weight: 650; }
.article em { color: var(--text-secondary); }

.article ul, .article ol { margin: 0 0 var(--space-4) 1.35em; color: var(--text-secondary); line-height: 1.72; }
.article li { margin-bottom: var(--space-2); }
.article li::marker { color: var(--text-faint); }
.article li > ul, .article li > ol { margin-top: var(--space-2); }

.article a { color: var(--accent-ink); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
.article a:hover { border-bottom-color: var(--accent-ink); }

/* Heading anchors appear on hover — present when wanted, invisible otherwise.
   Not scoped to .article: static pages get the same TOC treatment. */
.heading-anchor {
  margin-left: .4em;
  border: none;
  color: var(--text-faint);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--dur);
}
:is(h1, h2, h3, h4):hover > .heading-anchor,
.heading-anchor:focus-visible { opacity: 1; }

/* A quote in a rulebook is almost always a note, so it reads as one. */
.article blockquote {
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-secondary);
}
.article blockquote > :last-child { margin-bottom: 0; }

.article code {
  padding: .15em .4em;
  border-radius: var(--radius-xs);
  background: var(--film-2);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: .87em;
  color: var(--text-primary);
}
.article pre {
  margin: var(--space-5) 0;
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  overflow-x: auto;
}
.article pre code { padding: 0; border: none; background: none; font-size: .84rem; line-height: 1.65; }

.article hr { margin: var(--space-8) 0; border: none; border-top: 1px solid var(--border-subtle); }
/* A rule followed by a heading is one separator, not two. */
.article hr + :is(h2, h3) { margin-top: 0; }
.article img { max-width: 100%; height: auto; border-radius: var(--radius-md); }

/* ── Tables ────────────────────────────────────────────────────
   Wide tables scroll inside their own box; the page itself never does. */
.article table {
  display: block;
  width: max-content;
  min-width: 100%;
  max-width: 100%;
  overflow-x: auto;
  margin: var(--space-5) 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}
.article thead { background: var(--surface-2); }
.article th {
  position: sticky;
  top: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.article th:hover { background: var(--surface-3); }
.article th .sort-icon { margin-left: 4px; font-size: .7em; color: var(--text-faint); }
.article td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
  line-height: 1.55;
}
.article tbody tr:last-child td { border-bottom: none; }
.article tbody tr:hover td { background: var(--film-1); }

/* ── Contents ──────────────────────────────────────────────── */
.toc-title {
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 var(--space-3) var(--space-3);
}
.toc, .toc ul { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  padding: 6px var(--space-3);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
  text-decoration: none;
  transition: color var(--dur), background var(--dur), border-color var(--dur);
}
.toc a:hover { color: var(--text-primary); background: var(--film-1); }
.toc a.active {
  color: var(--accent-ink);
  border-left-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.toc .toc-sub a { padding-left: var(--space-6); font-size: var(--text-xs); color: var(--text-faint); }
.toc .toc-sub a:hover, .toc .toc-sub a.active { color: var(--accent-ink); }

.toc-tool {
  width: 100%;
  margin-bottom: var(--space-4);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.toc-tool:hover { background: var(--surface-3); color: var(--text-primary); border-color: var(--border-strong); }

/* ── Page header block ─────────────────────────────────────── */
.page-head { margin-bottom: var(--space-8); }
.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -.024em;
  margin-bottom: var(--space-3);
  text-wrap: balance;
}
.page-head-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.page-head-lede {
  font-size: var(--text-lg);
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: var(--measure);
}

/* ── Back to top ───────────────────────────────────────────── */
.to-top {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  z-index: var(--z-panel);
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-secondary);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--dur), transform var(--dur) var(--ease-out), color var(--dur), background var(--dur);
}
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { color: var(--text-primary); background: var(--surface-3); }
.to-top svg { width: 17px; height: 17px; }

/* ── Reading progress ──────────────────────────────────────── */
.read-progress {
  position: fixed;
  top: var(--header-height);
  left: 0;
  z-index: var(--z-panel);
  height: 2px;
  width: 0;
  background: var(--accent);
  transition: width 80ms linear;
  pointer-events: none;
}

/* ── Callouts ──────────────────────────────────────────────────
   One component, four tones. The tone is the meaning, not decoration:
   note explains, tip helps you win, warn costs you points, rule is binding. */
.callout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3);
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--tone-line);
  border-radius: var(--radius-md);
  background: var(--tone-fill);
  max-width: var(--measure);
}
.callout-icon { color: var(--tone-ink); margin-top: 1px; }
.callout-icon svg { width: 17px; height: 17px; display: block; }
.callout-title {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--tone-ink);
  margin-bottom: 3px;
}
.callout-body { font-size: var(--text-sm); line-height: 1.65; color: var(--text-secondary); }
.callout-body > :last-child { margin-bottom: 0; }

.callout-note { --tone-ink: var(--info-ink); --tone-line: color-mix(in oklab, var(--info) 34%, transparent); --tone-fill: var(--info-soft); }
.callout-tip  { --tone-ink: var(--pos-ink);  --tone-line: color-mix(in oklab, var(--pos) 34%, transparent);  --tone-fill: var(--pos-soft); }
.callout-warn { --tone-ink: var(--neg-ink);  --tone-line: color-mix(in oklab, var(--neg) 34%, transparent);  --tone-fill: var(--neg-soft); }
.callout-rule { --tone-ink: var(--accent-ink); --tone-line: var(--accent-line); --tone-fill: var(--accent-soft); }

/* ── Definition rows ───────────────────────────────────────────
   A term, what it means, and when it bites. Reads as a table on a wide
   screen and as stacked cards on a phone, without a horizontal scrollbar. */
.deflist { display: grid; gap: 1px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; background: var(--border-subtle); }
.defrow {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 150px;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-1);
}
.defrow-term { font-weight: 650; color: var(--text-primary); font-size: var(--text-sm); }
.defrow-desc { font-size: var(--text-sm); line-height: 1.6; color: var(--text-secondary); }
.defrow-when { font-size: var(--text-xs); color: var(--text-muted); text-align: right; }
@media (max-width: 720px) {
  .defrow { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
  .defrow-when { text-align: left; }
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all var(--dur);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-bright);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Quick rules sections ─────────────────────────────────── */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.rules-section {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.rules-section h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rules-section p, .rules-section ul {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}
.rules-section ul { padding-left: 18px; }

/* ── Exercises ────────────────────────────────────────────── */
.exercise-landing {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--space-10) var(--space-6) var(--space-16);
}
.exercise-heading {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -.024em;
  margin-bottom: var(--space-3);
}
.exercise-subheading {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  line-height: 1.6;
  max-width: var(--measure);
  margin-bottom: var(--space-8);
}

/* ── Role grid (landing) ──────────────────────────────────────
   Two across: four roles fill the row cleanly and the eye compares them
   side by side instead of scrolling past four identical wide bars. */
.role-grid-landing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--space-4);
}
.role-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface-1);
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--role-color) 22%, var(--border));
  border-radius: var(--radius);
  padding: 19px 20px;
  cursor: pointer;
  transition: all var(--dur);
}
.role-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--role-color);
}
.role-card:hover {
  border-color: var(--role-color);
  background: color-mix(in srgb, var(--role-color) 5%, var(--surface-1));
  transform: translateY(-2px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--role-color) 15%, transparent);
}
.role-card-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--role-color) 30%, transparent);
  background: color-mix(in srgb, var(--role-color) 8%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.role-card-svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.role-card-body { flex: 1; min-width: 0; }
.role-card-label {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--role-color);
  margin-bottom: 3px;
}
.role-card-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
}
.role-card-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.role-card-progress {
  color: var(--pos-ink);
  font-weight: 600;
}

/* ── Scenario view ────────────────────────────────────────── */
.scenario-view {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}
.scenario-back {
  background: none;
  border: none;
  color: var(--accent-bright);
  font-family: var(--font);
  font-size: var(--text-sm);
  cursor: pointer;
  margin-bottom: 16px;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.scenario-back:hover { text-decoration: underline; }
.scenario-setup {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.scenario-header-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.scenario-title {
  font-size: 1.25rem;
  font-weight: 700;
}
.scenario-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.scenario-badge {
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.scenario-badge-muted {
  background: var(--surface-2);
  color: var(--text-muted);
}
.scenario-setup-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
}
.scenario-context {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.scenario-context-badge {
  font-size: var(--text-xs);
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-secondary);
}
.scenario-question {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 16px 0 12px;
}
.scenario-hand {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.scenario-card-wrap {
  cursor: pointer;
  transition: transform var(--dur);
}
.scenario-card-wrap:hover { transform: translateY(-4px); }
.scenario-card-wrap.rc-selected .rush-card.rc-mini {
  border-color: var(--accent-bright);
  box-shadow: 0 0 12px rgba(0,128,255,.3);
  transform: translateY(-6px);
}
.scenario-submit {
  margin-top: 12px;
  padding: 10px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--accent-contrast);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur);
}
.scenario-submit:hover { background: var(--accent-bright); }
.scenario-submit:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.scenario-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.scenario-feedback {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}
.feedback-score {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: 8px;
}
.feedback-score.perfect { color: var(--pos-ink); }
.feedback-score.good { color: var(--warn-ink); }
.feedback-score.partial { color: var(--type-trait); }
.feedback-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}
.common-mistake {
  margin-top: 12px;
  padding: 12px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}
.common-mistake strong { color: var(--warn-ink); }
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--film-3); color: var(--text-primary); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-bright); }
.scenario-hints { margin-top: 20px; }
.hint-btn {
  margin-top: 12px;
  padding: 6px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--text-xs);
  cursor: pointer;
}
.hint-btn:hover { border-color: var(--border-strong); }
.hint-text {
  margin-top: 8px;
  padding: 10px;
  background: var(--warn-soft);
  border: 1px solid color-mix(in oklab, var(--warn) 28%, transparent);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Learning / Rules page components ────────────────────── */

/* Badges */
.learn-badge {
  display: inline-flex; align-items: center;
  font-size: 0.65rem; font-weight: 600;
  padding: 3px 10px; border-radius: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.learn-badge-green { background: var(--pos-soft); color: var(--pos-ink); border: 1px solid color-mix(in oklab, var(--pos) 34%, transparent); }
.learn-badge-blue  { background: var(--info-soft);  color: var(--info-ink); border: 1px solid color-mix(in oklab, var(--info) 34%, transparent); }

/* Section wrapper */
.learn-section { }
.learn-section-title {
  font-size: 1.05rem; font-weight: 700;
  margin-bottom: 4px; color: var(--text-primary);
}
.learn-section-sub {
  font-size: var(--text-sm); color: var(--text-muted);
  margin-bottom: 16px; line-height: 1.5;
}

/* ── Core Loop Track ─────────────────────────────────────── */
.loop-track {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 16px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.loop-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 1; min-width: 100px; max-width: 160px;
  padding: 14px 10px;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--loop-color) 25%, transparent);
  border-radius: var(--radius);
  text-align: center;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.loop-step:hover {
  border-color: var(--loop-color);
  box-shadow: 0 0 12px color-mix(in srgb, var(--loop-color) 20%, transparent);
}
.loop-step-win {
  border-color: color-mix(in srgb, var(--loop-color) 40%, transparent);
  background: color-mix(in srgb, var(--loop-color) 6%, var(--surface-2));
}
.loop-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--loop-color) 12%, transparent);
  border-radius: 8px;
  color: var(--loop-color);
}
.loop-icon svg { width: 18px; height: 18px; }
.loop-label { font-size: var(--text-sm); font-weight: 700; color: var(--loop-color); }
.loop-desc { font-size: 0.65rem; color: var(--text-muted); line-height: 1.4; }
.loop-arrow {
  font-size: 1.2rem; color: var(--border-strong);
  flex-shrink: 0; padding: 0 4px;
}

/* ── Role Analogy Grid (rules page — scoped to .role-grid) ── */
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.role-grid .role-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  border-left: 1px solid var(--border);
  cursor: default;
}
.role-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.role-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.role-body {
  font-size: var(--text-sm); color: var(--text-secondary);
  line-height: 1.6;
}
.role-body strong { color: var(--text-primary); }

/* ── Setup Steps ─────────────────────────────────────────── */
.setup-steps {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.setup-step {
  display: flex; align-items: flex-start; gap: 14px;
  font-size: var(--text-sm); color: var(--text-secondary);
  line-height: 1.6;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.setup-step:last-child { border-bottom: none; padding-bottom: 0; }
.setup-step strong { color: var(--text-primary); }
.setup-num {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-bright);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ── Turn Stepper ────────────────────────────────────────── */
.turn-stepper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.turn-step {
  position: relative;
  overflow: hidden;
  background: var(--surface-1);
  border: 1px solid color-mix(in srgb, var(--step-color) 22%, var(--border-subtle));
  border-radius: var(--radius);
  padding: 15px 14px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.turn-step::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--step-color);
}
.turn-step-header {
  display: flex; align-items: center; gap: 8px;
}
.turn-step-num {
  font-size: 0.75rem; font-weight: 800;
  color: var(--step-color);
  background: color-mix(in srgb, var(--step-color) 12%, transparent);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.turn-step-name { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); flex: 1; }
.turn-step-tag {
  font-size: 0.55rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 2px 6px; border-radius: 4px;
  flex-shrink: 0;
}
.turn-step-tag.optional { background: var(--film-2); color: var(--text-muted); }
.turn-step-tag.required { background: var(--neg-soft); color: var(--neg-ink); }
.turn-step-body { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.6; }

/* ── Card Type Grid ──────────────────────────────────────── */
.card-type-grid {
  display: flex; flex-direction: column; gap: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-type-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--dur);
}
.card-type-item:last-child { border-bottom: none; }
.card-type-item:hover { background: var(--surface-2); }
.ct-pip {
  width: 10px; height: 10px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--ct-color);
  margin-top: 5px;
  box-shadow: 0 0 6px color-mix(in srgb, var(--ct-color) 60%, transparent);
}
.ct-name { font-size: var(--text-sm); font-weight: 600; color: var(--ct-color); margin-bottom: 2px; }
.ct-desc { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.55; }

/* ── Mechanic Alerts ─────────────────────────────────────── */
.mechanic-alerts { display: flex; flex-direction: column; gap: 8px; }
.mechanic-alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--alert-color) 6%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--alert-color) 26%, transparent);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}
.mechanic-alert strong { color: var(--text-primary); }
.mechanic-alert em { color: var(--text-muted); }
.alert-icon {
  color: var(--alert-color);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Quick Reference Table ───────────────────────────────── */
.ref-table-wrap {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.ref-table th {
  text-align: left;
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ref-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
}
.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:hover td { background: var(--surface-2); }
.ref-table td strong { color: var(--text-primary); }

/* ── Learn CTA ───────────────────────────────────────────── */
.learn-cta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 20px 24px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.btn-learn-primary {
  display: inline-flex; align-items: center;
  padding: 10px 22px;
  background: var(--accent-bright);
  color: var(--accent-contrast);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  transition: opacity var(--dur);
}
.btn-learn-primary:hover { opacity: 0.88; }
.btn-learn-secondary {
  display: inline-flex; align-items: center;
  padding: 10px 18px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: border-color var(--dur), color var(--dur);
}
.btn-learn-secondary:hover { border-color: var(--border-strong); color: var(--text-primary); }

/* ── Print ────────────────────────────────────────────────── */
@media print {
  header, nav, .header-bar, .content-sidebar, .site-footer, .tabs { display: none !important; }
  body { background: #fff; color: #000; }
  .article h2 { border-bottom-color: #ccc; }
  .article p, .article li, .article td { color: #333; }
  .article blockquote { border-color: #999; background: #f5f5f5; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .content-layout { flex-direction: column; padding: 16px var(--space-4); }
  .content-sidebar { width: 100%; position: static; max-height: none; }
  .scenario-hand { justify-content: center; }
  .role-card { padding: 14px 16px; gap: 12px; }
  .role-card-icon { width: 40px; height: 40px; }
  .scenario-header-row { flex-direction: column; gap: 8px; }

  .loop-track { gap: 8px; padding: 12px; }
  .loop-step { min-width: 80px; padding: 10px 8px; }
  .loop-desc { display: none; }
  .loop-arrow { font-size: 0.9rem; padding: 0 2px; }

  .turn-stepper { grid-template-columns: 1fr 1fr; }

  .learn-cta { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .loop-track { flex-wrap: wrap; justify-content: center; }
  .loop-step { flex: 0 0 calc(50% - 20px); max-width: none; }
  .loop-arrow { display: none; }

  .turn-stepper { grid-template-columns: 1fr; }
  .role-grid { grid-template-columns: 1fr; }
}

/* ── FAQ ───────────────────────────────────────────────────────
   Questions carry their own weight, so each one is a card rather than a run
   of headings. Scanning for your question is the whole job of this page. */
.faq-section { margin-bottom: var(--space-12); }
.faq-section > h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.012em;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
}

.faq-item {
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  transition: border-color var(--dur), background var(--dur);
}
.faq-item:hover { border-color: var(--border); background: var(--surface-2); }
.faq-item > h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
}
.faq-item p,
.faq-item ul,
.faq-item ol {
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: var(--measure);
}
.faq-item p { margin-bottom: var(--space-3); }
.faq-item ul, .faq-item ol { margin: 0 0 var(--space-3) 1.3em; }
.faq-item li { margin-bottom: var(--space-2); }
.faq-item li::marker { color: var(--text-faint); }
.faq-item > :last-child { margin-bottom: 0; }
.faq-item strong { color: var(--text-primary); font-weight: 650; }
.faq-item a { color: var(--accent-ink); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
.faq-item a:hover { border-bottom-color: var(--accent-ink); }

.content-page > h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -.024em;
  margin-bottom: var(--space-3);
  text-wrap: balance;
}
.content-intro {
  font-size: var(--text-lg);
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: var(--measure);
  margin-bottom: var(--space-10);
}

.content-cta {
  margin-top: var(--space-10);
  padding: var(--space-5) var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.content-cta a { color: var(--accent-ink); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
.content-cta a:hover { border-bottom-color: var(--accent-ink); }
