/* ==========================================================
   Case study pages
   Design source: Figma "Portfolio" › Moodboard › Desktop 1920x1080 › Use Case
   Builds on the tokens and base styles in ../styles.css.
   ========================================================== */

.cs {
  --cs-side: clamp(256px, 14.7vw, 282px);
  --cs-content: 1040px;        /* 12-column content area, centered */
  --cs-pad: 40px;
  --cs-hero-bg: #F8F5EC;
  --cs-accent-line: #E4DF4F;   /* yellow accent at the start of every case study */
  --cs-card-bg: #FCFCFB;
  --cs-chip-bg: #F0ECE0;
  --cs-note-final-bg: #EEF0FB;
  --cs-note-final-border: #CBD0EE;
  --cs-shadow: 0 4px 16px rgba(30, 41, 59, .10);
}

/* ---------- Layout ---------- */

.cs-layout {
  display: grid;
  grid-template-columns: var(--cs-side) minmax(0, 1fr);
  grid-template-areas:
    "side main"
    "side footer";
  min-height: 100dvh;
}

.cs-side {
  grid-area: side;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
  padding: 40px 24px;
  background-image: var(--dots);
  background-size: 1px 7px;
  background-position: right top;
  background-repeat: repeat-y;
}

.cs-main { grid-area: main; min-width: 0; outline: none; }
/* List reset with zero specificity, so component margins (e.g. .cs-stats) still apply */
:where(.cs) ul { margin: 0; padding: 0; list-style: none; }
.cs-footer { grid-area: footer; padding: 48px var(--cs-pad) 40px; max-width: calc(var(--cs-content) + 2 * var(--cs-pad)); width: 100%; margin: 0 auto; }

/* Every section sits on the same centered content column */
.cs-section,
.cs-hero img {
  max-width: calc(var(--cs-content) + 2 * var(--cs-pad));
  margin: 0 auto;
  padding: 0 var(--cs-pad);
}
.cs-section { padding-top: 96px; }

/* ---------- Sidebar ---------- */

.cs-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 24px;
  line-height: 32px;
  color: var(--ink);
  text-decoration: none;
}
.cs-back:hover { text-decoration: underline; text-underline-offset: 4px; }

.cs-label {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 24px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-strong);
}

/* About: first block of the Overview, labels above values in the eyebrow's mono style */
.cs-about {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px 24px;
  margin: 0 0 48px;
}
.cs-about dt {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 24px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-strong);
}
.cs-about dd { margin: 0; font-size: 14px; line-height: 22px; color: var(--ink); }

.cs-index ol { display: grid; gap: 4px; margin-top: 8px; }
.cs-index a {
  display: inline-block;
  padding: 2px 0;
  font-size: 14px;
  line-height: 22px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .2s ease, border-color .2s ease;
}
.cs-index a:hover { color: var(--ink); }
.cs-index a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Type ---------- */

.cs-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 24px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-strong);
}
.cs-eyebrow--dot::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.cs-title {
  max-width: 14em;
  margin-top: 8px;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 48px;
  line-height: 52px;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variation-settings: "opsz" 72;
  text-wrap: balance;
  scroll-margin-top: 32px;
  outline: none;
}
.cs-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 8px; }

.cs-lead { font-size: 20px; line-height: 28px; color: var(--ink); }
.cs-sub { margin-top: 24px; font-size: 16px; line-height: 24px; }
/* Running text stays at a readable line length (~70 characters); images and grids use the full 1040px column */
.cs-section p { max-width: 640px; color: var(--ink); }
.cs-section p + p { margin-top: 16px; }
.cs-section strong { font-weight: 600; }

.cs-section h3 {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 20px;
  line-height: 28px;
  color: var(--ink);
}

.cs-intro {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 16px;
  margin-top: 32px;
}
.cs-intro > :first-child { grid-column: 1 / span 5; }
.cs-intro > :last-child { grid-column: 7 / span 5; margin-top: 0; } /* body text: 5 of 12 columns, starting where the right column of Key decisions starts */

.cs-rule { margin: 32px 0 0; border: 0; border-top: 1px solid var(--ink); }
/* 32px between a section's closing line and the next section */
.cs-section:has(> .cs-rule:last-child) + .cs-section { padding-top: 32px; }
.cs-rule--dotted {
  height: 1px;
  border: 0;
  background-image: linear-gradient(to right, var(--divider) 0 1px, transparent 1px 7px);
  background-size: 7px 1px;
  background-repeat: repeat-x;
}

/* ---------- Hero ---------- */

