/*
 * Kosmaris Game Guide — styles.css
 *
 * ============================================================
 * DESIGN TOKEN MIRROR
 * ============================================================
 * The :root block below is a literal copy of the relevant CSS
 * custom properties from frontend/src/styles/_tokens.scss.
 * Values are reproduced exactly — do NOT change them here
 * without also updating the Angular token file, and vice-versa.
 * Re-sync this block whenever _tokens.scss changes.
 * ============================================================
 *
 * Palette: bg #0a0e1a, neon cyan #5ed5ff, gold #ffd700.
 * BEM naming.
 * Atmospheric nebula backdrop mirrors landing/auth-card pages.
 * WCAG AA contrast maintained on all foreground/background pairs.
 */

/* =====================================================================
   0. Design token layer (mirror of frontend/src/styles/_tokens.scss)
   ===================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* ── Raw RGB channels ──────────────────────────────────────────────── */
  --neon-rgb: 94 213 255;
  --danger-rgb: 255 77 77;
  --gold-rgb: 245 215 110;
  --success-rgb: 104 211 145;

  /* ── Background layers ─────────────────────────────────────────────── */
  --bg-base:     #0a0e1a;
  --bg-elevated: #0d1525;
  --bg-overlay:  #111827;
  --bg-void:     #03070f;
  --bg-pane:     rgb(10 22 40 / 72%);
  --bg-grid:
    linear-gradient(rgb(94 213 255 / 6%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(94 213 255 / 6%) 1px, transparent 1px);

  /* ── Borders ────────────────────────────────────────────────────────── */
  --border-subtle: #1e3a5f;
  --border-strong: #2a5a9f;
  --edge:        rgb(94 213 255 / 18%);
  --edge-strong: rgb(94 213 255 / 45%);

  /* ── Text ────────────────────────────────────────────────────────────── */
  --text-primary:   #e0e6f0;
  --text-secondary: #8899bb;
  --text-muted:     #5a7a9a;
  --text-on-dark:   #ffffff;
  --text-1: #e8f4ff;
  --text-2: #8ea8c4;
  --text-3: #51718e;

  /* ── Accent colours ──────────────────────────────────────────────────── */
  --accent-cool:      #5fa8b8;
  --accent-cool-dark: #3d7a8a;
  --accent-warm:      #ffd700;
  --neon:             #5ed5ff;
  --gold:             #f5d76e;
  --neon-soft:        #9ce4ff;

  /* ── Semantic status ─────────────────────────────────────────────────── */
  --danger:         #ff4d4d;
  --success:        #68d391;
  --danger-surface: #2a1020;

  /* ── Shadows / glow ─────────────────────────────────────────────────── */
  --shadow-glow:        0 0 24px rgb(94 213 255 / 25%);
  --shadow-glow-soft:   0 0 12px rgb(94 213 255 / 15%);
  --shadow-glow-warm:   0 0 18px rgb(245 215 110 / 25%);
  --shadow-glow-danger: 0 0 18px rgb(255 77 77 / 30%);

  /* ── Spacing scale ────────────────────────────────────────────────────── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* ── Radius ───────────────────────────────────────────────────────────── */
  --radius-none: 0;
  --radius-sm:   2px;
  --radius-md:   4px;
  --radius-full: 50%;

  /* ── Type scale ───────────────────────────────────────────────────────── */
  --text-micro: 10px;
  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-lg:   16px;
  --text-xl:   20px;

  /* ── Font families ────────────────────────────────────────────────────── */
  --font-sans: 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;

  /* ── Guide-specific layout ──────────────────────────────────────────── */
  --guide-nav-width:    252px;
  --guide-max-content:  840px;
  --guide-header-height: 56px;
  --transition-fast: 0.15s ease;
  --transition-med:  0.25s ease;
}

/* =====================================================================
   1. Base
   ===================================================================== */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  background: var(--bg-void);
  background-image: var(--bg-grid);
  background-size: 48px 48px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.75;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--neon);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--neon-soft);
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--neon);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* =====================================================================
   2. Atmospheric nebula backdrop
   Mirrors the landing page layered nebula treatment.
   Placed behind all content via z-index: -2.
   ===================================================================== */
