/* ---------------------------------------------------------------------------
   Teaching platform — visual language
   The page is a study notebook: a ruled margin carries the learner's position
   and their marks, the reading column stays quiet, and the only loud moment in
   the interface is the result of an attempt.
--------------------------------------------------------------------------- */

:root {
  --paper:        #FBFCFD;
  --paper-sunk:   #F1F4F8;
  --grid:         #E4EAF1;
  --rule:         #D5DDE7;
  --ink:          #16202B;
  --ink-soft:     #4A586A;
  --ink-faint:    #77869A;

  --indigo:       #2E4A8C;
  --indigo-wash:  #EDF1FA;
  --correct:      #12695A;
  --correct-wash: #E6F2EF;
  --hint:         #8A5A00;
  --hint-wash:    #FBF2DF;
  --spent:        #8E2C2C;
  --spent-wash:   #F8EDED;

  --serif: Literata, Charter, Georgia, "Times New Roman", serif;
  --sans:  Archivo, "Helvetica Neue", system-ui, -apple-system, sans-serif;

  --measure: 64ch;
  --radius: 3px;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: "kern", "liga";
}

/* The 4mm rule behind the reading column. Quiet enough to read through. */
.gridded {
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 18px 18px;
  background-position: -1px -1px;
}
@media (max-width: 720px) { .gridded { background-image: none; } }

a { color: var(--indigo); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3, h4, .ui { font-family: var(--sans); }
h1 { font-size: 1.9rem; line-height: 1.18; letter-spacing: -0.015em; margin: 0 0 .4em; font-weight: 620; }
h2 { font-size: 1.35rem; line-height: 1.25; margin: 2rem 0 .5em; font-weight: 600; }
h3 { font-size: 1.1rem; margin: 1.6rem 0 .4em; font-weight: 600; }
p, ul, ol, table { margin: 0 0 1em; }
code, pre, .mono { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9em; }

/* ------------------------------------------------------------------ chrome */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky; top: 0; z-index: 20;
}
.masthead__inner {
  max-width: 1180px; margin: 0 auto; padding: .7rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem;
}
.wordmark {
  font-family: var(--sans); font-weight: 660; font-size: 1.02rem;
  letter-spacing: -0.01em; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: baseline; gap: .45rem;
}
.wordmark span { color: var(--indigo); font-weight: 500; }
.masthead nav { margin-left: auto; display: flex; gap: 1.1rem; align-items: center; font-family: var(--sans); font-size: .92rem; }
.masthead nav a { color: var(--ink-soft); text-decoration: none; }
.masthead nav a:hover, .masthead nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

.shell { max-width: 1180px; margin: 0 auto; padding: 2rem 1.25rem 5rem; }
.shell--reading { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); gap: 3rem; align-items: start; }
@media (max-width: 900px) { .shell--reading { grid-template-columns: 1fr; gap: 1.5rem; } }

.column { max-width: var(--measure); }

footer.site {
  border-top: 1px solid var(--rule); color: var(--ink-faint);
  font-family: var(--sans); font-size: .85rem;
  padding: 1.5rem 1.25rem; max-width: 1180px; margin: 0 auto;
}

/* --------------------------------------------------------------- the rail */

.rail { position: sticky; top: 4.5rem; font-family: var(--sans); font-size: .92rem; }
.rail__subject { color: var(--ink-faint); text-decoration: none; display: block; margin-bottom: .2rem; }
.rail__topic { font-weight: 600; font-size: 1rem; margin: 0 0 1rem; line-height: 1.3; }

.path { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--rule); }
.path li { position: relative; }
.path a {
  display: block; padding: .42rem 0 .42rem 1rem; color: var(--ink-soft);
  text-decoration: none; line-height: 1.35;
}
.path a:hover { color: var(--ink); }
.path li::before {
  content: ""; position: absolute; left: -5px; top: .78rem;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--rule);
}
.path li.seen::before { background: var(--ink-faint); border-color: var(--ink-faint); }
.path li.current::before { background: var(--indigo); border-color: var(--indigo); }
.path li.current a { color: var(--ink); font-weight: 600; }
.path li.done::before { background: var(--correct); border-color: var(--correct); }
.path .check-step a { font-style: italic; }

