:root {
  --night: #071018;
  --night-2: #0d1826;
  --sheet: #101c2c;
  --ink: #e6edf4;
  --mute: #7d8b9a;
  --tungsten: #e8b24a;
  --tungsten-2: #f3d27a;
  --tube: #e23a32;
  --ash: #6a7888;
  --ok: #3d9a6a;
  --lane-a: #c45c18;
  --lane-b: #1a140c;
  --line: rgba(232, 178, 74, 0.28);
  --display: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "PingFang SC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: 88px; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--night);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
.app-link {
  color: var(--tungsten);
  text-decoration: underline;
  text-underline-offset: 3px;
}
button { font-family: inherit; cursor: pointer; }
code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--tungsten-2);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  opacity: 0.22;
  background-image: url("images/texture.webp");
  background-size: 420px auto;
  mix-blend-mode: overlay;
}

.lane {
  display: none;
}

.skip { position: absolute; left: -999px; }
.skip:focus {
  left: 16px;
  top: 16px;
  z-index: 80;
  background: var(--tungsten);
  color: var(--night);
  padding: 8px 12px;
}

.mast {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px 10px 28px;
  background: rgba(7, 16, 24, 0.94);
  border-bottom: 1px solid var(--line);
}

.mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.04em;
}
.mark small {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.16em;
  color: var(--mute);
}

.lamp-dot {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  background: var(--tungsten);
  color: var(--night);
  font-family: var(--display);
  font-size: 18px;
  box-shadow: 0 0 18px rgba(232, 178, 74, 0.45);
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--tungsten);
  color: var(--tungsten);
  padding: 7px 12px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.ledger-links {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 14px;
}
.ledger-links a { color: var(--mute); }
.ledger-links a.is-active,
.ledger-links a:hover { color: var(--tungsten); }
.ledger-links .live {
  background: var(--tungsten);
  color: var(--night);
  padding: 7px 12px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  align-items: end;
  overflow: hidden;
}
.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero .ink-grid {
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(232, 178, 74, 0.12) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(232, 178, 74, 0.12) 47px 48px);
  mix-blend-mode: screen;
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 16, 24, 0.55) 0%, transparent 18%),
    linear-gradient(180deg, rgba(7, 16, 24, 0.15) 0%, rgba(7, 16, 24, 0.82) 78%, var(--night) 100%);
}

.hero-sheet {
  position: relative;
  z-index: 1;
  padding: 10vh 8vw 8vh;
  max-width: 820px;
}

.kicker,
.code {
  font-family: var(--mono);
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--tungsten);
  margin: 0 0 12px;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.08;
  margin: 0 0 16px;
}
h1 { font-size: clamp(44px, 8vw, 92px); }
h2 { font-size: clamp(28px, 4.4vw, 46px); }
h3 { font-size: 24px; line-height: 1.25; }

.lead, .lede {
  max-width: 44em;
  color: rgba(230, 237, 244, 0.88);
}
.lede { margin: 0 0 28px; }

.ticks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 22px 0;
  list-style: none;
}
.ticks li {
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 12px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 14px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.btn.fill { background: var(--tungsten); color: var(--night); }
.btn.line { border: 1px solid var(--tungsten); color: var(--tungsten); }

.sheet {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 88px 0;
}

.plaque-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
#value .plaque-row { grid-template-columns: repeat(2, 1fr); }

.plaque {
  background: var(--sheet);
  border: 1px solid var(--line);
  padding: 22px;
  min-height: 240px;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.plaque.hot { border-color: var(--tube); }
.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--tungsten);
  border: 1px solid var(--line);
  padding: 2px 8px;
  margin: 0 0 10px;
}
.plaque ul { margin: 0; padding-left: 1.1em; }
.plaque li { margin: 0.35em 0; }
.plaque p { margin: 0; color: var(--mute); }

.street { padding: 12px 0 64px; }
.stall {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto 56px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 36px;
  align-items: center;
}
.stall.flip { grid-template-columns: 0.95fr 1.05fr; }
.stall.flip figure { order: 2; }