/* Behind the hero image: a full-width band that fades from #F8F5EC into the page and ends
   halfway down the Overview card, so the card's lighter background stands out against it.
   case-study.js sets --cs-band to that height; 480px is the fallback. */
.cs-main { background: linear-gradient(to bottom, var(--cs-hero-bg), var(--bg)) top / 100% var(--cs-band, 480px) no-repeat; }
.cs-hero { padding-top: 40px; } /* room above the image */
.cs-hero img { display: block; width: 100%; height: auto; padding: 0; }
/* The devices dissolve into the band at the bottom (transparent, so the gradient shows through) */
/* --cs-hero-fade: where the fade starts. A flat screenshot fades over a longer stretch (see order-sets.css) */
.cs-hero img { -webkit-mask-image: linear-gradient(to bottom, #000 var(--cs-hero-fade, 82%), transparent); mask-image: linear-gradient(to bottom, #000 var(--cs-hero-fade, 82%), transparent); }

/* ---------- 01. Overview ---------- */

.cs-overview {
  /* Card: #FCFCFB with 40px padding on every side. Same box as the other sections,
     so the text inside stays aligned with the rest of the page. */
  margin-top: 32px;
  padding: 40px var(--cs-pad);
  background: var(--cs-card-bg);
  position: relative;
}
/* Barely-there accent: a 2px yellow line on the top-left 30% of the card, fading in and out */
.cs-overview::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 30%;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--cs-accent-line) 50%, transparent);
  pointer-events: none;
}
.cs-overview__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 32px;
  margin-top: 32px;
}
.cs-overview__main { grid-column: 1 / span 8; }
.cs-overview__main .cs-label { margin-top: 24px; }
.cs-overview__main .cs-label + p { margin-top: 4px; }

/* Persona card (shared): right of the Overview text on desktop, full width below 1100px */
.cs-persona {
  grid-column: 9 / span 4;
  align-self: start;
  margin: 0;
  padding: 24px;
  border-radius: 8px;
  background: var(--cs-card-bg);
  box-shadow: var(--cs-shadow);
}
.cs-persona__head { display: flex; gap: 16px; align-items: center; }
.cs-persona__avatar {
  flex: none;
  width: 56px; height: 56px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--cs-chip-bg);
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink);
}
.cs-section .cs-persona__name { margin: 0; font-size: 16px; line-height: 24px; font-weight: 500; }
.cs-section .cs-persona__role { margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-soft); }
.cs-persona dl { display: grid; gap: 12px; margin: 20px 0 0; }
.cs-persona dt {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-strong);
}
.cs-persona dt { line-height: 20px; }
.cs-persona dd { margin: 2px 0 0; font-size: 14px; line-height: 20px; color: var(--ink); }
.cs-section .cs-persona__note { margin: 16px 0 0; font-size: 12px; line-height: 18px; color: var(--ink-soft); } /* --muted is under 4.5:1 on the card */

@media (max-width: 1099px) { .cs-persona { grid-column: 1 / -1; } }

.cs-impact { margin-top: 48px; }
.cs-impact .cs-lead { margin-top: 4px; }
.cs-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  line-height: 20px;
}
.cs-stat {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 56px;
  line-height: 56px;
  color: var(--ink);
  font-variant-numeric: lining-nums;
}
.cs-stat__unit { font-size: 32px; line-height: 0; } /* smaller % sign; line-height 0 keeps the row height */

/* ---------- 02. The challenge ---------- */

