/* Shared design system for the Vercel Hobby course.
   Every lesson, reference page and the index link this file. */

:root {
  --paper: #fffff8;
  --ink: #151515;
  --muted: #66645c;
  --rule: #d8d5c6;
  --accent: #9a2a1f;
  --ok: #24613a;
  --bad: #9a2a1f;
  --code-bg: #f3f1e6;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "Iowan Old Style", Georgia, serif;
  --mono: Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  --col: 38rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161615;
    --ink: #e4e2d8;
    --muted: #a09d92;
    --rule: #3a3934;
    --accent: #e08a7d;
    --ok: #86c79a;
    --bad: #e08a7d;
    --code-bg: #22211f;
  }
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.58;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.16em; }
a:hover { color: var(--accent); }

/* ---------- page frame ---------- */

.site {
  max-width: calc(var(--col) + 2.5rem);
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  justify-content: space-between;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.site a { text-decoration: none; }
.site a:hover { text-decoration: underline; }
.site .home { font-variant: small-caps; letter-spacing: 0.08em; }
.site nav { display: flex; gap: 1rem; flex-wrap: wrap; }

.page {
  max-width: calc(var(--col) + 2.5rem);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* ---------- type ---------- */

h1 { font-weight: 400; font-size: 2.15rem; line-height: 1.15; margin: 0.4rem 0 1rem; }
h2 { font-weight: 400; font-style: italic; font-size: 1.5rem; line-height: 1.2; margin: 2.6rem 0 0.7rem; }
h3 { font-weight: 400; font-style: italic; font-size: 1.15rem; margin: 1.8rem 0 0.4rem; }
p, ul, ol, dl { margin: 0 0 1rem; }
li { margin-bottom: 0.35rem; }
strong { font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4rem 0; }

.eyebrow {
  margin: 2.2rem 0 0;
  font-variant: small-caps;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-size: 0.95rem;
}

.lede { font-size: 1.12rem; }

.win {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding: 0.75rem 0;
  margin: 1.2rem 0 1.6rem;
}
.win > span, .label {
  font-variant: small-caps;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin-right: 0.5rem;
}

/* ---------- code ---------- */

code, kbd, pre { font-family: var(--mono); }
code { font-size: 0.86em; background: var(--code-bg); padding: 0.08em 0.3em; border-radius: 2px; }
kbd { font-size: 0.82em; border: 1px solid var(--rule); border-bottom-width: 2px; padding: 0 0.35em; border-radius: 3px; }

.codeblock { position: relative; margin: 0 0 1rem; }
pre {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--code-bg);
  border-left: 3px solid var(--rule);
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
}
.codeblock pre { margin: 0; }
pre code { background: none; padding: 0; font-size: inherit; }
pre.output { border-left-style: dotted; color: var(--muted); }
.file {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}
.copy {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  font: 0.68rem var(--mono);
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.1rem 0.45rem;
  cursor: pointer;
}
.copy:hover, .copy:focus-visible { color: var(--ink); border-color: var(--ink); }

/* ---------- margin notes ---------- */

aside.note {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
  border-left: 2px solid var(--rule);
  padding-left: 0.8rem;
  margin: 0 0 1rem;
}
aside.note p:last-child { margin-bottom: 0; }

@media (min-width: 76rem) {
  .site, .page { max-width: calc(var(--col) + 21rem); padding-right: 19.75rem; }
  aside.note {
    float: right;
    clear: right;
    width: 15.5rem;
    margin-right: -18.5rem;
    border-left: 0;
    border-top: 1px solid var(--rule);
    padding: 0.4rem 0 0;
  }
}

/* ---------- tables (booktabs style) ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.2rem;
  font-size: 0.9rem;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
caption { caption-side: top; text-align: left; font-style: italic; color: var(--muted); padding-bottom: 0.35rem; }
th, td { text-align: left; vertical-align: top; padding: 0.4rem 0.7rem 0.4rem 0; }
thead th { font-weight: 400; font-variant: small-caps; letter-spacing: 0.06em; border-bottom: 1px solid var(--ink); }
tbody tr + tr td, tbody tr + tr th { border-top: 1px solid var(--rule); }
tbody th { font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* ---------- callouts ---------- */

.callout {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink);
  padding: 0.7rem 0.9rem;
  margin: 1.4rem 0;
}
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout.warn { border-left-color: var(--accent); }
.callout.source { border-left-color: var(--ok); }

/* ---------- steps (checklist) ---------- */