.guide-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: var(--bg-base);
  background-image:
    /* Vignette — darkens corners */
    radial-gradient(
      ellipse 120% 120% at 50% 50%,
      transparent 40%,
      rgb(3 7 15 / 65%) 100%
    ),
    /* Secondary wisp — upper-right, warm gold */
    radial-gradient(
      ellipse 50% 45% at 80% 12%,
      rgb(255 215 0 / 5%) 0%,
      transparent 70%
    ),
    /* Primary nebula core — off-centre cyan */
    radial-gradient(
      ellipse 75% 60% at 30% 55%,
      rgb(94 213 255 / 9%) 0%,
      rgb(94 213 255 / 3%) 35%,
      transparent 75%
    ),
    /* Lower-right scatter */
    radial-gradient(
      ellipse 38% 32% at 87% 82%,
      rgb(94 213 255 / 4%) 0%,
      transparent 65%
    );
}

/* Tactical grid overlay */
.guide-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--bg-grid);
  background-size: 32px 32px;
  opacity: 0.15;
  pointer-events: none;
}

/* =====================================================================
   3. Site header — game HUD top-bar with scan-line accent
   ===================================================================== */
.guide-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--guide-header-height);
  background: rgb(10 14 26 / 92%);
  border-bottom: 1px solid var(--edge);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  /* HUD chrome: neon glow below + faint inner highlight */
  box-shadow: 0 1px 0 rgb(94 213 255 / 12%), inset 0 1px 0 rgb(94 213 255 / 8%);
  transition: background var(--transition-med), border-color var(--transition-med), box-shadow var(--transition-med);
}

/* HUD scan-line — animated neon+gold gradient stripe across top of header */
.guide-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--neon) 30%, var(--gold) 60%, transparent 100%);
  opacity: 0.65;
  animation: guide-hud-scan 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes guide-hud-scan {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
  .guide-header::before { animation: none; opacity: 0.55; }
}

.guide-header--scrolled {
  background: rgb(10 14 26 / 96%);
  border-bottom-color: var(--edge-strong);
  box-shadow: var(--shadow-glow-soft), 0 1px 0 rgb(94 213 255 / 16%), inset 0 1px 0 rgb(94 213 255 / 10%);
}

.guide-header__inner {
  width: 100%;
  max-width: calc(var(--guide-nav-width) + var(--guide-max-content) + var(--space-6) * 2);
  margin: 0 auto;
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

/* Brand wordmark — mirrors .brand--nav from landing page */
.guide-header__logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--neon);
  text-shadow: 0 0 14px rgb(94 213 255 / 60%);
  text-decoration: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.guide-header__logo:hover {
  color: var(--neon);
  text-decoration: none;
}

/* "Game Guide" subtitle badge next to the wordmark */
.guide-header__logo-sub {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 2px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  text-shadow: none;
}

.guide-header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Mobile nav toggle — shown only on small screens */
.guide-header__mobile-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.guide-header__mobile-toggle:hover {
  border-color: var(--neon);
  color: var(--neon);
}

/* Play Now CTA — gold outline button */
.guide-header__play-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--bg-base);
  background: var(--gold);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  text-decoration: none;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.guide-header__play-link:hover {
  background: color-mix(in srgb, var(--gold) 85%, #fff);
  box-shadow: var(--shadow-glow-warm);
  color: var(--bg-base);
  text-decoration: none;
}

/* =====================================================================
   4. Main layout — sidebar + content
   ===================================================================== */
.guide-layout {
  display: flex;
  min-height: calc(100vh - var(--guide-header-height));
  position: relative;
}

/* =====================================================================
   5. Left nav sidebar — frosted HUD panel
   ===================================================================== */
.guide-nav {
  width: var(--guide-nav-width);
  flex-shrink: 0;
  background: rgb(13 21 37 / 85%);
  border-right: 1px solid var(--edge);
  position: sticky;
  top: var(--guide-header-height);
  height: calc(100vh - var(--guide-header-height));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
  transition: transform var(--transition-med);
  /* HUD panel — relative for corner-bracket pseudo-element */
  position: sticky;
}

/* Nexus corner bracket — top-right, mirrors .k-panel--nexus */
.guide-nav::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 14px; height: 14px;
  border-top: 1px solid var(--neon);
  border-right: 1px solid var(--neon);
  filter: drop-shadow(0 0 6px rgb(94 213 255 / 70%));
  pointer-events: none;
  z-index: 1;
}

