/* ==================================================================
   Project showcase ("folio unfold"): the live site's Selected projects
   (index.html) and the lab page (lab/showcase/index.html).
   Layered over portfolio.css + minimal.css. Scoped so nothing here touches
   the rest of the site: the rows live in the mount root (.showcase, set by
   folio.js), the gallery layer is .gallery on <body>, the section-level bits
   sit under #projects, the lab's own chrome under .showcase-lab. The only
   page-level rules are state classes the showcase sets while it needs them
   (html.is-gallery, html.is-morphing).
   Follows lab/showcase/DRAWING-RULES.md.
   ================================================================== */

.showcase, .gallery { --folio-ease: cubic-bezier(.42,.05,.4,1); --folio-dur: 560ms; }

/* ---------- Lab header (lab page only) ---------- */
.lab-head { padding: 44px 0 0; }
.lab-head__row { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.lab-head__note { margin: 14px 0 0; font-size: 15px; color: var(--olive); max-width: 62ch; }
.showcase-lab #projects.band { padding-top: 72px; margin-top: 44px; }

.lab-toggle,
.folio-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 6px 0 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--stone);
  cursor: pointer;
  /* a stitched underline instead of a button box */
  background: var(--stitch-h) left bottom / var(--stitch-size-h) repeat-x;
  transition: color 0.16s ease;
}
.lab-toggle:hover, .folio-btn:hover { color: var(--brand); }
.lab-toggle:focus-visible, .folio-btn:focus-visible,
.project-row:focus-visible, .folio-step:focus-visible, .folio:focus-visible {
  outline: 1px dashed var(--brand);
  outline-offset: 6px;
}
.folio:focus { outline: none; }

/* ---------- Rows: same design as the site, as buttons ---------- */
#project-list { background: var(--stitch-h) left top / var(--stitch-size-h) repeat-x; }
.folio-row { position: relative; }
.folio-row__heading { margin: 0; font: inherit; }
#project-list .project-row {
  appearance: none;
  width: 100%;
  border: 0;
  margin: 0;
  background: none;              /* the stitch is its own element here, so it can be unpicked */
  padding: 26px 0 24px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.project-row > span, .project-row__main > span, .project-row__side > span { display: block; }
#project-list .project-row__index { display: flex; }
.project-row__name { font-family: var(--serif); color: var(--near-black); }
.folio-row.is-open .project-row__name { color: var(--brand); }
.project-row__stack { margin: 0; }
.folio-row__hint { opacity: 0.55; transition: opacity 0.16s ease, color 0.16s ease; }
.folio-row__hint::after { content: " \2193"; }
.folio-row.is-open .folio-row__hint::after { content: " \2191"; }
.project-row:hover .folio-row__hint,
.project-row:focus-visible .folio-row__hint,
.folio-row.is-open .folio-row__hint { opacity: 1; color: var(--brand); }

/* stitch lines: sewn / unpicked one stitch at a time by folio.js (--seam-draw) */
.seam {
  height: 4px;
  background: var(--stitch-h) left center / var(--stitch-size-h) repeat-x;
  clip-path: inset(0 calc(100% - var(--seam-draw, 100%)) 0 0);
  pointer-events: none;
}
.seam--folio { position: absolute; left: 0; right: 0; bottom: 0; --seam-draw: 0px; }

/* ---------- The unfold ---------- */
.folio-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--folio-dur) var(--folio-ease);
}
.folio-wrap.is-open { grid-template-rows: 1fr; }
.folio-wrap.is-instant { transition: none; }
.folio-clip { min-height: 0; overflow: hidden; }
.folio-wrap:not(.is-open):not(.is-closing) .folio { visibility: hidden; }

.folio {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);   /* ≈ 40 / 60 */
  column-gap: 48px;
  align-items: start;
  padding: 12px 0 44px;
}

/* ---------- Left: three steps ---------- */
.folio__text { display: flex; flex-direction: column; min-width: 0; }
.folio-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.folio-step {
  appearance: none;
  display: block;
  width: 100%;
  border: 0;
  background: none;
  margin: 0;
  padding: 10px 0 10px 20px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  opacity: 0.46;
  transition: opacity 0.18s ease;
}
.folio-step:hover { opacity: 0.8; }
.folio-step[aria-current="step"] { opacity: 1; cursor: default; }
/* the active step is marked by a hand-written "[" down its label and paragraph
   (folio.js markStep): the History notes' bracket, in the same pen (handwriting/written.js) */
