/* ------------------------------------------------------------------
   algebra.li — Linear Algebra I, exercise class
   Palette: graph paper, blue-black ink, red and blue marking pens.
------------------------------------------------------------------ */

:root {
  --paper:        #F3F5F1;
  --paper-raised: #FAFBF8;
  --rule:         #D8DED4;
  --rule-strong:  #BCC5B8;
  --ink:          #17222B;
  --ink-soft:     #4E5A63;
  --ink-faint:    #7D8890;
  --red:          #C2402E;
  --red-wash:     #F6E4E0;
  --blue:         #2B5C9E;
  --blue-wash:    #E2E9F3;
  --green:        #2F6B4F;

  --measure: 34rem;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --shell: 74rem;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  color-scheme: light;
}

[data-theme="dark"] {
  --paper:        #0F1419;
  --paper-raised: #161E25;
  --rule:         #27333D;
  --rule-strong:  #3A4854;
  --ink:          #E7EAE4;
  --ink-soft:     #A3AEB6;
  --ink-faint:    #6F7D87;
  --red:          #EE8069;
  --red-wash:     #2E1D19;
  --blue:         #75A9E2;
  --blue-wash:    #16232F;
  --green:        #6FC79B;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  font-synthesis-weight: none;
}

::selection { background: var(--red); color: var(--paper); }

a { color: inherit; }

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

/* ---------------------------------------------------------- shell */

.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

/* --------------------------------------------------------- header */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.wordmark {
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.wordmark b { font-weight: 500; }

.nav {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2.4vw, 1.75rem);
  font-size: 0.875rem;
}

.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding-block: 0.25rem;
  border-bottom: 1px solid transparent;
}

.nav a:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--red); }

.switches { display: flex; align-items: center; gap: 0.4rem; }

.switch {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  line-height: 1.2;
}

.switch:hover { color: var(--ink); border-color: var(--rule-strong); }

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

.hero { position: relative; border-bottom: 1px solid var(--rule); overflow: hidden; }

.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hero__inner {
  position: relative;
  display: grid;
  gap: 2rem;
  min-height: min(38rem, 74vh);
  align-content: center;
  padding-block: clamp(3rem, 9vw, 6rem);
  pointer-events: none;
}

.hero__inner > * { pointer-events: auto; }

.hero__course {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--ink-faint);
  margin: 0 0 1.25rem;
  white-space: pre-line;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.1rem, 5.4vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 1.1rem;
  max-width: 15ch;
}

.hero__lede {
  margin: 0 0 1.75rem;
  max-width: 32ch;
  color: var(--ink-soft);
  font-size: 1rem;
}

.hero__text { max-width: 30rem; }

.hero__actions { display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem; }

.hero__readout {
  position: absolute;
  right: var(--gutter);
  bottom: 1.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.7;
  color: var(--ink-faint);
  text-align: right;
  white-space: pre;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.hero__readout:hover { color: var(--ink-soft); }

.hero__hint {
  display: block;
  margin-top: 0.5rem;
  color: var(--red);
  opacity: 0;
  transition: opacity 160ms ease;
  white-space: nowrap;
}

.hero__readout:hover .hero__hint,
.hero__readout:focus-visible .hero__hint { opacity: 1; }

@media (max-width: 40rem) {
  .hero__readout { display: none; }
  .hero__canvas { opacity: 0.5; }
}

/* ---------------------------------------------------------- links */

.link {
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 1px;
  color: var(--ink);
  font-size: 0.9375rem;
}

.link:hover { border-bottom-color: var(--red); color: var(--red); }

.link--quiet { color: var(--ink-soft); border-bottom-color: transparent; }
.link--quiet:hover { color: var(--red); border-bottom-color: var(--red); }

/* -------------------------------------------------------- section */

.band { padding-block: clamp(2.75rem, 6vw, 4.5rem); border-bottom: 1px solid var(--rule); }
.band:last-of-type { border-bottom: 0; }
.pagehead + .band,
.pagehead + div > .band:first-child,
#groups .band:first-child { padding-top: clamp(1.5rem, 3vw, 2.25rem); }

.band__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.band__head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin: 0;
}

.band__note { font-size: 0.8125rem; color: var(--ink-faint); margin: 0; }

/* ------------------------------------------------------ this week */

.current {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0 clamp(1rem, 3vw, 2.5rem);
  align-items: start;
}

.current__index {
  font-family: var(--mono);
  font-size: 2.25rem;
  line-height: 1;
  color: var(--red);
  letter-spacing: -0.04em;
}

.current__date { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-faint); margin: 0.5rem 0 0; }

.current h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

.current__topics { color: var(--ink-soft); margin: 0 0 1.5rem; max-width: var(--measure); }

/* ------------------------------------------------------- material */

.material { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }

.material a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.4rem 0.7rem;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--paper-raised);
}

.material a:hover { border-color: var(--red); color: var(--red); }

.material .kind { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-faint); }
.material a:hover .kind { color: var(--red); }

.material a[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* ---------------------------------------------------- week ledger */

.ledger { border-top: 1px solid var(--rule); }

.ledger__row {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0 clamp(0.75rem, 2vw, 1.5rem);
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: var(--ink);
}

.ledger__row:hover { background: var(--paper-raised); }
.ledger__row:hover .ledger__title { color: var(--red); }

.ledger__n { font-family: var(--mono); font-size: 0.8125rem; color: var(--ink-faint); }
.ledger__title { font-size: 0.9375rem; }
.ledger__date { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-faint); }

.ledger__row--now .ledger__n { color: var(--red); }
.ledger__row--now .ledger__title { font-weight: 700; }

