/* Kernudgeon landing page — tokens ported from the app's ThemeColors.
   Dark "blueprint" is the default; light "parchment" via data-theme or OS setting. */

@font-face {
  font-family: "Rulebook";
  src: url("fonts/Rulebook-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Fieldstone";
  src: url("fonts/Fieldstone-Regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Fieldstone";
  src: url("fonts/Fieldstone-Medium.otf") format("opentype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Fieldstone";
  src: url("fonts/Fieldstone-Bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --canvas: #1c1915;
  --canvas-lift: #2a2318;   /* warm top-glow for the background gradient */
  --canvas-deep: #100d09;   /* darker floor — bottom goes deeper than the top */
  --surface: #252019;
  --surface-raised: #2f2a20; /* card hover fill */
  --ink: #eae4d6;
  --ink-muted: #9c9483;
  --line: #b89a52;
  --line-muted: #6b5e3c;
  --accent: #c2402c;
  --accent-text: #db6a52;
  --accent-cool: #7c93a6;
  --card-title: #eae4d6;       /* mapping-card titles — bone on dark */
  --numeral: #b89a52;          /* step ordinals — needs its own light override */

  /* The CTA fill is the darker oxblood in both themes so its text passes AA. */
  --button-bg: #b23a26;
  --button-bg-hover: #9a3520;
  --button-ink: #f3ede1;

  --rulebook: "Rulebook", "Iowan Old Style", Georgia, serif;
  --fieldstone: "Fieldstone", -apple-system, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="light"] {
  color-scheme: light;

  --canvas: #eae2d0;
  --canvas-lift: #f4eede;
  --canvas-deep: #d3c7ac;
  --surface: #f3eddf;
  --surface-raised: #faf6ec;
  --ink: #2a241b;
  --ink-muted: #5e5546;
  --line: #9a7e3a;
  --line-muted: #c3b488;
  --accent: #b23a26;
  --accent-text: #9a3520;
  --accent-cool: #4e6678;
  --card-title: #4e6678;
  --numeral: #7d6527;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background-color: var(--canvas);
  /* Warm top glow easing down to a deeper floor at the base. */
  background-image:
    radial-gradient(120% 60% at 50% -5%, var(--canvas-lift), transparent 55%),
    linear-gradient(180deg, var(--canvas) 0%, var(--canvas) 40%, var(--canvas-deep) 100%);
  color: var(--ink);
  font-family: var(--fieldstone);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Film grain — self-contained SVG noise, sits above the gradient, below content. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="light"] body::before { opacity: 0.03; }

/* Keep real content above the grain layer. */
body > * { position: relative; z-index: 1; }

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  text-align: center;
  padding: 40px 32px 8px;
}

#theme-toggle {
  position: absolute;
  top: 0;
  right: 12px;
  background: none;
  border: none;
  color: var(--line);
  cursor: pointer;
  padding: 12px;
  display: grid;
  place-items: center;
}
#theme-toggle svg { width: 18px; height: 18px; }
#theme-toggle .sun { display: none; }
[data-theme="light"] #theme-toggle .sun { display: block; }
[data-theme="light"] #theme-toggle .moon { display: none; }

/* Icon + wordmark read as one lockup, the icon set beside the name rather than
   stacked above it. The wordmark centers against the icon's 96px height. */
.wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 22px 0;
}

.hero h1 {
  font-family: var(--rulebook);
  font-weight: 400;
  font-size: clamp(3.25rem, 8vw, 4.75rem);
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.hero .tagline {
  margin-top: 14px;
  font-size: clamp(1.125rem, 2.5vw, 1.3125rem);
  color: var(--ink);
}

.app-icon {
  display: block;
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.45));
}
[data-theme="light"] .app-icon {
  filter: drop-shadow(0 10px 20px rgba(42, 36, 27, 0.25));
}

