/* ==========================================================================
   How to Survive Danzhou — stylesheet
   One stylesheet shared by all four pages: external, never inline or internal.
   Order: variables → base → layout → components → page-specific → responsive
   ========================================================================== */

/* ---- 1. Variables — change a colour here and the whole site follows ---- */
:root {
  --paper: #fbfaf7;
  --ink: #12141a;
  --dim: #5b6270;
  --line: #ded9d0;
  --accent: #c2410c;
  --accent-soft: #fdf0e8;
  --card: #ffffff;
  /* Text on the accent: the light-mode orange is dark enough for white text; dark mode is handled below */
  --on-accent: #ffffff;
  --max: 68rem;
  --radius: 10px;
  --header-offset: 5rem;   /* real height of the sticky header — anchor jumps clear it by this much;
                              overridden at runtime by js/header.js, which measures the real height */
  --head-pad: .8rem;       /* the header's padding-block; the search panel's top is derived from it */
  --search-w: 15rem;       /* 240px inline search field */
  --search-h: 2.5625rem;   /* 41px = the theme button's rendered height */
  --search-panel-w: 22rem; /* 352px results panel */
  --row-hover: var(--accent-soft);
}

/* Dark mode: js/theme.js sets data-theme="dark" on <html> */
html[data-theme="dark"] {
  --paper: #14161c;
  --ink: #ecebe7;
  --dim: #a2a8b4;
  --line: #2c303a;
  --accent: #fb8f5c;
  --accent-soft: #241c17;
  --card: #1b1e25;
  /* The dark-mode orange is lighter: white on it is only 2.3:1, dark text reaches 7.9:1 */
  --on-accent: #14161c;
  /* accent-soft is 1.005:1 against --card here, so a hovered or highlighted
     row must use --line instead — see the search panel below */
  --row-hover: var(--line);
}

/* ---- 2. Base ---- */
*,
*::before,
*::after { box-sizing: border-box; }   /* border-box: width includes padding and border */

/* scroll-padding-top: the header is sticky, so an anchored heading has to clear
   it — otherwise the heading lands behind the header and is completely hidden */
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-offset);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  /* latin-first stack: this site is written in English, so no CJK face should win */
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, system-ui, sans-serif;
  /* Inherited properties — set once on body and they flow down */
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.9rem, 5vw, 3.1rem); margin: 0 0 .45em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.9rem); margin: 2.4em 0 .6em; }
h3 { font-size: 1.15rem; margin: 1.8em 0 .4em; }

p, li { max-width: 42em; }

/* Keyboard access: skip straight to the main content */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--on-accent);
  padding: .7rem 1.1rem;
  z-index: 99;
  border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

/* One focus ring for the whole site. The browser's default blue is nearly
   invisible against the dark paper, so it is replaced here once; nothing
   else on the site may set outline:none. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Text for the screen reader only: kept in the layout as one clipped pixel,
   not display:none, so it is still announced. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- 3. Layout ---- */
.wrap {
  width: min(100% - 2.5rem, var(--max));
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: var(--head-pad);
}

.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;      /* pushes the navigation to the right */
}
.brand span { color: var(--accent); }

.site-nav ul {
  display: flex;
  gap: .35rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.site-nav a {
  display: block;
  padding: .42rem .7rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--dim);
  font-size: .95rem;
}
.site-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.site-nav a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }

main { padding-block: 2.5rem 4rem; }

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2rem;
  color: var(--dim);
  font-size: .92rem;
}

/* Credits and sources: one step smaller than the footer text, but still readable */
.fineprint {
  font-size: .82rem;
  line-height: 1.65;
  opacity: .9;
  margin: .9rem 0 0;
  max-width: 52em;
}

/* Two columns: main content + sidebar */
.with-aside {
  display: grid;
  gap: 2.5rem;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 60rem) {
  .with-aside { grid-template-columns: minmax(0, 1fr) 17rem; }
}

/* Card grid: auto-fitting, collapsing to one column on a phone */
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin: 1.5rem 0;
}

