/* Kāla Parīkṣā (/kp/) — Lean 3-Layer Swiss/Tufte White & Maroon Stylesheet
   Layer 1: 4x3 Zero-Scroll 100dvh Desktop Serpentine Map
   Layer 2: 1-to-1 Card Expansion Pages (/kp/step-1/ .. /kp/step-12/)
   Layer 3: Dedicated H0 Flagship Page (/kp/impossible-fiction/) */

:root {
  --canvas: #ffffff;
  --surface: #ffffff;
  --card-bg: #ffffff;
  --ink: #4a0c17;
  --ink-2: #5d1522;
  --mute: #7a3340;
  --blueprint: #6e1423;
  --blueprint-2: #8c2436;
  --blueprint-soft: rgba(35, 75, 130, 0.10);
  --bar-blue-1: #234b82;
  --bar-blue-2: #3867a6;
  --bar-teal: #1e6b52;
  --rule: rgba(74, 12, 23, 0.17);
  --rule-2: rgba(74, 12, 23, 0.32);
  --hi: rgba(35, 75, 130, 0.05);
  --accent: #8c192b;
  --on-accent: #ffffff;
  --fail: #a1232f;
  --fail-bg: rgba(161, 35, 47, 0.10);
  --pass: #1b693e;
  --pass-bg: rgba(27, 105, 62, 0.11);
  --gold: #df9b1b;
  --gold-soft: rgba(223, 155, 27, 0.17);
  --gold-ink: #825000;
  --f-sans: "Barlow", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --f-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --f-mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gut: clamp(16px, 2.4vw, 36px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.55 var(--f-sans);
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { text-decoration-color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main[tabindex="-1"]:focus, main[tabindex="-1"]:focus-visible { outline: none; }
::selection { background: var(--accent); color: var(--on-accent); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  display: inline-flex; align-items: center; min-height: 40px;
  padding: 0 14px; background: var(--ink); color: var(--canvas);
  font: 500 12.5px/1 var(--f-mono); text-decoration: none;
}
.skip:focus-visible { left: 12px; top: 12px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.vt-shell {
  flex: 1;
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 var(--gut) 32px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

main { flex: 1; min-width: 0; width: 100%; }

/* ---------- Persistent Always-Available Top Header & Footer ---------- */
.vt-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--canvas);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  padding: 12px 0 10px;
  margin-bottom: clamp(16px, 2.6dvh, 28px);
  border-bottom: 1px solid var(--ink);
}
.vt-brand {
  display: inline-flex; align-items: center; min-height: 36px;
  font: 600 13.5px/1 var(--f-mono); letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
}
.vt-bar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.vt-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; font: 400 12.5px/1 var(--f-mono); }
.vt-nav a { display: inline-flex; align-items: center; min-height: 36px; text-decoration: none; }
.vt-nav a:hover, .vt-nav a[aria-current="page"] {
  text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 5px;
}

.vt-contact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--gold-soft);
  color: var(--ink);
  font: 500 12.5px/1 var(--f-mono);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}
.vt-contact-btn:hover {
  background: var(--ink);
  color: var(--on-accent);
  text-decoration: none;
}

.vt-foot {
  margin-top: 36px;
  padding-top: 12px;
  border-top: 1px solid var(--ink);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 6px 20px;
  font: 400 12px/1.45 var(--f-mono); color: var(--mute);
}
.vt-foot p { margin: 0; }
.vt-foot nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.vt-foot a { color: var(--ink); text-decoration: none; }
.vt-foot a:hover { text-decoration: underline; }

/* ==========================================================================
   LAYER 1: 12-CARD ZERO-SCROLL 100dvh SERPENTINE HOMEPAGE
   ========================================================================== */
.sp-home {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.sp-header {
  padding-right: 0;
}
.sp-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
}
.sp-h1 {
  margin: 0;
  font: 700 clamp(20px, 2vw, 27px)/1.12 var(--f-sans);
  letter-spacing: -0.02em;
}
.sp-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.sp-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  background: var(--card-bg);
  font: 500 12px/1.2 var(--f-mono);
  text-decoration: none;
  white-space: nowrap;
}
.sp-pill:hover {
  border-color: var(--ink);
  text-decoration: none;
}
.sp-pill-gold {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--ink);
}
.sp-sub {
  margin: 2px 0 0;
  font: 400 clamp(11px, 0.9vw, 12.5px)/1.3 var(--f-mono);
  color: var(--mute);
}

