/* ==========================================================================
   Case-study pages only (yantra, navibus, pillpal, keep), v3. Link it after
   css/motion.css and before the page's own CSS. See BUILD-NOTES.md,
   "Visual system v3" and "Motion on the case-study pages".

   The same voice as the landing page: one grotesk, bold sentence case for the
   few big things, 12 to 17px for everything else, the whole window, few rules.

   0. Page: colour, edges, tiny header and footer
   1. Case bar: the way back and the reading time, stuck to the top of the window
   2. Reading progress: a hairline along the bottom edge of the bar
   3. Title block: project name, one line, small meta list, first big image
   4. Sections and the pieces inside them
   5. Next project: the next cover as a sleeve on a small shelf
   Nothing here needs JavaScript. The scroll-linked parts use CSS scroll
   timelines where the browser has them and are simply still where it has not.
   ========================================================================== */

/* 0. Page ------------------------------------------------------------------- */
.case {
  --paper: var(--paper-home);             /* the landing page's colour (#e3e1dc; a token, so it follows the lamp: styles.css) */
  --edge: clamp(16px, 2.4vw, 40px);       /* the landing page's distance from the window edge */
  background: var(--paper);
}
.case .wrap { max-width: 1600px; padding-inline: var(--edge); }
/* The next cover slides in from the right: keep it from widening the page.
   (clip, not hidden: hidden would make <main> a scroll container and unstick the bar) */
.case main { overflow-x: clip; }

/* Footer: one quiet line (it wraps to a few short ones on a phone), no columns, no rule */
.case .site-footer { border-top: 0; margin-top: var(--space-6); padding-block: 0 1.1rem; }
.case .site-footer__inner { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 1.5rem; font-size: var(--text-xs); font-weight: var(--w-mid); }
.case .site-footer__name { font-size: inherit; font-weight: var(--w-bold); line-height: 1.4; letter-spacing: -0.01em; }
.case .site-footer__blurb { font-size: inherit; line-height: 1.4; color: var(--ink-3); }
.case .site-footer__links { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0 1.5rem; margin: 0 0 0 auto; font-size: inherit; }
.case .site-footer__links a, .case .site-footer__small a {
  display: inline-block; text-decoration: none; padding-block: 0.5rem; color: var(--ink);
  background: linear-gradient(currentColor, currentColor) 0 calc(100% - 0.35rem) / 0 1px no-repeat;
  transition: background-size 0.35s var(--ease);
}
.case .site-footer__links a:hover, .case .site-footer__small a:hover { background-size: 100% 1px; }
.case .site-footer__small { display: block; border-top: 0; padding-top: 0; margin: 0; text-transform: none; letter-spacing: 0; font-size: inherit; }
.case .site-footer__small > span { display: none; }      /* the name is already at the start of the line */
@media (max-width: 719px) { .case .site-footer__links { margin-left: 0; width: 100%; } }

/* 1. Case bar -------------------------------------------------------------- */
/* A direct child of <article>, so it stays stuck for the whole case study and
   the way back to the cover shelf is on screen at every scroll position.
   Plain HTML and CSS: it works without the script. Never put data-enter or
   data-reveal on it. */
.case-bar {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
}
.case-bar__inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 2.5rem; }
.case-bar .label { white-space: nowrap; font-size: var(--text-xs); text-transform: none; letter-spacing: 0; }
/* The way back: one clear control in ink, the arrow and the words over one hairline.
   It goes to the top of the landing page. */
.case-bar__back {
  display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.5rem;
  color: var(--ink); font-weight: var(--w-mid); text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 calc(50% + 0.8em) / 100% 1px no-repeat;
}
.case-bar__back::before { content: "\2190"; display: inline-block; line-height: 1; transition: transform 0.3s var(--ease); }
.case-bar__back:hover::before { transform: translateX(-4px); }
.case-bar__crumb { display: inline-flex; align-items: center; gap: 0.5ch; }
/* phones: the bar keeps the way back and the reading time on one line */
@media (max-width: 479px) { .case-bar__long, .case-bar__here { display: none; } }

/* 2. Reading progress ------------------------------------------------------ */
.case-progress { display: none; }
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .case-progress {
      display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
      background: var(--signal); transform-origin: 0 50%; transform: scaleX(0);
      animation: case-progress linear both; animation-timeline: scroll(root block);
      pointer-events: none;
    }
  }
}
@keyframes case-progress { to { transform: scaleX(1); } }

/* 3. Title block ----------------------------------------------------------- */
/* The project name at the scale of the name on the landing page, on one line; under it one
   bold line, a short introduction on the left and a small list of facts on the right; then
   the first image across the whole width. */
