/* Faction guide pages. Palette and type mirror the main Adjutant UI (index.html). */
:root {
  --bg-0: #07090f;
  --bg-1: #0a1220;
  --bg-2: #121a2b;
  --surface: #111b2e;
  --surface-2: #17243a;
  --line: #314563;
  --line-soft: #233650;
  --text: #d4deed;
  --muted: #93a8c4;
  --accent: #66b6ff;
  --accent-2: #45f2ff;
  --terran: #7db4ff;
  --protoss: #f1bf59;
  --zerg: #f76db2;
  --green: #46d48a;
  --yellow: #f1bf59;
  --red: #ff626b;
  --faction: var(--accent);
  --faction-rgb: 102, 182, 255;
  --header-h: 58px;
}
.faction-terran { --faction: var(--terran); --faction-rgb: 125, 180, 255; }
.faction-zerg { --faction: var(--zerg); --faction-rgb: 247, 109, 178; }
.faction-protoss { --faction: var(--protoss); --faction-rgb: 241, 191, 89; }
.faction-skirmish { --faction: var(--green); --faction-rgb: 70, 212, 138; }

*, *::before, *::after { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--header-h) + 16px); }
/* Enabled by guides.js after the initial #hash jump, which smooth scrolling can interrupt. */
@media (prefers-reduced-motion: no-preference) { html.smooth-scroll { scroll-behavior: smooth; } }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  font-size: 1.08rem;
  line-height: 1.55;
  background:
    radial-gradient(circle at 18% 10%, rgba(var(--faction-rgb), .12), transparent 38%),
    radial-gradient(circle at 84% 24%, rgba(77, 245, 255, .07), transparent 34%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 52%, var(--bg-2));
  background-attachment: fixed;
}

a { color: var(--accent); }
a:hover { color: var(--accent-2); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11, 20, 35, .95), rgba(9, 16, 29, .9));
  backdrop-filter: blur(7px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}
.brand {
  color: var(--terran);
  font-family: 'Orbitron', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  text-shadow: 0 0 14px rgba(102, 182, 255, .3);
  white-space: nowrap;
}
.brand:hover { color: var(--accent-2); }
.badge {
  font-family: 'Orbitron', sans-serif;
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--protoss);
  border: 1px solid rgba(241, 191, 89, .45);
  background: rgba(241, 191, 89, .12);
}
.badge:hover { color: var(--protoss); background: rgba(241, 191, 89, .22); }
.faction-switch { margin-left: auto; display: inline-flex; gap: 6px; }
.faction-link {
  font-family: 'Orbitron', sans-serif;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(17, 27, 46, .7);
  transition: border-color .15s, color .15s, background .15s;
}
.faction-link:hover, .faction-link.active {
  color: var(--faction);
  border-color: rgba(var(--faction-rgb), .7);
  background: rgba(var(--faction-rgb), .12);
}

/* ---------- Layout ---------- */
.guide-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 36px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}
.guide-main { min-width: 0; max-width: 860px; }

/* ---------- Table of contents ---------- */
.toc {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
  padding: 14px 10px 14px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.toc-toggle { display: none; }
.toc-list, .toc-sub { list-style: none; margin: 0; padding: 0; }
.toc-list > li > a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  color: var(--muted);
  font-weight: 600;
  font-size: .98rem;
  line-height: 1.25;
  text-decoration: none;
}
.toc-list > li > a:hover { color: var(--text); background: rgba(var(--faction-rgb), .06); }
.toc-list > li.active > a {
  color: var(--faction);
  border-left-color: var(--faction);
  background: rgba(var(--faction-rgb), .1);
}
.toc-num {
  flex: 0 0 auto;
  min-width: 1.5em;
  font-family: 'Orbitron', sans-serif;
  font-size: .64rem;
  color: rgba(var(--faction-rgb), .75);
}
.toc-sub { display: none; margin: 2px 0 6px 30px; border-left: 1px solid var(--line-soft); }
.toc-list > li.active > .toc-sub { display: block; }
.toc-sub a {
  display: block;
  padding: 3px 10px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.25;
  text-decoration: none;
}
.toc-sub a:hover { color: var(--text); }
.toc-sub a.active { color: var(--faction); }

/* ---------- Hero ---------- */
.hero { padding: 6px 0 22px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.eyebrow {
  margin: 0 0 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faction);
}
.hero h1 {
  margin: 0 0 8px;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.45rem, 3.2vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: .02em;
  color: #fff;
  text-shadow: 0 0 22px rgba(var(--faction-rgb), .35);
}
.subtitle { margin: 0 0 12px; color: var(--faction); font-weight: 700; font-size: 1.05rem; }
.intro { margin: 0; color: var(--muted); font-size: 1rem; }

