/* ---------- Base ---------- */
:root {
  --ink: #1d2433;
  --muted: #5b6577;
  --line: #dde2ea;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #1f5fbf;
  --accent-soft: #e8f0fc;
  --ad: #1f5fbf;
  --sras: #c2410c;
  --lras: #1d7a3a;
  --good: #1d7a3a;
  --good-soft: #e6f4ea;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --todo: #fff6d6;
  --todo-line: #c99a06;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; margin-top: 1.6em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); }

/* ---------- Header and menu ---------- */
.site-header {
  background: var(--ink);
  color: #fff;
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-top: .8rem;
  padding-bottom: .8rem;
}
.brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.1rem;
}
.menu { display: flex; flex-wrap: wrap; gap: .25rem; }
.menu a {
  color: #cfd6e4;
  text-decoration: none;
  padding: .35rem .75rem;
  border-radius: 6px;
}
.menu a:hover { background: rgba(255,255,255,.1); color: #fff; }
.menu a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 600; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem; }
main.wrap { padding-top: 2rem; padding-bottom: 3rem; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
  padding: 1.25rem 0 2rem;
}

/* ---------- Cards and boxes ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}

.lead { font-size: 1.1rem; color: var(--muted); max-width: 70ch; }

.problem {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 2rem;
}
.problem h2 { margin-top: 0; font-size: 1rem; letter-spacing: .08em; text-transform: uppercase; }
.problem dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; }
.problem dt { font-weight: 700; }
.problem dd { margin: 0; }

.section-label {
  font-size: 1rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.tool-card { display: flex; flex-direction: column; }
.tool-card h3 a { text-decoration: none; }
.tool-card h3 a:hover { text-decoration: underline; }
.tool-card p { color: var(--muted); }

/* Placeholder the student must replace in their own words */
.todo {
  background: var(--todo);
  border: 2px dashed var(--todo-line);
  border-radius: 6px;
  padding: .5rem .75rem;
  font-style: italic;
  color: #6b5200;
}

.did-it-work dt { font-weight: 700; margin-top: 1rem; }
.did-it-work dd { margin: .35rem 0 0; }

/* ---------- Buttons and forms ---------- */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: .5rem .9rem;
  border-radius: 8px;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #184d9b; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #86b0f0; outline-offset: 2px; }

/* ---------- Graph ---------- */
.graph {
  width: 100%;
  height: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: block;
}
.graph text { font-family: inherit; }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; color: var(--muted); margin: .5rem 0 0; }
.legend span::before { content: ""; display: inline-block; width: 18px; height: 3px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.legend .k-ad { color: var(--ad); }
.legend .k-sras { color: var(--sras); }
.legend .k-lras { color: var(--lras); }
.legend .k-old { color: #9aa3b2; }

/* ---------- Curve Lab ---------- */
.lab { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1.5rem; align-items: start; }
.slider-row { margin-bottom: 1rem; }
.slider-row label { display: flex; justify-content: space-between; font-weight: 600; }
.slider-row output { font-weight: 400; color: var(--muted); }
.slider-row input[type="range"] { width: 100%; }
.slider-row.ad label { color: var(--ad); }
.slider-row.sras label { color: var(--sras); }
.slider-row.lras label { color: var(--lras); }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }

.readout { list-style: none; padding: 0; margin: 0 0 1rem; }
.readout li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.readout li:last-child { border-bottom: 0; }
.readout b { display: inline-block; min-width: 8.5em; }

.explain { background: var(--accent-soft); border-radius: 8px; padding: .75rem 1rem; }
.explain p:last-child { margin-bottom: 0; }

details { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem; margin-bottom: .6rem; background: var(--card); }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .4rem; }

/* ---------- Shift Drill ---------- */
.drill-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.progress { color: var(--muted); }
.event { font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem; }
.step { margin-bottom: 1.1rem; }
.step h3 { font-size: 1rem; color: var(--muted); margin-bottom: .4rem; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .5rem; }
.choices button { text-align: left; }
.choices button.right { background: var(--good-soft); border-color: var(--good); color: var(--good); font-weight: 600; }
.choices button.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.feedback { margin-top: .5rem; font-size: .95rem; }
.feedback.ok { color: var(--good); }
.feedback.no { color: var(--bad); }
.result { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .85rem; font-weight: 600; }
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.no { background: var(--bad-soft); color: var(--bad); }

table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; background: var(--card); }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #eef1f6; font-size: .95rem; }

/* ---------- Shifters sheet ---------- */
.sheet h2 { border-bottom: 3px solid var(--line); padding-bottom: .3rem; }
.sheet h2.ad { border-color: var(--ad); }
.sheet h2.sras { border-color: var(--sras); }
.sheet h2.lras { border-color: var(--lras); }
.trap { border-left: 4px solid var(--bad); }
.toc { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.toc a { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: .25rem .8rem; text-decoration: none; }

/* ---------- Small screens ---------- */
@media (max-width: 800px) {
  .lab, .result { grid-template-columns: 1fr; }
  .problem dl { grid-template-columns: 1fr; }
  .problem dd { margin-bottom: .5rem; }
  h1 { font-size: 1.6rem; }
}

@media print {
  .site-header, .site-footer, .toc { display: none; }
  body { background: #fff; }
}

/* ---------- Loanable funds additions ---------- */
.legend .k-priv { color: #7a3db8; }
.slider-row.gov label { color: #7a3db8; }
.hint { display: block; color: var(--muted); font-size: .88rem; margin: .25rem 0 0; }
.convention {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem 1.1rem;
  margin: 0 0 1.25rem;
}
.convention legend { font-weight: 700; padding: 0 .3rem; }
.convention label { display: block; margin: .25rem 0; cursor: pointer; }
.convention input { margin-right: .4rem; }