.cta {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.button {
  display: inline-block;
  background: var(--button-bg);
  color: var(--button-ink);
  font-family: var(--fieldstone);
  font-weight: 700;
  font-size: 1.1875rem;
  text-decoration: none;
  padding: 15px 48px;
  border-radius: 999px;   /* full pill */
  transition: background-color 120ms ease, transform 120ms ease;
}
.button:hover, .button:focus-visible { background: var(--button-bg-hover); }
.button:active { transform: translateY(1px); }

/* Faux app window — the actual app, rebuilt in the page: Setup / Map / Tune / Info. */
.app-window {
  margin: 44px auto 0;
  max-width: 960px;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 30px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-muted);
}
.tab {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--fieldstone);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 4px 2px;
  position: relative;
  transition: color 120ms ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -15px;
  height: 2px;
  background: var(--accent-text);
}

.screens { margin-top: 30px; text-align: left; }
.screen[hidden] { display: none; }

a { color: var(--accent-text); }

/* ---------- SETUP screen — the five one-time steps ---------- */

.steps { list-style: none; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 20px;
  padding: 26px 0;
  border-bottom: 1px solid var(--line-muted);
}
.steps li:last-child { border-bottom: none; }
.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 1.375rem;
  color: var(--numeral);
  line-height: 1.3;
}
.steps h3 {
  font-family: var(--rulebook);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.2;
}
.steps p { margin-top: 8px; color: var(--ink-muted); font-size: 1rem; line-height: 1.6; }
.steps strong { color: var(--ink); font-weight: 700; }

kbd {
  font-family: var(--mono);
  font-size: 0.875em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-muted);
  border-radius: 4px;
  padding: 1px 6px 2px;
  white-space: nowrap;
}

/* ---------- MAP screen — controller diagram rebuilt from app geometry ---------- */

.map-stage {
  position: relative;
  aspect-ratio: 1100 / 700;
  width: 100%;
  container-type: inline-size;   /* cards + type scale with the stage */
}

.leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.leader {
  fill: none;
  stroke: var(--line-muted);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transition: stroke 120ms ease;
}
.leader.is-hot { stroke: var(--accent); stroke-width: 1.6; }
.leader-dot { fill: var(--line-muted); transition: fill 120ms ease; }
.leader-dot.is-hot { fill: var(--accent); }

.map-controller {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 40%;
  height: auto;
  aspect-ratio: 2666.27 / 1874.16;
  fill: var(--line);   /* paths carry no fill of their own → inherit brass */
}
@media (forced-colors: active) { .map-controller { fill: CanvasText; } }

.mcard {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 24cqw;                 /* 264 / 1100 */
  height: 6.18cqw;             /* 68 / 700 → keeps the leader dot on the card's mid */
  display: flex;
  align-items: center;
  gap: 0.7cqw;
  padding: 0 1.1cqw;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-muted);
  border-radius: 0.64cqw;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.mcard.is-hot { background: var(--surface-raised); border-color: var(--accent); }
.mcard-badge {
  flex: 0 0 3.6cqw;
  font-family: var(--fieldstone);
  font-weight: 600;
  font-size: 1cqw;
  color: var(--line);
  transition: color 120ms ease;
}
.mcard.is-hot .mcard-badge { color: var(--accent-text); }
.mcard-body { min-width: 0; display: flex; flex-direction: column; gap: 0.18cqw; }
.mcard-title {
  font-family: var(--rulebook);
  font-size: 1.82cqw;
  line-height: 1.15;
  color: var(--card-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mcard.is-off .mcard-title { color: var(--ink-muted); }
.mcard-hint {
  font-family: var(--fieldstone);
  font-size: 1.18cqw;
  line-height: 1.1;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ---------- TUNE screen — engine-feel controls ---------- */

.tune-intro {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-muted);
  margin-bottom: 26px;
}
.tune-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(200px, 0.85fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}
.tune-label h3 {
  font-family: var(--rulebook);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--ink);
}
.tune-label p {
  margin-top: 6px;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-muted);
}
.tune-control { display: flex; align-items: center; gap: 14px; padding-top: 6px; }