.folio-steps__item { position: relative; }
.folio-step__bracket {
  position: absolute;
  left: 0;
  width: 12px;
  color: var(--brand);
  pointer-events: none;
}
.folio-step__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.folio-step__ref {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--stone);
  transition: color 0.18s ease;
}
.folio-step[aria-current="step"] .folio-step__ref { color: var(--brand); }
.folio-step__body {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--dark-warm);
}

/* ---------- The active step's notes: under its paragraph (the site's .note-line) ----------
   Only the active step's slot is open. One pen writes its bracket (0.45s), then a small arrow
   from the bracket's foot to the first line (0.4s), then the lines, letter by letter
   (folio.js showStep → handwriting/written.js); a step that stops being active loses all three at once. */
.folio-note {
  position: relative;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 420ms var(--folio-ease);
  color: var(--brand);
  pointer-events: none;
}
.folio-steps__item.is-current .folio-note { grid-template-rows: 1fr; }
.folio-note__clip { min-height: 0; overflow: hidden; }
.folio-note .margin-note__lines { padding: 4px 0 10px 20px; }      /* level with the paragraph text */
.folio-note .note-line { font-size: 21px; line-height: 1.2; }
.folio-note__arrow {                                                /* top: folio.js, from the bracket's foot */
  position: absolute;
  left: 0;
  width: 20px; height: 31px;
  overflow: visible;
}
.folio-note__arrow path { fill: currentColor; }

/* ---------- "There is a next step": the last mark on (a) and (b) ----------
   A hint word and a short dashed arrow from under the notes to the next step's label (folio.js
   nextMark places it; hung from the block's bottom edge, out of the flow). Quiet thread ink: the
   accent already belongs to the bracket and the notes. The word is written by the notes' pen,
   then the arrow is drawn tail to point (a mask follows the pen along the dashes), then the two
   barbs. --d: when the arrow starts. Leaves at once with the step's other marks. */