.case .case-hero { position: relative; padding-top: clamp(2.75rem, 12svh, 7.5rem); }
/* The project's cover stands on a small shelf at the right, on the line the name stands on:
   the same object the visitor clicked on the landing page. Drawn flat, so it is sharp
   (styles.css, "A settled sleeve"). Wide screens only; on a phone the name has the width. */
.case-hero__cover { display: none; }
@media (min-width: 900px) {
  .case-hero__cover {
    --f: clamp(3.4rem, 11.6vw, 14.5rem); --w: clamp(9rem, 15vw, 15rem);
    display: block; position: absolute; isolation: isolate; right: calc(var(--edge) + 22px); width: var(--w);
    top: calc(clamp(2.75rem, 12svh, 7.5rem) + 0.8 * var(--f) - var(--w));
  }
  .case-hero__cover::after {
    content: ""; position: absolute; left: -22px; right: -22px; top: 100%; height: 11px; z-index: -1;
    background: linear-gradient(to bottom, #fbfaf7 0, #efede8 2px, #dcd9d2 100%);
    box-shadow: 0 1px 1px rgb(0 0 0 / 0.16), 0 6px 8px -2px rgb(0 0 0 / 0.14), 0 16px 22px -6px rgb(0 0 0 / 0.16), 0 34px 40px -16px rgb(0 0 0 / 0.14);
    border-radius: 1px;
  }
}
.case .case-title {
  display: block; white-space: nowrap; margin-left: -0.045em; padding-bottom: 0.1em;   /* room for g and p */
  font-size: clamp(3.4rem, 11.6vw, 14.5rem); line-height: 0.8; letter-spacing: var(--track-display);
}
.case .case-subtitle {
  margin-top: clamp(1.1rem, 2.6vw, 2.25rem);
  font-size: var(--step-2); line-height: 1.1; letter-spacing: var(--track-head);
}
.case .case-hero__grid { gap: 2rem; margin-top: 0.7rem; }
.case .lede { font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem); line-height: 1.42; max-width: 33rem; }
.case .link-arrow { font-size: var(--text-sm); font-weight: var(--w-mid); padding-bottom: 0.15rem; }
.case .case-hero .mt-3 { margin-top: 1.1rem !important; }
.case .case-hero > .figure { margin-top: clamp(2.5rem, 5.5vw, 5rem) !important; }
@media (min-width: 900px) {
  .case .case-hero__grid > .lede, .case .case-hero__grid > .case-hero__intro { grid-column: 1 / 7; }
  /* the list starts level with the bold line above the introduction */
  .case .case-hero__grid > .meta { grid-column: 9 / 13; margin-top: calc(-1.1 * var(--step-2) - 0.55rem); }
}
/* phones: the name as large as the landing page's, or as large as fits on one line.
   --title-em is the width of the name in em, set on the element (YANTRA 2.8, Google Keep 5.45). */
@media (max-width: 719px) {
  .case .case-hero { padding-top: clamp(2.5rem, 8svh, 4rem); }
  .case .case-title { font-size: min(24vw, (100vw - 2 * var(--edge)) / var(--title-em, 5.6)); line-height: 0.84; }
  .case .case-subtitle { margin-top: 0.9rem; }
}

/* The small list of facts: tiny grey keys, small values, hairlines (the landing stage's list) */
.case .meta { border-top: 1px solid var(--rule); }
.case .meta > div { grid-template-columns: 4.25rem minmax(0, 1fr); gap: 1rem; padding-block: 0.5rem; }
.case .meta dt { font-size: var(--text-micro); letter-spacing: 0; text-transform: none; padding-top: 0.12em; }
.case .meta dd { font-size: var(--text-sm); font-weight: var(--w-mid); line-height: 1.38; text-wrap: pretty; }

/* 4. Sections -------------------------------------------------------------- */
/* No rule on top: air does the separating. The number stays as one tiny grey label. */
.case .case-section { margin-top: var(--space-6); border-top: 0; padding-top: 0; }
.case .case-section__head .label { margin-bottom: 0.6rem; }
.case .case-section__head .h3 { font-size: clamp(1.375rem, 1.1rem + 0.9vw, 1.75rem); line-height: 1.04; letter-spacing: var(--track-head); }
@media (min-width: 900px) {
  .case .case-section > .case-section__head { padding-right: 1.5rem; }
}

/* Asides (a "why" paragraph, the honest status line): small text beside one hairline, no box */
.case .callout {
  background: none; border-radius: 0;
  border-left: 1px solid var(--rule); padding: 0.1rem 0 0.1rem 1.1rem;
  font-size: var(--text-base); line-height: 1.5; color: var(--ink-2);
}
.case .callout > .label { margin-bottom: 0.4rem; color: var(--ink-3); }
.case .callout--status { border-left: 0; padding-left: 0; max-width: 31rem; }
.case .callout--status > .label::before {
  content: ""; display: inline-block; width: 0.4rem; height: 0.4rem; margin-right: 0.45rem;
  border-radius: 50%; background: var(--signal); vertical-align: 0.05em;
}

