/* Math 6A study app. Plain hand-written CSS: no libraries, no web fonts, system font stacks only.
 * Mobile first. Light and dark colours come from the variables below.
 * One accent colour (blue). Green and red appear only for right and wrong answers. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #14181f;
  --soft: #4b5361;
  --line: #cfd5de;
  --accent: #1d5bb8;
  --on-accent: #ffffff;
  --good: #1b6b3a;
  --bad: #9c2b1a;
  --flag: #fff4d6;
  --flag-line: #8a6400;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --math: ui-serif, Cambria, Georgia, "Times New Roman", serif;
  --radius: 10px;
  --tap: 44px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111419;
    --card: #1a1e26;
    --text: #eef1f5;
    --soft: #b3bccb;
    --line: #3a4150;
    --accent: #8fbcf7;
    --on-accent: #0c1b33;
    --good: #7fd19f;
    --bad: #f6a593;
    --flag: #352d14;
    --flag-line: #d4a72c;
  }
}

/* ---------- Base type: 17px on phones, 18px wider; 1.5 line height; about 70 characters per line ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 17px; line-height: 1.5; }
@media (min-width: 720px) { body { font-size: 18px; } }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { color: var(--text); line-height: 1.2; }
h1 { font-size: 1.9rem; letter-spacing: -0.01em; margin: .3rem 0 .5rem; }
h2 { font-size: 1.3rem; margin: 1.8rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
@media (min-width: 720px) { h1 { font-size: 2.3rem; } }
p, li, dd { max-width: 70ch; }
p { margin: .5rem 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 20; background: var(--card); color: var(--text); padding: 10px 14px; border-radius: 6px; }

/* ---------- Top bar and navigation ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 700; color: var(--text); text-decoration: none; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* Phone: the four main places sit in a bar at the bottom of the screen. Wide: a bar that sticks to the top. */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav a { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 56px; padding: 6px 4px; color: var(--soft); text-decoration: none; font-size: .9rem; line-height: 1.15; font-weight: 600; border-top: 3px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 700; border-top-color: var(--accent); }
@media (min-width: 720px) {
  .nav { position: sticky; top: 0; bottom: auto; display: flex; gap: 4px; padding: 0 16px; border-top: 0; border-bottom: 1px solid var(--line); }
  .nav a { min-height: var(--tap); padding: 10px 14px; font-size: 1rem; border-top: 0; border-bottom: 3px solid transparent; }
  .nav a[aria-current="page"] { border-bottom-color: var(--accent); }
}

main { max-width: 980px; margin: 0 auto; padding: 16px 16px 112px; }
@media (min-width: 720px) { main { padding: 24px 24px 56px; } }

/* ---------- Buttons and links you can tap ---------- */
button, .button { font: inherit; font-size: 1rem; font-weight: 600; line-height: 1.2; min-height: var(--tap); min-width: var(--tap); padding: 8px 16px; border: 1.5px solid var(--soft); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:not(.primary):hover, .button:not(.primary):hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.primary, button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); color: var(--on-accent); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.end { border-top: 1px solid var(--line); padding-top: 16px; margin-bottom: 0; }

/* ---------- Dashboard: summary strip, continue button, module cards ---------- */
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 18px 0 0; }
.cta { min-height: 52px; padding: 12px 22px; font-size: 1.1rem; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 22px 0 8px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.num { font-size: 2.2rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.lbl { font-size: .9rem; color: var(--soft); line-height: 1.3; }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; max-width: none; }
.mod { display: flex; flex-direction: column; gap: 8px; margin: 0; color: var(--text); text-decoration: none; }
.mod:hover { border-color: var(--accent); }
.mod-name { font-size: 1.1rem; line-height: 1.3; }
.goal { display: block; color: var(--soft); margin: 0; }
.eyebrow, .small { color: var(--soft); font-size: .92rem; margin: .3rem 0; }
.eyebrow { font-weight: 600; }
.big { font-size: 3rem; font-weight: 800; line-height: 1.05; margin: 0; }
.question { font-size: 1.15rem; line-height: 1.5; }

.status { display: inline-flex; align-items: center; align-self: flex-start; min-height: 28px; padding: 2px 12px; border: 1.5px solid var(--line); border-radius: 999px; font-size: .88rem; font-weight: 600; color: var(--soft); }
.status.s-done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.status.s-going { border-color: var(--accent); color: var(--accent); }
.status.s-new { border-style: dashed; }

/* Progress bar: the number is printed next to it, not only shown as a bar. */
.bar { display: flex; align-items: center; gap: 10px; }
progress { flex: 1 1 auto; width: 100%; height: 12px; border: 0; border-radius: 999px; background: var(--line); accent-color: var(--accent); appearance: none; -webkit-appearance: none; overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.bar-num { min-width: 3.4em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.modmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 10px 0 0; }
.modmeta .bar { flex: 1 1 220px; max-width: 360px; }
.modmeta .small { margin: 0; }

.mod-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.mod-list li { max-width: none; }
.mod-list .card { margin: 0; }
.mod-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }

/* ---------- Module tabs: Learn, Practice, Check ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 8px; overflow-x: auto; }
.tabs a { flex: 1 0 auto; min-height: var(--tap); display: flex; align-items: center; justify-content: center; padding: 8px 18px; color: var(--soft); font-weight: 600; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Notices ---------- */
.notice, .flag { padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); max-width: none; }
.flag { background: var(--flag); border-color: var(--flag-line); }
.flagged li { margin-bottom: 8px; }