.guide-nav::-webkit-scrollbar {
  width: 4px;
}

.guide-nav::-webkit-scrollbar-track {
  background: transparent;
}

.guide-nav::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

.guide-nav__inner {
  padding: var(--space-5) 0 var(--space-6);
}

.guide-nav__heading {
  /* Matches app-nav-section: 9px, 0.28em tracking, muted caps (nav-section.component.scss) */
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 var(--space-4) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Small decorative neon bar before the heading */
.guide-nav__heading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 1px;
  background: var(--neon);
  opacity: 0.5;
  flex-shrink: 0;
}

/* TOC section group labels */
.guide-toc__section-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: var(--space-4) var(--space-4) var(--space-2);
}

.guide-toc__section-label:not(:first-child) {
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-2);
}

/* TOC individual page links */
.guide-toc__link {
  display: flex;
  align-items: center;
  padding: 7px var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.guide-toc__link:hover {
  color: var(--neon-soft);
  background: rgb(94 213 255 / 5%);
  border-left-color: rgb(94 213 255 / 40%);
  text-decoration: none;
}

.guide-toc__link--active {
  color: var(--neon);
  border-left-color: var(--neon);
  background: rgb(94 213 255 / 8%);
  font-weight: 600;
}

.guide-toc__link--active:hover {
  color: var(--neon);
  background: rgb(94 213 255 / 10%);
  border-left-color: var(--neon);
}

/* Mobile overlay close button inside the nav */
.guide-nav__close {
  display: none;
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  line-height: 1;
}

/* =====================================================================
   6. Content area
   ===================================================================== */
.guide-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-6) var(--space-6) 80px;
}

.guide-article {
  max-width: var(--guide-max-content);
}

/* ── Page title (h1) — neon underline + wider accent bar ── */
.guide-article h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.02em;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.guide-article h1::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 72px;
  height: 2px;
  background: linear-gradient(90deg, var(--neon), transparent);
  filter: drop-shadow(0 0 6px rgb(94 213 255 / 60%));
}

/* ── HUD SECTION PANELS ──────────────────────────────────────────────────────
   .guide-section wraps each h2 block, giving it the Kosmaris panel aesthetic:
   - --bg-elevated surface above the --bg-void body
   - 2px top-edge: neon→transparent gradient (matches k-panel--nexus top accent)
   - 1px side/bottom: --border-subtle
   - L-shaped corner brackets via ::before / ::after (nexus-corner-brackets mixin)
   Injected by build.mjs around every h2…next-h2 content block.
   ───────────────────────────────────────────────────────────────────────────── */
.guide-section {
  position: relative;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  /* Two-layer border-image trick: 2px top accent, 1px rest */
  border: 1px solid var(--border-subtle);
  border-top: 2px solid transparent;
  background-image:
    linear-gradient(var(--bg-elevated), var(--bg-elevated)),
    linear-gradient(90deg, var(--neon) 0%, rgb(94 213 255 / 20%) 45%, transparent 72%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

/* Nexus top-right corner bracket */
.guide-section::before {
  content: '';
  position: absolute;
  top: -1px; right: -1px;
  width: 14px; height: 14px;
  border-top: 1px solid var(--neon);
  border-right: 1px solid var(--neon);
  filter: drop-shadow(0 0 6px rgb(94 213 255 / 70%));
  pointer-events: none;
  z-index: 1;
}

/* Nexus bottom-left corner bracket */
.guide-section::after {
  content: '';
  position: absolute;
  bottom: -1px; left: -1px;
  width: 14px; height: 14px;
  border-bottom: 1px solid var(--neon);
  border-left: 1px solid var(--neon);
  filter: drop-shadow(0 0 6px rgb(94 213 255 / 70%));
  pointer-events: none;
  z-index: 1;
}

/* ── Section headings (h2) — neon accent with // prefix ── */
.guide-article h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--neon);
  /* Reset margin — .guide-section provides padding */
  margin-top: 0;
  margin-bottom: var(--space-4);
  letter-spacing: 0.02em;
  /* Flex so the // prefix aligns at baseline without gap jank */
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

/* // ghost prefix — matches existing guide convention but with flex alignment */
.guide-article h2::before {
  content: '//';
  color: rgb(94 213 255 / 35%);
  font-size: 0.72em;
  font-weight: 400;
  letter-spacing: -0.1em;
  flex-shrink: 0;
}

/* ── Sub-section headings (h3) — gold with › caret prefix ── */
.guide-article h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gold);
  margin-top: var(--space-5);
  margin-bottom: var(--space-3);
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