.folio-next {
  position: absolute;
  z-index: 1;                                   /* over the next step's button: its click goes the same way */
  display: flex;
  color: var(--near-black);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.folio-next[hidden] { display: none; }
.folio-next:not(.is-drawn) { pointer-events: none; }
.folio-next::before { content: ""; position: absolute; inset: -2px -8px -6px -4px; }   /* a kinder target */
.folio-next__arrow { flex: none; display: block; overflow: visible; opacity: 0.45; transition: opacity 0.16s ease; }
.folio-next__arrow path { fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.folio-next__arrow .folio-next__pen { stroke: #fff; stroke-width: 5; }
.folio-next__pen,
.folio-next__barb { stroke-dasharray: var(--len, 60); stroke-dashoffset: var(--len, 60); }
.folio-next.is-drawn .folio-next__pen {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s var(--folio-ease) var(--d, 0ms);
}
.folio-next.is-drawn .folio-next__barb {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.05s ease-out calc(var(--d, 0ms) + 0.33s + var(--k, 0) * 0.07s);
}
.folio-next__word { position: relative; margin-left: 5px; height: 0; opacity: 0.6; transition: opacity 0.16s ease; }
.folio-next .folio-next__line { font-size: 17px; color: inherit; }
@media (hover: hover) {
  .folio-next:hover .folio-next__arrow { opacity: 0.8; }
  .folio-next:hover .folio-next__word { opacity: 0.9; }
}
.folio-next.is-static .folio-next__pen,
.folio-next.is-static .folio-next__barb,
.is-reduced .folio-next__pen,
.is-reduced .folio-next__barb,
.is-reduced .folio-next__arrow,
.is-reduced .folio-next__word { transition: none !important; }

.folio__keys { margin: 18px 0 0 20px; opacity: 0.7; }

/* ---------- Right: the figure on its sheet ---------- */
.folio__plate { min-width: 0; display: flex; justify-content: flex-end; }
.sheet {
  position: relative;
  width: 100%;
  max-width: 716px;               /* 680 figure + padding */
  background: var(--ivory);
  padding: 18px 18px 12px;
}
.sheet__figure {
  position: relative;
  width: 100%;
  max-width: 680px;
  height: clamp(420px, 58vh, 560px);
  margin: 0 auto;
}
.sheet__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 0 6px;
}
.sheet__actions { display: flex; gap: 22px; }

/* four corner stitches hold the sheet; they pop in one stitch at a time */
.sheet__corner {
  position: absolute;
  width: 18px; height: 18px;
  color: var(--stone);
  overflow: visible;
  pointer-events: none;
}
.sheet__corner--tl { left: -5px;  top: -5px; }
.sheet__corner--tr { right: -5px; top: -5px;    transform: scaleX(-1); }
.sheet__corner--br { right: -5px; bottom: -5px; transform: scale(-1, -1); }
.sheet__corner--bl { left: -5px;  bottom: -5px; transform: scaleY(-1); }
.sheet__corner line { stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; opacity: 0; }
.sheet__corner circle { fill: currentColor; opacity: 0; }
.sheet.is-sewn .sheet__corner line { opacity: 0.75; transition: opacity 0s linear var(--d, 0ms); }
.sheet.is-sewn .sheet__corner circle { opacity: 0.4; transition: opacity 0s linear var(--d, 0ms); }

/* ---------- Placeholder plate ("figure in progress") ---------- */
.plate-blank { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--near-black); overflow: visible; }
.plate-blank path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.plate-blank .pb-draw {
  stroke-dasharray: var(--len, 1000);
  stroke-dashoffset: var(--len, 1000);
  transition: stroke-dashoffset var(--dur, 0.9s) var(--folio-ease) var(--d, 0ms);
}
.plate-blank.is-drawn .pb-draw { stroke-dashoffset: 0; }
.plate-blank .pb-fade { opacity: 0; transition: opacity 0.3s ease var(--d, 0ms); }
.plate-blank.is-drawn .pb-fade { opacity: 1; }
.plate-blank text.pb-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  fill: var(--stone);
}
.plate-blank text.pb-ref {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  fill: var(--stone);
  transition: fill 0.18s ease;
}
.plate-blank .pb-callout path { stroke-width: 0.6; opacity: 0.55; transition: stroke 0.18s ease, opacity 0.18s ease; }
.plate-blank .pb-callout.is-active text.pb-ref { fill: var(--brand); }
.plate-blank .pb-callout.is-active path { stroke: var(--brand); opacity: 0.7; }

/* ---------- Reduced motion (or ?reduced=1): everything finished, instantly ---------- */
.is-reduced .folio-wrap,
.is-reduced .folio-step,
.is-reduced .folio-note,
.is-reduced .plate-blank .pb-draw,
.is-reduced .plate-blank .pb-fade,
.is-reduced .sheet__corner line,
.is-reduced .sheet__corner circle { transition: none !important; }
.is-reduced { scroll-behavior: auto; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1000px) {
  .folio { column-gap: 32px; }
  .folio-step__body { font-size: 16px; }
}
@media (max-width: 760px) {
  .lab-head { padding-top: 28px; }
  .showcase-lab #projects.band { padding-top: 48px; margin-top: 28px; }
  .folio { grid-template-columns: minmax(0, 1fr); row-gap: 22px; padding: 4px 0 36px; }
  .folio__plate { justify-content: stretch; }
  .sheet { padding: 12px 12px 10px; }
  /* the sheet fits the figure: full sheet width, about as tall as the drawing (figures refit on resize) */
  .sheet__figure { height: auto; aspect-ratio: 1 / 0.85; min-height: 300px; }
  /* the sheet's buttons wrap as whole words, two to a line, each with a 40px+ tap area */
  .sheet__actions { flex-wrap: wrap; gap: 0 22px; }
  .sheet__actions .folio-btn { position: relative; white-space: nowrap; margin: 6px 0; }
  .sheet__actions .folio-btn::after { content: ""; position: absolute; inset: -7px -10px; }
  .folio__keys { display: none; }
  .sheet__corner--tl, .sheet__corner--bl { left: -3px; }
  .sheet__corner--tr, .sheet__corner--br { right: -3px; }
}
@media print {
  .lab-toggle, .folio-btn { display: none; }
}

