/* ==========================================================================
   One centred column.

   There is a single column, centred once, and everything sits inside it —
   heading, switcher, filters and content all share one left edge, which is
   what makes a page read as deliberate. Line length is controlled by the
   column itself, so blocks inside it fill the width rather than carrying
   caps of their own.
   ========================================================================== */

.app__inner {
  position: relative;
  z-index: 1;
  max-width: 62rem;
  margin-inline: auto;
}

.paper-body,
.notes,
.prose,
.subject-heading,
.storage-notice,
.reading-content {
  max-width: none;
}

/* Every page in the app uses this one column — home, the picker, subject,
   unit and topic pages alike — so the header, switcher and content land in
   the same place wherever you go. */

/* The header used to sit on a pastel wash, with a glossy illustration per
   subject behind it. Both are gone: the page head sits on the canvas and
   the subject is carried by its emblem beside the title. */

.planned-outline {
  margin: 28px 0;
  padding: 22px 24px;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.planned-outline ul { padding-left: 1.25rem; margin: 16px 0; }
.planned-outline li { padding: 4px 0; }
.planned-outline .quiet:last-child { margin-bottom: 0; }
@media (max-width: 780px) {
  .planned-outline { padding: 18px; }
}

.course-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 18px;
  color: var(--text);
}
.course-row:hover { background: var(--accent-tint); text-decoration: none; }
.course-row .module-row__body { flex: 1; min-width: 0; }
.course-row strong { color: var(--ink); font-size: 1.05rem; }
.course-row:hover strong { color: var(--accent); }
.course-row > .icon { width: 18px; height: 18px; color: var(--faint); }
/* Courses with their own badge (calculus, linear algebra, complex numbers)
   show it in place of the row number. */
.course-row__icon { align-self: flex-start; flex-shrink: 0; }
.course-row__icon .course-icon { display: block; width: 36px; height: 36px; }
.course-description {
  display: block;
  max-width: 65ch;
  margin: 6px 0;
  font-size: .875rem;
  line-height: 1.65;
  color: var(--muted);
}
.scope-search { margin: 0 0 14px; }
.scope-search input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.course-matches { padding: 0 0 12px 40px; }
.search-empty { padding: 24px 0; color: var(--muted); }
.topic-progress-ring { display: inline-flex; flex-shrink: 0; }
.course-row [data-reading-topics], .course-row [data-unit-reading] { flex-shrink: 0; }
.topic-row .topic-label { min-width: 0; }
@media (max-width: 780px) {
  .course-row { gap: 12px; padding: 18px 14px; }
  .course-row__icon .course-icon { width: 30px; height: 30px; }
  .course-matches { padding-left: 0; }
  .topic-row .topic-label { flex-basis: calc(100% - 40px); }
  .topic-row .pill { margin-left: 34px; }
}

/* A topic is a sheet of paper on the canvas, the full width of the shared
   column, with the heading and switcher above it sharing its left edge. */
.reading-layout {
  display: block;
}

.topic-page .reading-content {
  padding: 28px clamp(20px, 5vw, 48px) 36px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
}
/* On a phone the sheet becomes the screen. Inline maths is set not to wrap,
   so every pixel of measure matters; inset padding inside an inset card
   pushed the longest runs 22px past the edge. */
@media (max-width: 780px) {
  .topic-page .reading-content {
    margin-inline: calc(-1 * var(--main-pad-x));
    padding: 22px var(--main-pad-x) 30px;
    border-inline: 0;
    border-radius: 0;
  }
}

/* --------------------------------------------------------------------------
   No top bar on a desktop. The rail already says where you are. On a
   narrower screen a slim strip keeps the wordmark, and on a phone the
   button that opens the off-canvas rail.
   -------------------------------------------------------------------------- */

.topbar {
  display: none;
}

.topbar-brand {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.topbar-brand:hover {
  text-decoration: none;
}

@media (max-width: 1100px) {
  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar);
    padding: 0 14px;
    border-bottom: 1px solid var(--hairline);
    background: var(--canvas);
  }
}