/* › caret prefix on h3 — gold caret, dimmer than heading */
.guide-article h3::before {
  content: '›';
  color: rgb(245 215 110 / 45%);
  font-size: 0.85em;
  font-weight: 400;
  flex-shrink: 0;
}

/* ── Minor headings (h4) — muted uppercase ── */
.guide-article h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-2);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── Body text ── */
.guide-article p {
  margin-bottom: var(--space-4);
  color: var(--text-primary);
  line-height: 1.75;
}

.guide-article ul,
.guide-article ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-5);
  color: var(--text-primary);
}

.guide-article li {
  margin-bottom: var(--space-2);
  line-height: 1.7;
}

/* Custom bullet dots */
.guide-article ul li::marker {
  color: var(--neon);
}

.guide-article ol li::marker {
  color: var(--text-3);
}

.guide-article strong {
  color: var(--text-1);
  font-weight: 600;
}

.guide-article em {
  color: var(--accent-cool);
  font-style: normal;
}

/* ── Inline code ── */
.guide-article code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--bg-overlay);
  color: var(--neon-soft);
  padding: 2px 7px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* ── Code blocks (fenced markdown) ── */
.guide-article pre {
  background: var(--bg-void);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
  overflow-x: auto;
  position: relative;
}

/* Top accent bar on code block */
.guide-article pre::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--neon) 0%, transparent 60%);
  opacity: 0.5;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.guide-article pre code {
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  color: var(--text-1);
  font-size: var(--text-sm);
  line-height: 1.65;
  white-space: pre;
}

/* ── Horizontal rule ── */
.guide-article hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-6) 0;
}

/* ── Blockquotes — styled as info callouts ── */
.guide-article blockquote {
  border-left: 3px solid var(--neon);
  background: rgb(94 213 255 / 5%);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  position: relative;
}

.guide-article blockquote::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--neon) 0%, rgb(94 213 255 / 40%) 100%);
  border-radius: 3px 0 0 3px;
}

.guide-article blockquote p {
  margin-bottom: 0;
  color: var(--text-2);
}

.guide-article blockquote p:not(:last-child) {
  margin-bottom: var(--space-2);
}

/* ── Callout boxes (special divs injected via build.mjs or markdown class) ── */
.guide-callout {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-sm);
  margin: var(--space-5) 0;
  border: 1px solid;
  position: relative;
}

.guide-callout--tip {
  background: rgb(104 211 145 / 7%);
  border-color: rgb(104 211 145 / 40%);
  color: var(--text-primary);
}

.guide-callout--tip::before {
  content: "MECHANIC";
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--success);
  margin-bottom: var(--space-2);
}

.guide-callout--info {
  background: rgb(94 213 255 / 6%);
  border-color: var(--edge-strong);
  color: var(--text-primary);
}

.guide-callout--info::before {
  content: "NOTE";
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--neon);
  margin-bottom: var(--space-2);
}

.guide-callout--warn {
  background: rgb(245 215 110 / 7%);
  border-color: rgb(245 215 110 / 40%);
  color: var(--text-primary);
}

.guide-callout--warn::before {
  content: "WARNING";
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: var(--space-2);
}

/* ── Page intro paragraph ── */
.guide-page-intro {
  font-size: var(--text-base);
  color: var(--text-2);
  margin-bottom: var(--space-6);
  line-height: 1.8;
}

/* ── Stat chips — resource-style inline data nuggets ──────────────────────
   Matches the game's stat-card / resource-pill look:
   --bg-overlay surface, monospace values, uppercase labels, neon/gold accents.
   Usage: <div class="guide-stat-row"><div class="guide-stat-chip">…</div></div>
   ──────────────────────────────────────────────────────────────────────────── */
.guide-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.guide-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