/* ---- 4. Components ---- */
.hero {
  padding-block: clamp(2rem, 7vw, 4.5rem);
  border-bottom: 1px solid var(--line);
}
.hero .kicker {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 1rem;
}
.hero p.lead {
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  color: var(--dim);
  max-width: 34em;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

.note {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .9rem 1.1rem;
  margin: 1.5rem 0;
}
.note p:last-child { margin-bottom: 0; }

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: .97rem;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: .6rem .7rem;
  text-align: left;
  vertical-align: top;
}
th { background: var(--accent-soft); }

/* The leading column holds row headers (<th scope="row">), so it does not take
   the header colour — a whole orange column would flatten the hierarchy */
tbody th { background: none; font-weight: 600; }

/* Filter controls — driven by js/filter.js */
.filters {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 1rem;
}
.filters button {
  font: inherit;
  font-size: .95rem;
  padding: .45rem .9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.filters button:hover { border-color: var(--accent); color: var(--accent); }
.filters button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.filter-status { color: var(--dim); font-size: .92rem; margin: 0 0 1rem; }

/* Photograph: image + caption. The source goes on its own .credit line */
.photo { margin: 2rem 0; }
.photo img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.photo figcaption {
  color: var(--dim);
  font-size: .9rem;
  margin-top: .65rem;
  max-width: 46em;
}
.photo .credit { display: block; font-size: .82rem; }

/* Two side by side, stacking on narrow screens */
.photo-pair {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin: 2rem 0;
}
.photo-pair .photo { margin: 0; }

/* Theme toggle button */
.theme-toggle {
  font: inherit;
  font-size: .95rem;
  padding: .42rem .7rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--dim);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---- 4b. Site search ---------------------------------------------------
   A header field that indexes the four pages in the browser at runtime.
   Three layouts, and in every one the header keeps exactly the height it
   had before the search was opened — the expanded field never participates
   in the row the header's height is taken from. */

.search { position: relative; }
.search [hidden] { display: none !important; }

.search__toggle {
  display: none;               /* desktop shows the field, not the button */
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--dim);
  cursor: pointer;
}
.search__toggle:hover { border-color: var(--accent); color: var(--accent); }
.search__toggle .search__cross { display: none; }
.search__toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.search__toggle[aria-expanded="true"] .search__glass { display: none; }
.search__toggle[aria-expanded="true"] .search__cross { display: block; }

.search__box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 var(--search-w);
}
.search__icon {
  position: absolute;
  left: .72rem;
  width: 16px;
  height: 16px;
  color: var(--dim);
  pointer-events: none;
}
.search__input {
  width: 100%;
  height: var(--search-h);
  padding: 0 .7rem 0 2.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  line-height: 1;
}
.search__input::placeholder { color: var(--dim); opacity: 1; }  /* Firefox dims it by default */
.search__input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.search__clear {
  position: absolute;
  right: .4rem;
  height: 100%;
  padding: 0 .4rem;
  border: 0;
  background: none;
  font: inherit;
  font-size: .82rem;
  color: var(--dim);
  cursor: pointer;
}
.search__clear:hover { color: var(--ink); }
.search__box.has-value .search__input { padding-right: 2.6rem; }

