/* Case studies: the shared reading page. Loaded after convocation.css on every projects/*.html page.
   Header, nav, chapter bar, pager and footer live in convocation.css; this file holds the body vocabulary.

   Vocabulary
     .case-body > section.chapter#id      one chapter; .chapter-head holds the h2 and the opening prose side by side
     .prose                                running text (p, ul, ol), 62ch measure
     figure.plate                          a screenshot or photo with figcaption
     figure.diagram                        an inline SVG drawn on night, with figcaption
     .split / .split.flip                  media beside prose (7/5 columns)
     .gallery                              2- or 3-up grid of plates (.gallery.is-3)
     .compare                              before/after slider (js/case.js)
     .figures                              up to four numbers that come from the sources, each with a sentence
     .steps                                an ordered list for content that really is a sequence
     .spec                                 a two-column definition list (term, value)
     .aside                                a short note set off from the prose (limits, caveats)
     .case-close                           the closing chapter: h2, links, a quiet note */

.case-body { padding: 0 var(--gutter) clamp(80px, 10vw, 130px); }
.chapter { max-width: 1280px; margin: 0 auto; padding: clamp(80px, 11vw, 150px) 0 0; scroll-margin-top: calc(var(--nav-h) + 56px); }
.chapter h2 { margin: 0 0 22px; max-width: 16em; font: 400 clamp(2.4rem, 4.6vw, 4.4rem)/1.02 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }
.chapter-head { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px 64px; align-items: start; }
.chapter-head h2 { margin: 0; }
.chapter h3 { margin: 0 0 10px; font: 400 clamp(1.6rem, 2.4vw, 2.1rem)/1.1 var(--font-display); letter-spacing: -.01em; }

.prose { max-width: 62ch; }
.prose p, .prose li { color: var(--ink-soft); font-size: 1.04rem; line-height: 1.75; }
.prose p { margin: 0 0 1em; }
.prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.2em; }
.prose li + li { margin-top: .4em; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose a { color: var(--ink); text-decoration-color: var(--gold-deep); text-underline-offset: 3px; }
.prose code, .spec code, figcaption code { font: .9em ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", monospace; color: var(--ink); background: rgba(25, 29, 29, .06); padding: .1em .35em; border-radius: 3px; overflow-wrap: anywhere; }
.prose h3 { margin-top: 1.6em; }

.chapter-media { margin: clamp(36px, 5vw, 64px) 0 0; }
.plate, .diagram { margin: 0; }
.plate img, .plate video { display: block; width: 100%; height: auto; border-radius: var(--radius); background: var(--parchment-bright); box-shadow: 0 30px 70px -36px rgba(25, 29, 29, .55), 0 0 0 1px var(--rule); }
.plate.is-narrow { max-width: 420px; }
.plate.is-medium { max-width: 820px; }
figcaption { margin-top: 12px; color: var(--ink-soft); font-size: .88rem; line-height: 1.55; max-width: 62ch; }

/* Diagrams are drawn as inline SVG on the night ground, in the site's own colours. */
.diagram > div, .diagram > svg { display: block; border-radius: var(--radius); background: var(--gown); color: var(--on-night); box-shadow: 0 30px 70px -36px rgba(25, 29, 29, .55); }
.diagram svg { display: block; width: 100%; height: auto; font-family: var(--font-body); }
.diagram > div { padding: clamp(16px, 2.4vw, 32px); overflow-x: auto; }
.diagram > div > svg { min-width: 640px; }

.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.split.flip { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.split.flip > :first-child { order: 2; }
.split > .prose { padding-top: 6px; }

.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(18px, 2.4vw, 32px); align-items: start; }
.gallery.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery h3 { margin: 16px 0 6px; font-size: 1.5rem; }
.gallery p { margin: 0; color: var(--ink-soft); line-height: 1.6; font-size: .96rem; }

/* Before and after, dragged with a range input so it works with keys and touch. */
.compare { position: relative; overflow: hidden; border-radius: var(--radius); box-shadow: 0 30px 70px -36px rgba(25, 29, 29, .55), 0 0 0 1px var(--rule); --pos: 50%; touch-action: pan-y; user-select: none; }
.compare img { display: block; width: 100%; height: auto; pointer-events: none; }
.compare-after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos)); }
.compare-after img { height: 100%; object-fit: cover; }
.compare-line { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: var(--parchment-bright); box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); pointer-events: none; }
.compare-line::after { content: ""; position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: var(--parchment-bright) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7l-5 5 5 5M15 7l5 5-5 5' fill='none' stroke='%23191d1d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 22px no-repeat; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }
.compare input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.compare input:focus-visible + .compare-line::after { outline: 2px solid var(--gold-deep); outline-offset: 3px; }
.compare-tag { position: absolute; top: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(27, 20, 14, .74); color: var(--on-night); font-size: .8rem; pointer-events: none; }
.compare-tag.is-before { left: 12px; }
.compare-tag.is-after { right: 12px; }

