/* Study Hub — shared styles */
:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --ink: #1c2433;
  --muted: #5b6472;
  --line: #e3e7ee;
  --actg: #0e7c66;      /* ledger green */
  --actg-soft: #e2f3ee;
  --econ: #4f46e5;      /* regression indigo */
  --econ-soft: #e9e8fd;
  --now: #e05d3d;       /* the needle */
  --good: #15803d;
  --warn: #b45309;
  --bad: #b3261e;
  --shadow-1: 0 1px 2px rgba(28,36,51,.06), 0 4px 12px rgba(28,36,51,.08);
  --shadow-2: 0 2px 4px rgba(28,36,51,.08), 0 12px 28px rgba(28,36,51,.14);
  --r: 14px;
  --sans: "Avenir Next", "Avenir", -apple-system, "Segoe UI", system-ui, sans-serif;
  --serif: "Charter", "Georgia", serif;
  --mono: ui-monospace, "SF Mono", "Menlo", monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.55;
}
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
code { font-family: var(--mono); font-size: 0.9em; background: #eef1f6; padding: 1px 5px; border-radius: 5px; }
pre code { display: block; padding: 12px 14px; overflow-x: auto; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.narrow { max-width: 780px; }

/* ---------- header / top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(242,244,248,.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1100px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 14px;
}
.topbar .brand { font-weight: 600; text-decoration: none; font-size: 15px; }
.topbar .brand span { color: var(--muted); font-weight: 500; }
.topbar .spacer { flex: 1; }
.clock { font-family: var(--mono); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* on narrow screens the brand, day switch, pace pill, clock and session button
   do not fit on one line; let them wrap and shrink the clock a touch */
@media (max-width: 520px) {
  .topbar-in { gap: 8px; flex-wrap: wrap; padding: 8px 14px; }
  .clock { font-size: 18px; }
}

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow-1); padding: 22px 24px;
}
.card + .card { margin-top: 18px; }
.card.raised { box-shadow: var(--shadow-2); }

