/* Bubble Cards reader. Static, no third-party requests.
 *
 * Palette and type are the Champagne Atlas's, not this file's own. The first draft
 * was written in a cloud container that had never seen the site, so it arrived in a
 * cool blue-grey (#1f2a33 ink, #1d5a6e teal) that shared nothing with the brand.
 * Structure and the accessibility work are kept exactly as built — 44px targets,
 * :focus-visible, the skip link, the dialog semantics. Only the clothes changed.
 */
:root {
  --bg: #f7f3e8;            /* paper */
  --surface: #fffdf6;       /* the atlas's card ground */
  --ink: #2b2822;
  --ink-soft: #6d6650;      /* mute */
  --line: #d8d0ba;
  --accent: #8a4a56;        /* wine — links and progress */
  --accent-ink: #fffdf6;
  --chip: #efe9d8;
  --focus: #8a4a56;         /* wine. NOT gold: gold measured 1.71:1 and failed. */
  --progress: #d9705f;      /* rose */
  --shadow: 0 1px 2px rgba(43, 40, 34, .10);
  color-scheme: light;
}
/* LIGHT ONLY, and deliberately so.
 *
 * An earlier draft of this file carried a warm dark palette and a Dark mode
 * button, on the reasoning that a reading app earns one. It does not earn one
 * here: every other page on the site is light, the atlas has no dark mode at all,
 * and the effect was that following a link from the map into the cards could
 * change the whole brand underfoot. One page behaving differently from twenty is
 * not a feature.
 *
 * So there is no `prefers-color-scheme` block and no `[data-theme]` selector, and
 * `color-scheme: light` above is what stops the browser painting form controls and
 * scrollbars dark around a light page. Removed 2026-10-24 at James's instruction.
 */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}
a { color: var(--accent); }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
/* 55rem to match the rest of the site (see build_shell.py .cs-doc).
   James, 2026-11-05, after the Library moved: "yes do school and bubble cards
   too". */
.wrap { max-width: 62rem; margin: 0 auto; padding: 0 16px; }
/* Same 46rem measure as the sheets, so the listing aligns with every
   other page. .r-card below keeps its own width for reading. */
.wrap main > * { max-width: 46rem; }
/* ...BUT THE TILES RUN WIDER. James: "the tiles on bubble cards could be
   wider." Prose wants a 46rem measure; a grid of cards does not, and capping
   both at the same number was treating a tile like a paragraph. The library
   of threads gets the full container, so the tiles use the width the page
   already occupies. */
.wrap main > #library { max-width: none; }

/* ...BUT THE READING CARD KEEPS ITS OWN MEASURE. This was the only max-width
   in this file, so widening it would have widened the CARD as well as the
   listing — and a card is a short reading unit, not a page. 44rem is exactly
   what it rendered at before (46rem less 32px of padding), so the reading
   experience is unchanged; only the thread listing around it got wider.
   Left-aligned rather than centred, so the card's left edge lines up with the
   listing you just came from instead of jumping inward. */
.r-card { max-width: 46rem; }
.skip {
  position: absolute; left: 16px; top: -100px;
  background: var(--surface); color: var(--ink); padding: 12px 16px; z-index: 10;
}
.skip:focus { top: 8px; }

header.site {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
header.site a.home {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--ink); text-decoration: none; font-weight: bold;
}
button, .btn {
  font: inherit; min-height: 44px; min-width: 44px; padding: 8px 16px;
  border-radius: 3px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }

/* IDENTICAL TO THE SHELL'S .cs-doc h1. James, 2026-11-05: "why is the title
   Bubble Cards, smaller than the other titles" and "the top heading,
   proximity to The Chalk Sea in the header, is different".
   Both were this rule. It capped at 34px where every other page caps at 46,
   and its 26px top margin pushed the heading 48px below the chrome where the
   rest sit at 22. Three pages had each written their own h1 from scratch;
   these are the shell's numbers, copied exactly. */
h1 {
  font-family: "Archivo Black", sans-serif; font-weight: 400;
  font-size: clamp(28px, 5.2vw, 46px); letter-spacing: .02em; text-transform: uppercase;
  color: #d9705f; -webkit-text-stroke: 1.8px var(--ink); paint-order: stroke fill;
  line-height: 1.04; margin: 0 0 22px;
}
.lede { color: var(--ink-soft); margin: 0 0 24px; }