.search__panel {
  position: absolute;
  top: calc(100% + var(--head-pad) + 1px);
  left: 0;
  width: var(--search-panel-w);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 32px -24px rgb(0 0 0 / .45);
  z-index: 20;
  max-height: min(26rem, 70vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.s-meta {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  margin: 0;
  padding: .45rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
  color: var(--dim);
}
.s-keys { font-size: .82rem; color: var(--dim); }

.s-list { list-style: none; margin: 0; padding: 0; }

.s-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: .72rem 1rem;
  cursor: pointer;
}
.s-row + .s-row { border-top: 1px solid var(--line); }
.s-row:hover { background: var(--row-hover); }
.s-row:hover .s-title { color: var(--accent); }
.s-row.is-active { background: var(--row-hover); outline: 2px solid var(--accent); outline-offset: -2px; }

.s-page {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
}
.s-title {
  display: block;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.s-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
  font-size: .92rem;
  line-height: 1.5;
  color: var(--dim);
  overflow-wrap: anywhere;
}

mark {
  background: var(--accent-soft);
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  border-radius: 2px;
  padding: 0 .1em;
}
html[data-theme="dark"] mark { background: var(--line); }

.s-empty { padding: 1.35rem 1rem; }
.s-empty strong { display: block; font-size: .95rem; font-weight: 600; color: var(--ink); }
.s-empty span { display: block; margin-top: .25rem; font-size: .92rem; color: var(--dim); }
.s-retry {
  margin-top: .5rem;
  font: inherit;
  font-size: .88rem;
  padding: .35rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--accent);
  cursor: pointer;
}
.s-retry:hover { border-color: var(--accent); }

/* Below 60rem the field collapses into the button, so a 60rem-wide header
   does not have to grow a third row. The field's own position changes per
   band — absolute over the nav row on a phone, in-flow on a mid-sized
   window — but the header height never moves (see js/search.js). */
@media (max-width: 60rem) {
  .search__toggle { display: inline-flex; }
  .search__box { display: none; }
  .search__panel { max-height: min(50svh, 22rem); }
}

/* Mid-sized window: the field replaces the brand and nav in the one row,
   and the toggle stays put as the close control. */
@media (min-width: 40.0625rem) and (max-width: 60rem) {
  .search[data-open] { display: flex; align-items: center; gap: .5rem; flex: 1 1 auto; max-width: 26rem; margin-right: auto; }
  .search[data-open] .search__box { position: static; display: flex; flex: 1 1 auto; }
  .site-header[data-search-open] .brand,
  .site-header[data-search-open] .site-nav { display: none; }
}

/* Phone: the field covers the nav row (nav keeps its slot via visibility),
   and both the field and the panel anchor to the header, not to the button. */
@media (max-width: 40rem) {
  .search { position: static; }
  .search__panel {
    top: calc(100% + 1px);
    left: 1.25rem;
    right: 1.25rem;
    width: auto;
  }
  .search[data-open] .search__box {
    display: flex;
    position: absolute;
    left: 1.25rem;
    right: 1.25rem;
    bottom: var(--head-pad);
  }
  .search[data-open] .search__box .search__input { height: 2.75rem; font-size: 1rem; }
  .search[data-open] ~ .site-nav { visibility: hidden; }
}

/* 641–736px is the tight band: the 44px button plus its gap leaves the
   nav only ~24px of slack, so the nav links lose a little side padding. */
@media (min-width: 40.0625rem) and (max-width: 46rem) {
  .site-header .wrap { gap: .5rem; }
  .site-nav a { padding-inline: .5rem; }
}

/* ---- 4c. The useless machine -----------------------------------------
   A toy at the foot of the home page: one question, one lever, one answer
   that helps nobody. js/machine.js drives it; without JavaScript the
   whole block stays hidden, and the page still reads. */

.machine {
  --screen: #14161c;
  --screen-ink: #f5f1e8;
  --screen-dim: #a8adb5;

  max-width: 40rem;
  margin: 1.5rem 0 0;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 32px -28px rgb(0 0 0 / .55);
}

/* the readout */
.machine__screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: .75rem;
  padding: .9rem 1rem;
  border-radius: 8px;
  background: var(--screen);
}

.machine__label,
.machine__slip-label {
  margin: 0;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #8b9098;
}

.machine__q {
  margin: .35rem 0 0;
  min-height: 1.35em;
  max-width: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 1.05rem;
  line-height: 1.35;
  color: var(--screen-ink);
  overflow-wrap: anywhere;
}

.machine__status {
  margin: .45rem 0 0;
  max-width: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .76rem;
  color: var(--screen-dim);
}

.machine__status::after {
  content: "\258C";              /* ▌ — a cursor, so it looks switched on */
  margin-left: 2px;
  animation: machine-blink 1.1s steps(1) infinite;
}