.guide-stat-chip__label {
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.guide-stat-chip__value {
  color: var(--neon);
  font-weight: 600;
}

.guide-stat-chip__value--gold {
  color: var(--gold);
}

.guide-stat-chip__value--danger {
  color: var(--danger);
}

/* =====================================================================
   7. Data table fallback (unused by current guide but kept as safety net)
   ===================================================================== */
.guide-table-wrap {
  overflow-x: auto;
  margin: var(--space-5) 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--bg-elevated);
}

.guide-table caption {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--border-subtle);
}

.guide-table th {
  background: var(--bg-overlay);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.guide-table td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: top;
}

.guide-table tbody tr:last-child td {
  border-bottom: none;
}

.guide-table tbody tr:hover td {
  background: rgb(94 213 255 / 3%);
}

.guide-table td.guide-table__num {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: right;
  color: var(--text-2);
}

.guide-table td.guide-table__name {
  font-weight: 600;
  color: var(--text-1);
}

.guide-table td.guide-table__desc {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* Badge utility */
.guide-badge {
  display: inline-block;
  font-size: var(--text-micro);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  background: rgb(94 213 255 / 12%);
  color: var(--neon);
  border: 1px solid rgb(94 213 255 / 25%);
}

.guide-badge--gold {
  background: rgb(245 215 110 / 12%);
  color: var(--gold);
  border-color: rgb(245 215 110 / 25%);
}

.guide-badge--success {
  background: rgb(104 211 145 / 12%);
  color: var(--success);
  border-color: rgb(104 211 145 / 25%);
}

/* =====================================================================
   8. Site footer
   ===================================================================== */
.guide-footer {
  background: rgb(10 14 26 / 90%);
  border-top: 1px solid var(--edge);
  padding: var(--space-4) var(--space-5);
}

.guide-footer__inner {
  max-width: calc(var(--guide-nav-width) + var(--guide-max-content) + var(--space-6) * 2);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.guide-footer__brand {
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--neon);
  text-shadow: 0 0 8px rgb(94 213 255 / 40%);
}

.guide-footer__links {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  flex-wrap: wrap;
}

.guide-footer__link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-xs);
  transition: color var(--transition-fast);
}

.guide-footer__link:hover {
  color: var(--neon);
  text-decoration: none;
}

/* =====================================================================
   9. Responsive — collapse sidebar on narrow screens
   ===================================================================== */
@media (max-width: 768px) {
  .guide-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    height: 100vh;
    width: 100%;
    max-width: 300px;
    border-right: 1px solid var(--edge-strong);
    box-shadow: 8px 0 32px rgb(0 0 0 / 60%);
    background: var(--bg-elevated);
  }

  .guide-nav--mobile-open {
    display: block;
  }

  .guide-nav__close {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .guide-nav__inner {
    padding-top: 56px;
  }

  .guide-header__mobile-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .guide-layout {
    flex-direction: column;
  }

  .guide-main {
    padding: var(--space-4);
  }

  .guide-article h1 {
    font-size: 24px;
  }

  .guide-article h2 {
    font-size: var(--text-lg);
  }
}

/* Mobile overlay backdrop — semi-transparent mask when nav is open */
.guide-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgb(3 7 15 / 70%);
  backdrop-filter: blur(2px);
}

.guide-nav-backdrop--visible {
  display: block;
}

/* =====================================================================
   10. Scrolled-header state (JS-driven via IntersectionObserver sentinel)
   ===================================================================== */
/* Applied by script.js when page scrolls past 8px */

/* =====================================================================
   11. Search widget
   ===================================================================== */
.guide-search {
  position: relative;
  flex: 1;
  max-width: 320px;
  margin: 0 var(--space-4);
}