.cs-problem { max-width: 560px; margin-top: 64px; }
/* 32px above and below every dashed divider */
.cs-rule.cs-rule--dotted { margin-top: 32px; }
.cs-rule--dotted + * { margin-top: 32px !important; }
.cs-problem .cs-label { margin-bottom: 16px; }
.cs-section h3.cs-label { font-family: var(--font-mono); font-size: 12px; line-height: 24px; }
.cs-hard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* below 1100px: 2 per row; the second column lines up with column 7 of the grid */
  gap: 32px 24px;
  margin-top: 32px;
}
.cs-hard__num {
  display: block;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 40px;
  line-height: 44px;
  color: var(--ink);
}
/* Desktop (1100px+): all four in one row, larger numbers */
@media (min-width: 1100px) {
  .cs-hard { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cs-hard__num { font-size: 56px; line-height: 56px; }
}
.cs-hard h3 { margin: 16px 0 0; font-size: 16px; line-height: 24px; font-weight: 500; }
.cs-hard p { font-size: 16px; line-height: 24px; margin-top: 4px !important; }

/* ---------- 03. Key decisions ---------- */

.cs-decision {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 32px;
  align-items: start;
  margin-top: 64px;
}

.cs-decision__text { grid-column: 1 / span 5; }
.cs-decision__text .cs-label { margin-bottom: 8px; }
.cs-decision__text h3 + p { margin-top: 8px; }
.cs-decision__media { grid-column: 7 / span 6; margin: 0; }
.cs-decision--reverse .cs-decision__text { grid-column: 7 / span 6; grid-row: 1; }
.cs-decision--reverse .cs-decision__media { grid-column: 1 / span 6; grid-row: 1; }
.cs-decision__media img { display: block; width: 100%; height: auto; }
.cs-decision__media--zebra img { max-width: 360px; margin: 0 auto; }
.cs-decision__media--zebra figcaption { max-width: 420px; margin: 16px auto 0; }
.cs-decision__media--bleed { margin-right: calc(-1 * var(--cs-pad)); }
.cs-decision__media figcaption { font-size: 12px; line-height: 18px; color: var(--muted); }

.cs-chip {
  display: inline-flex;
  gap: 12px;
  margin-top: 24px !important;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--cs-chip-bg);
  font-size: 14px;
  line-height: 20px;
}
.cs-chip span { color: var(--ink-soft); } /* 6.5:1 on the chip background */

/* ---------- 04. Validation ---------- */

.cs-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-top: 48px;
}
/* The controls stick to the top while the Validation section is on screen,
   so the version and annotations can be changed further down. */
.cs-controls {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-left: -16px;
  margin-right: -16px;
  padding: 12px 16px;
  border-radius: 0 0 12px 12px;
  background: rgba(255, 254, 251, .82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.cs-controls__left { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.cs-controls__right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

.cs-btn,
.cs-segmented {
  border: 1px solid #CBCAC3;
  border-radius: 8px;
  background: #F2F1ED;
}
.cs-btn {
  height: 40px;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  color: var(--ink);
}
.cs-btn:hover { background: #E9E8E2; }

/* Segmented control: the selected option fills its half edge to edge (no gap showing the background) */
.cs-segmented {
  display: inline-flex;
  height: 40px;
  overflow: hidden;
}
.cs-segmented button {
  padding: 8px 16px;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  color: var(--ink);
}
.cs-segmented button:hover { background: #E9E8E2; }
.cs-segmented button[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.cs-segmented button:focus-visible { outline-offset: -4px; outline-color: #FFFFFF; }
.cs-segmented button[aria-pressed="false"]:focus-visible { outline-color: var(--accent); }

.cs-switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  line-height: 24px;
  color: var(--ink);
}
.cs-switch__track {
  position: relative;
  width: 44px; height: 24px;
  border-radius: 999px;
  background: #94A3B8;
  transition: background-color .2s ease;
}
.cs-switch__track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #FFFFFF;
  transition: transform .2s ease;
}
.cs-switch[aria-checked="true"] .cs-switch__track { background: var(--ink); }
.cs-switch[aria-checked="true"] .cs-switch__track::after { transform: translateX(20px); }
.cs-switch__hint { font-size: 12px; line-height: 18px; color: var(--muted) !important; }

.cs-version { display: grid; gap: 48px; margin-top: 32px; overflow-anchor: none; } /* scroll position is kept by case-study.js */
.cs-version[hidden] { display: none; }

.cs-shot {
  margin: 0;
  padding: 40px 0 24px;
  border-radius: 12px;
  background: var(--cs-card-bg);
}
.cs-shot figcaption,
.cs-mobile figcaption,
.cs-results figcaption {
  margin-top: 24px;
  padding: 0 24px;
  text-align: right;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink);
}

/* The screenshot and its notes. Note positions are percentages of the screenshot
   (from Figma), set per note: --x/--y for the marker, --nx/--ny for the note card. */
.cs-shot__frame {
  position: relative;
  width: 100%;
  container-type: inline-size;
}
.cs-shot__img { position: relative; }
.cs-shot__frame img { display: block; width: 100%; height: auto; } /* the screenshots carry their own rounded corners and shadow */

.cs-notes { counter-reset: note; }
.cs-notes[hidden] { display: none; }
.cs-notes li {
  counter-increment: note;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink);
}
.cs-notes li strong { font-weight: 600; }

/* List layout (smaller screens): numbered notes under the screenshot, with matching
   numbered markers on the image. */
.cs-notes {
  display: grid;
  gap: 12px;
  margin-top: 24px;
  padding: 0 24px;
}
.cs-notes li {
  position: relative;
  padding: 12px 14px 12px 44px;
  border: 1px solid #D6CEC7;
  border-radius: 4px;
  background: #FCFCFB;
  color: #403730;
  box-shadow: var(--cs-shadow);
}
.cs-notes li::before {
  content: counter(note);
  position: absolute;
  left: 12px; top: 12px;
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 11px;
  line-height: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  /* Trim the font's ascender/descender space so the digit sits in the optical center */
  text-box: trim-both cap alphabetic;
}
.cs-version--final .cs-notes li { background: var(--cs-note-final-bg); border-color: var(--cs-note-final-border); }

/* Markers on the image (added by case-study.js, decorative) */
.cs-marker {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 11px;
  line-height: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-box: trim-both cap alphabetic;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .8);
  pointer-events: none;
}
.cs-shot__frame:has(.cs-notes[hidden]) .cs-marker { display: none; }

/* Overlay layout (large screens): notes float over and beside the screenshot, like the design */
@media (min-width: 1280px) {
  .cs-shot { padding-top: 48px; }
  .cs-shot__frame { width: 70%; margin-left: 14%; }
  .cs-notes { display: block; margin: 0; padding: 0; }
  .cs-notes li {
    position: absolute;
    left: calc(var(--nx) * 1%);
    top: calc(var(--ny) * 1%);
    width: calc(var(--w, 34) * 1cqw);
    padding: 10px 12px;
    font-size: 12px;
    line-height: 17px;
    z-index: 2;
  }
  .cs-notes li::before { display: none; }
  .cs-marker {
    width: 8px; height: 8px;
    margin: -4px 0 0 -4px;
    font-size: 0;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .9);
  }
}

.cs-mobile { margin: 64px 0 0; }
.cs-mobile ul {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}
.cs-mobile img { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: var(--cs-shadow); }

/* ---------- 05. Outcome ---------- */

.cs-results { margin: 48px 0 0; }
.cs-results ul {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}
.cs-results li {
  padding: 24px;
  border-radius: 12px;
  background: var(--cs-card-bg);
}
.cs-results img { display: block; width: 100%; height: auto; }
.cs-results p { margin-top: 16px; font-size: 18px; line-height: 24px; }
.cs-results figcaption { padding: 0; margin-top: 16px; color: var(--muted); }

/* ---------- 06. Reflection ---------- */

.cs-lessons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px 24px;
  margin-top: 48px;
}
.cs-lessons h3 { margin: 0; }
.cs-lessons p { margin-top: 4px !important; font-size: 14px; line-height: 22px; }
.cs-next { margin-top: 32px; }
.cs-next a { font-size: 16px; font-weight: 500; color: var(--ink); text-underline-offset: 4px; }

