/* ECON 301 study site — single stylesheet, no framework. */
:root {
  /* palette: 02020B black, D36135 spicy paprika, 7FB069 sage green, ECE4B7 vanilla custard, E6AA68 light caramel */
  --bg: #faf7e8;
  --surface: #fffdf5;
  --ink: #02020b;
  --muted: #5c5a48;
  --line: #e4dcb0;
  --accent: #b84d20;
  --accent-soft: #f3e9c2;
  --on-accent: #ffffff;
  --c1: #5f9348;
  --c2: #d36135;
  --c3: #c98530;
  --good: #4a8a38;
  --good-soft: #e1edd3;
  --bad: #b3261e;
  --bad-soft: #f9ddd0;
  --warn-soft: #f6e7b0;
  --shadow: 0 1px 2px rgba(2, 2, 11, .06), 0 6px 20px rgba(2, 2, 11, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
}
:root[data-theme="dark"] {
  --bg: #05050f;
  --surface: #101019;
  --ink: #f4eecb;
  --muted: #b3ad8c;
  --line: #2a2a36;
  --accent: #e6aa68;
  --accent-soft: #231c14;
  --on-accent: #02020b;
  --c1: #7fb069;
  --c2: #e8744a;
  --c3: #e6aa68;
  --good: #8fc47a;
  --good-soft: #172619;
  --bad: #f08a6a;
  --bad-soft: #3a1f18;
  --warn-soft: #3a321a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 var(--sans);
}
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; letter-spacing: -.01em; margin: 1.6em 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin-top: .3em; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
p { margin: .7em 0; }
main table { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--accent-soft); padding: .08em .35em; border-radius: 5px; }
.katex { font-size: 1.06em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .2em 0; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar { max-width: 1040px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 14px; height: 56px; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 2px; flex: 1; align-items: center; }
.nav > a { color: var(--muted); text-decoration: none; padding: 6px 11px; border-radius: 999px; font-size: .92rem; white-space: nowrap; }
.nav > a:hover { background: var(--accent-soft); color: var(--ink); }
.nav > a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem; flex: none; }
.icon-btn:hover { border-color: var(--accent); }

/* ---------- layout ---------- */
main { max-width: 820px; margin: 0 auto; padding: 24px 16px 80px; }
main.wide { max-width: 1040px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--accent); font-weight: 700; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 40em; }
.pagenav { display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; flex-wrap: wrap; }
.pagenav a { padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; background: var(--surface); }
.pagenav a:hover { border-color: var(--accent); }
footer.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; text-align: center; padding: 24px 16px; }