/* Numbers from the sources, each explained in a sentence. Never more than four. */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0; margin: clamp(32px, 4vw, 48px) 0 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.figures li { padding: 22px 20px 0 0; }
.figures b { display: block; font: 400 clamp(2.4rem, 4vw, 3.4rem)/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink); }
.figures span { display: block; margin-top: 8px; color: var(--ink-soft); font-size: .92rem; line-height: 1.5; max-width: 26em; }

.steps { margin: clamp(28px, 4vw, 44px) 0 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 0; }
.steps > li { counter-increment: step; display: grid; grid-template-columns: 3.2rem minmax(0, 1fr); gap: 0 18px; padding: 18px 0; border-top: 1px solid var(--rule); }
.steps > li::before { content: counter(step); color: var(--gold-deep); font: 400 1.8rem/1 var(--font-display); }
.steps b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.steps p { margin: 0; color: var(--ink-soft); line-height: 1.65; max-width: 62ch; }

.spec { display: grid; grid-template-columns: minmax(0, 12em) minmax(0, 1fr); gap: 0; margin: clamp(24px, 3vw, 36px) 0 0; max-width: 820px; }
.spec dt, .spec dd { margin: 0; padding: 12px 0; border-top: 1px solid var(--rule); line-height: 1.55; }
.spec dt { color: var(--ink-soft); font-size: .92rem; padding-right: 20px; }
.spec dd { color: var(--ink); }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 0; padding: 0; list-style: none; }
.tag-row li { padding: 5px 11px; border: 1px solid var(--rule); border-radius: 999px; font-size: .85rem; color: var(--ink); }

.aside { margin: clamp(28px, 4vw, 44px) 0 0; max-width: 62ch; padding: 18px 22px; border: 1px solid rgba(184, 70, 11, .24); border-radius: var(--radius); background: rgba(244, 129, 42, .07); color: var(--ink-soft); line-height: 1.7; }
.aside strong { color: var(--ink); }

.case-close { max-width: 1280px; margin: clamp(90px, 12vw, 160px) auto 0; }
.case-close h2 { margin: 0; max-width: 16em; font: 400 clamp(2.4rem, 5vw, 4.4rem)/1.02 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }
.case-close .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.case-close .note { margin-top: 26px; max-width: 62ch; color: var(--ink-soft); font-size: .95rem; line-height: 1.65; }

/* Video in the reading flow: poster first, plays only when asked. */
.clip video { display: block; width: 100%; height: auto; border-radius: var(--radius); background: var(--gown); box-shadow: 0 30px 70px -36px rgba(25, 29, 29, .55), 0 0 0 1px var(--rule); }

@media (max-width: 1080px) {
  .chapter-head, .split, .split.flip { grid-template-columns: minmax(0, 1fr); }
  .split.flip > :first-child { order: 0; }
  .gallery.is-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .gallery, .gallery.is-3 { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .spec { grid-template-columns: minmax(0, 1fr); }
  .spec dd { border-top: 0; padding-top: 0; }
  .figures { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 24px; }
}

/* ── Round 4: graph tour, workflow wall, atlas spreads, catalogue ─────────────────────────────────────────── */

/* A switchable before/after: every example's pictures sit in the slider, only the chosen pair shows. */
.compare.has-variants picture:not(.is-on) { display: none; }
.variants { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; }
.variants button { padding: 7px 14px; border: 1px solid var(--rule); border-radius: 999px; background: none; color: var(--ink); font: inherit; font-size: .88rem; cursor: pointer; transition: background .2s, border-color .2s; }
.variants button:hover { border-color: var(--ink); }
.variants button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--parchment-bright); }
.variants button:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