/* callout letters quoted inside a paragraph */
.folio-step__body .folio-step__ref { font-size: 15px; }

/* ==================================================================
   Gallery mode (gallery.js): the open row morphs into a wide spread,
   six spreads side by side; closing morphs the current one back.
   ================================================================== */

/* ---------- list · gallery, at the right of the section heading ---------- */
#projects .section-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.view-toggle {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--stone);
}
.view-toggle[hidden] { display: none; }
.view-toggle__btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 6px 0 7px;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--stone);
  cursor: pointer;
  transition: color 0.16s ease;
}
.view-toggle__btn:hover { color: var(--brand); }
.view-toggle__btn[aria-pressed="true"] {
  color: var(--brand);
  background: var(--stitch-h) left bottom / var(--stitch-size-h) repeat-x;
  cursor: default;
}

/* a pen arrow arching over the toggle from "List" down onto "Gallery" (gallery.js
   drawPointer): drawn in once when the toggle comes into view, nudges down toward
   the word on hover / focus, gone while the gallery is open. It rises ~13px above
   the toggle row, inside the section's top padding (or the 20px row gap, if the
   heading row ever wraps). */
.view-toggle__btn { position: relative; }
.view-toggle__arrow {
  position: absolute;
  right: calc(50% - 4px);                        /* the tip (x 66 of 70) over the middle of "Gallery" */
  top: -12px;                                    /* bottom edge on the capitals' top line: the tip lands 3px above it */
  width: 70px; height: 22px;
  overflow: visible;
  color: var(--brand);
  opacity: 0.75;
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease, visibility 0s;
}
.view-toggle__arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--len, 60);
  stroke-dashoffset: var(--len, 60);
}
.view-toggle__arrow.is-drawn path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--dur, 0.5s) cubic-bezier(.42,.05,.4,1) calc(var(--d, 0s) + 0.25s);
}
.view-toggle:hover .view-toggle__arrow,
.view-toggle:focus-within .view-toggle__arrow { transform: translateY(2px); }
.view-toggle__btn[aria-pressed="true"] .view-toggle__arrow { opacity: 0; visibility: hidden; transition: opacity 0.18s ease, visibility 0s linear 0.18s; }
/* reduced motion: there, finished, still */
.view-toggle__arrow.is-static path { stroke-dashoffset: 0; transition: none; }
.view-toggle .view-toggle__arrow.is-static { transform: none; transition: none; }
@media (prefers-reduced-motion: reduce) {
  .view-toggle__arrow path { stroke-dashoffset: 0; transition: none !important; }
  .view-toggle .view-toggle__arrow,
  .view-toggle:is(:hover, :focus-within) .view-toggle__arrow { transform: none; transition: none; }
}

