/* The problem sheets: units/NN-slug/problems.html. Same palette, type and part
   colours as the decks (slides/deck.css) and CURRICULUM.html, laid out as a page to
   be read beside a pad of paper rather than projected. */

:root {
  --ground: #f3f5f6; --surface: #ffffff; --surface-sunk: #eef1f2;
  --ink: #151a1d; --ink-soft: #59646a; --ink-faint: #8a949a;
  --rule: #d9dfe1; --rule-strong: #b9c3c6;
  --accent: #1f4a54; --accent-soft: #e2ecee;
  --warn: #8a3a3a; --warn-soft: #f6e9e9; --good: #1f6b3f; --good-soft: #e5f1e9;
  --c-root: #151a1d; --c-a: #1f4a54; --c-b: #8c5e12; --c-c: #1f6b3f;
  --c-d: #2a4a80; --c-e: #63397a; --c-f: #8a3a3a;
  --unit: var(--c-root);
  --f-display: "Zilla Slab", "Bitter", Georgia, serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #101416; --surface: #181d20; --surface-sunk: #141a1c;
    --ink: #e4e9eb; --ink-soft: #939ea4; --ink-faint: #6d787e;
    --rule: #283034; --rule-strong: #3b464b;
    --accent: #7fbdc9; --accent-soft: #1c2b30;
    --warn: #dd9090; --warn-soft: #2e1c1c; --good: #5cbb82; --good-soft: #17281e;
    --c-root: #e4e9eb; --c-a: #7fbdc9; --c-b: #d6a241; --c-c: #5cbb82;
    --c-d: #8fb0e8; --c-e: #b98fd0; --c-f: #dd9090;
  }
}
:root[data-theme="dark"] {
  --ground: #101416; --surface: #181d20; --surface-sunk: #141a1c;
  --ink: #e4e9eb; --ink-soft: #939ea4; --ink-faint: #6d787e;
  --rule: #283034; --rule-strong: #3b464b;
  --accent: #7fbdc9; --accent-soft: #1c2b30;
  --warn: #dd9090; --warn-soft: #2e1c1c; --good: #5cbb82; --good-soft: #17281e;
  --c-root: #e4e9eb; --c-a: #7fbdc9; --c-b: #d6a241; --c-c: #5cbb82;
  --c-d: #8fb0e8; --c-e: #b98fd0; --c-f: #dd9090;
}
body[data-trunk="a"] { --unit: var(--c-a); }
body[data-trunk="b"] { --unit: var(--c-b); }
body[data-trunk="c"] { --unit: var(--c-c); }
body[data-trunk="d"] { --unit: var(--c-d); }
body[data-trunk="e"] { --unit: var(--c-e); }
body[data-trunk="f"] { --unit: var(--c-f); }

* { box-sizing: border-box; }
html { background: var(--ground); }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 17px/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
.sheet { max-width: 820px; margin: 0 auto; padding: 40px 16px 96px; }

/* ---------------------------------------------------------------- head -- */

.sheet-head { border-bottom: 2px solid var(--ink); padding-bottom: 18px; margin-bottom: 8px; }
.eyebrow {
  font: 500 12px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--unit); margin: 0 0 12px;
}
h1 { font: 600 clamp(1.7rem, 4vw, 2.3rem)/1.12 var(--f-display); margin: 0 0 10px; }
.sheet-links { font: 14px var(--f-mono); color: var(--ink-faint); margin: 0 0 18px; }
.sheet-links a { color: var(--accent); }
.checkpoint {
  background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--unit);
  border-radius: 4px; padding: 12px 16px; margin: 14px 0;
}
.checkpoint b:first-child { font-family: var(--f-display); color: var(--unit); }
.howto { font-size: 15px; color: var(--ink-soft); }
.howto kbd {
  font: 12px var(--f-mono); border: 1px solid var(--rule-strong); border-radius: 3px;
  padding: 0 4px; background: var(--surface);
}
.preamble { font-size: 15.5px; }

