/* Beyond STEP: site style, matching drafts/latex/stepbook.sty */
:root {
  --ink: #1F2A33;
  --ink-soft: #4a5761;
  --teal: #1D5C63;
  --teal-pale: #E8F1F1;
  --amber: #B5651D;
  --amber-pale: #FBF1E6;
  --plum: #5B3F72;
  --plum-pale: #F2EDF6;
  --rule: #B9C6C8;
  --paper: #FFFFFF;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "TeX Gyre Pagella", "URW Palladio L", Georgia, serif;
  --sans: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --measure: 44rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.09rem;
  line-height: 1.6;
}
a { color: var(--teal); }
a:hover { color: var(--amber); }
img { max-width: 100%; height: auto; }

.wrap { max-width: 64rem; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: calc(var(--measure) + 32px); }

/* ---------- header / footer ---------- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--paper); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 3.4rem; }
.brand { font-family: var(--sans); font-weight: 700; color: var(--teal); text-decoration: none; letter-spacing: 0.01em; font-size: 1.05rem; }
.site-header nav a { font-family: var(--sans); font-size: 0.9rem; color: var(--ink-soft); text-decoration: none; margin-left: 1.2rem; }
.site-header nav a:hover { color: var(--amber); }
.site-footer { margin-top: 4rem; border-top: 1px solid var(--rule); padding: 1.5rem 0 2.5rem; font-family: var(--sans); font-size: 0.82rem; color: var(--ink-soft); }
.site-footer p { margin: 0.25rem 0; }

/* ---------- banners ---------- */
.hero, .chapter-banner, .section-banner { background: var(--teal); color: #fff; }
.hero { border-bottom: 6px solid var(--amber); padding: 4.5rem 0 3.5rem; }
.hero-kicker, .ch-kicker { font-family: var(--sans); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase; color: #b9d0d2; }
.hero h1 { font-family: var(--sans); font-size: clamp(2.6rem, 7vw, 4.2rem); line-height: 1.05; margin: 0.4rem 0 0.6rem; }
.hero-sub { font-style: italic; font-size: 1.3rem; margin: 0; color: #e3eeee; max-width: 36rem; }

.chapter-banner { border-bottom: 6px solid var(--amber); padding: 3.5rem 0 2.6rem; }
.ch-num { font-family: var(--sans); font-weight: 700; font-size: clamp(5rem, 14vw, 7.5rem); line-height: 0.9; margin: 0.2rem 0 1.4rem; }
.chapter-banner h1 { font-family: var(--sans); font-size: clamp(1.9rem, 5vw, 2.7rem); line-height: 1.1; margin: 0 0 0.6rem; }
.strap { font-style: italic; font-size: 1.15rem; color: #dbe8e8; margin: 0; max-width: 38rem; }

.section-banner { padding: 1.4rem 0 1.9rem; }
.section-banner .wrap { max-width: calc(var(--measure) + 32px); }
.crumb { font-family: var(--sans); font-size: 0.82rem; color: #b9d0d2; text-decoration: none; }
.crumb:hover { color: #fff; }
.src { font-family: var(--sans); font-size: 0.85rem; color: #cfe0e1; letter-spacing: 0.04em; margin-top: 0.3rem; }
.sec-head { display: flex; align-items: center; gap: 1.1rem; margin-top: 1.1rem; }
.sec-num { font-family: var(--sans); font-weight: 700; font-size: clamp(2.4rem, 8vw, 3.4rem); line-height: 1; flex: none; }
.sec-head h1 { font-family: var(--sans); font-size: clamp(1.45rem, 4.5vw, 2rem); line-height: 1.15; margin: 0; }

/* ---------- downloads ---------- */
.downloads { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 1.6rem 0 0.6rem; }
.dl { display: inline-flex; align-items: center; gap: 0.7rem; padding: 0.6rem 1rem 0.6rem 0.8rem; border: 1px solid var(--rule); border-radius: 4px; text-decoration: none; color: var(--ink); background: #fff; }
.dl:hover { border-color: var(--teal); background: var(--teal-pale); color: var(--ink); }
.dl-icon { width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--teal); flex: none; position: relative; }
.dl-icon::after { content: ""; position: absolute; left: 50%; top: 45%; width: 0.5rem; height: 0.5rem; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: translate(-50%, -50%) rotate(45deg); }
.dl-label { display: block; font-family: var(--sans); font-weight: 700; font-size: 0.92rem; color: var(--teal); }
.dl-sub { display: block; font-family: var(--sans); font-size: 0.78rem; color: var(--ink-soft); }

/* ---------- contents ---------- */
.contents-head { font-family: var(--sans); font-size: 0.85rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); margin: 2.4rem 0 0.8rem; }
.toc { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.toc li { display: flex; align-items: center; gap: 0.6rem; border-bottom: 1px solid var(--rule); }
.toc-link { flex: 1; display: grid; grid-template-columns: 2.6rem 1fr auto; gap: 0.6rem; align-items: baseline; padding: 0.6rem 0; text-decoration: none; color: var(--ink); }
.toc-link:hover .toc-title { color: var(--teal); text-decoration: underline; }
.toc-num { font-family: var(--sans); font-weight: 700; color: var(--teal); }
.toc-src { font-family: var(--sans); font-size: 0.75rem; color: #6c9497; white-space: nowrap; }
.toc-ws { font-family: var(--sans); font-size: 0.75rem; font-weight: 700; color: var(--amber); text-decoration: none; border: 1px solid var(--amber); border-radius: 3px; padding: 0.1rem 0.45rem; }
.toc-ws:hover { background: var(--amber-pale); }
@media (max-width: 34rem) { .toc-src { display: none; } .toc-link { grid-template-columns: 2.3rem 1fr; } }

/* ---------- home ---------- */
.lede { font-size: 1.22rem; }
.parts { list-style: none; padding: 0; margin: 0; counter-reset: part; display: grid; gap: 0.5rem; }
.parts li { counter-increment: part; display: grid; grid-template-columns: 2rem 1fr; column-gap: 0.6rem; padding: 0.5rem 0; border-bottom: 1px solid var(--rule); }
.parts li::before { content: counter(part); grid-row: span 2; font-family: var(--sans); font-weight: 700; color: var(--teal); font-size: 1.1rem; }
.parts strong { font-family: var(--sans); font-size: 0.95rem; color: var(--teal); }
.parts span { font-size: 0.98rem; }
.note { font-size: 0.98rem; color: var(--ink-soft); margin-top: 1.2rem; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.ch-card { display: flex; gap: 0.9rem; padding: 1.1rem 1.1rem 1rem; border: 1px solid var(--rule); border-radius: 4px; text-decoration: none; color: var(--ink); background: #fff; }
.ch-card.live { border-color: var(--teal); border-top: 4px solid var(--teal); }
.ch-card.live:hover { background: var(--teal-pale); color: var(--ink); }
.card-num { font-family: var(--sans); font-weight: 700; font-size: 2rem; line-height: 1; color: var(--rule); flex: none; width: 2.2rem; }
.ch-card.live .card-num { color: var(--teal); }
.card-body { display: flex; flex-direction: column; gap: 0.35rem; }
.card-title { font-family: var(--sans); font-weight: 700; font-size: 1rem; line-height: 1.25; }
.card-blurb { font-size: 0.92rem; line-height: 1.45; color: var(--ink-soft); }
.card-status { font-family: var(--sans); font-size: 0.78rem; font-weight: 700; color: var(--teal); margin-top: auto; padding-top: 0.3rem; }
.card-status.soon { color: #8b989e; font-weight: 400; }

/* ---------- prose ---------- */
.prose { margin-top: 1.4rem; }
.prose p { margin: 0 0 0.8rem; hyphens: auto; }
.prose h2 { font-family: var(--sans); font-size: 1.28rem; color: var(--teal); margin: 2.3rem 0 0.8rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--rule); }
.prose h3 { font-family: var(--sans); font-size: 1.02rem; color: var(--ink); margin: 1.7rem 0 0.5rem; }
.prose h4.stage { font-family: var(--sans); font-size: 1.02rem; margin: 1.8rem 0 0.6rem; }
.stage-n { color: var(--amber); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; margin-right: 0.5rem; }
.prose strong { font-family: var(--sans); font-size: 0.94em; }
.prose ul { padding-left: 1.4rem; list-style: none; }
.prose ul > li { position: relative; margin-bottom: 0.35rem; }
.prose ul > li::before { content: "\25B8"; position: absolute; left: -1.2rem; color: var(--teal); }
.prose ol { padding-left: 2.2rem; }
.prose li > p { margin-bottom: 0.3rem; }
.prose ol.roman { list-style: none; counter-reset: rom; }
.prose ol.roman > li { counter-increment: rom; position: relative; }
.prose ol.roman > li::before { content: "(" counter(rom, lower-roman) ")"; position: absolute; left: -2.2rem; width: 1.9rem; text-align: right; }
.prose ol.alpha { list-style: none; counter-reset: alp; }
.prose ol.alpha > li { counter-increment: alp; position: relative; }
.prose ol.alpha > li::before { content: "(" counter(alp, lower-alpha) ")"; position: absolute; left: -2.2rem; width: 1.9rem; text-align: right; }
.qed { float: right; color: var(--teal); font-size: 0.85em; margin-left: 0.5rem; }
.hard { font-family: var(--sans); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); font-weight: 700; }
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; max-width: 100%; padding: 2px 0; }
.table-wrap { overflow-x: auto; margin: 1rem 0; }
.prose table { border-collapse: collapse; font-size: 0.93rem; width: 100%; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); }
.prose th { font-family: var(--sans); text-align: left; border-bottom: 1px solid var(--ink); padding: 0.4rem 0.6rem 0.4rem 0; }
.prose td { padding: 0.3rem 0.6rem 0.3rem 0; vertical-align: top; }
.prose td:first-child { font-family: var(--sans); font-weight: 700; color: var(--teal); }

.essay-kicker { font-family: var(--sans); font-weight: 700; font-size: 0.85rem; color: var(--amber); margin-top: 2.8rem; }
.essay-title { font-family: var(--sans); color: var(--teal); font-size: 2rem; margin: 0.2rem 0 0.5rem; line-height: 1.15; }
.essay-rule { width: 8rem; height: 3px; background: var(--amber); margin-bottom: 1.6rem; }
.pullquote { text-align: center; margin: 1.6rem auto; max-width: 34rem; }
.pullquote p { font-style: italic; font-size: 1.2rem; color: var(--teal); margin-bottom: 0.3rem; }
.pullquote p.who { font-style: normal; font-family: var(--sans); font-size: 0.85rem; color: var(--amber); }

/* ---------- boxes ---------- */
.box-title { display: block; font-family: var(--sans); font-weight: 700; font-size: 0.88rem; margin-bottom: 0.5rem; }
.stepquestion { background: var(--teal-pale); border-left: 4px solid var(--teal); padding: 0.9rem 1.1rem 0.5rem; margin: 1.2rem 0 1.4rem; }
.stepquestion .box-title { color: var(--teal); }

.askyourself, .pausebox { position: relative; padding: 0.7rem 1rem 0.2rem 3.1rem; margin: 1rem 0; border-radius: 4px; }
.askyourself { background: var(--plum-pale); }
.pausebox { background: var(--amber-pale); border: 1px dashed var(--amber); }
.askyourself::before, .pausebox::before { position: absolute; left: 0.85rem; top: 0.75rem; width: 1.45rem; height: 1.45rem; border-radius: 50%; color: #fff; font-family: var(--sans); font-weight: 700; font-size: 0.9rem; line-height: 1.45rem; text-align: center; }
.askyourself::before { content: "?"; background: var(--plum); }
.pausebox::before { content: "\270E"; background: var(--amber); font-size: 0.85rem; }
.askyourself > p:first-child::before, .pausebox > p:first-child::before { font-family: var(--sans); font-weight: 700; font-size: 0.8rem; margin-right: 0.5rem; }
.askyourself > p:first-child::before { content: "Ask yourself"; color: var(--plum); }
.pausebox > p:first-child::before { content: "Pause and try"; color: var(--amber); }

.skillbox { border: 1.5px solid var(--teal); padding: 0.9rem 1.2rem 0.4rem; margin: 1.2rem 0; }
.skillbox .box-title { color: var(--teal); font-size: 0.95rem; }
.historybox { border-bottom: 1px solid var(--rule); padding: 0.2rem 0 0.4rem; margin: 1rem 0 1.4rem; }
.historybox .box-title { color: var(--amber); }

.exercises ol { padding-left: 2rem; }
.exercises ol > li::marker { font-family: var(--sans); font-weight: 700; color: var(--teal); }
.exercises ol > li { margin-bottom: 0.7rem; }

/* ---------- figures ---------- */
figure.stepfig { margin: 1.8rem 0; text-align: center; }
figure.stepfig img { width: auto; max-height: 30rem; }
figure.steppic { margin: 1rem 0; text-align: center; }
figure.steppic img { width: auto; max-height: 22rem; }
figure.stepfig figcaption { text-align: left; font-size: 0.93rem; line-height: 1.5; max-width: 36rem; margin: 0.6rem auto 0; }
.fig-label { font-family: var(--sans); font-weight: 700; color: var(--teal); margin-right: 0.5rem; }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 3rem 0 0; padding-top: 1.2rem; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.92rem; }
.pager a { text-decoration: none; font-weight: 700; }
.pager .next { margin-left: auto; text-align: right; }

@media print {
  .site-header, .site-footer, .downloads, .pager { display: none; }
}