/* ---------- Raw data dialog ---------- */

.cs-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: #FFFFFF;
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(30, 41, 59, .25);
}
.cs-dialog::backdrop { background: rgba(30, 41, 59, .45); }
.cs-dialog__body { position: relative; padding: 48px 40px 40px; }
.cs-dialog__close {
  position: absolute;
  top: 16px; right: 16px;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  color: var(--ink);
}
.cs-dialog__close:hover { background: #F1F5F9; }
.cs-dialog__title {
  padding-right: 48px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 28px;
  line-height: 36px;
  color: var(--ink);
}
.cs-dialog__body > p { max-width: 760px; margin-top: 16px; font-size: 18px; line-height: 28px; }
.cs-dialog__list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px 32px;
  margin: 40px 0 0;
  font-size: 16px;
  line-height: 26px;
}
.cs-dialog__list dt { font-weight: 600; }
.cs-dialog__list dd { margin: 12px 0 0; }
.cs-dialog__shot {
  margin: 40px 0 0;
  padding: 28px;
  border-radius: 20px;
  background: #F7F7F8;
}
.cs-dialog__shot img { display: block; width: 100%; height: auto; }

/* ---------- Footer ---------- */

.cs-footer .last-update { color: var(--ink-strong); }

/* ==========================================================
   Smaller screens: sidebar becomes a top block
   ========================================================== */