.topbar-account { margin-left: auto; }

/* Inline maths is kept on one line (notes.css), which is right on a wide
   column. On a phone a long inline chain would then push the whole page
   sideways, so there KaTeX may break at its own break points — after a
   relation or an operator — and never inside a symbol. */
@media (max-width: 560px) {
  .notes .katex { white-space: normal; }
}
.course-row { transition: background-color var(--dur-press) var(--ease-out); }

/* --------------------------------------------------------------------------
   The learning path (unit pages).

   Topics run through rows of nodes in curriculum order. Each node is a real
   link. Opened notes fill their reading marker, the next available lesson is
   citrus, and a topic without notes yet is dashed and grey. Practice scores
   do not affect this path.
   -------------------------------------------------------------------------- */

.path-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; align-items: start; }
.path-card { position: sticky; top: 24px; padding: 20px; background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius-lg); animation: rh-rise var(--dur-enter) var(--ease-out) both; }
.path-card h2 { font-size: 1rem; margin-bottom: 14px; }
.path-card__facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 16px; }
.path-card__facts div { padding: 10px 12px; background: var(--surface); border-radius: var(--radius-sm); }
.path-card__facts dt { font-size: .75rem; color: var(--muted); }
.path-card__facts dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.path-meter { height: 8px; overflow: hidden; background: var(--canvas-deep); border-radius: var(--radius-pill); }
.path-meter span { display: block; height: 100%; background: var(--done); border-radius: inherit; }
.path-meter__text { margin: 8px 0 14px; font-size: .8125rem; color: var(--muted); }
.path-card__action { width: 100%; white-space: normal; text-align: center; }

.path-map { min-width: 0; }
/* A straight curriculum column replaces the former winding path. Every row
   shares the same marker, title and status columns, while the vertical rule
   makes the order unambiguous without adding visual noise. */