/* A graph screenshot that opens at full size. */
.graph-shot { margin: 26px 0 0; }
.graph-shot a, .wf-shot { position: relative; display: block; overflow: hidden; border-radius: 8px; background: #1e1e1e; box-shadow: 0 0 0 1px var(--rule), 0 24px 44px -28px rgba(25, 29, 29, .55); }
.graph-shot img, .wf-shot img { display: block; width: 100%; height: auto; transition: transform .6s var(--ease-out); }
.graph-shot a:hover img, .wf-shot:hover img { transform: scale(1.03); }
.graph-open { position: absolute; right: 10px; bottom: 10px; padding: 5px 11px; border-radius: 999px; background: rgba(14, 16, 17, .84); color: #f6f2ec; font-size: .78rem; }
.graph-shot a:focus-visible, .wf-shot:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; }

/* The universal graph, flown through. Without the tour (no script, reduced motion, small screens) it is the
   whole graph followed by its five blocks as cards. */
.tour { max-width: 1280px; margin: clamp(36px, 5vw, 64px) auto 0; }
.tour-camera { overflow: hidden; border-radius: var(--radius); background: #1e1e1e; box-shadow: 0 30px 70px -36px rgba(25, 29, 29, .55); }
.tour-canvas { position: relative; }
.tour-canvas img { display: block; width: 100%; height: auto; }
.tour-spot { display: none; }
.tour-intro { margin: 28px 0 0; color: var(--ink-soft); }
.tour-intro b { margin-right: 6px; color: var(--ink); }
.tour-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 36px 32px; margin: 26px 0 0; padding: 0; list-style: none; }
.tour-n { margin: 0 0 6px; color: var(--gold-deep); font: 400 1.6rem/1 var(--font-display); }
.tour-n span { margin-left: 8px; color: var(--ink-soft); font: 500 .8rem/1 var(--font-body); letter-spacing: .02em; }
.tour-step h3 { margin: 0 0 8px; }
.tour-step p:not(.tour-n) { margin: 0; color: var(--ink-soft); line-height: 1.65; }
.tour-crop { margin: 16px 0 0; }
.tour-crop img { display: block; width: 100%; height: auto; border-radius: var(--radius); background: #1e1e1e; }
.tour-full { display: inline-block; margin-top: 26px; color: var(--ink); }

.tour.is-live { max-width: none; width: calc(100% + 2 * var(--gutter)); margin: clamp(36px, 5vw, 64px) 0 0 calc(-1 * var(--gutter)); }
.tour.is-live .tour-stage { position: relative; height: 100svh; overflow: hidden; background: #161818; }
.tour.is-live .tour-camera { position: absolute; inset: 0; border-radius: 0; box-shadow: none; background: #161818; }
.tour.is-live .tour-canvas { position: absolute; left: 0; top: 0; width: 8575px; height: 2281px; transform-origin: 0 0; will-change: transform; }
.tour.is-live .tour-canvas img { width: 100%; height: 100%; }
.tour.is-live .tour-spot { display: block; position: absolute; border: 14px solid var(--orange); border-radius: 22px; box-shadow: 0 0 0 40000px rgba(10, 12, 13, .55); opacity: 0; pointer-events: none; }
.tour.is-live .tour-panel { position: absolute; z-index: 2; left: var(--gutter); top: 50%; width: min(400px, 30vw); padding: 26px 28px 24px; border-radius: 14px; background: var(--parchment-bright); color: var(--ink);
  transform: translateY(-50%); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .7); }
.tour.is-live .tour-intro { margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); font-size: .9rem; }
.tour.is-live .tour-steps { display: grid; grid-template-columns: minmax(0, 1fr); margin: 0; }
/* The notes stack in one cell; js/graph-tour.js fades them in and out with the film's timing. */
.tour.is-live .tour-step { grid-area: 1 / 1; }
.tour.is-live .tour-step p:not(.tour-n) { font-size: .95rem; }
.tour.is-live .tour-crop { display: none; }
.tour.is-live .tour-full { margin-top: 18px; font-size: .9rem; }

/* Every workflow: big graph shots, two to a row. */
.wf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(40px, 5vw, 64px) clamp(24px, 3vw, 40px); }
.wf-meta { display: flex; gap: 14px; margin: 18px 0 6px; color: var(--gold-deep); font-size: .86rem; font-weight: 500; }
.wf-meta span + span { color: var(--ink-soft); }
.wf-card h3 { margin: 0 0 6px; }
.wf-card p:last-child { margin: 0; color: var(--ink-soft); line-height: 1.65; max-width: 46ch; }

/* The atlas: one wide spread per job. */
.atlas { display: grid; gap: clamp(80px, 10vw, 140px); margin-top: clamp(48px, 6vw, 80px); }
.spread { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: clamp(28px, 4.5vw, 64px); align-items: start; }
.spread.is-flip { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); }
.spread.is-flip .spread-media { order: 2; }
.spread-text { position: sticky; top: calc(var(--nav-h) + 72px); }
.spread-n { margin: 0 0 8px; color: var(--gold-deep); font: 400 clamp(2.4rem, 4vw, 3.6rem)/1 var(--font-display); }
.spread-text h3 { font-size: clamp(1.8rem, 2.6vw, 2.4rem); }
.spread-text > p:not(.spread-n) { margin: 0; color: var(--ink-soft); line-height: 1.7; }
.spread-io { display: grid; gap: 0; margin: 22px 0 0; }
.spread-io div { display: grid; grid-template-columns: 4em minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); font-size: .92rem; line-height: 1.5; }
.spread-io dt { color: var(--gold-deep); font-weight: 600; }
.spread-io dd { margin: 0; color: var(--ink); }
.spread .plate img { border-radius: var(--radius); }
.ref-steps { display: flex; align-items: center; gap: 8px; margin: 24px 0 0; }
.ref-steps picture { flex: 1 1 0; min-width: 0; }
.ref-steps img { display: block; width: 100%; height: auto; border-radius: var(--radius); box-shadow: 0 0 0 1px var(--rule); }
.ref-steps span { color: var(--gold-deep); font-size: .76rem; font-weight: 600; white-space: nowrap; }
.ref-card { display: flex; align-items: center; gap: 16px; margin: 24px 0 0; }
.ref-card picture { flex: 0 0 120px; }
.ref-card img { display: block; width: 120px; height: auto; border-radius: var(--radius); background: #fff; box-shadow: 0 0 0 1px var(--rule); }
.ref-card figcaption { margin: 0; }

/* The catalogue sheet, the schema and the taxonomy. */
.catalogue a { display: block; overflow: hidden; border-radius: var(--radius); background: #fff; box-shadow: 0 0 0 1px var(--rule), 0 30px 70px -40px rgba(25, 29, 29, .45); }
.catalogue img { display: block; width: 100%; height: auto; }
.schema { margin: 18px 0 18px; padding: 18px 20px; overflow-x: auto; border-radius: var(--radius); background: #161818; color: #f1ede6; font: .86rem/1.6 ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", monospace; }
.schema code { background: none; padding: 0; color: inherit; font: inherit; }
.taxonomy h3 { margin-bottom: 14px; }
.tax-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: 0 0 16px; }
.tax-row b { flex: 0 0 100%; color: var(--gold-deep); font-size: .82rem; font-weight: 600; letter-spacing: .02em; }
.tax-row span { padding: 4px 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--parchment-bright); color: var(--ink); font-size: .82rem; }

@media (max-width: 1080px) {
  .spread, .spread.is-flip { grid-template-columns: minmax(0, 1fr); }
  .spread.is-flip .spread-media { order: 0; }
  .spread-text { position: static; }
}
@media (max-width: 760px) {
  .wf-grid { grid-template-columns: minmax(0, 1fr); }
}
.tour-hint { display: none; }
.tour.is-live .tour-hint { display: block; grid-area: 1 / 1; align-self: center; margin: 0; color: var(--ink-soft); font: 400 1.7rem/1.2 var(--font-display); transition: opacity .35s ease; }
.tour.is-live .tour-steps:has(.is-on) .tour-hint { opacity: 0; }

/* A fanned spread of report pages: each lifts when hovered and opens at full size. */
.pages { display: flex; justify-content: center; margin-top: clamp(40px, 5vw, 64px); padding: 30px 0 10px; list-style: none; }
.pages li { flex: 0 0 auto; width: clamp(150px, 15vw, 220px); margin-left: calc(clamp(150px, 15vw, 220px) * -.38); transform: rotate(var(--r)); transition: transform .45s var(--ease-out); }
.pages li:first-child { margin-left: 0; }
.pages a { position: relative; display: block; border-radius: 3px; background: #fff; box-shadow: 0 1px 2px rgba(25, 29, 29, .2), 0 24px 40px -22px rgba(25, 29, 29, .55); }
.pages img { display: block; width: 100%; height: auto; border-radius: 3px; }
.pages span { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(14, 16, 17, .8); color: #f6f2ec; font-size: .74rem; opacity: 0; transition: opacity .25s; }
.pages li:hover, .pages li:focus-within { position: relative; z-index: 5; transform: translateY(-22px) rotate(0) scale(1.06); }
.pages li:hover span, .pages li:focus-within span { opacity: 1; }
.pages a:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; }
@media (max-width: 760px) {
  .pages { justify-content: flex-start; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 20px 4px; scrollbar-width: none; }
  .pages li { width: 58vw; margin-left: 0; transform: none; scroll-snap-align: center; }
  .pages span { opacity: 1; }
}