/* the dial */
.machine__gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.machine__gauge svg { display: block; width: 100%; height: auto; }

.machine__track {
  fill: none;
  stroke: #3a3f49;
  stroke-width: 7;
  stroke-linecap: round;
}

.machine__needle {
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  transform: rotate(-68deg);
  transform-origin: 100px 104px;
  transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}

.machine__pin { fill: var(--screen-ink); }

.machine__gauge-label {
  margin: 0;
  font-size: .58rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #6f757e;
}

/* input + lever */
.machine__controls {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
}

.machine__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.75rem;
  padding: 0 .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
}

.machine__input::placeholder { color: var(--dim); opacity: 1; }

.machine__input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.machine__run {
  flex: 0 0 auto;
  height: 2.75rem;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color .15s;
}

.machine__run:hover { background: var(--ink); }
.machine__run:active { transform: translateY(1px); }

.machine__meter {
  height: 6px;
  margin-top: .75rem;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.machine__meter span {
  display: block;
  height: 100%;
  width: 3%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .3s ease;
}

/* the slip the answer is printed on */
.machine__slot {
  height: 0;
  overflow: hidden;
  transition: height .4s cubic-bezier(.2, .8, .2, 1);
}

.machine__slip {
  margin-top: .75rem;
  padding: .8rem 1rem .9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 2px dashed var(--line);
  border-radius: 0 0 8px 8px;
  transform: translateY(-102%);
  transition: transform .45s cubic-bezier(.2, .8, .2, 1);
}

.machine__answer {
  margin: .25rem 0 0;
  max-width: none;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 1.15rem;
  line-height: 1.3;
  color: var(--ink);
}

/* ---- what the machine does while it thinks ---- */

.machine[data-state="thinking"] .machine__gauge svg,
.machine[data-state="thinking"] .machine__meter span { will-change: transform; }

.machine[data-state="thinking"] .machine__needle {
  animation: machine-swing .82s ease-in-out infinite;
}

.machine[data-state="thinking"] .machine__meter span {
  animation: machine-fill 2.2s linear infinite;
}

.machine[data-state="thinking"] .machine__q {
  animation: machine-blur .5s steps(2) infinite;
}

.machine[data-state="answering"] .machine__needle {
  transform: rotate(74deg);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.3);
}

.machine[data-state="answering"] .machine__meter span { width: 100%; }

.machine[data-state="answering"] .machine__slot { height: 5.9rem; }
.machine[data-state="answering"] .machine__slip { transform: none; }

@keyframes machine-blink { 50% { opacity: 0; } }

@keyframes machine-swing {
  0%   { transform: rotate(-72deg); }
  18%  { transform: rotate(58deg); }
  36%  { transform: rotate(-28deg); }
  55%  { transform: rotate(42deg); }
  72%  { transform: rotate(-52deg); }
  88%  { transform: rotate(14deg); }
  100% { transform: rotate(-72deg); }
}

@keyframes machine-fill {
  0%   { width: 3%; }
  12%  { width: 36%; }
  24%  { width: 19%; }
  40%  { width: 64%; }
  52%  { width: 47%; }
  70%  { width: 89%; }
  82%  { width: 71%; }
  100% { width: 96%; }
}

@keyframes machine-blur {
  50% { opacity: .55; }
}

@media (max-width: 30rem) {
  .machine__screen { grid-template-columns: minmax(0, 1fr); }
  .machine__gauge { display: none; }
}

/* ---- 4d. Photo card + gallery ----------------------------------------
   A small photo on the canteen card, and an auto-advancing strip at the
   foot of the campus page. js/gallery.js owns the strip and its list of
   photographs; the markup here is just the frame it fills. */

.card__photo {
  margin: 0 0 .7rem;
}

.card__photo img {
  border: 1px solid var(--line);
  border-radius: 6px;
}

.card__photo figcaption {
  margin-top: .4rem;
  font-size: .78rem;
  line-height: 1.5;
  color: var(--dim);
}

.gallery {
  max-width: 40rem;
  margin: 1.5rem 0 0;
}

