/* LearnWell: the palette, and the student's pages.
 *
 * The colours are defined once here as tokens. `admin-theme.css` maps these
 * same tokens onto Django's admin variables, so changing a colour changes
 * both faces of the application rather than one of them.
 *
 * Green carries the brand and amber marks progress, a considered nod to the
 * Ethiopian flag rather than a copy of it. Red is reserved for errors and is
 * never used decoratively, so that "something went wrong" always reads as
 * exactly that.
 *
 * Both light and dark are first-class: a student reading in the evening
 * should not be handed a white page.
 */

:root {
  --lw-ink: #17201b;
  --lw-ink-muted: #5a665e;
  --lw-paper: #fbfaf6;
  --lw-paper-raised: #ffffff;
  --lw-edge: #dfe2da;

  --lw-green: #1f6b4a;
  --lw-green-strong: #17513a;
  --lw-green-soft: #e6f0ea;
  --lw-on-green: #ffffff;

  /* The top bar keeps its deep green and white text in both themes, so the
     name always reads bright white (#122). White on #1f6b4a measures 6.4:1.
     Not overridden for dark mode below, deliberately: the dark theme's
     lighter green would give white text only 2.6:1. */
  --lw-bar: #1f6b4a;
  --lw-on-bar: #ffffff;

  /* Two ambers, because one cannot pass both tests. The fill is a UI
     element needing 3:1 against its track; the badge is small text needing
     4.5:1 against the soft background. A single mid amber failed both. */
  --lw-amber: #a96e1c;
  --lw-amber-text: #8c5a12;
  --lw-amber-soft: #fbf1de;

  --lw-red: #b3261e;
  --lw-red-soft: #fbeae9;

  /* The heatmap's four shades (D-033): two tints mixed from the green
     toward the page, then the green and the strong green themselves. Every
     shade clears 3:1 against the page in both skins (light 3.26, 4.48, 6.17,
     8.84; dark 3.30, 4.89, 6.96, 9.03) and each step is a visible lightness
     step from the last. The dark tints use less green because the dark page
     is further from it. A test measures these from this file. */
  --lw-heat-1: color-mix(in srgb, var(--lw-green) 70%, var(--lw-paper));
  --lw-heat-2: color-mix(in srgb, var(--lw-green) 85%, var(--lw-paper));
  --lw-heat-3: var(--lw-green);
  --lw-heat-4: var(--lw-green-strong);

  --lw-radius: 8px;
  --lw-measure: 42rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --lw-ink: #e8efe9;
    --lw-ink-muted: #96a29a;
    --lw-paper: #12171a;
    --lw-paper-raised: #1a2126;
    --lw-edge: #2b343a;

    --lw-green: #4bb387;
    --lw-green-strong: #6cc9a1;
    --lw-green-soft: #16302a;
    --lw-on-green: #07130f;

    --lw-amber: #e0a44a;
    --lw-amber-text: #e8b76a;
    --lw-amber-soft: #2e2415;

    --lw-red: #f2b8b5;
    --lw-red-soft: #331a19;

    --lw-heat-1: color-mix(in srgb, var(--lw-green) 60%, var(--lw-paper));
    --lw-heat-2: color-mix(in srgb, var(--lw-green) 80%, var(--lw-paper));
    --lw-heat-3: var(--lw-green);
    --lw-heat-4: var(--lw-green-strong);
  }
}

/* ---------------------------------------------------------------- shell */

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--lw-paper);
  color: var(--lw-ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Generous for reading mathematics for half an hour at a time. */
  font-size: 1.0625rem;
  line-height: 1.65;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.page {
  max-width: var(--lw-measure);
  margin: 0 auto;
  padding: 1.5rem 16px 5rem;
}

a {
  color: var(--lw-green);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--lw-green-strong);
}

h1 {
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 2rem 0 0.5rem;
}