.case .numbered { border-top: 0; }
.case .numbered > li { border-bottom: 0; padding-block: 0.45rem; grid-template-columns: 2.25rem 1fr; }
.case .numbered > li::before { padding-top: 0.42em; }

.case .data-table thead th { font-family: var(--font-sans); font-size: var(--text-micro); letter-spacing: 0.04em; }
.case .data-table .num { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }

/* Figures: large wells, small captions */
.case .figure { gap: 0.7rem; }
.case .figure__frame { border-radius: 8px; box-shadow: none; }
.case .caption { font-size: var(--text-sm); line-height: 1.45; gap: 0.7rem; max-width: 40rem; }
.case .caption__num { font-size: var(--text-micro); letter-spacing: 0.02em; padding-top: 0.2em; }
.case .scroll-hint { font-size: var(--text-xs); text-transform: none; letter-spacing: 0; }
.case .pullquote::before { font-size: 1.5em; line-height: 0.7; }
.case .pullquote--sm { font-weight: var(--w-bold); }

/* Swimlane diagram (YANTRA): its lane names in sentence case */
.case .lanes__band { font-size: var(--text-xs); font-weight: 600; text-transform: none; letter-spacing: 0; }
.case .lanes__n { font-size: var(--text-micro); }

/* 5. Next project ---------------------------------------------------------- */
/* The whole block is one link: the next project's name at the size of the title on top of the
   page, and its cover as a sleeve standing on a small shelf. The sleeve slides along the shelf
   into place as the block scrolls into view, and lifts and flattens when the link is hovered
   or focused, like the covers on the landing page. */