.gallery[hidden] { display: none; }

/* One fixed 16:9 frame, whatever each photograph's own shape: tall ones
   are cropped (centred, or wherever each entry asks), so the page never
   jumps as the strip moves. */
.gallery__frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);      /* the colour that shows while one loads */
  aspect-ratio: 16 / 9;
}

.gallery__track {
  display: flex;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  transition: transform .5s cubic-bezier(.4, 0, .2, 1);
}

.gallery__slide {
  flex: 0 0 100%;
  min-width: 0;
}

.gallery__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  margin-top: .5rem;
}

.gallery__controls { display: flex; gap: .35rem; }

.gallery__controls button {
  font: inherit;
  font-size: .85rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0 .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.gallery__controls button:hover { border-color: var(--accent); color: var(--accent); }
.gallery__controls button:active { transform: translateY(1px); }

.gallery__caption {
  flex: 1 1 16rem;
  margin: 0;
  max-width: none;
  font-size: .9rem;
  color: var(--dim);
}

.gallery__credit {
  display: block;
  margin-top: .1rem;
  font-size: .78rem;
  color: var(--dim);
  opacity: .85;
}

.gallery__count {
  font-size: .85rem;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* ---- 5. Page-specific ---- */
.toc {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  position: sticky;
  top: var(--header-offset);
  align-self: start;
  font-size: .95rem;
}
.toc h2 { margin: 0 0 .6rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); }
.toc ul { margin: 0; padding-left: 1.1em; }
.toc li { margin: .3em 0; }

.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 3rem;
  margin: 1.2rem 0;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: .1rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 50%;
  font-weight: 700;
  font-size: .95rem;
}

.checklist { list-style: none; padding: 0; }
.checklist li { padding-left: 1.7rem; position: relative; margin: .45em 0; }
.checklist li::before {
  content: "☐";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 1.1em;
}

/* ---- 6. Responsive details ---- */
@media (max-width: 40rem) {
  /* On a phone the header becomes two rows: brand + search + theme button,
     then the nav. Without this, the pieces wrap to three rows and the
     sticky header eats a fifth of the screen */
  :root { --header-offset: 7rem; --head-pad: .6rem; }

  .site-header .wrap {
    padding-block: var(--head-pad);
    gap: .35rem .6rem;
  }
  .brand { order: 1; }
  .search { order: 2; }
  .theme-toggle { order: 3; }
  .site-nav { order: 4; flex-basis: 100%; }
  .site-nav ul { gap: .2rem; }
  .site-nav a { padding: .35rem .5rem; font-size: .88rem; }
  .toc { position: static; }
}

/* On a 320px screen the four nav words wrap to a second line and push the header
   up again. Tightening the side padding — not the font size — fits them, so the
   header stays at two rows */
@media (max-width: 24rem) {
  .site-nav a { padding: .3rem .3rem; }
  /* The theme button drops its word and keeps only the moon/sun. The icon
     comes from a pseudo-element keyed to data-theme on <html>, so theme.js
     needs no change; the accessible name is still its aria-label. */
  .theme-toggle {
    font-size: 0;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .theme-toggle::before { content: "☾"; font-size: 1rem; }
  html[data-theme="dark"] .theme-toggle::before { content: "☀"; }
}

/* Respect the system "reduce motion" setting */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* Print: drop the nav, footer and sidebar, and force light ink on paper.
   Only the variables are overridden — printing in dark mode must not produce a
   black page */
@media print {
  :root,
  html[data-theme="dark"] {
    --paper: #fff;
    --ink: #000;
    --line: #bbb;
    --card: #fff;
    --accent: #c2410c;      /* print always uses the light-mode orange, so both themes print the same */
    --accent-soft: #f4f4f4;
    --on-accent: #fff;
  }
  /* Browsers do not print backgrounds by default: white text on the accent would
     come out invisible, so force these fills to print as well */
  html { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .site-header, .site-footer, .toc, .filters, .theme-toggle, .search, .skip { display: none; }
}