h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.4rem;
  color: var(--lw-ink-muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.muted {
  color: var(--lw-ink-muted);
}

.crumbs {
  font-size: 0.85rem;
  color: var(--lw-ink-muted);
  margin: 0 0 0.35rem;
}

/* --------------------------------------------------------------- header */

.bar {
  background: var(--lw-bar);
  color: var(--lw-on-bar);
}

.bar .page {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding-block: 0.7rem;
}

.bar a,
.bar a:hover {
  color: var(--lw-on-bar);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.bar .who {
  margin-left: auto;
  font-size: 0.85rem;
  opacity: 0.9;
}

/* -------------------------------------------------------------- buttons */

button,
.button {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--lw-radius);
  background: var(--lw-green);
  color: var(--lw-on-green);
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--lw-green-strong);
}

.bar button {
  background: transparent;
  border-color: color-mix(in srgb, var(--lw-on-bar) 45%, transparent);
  color: var(--lw-on-bar);
  padding-block: 0.3rem;
}

.bar button:hover {
  background: color-mix(in srgb, var(--lw-on-bar) 12%, transparent);
}

/* --------------------------------------------------------------- lesson */

.lesson-list {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
}

.lesson-list li {
  border-bottom: 1px solid var(--lw-edge);
}

.lesson-list a {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.7rem 0.25rem;
  text-decoration: none;
}

.lesson-list a:hover {
  background: var(--lw-green-soft);
}

.lesson-list .state {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--lw-ink-muted);
  white-space: nowrap;
}

.lesson-list .state.done {
  color: var(--lw-green);
  font-weight: 600;
}

.block {
  padding: 1.35rem 0;
  border-bottom: 1px solid var(--lw-edge);
}

.block h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.block img {
  max-width: 100%;
  height: auto;
  border-radius: var(--lw-radius);
}

/* Amber marks having been read: progress, not success or failure. */
.block.seen {
  position: relative;
}

.block.seen::after {
  content: "read";
  position: absolute;
  top: 1.45rem;
  right: 0;
  font-size: 0.7rem;
  color: var(--lw-amber-text);
  background: var(--lw-amber-soft);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

#progress {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--lw-paper);
  border-bottom: 1px solid var(--lw-edge);
  padding: 0.6rem 0 0.7rem;
  font-size: 0.85rem;
  color: var(--lw-ink-muted);
}

#bar {
  height: 5px;
  border-radius: 999px;
  background: var(--lw-edge);
  margin-top: 0.4rem;
  overflow: hidden;
}

#bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--lw-amber);
  transition: width 0.35s ease;
}

#progress.complete #bar span {
  background: var(--lw-green);
}

/* ----------------------------------------------------------------- sign in */

.signin {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.signin .card {
  width: 100%;
  max-width: 22rem;
  background: var(--lw-paper-raised);
  border: 1px solid var(--lw-edge);
  border-radius: calc(var(--lw-radius) * 1.5);
  padding: 2rem 1.75rem;
}

/* The name sits on the bar's deep green, white in both themes (#122), as
   in the header: on the card's own background white would vanish in light
   mode. The band runs edge to edge across the top of the card. */
.signin h1 {
  margin: -2rem -1.75rem 1.5rem;
  padding: 1rem 1.75rem;
  background: var(--lw-bar);
  color: var(--lw-on-bar);
  border-radius: calc(var(--lw-radius) * 1.5) calc(var(--lw-radius) * 1.5) 0 0;
}

.signin label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.signin input {
  width: 100%;
  font: inherit;
  padding: 0.6rem 0.7rem;
  margin-bottom: 1rem;
  background: var(--lw-paper);
  color: var(--lw-ink);
  border: 1px solid var(--lw-edge);
  border-radius: var(--lw-radius);
}

.signin input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--lw-green);
  outline-offset: 2px;
}

.signin button {
  width: 100%;
  padding-block: 0.65rem;
}

