:root {
  color-scheme: light dark;
  --paper: #F2F5F4;
  --ink: #14212B;
  --soft: #55656F;
  --rule: #D5DCDB;
  --line: #2B5B6B;
  --decrypt-fill: #A5472D;
  --backdrop: #C5D0D8;
  --interface: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --reading: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101A21;
    --ink: #E7EDF0;
    --soft: #9FB0BA;
    --rule: #2A3944;
    --line: #93C5D6;
    --decrypt-fill: #DF9A7C;
    --backdrop: #263843;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.125rem/1.6 var(--reading);
}

.page { max-width: 80rem; margin-inline: auto; padding: 3.25rem 1.5rem 5rem; }
.lesson-header { padding-block: 0 2.5rem; }

h1, h2, h3, .course-label, button, label, .label, .hint, .status, dt, summary {
  font-family: var(--interface);
}

h1, h2, h3, p, figure, dl, dd { margin: 0; }
h1 { max-width: 17ch; font-size: clamp(2.5rem, 6vw, 4.25rem); line-height: 1.04; letter-spacing: -0.025em; }
h2 { font-size: 1.625rem; line-height: 1.2; letter-spacing: -0.015em; }
h3 { font-size: 1.1875rem; line-height: 1.3; }
.course-label { margin-bottom: 0.625rem; color: var(--soft); font-size: 0.9375rem; font-weight: 600; }
.course-label span { margin-inline: 0.3em; color: var(--soft); }
.course-label a { display: inline-flex; align-items: center; min-height: 2.75rem; }
a { color: var(--line); text-decoration: underline; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
.lede { max-width: 38rem; margin-top: 1rem; font-size: 1.25rem; }

.experiment { border-block: 1px solid var(--rule); padding-block: 1.5rem 1rem; }
.experiment-header p { margin-top: 0.375rem; }
.stations { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 1.5rem; }

.station {
  min-width: 0;
  padding: 1rem clamp(0.75rem, 2.2vw, 1.75rem) 1.25rem;
  border-top: 2px solid var(--line);
  border-inline-end: 1px solid var(--rule);
}

.station:last-child { border-inline-end: 0; }
.station h3 { margin-bottom: 0.875rem; }
.station h3::before {
  display: inline-block;
  width: 0.62rem;
  height: 0.62rem;
  margin-inline-end: 0.5rem;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--line);
  content: "";
}
.station.is-current h3::before { background: var(--paper); }
.station-gloss { color: var(--soft); font-size: 0.875rem; font-weight: 400; }

.label, label { display: block; font-size: 0.875rem; font-weight: 650; }
.soft, .hint { color: var(--soft); font-weight: 400; }
.hint { margin-block: 0.325rem 0.65rem; font-size: 0.875rem; }
.sender-state { overflow-wrap: anywhere; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }

button, select, input {
  min-height: 2.75rem;
  max-width: 100%;
  border: 1px solid var(--soft);
  border-radius: 0.4rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
}

input, select { margin-top: 0.25rem; padding: 0.4rem 0.6rem; font-family: var(--mono); }
input { width: 100%; }
button { display: block; margin-top: 0.85rem; padding: 0.5rem 0.85rem; font-size: 0.875rem; font-weight: 650; }
button:not(:disabled) { cursor: pointer; }
button:not(:disabled):hover { border-color: var(--line); text-decoration: underline; }
button:disabled, select:disabled { opacity: 0.55; }
.station.is-current button:not(:disabled) { border-color: var(--decrypt-fill); background: var(--decrypt-fill); color: var(--paper); }
:focus-visible { outline: 2px solid var(--line); outline-offset: 3px; }

code, .signal, .attempt-text { font-family: var(--mono); overflow-wrap: anywhere; }
.signal {
  min-height: 3.15rem;
  margin-top: 0.25rem;
  padding: 0.65rem;
  border: 1px dashed var(--line);
  background: color-mix(in srgb, var(--backdrop) 24%, var(--paper));
  font-size: 1rem;
  white-space: pre-wrap;
}

.attempts { margin: 1rem 0 0; padding: 0; list-style: none; }
.attempts li { padding-block: 0.45rem; border-top: 1px solid var(--rule); }
.attempt-label { display: block; font: 0.875rem/1.4 var(--interface); }
.attempt-text { display: block; white-space: pre-wrap; font-size: 1rem; }
.status { min-height: 1.6em; color: var(--line); font-size: 0.9375rem; overflow-wrap: anywhere; }
.no-script { border-block: 1px solid var(--rule); padding-block: 1rem; }

.reading { max-width: 40rem; margin-top: 3.25rem; }
.reading p { margin-top: 1rem; }
.walkthrough { margin-block: 1.5rem; }
.walkthrough dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.walkthrough dl > div { border-top: 1px solid var(--rule); padding: 0.65rem 0.75rem 0.65rem 0; }
.walkthrough dt, .walkthrough figcaption { color: var(--soft); font-size: 0.9375rem; }
.walkthrough figcaption { margin-top: 0.5rem; border-top: 1px solid var(--rule); padding-top: 0.5rem; }
.check { margin-top: 3.25rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
details { margin-top: 0.5rem; }
summary { min-height: 2.75rem; width: fit-content; padding-block: 0.5rem; color: var(--line); cursor: pointer; text-decoration: underline; font-size: 0.9375rem; font-weight: 600; }
summary:hover { text-decoration-thickness: 2px; }

@media (max-width: 47rem) {
  .page { padding-top: 2rem; }
  .stations { grid-template-columns: 1fr; }
  .station { padding-inline: 0.25rem; border-inline-end: 0; }
  .station + .station { padding-top: 1rem; }
  .status { margin-top: 0.25rem; }
}

@media (max-width: 25rem) {
  .walkthrough dl { grid-template-columns: 1fr; }
}

@media print {
  :root { --paper: #fff; --ink: #000; --soft: #000; --rule: #999; --line: #000; }
  .page { padding: 0; }
  .experiment, .no-script { display: none; }
  .reading { margin-top: 0; }
  .walkthrough { break-inside: avoid; }
}