/* subject cards on hub */
.subjects { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 26px; }
.subject-card {
  display: block; text-decoration: none; position: relative;
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-1);
  padding: 26px 26px 22px; transition: transform .15s ease, box-shadow .15s ease;
  border-top: 4px solid var(--accent, var(--ink));
}
.subject-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.subject-card .kicker { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.subject-card h2 { margin: 6px 0 8px; font-size: 24px; }
.subject-card p { color: var(--muted); margin: 0 0 14px; }
.subject-card .links { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-block; font-size: 13px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
  background: var(--soft, #eef1f6); color: var(--accent, var(--ink));
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 10px 18px;
  font-weight: 600; font-size: 15px; color: #fff; background: var(--ink);
  box-shadow: var(--shadow-1); transition: transform .12s ease, box-shadow .12s ease, background .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.btn:active { transform: translateY(0); }
.btn.accent { background: var(--accent, var(--ink)); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { background: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
:focus-visible { outline: 2.5px solid var(--econ); outline-offset: 2px; }

/* status pill */
.pill {
  font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.pill.ahead { background: #e4f4e8; color: var(--good); }
.pill.behind { background: #fbeee1; color: var(--warn); }
.pill.onpace { background: #eef1f6; color: var(--muted); }

/* ---------- day layout ---------- */
.day-grid { display: grid; grid-template-columns: 264px 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) {
  /* minmax(0,1fr) lets the single column shrink below the rail's nowrap content
     so the rail no longer forces the page wider than the viewport */
  .day-grid { grid-template-columns: minmax(0, 1fr); }
  /* wide tables scroll inside their own box instead of pushing the page sideways */
  .q-table, table.attempts, .scenario table, .mcq table {
    display: block; overflow-x: auto; max-width: 100%;
  }
}

/* the signature: vertical day rail */
.rail {
  position: sticky; top: 64px; max-height: calc(100vh - 84px);
  overflow-y: auto; background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow-1); padding: 14px 0;
}
.rail-block {
  display: grid; grid-template-columns: 52px 14px 1fr; align-items: center;
  padding: 5px 12px 5px 10px; position: relative; min-height: 34px;
  border: 0; background: none; width: 100%; text-align: left; font-size: 13px;
}
.rail-block .t { font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rail-block .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--actg); justify-self: center; }
.rail-block.break .dot { background: transparent; border: 2px dashed #b9c1cd; border-radius: 50%; width: 9px; height: 9px; }
.rail-block.meal .dot { background: var(--warn); border-radius: 50%; }
.rail-block .lbl { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-block.break .lbl, .rail-block.meal .lbl { color: var(--muted); font-weight: 400; }
.rail-block.done .lbl { text-decoration: line-through; color: #a6adba; }
.rail-block.done .dot { background: #c9cfd9; }
.rail-block.current { background: linear-gradient(90deg, var(--actg-soft), transparent); }
.rail-block.current .lbl { font-weight: 700; }
.rail-block.skipped .lbl { color: #a6adba; font-style: italic; }
/* placed after the base .rail rules so these actually win on small screens:
   the rail drops out of sticky and shortens so it does not cover the questions,
   and minmax(0,1fr) lets long labels ellipsize instead of widening the page */
@media (max-width: 860px) {
  .rail { position: static; max-height: 320px; }
  .rail-block { grid-template-columns: 52px 14px minmax(0, 1fr); }
}
.rail-needle {
  position: absolute; left: 0; right: 0; height: 2px; background: var(--now);
  box-shadow: 0 0 6px rgba(224,93,61,.7); pointer-events: none; z-index: 2;
}
.rail-needle::before {
  content: ""; position: absolute; left: 2px; top: -3.5px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--now);
}

/* now banner */
.now-banner { border-left: 5px solid var(--actg); }
.now-banner.break-mode { border-left-color: var(--warn); background: #fffaf3; }
.now-banner .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.now-banner h2 { margin: 0 0 6px; font-size: 21px; }
.now-banner .meta { color: var(--muted); font-size: 14px; margin: 0; font-variant-numeric: tabular-nums; }
.now-banner ul { margin: 10px 0 0; padding-left: 20px; }
.block-flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 3px rgba(224,93,61,.45), var(--shadow-2); } }

/* ---------- topic sections & questions ---------- */
.topic { margin-top: 26px; scroll-margin-top: 76px; }
.topic-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topic-head h2 { margin: 0; font-size: 22px; }
.topic-head .count { color: var(--muted); font-size: 13.5px; }
.topic.known-topic .q-card, .topic.known-topic .intro { opacity: .45; }
.topic .intro { font-family: var(--serif); font-size: 16.5px; color: #333c4d; }

.q-card { margin-top: 14px; }
.q-card .q-top { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.q-card .q-title { font-weight: 700; font-size: 16.5px; }
.q-card .q-est { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.q-card .prompt { font-family: var(--serif); font-size: 16.5px; }
.q-table { border-collapse: collapse; margin: 10px 0; font-size: 14.5px; width: auto; }
.q-table th, .q-table td { border: 1px solid var(--line); padding: 6px 12px; text-align: right; }
.q-table th:first-child, .q-table td:first-child { text-align: left; }
.q-table th { background: #f6f8fb; font-weight: 600; }
.journal { font-family: var(--mono); font-size: 13.5px; background: #f6f8fb; border-radius: 8px; padding: 10px 14px; margin: 8px 0; white-space: pre-wrap; }
.takeaway { border-left: 3px solid var(--actg); padding-left: 10px; color: #333c4d; font-size: 14.5px; }

.hint-toggle { margin-top: 8px; }
.hint-body {
  margin-top: 8px; background: #f3f7f6; border: 1px solid #d8e8e4;
  border-radius: 10px; padding: 12px 16px; font-size: 15px;
}
.answer-area { margin-top: 12px; }
.answer-area textarea {
  width: 100%; min-height: 88px; resize: vertical;
  font: 14px/1.5 var(--mono); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fbfcfe;
}
.answer-area textarea:focus { border-color: var(--actg); outline: none; }
.answer-area .saved { font-size: 12px; color: var(--muted); }

.solution {
  margin-top: 12px; border: 1.5px solid var(--actg-soft); border-radius: 10px;
  padding: 14px 16px; background: #f7fbfa;
}
.solution .sol-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.solution .sol-head strong { color: var(--actg); }
.marks { display: flex; gap: 6px; }
.mark-btn { border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mark-btn.on-got { background: #e4f4e8; border-color: var(--good); color: var(--good); }
.mark-btn.on-partial { background: #fbeee1; border-color: var(--warn); color: var(--warn); }
.mark-btn.on-missed { background: #fdecea; border-color: var(--bad); color: var(--bad); }
.backfilled { font-size: 12px; font-weight: 700; color: var(--econ); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- quiz player ---------- */
.scenario { background: #f6f8fb; border-radius: 10px; padding: 14px 18px; margin: 18px 0 6px; }
.scenario .sc-label { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--econ); }
.mcq { margin-top: 12px; }
.mcq .prompt { font-weight: 600; }
.opts { display: grid; gap: 8px; margin-top: 8px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 14px; font-size: 15px; width: 100%;
}
.opt:hover { border-color: #b9c1cd; }
.opt .key { font-weight: 700; font-family: var(--mono); color: var(--muted); }
.opt.sel { border-color: var(--econ); background: var(--econ-soft); }
.opt.correct { border-color: var(--good); background: #e4f4e8; }
.opt.wrong { border-color: var(--bad); background: #fdecea; }
.explain { margin-top: 10px; border-left: 3px solid var(--econ); padding: 2px 0 2px 12px; color: #333c4d; font-size: 14.5px; }
.quiz-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.timer { font-family: var(--mono); font-weight: 700; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.score-line { font-size: 20px; font-weight: 700; }
table.attempts { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.attempts th, table.attempts td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }

/* ---------- misc ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
.footer-note { margin-top: 40px; color: var(--muted); font-size: 13px; text-align: center; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.copied { color: var(--good) !important; }

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