/* the problem index */
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 8px; padding: 0; list-style: none; }
.toc a {
  display: inline-block; font: 500 13px var(--f-mono); text-decoration: none; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 3px; padding: 3px 8px; background: var(--surface);
}
.toc a:hover { border-color: var(--unit); color: var(--unit); }
.toc .routine { border-bottom: 3px solid var(--good); }
.toc .medium { border-bottom: 3px solid var(--c-b); }
.toc .hard { border-bottom: 3px solid var(--warn); }

/* -------------------------------------------------------------- problems -- */

h2.group {
  font: 600 1.3rem var(--f-display); margin: 44px 0 0; padding-bottom: 6px;
  border-bottom: 1px solid var(--rule-strong);
}
.problem { padding: 26px 0 22px; border-bottom: 1px solid var(--rule); scroll-margin-top: 16px; }
.problem > h3 {
  font: 600 1.18rem/1.3 var(--f-display); margin: 0 0 4px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
}
.pno { font: 700 1.05rem var(--f-mono); color: var(--unit); }
.tag {
  font: 500 11px var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
  border-radius: 3px; padding: 1px 6px; margin-left: auto;
}
.tag.routine { color: var(--good); background: var(--good-soft); }
.tag.medium { color: var(--c-b); background: var(--surface-sunk); }
.tag.hard { color: var(--warn); background: var(--warn-soft); }
.exercises { font: 13px/1.5 var(--f-mono); color: var(--ink-faint); margin: 0 0 12px; }

.statement > :first-child, details > div > :first-child { margin-top: 0; }
p { margin: .6em 0; }
ol, ul { padding-left: 1.5em; margin: .5em 0; }
li { margin: .25em 0; }
li > p { margin: .2em 0; }
code { font: .9em var(--f-mono); background: var(--surface-sunk); padding: 0 3px; border-radius: 3px; }
table { border-collapse: collapse; margin: .8em 0; font-size: 15px; display: block; overflow-x: auto; }
th, td { padding: 4px 10px; border-bottom: 1px solid var(--rule); text-align: left; }
th { border-bottom: 2px solid var(--ink); font-weight: 600; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* ------------------------------------------------ hints and the solution -- */

details { margin-top: 12px; }
details > summary {
  cursor: pointer; list-style: none; user-select: none;
  font: 500 13px var(--f-mono); letter-spacing: .06em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 4px; border: 1px solid var(--rule-strong);
  background: var(--surface); color: var(--ink-soft);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; font-size: 11px; transition: transform .12s ease; }
details[open] > summary::before { transform: rotate(90deg); }
details > summary:hover { border-color: var(--unit); color: var(--ink); }
details > div { padding: 10px 0 0 14px; border-left: 2px solid var(--rule); margin-left: 6px; }

details.hints > summary { color: var(--accent); }
details.hints > div { border-left-color: var(--accent-soft); }
/* rungs nest, so rung n+1 cannot even be seen until rung n is open */
details.rung { margin-top: 10px; }
details.rung > summary { text-transform: none; letter-spacing: 0; font-size: 13px; padding: 3px 9px; }

details.solution > summary { color: var(--warn); }
details.solution[open] > summary { color: var(--ink-soft); }
details.solution > div { border-left-color: var(--unit); }
.solution h4 {
  font: 600 1rem var(--f-display); margin: 1.2em 0 .3em; color: var(--ink-soft);
}

.sheet-foot { margin-top: 40px; font-size: 13px; color: var(--ink-faint); }
.sheet-foot a { color: var(--accent); }

/* the bar: the same D (theme) and a way out, as in the decks */
.sheet-bar {
  position: fixed; left: 12px; bottom: 12px; display: flex; gap: 6px; z-index: 5;
}
.sheet-bar button {
  font: 12px var(--f-mono); border: 1px solid var(--rule-strong); border-radius: 4px;
  background: var(--surface); color: var(--ink-soft); padding: 4px 8px; cursor: pointer;
}
.sheet-bar button:hover { color: var(--ink); border-color: var(--unit); }

@media print {
  .sheet-bar, details.hints, details.solution { display: none; }
  body { background: #fff; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .tag { margin-left: 0; }
}