@media (max-width: 1099px) {
  .cs { --cs-pad: 20px; }
  .cs-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "side" "main" "footer";
  }
  /* Only "Back" stays in the header: fixed top-left, 16px padding. At the top of the page it
     sits on the hero band with no box; once the page scrolls (.is-scrolled, set by
     case-study.js) it gets a blurred background so the page shows through. */
  .cs-side {
    position: fixed;
    top: calc(4px + env(safe-area-inset-top, 0px));
    left: calc(4px + env(safe-area-inset-left, 0px));
    z-index: 30;
    height: auto;
    overflow: visible;
    display: block;
    padding: 16px;
    border-radius: 12px;
    background: none; /* no dotted divider here */
    transition: background-color .2s ease;
  }
  .cs-side.is-scrolled {
    background: rgba(255, 254, 251, .72);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  .cs-side .cs-index { display: none; } /* no section navigation below 1100px */
  /* Impact numbers: 2 per row at 40px; the % keeps its proportion to the number (32/56) */
  .cs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 32px; }
  .cs-stat { font-size: 40px; line-height: 44px; }
  .cs-stat__unit { font-size: 23px; }
  /* The hero band starts at the very top; the image starts below Back */
  .cs-hero { padding-top: 72px; }
  /* The controls are a bar fixed to the bottom edge. It slides in (.is-docked, set by
     case-study.js) while the Validation screenshots are on screen, and always when a
     control inside it has keyboard focus. */
  .cs-controls {
    position: fixed;
    top: auto; left: 0; right: 0; bottom: 0;
    z-index: 30;
    margin: 0;
    align-items: center;
    gap: 12px 16px;
    padding: 12px max(var(--cs-pad), env(safe-area-inset-left, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(var(--cs-pad), env(safe-area-inset-right, 0px));
    border-top: 1px solid #E5E3DD;
    border-radius: 0;
    background: rgba(255, 254, 251, .82);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    transform: translateY(110%);
    transition: transform .25s ease;
  }
  .cs-controls.is-docked,
  .cs-controls:focus-within { transform: none; }
  .cs-controls .cs-switch__hint { display: none; }
  .cs-validation .cs-controls + .cs-version { margin-top: 32px; }

  .cs-section { padding-top: 72px; }
  .cs-overview { margin-top: 20px; padding-top: 40px; padding-bottom: 40px; }
  .cs-title { font-size: 40px; line-height: 44px; }

  .cs-intro > :first-child,
  .cs-intro > :last-child,
  .cs-overview__main,
  .cs-decision__text,
  .cs-decision__media,
  .cs-decision--reverse .cs-decision__text,
  .cs-decision--reverse .cs-decision__media { grid-column: 1 / -1; grid-row: auto; }
  .cs-decision--reverse .cs-decision__media { order: 2; }
}

@media (max-width: 699px) {
  .cs-title { font-size: 36px; line-height: 40px; }
  .cs-results ul,
  .cs-lessons { grid-template-columns: minmax(0, 1fr); }
  .cs-about { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-mobile ul { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .cs-controls__right { align-items: flex-start; }
  .cs-shot { padding: 20px 0 16px; }
  .cs-shot__frame { width: calc(100% - 32px); margin: 0 16px; }
  .cs-notes { padding: 0 16px; }
  /* Phone: the raw data dialog opens as a bottom sheet */
  .cs-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
    animation: cs-sheet-in .25s ease-out;
  }
  .cs-dialog__body { padding: 32px 20px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .cs-dialog__body::before {
    content: "";
    position: absolute;
    top: 8px; left: 50%;
    width: 40px; height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: #CBCAC3;
  }
  .cs-dialog__close { top: 12px; right: 8px; z-index: 1; background: rgba(255, 255, 255, .9); }
  /* Bottom sheet: the advisor system screenshot comes first, then the text */
  .cs-dialog__body { display: flex; flex-direction: column; }
  .cs-dialog__shot { order: -1; margin: 16px 0 24px; padding: 12px; border-radius: 12px; }
  @keyframes cs-sheet-in { from { transform: translateY(100%); } }
  .cs-dialog__list { grid-template-columns: minmax(0, 1fr); }
  .cs-dialog__title { font-size: 24px; line-height: 32px; }
  .cs-dialog__body > p { font-size: 16px; line-height: 24px; }
}

/* Opening a case study: the page rises in from below. Fill mode "backwards" leaves no transform
   once it ends, so fixed and sticky elements inside work as usual. Near-instant with reduced motion. */
.cs-main { animation: cs-page-in 700ms var(--ease) backwards; }
@keyframes cs-page-in { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }

/* Blocks settle in as they enter the screen (case-study.js adds .cs-reveal only without reduced motion) */
.cs-reveal { opacity: 0; transform: translateY(12px); transition: opacity var(--dur-long) var(--ease), transform var(--dur-long) var(--ease); }
.cs-reveal.is-in { opacity: 1; transform: none; }
/* Counting numbers keep a steady width */
.cs-stat__num { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