.tune-slider {
  flex: 1;
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: var(--line-muted);
}
.tune-slider::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--fill, 50%);
  border-radius: 2px;
  background: var(--accent);
}
.tune-slider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: var(--fill, 50%);
  width: 15px; height: 15px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #f3ede1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.tune-readout {
  flex: 0 0 auto;
  min-width: 44px;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--line);
}
.tune-stepper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  color: var(--ink);
}
.stepper-arrows {
  width: 20px; height: 22px;
  border: 1px solid var(--line-muted);
  border-radius: 4px;
  background:
    linear-gradient(var(--ink-muted) 0 0) center 6px / 8px 1.5px no-repeat,
    linear-gradient(var(--ink-muted) 0 0) center 14px / 8px 1.5px no-repeat;
  position: relative;
}
.stepper-arrows::before,
.stepper-arrows::after {
  content: "";
  position: absolute;
  left: 50%;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}
.stepper-arrows::before {
  top: 4px; transform: translateX(-50%);
  border-bottom: 5px solid var(--ink-muted);
}
.stepper-arrows::after {
  bottom: 4px; transform: translateX(-50%);
  border-top: 5px solid var(--ink-muted);
}
.tune-meters { display: flex; gap: 26px; margin-bottom: 24px; }
.tune-meter { display: flex; align-items: center; gap: 8px; }
.tune-meter em {
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.6875rem;
  color: var(--ink-muted);
}
.meter-track {
  width: 140px; height: 4px;
  border-radius: 2px;
  background: var(--line-muted);
}
.tune-divider {
  border: none;
  border-top: 1px solid var(--line-muted);
  margin: 26px 0;
}

/* ---------- INFO screen ---------- */

.info-section { margin-bottom: 34px; }
.info-section:last-child { margin-bottom: 0; }
.info-section > h3 {
  font-family: var(--rulebook);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 14px;
}
.info-para {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-muted);
  margin-bottom: 14px;
}
/* The author's-note paragraph, set as a pull-quote. */
.info-quote {
  font-family: var(--fieldstone);
  font-style: italic;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  padding-left: 20px;
  border-left: 1px solid var(--line);
  margin: 18px 0;
}
.info-link {
  display: inline-block;
  margin-top: 4px;
  font-weight: 700;
  font-size: 0.9375rem;
}

/* ---------- closing ---------- */

.closing {
  text-align: center;
  padding: 0 32px 72px;
}
.gold-rule {
  border: none;
  border-top: 1px solid var(--line-muted);
  max-width: 960px;
  margin: 0 auto 28px;
}
.closing .button { margin: 0 auto; }
.min-os {
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 0.6875rem;   /* 11px */
  line-height: 1.65;      /* ~18px — the two requirement lines sit close */
  letter-spacing: 0.02em;
  color: var(--accent-cool);   /* the blue min-OS line */
}

/* ---------- terms page ---------- */

.terms { padding: 48px 32px 72px; }
.terms-home {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--rulebook);
  font-size: 1.375rem;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 44px;
}
.terms-mark { width: 48px; height: 48px; }
.terms h1 {
  font-family: var(--rulebook);
  font-weight: 400;
  font-size: clamp(2.25rem, 5vw, 3rem);
  line-height: 1.15;
}
.terms .updated {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  color: var(--accent-cool);
}
/* The one-line summary, set as a pull-quote so a reader who stops here is still right. */
.terms .lede {
  margin: 32px 0 8px;
  padding-left: 20px;
  border-left: 1px solid var(--line);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
}
.terms h2 {
  font-family: var(--rulebook);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--ink);
  margin: 34px 0 12px;
}
.terms p { font-size: 1rem; line-height: 1.6; color: var(--ink-muted); margin-bottom: 14px; }
.terms strong { color: var(--ink); font-weight: 700; }
.terms .back {
  display: inline-block;
  margin-top: 44px;
  font-weight: 700;
  font-size: 0.9375rem;
}

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line-muted);
  padding: 20px 0 28px;
}
footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}
footer a { color: var(--ink-muted); }
footer a:hover, footer a:focus-visible { color: var(--accent-text); }

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .tune-row { grid-template-columns: 1fr; gap: 12px; }
  .steps li { grid-template-columns: 44px 1fr; gap: 14px; }
  footer .wrap { flex-direction: column; }
}
/* The side-by-side lockup needs ~412px of its own; below that the icon goes
   back above the name rather than shrinking the wordmark. */
@media (max-width: 520px) {
  .wordmark { flex-direction: column; gap: 16px; }
}
@media (max-width: 460px) {
  .tabs { gap: 18px; }
}