/* ---------- Math: larger, serif, exponents lifted clear of the line ---------- */
.m { font-family: var(--math); font-size: 1.2em; }
.m sup { font-size: .72em; line-height: 0; vertical-align: .6em; margin-left: 1px; }
.m sup sup { font-size: .85em; }
.rad { border-top: 1.5px solid currentColor; padding: 0 2px; }
.nocalc .dec { display: none; }

/* ---------- Practice: chips, one problem, hint ladder, walkthrough ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.chip { min-width: var(--tap); min-height: var(--tap); padding: 6px 12px; text-align: center; }
.chip.solved { border-color: var(--good); border-width: 2px; }
.chip.cold { background: var(--good); border-color: var(--good); color: var(--card); }
.chip.here { outline: 3px solid var(--accent); outline-offset: 2px; }

.part { border: 0; padding: 0; margin: 22px 0; min-width: 0; }
.part legend { padding: 0; font-weight: 600; margin-bottom: 4px; }
.field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
input[type="text"], input[type="number"], textarea, select, .short { font: inherit; font-size: 1rem; color: var(--text); background: var(--card); border: 1.5px solid var(--soft); border-radius: 8px; padding: 10px 12px; min-height: var(--tap); }
input[type="text"] { width: min(100%, 440px); }
textarea { width: 100%; }
.short { width: 100px; }
.right input[type="text"] { border-color: var(--good); }
.wrong input[type="text"] { border-color: var(--bad); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); }
.opt { display: flex; gap: 12px; align-items: center; min-height: var(--tap); padding: 6px 0; cursor: pointer; }
.opt span { min-width: 0; }
.entry { margin: 14px 0; }
.entry label { display: block; margin-bottom: 6px; font-weight: 600; }
.entry select { max-width: 100%; }
.choice { display: flex; flex-wrap: wrap; gap: 0 16px; align-items: end; }
.choice .entry { flex: 1 1 260px; margin: 6px 0; }
.typing { color: var(--soft); font-size: .95rem; min-height: 1.5em; margin: 4px 0 0; }
.result { margin: 6px 0; font-weight: 600; }
.result.right { color: var(--good); }
.result.wrong, .result.blank { color: var(--bad); }

.ladder { margin-top: 24px; }
.ladder ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.rung { padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.rung-label { display: block; margin-bottom: 4px; font-size: .82rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--soft); }
.rung p { margin: 0; }
.rung.shown { background: var(--card); border-color: var(--accent); }
.rung.next { background: var(--card); border-style: dashed; border-color: var(--accent); }
.rung.locked { opacity: .65; }

.steps, .answers { padding-left: 1.4em; }
.steps li, .answers li { margin-bottom: 14px; }
.answers { list-style: none; padding: 0; }
.answers .wrong, .answers .blank { border-left: 3px solid var(--bad); padding-left: 10px; }
.why { color: var(--soft); margin: 2px 0 0; }
.explain { margin-top: 24px; }

/* ---------- Quiz (Check) and mock final ---------- */
.testbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.clock { margin-right: auto; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
summary { cursor: pointer; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; }
.picks { display: grid; grid-template-columns: 1fr; gap: 2px 16px; }
@media (min-width: 560px) { .picks { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Learn tab: videos, formulas, tables ---------- */
.video { padding: 10px 0; border-top: 1px solid var(--line); }
.video:first-of-type { border-top: 0; padding-top: 0; }
.video > a { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; }
.video .row { margin: 6px 0 0; }
dl { margin: 0; }
dl div { display: grid; grid-template-columns: minmax(130px, 1fr) 2fr; gap: 6px 16px; padding: 10px 0; border-top: 1px solid var(--line); }
dl div:first-child { border-top: 0; padding-top: 0; }
dd { margin: 0; }
@media (max-width: 559px) { dl div { grid-template-columns: 1fr; gap: 2px; } }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin: 12px 0; }
th, td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }

/* ---------- Notes page: two columns on screen, three on paper ---------- */
.notes { columns: 1; column-gap: 32px; }
@media (min-width: 720px) { .notes { columns: 2; } }
.notes section { break-inside: avoid-column; }
.notes h2 { font-size: 1.05rem; margin: 1rem 0 .3rem; }
.notes ul { padding-left: 18px; margin: 0; }
.notes li { max-width: none; }

@media print {
  @page { size: letter; margin: .35in; }
  :root { color-scheme: light; --text: #000; --soft: #000; --bg: #fff; --card: #fff; --line: #999; --accent: #000; }
  .top, .nav, .noprint, .skip { display: none !important; }
  body { background: #fff; font-size: 9pt; line-height: 1.25; }
  main { max-width: none; padding: 0; }
  p, li, dd { max-width: none; }
  .notes { columns: 3; column-gap: .2in; font-size: 9pt; }
  .notes h2 { font-size: 9.5pt; margin: 6pt 0 1pt; border-bottom: 1px solid #999; }
  .notes ul { padding-left: 10pt; }
}