/* ---------- cards / home ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); margin: 18px 0; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
}
a.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { margin: .2em 0 .3em; font-size: 1.15rem; }
.card p { color: var(--muted); font-size: .92rem; margin: 0 0 .8em; }
.card.soon { opacity: .6; pointer-events: none; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); letter-spacing: .04em; }
.tag.new { background: var(--good-soft); color: var(--good); }
.tag.soon { background: var(--warn-soft); color: var(--muted); }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.progress-label { font-size: .78rem; color: var(--muted); margin-top: 5px; }
.hero { padding: 28px 0 8px; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.btn {
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; display: inline-block;
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent);
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 5px 12px; font-size: .84rem; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- callouts ---------- */
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 18px; border-radius: 0 var(--radius) var(--radius) 0; margin: 18px 0; }
.callout > :first-child { margin-top: 0; } .callout > :last-child { margin-bottom: 0; }
.callout.warn { border-color: #d49a1c; background: var(--warn-soft); }
.callout .label { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; display: block; margin-bottom: 2px; }

/* ---------- widgets ---------- */
.widget {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin: 22px 0; display: grid; gap: 16px; grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .widget.duo { grid-template-columns: 1fr 1fr; }
  .widget.duo .ctl { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; }
  .widget.duo .ctl .readout { grid-column: 1 / -1; }
  .widget.split { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
}
.widget-title { grid-column: 1 / -1; font-family: var(--serif); font-weight: 700; font-size: 1.05rem; margin: 0; }
.widget-title small { font-family: var(--sans); font-weight: 400; color: var(--muted); margin-left: 6px; }
.plot { width: 100%; }
.plot svg { width: 100%; height: auto; display: block; touch-action: manipulation; user-select: none; }
.ctl { display: grid; gap: 10px; }
.ctl label { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: .9rem; color: var(--muted); }
.ctl label b { color: var(--ink); font-variant-numeric: tabular-nums; }
.ctl input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); height: 28px; }
.ctl select, .ctl input[type=number], .ctl input[type=text] {
  font: inherit; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
.ctl .row { display: flex; gap: 8px; flex-wrap: wrap; }
.readout { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: .94rem; }
.readout p { margin: .25em 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.hint { font-size: .85rem; color: var(--muted); }

/* svg plot styling */
svg .axis { stroke: var(--muted); stroke-width: 1.4; fill: none; }
svg .grid-l { stroke: var(--line); stroke-width: 1; }
svg .tick-t { fill: var(--muted); font: 13px var(--sans); }
svg .axis-t { fill: var(--ink); font: italic 17px var(--serif); }
svg .lab { fill: var(--ink); font: 600 14px var(--sans); }
svg .lab.c1 { fill: var(--c1); } svg .lab.c2 { fill: var(--c2); } svg .lab.c3 { fill: var(--c3); }
svg .s1 { stroke: var(--c1); } svg .s2 { stroke: var(--c2); } svg .s3 { stroke: var(--c3); }
svg .sink { stroke: var(--ink); } svg .smuted { stroke: var(--muted); }
svg .f1 { fill: var(--c1); } svg .f2 { fill: var(--c2); } svg .f3 { fill: var(--c3); } svg .fink { fill: var(--ink); }
svg .fill-set { fill: var(--c1); fill-opacity: .12; stroke: none; }
svg .dot-halo { fill: var(--surface); }

/* ---------- exercises & quiz ---------- */
.exercise { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 18px 14px; margin: 18px 0; }
.exercise > h4 { font-family: var(--sans); font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 14px 0 4px; }
details.solution { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
details.solution > summary { cursor: pointer; font-weight: 600; color: var(--accent); list-style: none; }
details.solution > summary::before { content: "▸ "; }
details.solution[open] > summary::before { content: "▾ "; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; }
.q .qmeta { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.q .qtext > :first-child { margin-top: 0; }
.q table { border-collapse: collapse; margin: 8px 0; font-size: .92rem; }
.q td, .q th { border: 1px solid var(--line); padding: 4px 12px; text-align: center; }
.choices { display: grid; gap: 8px; margin: 12px 0; }
.choice {
  text-align: left; font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 14px; cursor: pointer; display: flex; gap: 10px; align-items: baseline;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice .k { font-weight: 700; color: var(--accent); }
.choice.right { border-color: var(--good); background: var(--good-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice:disabled { cursor: default; color: var(--ink); }
.tf-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.tf-item:first-child { border-top: 0; }
.tf-item .tfbtns { display: flex; gap: 6px; flex: none; }
.tf-item .choice { padding: 5px 12px; }
.tf-item.right > div:first-child { color: var(--good); }
.tf-item.wrong > div:first-child { color: var(--bad); }
.feedback { margin-top: 10px; padding: 10px 14px; border-radius: 12px; font-size: .95rem; }
.feedback.good { background: var(--good-soft); } .feedback.bad { background: var(--bad-soft); }
.feedback strong:first-child { display: block; }
.numrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.numrow input { width: 9em; font: inherit; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); }
.qfoot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.chip { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 5px 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.score { font-family: var(--serif); font-size: 1.6rem; }

/* pop quiz */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 80; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .3); display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px);
  animation: rise .35s ease-out;
}
.toast button { font: inherit; font-weight: 600; border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer; background: var(--accent); color: var(--on-accent); }
.toast .x { background: transparent; color: inherit; opacity: .7; padding: 4px 8px; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-bg { position: fixed; inset: 0; z-index: 90; background: rgba(10, 10, 20, .55); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--bg); border-radius: 18px; width: min(620px, 100%); max-height: 90vh; overflow: auto; padding: 8px 18px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 0; }
.modal-head b { font-family: var(--serif); font-size: 1.2rem; }
.fab { position: fixed; left: 16px; bottom: 16px; z-index: 40; box-shadow: var(--shadow); }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .brand span { display: none; }
  .fab { bottom: 12px; left: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- top-bar dropdown ---------- */
.dd { position: relative; }
.dd-btn { font: inherit; font-size: .92rem; color: var(--muted); background: none; border: 0; padding: 6px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.dd-btn i { font-style: normal; font-size: .7em; margin-left: 3px; }
.dd:hover .dd-btn, .dd.open .dd-btn { background: var(--accent-soft); color: var(--ink); }
.dd-btn.on { color: var(--accent); font-weight: 600; }
.dd-panel { display: none; position: absolute; top: 100%; left: 0; padding-top: 10px; z-index: 60; }
.dd:hover .dd-panel, .dd.open .dd-panel { display: block; }
.dd-inner {
  display: grid; grid-template-columns: repeat(2, minmax(240px, 1fr)); gap: 4px 22px; width: max-content; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: 0 14px 44px rgba(0, 0, 0, .2);
}
.dd-col h4 { margin: 2px 8px 6px; font: 700 .72rem var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.dd-inner a { display: flex; align-items: baseline; gap: 8px; padding: 7px 8px; border-radius: 9px; text-decoration: none; color: var(--ink); font-size: .93rem; }
.dd-inner a:hover { background: var(--accent-soft); }
.dd-inner a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.dd-inner a small { margin-left: auto; color: var(--muted); font-size: .75rem; white-space: nowrap; padding-left: 6px; }
.dd-inner .tag { font-size: .6rem; padding: 1px 6px; font-style: normal; }
@media (max-width: 640px) {
  .dd { position: static; }
  .dd-panel { left: 8px; right: 8px; padding-top: 0; top: 100%; }
  .dd-inner { grid-template-columns: 1fr; width: auto; max-height: 72vh; overflow-y: auto; margin-top: 4px; }
}

/* ---------- figures, multi-part answers ---------- */
.q .plot { max-width: 460px; margin: 6px 0 4px; }
.numgrid { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; }
.numpart { display: grid; gap: 3px; font-size: .88rem; color: var(--muted); }
.numpart input {
  width: 8.5em; font: inherit; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
}
.numpart input.ok { border-color: var(--good); background: var(--good-soft); }
.numpart input.no { border-color: var(--bad); background: var(--bad-soft); }
ul.ans { margin: 6px 0; padding-left: 1.2em; }
.tf-item .tfbtns .choice { white-space: nowrap; }
.dd-inner.three { grid-template-columns: repeat(3, minmax(190px, 1fr)); }
@media (max-width: 900px) { .dd-inner.three { grid-template-columns: repeat(2, minmax(190px, 1fr)); } }
@media (max-width: 640px) { .dd-inner.three { grid-template-columns: 1fr; } }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 12px 0; }
.match .col { display: grid; gap: 8px; align-content: start; }
.match .choice { justify-content: center; text-align: center; min-height: 48px; align-items: center; }
.match .choice.sel { border-color: var(--accent); background: var(--accent-soft); }
.match .choice.done { border-color: var(--good); background: var(--good-soft); opacity: .8; }
.match .choice.shake { border-color: var(--bad); background: var(--bad-soft); }
table.notation { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: .95rem; margin: 8px 0 20px; }
table.notation th:nth-child(1), table.notation td:nth-child(1) { width: 32%; }
table.notation th:nth-child(2), table.notation td:nth-child(2) { width: 36%; }
table.notation th { text-align: left; color: var(--muted); padding: 6px 8px; }
table.notation td { border-top: 1px solid var(--line); padding: 9px 8px; vertical-align: top; }
table.notation td:first-child { font-size: 1.05rem; overflow-x: auto; }
table.notation td.ex { color: var(--muted); }
@media (max-width: 560px) { table.notation td.ex { display: none; } table.notation th.ex { display: none; } }