/* ------------------------------------------------------------------- cards */

.stack { display: grid; gap: 1rem; }

.subject-card {
  display: block; border: 1px solid var(--rule); border-left: 3px solid var(--indigo);
  background: var(--paper); padding: 1.1rem 1.25rem; text-decoration: none; color: inherit;
  border-radius: var(--radius);
}
.subject-card:hover { border-left-color: var(--ink); background: #fff; }
.subject-card h2 { margin: 0 0 .3rem; font-size: 1.18rem; }
.subject-card p { margin: 0 0 .5rem; color: var(--ink-soft); }

.meta { font-family: var(--sans); font-size: .85rem; color: var(--ink-faint); display: flex; gap: 1.1rem; flex-wrap: wrap; }

.tag {
  font-family: var(--sans); font-size: .74rem; font-weight: 600;
  padding: .12rem .45rem; border-radius: 2px; border: 1px solid currentColor; color: var(--ink-faint);
}
.tag--restricted { color: var(--hint); }
.tag--registered { color: var(--indigo); }
.tag--draft { color: var(--spent); }

/* ------------------------------------------------------------ topic list */

.topic-list { list-style: none; margin: 0; padding: 0; counter-reset: topic; }
.topic-row {
  display: grid; grid-template-columns: 2.4rem 1fr auto; gap: 1rem; align-items: baseline;
  padding: .95rem 0; border-bottom: 1px solid var(--rule);
}
.topic-row__n {
  counter-increment: topic; font-family: var(--sans); font-size: .95rem;
  color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.topic-row__n::before { content: counter(topic, decimal-leading-zero); }
.topic-row h3 { margin: 0 0 .15rem; font-size: 1.05rem; }
.topic-row p { margin: 0; color: var(--ink-soft); font-size: .95rem; }
.topic-row--locked { color: var(--ink-faint); }
.topic-row--locked h3 { color: var(--ink-faint); }
.topic-row--done .topic-row__n { color: var(--correct); }

.score {
  font-family: var(--sans); font-size: .85rem; font-variant-numeric: tabular-nums;
  color: var(--ink-soft); white-space: nowrap;
}
.score strong { color: var(--correct); }

/* --------------------------------------------------------- content blocks */

.tp-body > * { max-width: var(--measure); }
.tp-body figure { margin: 1.8rem 0; max-width: 100%; }
.tp-body figure img, .tp-body video, .tp-body .lottie { max-width: 100%; height: auto; display: block; border-radius: var(--radius); }
.tp-body figcaption { font-family: var(--sans); font-size: .85rem; color: var(--ink-faint); margin-top: .5rem; }
.tp-body blockquote { margin: 1.4rem 0; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--ink-soft); }
.tp-body table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.tp-body th, .tp-body td { border: 1px solid var(--rule); padding: .45rem .6rem; text-align: left; }
.tp-body th { background: var(--paper-sunk); font-family: var(--sans); font-weight: 600; }
.embed { position: relative; padding-top: 56.25%; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.formula { margin: 1.5rem 0; overflow-x: auto; }
.formula--display { text-align: center; }
.formula__caption { font-family: var(--sans); font-size: .85rem; color: var(--ink-faint); text-align: center; }

.callout {
  margin: 1.5rem 0; padding: .9rem 1.1rem; border-left: 3px solid var(--indigo);
  background: var(--indigo-wash); border-radius: 0 var(--radius) var(--radius) 0;
}
.callout--warning { border-left-color: var(--hint); background: var(--hint-wash); }
.callout--definition { border-left-color: var(--correct); background: var(--correct-wash); }
.callout--example { border-left-color: var(--ink-faint); background: var(--paper-sunk); }
.callout h4 { font-size: .95rem; margin: 0 0 .3rem; }
.callout > :last-child { margin-bottom: 0; }

/* -------------------------------------------------------------- questions */

.questions { margin-top: 3rem; border-top: 2px solid var(--ink); padding-top: 1.2rem; }
.questions > h2 { margin-top: 0; }
.questions__intro { color: var(--ink-soft); font-size: .97rem; max-width: var(--measure); }

.q {
  --state: var(--rule);
  position: relative; margin: 1.5rem 0; padding: 1.2rem 1.3rem 1.3rem 1.5rem;
  border: 1px solid var(--rule); border-left: 4px solid var(--state);
  background: #fff; border-radius: var(--radius);
}
.q[data-state="correct"]   { --state: var(--correct); background: var(--correct-wash); }
.q[data-state="exhausted"] { --state: var(--spent); background: var(--spent-wash); }
.q[data-state="in_progress"][data-attempts="1"] { --state: var(--hint); background: var(--hint-wash); }

.q__head { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .6rem; }
.q__n { font-family: var(--sans); font-weight: 600; font-size: .85rem; color: var(--ink-faint); }
.q__points { margin-left: auto; font-family: var(--sans); font-size: .82rem; color: var(--ink-faint); }

/* The attempt ladder — the marks a teacher would leave in the margin. */
.ladder { display: inline-flex; gap: 3px; }
.ladder i {
  width: 9px; height: 9px; border: 1.5px solid var(--ink-faint); border-radius: 2px;
  display: block; background: transparent;
}
.ladder i.used { background: var(--spent); border-color: var(--spent); }
.ladder i.won  { background: var(--correct); border-color: var(--correct); }

.q__prompt > :last-child { margin-bottom: .8rem; }

.options { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .4rem; }
.option {
  display: flex; gap: .65rem; align-items: flex-start; padding: .55rem .75rem;
  border: 1px solid var(--rule); border-radius: var(--radius); cursor: pointer; background: var(--paper);
}
.option:hover { border-color: var(--indigo); }
.option input { margin-top: .32rem; }
.option--chosen { border-color: var(--indigo); background: var(--indigo-wash); }

.blank-input, .value-input, textarea.text-input {
  font: inherit; font-family: var(--sans); padding: .3rem .5rem;
  border: 1px solid var(--ink-faint); border-radius: 2px; background: #fff; color: var(--ink);
}
.blank-input { width: 7ch; text-align: center; }
.blank-input[data-wrong="1"] { border-color: var(--spent); background: var(--spent-wash); }
.blank-input[data-wrong="0"] { border-color: var(--correct); background: var(--correct-wash); }
textarea.text-input { width: 100%; }
.value-row { display: flex; gap: .5rem; align-items: center; font-family: var(--sans); }
.blank-sentence { line-height: 2.4; }

.hotspot { position: relative; display: inline-block; max-width: 100%; cursor: crosshair; }
.hotspot img { display: block; max-width: 100%; height: auto; }
.hotspot__pin {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 2px solid var(--indigo); border-radius: 50%; background: rgba(46,74,140,.25);
}
.label-targets { position: relative; display: inline-block; }
.label-target {
  position: absolute; transform: translate(-50%, -50%);
  background: #fff; border: 1px solid var(--indigo); border-radius: 2px; padding: .1rem;
}
.label-target select { font: inherit; font-family: var(--sans); font-size: .82rem; border: 0; background: transparent; }

.q__feedback { margin-top: .9rem; font-size: .97rem; }
.q__feedback:empty { margin: 0; }
.verdict { font-family: var(--sans); font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.verdict--correct { color: var(--correct); }
.verdict--wrong { color: var(--hint); }
.verdict--spent { color: var(--spent); }
.reveal { margin-top: .7rem; padding: .8rem 1rem; border-radius: var(--radius); background: var(--paper-sunk); }
.reveal h4 { font-family: var(--sans); font-size: .88rem; margin: 0 0 .35rem; color: var(--ink-soft); }
.reveal > :last-child { margin-bottom: 0; }
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: unfold .22s ease-out; }
  @keyframes unfold { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}

/* -------------------------------------------------------------- controls */

.btn {
  font-family: var(--sans); font-size: .93rem; font-weight: 550;
  padding: .5rem .95rem; border-radius: var(--radius); border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper); cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { background: #000; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn--quiet { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--quiet:hover { background: var(--paper-sunk); border-color: var(--ink-faint); }
.btn--small { font-size: .84rem; padding: .3rem .6rem; }
.btn--danger { background: var(--spent); border-color: var(--spent); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); font-family: var(--sans); }
.pager a { text-decoration: none; }

.notice {
  border: 1px solid var(--rule); border-left: 3px solid var(--indigo); background: var(--indigo-wash);
  padding: 1rem 1.15rem; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1.5rem;
}
.notice--warn { border-left-color: var(--hint); background: var(--hint-wash); }
.notice--error { border-left-color: var(--spent); background: var(--spent-wash); }
.notice h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.notice p { margin: 0 0 .6rem; }
.notice__actions { display: flex; gap: .6rem; align-items: center; font-family: var(--sans); font-size: .9rem; }

.badge-toast {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50;
  background: var(--ink); color: var(--paper); padding: .8rem 1rem; border-radius: var(--radius);
  font-family: var(--sans); font-size: .9rem; max-width: 20rem; box-shadow: 0 6px 24px rgba(22,32,43,.25);
}
.badge-toast strong { display: block; }

/* ----------------------------------------------------------------- forms */

.form { max-width: 34rem; }
.form--wide { max-width: 56rem; }
.field { margin-bottom: 1.1rem; }
.field > label { display: block; font-family: var(--sans); font-size: .88rem; font-weight: 600; margin-bottom: .25rem; }
.field .help { font-family: var(--sans); font-size: .82rem; color: var(--ink-faint); margin-top: .25rem; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field select, .field textarea {
  width: 100%; font: inherit; font-family: var(--sans); font-size: .95rem;
  padding: .45rem .6rem; border: 1px solid var(--ink-faint); border-radius: 2px; background: #fff;
}
.field textarea { min-height: 6rem; }
.field--inline { display: flex; gap: .6rem; align-items: center; }
.field--inline label { margin: 0; font-weight: 400; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; }
.checks { display: grid; gap: .3rem; font-family: var(--sans); font-size: .9rem; }

/* --------------------------------------------------------- writers panel */

.panel { display: grid; grid-template-columns: minmax(0,1fr); gap: 2rem; }
.panel-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.panel-head h1 { margin: 0; }
.panel-head .btn { margin-left: auto; }
.crumbs { font-family: var(--sans); font-size: .87rem; color: var(--ink-faint); margin-bottom: .4rem; }
.crumbs a { color: var(--ink-soft); }

table.list { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: .92rem; }
table.list th { text-align: left; font-weight: 600; color: var(--ink-soft); border-bottom: 2px solid var(--ink); padding: .45rem .5rem; }
table.list td { border-bottom: 1px solid var(--rule); padding: .5rem .5rem; vertical-align: middle; }
table.list tr:hover td { background: var(--paper-sunk); }
.drag-handle { cursor: grab; color: var(--ink-faint); }

.block-editor { display: grid; gap: .75rem; }
.block {
  border: 1px solid var(--rule); border-left: 3px solid var(--ink-faint);
  border-radius: var(--radius); padding: .75rem .9rem; background: #fff;
}
.block__bar { display: flex; align-items: center; gap: .5rem; font-family: var(--sans); font-size: .84rem; color: var(--ink-soft); margin-bottom: .5rem; }
.block__bar .spacer { margin-left: auto; }
.block textarea, .block input { width: 100%; font-family: var(--sans); font-size: .9rem; padding: .35rem .5rem; border: 1px solid var(--rule); border-radius: 2px; }
.block textarea { min-height: 4.5rem; }
.preview { border: 1px dashed var(--rule); border-radius: var(--radius); padding: 1rem 1.2rem; background: var(--paper); }

.split { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 2rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.muted { color: var(--ink-faint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spread { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