.case .next { display: block; margin-top: var(--space-6); border-top: 0; padding-top: 0; }
.case .next__link { position: relative; display: grid; gap: 2.5rem; padding: 0 0 2.75rem; border-bottom: 0; }
.case .next__text { display: grid; gap: 0; align-content: end; padding-bottom: 0; }
.case .next__title { margin: 0.9rem 0 0 -0.045em; padding-bottom: 0.1em; font-size: clamp(2.75rem, 10.4vw, 12.5rem); line-height: 0.84; white-space: nowrap; }
.case .next__link:hover .next__title { transform: translateX(8px); }
.case .next__desc { margin-top: 0.9rem; font-size: var(--text-lede); line-height: 1.4; max-width: 30rem; }
.case .next__stage { position: relative; isolation: isolate; display: block; width: min(56%, 15rem); justify-self: end; margin-right: 14%; }
/* the shelf: a light front lip with stacked soft shadows (the landing page's rack) */
.case .next__stage::after {
  content: ""; position: absolute; left: -22px; right: -22px; top: 100%; height: 11px; z-index: -1;
  background: linear-gradient(to bottom, #fbfaf7 0, #efede8 2px, #dcd9d2 100%);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.16), 0 6px 8px -2px rgb(0 0 0 / 0.14), 0 16px 22px -6px rgb(0 0 0 / 0.16), 0 34px 40px -16px rgb(0 0 0 / 0.14);
  border-radius: 1px;
}
.case .next__lift { display: block; }
.case .next__cover { --px: -30%; transform: none; box-shadow: none; }
/* the cover is drawn flat (sharp), so on hover it simply lifts off the shelf */
.case .next__link .sleeve__obj { transition: transform 0.58s var(--ease-sleeve); }
.case .next__link:hover .sleeve__obj, .case .next__link:focus-visible .sleeve__obj { transform: translateY(-14px); }
.case .next__link:hover .sleeve__sheen, .case .next__link:focus-visible .sleeve__sheen { background-position: 85% 0; }
.case .next__link:hover .sleeve__shadow, .case .next__link:focus-visible .sleeve__shadow { transform: skewX(-12deg) translateX(9%) scale(1.07, 1.02); opacity: 0.42; }
.case .next__link:hover .sleeve__contact, .case .next__link:focus-visible .sleeve__contact { transform: scale(0.86, 1.5) translateY(2px); opacity: 0.3; }
.case .next__link:hover .cover__art--full img, .case .next__link:focus-visible .cover__art--full img { transform: scale(1.05); }
.case .next__foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem 1.5rem; padding-top: var(--space-3); }
.case .next__back { justify-self: auto; }
@media (min-width: 900px) {
  .case .next__link { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); align-items: end; }
  .case .next__text { grid-column: 1 / 10; }
  .case .next__stage { grid-column: 10 / 13; width: min(82%, 19rem); margin-right: 16%; }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .case .next__stage { view-timeline: --next-cover block; }
    .case .next__lift {
      animation: next-cover linear both; animation-timeline: --next-cover;
      animation-range: entry 0% cover 15%;
    }
  }
}
@keyframes next-cover { from { transform: translateX(34%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .case-bar__back:hover::before { transform: none; }
  .case .next__link:hover .sleeve__obj, .case .next__link:focus-visible .sleeve__obj { transform: none; }
  .case .next__link:hover .cover__art--full img, .case .next__link:focus-visible .cover__art--full img { transform: none; }
}

@media print {
  .case-bar { position: static; }
  .case-progress { display: none !important; }
  .case .next__stage::after, .case-hero__cover { display: none; }
}

/* 6. Evening (v9) ----------------------------------------------------------- */
/* The tokens in styles.css carry the page (text, hairlines, the bar, the footer). These are the
   pieces they cannot say. Her screens and boards keep their own colours: a screen is only dimmed
   with --glare (styles.css), and the board colour behind it is dimmed by exactly the same amount
   (color-mix with black at --glare is what brightness() does), so no edge shows between the two. */
/* the two small shelves (under the cover on top, under the next cover): dark wood, a pale top edge */
html[data-room="evening"] .case-hero__cover::after,
html[data-room="evening"] .case .next__stage::after {
  background: linear-gradient(to bottom, #6b6055 0, #554b42 2px, #40382f 100%);
  box-shadow: 0 1px 1px rgb(8 5 2 / 0.5), 0 6px 8px -2px rgb(8 5 2 / 0.45), 0 16px 22px -6px rgb(8 5 2 / 0.5), 0 34px 40px -16px rgb(8 5 2 / 0.45);
}
html[data-room="evening"] .case .sleeve .cover__art img { filter: brightness(var(--glare)); }
html[data-room="evening"] .case .sleeve .sleeve__shadow { background: rgb(8 5 2 / 0.8); }
/* her board colours behind the screens: navy, plum and pink stay what they are */
html[data-room="evening"] .figure__frame--navibus { --frame-bg: color-mix(in srgb, var(--navibus-bg) calc(var(--glare) * 100%), #000); }
html[data-room="evening"] .figure__frame--pillpal { --frame-bg: color-mix(in srgb, var(--pillpal-bg) calc(var(--glare) * 100%), #000); }
html[data-room="evening"] .figure__frame--keep { --frame-bg: color-mix(in srgb, var(--keep-bg) calc(var(--glare) * 100%), #000); }
/* a focus ring on the pink board: the pale orange ring would not show, the board's own plum does */
html[data-room="evening"] .figure__frame--keep { --focus: var(--keep-ink); }

/* v9.1: lamplight on the case pages. A faint warm pool behind the name and the cover on its shelf
   (the lamp in the header is just above), and one behind the next cover. Each fades out before
   the edge of its block and before the sticky bar, so no band shows. Evening only. */
html[data-room="evening"] .case .case-hero {
  background: radial-gradient(ellipse min(62rem, 78vw) 27rem at 86% 21rem, rgb(255 198 132 / 0.075) 0%, rgb(255 198 132 / 0.048) 28%, rgb(255 198 132 / 0.02) 58%, rgb(255 198 132 / 0.005) 82%, rgb(255 198 132 / 0) 100%) no-repeat;
}
html[data-room="evening"] .case .next__link {
  background: radial-gradient(ellipse min(46rem, 70vw) 58% at 84% 52%, rgb(255 198 132 / 0.06) 0%, rgb(255 198 132 / 0.038) 30%, rgb(255 198 132 / 0.015) 60%, rgb(255 198 132 / 0.003) 84%, rgb(255 198 132 / 0) 100%) no-repeat;
}
/* Keep's pink boards are the brightest thing in the dim room: a narrow warm-dark mat round them,
   like a print on the wall, so the pink edge does not meet the page directly */
html[data-room="evening"] .case .figure__frame--keep { box-shadow: 0 0 0 6px var(--surface), 0 0 0 7px rgb(255 236 210 / 0.07); }

/* v9.1: the lamp in the sticky bar. The header (and its lamp) scrolls away; once it has, the same
   switch shows at the right end of the bar and the reading time steps aside (.is-stuck is set by
   js/motion.js, part 7b). At the top of the page the bar looks as before. */
.case-bar__end { position: relative; display: flex; align-items: center; }
.case-bar__end .label { transition: transform 0.3s var(--ease); }
.case-bar__end .room-toggle {
  position: absolute; right: 0; top: 50%; margin: -1.25rem -0.7rem 0 0;
  opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0s 0.25s, background-color 0.2s;
}
.case-bar.is-stuck .case-bar__end .label { transform: translateX(-2.15rem); }
.case-bar.is-stuck .case-bar__end .room-toggle { opacity: 1; visibility: visible; transition-delay: 0s; }
@media (prefers-reduced-motion: reduce) { .case-bar__end .label, .case-bar__end .room-toggle { transition: none; } }
@media print { .case-bar__end .room-toggle { display: none; } }