/* ---------- the layer: the site's paper, a seam above and below ---------- */
html.is-gallery { overflow: hidden; }            /* the page behind stays where it is */
.gallery {
  /* slot = spread + a fixed gap, so the neighbours sit right beside the current sheet
     at any window width. The spread fills what the peeks and gaps leave, up to 1240px;
     past that the window simply shows more of the neighbours. */
  --gap: clamp(24px, 4vw, 56px);                 /* paper between two sheets (56px from 1400px up) */
  --peek: min(7vw, 160px);                       /* how much of a neighbour shows, until the spread reaches its cap */
  --spread-w: min(calc(100vw - 2 * (var(--peek) + var(--gap))), 1240px);
  --spread-h: min(calc(var(--spread-w) * 0.6), calc(100vh - 168px), 760px);
  --side: calc((100vw - var(--spread-w)) / 2);
  --bar: 84px;                                   /* header / index rows: 2 x 84 = the 168 above */
  --bar-line: 58px;                              /* where the seams run */
  position: fixed;
  inset: 0;
  z-index: 44;                                   /* over the page and nav (40), under the paper grain (45): one texture for both */
  display: grid;
  grid-template-rows: var(--bar) minmax(0, 1fr) var(--bar);
  background: var(--parchment);
  overscroll-behavior: contain;
}
.gallery[hidden] { display: none; }
.gallery__head {
  grid-row: 1;
  width: var(--spread-w);
  height: var(--bar-line);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.gallery__x { font-size: 14px; letter-spacing: 0; margin-left: 2px; }
.gallery__seam { position: absolute; left: 0; right: 0; }
.gallery__seam--top { top: calc(var(--bar-line) - 2px); }
.gallery__seam--bottom { bottom: calc(var(--bar-line) - 2px); }
.gallery__foot {
  grid-row: 3;
  align-self: end;
  height: var(--bar-line);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- the track: native scroll-snap does the browsing ---------- */
.gallery__track {
  grid-row: 2;
  position: relative;                            /* offsetLeft of the spreads is read against it */
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 12px var(--side);                     /* 12px: room for the corner stitches, which sit just off the sheet */
  margin-block: -12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  cursor: pointer;                               /* a peeking neighbour is a way to go there */
}
.gallery__track::-webkit-scrollbar { display: none; }
.spread {
  flex: 0 0 var(--spread-w);
  width: var(--spread-w);
  height: var(--spread-h);
  scroll-snap-align: center;
  scroll-snap-stop: always;
  /* --near (gallery.js, from the scroll position): 1 in the middle, 0 one place away */
  opacity: calc(0.45 + 0.55 * var(--near, 0));
  cursor: auto;
}
/* the scale is on the sheet, not on the snap box (a transformed box would move its own snap point) */
.spread__paper {
  transform: scale(calc(0.96 + 0.04 * var(--near, 0)));
  transform-origin: var(--toward, 50%) 50%;      /* shrinks toward the middle, so the gap to the current sheet holds */
}
.spread:focus { outline: none; }

/* a spread is one sheet of paper, sewn at its four corners, with a stitched gutter */
.spread__paper { position: relative; height: 100%; background: var(--ivory); }
.spread__paper > .sheet__corner line { opacity: 0.75; }
.spread__paper > .sheet__corner circle { opacity: 0.4; }
.spread__inner {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 36fr) minmax(0, 64fr);
}

/* left page */
.spread__text {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 38px 34px 24px 44px;
  overflow-y: auto;                              /* short windows: the page scrolls rather than spills */
  scrollbar-width: none;
}
.spread__text::-webkit-scrollbar { display: none; }
.spread__top { display: flex; align-items: baseline; gap: 16px; }
.spread__num {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
  color: var(--brand);
  font-variant-numeric: tabular-nums lining-nums;
}
.spread__title {
  width: fit-content;
  margin: 14px 0 20px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--near-black);
  text-wrap: balance;
}
/* the three steps: here only the active one is unfolded (same 0fr → 1fr unfold as the rows) */
.spread .folio-steps { gap: 0; }
.spread .folio-step {
  display: grid;
  grid-template-rows: auto 0fr;
  padding: 9px 0 9px 20px;
  transition: opacity 0.18s ease, grid-template-rows 420ms var(--folio-ease);
}
.spread .folio-step[aria-current="step"] { grid-template-rows: auto 1fr; }
.spread .folio-step__head { margin-bottom: 0; }
.spread .folio-step__body { min-height: 0; overflow: hidden; font-size: 16px; line-height: 1.58; }
.spread .folio-step__body::before { content: ""; display: block; height: 6px; }
.spread .folio-note .note-line { font-size: 20px; }
.spread__keys { margin: auto 0 0 20px; padding-top: 16px; opacity: 0.7; }

/* right page: the figure on its sheet (the stitched gutter is the plate's left edge) */
.spread__plate { position: relative; min-width: 0; min-height: 0; display: flex; }
.spread__plate::after {
  content: "";
  position: absolute;
  left: -2px; top: 26px; bottom: 26px;
  width: 4px;
  background: var(--stitch-v) center top / var(--stitch-size-v) repeat-y;
  pointer-events: none;
}
.spread__sheet {
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 22px 26px 16px 28px;
}
.spread__sheet .sheet__figure { flex: 1 1 auto; min-height: 0; height: auto; max-width: none; }
.spread__sheet .sheet__foot { flex: none; }