.sp-stage {
  position: relative;
  width: 100%;
}
.sp-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.sp-track {
  fill: none;
  stroke: var(--mute);
  stroke-width: 1.4;
  stroke-dasharray: 4 4;
  opacity: 0.5;
}
.sp-turn-arrow {
  fill: none;
  stroke: var(--mute);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}

.sp-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.sp-step {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px 12px 9px;
  text-decoration: none;
  transition: border-color 0.14s var(--ease), transform 0.14s var(--ease);
  min-width: 0;
}
.sp-step:hover {
  border-color: var(--ink);
  text-decoration: none;
}

.sp-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}
.sp-num {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--canvas);
  font: 600 11px/1 var(--f-mono);
}
.sp-title {
  margin: 0;
  font: 600 13.8px/1.18 var(--f-sans);
  letter-spacing: -0.01em;
}

.sp-bar-wrap {
  width: 100%;
  height: 25px;
  margin-bottom: 5px;
  flex: none;
}
.sp-bar-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* SVG bar fills and typography (Ultramarine Blue + Sovereign Gold + Emerald Green + Crimson on Pure White) */
.mb-seg-1 { fill: var(--bar-blue-1); }
.mb-seg-2 { fill: var(--bar-blue-2); }
.mb-seg-3 { fill: var(--bar-teal); }
.mb-gold { fill: var(--gold); }
.mb-gold-soft { fill: var(--gold-soft); stroke: var(--gold); stroke-width: 0.9; }
.mb-cut { fill: var(--hi); stroke: var(--rule-2); stroke-width: 0.8; }
.mb-cut-2 { fill: var(--blueprint-soft); stroke: rgba(35, 75, 130, 0.32); stroke-width: 0.8; }
.mb-cut-3 { fill: var(--hi); stroke: var(--rule); stroke-width: 0.8; }
.mb-pass-box { fill: var(--pass-bg); stroke: var(--pass); stroke-width: 0.9; }
.mb-fail-box { fill: var(--fail-bg); stroke: var(--fail); stroke-width: 0.85; }
.mb-axis { stroke: var(--rule-2); stroke-width: 1; }
.mb-axis-strong { stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 3 2; }
.mb-tx-inv { font: 500 10.2px/1 var(--f-mono); fill: #ffffff; }
.mb-tx-dark { font: 600 10.2px/1 var(--f-mono); fill: #231100; }
.mb-tx-ink { font: 600 10px/1 var(--f-mono); fill: var(--ink); }
.mb-tx-sm { font: 500 9.8px/1 var(--f-mono); fill: var(--mute); }
.mb-tx-gold { font: 600 10.5px/1 var(--f-mono); fill: var(--gold-ink); }
.mb-tx-pass { font: 600 9.8px/1 var(--f-mono); fill: var(--pass); }
.mb-tx-fail { font: 500 9.8px/1 var(--f-mono); fill: var(--fail); }

.sp-bullets {
  margin: 0;
  padding: 0 0 0 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font: 400 12.2px/1.32 var(--f-sans);
  color: var(--ink-2);
  flex: 1;
}
.sp-bullets li {
  margin: 0;
}

.sp-cta {
  margin-top: 5px;
  font: 500 11px/1.15 var(--f-mono);
  color: var(--blueprint);
}
.sp-step:hover .sp-cta {
  color: var(--accent);
  text-decoration: underline;
}

.sp-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 9px;
  font: 400 11.2px/1.25 var(--f-mono);
  color: var(--mute);
  border-top: 1px solid var(--rule);
  padding-top: 5px;
}
.sp-foot a { text-decoration: none; color: var(--ink-2); }
.sp-foot a:hover { text-decoration: underline; color: var(--accent); }
.sp-dot { opacity: 0.55; }

/* Tablet 2-column intermediate grid */
@media (min-width: 680px) and (max-width: 1023px) {
  .sp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Desktop Strict Zero-Scroll 100dvh Viewport Lock (>= 1024px) */
@media (min-width: 1024px) and (min-height: 680px) {
  html:has(.sp-home),
  body:has(.sp-home) {
    height: 100dvh;
    overflow: hidden;
  }
  :root:has(.sp-home) .vt-shell {
    height: 100dvh;
    max-width: 1960px;
    padding: clamp(5px, 0.8dvh, 12px) clamp(14px, 1.6vw, 30px) clamp(5px, 0.8dvh, 11px);
    overflow: hidden;
  }
  :root:has(.sp-home) .vt-bar {
    position: static;
    padding: 0 0 clamp(4px, 0.6dvh, 8px);
    margin-bottom: clamp(4px, 0.65dvh, 9px);
  }
  :root:has(.sp-home) .vt-brand,
  :root:has(.sp-home) .vt-nav a {
    min-height: clamp(24px, 3dvh, 32px);
    font-size: clamp(12px, min(0.95vw, 1.55dvh), 15px);
  }
  :root:has(.sp-home) .vt-contact-btn {
    min-height: clamp(24px, 2.9dvh, 30px);
    padding: 0 12px;
    font-size: clamp(11.8px, min(0.92vw, 1.5dvh), 14.5px);
  }
  :root:has(.sp-home) main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .sp-home {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: clamp(4px, 0.68dvh, 9px);
  }
  .sp-h1 {
    font-size: clamp(17.5px, min(1.58vw, 2.55dvh), 26px);
  }
  .sp-sub {
    margin-top: 0;
    font-size: clamp(11px, min(0.86vw, 1.42dvh), 14px);
  }
  .sp-stage {
    min-height: 0;
    padding: 0 22px;
    display: flex;
    flex-direction: column;
  }
  .sp-grid {
    flex: 1;
    min-height: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: clamp(5px, 0.8dvh, 11px) clamp(8px, 0.85vw, 14px);
  }
  /* Serpentine placement: Row 1 L->R (1..4), Row 2 R->L (5..8), Row 3 L->R (9..12) */
  .sp-step-1  { grid-column: 1; grid-row: 1; }
  .sp-step-2  { grid-column: 2; grid-row: 1; }
  .sp-step-3  { grid-column: 3; grid-row: 1; }
  .sp-step-4  { grid-column: 4; grid-row: 1; }
  .sp-step-5  { grid-column: 4; grid-row: 2; }
  .sp-step-6  { grid-column: 3; grid-row: 2; }
  .sp-step-7  { grid-column: 2; grid-row: 2; }
  .sp-step-8  { grid-column: 1; grid-row: 2; }
  .sp-step-9  { grid-column: 1; grid-row: 3; }
  .sp-step-10 { grid-column: 2; grid-row: 3; }
  .sp-step-11 { grid-column: 3; grid-row: 3; }
  .sp-step-12 { grid-column: 4; grid-row: 3; }

  .sp-step {
    min-height: 0;
    padding: clamp(5px, 0.8dvh, 11px) clamp(8px, 0.85vw, 14px);
  }
  .sp-head {
    gap: 7px;
    margin-bottom: clamp(2.5px, 0.45dvh, 5px);
    flex: none;
  }
  .sp-num {
    width: clamp(18px, 2.2dvh, 24px);
    height: clamp(18px, 2.2dvh, 24px);
    font-size: clamp(10px, 1.25dvh, 12.5px);
  }
  .sp-title {
    font-size: clamp(11.8px, min(0.98vw, 1.66dvh), 16.5px);
    line-height: 1.15;
  }
  .sp-bar-wrap {
    height: clamp(18px, 2.5dvh, 27px);
    margin-bottom: clamp(2.5px, 0.48dvh, 6px);
    flex: none;
  }
  .sp-bullets {
    padding-left: 15px;
    font-size: clamp(10.6px, min(0.86vw, 1.38dvh), 14.8px);
    line-height: 1.25;
    gap: clamp(1.5px, 0.34dvh, 4.5px);
    flex: 1 0 auto;
  }
  .sp-cta {
    flex: none;
    margin-top: auto;
    padding-top: clamp(4px, 0.6dvh, 8px);
    font-size: clamp(10.2px, min(0.82vw, 1.3dvh), 13px);
  }
  .sp-foot {
    padding-top: 4px;
    font-size: clamp(10.8px, min(0.88vw, 1.38dvh), 13.5px);
  }
}

/* ==========================================================================
   LAYER 2 & LAYER 3: STEP EXPANSIONS & IMPOSSIBLE FICTION FLAGSHIP PAGE
   ========================================================================== */
.kicker {
  margin: 0 0 8px;
  font: 500 11.5px/1.35 var(--f-mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--mute);
}
.st-page {
  max-width: 1220px;
  margin: 0 auto;
}
.st-hero {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ink);
}
.st-h1 {
  margin: 0 0 12px;
  font: 600 clamp(24px, 3vw, 36px)/1.14 var(--f-serif);
  letter-spacing: -0.01em;
}
.st-hero-bar {
  max-width: 480px;
  height: 32px;
  margin: 0 0 12px;
}
.st-hero-bullets {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  font: 400 16px/1.5 var(--f-sans);
  max-width: 78ch;
}
.st-sec {
  margin-top: 28px;
}
.st-h2 {
  margin: 0 0 10px;
  font: 600 20px/1.24 var(--f-sans);
  letter-spacing: -0.01em;
}
.st-h3-sec {
  margin: 0 0 4px;
  font: 600 17px/1.28 var(--f-sans);
}
.st-sub {
  margin: 0 0 10px;
  font-size: 14.5px;
  color: var(--mute);
}
.st-list {
  margin: 0 0 18px;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  max-width: 86ch;
}
.st-qa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.st-qa-card {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 15px 18px;
}
.st-h3 {
  margin: 0 0 6px;
  font: 600 15px/1.3 var(--f-sans);
}
.st-qa-card p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.52;
  color: var(--ink-2);
}