.errors {
  background: var(--lw-red-soft);
  color: var(--lw-red);
  border-radius: var(--lw-radius);
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ----------------------------------------------------------------- footer */

.site-footer {
  margin-top: 3rem;
  font-size: 0.75rem;
  color: var(--lw-ink-muted);
}

/* -------------------------------------------------------------- practice */

.question {
  padding: 1.35rem 0;
  border-bottom: 1px solid var(--lw-edge);
}

.q-number {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--lw-ink-muted);
  margin: 0 0 0.35rem;
}

.options {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}

.options li {
  padding: 0.35rem 0.5rem;
  border-radius: var(--lw-radius);
}

.options label {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  cursor: pointer;
}

/* On a result, mark the answer and what was chosen. Never colour alone:
   the words "correct" and "not correct" carry the meaning, so a student who
   cannot distinguish the colours loses nothing. */
.options li.is-correct {
  background: var(--lw-green-soft);
}

.options li.chosen:not(.is-correct) {
  background: var(--lw-red-soft);
}

.options .feedback {
  display: block;
  font-size: 0.85rem;
  color: var(--lw-ink-muted);
  margin-top: 0.2rem;
}

.typed {
  font: inherit;
  padding: 0.5rem 0.65rem;
  margin-top: 0.75rem;
  min-width: 14rem;
  background: var(--lw-paper-raised);
  color: var(--lw-ink);
  border: 1px solid var(--lw-edge);
  border-radius: var(--lw-radius);
}

.verdict {
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  margin-left: 0.4rem;
  letter-spacing: 0;
  text-transform: none;
}

.verdict.right {
  color: var(--lw-green);
  background: var(--lw-green-soft);
}

.verdict.wrong {
  color: var(--lw-red);
  background: var(--lw-red-soft);
}

.verdict.skipped {
  color: var(--lw-amber-text);
  background: var(--lw-amber-soft);
}

.score {
  font-size: 1.4rem;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.score .muted {
  font-size: 0.85rem;
}

.score.passed strong {
  color: var(--lw-green);
}

.note {
  background: var(--lw-green-soft);
  border-radius: var(--lw-radius);
  padding: 0.6rem 0.8rem;
}

.note.done {
  font-weight: 600;
  color: var(--lw-green);
}

.explanation {
  margin-top: 0.75rem;
  padding-left: 0.8rem;
  border-left: 3px solid var(--lw-amber);
  color: var(--lw-ink-muted);
}

a.button {
  display: inline-block;
  text-decoration: none;
}

/* -------------------------------------------------------------- guardian */

.tiles {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.25rem 0 0.5rem;
}

.tile {
  flex: 1 1 8rem;
  background: var(--lw-green-soft);
  border-radius: var(--lw-radius);
  padding: 0.85rem 1rem;
}

.tile .figure {
  display: block;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--lw-green);
}

.tile .label {
  display: block;
  font-size: 0.78rem;
  color: var(--lw-ink-muted);
}

/* A guardian's lists are read rather than clicked, so the row is a span and
   needs its own layout instead of the anchor styling above. */
.lesson-list .lesson-row {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.55rem 0.25rem 0;
}

.lesson-list .when {
  display: block;
  padding: 0 0.25rem 0.55rem;
  font-size: 0.75rem;
  color: var(--lw-ink-muted);
}

/* --- the weekly summary (D-018, #26) ------------------------------------
   Every colour here is an existing measured token. D-024 says a new pair
   has to be measured before it is used, so none is introduced: a week with
   less work in it is not an error, so it takes the amber, and red stays
   reserved. */

.weeks {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--lw-edge);
  font-size: 0.9rem;
}

.tile .against {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.72rem;
}

.up {
  color: var(--lw-green);
  font-weight: 600;
}

.down {
  color: var(--lw-amber-text);
  font-weight: 600;
}

/* Seven entries, always: a day with nothing on it is part of the shape of
   a week and is drawn rather than skipped. */
.week-days {
  display: flex;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 1.5rem;
  flex-wrap: wrap;
}

.week-days li {
  flex: 1 1 3.5rem;
  text-align: center;
  padding: 0.5rem 0.35rem;
  border-radius: var(--lw-radius);
  background: var(--lw-green-soft);
}