/* ---------- arrows at the sheet edges, the 01–06 index ---------- */
.gallery__arrow {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 44px; height: 44px;
  margin-top: -22px;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 17px;
  line-height: 1;
  color: var(--stone);
  cursor: pointer;
  transition: color 0.16s ease, opacity 0.16s ease;
}
.gallery__arrow--prev { left: calc(var(--side) - var(--gap) / 2 - 22px); }    /* in the gap beside the sheet */
.gallery__arrow--next { right: calc(var(--side) - var(--gap) / 2 - 22px); }
.gallery__arrow:hover { color: var(--brand); }
.gallery__arrow[aria-disabled="true"] { opacity: 0.22; pointer-events: none; }
.gallery__index { display: flex; gap: 4px; }
.gallery__tab {
  position: relative;
  appearance: none;
  border: 0;
  background: none;
  min-width: 38px; height: 36px;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  font-variant-numeric: tabular-nums;
  color: var(--stone);
  cursor: pointer;
  transition: color 0.16s ease;
}
.gallery__tab:hover { color: var(--brand); }
.gallery__tab[aria-selected="true"] { color: var(--brand); cursor: default; }
/* one stitch under the current number */
.gallery__tab::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 5px;
  width: 9px; height: 1.4px;
  margin-left: -5px;
  border-radius: 1px;
  background: var(--brand);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.gallery__tab[aria-selected="true"]::after { opacity: 0.8; }
.gallery__arrow:focus-visible, .gallery__tab:focus-visible, .view-toggle__btn:focus-visible {
  outline: 1px dashed var(--brand);
  outline-offset: 2px;
}

/* ---------- the morph (View Transitions; gallery.js names the travelling parts) ---------- */
/* the row's number and title hug their words while they travel, as they do in the spread */
.project-row__num.is-travelling,
.project-row__name.is-travelling { width: fit-content; align-self: flex-start; }
html.is-morphing::view-transition-group(*),
html.is-morphing::view-transition-old(*),
html.is-morphing::view-transition-new(*) {
  animation-duration: 600ms;
  animation-timing-function: cubic-bezier(.42,.05,.4,1);
}
/* the steps reflow between the two places: cross over at their own size, no stretching */
html.is-morphing::view-transition-old(sc-steps),
html.is-morphing::view-transition-new(sc-steps) { width: auto; height: auto; }
/* the sheet is one piece of paper changing shape */
html.is-morphing::view-transition-old(sc-sheet),
html.is-morphing::view-transition-new(sc-sheet) { height: 100%; object-fit: fill; }
/* the paper grain lies over the travelling parts too, as it does at rest */
html.is-morphing body::after { view-transition-name: sc-grain; }
html.is-morphing::view-transition-old(sc-grain),
html.is-morphing::view-transition-new(sc-grain) { animation: none; }
html.is-morphing::view-transition-old(sc-grain) { display: none; }

/* ---------- gallery: reduced motion ---------- */
.is-reduced .spread { opacity: 0.45; }
.is-reduced .spread__paper { transform: none; }
.is-reduced .spread.is-current { opacity: 1; }