/* Tables — Crisp Swiss/Tufte Alignment & Balanced Column Gutters */
.tbl-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 14px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.48;
}
caption {
  text-align: left;
  font: 500 11.5px/1.4 var(--f-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mute);
  margin-bottom: 8px;
}
th, td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
th:first-child, td:first-child {
  padding-left: 12px;
}
th:last-child, td:last-child {
  padding-right: 12px;
}
thead th {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font: 500 11.5px/1.35 var(--f-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mute);
  padding-top: 10px;
  padding-bottom: 10px;
}
tbody th[scope="row"] {
  font-weight: 600;
  min-width: 152px;
}
th.r, td.r {
  text-align: right;
  white-space: nowrap;
}
th.r + th:not(.r), td.r + td:not(.r) {
  padding-left: 26px;
}
.mono {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.st-skt {
  font: 400 14.5px/1.48 var(--f-serif);
  min-width: 210px;
}
tr.is-win > th, tr.is-win > td {
  background: var(--gold-soft);
}

/* Impossible Fiction stat strip */
.imp-stats {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px 18px;
}
.imp-stats dt {
  font: 400 11px/1.3 var(--f-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mute);
}
.imp-stats dd {
  margin: 3px 0 0;
  font: 600 17px/1.25 var(--f-mono);
}

/* Replication box & Pager */
.st-rep-box {
  background: var(--card-bg);
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  padding: 16px 18px;
}
.st-rep-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}
.st-code {
  margin: 0;
  padding: 10px 12px;
  background: var(--hi);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font: 500 13px/1.4 var(--f-mono);
  overflow-x: auto;
}
.st-jump-wrap {
  margin-top: 14px;
}

