@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../../assets/fonts/playfair-display-v40-latin-700.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../../assets/fonts/source-sans-3-v19-latin-regular.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../../assets/fonts/source-sans-3-v19-latin-600.woff2") format("woff2");
}

* {
  box-sizing: border-box;
}

:root {
  --wall-bg: #0f1712;
  --wall-bg-deep: #0a100d;
  --wall-surface: rgba(249, 251, 249, 0.045);
  --wall-surface-strong: rgba(249, 251, 249, 0.075);
  --wall-ink: #f3f5ee;
  --wall-muted: rgba(232, 235, 226, 0.70);
  --wall-dim: rgba(232, 235, 226, 0.45);
  --wall-rule: rgba(169, 200, 163, 0.22);
  --wall-rule-strong: rgba(169, 200, 163, 0.38);
  --wall-sage: #a9c8a3;
  --wall-green: #6f9a68;
  --wall-gold: #c9a44a;
  --wall-amber: #b98432;
  --wall-danger: #d6845d;
  --wall-panel-radius: 8px;
}

html {
  background: var(--wall-bg);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  color: var(--wall-ink);
  background:
    radial-gradient(circle at 16% 16%, rgba(169, 200, 163, 0.10), transparent 28%),
    radial-gradient(circle at 84% 12%, rgba(201, 164, 74, 0.08), transparent 26%),
    linear-gradient(180deg, var(--wall-bg) 0%, var(--wall-bg-deep) 100%);
  font-family: "Source Sans 3", var(--sans), system-ui, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.wall-shell {
  width: min(1220px, calc(100% - 32px));
  max-width: 100%;
  margin: 0 auto;
  padding: 72px 0 58px;
}

.wall-hero {
  max-width: 860px;
  margin: 0 0 30px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--wall-gold);
  font-family: var(--mono), "Courier New", monospace;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: "Playfair Display", Georgia, serif;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  max-width: 940px;
  font-size: clamp(2.4rem, 5vw, 4.65rem);
  line-height: 1.02;
}

.lede {
  margin: 16px 0 0;
  max-width: 760px;
  color: var(--wall-sage);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.1rem, 2.1vw, 1.55rem);
  overflow-wrap: break-word;
}

.hero-note {
  margin: 15px 0 0;
  max-width: 780px;
  color: var(--wall-muted);
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  overflow-wrap: break-word;
}

.lab-layout {
  display: grid;
  gap: 18px;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metrics-strip div,
.machine-panel,
.control-deck,
.reading-notes article,
.concept-links a {
  border: 1px solid var(--wall-rule);
  border-radius: var(--wall-panel-radius);
  background: var(--wall-surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.metrics-strip div {
  padding: 15px 16px;
}

.metrics-strip span,
.panel-heading p,
.micro-label {
  display: block;
  color: var(--wall-dim);
  font-family: var(--mono), "Courier New", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.metrics-strip strong {
  display: block;
  margin-top: 4px;
  color: var(--wall-sage);
  font-size: clamp(1.3rem, 3vw, 2.2rem);
  line-height: 1.05;
}

.machine-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.45fr);
  grid-template-areas:
    "verify forest"
    "budget budget";
  gap: 18px;
}

.machine-panel {
  min-width: 0;
  max-width: 100%;
  padding: 18px;
  overflow: hidden;
}

.verify-panel {
  grid-area: verify;
}

.forest-panel {
  grid-area: forest;
}

.budget-panel {
  grid-area: budget;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(1.4rem, 2.6vw, 2.3rem);
  line-height: 1.08;
}

.panel-copy {
  min-height: 3.1em;
  margin: 15px 0 0;
  color: var(--wall-muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.board-stage,
.forest-stage {
  position: relative;
  border: 1px solid rgba(232, 235, 226, 0.10);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(23, 35, 27, 0.88), rgba(10, 15, 12, 0.94)),
    radial-gradient(circle at 70% 20%, rgba(169, 200, 163, 0.10), transparent 30%);
}

.board-stage {
  width: min(320px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
}

#solution-board {
  display: block;
  width: 100%;
  height: 100%;
}

.board-cell {
  fill: rgba(249, 251, 249, 0.035);
  stroke: rgba(169, 200, 163, 0.28);
  stroke-width: 1;
}

.board-cell.region {
  fill: rgba(201, 164, 74, 0.055);
}

.board-number {
  fill: rgba(243, 245, 238, 0.78);
  font-family: var(--mono), "Courier New", monospace;
  font-size: 13px;
  text-anchor: middle;
  dominant-baseline: central;
}

.board-rule {
  stroke: rgba(201, 164, 74, 0.58);
  stroke-width: 2;
}

.scan-line {
  position: absolute;
  left: 0;
  top: -12%;
  width: 100%;
  height: 12%;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(201, 164, 74, 0.32), transparent);
  opacity: 0;
}

.is-checking .scan-line {
  animation: scan-board 1.15s ease-in-out 1;
}

@keyframes scan-board {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translateY(930%);
    opacity: 0;
  }
}

.forest-stage {
  min-height: 462px;
  max-width: 100%;
}

#search-forest {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 462px;
}