/* ---------- Body typography ---------- */
.guide-section { padding-top: 10px; }
.guide-body h2, .guide-body h3, .guide-body h4 { position: relative; line-height: 1.25; }
.guide-body h2 {
  margin: 44px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(var(--faction-rgb), .4);
  font-family: 'Orbitron', sans-serif;
  font-size: 1.3rem;
  letter-spacing: .03em;
  color: var(--faction);
}
.guide-body h3 {
  margin: 30px 0 10px;
  font-size: 1.32rem;
  font-weight: 700;
  color: #fff;
}
.guide-body h4 {
  margin: 22px 0 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-2);
}
.anchor {
  position: absolute;
  left: -1.1em;
  padding-right: .3em;
  color: var(--line);
  text-decoration: none;
  opacity: 0;
  transition: opacity .15s;
}
h2:hover > .anchor, h3:hover > .anchor, h4:hover > .anchor, .anchor:focus { opacity: 1; }
.anchor:hover { color: var(--faction); }

.guide-body p { margin: 0 0 12px; }
.guide-body strong { color: #fff; font-weight: 700; }
.guide-body em { color: #e6edf8; }
.guide-body ul, .guide-body ol { margin: 0 0 14px; padding-left: 1.5em; }
.guide-body li { margin: 4px 0; }
.guide-body li > ul, .guide-body li > ol { margin: 4px 0 6px; }
.guide-body li::marker { color: rgba(var(--faction-rgb), .8); font-weight: 700; }
.guide-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: .9em;
}

.ability-src { color: var(--muted); font-size: .92em; }

/* Combo blocks */
.combo-label {
  display: inline-block;
  margin-right: 4px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: .8em;
  letter-spacing: .06em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.guide-body .combo-needs { color: var(--accent); background: rgba(102, 182, 255, .14); }
.guide-body .combo-do-it { color: var(--green); background: rgba(70, 212, 138, .14); }
.guide-body .combo-payoff { color: var(--yellow); background: rgba(241, 191, 89, .14); }
.guide-body .combo-watch-for { color: var(--red); background: rgba(255, 98, 107, .14); }

/* Tables */
.table-wrap {
  margin: 12px 0 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 27, 46, .65);
}
.guide-body table { width: 100%; border-collapse: collapse; font-size: .98rem; }
.guide-body th, .guide-body td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}
.guide-body th {
  background: var(--surface-2);
  color: var(--faction);
  font-family: 'Orbitron', sans-serif;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.guide-body tr:last-child td { border-bottom: none; }
.guide-body tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .02); }

/* Unit cards */
.unit-card { margin: 10px 0 18px; }
.unit-card a { display: block; width: min(100%, 420px); }
.unit-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
  transition: transform .18s, border-color .18s;
}
/* Mission and deployment cards (13.2 / 13.3): wide maps, tall mission text cards. */
.scenario-deployment a { width: min(100%, 600px); }
.scenario-mission a { width: min(100%, 340px); }
.unit-card a:hover img { transform: translateY(-2px); border-color: rgba(var(--faction-rgb), .7); }

/* Footer */
.guide-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
}
.back-top { text-decoration: none; font-weight: 700; }

/* ---------- Index page ---------- */
.index-main { max-width: 1040px; margin: 0 auto; padding: 32px 24px 60px; }
.guide-index .hero h1 { text-shadow: 0 0 22px rgba(102, 182, 255, .35); }
.guide-index .eyebrow { color: var(--accent); }
.guide-index .intro { max-width: 70ch; }
.guide-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 26px 0 40px;
}
.guide-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid rgba(var(--faction-rgb), .45);
  border-radius: 12px;
  background:
    radial-gradient(circle at 100% 0%, rgba(var(--faction-rgb), .18), transparent 60%),
    rgba(17, 27, 46, .8);
  color: var(--text);
  text-decoration: none;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.guide-card:hover {
  color: var(--text);
  transform: translateY(-3px);
  border-color: var(--faction);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .4), 0 0 24px rgba(var(--faction-rgb), .15);
}
.guide-card-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faction);
}
.guide-card-blurb { flex: 1; color: var(--muted); }
.guide-card-cta { font-weight: 700; color: var(--faction); }
.index-sections h2 {
  margin: 0 0 4px;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.05rem;
  letter-spacing: .05em;
  color: #fff;
}
.muted { color: var(--muted); margin: 0 0 14px; }
.section-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 24px;
}
.section-grid li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
}
.section-grid .toc-num { color: var(--accent); }
.jump { margin-left: auto; display: inline-flex; gap: 4px; }
.jump a {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(var(--faction-rgb), .45);
  background: rgba(var(--faction-rgb), .1);
  color: var(--faction);
  font-family: 'Orbitron', sans-serif;
  font-size: .66rem;
  text-decoration: none;
}
.jump a:hover { color: var(--faction); background: rgba(var(--faction-rgb), .25); }

