:root {
  --ink: #1f2a22;
  --muted: #54655a;
  --paper: #e6edda;
  --panel: #fbfcf5;
  --line: #cdd9c2;
  --blue: #2b7350;
  --teal: #0e7c8a;
  --clay: #a8543a;
  --indigo: #466f96;
  --green: #2f7d5b;
  --rose: #b0533f;
  --amber: #9a7d2e;
  --shadow: 0 16px 40px rgba(31, 42, 34, 0.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-wrap: break-word;
}
a { color: inherit; text-decoration: none; }

/* Visible keyboard focus across the page's many links/buttons/cards */
a:focus-visible,
.button:focus-visible,
.mission-card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: inherit;
}

/* =====================================================================
   Universal responsive hardening, inherited by every module via
   @import url("../styles.css"). Keeps content from overflowing on
   phones and makes wide media (canvas, code, math, tables) behave.
   ===================================================================== */
img, svg, video { max-width: 100%; height: auto; }
canvas { max-width: 100%; }
/* Long code / pre scroll horizontally instead of stretching the page */
pre, .code-block, .code-panel pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Wide KaTeX display equations scroll within their box on small screens */
.katex-display { overflow-x: auto; overflow-y: hidden; max-width: 100%; padding: 4px 0; }
.katex-display > .katex { white-space: nowrap; }
/* Any data tables become horizontally scrollable rather than overflowing */
table { display: block; width: 100%; max-width: 100%; overflow-x: auto; }
/* Media controls should never exceed their container */
input[type="range"] { max-width: 100%; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 247, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  color: white;
  background: var(--green);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 750;
}

.hero {
  display: grid;
  min-height: 680px;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  padding: clamp(48px, 7vw, 92px) clamp(18px, 4vw, 56px);
}

.hero h1 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(2.4rem, 6vw, 5.6rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.how h2,
.missions h2,
.cta h2 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.05;
}

.lead {
  max-width: 740px;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  line-height: 1.72;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 16px;
  background: white;
  font-weight: 850;
}

.button.primary {
  border-color: var(--blue);
  color: white;
  background: var(--blue);
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  padding: 28px clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

nav a { position: relative; transition: color 0.2s ease; }
nav a:hover { color: var(--ink); }
nav a.active { color: var(--blue); }
nav a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -6px;
  height: 2px;
  border-radius: 2px;
  background: var(--blue);
}
nav a.nav-cta {
  padding: 7px 14px;
  border-radius: 999px;
  color: white;
  background: var(--blue);
}

/* "Star on GitHub" button - links to the public showcase repo */
.star-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.star-btn:hover {
  border-color: var(--amber);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.star-btn .gh-mark { width: 17px; height: 17px; flex: none; }
.star-btn .star-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
/* In the footer the button sits on the lighter paper bg */
footer .star-btn { background: white; }
footer .copyright { flex-basis: 100%; margin-top: 4px; font-size: 0.8rem; opacity: 0.8; }
nav a.nav-cta:hover { color: white; filter: brightness(1.05); }
nav a.nav-cta.active::after { display: none; }

.hero-hint {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ---------- Hero extras ---------- */
.hero-stage {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel), #dce5cd);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-stage canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Section titles ---------- */
.section-title { max-width: 880px; margin-bottom: 30px; }
.section-title h2 { margin: 6px 0 12px; }

/* ---------- "How it works" ladder ---------- */
.how {
  padding: clamp(48px, 7vw, 86px) clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  background: #dce5cd;
}
.ladder {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rung;
}
.ladder li {
  position: relative;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 18px 18px;
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ladder li::before {
  counter-increment: rung;
  content: counter(rung);
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  font-weight: 900;
  color: white;
  background: var(--blue);
}
.ladder li::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--rose));
  opacity: 0.85;
}
.ladder li:nth-child(1)::before { background: var(--green); }
.ladder li:nth-child(2)::before { background: var(--blue); }
.ladder li:nth-child(3)::before { background: var(--amber); }
.ladder li:nth-child(4)::before { background: var(--rose); }
.ladder strong { font-size: 1.15rem; }
.ladder span { color: var(--muted); line-height: 1.6; }

/* ---------- Missions grid: each card is a clickable room ---------- */
.missions {
  padding: clamp(48px, 7vw, 86px) clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
}
.mission-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}
.mission-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent, var(--blue));
  border-radius: 10px;
  padding: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.mission-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 26px 60px rgba(23, 32, 43, 0.18);
}
.mission-card .num {
  align-self: flex-start;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent, var(--green));
  background: color-mix(in srgb, var(--accent, var(--green)) 14%, white);
}
.mission-card strong {
  margin-top: 6px;
  font-size: 1.5rem;
  color: var(--accent, var(--ink));
}
.mission-card .what { color: var(--ink); line-height: 1.55; font-weight: 650; }
.mission-card .learn { color: var(--muted); line-height: 1.55; font-size: 0.92rem; }
.mission-card .go {
  margin-top: auto;
  padding-top: 12px;
  font-weight: 850;
  color: var(--accent, var(--blue));
}

.inline-link {
  color: var(--blue);
  font-weight: 850;
  border-bottom: 2px solid color-mix(in srgb, var(--blue) 35%, transparent);
}
.inline-link:hover { border-bottom-color: var(--blue); }

/* ---------- Tracks (higher-level grouping) ---------- */
.track {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 36px);
  align-items: start;
  max-width: 1200px;
  margin: 0 auto 26px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.track.deep {
  border-color: color-mix(in srgb, var(--amber) 45%, var(--line));
  background: linear-gradient(180deg, #d6e0c6, var(--panel));
  box-shadow: var(--shadow);
}
.track-head { position: sticky; top: 80px; }
.track-tag {
  display: inline-block;
  margin-bottom: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rose);
  background: color-mix(in srgb, var(--rose) 12%, white);
}
.track.deep .track-tag { color: var(--amber); background: color-mix(in srgb, var(--amber) 16%, white); }
.track-head h3 { margin: 4px 0 8px; font-size: clamp(1.2rem, 2.4vw, 1.6rem); }
.track-head p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 0.95rem; }
.track-head p strong { color: var(--ink); }
.track .mission-map { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.track.deep .mission-card { border-top-width: 5px; }
.track.deep .mission-card .num { color: var(--amber); background: color-mix(in srgb, var(--amber) 16%, white); }

@media (max-width: 860px) {
  .track { grid-template-columns: 1fr; }
  .track-head { position: static; }
}

/* ---------- Closing CTA ---------- */
.cta {
  padding: clamp(56px, 8vw, 100px) clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, #dce6cd, var(--paper));
  text-align: center;
}
.cta .actions { justify-content: center; }

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

  .hero {
    min-height: auto;
  }

  .ladder {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .ladder { grid-template-columns: 1fr; }
  .topbar { padding: 12px 18px; gap: 10px; }
  nav { gap: 12px; font-size: 0.9rem; }
  .actions { width: 100%; }
  .actions .button { flex: 1 1 100%; }
  .hero-stage { border-radius: 12px; }
}

/* ---------- Reveal-on-scroll (cards + ladder rungs fade/slide in) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .mission-card:hover { transform: none; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
