/* Dead Grid course theme.
   Night: the dead city. Paper: the resistance field manual.
   Hazard yellow = something you can act on. Sensor red = machines and errors.
   Salvage green = confirmed by the teacher. */

:root {
  --night: #23271f;
  --night-raised: #2d3228;
  --night-line: #454c3e;
  --ash: #dcdfd6;
  --ash-raised: #e9ebe4;
  --ash-line: #b9bdb1;
  --ink: #1c2019;
  --ink-soft: #4a5045;
  --bone: #e9ebe3;
  --bone-soft: #b0b5a8;
  --hazard: #f2b807;
  --hazard-ink: #241c00;
  --sensor: #e0393e;
  --sensor-ink: #a8242a;
  --salvage: #6f9f58;
  --salvage-ink: #2f5a25;
  --code-bg: #262b22;
  --display: "Big Shoulders Stencil Display", "Big Shoulders Stencil", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --measure: 68ch;
  --gutter: clamp(16px, 4vw, 48px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--night);
  color: var(--bone);
  font: 400 1.125rem/1.6 var(--body);
  min-width: 300px;
}

a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--hazard); outline-offset: 3px; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.1; }
p, ul, ol, dl { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; }
li + li { margin-top: .3em; }
img, svg { display: block; }
button, input, select { font: inherit; }