.st-pager {
  margin-top: 32px;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.st-nav-btn, .st-nav-map {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  background: var(--card-bg);
  font: 500 12.5px/1.25 var(--f-mono);
  text-decoration: none;
}
.st-nav-btn:hover, .st-nav-map:hover {
  border-color: var(--ink);
  text-decoration: none;
}
.st-nav-map {
  background: var(--hi);
}

@media (max-width: 680px) {
  .sp-title-row { flex-direction: column; align-items: flex-start; }
  .st-pager { flex-direction: column; align-items: stretch; }
  .st-nav-btn, .st-nav-map { justify-content: center; text-align: center; }
  th, td { padding: 9px 10px; font-size: 13px; }
  th.r + th:not(.r), td.r + td:not(.r) { padding-left: 14px; }
  tbody th[scope="row"] { min-width: 118px; }
  .st-skt { min-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  :root {
    --canvas: #ffffff; --card-bg: #ffffff; --ink: #000000; --ink-2: #111111; --mute: #444444;
    --rule: #bbbbbb; --rule-2: #888888; --gold-soft: #f2f2f2;
    color-scheme: light;
  }
  html:has(.sp-home), body:has(.sp-home), :root:has(.sp-home) .vt-shell, :root:has(.sp-home) main {
    height: auto !important;
    overflow: visible !important;
  }
  .skip { display: none !important; }
}