.skirmish-callout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: -16px 0 36px;
  padding: 14px 18px;
  border: 1px solid rgba(70, 212, 138, .45);
  border-radius: 12px;
  background: rgba(70, 212, 138, .07);
  color: var(--text);
  text-decoration: none;
}
.skirmish-callout:hover { color: var(--text); border-color: var(--green); background: rgba(70, 212, 138, .12); }
.skirmish-callout-title { font-family: 'Orbitron', sans-serif; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--green); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .guide-layout { display: block; padding: 0 16px 48px; }
  .toc {
    position: sticky;
    top: var(--header-h);
    z-index: 20;
    max-height: none;
    overflow: visible;
    margin: 0 -16px 18px;
    padding: 0;
    background: rgba(9, 16, 29, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(7px);
  }
  .toc-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 16px;
    border: 0;
    background: none;
    color: var(--faction);
    font-family: 'Orbitron', sans-serif;
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    cursor: pointer;
  }
  .toc-toggle::after { content: '▾'; font-size: 1rem; transition: transform .15s; }
  .toc-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
  .toc-current { color: var(--text); font-family: 'Rajdhani', sans-serif; font-size: .95rem; letter-spacing: 0; text-transform: none; margin-left: 10px; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toc-list {
    display: none;
    max-height: calc(100vh - var(--header-h) - 60px);
    overflow-y: auto;
    padding: 0 8px 12px;
  }
  .toc.open .toc-list { display: block; }
  .toc-sub, .toc-list > li.active > .toc-sub { display: none; }
  html { scroll-padding-top: calc(var(--header-h) + 56px); }
  .hero { padding-top: 4px; }
  .guide-cards { grid-template-columns: 1fr; }
  .section-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --header-h: 92px; }
  .site-header { flex-wrap: wrap; padding: 10px 16px; gap: 8px 10px; }
  .brand { font-size: .9rem; }
  .brand-long { display: none; }
  .faction-switch { margin-left: 0; width: 100%; }
  .faction-link { flex: 1; text-align: center; padding: 6px 4px; }
  .index-main { padding: 22px 16px 48px; }
  .guide-body h2 { font-size: 1.08rem; }
  .guide-body h3 { font-size: 1.18rem; }
  .guide-body ul, .guide-body ol { padding-left: 1.25em; }
  .guide-body th, .guide-body td { padding: 7px 9px; }
  .anchor { display: none; }
}