.week-days li.quiet {
  background: transparent;
  border: 1px dashed var(--lw-edge);
}

.week-days .day {
  display: block;
  font-size: 0.72rem;
  color: var(--lw-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.week-days .amount {
  display: block;
  font-weight: 600;
  color: var(--lw-ink);
}

.week-days li.quiet .amount {
  color: var(--lw-ink-muted);
  font-weight: 400;
}

/* An empty week is as worth saying as a busy one, so it gets a panel
   rather than a blank page. */
.empty-week {
  background: var(--lw-amber-soft);
  border-radius: var(--lw-radius);
  padding: 1rem 1.15rem;
  margin: 1.25rem 0;
}

.empty-week h2 {
  margin-top: 0;
}

/* --- one day, in order (D-032, #20) -------------------------------------
   Existing measured tokens only, per D-024. A day whose detail has aged out
   is not a fault, so its notice takes the amber, as a quiet week does. */

.day-note {
  background: var(--lw-amber-soft);
  border-radius: var(--lw-radius);
  padding: 1rem 1.15rem;
  margin: 1.25rem 0;
}

.day-note h2 {
  margin-top: 0;
}

.day-timeline {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  border-left: 2px solid var(--lw-edge);
}

.day-timeline li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.75rem;
  padding: 0.45rem 0 0.45rem 0.85rem;
}

.day-timeline .time {
  color: var(--lw-ink-muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 30rem) {
  .day-timeline li {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* Each day of the week opens its timeline; the tile keeps its own colours. */
.week-days a {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* --- spaced review (D-029, #18) -----------------------------------------
   Existing measured tokens only, per D-024. Work falling due is a prompt,
   not a fault, so it takes the green rather than the amber. */

.due {
  background: var(--lw-green-soft);
  border-radius: var(--lw-radius);
  padding: 1rem 1.15rem;
  margin: 1.25rem 0;
}

.due p {
  margin-top: 0;
}

.due strong {
  font-size: 1.3rem;
  color: var(--lw-green);
}

/* A review result is neither passed nor failed: there was nothing to pass. */
.score.reviewed strong {
  color: var(--lw-green);
}

/* --- vocabulary (D-011, D-030, #3) --------------------------------------
   Existing measured tokens only, per D-024. The reveal is a button in all
   but name, so it takes the button's pair; a missed card is the word
   "again" or "not correct" in the existing verdict badge, never a colour
   alone. */

details.grade > summary {
  cursor: pointer;
  list-style-position: outside;
  margin-left: 1.1rem;
}

details.grade > summary h2 {
  display: inline;
  margin: 0;
}

details.grade {
  margin: 2rem 0 0.5rem;
}

.list-meta {
  display: block;
  font-size: 0.8rem;
}

.word-standing .lesson-row {
  padding-bottom: 0.55rem;
}

.card-results .verdict {
  margin-left: auto;
}

.study-way h2 {
  font-size: 1.1rem;
}

fieldset.modes {
  border: 0;
  padding: 0;
  margin: 0 0 0.9rem;
}

fieldset.modes legend {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

fieldset.modes label {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  cursor: pointer;
}

.word-card {
  padding: 1.35rem 0;
  border-bottom: 1px solid var(--lw-edge);
}

/* Big enough to read across a table, because the word is the whole card. */
.headword {
  margin: 0.25rem 0 0;
}

.headword strong {
  font-size: 2rem;
  line-height: 1.2;
}

.word-facts {
  font-size: 0.9rem;
  margin: 0.2rem 0 0.75rem;
}

.pronunciation {
  font-style: italic;
}

.meaning {
  font-size: 1.15rem;
}

.amharic {
  font-size: 1.2rem;
}

.examples {
  padding-left: 1.2rem;
}

.examples li {
  margin-bottom: 0.5rem;
}

.examples .translation {
  display: block;
  font-size: 0.9rem;
}

img.cue {
  display: block;
  max-width: 100%;
  max-height: 14rem;
  height: auto;
  border-radius: var(--lw-radius);
  margin: 0.75rem 0;
}

.reveal {
  margin-top: 1rem;
}

.reveal > summary {
  display: inline-block;
  list-style: none;
  font-size: 0.95rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--lw-radius);
  background: var(--lw-green);
  color: var(--lw-on-green);
  cursor: pointer;
}

.reveal > summary::-webkit-details-marker {
  display: none;
}

.reveal > summary:hover {
  background: var(--lw-green-strong);
}

.reveal > summary:focus-visible,
details.grade > summary:focus-visible {
  outline: 2px solid var(--lw-green);
  outline-offset: 2px;
}

/* Once shown it stays shown: there is nothing to hide again, and the
   ratings are what comes next. */
.reveal[open] > summary {
  display: none;
}

.rating-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rating-buttons button {
  flex: 1 1 7rem;
  text-align: left;
}

.rating-buttons .hint {
  display: block;
  font-size: 0.75rem;
}

.spell label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.75rem;
}

.spell .typed {
  margin: 0.25rem 0.5rem 0.5rem 0;
}

.stop {
  margin-top: 1.5rem;
  font-size: 0.85rem;
}

/* --- the study record and its year (D-033, #19) -------------------------
   Four measured greens and an outline, nothing else. A square's value is
   also written into it for a screen reader and shown in words under the
   pointer, because neighbouring shades are too close to tell apart by eye
   alone: the colour is the overview, the words are the value. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.heatmap {
  margin: 0.75rem 0 1.5rem;
}

/* Fifty-three weeks do not fit a phone. The heatmap scrolls inside its own
   box rather than pushing the page sideways, and starts at the latest weeks. */
.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.heatmap-grid {
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 0.68rem;
  line-height: 1;
  color: var(--lw-ink-muted);
}

.heatmap-grid th {
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
  padding: 0 0.3rem 0.2rem 0;
}

/* The weekday names stay put while the weeks scroll past them. */
.heatmap-grid tbody th {
  padding-bottom: 0;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--lw-paper);
}

.sq {
  width: 9px;
  min-width: 9px;
  height: 9px;
  padding: 0;
  border-radius: 2px;
  position: relative;
}

/* A day lived through with nothing on it is drawn, as the week strip draws
   its quiet days; a day before the record began, or not yet lived, is not. */
.sq.s0 {
  outline: 1px dashed var(--lw-edge);
  outline-offset: -1px;
}

.sq.s1 { background: var(--lw-heat-1); }
.sq.s2 { background: var(--lw-heat-2); }
.sq.s3 { background: var(--lw-heat-3); }
.sq.s4 { background: var(--lw-heat-4); }

.heat-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--lw-ink-muted);
}

.heat-legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.heat-legend .sq {
  display: inline-block;
  width: 10px;
  height: 10px;
}

.heat-detail {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
}

/* --- the name and the read button (#122) --------------------------------
   Existing tokens only, per D-024. */

/* (TM), not (R): the name is not a registered trademark. */
.mark {
  font-size: 0.55em;
  vertical-align: super;
  margin-left: 0.1em;
  font-weight: 400;
}

/* "I have read this" (D-039): a deliberate press, never a scroll. */
.read-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

button.secondary {
  background: transparent;
  color: var(--lw-green);
  border-color: var(--lw-green);
}

button.secondary:hover {
  background: var(--lw-green-soft);
}

button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--lw-ink-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: inherit;
}

button.link:hover {
  background: none;
  color: var(--lw-ink);
}

.read-count {
  position: relative;
}

.read-dates {
  position: absolute;
  left: 0;
  top: calc(100% + 0.35rem);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 12rem;
  padding: 0.55rem 0.75rem;
  background: var(--lw-paper-raised);
  border: 1px solid var(--lw-edge);
  border-radius: var(--lw-radius);
  color: var(--lw-ink);
  font-size: 0.85rem;
  white-space: nowrap;
}

.read-row .errors {
  margin: 0;
}