/* ---------- gallery: narrower and shorter windows ---------- */
@media (max-width: 1000px) {
  .spread__text { padding: 30px 22px 20px 28px; }
  .spread__sheet { padding: 18px 16px 12px 20px; }
}
@media (max-height: 720px) and (min-width: 761px) {
  .spread__text { padding-top: 26px; padding-bottom: 18px; }
  .spread__title { font-size: 26px; margin: 10px 0 12px; }
  .spread .folio-step { padding-top: 7px; padding-bottom: 7px; }
  .spread .folio-step__body { font-size: 15px; }
  .spread__keys { display: none; }
}
/* phone: full-width spreads, text above the figure inside each (the sheet scrolls if it must) */
@media (max-width: 760px) {
  /* one spread per screen, no peeking neighbours: the spread (12px in from each edge, its
     4px padding room for the corner stitches) is a vertical scroller of the full height
     between the bars; the sheet of paper grows with what's on it (text, steps, notes,
     then the figure at full width), so nothing is cut off. Sideways is still the track's
     scroll-snap; the wheel → step mapping is off on phones (gallery.js), steps change by
     tapping a step's heading or with the arrow keys. */
  .gallery {
    --spread-w: calc(100vw - 24px);
    --gap: 24px;
    --bar: 62px;
    --bar-line: 46px;
    --spread-h: calc(100vh - 124px);
  }
  @supports (height: 100dvh) { .gallery { --spread-h: calc(100dvh - 124px); } }
  .spread {
    padding: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: none;
  }
  .spread::-webkit-scrollbar { display: none; }
  .spread__paper { height: auto; min-height: 100%; }
  .spread__inner { height: auto; display: flex; flex-direction: column; }
  .spread__text { flex: none; padding: 22px 20px 6px; overflow: visible; }
  .spread__title { font-size: 26px; margin: 10px 0 12px; }
  .spread__keys { display: none; }
  .spread__plate { flex: none; flex-direction: column; margin-top: 12px; }
  .spread__plate::after {
    left: 20px; right: 20px; top: -2px; bottom: auto;
    width: auto; height: 4px;
    background: var(--stitch-h) left center / var(--stitch-size-h) repeat-x;
  }
  .spread__sheet { flex: none; height: auto; padding: 14px 12px 12px; }
  .spread__sheet .sheet__figure { flex: none; height: auto; aspect-ratio: 1 / 0.85; min-height: 300px; }
  /* no room beside the sheet: the arrows flank the index; thumb-sized targets */
  .gallery__arrow { top: auto; bottom: 1px; margin-top: 0; }
  .gallery__arrow--prev { left: 6px; }
  .gallery__arrow--next { right: 6px; }
  .gallery__index { gap: 2px; }
  .gallery__tab { min-width: 40px; height: 44px; padding: 0 6px; }
  .gallery__close { position: relative; }
  .gallery__close::after { content: ""; position: absolute; inset: -8px -6px; }
}
@media (max-width: 440px) {
  /* the header line stays one line */
  .gallery__head { gap: 10px; }
  .gallery__head .eyebrow { gap: 8px; font-size: 11px; letter-spacing: 0.8px; white-space: nowrap; }
  .gallery__close { letter-spacing: 0.8px; white-space: nowrap; }
}
@media print {
  .gallery, .view-toggle { display: none; }
}

/* Phones: one step at a time in an unfolded row — the other steps fold down to their
   heading (a, b, c), which is the tap target to switch (as in the gallery spreads). */
@media (max-width: 760px) {
  .folio-steps { gap: 2px; }
  .folio-step:not([aria-current="step"]) .folio-step__body { display: none; }
  .folio-step:not([aria-current="step"]) .folio-step__head { margin-bottom: 0; padding: 10px 0; }
}

/* Phones: no gallery — the list (one step at a time) is the phone view. Hide both
   ways in: the section's list · gallery toggle (with its pen arrow) and the row button. */
@media (max-width: 760px) {
  .view-toggle,
  .view-toggle__arrow,
  .folio-btn--gallery { display: none !important; }
}

/* ---------- Figures drawn in a product's own colours (folios.js: skin "product") ----------
   folio.js puts .skin-product (+ data-palette) on the figure's box only. That box becomes the
   product's own light paper, mounted on the sheet like a print, in both themes; the sheet, its
   stitches and its buttons stay the site's. The box takes the drawing's own proportions
   (the same ones as the boards in lab/sales-central), so there is no empty paper around it. */
.sheet__figure.skin-product {
  height: auto;
  min-height: 0;
  aspect-ratio: 700 / 440;
  background: var(--sc-paper, transparent);
  border-radius: 3px;
}
.sheet__figure.skin-product[data-palette="c2c"] { aspect-ratio: 790 / 448; }
/* these drawings are screens with small type: in the list their plate takes 64% of the row
   (the same split as a gallery spread) so the figure is drawn as large as the sheet allows */
@media (min-width: 761px) {
  .folio--print { grid-template-columns: minmax(0, 36fr) minmax(0, 64fr); column-gap: 40px; }
}
/* gallery: as large as the page allows, centred above the sheet's buttons */
.spread__sheet .sheet__figure.skin-product { flex: 0 1 auto; width: 100%; max-height: 100%; margin-block: auto; }