ol.steps { padding-left: 0; list-style: none; counter-reset: step; }
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0.75rem 0 0.2rem 2.3rem;
  border-top: 1px solid var(--rule);
  margin: 0;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.7rem;
  font-size: 1.25rem;
  font-style: italic;
  color: var(--accent);
}
ol.steps > li.done::before { content: "\2713"; font-style: normal; color: var(--ok); }
ol.steps > li.done > :not(.tick) { opacity: 0.62; }
.tick {
  float: right;
  margin-left: 0.8rem;
  font: 0.7rem var(--mono);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.tick input { vertical-align: -0.12em; margin-right: 0.25em; accent-color: var(--ok); }

/* ---------- recall prompts ---------- */

details.recall {
  border-top: 1px solid var(--rule);
  padding: 0.55rem 0;
}
details.recall:last-of-type { border-bottom: 1px solid var(--rule); margin-bottom: 1.2rem; }
details.recall summary { cursor: pointer; }
details.recall summary::marker { color: var(--accent); }
details.recall[open] summary { margin-bottom: 0.4rem; }
details.recall > p { margin: 0 0 0.3rem 1.1rem; color: var(--muted); }

/* ---------- quiz ---------- */

.quiz { margin-top: 2.6rem; }
.q { border-top: 1px solid var(--rule); padding: 0.9rem 0 0.3rem; }
.q .prompt { margin-bottom: 0.6rem; }
.q .options { list-style: none; padding: 0; margin: 0 0 0.7rem; }
.q .options li { margin: 0 0 0.4rem; }
.q .options button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}
.q .options button:hover:not(:disabled), .q .options button:focus-visible { border-color: var(--ink); }
.q .options button:disabled { cursor: default; color: var(--muted); }
.q .options button.right { border-color: var(--ok); border-left-width: 4px; color: var(--ink); }
.q .options button.wrong { border-color: var(--bad); border-left-width: 4px; text-decoration: line-through; }
.q .mark { font: 0.7rem var(--mono); margin-left: 0.6rem; text-decoration: none; display: inline-block; }
.q .right .mark { color: var(--ok); }
.q .wrong .mark { color: var(--bad); }
.verdict { margin-bottom: 0.3rem; font-variant: small-caps; letter-spacing: 0.06em; }
.verdict.ok { color: var(--ok); }
.verdict.no { color: var(--bad); }
.why { color: var(--muted); font-size: 0.92rem; }
.quiz-status { font: 0.78rem var(--mono); color: var(--muted); margin-top: 0.8rem; }
.retry {
  font: 0.78rem var(--mono);
  color: inherit;
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 3px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

/* ---------- pager, index ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--ink);
  margin-top: 3rem;
  padding-top: 0.8rem;
  font-size: 0.92rem;
}
.pager a { text-decoration: none; }
.pager a:hover { text-decoration: underline; }
.pager .next { text-align: right; margin-left: auto; }
.pager small { display: block; font-variant: small-caps; letter-spacing: 0.08em; color: var(--muted); }

ol.toc { list-style: none; padding: 0; counter-reset: toc; }
ol.toc > li {
  counter-increment: toc;
  position: relative;
  border-top: 1px solid var(--rule);
  padding: 0.7rem 0 0.4rem 2.3rem;
  margin: 0;
}
ol.toc > li::before {
  content: counter(toc);
  position: absolute;
  left: 0;
  top: 0.6rem;
  font-size: 1.35rem;
  font-style: italic;
  color: var(--accent);
}
ol.toc a { font-size: 1.1rem; }
ol.toc p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.92rem; }
.progress { font: 0.7rem var(--mono); color: var(--ok); }

dl.glossary dt { font-weight: 700; margin-top: 0.9rem; }
dl.glossary dd { margin: 0.1rem 0 0; }
dl.glossary dd small { color: var(--muted); }

.tested { font: 0.72rem var(--mono); color: var(--muted); }

.cols { columns: 2 17rem; column-gap: 2rem; }
.cols > * { break-inside: avoid; }

/* ---------- print ---------- */

@media print {
  :root { --paper: #fff; --ink: #000; --muted: #444; --rule: #bbb; --code-bg: #f4f4f4; --accent: #000; --ok: #000; --bad: #000; }
  html { font-size: 10.5pt; }
  .site nav, .copy, .pager, .retry, .quiz-status, .tick { display: none !important; }
  .site, .page { max-width: none; padding: 0; }
  aside.note { float: none; width: auto; margin: 0 0 0.8rem; border-left: 2px solid var(--rule); border-top: 0; padding: 0 0 0 0.7rem; }
  a { text-decoration: none; }
  .page a[href^="http"]::after { content: " \2039" attr(href) "\203A"; font: 0.68em var(--mono); color: var(--muted); word-break: break-all; }
  pre { white-space: pre-wrap; word-break: break-word; }
  table, pre, .callout, .q, ol.steps > li, dl.glossary dt + dd { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  details.recall > p { display: block; }
}