.path { position: relative; display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.path::before { content: ""; position: absolute; z-index: 0; top: 28px; bottom: 28px; left: 27px; width: 2px; background: var(--path-line); }
.path__step { position: relative; z-index: 1; min-width: 0; }
.path__node { display: grid; grid-template-columns: 54px minmax(0, 1fr); align-items: center; gap: 16px; width: 100%; min-height: 78px; padding: 11px 16px 11px 0; border: 1px solid var(--hairline); border-radius: var(--radius-lg); background: var(--paper); color: var(--text); text-align: left; transition: background-color var(--dur-press) var(--ease-out), border-color var(--dur-press) var(--ease-out); }
.path__node:hover { text-decoration: none; background: var(--surface); border-color: var(--hairline-strong); }
.path__marker { display: grid; place-items: center; width: 42px; height: 42px; margin-left: 6px; border: 2px solid var(--hairline-strong); border-radius: 10px; background: var(--paper); color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; transition: background-color var(--dur-control) var(--ease-out), border-color var(--dur-control) var(--ease-out), transform var(--dur-control) var(--ease-out); }
.path__node:hover .path__marker { transform: translateX(2px); }
.path__check { display: none; width: 24px; height: 24px; fill: none; stroke: var(--white); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.path__label { display: grid; gap: 4px; justify-items: start; min-width: 0; }
.path__title { font-size: .9375rem; font-weight: 600; line-height: 1.35; color: var(--ink); }
.path__meta { font-size: .75rem; color: var(--muted); }
.path__now { display: none; padding: 1px 8px; border-radius: var(--radius-pill); background: var(--ink); color: var(--white); font-size: .6875rem; font-weight: 600; }
.path__step[data-state="practising"] .path__marker { border-color: var(--accent); }
.path__step[data-state="fading"] .path__marker { border-color: var(--warn); }
.path__step[data-state="declared"] .path__marker { border-style: dashed; border-color: var(--ink); }
.path__step[data-state="secure"] .path__marker { background: var(--done); border-color: var(--done); }
.path__step[data-state="secure"] .path__check { display: block; }
.path__step[data-state="opened"] .path__marker { background: var(--ink); border-color: var(--ink); }
.path__step[data-state="opened"] .path__check { display: block; }
.path__step[data-written="false"] .path__marker { border-style: dashed; background: var(--surface); color: var(--faint); }
.path__step[data-written="false"] .path__title { color: var(--muted); }
/* The next topic remains aligned with every other row; a firmer border and
   citrus marker provide emphasis without distorting the structure. */
.path__step[data-current] .path__node { border-color: var(--accent); }
.path__step[data-current] .path__marker { background: var(--cta); border-color: var(--cta-edge); color: var(--cta-ink); }
.path__step[data-current] .path__node:hover .path__marker { transform: translateX(2px); }
.path__step[data-current] .path__now { display: inline-flex; }
@media (max-width: 1180px) { .path-layout { grid-template-columns: 1fr; } .path-card { position: static; } }
@media (max-width: 560px) {
  .path-layout { gap: 20px; }
  .path__node { grid-template-columns: 48px minmax(0, 1fr); gap: 12px; padding-right: 12px; }
  .path::before { left: 24px; }
  .path__marker { width: 38px; height: 38px; margin-left: 5px; }
}

/* --------------------------------------------------------------------------
   Previous and next topic.

   Two generous cards under the notes. Next is the stronger of the two —
   citrus, like the next step on a path — and previous stays quiet but easy
   to find. With one neighbour the card takes the whole row.
   -------------------------------------------------------------------------- */

.topic-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.topic-nav--single { grid-template-columns: minmax(0, 1fr); }
.topic-nav__card { display: flex; align-items: center; gap: 14px; min-height: 88px; padding: 18px 20px; border: 1px solid var(--hairline); border-radius: var(--radius-lg); background: var(--paper); color: var(--ink); transition: border-color var(--dur-control) var(--ease-out), background-color var(--dur-control) var(--ease-out), transform var(--dur-press) var(--ease-out); }
.topic-nav__card:hover { text-decoration: none; border-color: var(--ink); }
.topic-nav__card:active { transform: translateY(1px); }
.topic-nav__card--next { flex-direction: row-reverse; text-align: right; background: var(--cta-soft); border-color: var(--cta-line); }
.topic-nav__card--next:hover { border-color: var(--cta-edge); }
.topic-nav__arrow { display: grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; border: 1px solid var(--hairline-strong); border-radius: 50%; background: var(--paper); transition: transform var(--dur-control) var(--ease-out); }
.topic-nav__card--next .topic-nav__arrow { background: var(--cta); border-color: var(--cta-edge); color: var(--cta-ink); }
.topic-nav__arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.topic-nav__card--prev:hover .topic-nav__arrow { transform: translateX(-3px); }
.topic-nav__card--next:hover .topic-nav__arrow { transform: translateX(3px); }
.topic-nav__text { display: grid; flex: 1; gap: 4px; min-width: 0; }
.topic-nav__label { font-size: .75rem; font-weight: 600; color: var(--muted); }
.topic-nav__title { font-size: 1rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
@media (max-width: 640px) { .topic-nav { grid-template-columns: minmax(0, 1fr); } .topic-nav__card { min-height: 76px; } }

/* Mathematical figures keep axes and captions together at every viewport. */
.note-figure{margin:24px 0;padding:16px;border:1px solid var(--hairline);border-radius:12px;background:#fff}.note-figure img{display:block;width:100%;height:auto}.note-figure figcaption{margin-top:12px;color:var(--muted);font-size:.9rem;line-height:1.65}.note-prose{margin:16px 0;line-height:1.8}.note-prose p+p{margin-top:12px}
.note-figure-plot{overflow-x:auto}.note-figure-plot img{min-width:600px}.note-figure-plot:focus-visible{outline:2px solid #176c98;outline-offset:3px}.note-figure-hint{display:none;color:var(--muted);font-size:.8rem;margin-top:8px}@media(max-width:700px){.note-figure-hint{display:block}}