.ledger__row--void { color: var(--ink-faint); pointer-events: none; }
.ledger__row--void .ledger__title { color: var(--ink-faint); }

/* ------------------------------------------------------ resources */

.stack { list-style: none; margin: 0; padding: 0; }

.stack li { border-bottom: 1px solid var(--rule); padding: 1rem 0; }
.stack li:first-child { border-top: 1px solid var(--rule); }

.stack h3 { margin: 0 0 0.25rem; font-size: 1rem; font-weight: 700; }
.stack h3 a { text-decoration: none; }
.stack h3 a:hover { color: var(--red); }
.stack p { margin: 0; color: var(--ink-soft); font-size: 0.875rem; max-width: var(--measure); }

.stack__meta { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); }

/* ---------------------------------------------------------- quote */

.quote { padding-block: clamp(3rem, 7vw, 5rem); border-bottom: 1px solid var(--rule); }
.quote svg { display: block; width: 100%; height: auto; margin-bottom: 2rem; }

.quote blockquote {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  line-height: 1.45;
  max-width: 44ch;
}

.quote figcaption { margin-top: 1.25rem; font-size: 0.8125rem; color: var(--ink-faint); }

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

.foot { padding-block: 2.5rem 3.5rem; font-size: 0.875rem; color: var(--ink-soft); }
.foot__grid { display: grid; gap: 1.75rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.foot h2 { font-size: 0.8125rem; font-weight: 700; margin: 0 0 0.5rem; color: var(--ink); }
.foot p { margin: 0 0 0.35rem; }
.foot .colophon { margin-top: 2.5rem; font-size: 0.75rem; color: var(--ink-faint); max-width: var(--measure); }

/* ------------------------------------------------------ page head */

.pagehead { padding-block: clamp(2.5rem, 6vw, 4rem) 2rem; border-bottom: 1px solid var(--rule); }
.pagehead h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 4.6vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 0.75rem;
  max-width: 20ch;
}
.pagehead p { margin: 0; color: var(--ink-soft); max-width: var(--measure); }
.pagehead__kicker { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-faint); margin: 0 0 1rem; }

/* ------------------------------------------------------ week page */

.weekbody {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 0 clamp(1rem, 4vw, 3rem);
  padding-block: 2.5rem 3.5rem;
}

.weekbody__margin { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-faint); line-height: 1.9; }
.weekbody__margin b { display: block; color: var(--ink); font-weight: 500; }
.weekbody__main > * { max-width: var(--measure); }
.weekbody__main h2 { font-family: var(--serif); font-weight: 400; font-size: 1.25rem; margin: 2.25rem 0 0.75rem; }
.weekbody__main h2:first-child { margin-top: 0; }
.weekbody__main p { color: var(--ink-soft); }
.weekbody__main .material { max-width: none; }

.pager { display: flex; justify-content: space-between; gap: 1rem; padding-block: 1.5rem 3rem; border-top: 1px solid var(--rule); }

@media (max-width: 46rem) {
  .weekbody, .current { grid-template-columns: minmax(0, 1fr); }
  .weekbody__margin { margin-bottom: 1.5rem; }
  .current__index { font-size: 1.5rem; }
}

/* ----------------------------------------------------------- game */

.play { padding-block: 2rem 3.5rem; }

.play__frame {
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper-raised);
  overflow: hidden;
}

.play__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.target { display: flex; align-items: center; gap: 0.75rem; }
.target__label { font-size: 0.8125rem; color: var(--ink-soft); }

.bracket { display: flex; align-items: stretch; gap: 0.35rem; }
.bracket__l, .bracket__r { width: 0.4rem; border: 1.5px solid var(--ink); }
.bracket__l { border-right: 0; }
.bracket__r { border-left: 0; }
.bracket__col { font-family: var(--mono); font-size: 1rem; line-height: 1.4; text-align: center; min-width: 2.6rem; font-variant-numeric: tabular-nums; }

.play__stats { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.play__stage { position: relative; height: min(34rem, 68vh); cursor: crosshair; }
.play__stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.play__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}

.play__hint { font-size: 0.875rem; margin: 0; }
.play__hint--good { color: var(--green); }
.play__hint--miss { color: var(--red); }

.ladder { display: flex; align-items: center; gap: 0.35rem; }
.ladder__pip {
  width: 1.5rem; height: 0.3rem;
  background: var(--rule);
  border-radius: 1px;
}
.ladder__pip--done { background: var(--rule-strong); }
.ladder__pip--now { background: var(--red); }
.ladder__name { font-size: 0.8125rem; color: var(--ink-soft); margin-left: 0.5rem; }

.levelcard {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--red);
  border-radius: 0;
  background: var(--paper-raised);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  max-width: var(--measure);
}
.levelcard h2 { font-family: var(--serif); font-weight: 400; font-size: 1.1rem; margin: 0 0 0.35rem; }
.levelcard p { margin: 0; font-size: 0.875rem; color: var(--ink-soft); }

.rules { list-style: none; margin: 0; padding: 0; font-size: 0.875rem; color: var(--ink-soft); }
.rules li { padding: 0.4rem 0; border-bottom: 1px solid var(--rule); display: flex; gap: 0.75rem; }
.rules li:last-child { border-bottom: 0; }
.rules b { font-family: var(--mono); font-weight: 400; color: var(--ink); min-width: 4.5rem; font-size: 0.8125rem; }

/* --------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--paper);
  padding: 0.5rem 0.85rem; z-index: 50;
}
.skip:focus { left: var(--gutter); top: 0.5rem; }