code, pre, kbd { font-family: var(--mono); font-size: .9em; }
pre {
  margin: 0 0 1.2em;
  padding: 18px 20px;
  background: var(--code-bg);
  color: var(--bone);
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.55;
  font-size: .95rem;
  tab-size: 4;
}
pre code { font-size: inherit; background: none; padding: 0; color: inherit; }
:not(pre) > code {
  padding: .08em .32em;
  border-radius: 3px;
  background: var(--night-raised);
  color: var(--bone);
  overflow-wrap: anywhere;
}
.sheet :not(pre) > code { background: #c8ccc0; color: var(--ink); }

.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 99;
  padding: 10px 16px; background: var(--hazard); color: var(--hazard-ink); font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* ---------- top bar ---------- */

.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  min-height: 64px; padding: 8px var(--gutter);
  background: var(--night);
  border-bottom: 1px solid var(--night-line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  display: grid; grid-template-columns: repeat(3, 7px); gap: 2px;
}
.brand-mark i { width: 7px; height: 7px; background: var(--bone-soft); }
.brand-mark i:nth-child(5) { background: var(--hazard); }
.brand-mark i:nth-child(3), .brand-mark i:nth-child(7) { background: transparent; outline: 1px solid var(--night-line); }
.brand-name { font: 800 1.5rem/1 var(--display); letter-spacing: .04em; }
.bar nav { display: flex; gap: 4px 20px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.bar nav a { text-decoration: none; color: var(--bone-soft); font-weight: 700; padding: 6px 0; }
.bar nav a:hover, .bar nav a[aria-current="page"] { color: var(--bone); box-shadow: inset 0 -3px 0 var(--hazard); }

/* ---------- avatars ---------- */

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: var(--size, 32px); height: var(--size, 32px);
  background: var(--ash); color: var(--ink); border-radius: 3px;
}
.avatar svg { width: 62%; height: 62%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sheet .avatar { background: var(--ink); color: var(--ash); }

/* ---------- buttons ---------- */

.button {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px; border: 2px solid var(--hazard); border-radius: 3px;
  background: var(--hazard); color: var(--hazard-ink);
  font-weight: 700; text-decoration: none; cursor: pointer;
}
.button:hover { background: #ffcb2b; }
.button.quiet { background: transparent; color: var(--bone); border-color: var(--night-line); }
.button.quiet:hover { border-color: var(--bone-soft); }
.sheet .button.quiet { color: var(--ink); border-color: var(--ash-line); }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- notices ---------- */

.notice {
  margin: 0 var(--gutter) 24px; padding: 14px 18px; border-left: 6px solid var(--hazard);
  background: var(--night-raised); color: var(--bone);
}
.notice[hidden] { display: none; }
.notice.danger { border-color: var(--sensor); }
.notice p:last-child { margin-bottom: 0; }

/* ---------- hero with the city map ---------- */

.hero {
  display: grid; gap: clamp(28px, 5vw, 72px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 520px);
  align-items: center;
  padding: clamp(40px, 7vw, 96px) var(--gutter) clamp(32px, 5vw, 64px);
  max-width: 1360px; margin: 0 auto;
}
.hero h1 {
  font: 800 clamp(3.4rem, 9vw, 7.4rem)/.88 var(--display);
  letter-spacing: .01em; margin-bottom: 24px; text-wrap: balance;
}
.hero .lede { max-width: 46ch; color: var(--bone-soft); font-size: 1.2rem; }

.city-figure { margin: 0; min-width: 0; }
.city {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  padding: 10px; background: #1a1d17; border: 1px solid var(--night-line);
}
.city figcaption { grid-column: 1 / -1; color: var(--bone-soft); font-size: .9rem; padding-top: 6px; }
.cell {
  position: relative; aspect-ratio: 1;
  display: flex; align-items: flex-end; padding: 6px;
  background: var(--night-raised); color: var(--bone-soft);
  font-size: clamp(.62rem, 1.5vw, .8rem); line-height: 1.15;
}
.cell.rubble {
  background: repeating-linear-gradient(135deg, #343a2f 0 6px, #2a2f26 6px 12px);
  color: transparent;
}
.cell.bunker { outline: 2px solid var(--hazard); outline-offset: -2px; color: var(--bone); font-weight: 700; }
.cell .mark {
  position: absolute; top: 6px; left: 6px;
  width: 14px; height: 14px; aspect-ratio: 1; border-radius: 50%;
}
.cell .mark.you { background: var(--hazard); box-shadow: 0 0 0 4px rgba(242, 184, 7, .25); }
.cell .mark.robot { background: var(--sensor); box-shadow: 0 0 0 4px rgba(224, 57, 62, .25); }
.cell .mark.robot::after {
  content: attr(data-model); position: absolute; left: 20px; top: -2px;
  color: #ff8f92; font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.city-key { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; color: var(--bone-soft); font-size: .9rem; }
.city-key span { display: inline-flex; align-items: center; gap: 8px; }
.city-key i { width: 10px; height: 10px; border-radius: 50%; }
.city-key .k-you { background: var(--hazard); }
.city-key .k-robot { background: var(--sensor); }
.city-key .k-rubble { border-radius: 0; background: repeating-linear-gradient(135deg, #4a5143 0 3px, #2a2f26 3px 6px); }

/* ---------- page sections ---------- */

.wrap { max-width: 1360px; margin: 0 auto; padding: 0 var(--gutter); }
.section { padding-top: 48px; padding-bottom: 48px; }
.section > h2, .section-title { font: 800 clamp(2rem, 4.5vw, 3rem)/1 var(--display); letter-spacing: .01em; }

.sheet {
  background: var(--ash); color: var(--ink); min-width: 0;
  border-radius: 2px; padding: clamp(22px, 4vw, 48px);
}
.week-layout > *, .week-main > *, .step-body, .teacher-layout > *, .teacher-content > *, .hero > * { min-width: 0; }
.sheet h2, .sheet h3 { color: var(--ink); }
.sheet a { color: var(--ink); }

.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2px; background: var(--ash-line); }
.how-grid > div { background: var(--ash); padding: 22px 24px; }
.how-grid h3 { font: 800 1.5rem/1 var(--display); }
.how-grid p { margin: 0; color: var(--ink-soft); }

.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 32px; margin-top: 28px; }
.rules h3 { font-size: 1.05rem; margin-bottom: 4px; }
.rules p { color: var(--ink-soft); margin: 0; }

/* ---------- week strip ---------- */

.weeks-nav { position: sticky; top: 64px; z-index: 20; background: var(--night); border-bottom: 1px solid var(--night-line); }
.week-strip {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin;
  max-width: 1360px; margin: 0 auto; padding: 0 var(--gutter);
  list-style: none;
}
.week-strip li { margin: 0; flex: 1 0 120px; }
.week-strip a {
  display: grid; gap: 2px; height: 100%;
  padding: 12px 12px 10px; text-decoration: none;
  color: var(--bone-soft); border-bottom: 4px solid transparent;
}
.week-strip a:hover { color: var(--bone); background: var(--night-raised); }
.week-strip a[aria-current="true"] { color: var(--bone); border-bottom-color: var(--hazard); background: var(--night-raised); }
.week-strip .num { font: 800 1.6rem/1 var(--display); }
.week-strip .name { font-size: .85rem; line-height: 1.2; white-space: nowrap; }
.pips { display: flex; gap: 3px; margin-top: 6px; }
.pips i { width: 12px; height: 5px; background: var(--night-line); }
.pips i.pending { background: var(--hazard); }
.pips i.confirmed { background: var(--salvage); }

/* ---------- a week ---------- */

.week { padding: 40px 0 72px; scroll-margin-top: 140px; }
.js .week:not(.is-active) { display: none; }
.week-head { display: grid; grid-template-columns: auto 1fr; gap: 4px 24px; align-items: end; margin-bottom: 28px; }
.week-head .num { grid-row: span 2; font: 800 clamp(5rem, 12vw, 9rem)/.8 var(--display); color: var(--hazard); }
.week-head h2 { font: 800 clamp(2.4rem, 6vw, 4.4rem)/.95 var(--display); margin: 0; }
.week-head p { color: var(--bone-soft); margin: 0; max-width: 60ch; }

.week-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.week-main { display: grid; gap: 24px; min-width: 0; }
.week-main > .sheet > * { max-width: var(--measure); }
.week-main > .sheet > pre, .week-main > .sheet > .table-wrap, .week-main > .sheet > .pair { max-width: none; }
.week-aside { display: grid; gap: 16px; position: sticky; top: 160px; }

.brief h3 { font: 800 1.9rem/1 var(--display); }
.ideas { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 32px; }
.ideas h4 { font-size: 1rem; margin: 0 0 6px; color: var(--ink-soft); }
.ideas ul { margin-bottom: 0; }

.lesson h3 { font: 800 1.9rem/1 var(--display); }
.lesson h4 { font-size: 1.15rem; margin: 1.6em 0 .5em; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-bottom: 1em; }
.pair > div > :last-child { margin-bottom: 0; }

.callout { border-left: 5px solid var(--ink); padding: 4px 0 4px 18px; margin: 0 0 1.2em; }
.callout.danger { border-color: var(--sensor-ink); }
.callout p:last-child { margin-bottom: 0; }

.output { position: relative; }
.output::before {
  content: attr(data-label); display: block;
  font-size: .85rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 4px;
}
.output pre { background: #11140f; color: #cfe6bf; }

.pseudo {
  margin: 0 0 1.2em; padding: 16px 20px; white-space: pre; overflow-x: auto;
  border: 2px dashed var(--ink-soft); background: var(--ash-raised); color: var(--ink);
  font: .95rem/1.55 var(--mono);
}

.table-wrap { overflow-x: auto; margin-bottom: 1.2em; }
table { border-collapse: collapse; min-width: 100%; font-size: 1rem; }
th, td { padding: 8px 12px; border: 1px solid var(--ash-line); text-align: left; vertical-align: top; }
th { background: #cfd3c8; }
td.blank { min-width: 64px; }

/* ---------- steps and ticks ---------- */

.step { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 0 20px; }
.step-num { font: 800 4rem/.85 var(--display); color: var(--ink); }
.step-body > :last-child { margin-bottom: 0; }
.step-body > * { max-width: var(--measure); }
.step-body > pre, .step-body > .table-wrap, .step-body > .output { max-width: none; }
.step h3 { font-size: 1.35rem; margin-bottom: .2em; }
.step .kind { color: var(--ink-soft); font-weight: 700; margin-bottom: .8em; }
.step-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--ash-line); }
.step-foot p { margin: 0; color: var(--ink-soft); font-size: .95rem; }


/* ---------- aside panels ---------- */

.panel { background: var(--night-raised); border: 1px solid var(--night-line); padding: 20px; }
.panel h3 { font: 800 1.5rem/1 var(--display); margin-bottom: 12px; }
.panel p { color: var(--bone-soft); font-size: 1rem; }
.panel :last-child { margin-bottom: 0; }
.panel pre { background: #1a1d17; font-size: .85rem; }
.panel :not(pre) > code { background: #1a1d17; }
.panel ul { font-size: 1rem; }

.hint { border-top: 1px solid var(--night-line); }
.hint:last-of-type { border-bottom: 1px solid var(--night-line); margin-bottom: 1em; }
.hint summary { cursor: pointer; padding: 10px 0; font-weight: 700; }
.hint summary::marker { color: var(--hazard); }
.hint[open] summary { color: var(--hazard); }
.hint > :not(summary) { font-size: 1rem; }

.errors dt { font-family: var(--mono); color: #ff8f92; font-size: .9rem; margin-top: 12px; }
.errors dt:first-child { margin-top: 0; }
.errors dd { margin: 2px 0 0; color: var(--bone-soft); font-size: .98rem; }

.download { display: flex; gap: 12px; align-items: center; }

/* ---------- board ---------- */

.route { position: relative; margin: 32px 0 8px; padding: 72px 0 40px; }
.route-line { position: relative; height: 18px; display: grid; grid-template-columns: repeat(40, 1fr); gap: 2px; }
.route-line i { background: var(--night-line); }
.route-line i:nth-child(4n) { box-shadow: 3px 0 0 var(--night); }
.route-line i.reached { background: var(--salvage); }
.route-ends { display: flex; justify-content: space-between; margin-top: 10px; color: var(--bone-soft); font-weight: 700; }
.route-ends span:last-child { color: var(--hazard); }
.runner { position: absolute; top: 0; transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; }
.runner .faces { display: flex; }
.runner .faces .avatar + .avatar { margin-left: -10px; box-shadow: -2px 0 0 var(--night); }
.route-line + .route-ends { position: relative; }
.runner .avatar { --size: 34px; }
.runner b { font-size: .78rem; white-space: nowrap; color: var(--bone); }
.runner::after { content: ""; width: 2px; height: var(--stem, 10px); background: var(--bone-soft); }

.board-table td, .board-table th { border-color: var(--ash-line); }
.board-table .who { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.board-table .rank { font: 800 1.8rem/1 var(--display); width: 64px; }
.week-pips { display: flex; gap: 6px; }
.week-pips span { display: grid; grid-template-columns: repeat(2, 6px); gap: 2px; }
.week-pips i { width: 6px; height: 6px; background: var(--ash-line); }
.week-pips i.on { background: var(--salvage-ink); }

/* ---------- profile ---------- */

.field label, .field legend { display: block; font-weight: 700; margin-bottom: 6px; }
.field .help { color: var(--ink-soft); font-size: .95rem; margin: 6px 0 0; }
.field input[type="text"] {
  width: 100%; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 3px;
  background: var(--ash-raised); color: var(--ink); font-size: 1.15rem;
}
fieldset { border: 0; padding: 0; margin: 0; }
.avatar-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-width: 440px; }
.avatar-picker label { display: grid; justify-items: center; gap: 6px; padding: 10px; border: 2px solid var(--ash-line); border-radius: 3px; cursor: pointer; font-size: .9rem; }
.avatar-picker input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-picker input:checked + label { border-color: var(--ink); background: var(--ash-raised); }
.avatar-picker input:focus-visible + label { outline: 3px solid var(--hazard); outline-offset: 2px; }
.avatar-picker .avatar { --size: 40px; background: var(--ink); color: var(--ash); }
.form-status { min-height: 1.6em; font-weight: 700; }
.form-status.ok { color: var(--salvage-ink); }
.form-status.error { color: var(--sensor-ink); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- teacher ---------- */

.teacher-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; }
.teacher-index { position: sticky; top: 80px; display: grid; gap: 2px; font-size: .98rem; }
.teacher-index a { text-decoration: none; color: var(--bone-soft); padding: 6px 10px; border-left: 3px solid transparent; }
.teacher-index a:hover { color: var(--bone); border-left-color: var(--hazard); }
.teacher-content { display: grid; gap: 24px; min-width: 0; }
.teacher-content .sheet > * { max-width: var(--measure); }
.teacher-content .sheet > pre, .teacher-content .sheet > .table-wrap, .teacher-content .sheet > .pair, .teacher-content .sheet > .brief-box, .teacher-content .sheet > .run-sheet { max-width: none; }

.brief-box { border: 2px solid var(--ink); margin: 0 0 1.2em; }
.brief-box blockquote { margin: 0; padding: 18px 20px; white-space: pre-line; background: var(--ash-raised); font-size: 1rem; }
.brief-box .brief-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-top: 2px solid var(--ink); }
.brief-box .brief-foot span { color: var(--ink-soft); font-size: .95rem; }
.copy-button { padding: 8px 14px; border: 2px solid var(--ink); border-radius: 3px; background: var(--ink); color: var(--ash); font-weight: 700; cursor: pointer; }
.copy-button.copied { background: var(--salvage-ink); border-color: var(--salvage-ink); }

.run-sheet { display: grid; gap: 0; margin-bottom: 1.2em; border-top: 1px solid var(--ash-line); }
.run-sheet div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--ash-line); }
.run-sheet time { font: 800 1.3rem/1.2 var(--display); }
.run-sheet p { margin: 0; }

.confirm-table td:first-child { font-weight: 700; white-space: nowrap; }

.student-card .student-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 16px; }
.student-card .student-head h2 { font: 800 2rem/1 var(--display); margin: 0; }
.student-card .student-head .meta { color: var(--ink-soft); font-size: .95rem; }
.student-card .student-head .button-row { margin-left: auto; }
.admin-weeks td, .admin-weeks th { padding: 6px 8px; }
.admin-weeks td.is-done { background: #cfe2c4; }
.admin-weeks tr.week-done th { box-shadow: inset 5px 0 0 var(--salvage-ink); }
.step-check { display: flex; align-items: center; justify-content: center; min-height: 32px; cursor: pointer; }
.step-check input { width: 22px; height: 22px; accent-color: var(--salvage-ink); cursor: pointer; }
.avatar-select {
  padding: 6px 8px; border: 2px solid var(--ash-line); border-radius: 3px;
  background: var(--ash-raised); color: var(--ink); font-size: .9rem;
}
.add-student h2 { font: 800 2rem/1 var(--display); }
.add-student-fields { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 16px 32px; align-items: start; margin-bottom: 16px; }
.add-student .form-status { margin: 12px 0 0; }
.small-button { padding: 6px 10px; border: 2px solid var(--ink); border-radius: 3px; background: transparent; color: var(--ink); font-weight: 700; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.small-button.danger { border-color: var(--sensor-ink); color: var(--sensor-ink); }

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

.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  padding: 28px var(--gutter); border-top: 1px solid var(--night-line); color: var(--bone-soft); font-size: .95rem;
}

/* ---------- small screens ---------- */

@media (max-width: 1080px) {
  .week-layout { grid-template-columns: minmax(0, 1fr); }
  .week-aside { position: static; }
  .teacher-layout { grid-template-columns: minmax(0, 1fr); }
  .teacher-index { position: static; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (max-width: 820px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .bar { position: static; flex-wrap: wrap; gap: 8px 16px; }
  .bar nav { margin-left: 0; width: 100%; }
  .weeks-nav { position: static; }
  .step { grid-template-columns: minmax(0, 1fr); }
  .step-num { font-size: 2.8rem; margin-bottom: 4px; }
  .week-head { grid-template-columns: minmax(0, 1fr); }
  .week-head .num { grid-row: auto; font-size: 4.5rem; }
  .route { padding-top: 64px; }
  .add-student-fields { grid-template-columns: minmax(0, 1fr); }
  .runner b { display: none; }
}

@media print {
  body { background: #fff; color: #000; }
  .bar, .weeks-nav, .foot, .notice { display: none !important; }
  .js .week:not(.is-active) { display: block; }
  .sheet, .panel { background: #fff; color: #000; border: 1px solid #999; }
}