@media print {
  .site-header, .toc, .guide-footer .back-top { display: none; }
  body { background: #fff; color: #111; }
  .guide-layout { display: block; padding: 0; }
  .guide-body h2, .hero h1, .subtitle, .eyebrow { color: #111; text-shadow: none; }
  .guide-body strong, .guide-body h3 { color: #000; }
  .table-wrap { background: none; border-color: #ccc; }
  .guide-body th { background: #eee; color: #000; }
  .unit-card img { max-width: 70%; box-shadow: none; }
  .guide-section h2, .guide-section h3 { break-after: avoid; }
}

/* ---------- Clickable terms and their popup ---------- */
button.kw {
  font: inherit;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent-2);
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  border-bottom: 1px solid rgba(69, 242, 255, .35);
  cursor: pointer;
  text-align: inherit;
}
button.kw:hover, button.kw:focus-visible { color: #fff; border-bottom-color: var(--accent-2); outline: none; }
button.kw:focus-visible { box-shadow: 0 0 0 2px rgba(69, 242, 255, .4); border-radius: 2px; }
button.kw-plain { font-weight: inherit; color: #b9e9f5; border-bottom-style: dotted; }

.kw-pop {
  position: absolute;
  z-index: 50;
  width: min(440px, calc(100% - 24px));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(var(--faction-rgb), .6);
  border-radius: 12px;
  background: linear-gradient(180deg, #13203a, #0d1729);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .3);
  font-size: 1rem;
  line-height: 1.5;
}
.kw-pop[hidden] { display: none; }
.kw-pop.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: auto;
  max-height: 72vh;
  border-radius: 14px 14px 0 0;
  border-bottom: 0;
}
.kw-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.kw-head h3 {
  flex: 1;
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: .86rem;
  letter-spacing: .06em;
  color: var(--faction);
}
.kw-close, .kw-back {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(17, 27, 46, .9);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.kw-close:hover, .kw-back:hover { border-color: var(--faction); color: var(--faction); }
.kw-body { padding: 12px 16px 16px; overflow-y: auto; }
.kw-source { margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.kw-kind {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(var(--faction-rgb), .14);
  color: var(--faction);
  font-size: .78em;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.kw-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.kw-chip {
  display: inline-flex;
  align-items: center;
  gap: .25em;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(19, 31, 50, .6);
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.3;
}
/* Same colours as the Player Aid phase and activation chips (index.html). */
.kw-chip.phase-any { color: var(--text); background: rgba(63, 79, 99, .85); border-color: rgba(143, 155, 168, .55); }
.kw-chip.phase-movement { color: #f5fbff; background: rgba(31, 95, 158, .92); border-color: rgba(125, 180, 255, .62); }
.kw-chip.phase-assault { color: #fff7f8; background: rgba(163, 56, 70, .92); border-color: rgba(232, 143, 156, .58); }
.kw-chip.phase-combat { color: #1a1407; background: rgba(212, 169, 79, .95); border-color: rgba(255, 224, 156, .62); }
.kw-chip.phase-scoring { color: #f4fff8; background: rgba(26, 122, 64, .92); border-color: rgba(128, 217, 163, .56); }
.kw-chip.phase-cleanup { color: #faf7ff; background: rgba(122, 88, 199, .92); border-color: rgba(198, 173, 255, .6); }
.kw-chip.activation-active { color: #fffbea; background: rgba(166, 139, 67, .82); border-color: rgba(214, 191, 120, .5); }
.kw-chip.activation-passive { color: #edf1f6; background: rgba(93, 103, 118, .78); border-color: rgba(146, 156, 170, .48); }
.kw-chip.activation-reaction { color: #f7f2ff; background: rgba(100, 83, 143, .82); border-color: rgba(160, 144, 198, .52); }
.kw-chip.activation-generic { color: #f1eef8; background: rgba(88, 83, 112, .8); border-color: rgba(150, 144, 173, .46); }
.kw-chip.kw-gas { color: #b8f5d2; border-color: rgba(70, 212, 138, .45); background: rgba(70, 212, 138, .1); }
.kw-chip.kw-slots, .kw-chip.kw-unique { color: var(--muted); }
.kw-card-ability + .kw-card-ability { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.kw-card-ability-name { margin: 0 0 6px; }
.kw-chip.kw-resource { color: var(--text); background: rgba(32, 48, 74, .88); border-color: rgba(125, 180, 255, .4); }
/* Paid upgrade, styled like .upg-pill on roster cards. */
.kw-chip.kw-upgrade { color: var(--green); background: rgba(70, 212, 138, .08); border-color: rgba(70, 212, 138, .44); }
.kw-chip.kw-upgrade strong { color: var(--yellow); }
.resource-icon { display: inline-flex; align-items: center; min-width: .94em; line-height: 1; font-weight: 700; }
.resource-faction-terran { color: var(--terran); }
.resource-faction-zerg { color: var(--zerg); font-size: 1.16em; }
.resource-faction-protoss { color: var(--protoss); }
.kw-text p { margin: 0 0 8px; }
.kw-text p:last-child { margin-bottom: 0; }
.kw-text b, .kw-text strong { color: #fff; }
.kw-text h5 { margin: 10px 0 4px; font-size: .95rem; color: var(--accent-2); }
.kw-stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.kw-stat {
  display: inline-flex;
  flex-direction: column;
  min-width: 52px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(17, 27, 46, .8);
  font-weight: 700;
  text-align: center;
}
.kw-stat span { font-family: 'Orbitron', sans-serif; font-size: .58rem; letter-spacing: .06em; color: var(--muted); }
.kw-more { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.kw-more summary { cursor: pointer; color: var(--muted); font-size: .92rem; font-weight: 600; }
.kw-more[open] summary { margin-bottom: 8px; }
.kw-more hr { border: 0; border-top: 1px solid var(--line-soft); margin: 10px 0; }
.kw-see { margin: 12px 0 0; padding-top: 8px; border-top: 1px solid var(--line-soft); color: var(--muted); }
@media print { .kw-pop { display: none !important; } button.kw { color: inherit; border: 0; } }