.branch-line {
  fill: none;
  stroke: rgba(169, 200, 163, 0.40);
  stroke-width: 1.25;
}

.branch-line.active {
  stroke: rgba(201, 164, 74, 0.78);
  stroke-width: 1.7;
}

.branch-line.pruned {
  stroke: rgba(214, 132, 93, 0.35);
  stroke-dasharray: 4 7;
}

.branch-node {
  fill: #111914;
  stroke: rgba(169, 200, 163, 0.58);
  stroke-width: 1.2;
}

.branch-node.goal {
  fill: var(--wall-gold);
  stroke: rgba(249, 251, 249, 0.84);
}

.shortcut-path {
  fill: none;
  stroke: var(--wall-gold);
  stroke-width: 3;
  stroke-linecap: round;
}

.forest-label {
  fill: rgba(232, 235, 226, 0.64);
  font-family: var(--mono), "Courier New", monospace;
  font-size: 12px;
}

.budget-axis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 4px 0 18px;
  color: var(--wall-dim);
  font-family: var(--mono), "Courier New", monospace;
  font-size: 0.75rem;
}

.budget-axis span:last-child {
  color: var(--wall-gold);
  text-align: right;
}

.budget-bars {
  display: grid;
  gap: 12px;
}

.budget-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.budget-row span {
  color: var(--wall-muted);
  font-size: 0.92rem;
}

.budget-row i {
  position: relative;
  display: block;
  height: 13px;
  overflow: hidden;
  border: 1px solid rgba(169, 200, 163, 0.26);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}

.budget-row i::after {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 68%;
  width: 1px;
  background: rgba(201, 164, 74, 0.58);
}

.budget-row b {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--wall-sage), var(--wall-gold));
  transition: width 0.28s ease, background 0.28s ease;
}

.budget-row b.overflow {
  background: linear-gradient(90deg, var(--wall-amber), var(--wall-danger));
}

.control-deck {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.45fr) auto;
  gap: 18px;
  align-items: end;
  padding: 18px;
}

.size-control label,
.mode-control legend {
  display: block;
  margin-bottom: 10px;
  color: var(--wall-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.size-control label strong {
  color: var(--wall-gold);
  font-family: var(--mono), "Courier New", monospace;
  font-size: 1rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--wall-gold);
  cursor: pointer;
}

.mode-control {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mode-control legend {
  grid-column: 1 / -1;
}

.mode-control label {
  min-width: 0;
}

.mode-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-control span,
.verify-button,
.concept-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-family: "Source Sans 3", var(--sans), system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
}

.mode-control span {
  border: 1px solid rgba(169, 200, 163, 0.24);
  color: var(--wall-muted);
  background: rgba(249, 251, 249, 0.035);
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.mode-control input:checked + span {
  border-color: rgba(201, 164, 74, 0.78);
  color: var(--wall-ink);
  background: rgba(201, 164, 74, 0.13);
}

.mode-control input:focus-visible + span,
.verify-button:focus-visible,
.concept-links a:focus-visible {
  outline: 2px solid var(--wall-gold);
  outline-offset: 2px;
}

.verify-button {
  border: 1px solid var(--wall-gold);
  background: var(--wall-gold);
  color: #101812;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.verify-button:hover {
  border-color: var(--wall-sage);
  background: var(--wall-sage);
}

.reading-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.reading-notes article {
  padding: 20px;
}

.reading-notes h2 {
  margin: 0 0 9px;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
}

.reading-notes p {
  margin: 0;
  color: var(--wall-muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.03rem;
}

.concept-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.concept-links a {
  width: auto;
  min-width: 180px;
  color: var(--wall-ink);
  text-decoration: none;
  background: rgba(249, 251, 249, 0.045);
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.concept-links a:hover {
  border-color: rgba(201, 164, 74, 0.72);
  background: rgba(201, 164, 74, 0.12);
  color: var(--wall-sage);
}

@media (max-width: 980px) {
  .machine-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "verify"
      "forest"
      "budget";
  }

  .control-deck {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .forest-stage,
  #search-forest {
    min-height: 380px;
    height: 380px;
  }
}

@media (max-width: 680px) {
  .wall-shell {
    width: calc(100vw - 48px);
    margin: 0 auto;
    padding: 76px 0 48px;
  }

  .wall-hero,
  .lab-layout,
  .metrics-strip,
  .machine-grid,
  .control-deck,
  .reading-notes,
  .concept-links {
    max-width: 100%;
    min-width: 0;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 2.7rem);
    overflow-wrap: break-word;
  }

  .lede {
    font-size: 1.06rem;
  }

  .metrics-strip,
  .reading-notes {
    grid-template-columns: 1fr;
  }

  .mode-control {
    grid-template-columns: 1fr;
  }

  .machine-panel {
    padding: 15px;
  }

  .budget-row {
    grid-template-columns: 66px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