.guide-search__label {
  /* visually hidden but accessible */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.guide-search__wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.guide-search__icon {
  position: absolute;
  left: 10px;
  color: var(--text-3);
  pointer-events: none;
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color var(--transition-fast);
}

.guide-search__input {
  width: 100%;
  background: rgb(10 22 40 / 60%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: 6px 32px 6px 32px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  -webkit-appearance: none;
}

.guide-search__input::placeholder {
  color: var(--text-3);
}

/* Remove the native search clear button so we control it */
.guide-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.guide-search__input:focus {
  border-color: var(--neon);
  box-shadow: 0 0 0 2px rgb(94 213 255 / 18%);
  background: rgb(10 22 40 / 80%);
}

.guide-search__input:focus + .guide-search__icon,
.guide-search__wrap:focus-within .guide-search__icon {
  color: var(--neon);
}

.guide-search__clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.guide-search__clear:hover {
  color: var(--text-primary);
}

/* Results dropdown */
.guide-search__results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgb(13 21 37 / 97%);
  border: 1px solid var(--edge-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgb(0 0 0 / 60%), var(--shadow-glow-soft);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 300;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.guide-search__results::-webkit-scrollbar {
  width: 4px;
}

.guide-search__results::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

.guide-search__result {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast);
  color: inherit;
}

.guide-search__result:last-child {
  border-bottom: none;
}

.guide-search__result:hover,
.guide-search__result[aria-selected="true"] {
  background: rgb(94 213 255 / 8%);
  text-decoration: none;
  color: inherit;
}

.guide-search__result[aria-selected="true"] {
  outline: 2px solid var(--neon);
  outline-offset: -2px;
}

.guide-search__result-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 2px;
}

.guide-search__result-heading {
  font-size: var(--text-xs);
  color: var(--neon);
  margin-bottom: 2px;
}

.guide-search__result-section {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-bottom: var(--space-2);
}

.guide-search__result-snippet {
  font-size: var(--text-xs);
  color: var(--text-2);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Highlighted match term in snippet */
.guide-search__match {
  color: var(--gold);
  font-weight: 600;
  background: rgb(245 215 110 / 12%);
  border-radius: 2px;
  padding: 0 2px;
}

/* "No results" empty state */
.guide-search__no-results {
  padding: var(--space-4);
  color: var(--text-3);
  font-size: var(--text-sm);
  text-align: center;
}

/* On small screens, search takes full width below the logo row */
@media (max-width: 640px) {
  .guide-search {
    order: 3;
    flex: 0 0 100%;
    max-width: none;
    margin: var(--space-2) 0 0;
  }

  .guide-header__inner {
    flex-wrap: wrap;
  }
}

/* =====================================================================
   12. Collapsible sidebar nav — section toggles + nested headings
   ===================================================================== */

/* Section toggle button — replaces the old static section-label span */
.guide-toc__section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-4) var(--space-4) var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--text-3);
  transition: color var(--transition-fast);
}

.guide-toc__section-toggle:not(:first-child) {
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-2);
}

.guide-toc__section-toggle:hover {
  color: var(--text-secondary);
}

.guide-toc__section-toggle--active {
  color: var(--neon);
}

/* Section label text */
.guide-toc__section-toggle .guide-toc__section-label {
  display: inline;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0;
}

/* Chevron indicator — rotates when section is open */
.guide-toc__chevron {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  margin-left: var(--space-2);
  transition: transform var(--transition-med);
  /* Draw a right-pointing caret via border trick */
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);  /* points right (collapsed) */
}

/* When aria-expanded="true", rotate chevron to point down */
.guide-toc__section-toggle[aria-expanded="true"] .guide-toc__chevron {
  transform: rotate(45deg);
}

/* Collapsible section page list */
.guide-toc__section-pages {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition-med);
}

.guide-toc__section-pages--open {
  max-height: 1200px; /* large enough for any section */
}

.guide-toc__page-item {
  margin: 0;
  list-style: none;
}

/* Nested on-page heading links (h2 / h3 sub-items under active page) */
.guide-toc__headings {
  list-style: none;
  padding: 0;
  margin: 0;
}

.guide-toc__heading-link {
  display: flex;
  align-items: center;
  padding: 4px var(--space-4) 4px calc(var(--space-4) + 14px);
  font-size: var(--text-xs);
  color: var(--text-3);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  line-height: 1.4;
}

.guide-toc__heading-link--h3 {
  padding-left: calc(var(--space-4) + 26px);
}

.guide-toc__heading-link:hover {
  color: var(--neon-soft);
  background: rgb(94 213 255 / 4%);
  border-left-color: rgb(94 213 255 / 30%);
  text-decoration: none;
}

/* Active on-page heading link (set by scroll observer in script.js) */
.guide-toc__heading-link--current {
  color: var(--neon-soft);
  border-left-color: var(--neon);
  background: rgb(94 213 255 / 6%);
}