figure { margin: 0; }
figure img {
  width: 100%;
  height: 340px;
  object-fit: cover;
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  filter: saturate(0.92);
}
figcaption {
  margin-top: 10px;
  font-size: 13px;
  color: var(--mute);
  font-family: var(--mono);
}

.circuit-demo {
  border: 1px solid var(--line);
  background:
    repeating-linear-gradient(135deg, var(--lane-b) 0 10px, #24180e 10px 20px);
  padding: 22px;
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
}
.circuit-meta {
  background: rgba(7, 16, 24, 0.82);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.circuit-meta p { margin: 0 0 8px; }
.mono, .load-line { font-family: var(--mono); }
.load-line { color: var(--tungsten-2); }

.bar {
  height: 8px;
  background: rgba(230, 237, 244, 0.12);
  margin: 10px 0;
}
.bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ok);
  transition: width 0.2s ease, background 0.2s ease;
}
.bar i.over { background: var(--tube); }
.load-state { font-family: var(--mono); font-size: 13px; color: var(--mute); }
.load-state.over { color: var(--tube); }
.load-state.ok { color: var(--ok); }

.lamp-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.lamp {
  text-align: left;
  background: var(--tungsten);
  color: var(--night);
  border: 0;
  padding: 16px;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  box-shadow: 0 0 22px rgba(232, 178, 74, 0.35);
}
.lamp span { display: block; font-size: 11px; letter-spacing: 0.12em; }
.lamp strong { display: block; font-family: var(--display); font-size: 22px; margin: 4px 0; }
.lamp em { font-style: normal; font-family: var(--mono); font-size: 13px; }
.lamp.hot {
  background: var(--tube);
  color: #fff;
  animation: flash 0.6s ease 1;
  box-shadow: 0 0 22px rgba(226, 58, 50, 0.45);
}
.lamp.lit { outline: 2px solid var(--tungsten-2); outline-offset: 2px; }

@keyframes flash {
  0%, 100% { filter: brightness(1); }
  40% { filter: brightness(1.6); }
}

.knobs {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  background: rgba(7, 16, 24, 0.82);
  padding: 14px 16px;
  color: var(--ink);
}
.slider {
  display: grid;
  grid-template-columns: auto 1fr 28px;
  gap: 10px;
  align-items: center;
  flex: 1;
  min-width: 240px;
  font-size: 14px;
}
.slider input { width: 100%; accent-color: var(--tungsten); }
.check { font-size: 14px; display: flex; gap: 8px; align-items: center; }

.rule-list {
  max-width: 46em;
  font-size: 17px;
  padding-left: 1.2em;
}
.rule-list li { margin: 0.55em 0; }

.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.ledger th, .ledger td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 12px 10px;
  vertical-align: top;
}
.ledger th {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--tungsten);
  font-weight: 400;
}
.foot-note { color: var(--mute); font-size: 14px; }

.colophon {
  border-top: 1px solid var(--line);
  padding: 28px 8vw 48px;
  color: var(--mute);
  font-size: 13px;
}

@media (min-width: 1100px) {
  .lane {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 36px;
    z-index: 40;
    background: repeating-linear-gradient(
      135deg,
      var(--lane-a) 0 9px,
      var(--lane-b) 9px 18px
    );
  }
  .lane span {
    writing-mode: vertical-rl;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.22em;
    color: #f4e6c8;
    text-shadow: 0 1px 0 #000;
  }
  body { padding-left: 36px; }
}

@media (max-width: 900px) {
  .mark small { display: none; }
  .plaque-row,
  #value .plaque-row,
  .lamp-row,
  .stall,
  .stall.flip {
    grid-template-columns: 1fr;
  }
  .stall.flip figure { order: 0; }
  figure img { height: 240px; }
  .nav-toggle { display: inline-block; }
  .ledger-links {
    display: none;
    position: absolute;
    top: 58px;
    right: 12px;
    left: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--night-2);
    border: 1px solid var(--line);
    padding: 8px;
  }
  .ledger-links.open { display: flex; }
  .ledger-links a { padding: 10px 12px; }
  .mast { position: sticky; }
}