.tools { display: grid; gap: 12px; margin-bottom: 24px; }
.tools label { font-weight: bold; }
.tools input[type="search"] {
  font: inherit; width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--surface); color: var(--ink);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chips button { background: var(--chip); border-color: transparent; border-radius: 999px; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.thread {
  background: var(--surface); border: 1px solid var(--line); border-radius: 3px;
  padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.thread h2 { margin: 0 0 4px; font-size: 1.4rem; line-height: 1.3; }
.thread .sub { margin: 0 0 12px; color: var(--ink-soft); }
.thread .meta { font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 12px; }

/* THE THREAD TITLE IS A TOGGLE.
   Collapsed is the default: thirteen threads with their episodes showing came to
   89 buttons in one column, which is a scroll rather than a library. The button
   lives inside the h2 so heading navigation still works, and it has to undo the
   base button styling completely — it should read as the heading it is, not as a
   control sitting inside one. */
.thread h2 .toggle {
  width: 100%; min-height: 44px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
  margin: 0; padding: 0; border: 0; background: none; border-radius: 0;
  box-shadow: none; font: inherit; color: inherit; text-align: left;
  cursor: pointer;
}
.thread h2 .toggle:hover .t-name { color: var(--accent); }
.thread h2 .toggle[disabled] { cursor: default; opacity: 1; }

/* A chevron drawn in CSS rather than loaded: the reader makes no outside
   requests, and an SVG file would be the first. */
.thread h2 .caret {
  flex: none; width: 10px; height: 10px; margin-right: 4px;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg); transform-origin: 70% 70%;
  transition: transform 120ms ease;
}
.thread h2 .toggle[aria-expanded="true"] .caret { transform: rotate(225deg); }
.thread h2 .toggle[disabled] .caret { display: none; }

.episodes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
/* `.episodes` sets display:grid, which has the same specificity as a bare
   [hidden] rule — source order alone would decide whether a collapsed thread
   actually collapses. Scoping the attribute to the class settles it. */
.episodes[hidden] { display: none; }
.episodes button {
  width: 100%; text-align: left; display: flex; justify-content: space-between;
  align-items: center; gap: 12px;
}
.episodes .state { font-size: 0.9rem; color: var(--ink-soft); white-space: nowrap; }
.episodes li.coming { color: var(--ink-soft); padding: 10px 16px; min-height: 44px; }
.empty { color: var(--ink-soft); }

/* Card dialog */
dialog#reader {
  width: min(40rem, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 3px;
  background: var(--surface); color: var(--ink);
}
dialog#reader::backdrop { background: rgba(43, 40, 34, .62); }
.r-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 16px 8px;
}
.r-head h2 { margin: 0; font-size: 1.15rem; line-height: 1.35; }
/* The close button must not be squeezed by a long episode title.
   .r-head is a flex row, so the button inherits flex-shrink: 1 and the only floor
   under it was `min-width: 44px` from the shared button rule. "Close" plus its 32px
   of padding needs about 74px, so a title like "Episode 2: Pinot Noir, a Black Grape
   for Mostly White Wine" crushed the button to 44px and the label overflowed its own
   border. The title block gets min-width: 0 so it wraps rather than pushing. */
.r-head > div { min-width: 0; }
.r-head button { flex: 0 0 auto; white-space: nowrap; }
.r-head .r-thread { margin: 0 0 2px; font-size: 0.9rem; color: var(--ink-soft); }
.r-bar { height: 4px; background: var(--line); margin: 0 16px; border-radius: 2px; overflow: hidden; }
.r-bar span { display: block; height: 100%; background: var(--progress); width: 0; }
.r-card { padding: 24px 20px; min-height: 14rem; font-size: 1.2rem; line-height: 1.6; }
.r-card p { margin: 0 0 16px; }
/* A village named in a card links to its entry. Underlined rather than coloured:
   at this size a colour change reads as emphasis, and a card is forty words. */
.r-card a.place { color: inherit; text-decoration: underline;
  text-decoration-color: var(--accent); text-underline-offset: 2px; }
.r-card a.place:hover { color: var(--accent); }
.r-card .callback { font-size: 1rem; color: var(--ink-soft); font-style: italic; }
.r-card .setup-label { font-size: 0.95rem; color: var(--ink-soft); margin-bottom: 8px; }
.r-count { padding: 0 20px; font-size: 0.9rem; color: var(--ink-soft); }
.r-foot { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px 16px; }
.r-foot button { flex: 1 1 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
footer.site { border-top: 1px solid var(--line); margin-top: 40px; padding: 16px 0 32px; font-size: 0.95rem; }
footer.site ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
footer.site a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }

/* ── THE MATCHED CARD, WHILE SEARCHING ──────────────────────────────────────
   Audit v2 D06: a search returned threads and never said which card held the
   answer. This row is that answer, so it reads as a quotation rather than as
   another navigation control — the episode line small and definite above, the
   sentence itself in the reading face below.
   A button rather than a link because it opens the reader dialog in place; it
   carries its own aria-label naming the episode and card, since the excerpt
   alone would announce as a fragment of prose with no destination. */
.thread .found{display:block;width:100%;text-align:left;cursor:pointer;
  font:inherit;margin:2px 0 10px;padding:10px 12px;
  background:#fffdf6;border:1px solid #d8d0ba;border-left:3px solid #d9705f;
  border-radius:0 3px 3px 0}
.thread .found:hover{background:#f6edd6}
.thread .found:focus-visible{outline:2px solid #8a4a56;outline-offset:2px}
.thread .found-ep{display:block;font-size:11px;font-weight:700;letter-spacing:.1em;
  text-transform:uppercase;color:#8a4a56;margin-bottom:4px}
.thread .found-x{display:block;font-size:14px;line-height:1.5;color:#453f30}
