/* ============================================================
   CASE STUDIES - one template for every case study, in the Raven world.
   Loaded after styles.css and raven.css. Values come from tokens/.
   ============================================================ */
.case { position: relative; overflow-x: clip; }
.case p, .case li, .case dd, .case figcaption { text-wrap: pretty; }
.case h2, .case h3 { text-wrap: balance; }

/* ---- first screen: the mesh field, the title, the facts ---- */
.case-hero { position: relative; isolation: isolate; overflow: hidden; padding: clamp(150px, 16vw, 210px) 0 clamp(48px, 6vw, 96px); }
.case-hero .grain { position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0.06; mix-blend-mode: soft-light; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>"); }
.case-hero .floor { position: absolute; inset: auto 0 0 0; height: 40%; z-index: -1; background: linear-gradient(0deg, var(--raven), rgba(7, 4, 3, 0)); pointer-events: none; }
.case-hero-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: clamp(32px, 5vw, 80px); align-items: center; }
.case-hero-in.solo { grid-template-columns: minmax(0, 860px); }
.case-copy { position: relative; isolation: isolate; }
.case-copy::before { content: ''; position: absolute; z-index: -1; inset: -12% -18% -14% -24%; background: var(--scrim-text); pointer-events: none; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 26px; font-size: var(--text-ui); color: var(--ice-300); }
.crumbs span + span::before { content: ''; display: inline-block; width: 4px; height: 4px; margin-right: 12px; border-radius: 999px; background: var(--poppy-300); vertical-align: middle; }
.case-hero h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(56px, 7vw, 104px); line-height: 1; letter-spacing: -0.015em; color: var(--ice-100); text-shadow: 0 4px 30px rgba(7, 4, 3, 0.5); }
.case-hero h1 .alt { display: table; margin-bottom: 6px; font-size: 0.5em; color: var(--ice-300); }
.case-hero h1 .after { display: block; margin-top: 10px; font-size: 0.4em; color: var(--ice-300); }
.case-index { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; margin: clamp(32px, 4vw, 48px) 0 0; padding-top: 18px; border-top: 1px solid var(--ice-hairline); font-size: var(--text-ui); color: var(--ice-300); }
.case-index a { display: inline-flex; align-items: center; min-height: 32px; color: var(--ice-100); text-decoration: underline; text-decoration-color: var(--ice-hairline); text-underline-offset: 5px; transition: text-decoration-color 0.3s ease; }
.case-index a:hover { text-decoration-color: var(--poppy-300); }
.case-hero .lead { margin: 26px 0 0; max-width: 34em; font-size: clamp(17px, 1.35vw, 19px); line-height: 1.6; color: var(--ice-100); text-shadow: var(--shadow-text); text-wrap: pretty; }
.case-hero .lead + .lead { margin-top: 14px; color: var(--ice-200); }
.facts-row { display: flex; flex-wrap: wrap; gap: 18px clamp(24px, 4vw, 48px); margin: 34px 0 0; padding: 22px 0 0; border-top: 1px solid var(--ice-hairline); }
.facts-row div { min-width: 0; }
.facts-row dt { font-size: 14px; color: var(--ice-300); }
.facts-row dd { margin: 4px 0 0; font-size: var(--text-base); color: var(--ice-100); }
.facts-row dd.hot { color: var(--poppy-300); }

/* ---- figures: uploads sit whole in a glass frame, on a Raven well ---- */
.fig { margin: 0; padding: 10px; }
.fig .well { position: relative; overflow: hidden; border-radius: var(--radius-glass-sm); background: var(--screen-well); }
.fig .well img, .fig .well video { width: 100%; height: auto; object-fit: contain; }
.fig figcaption { padding: 12px 8px 4px; font-size: 14px; line-height: 1.45; color: var(--ice-200); }
.fig.bare { padding: 0; }
.fig.phone { max-width: 320px; justify-self: center; width: 100%; }
.fig.phone .well { border-radius: var(--radius-phone); }

/* ---- chapters ---- */
.chapter { position: relative; isolation: isolate; padding: clamp(72px, 9vw, 128px) 0; }
.chapter + .chapter { padding-top: clamp(24px, 4vw, 56px); }
.chapter-head { margin-bottom: clamp(32px, 4vw, 56px); }
.chapter-head h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(36px, 4.4vw, 60px); line-height: 1.04; letter-spacing: -0.01em; color: var(--ice-100); }
.chapter-head p { margin: 14px 0 0; font-size: 17px; line-height: 1.6; color: var(--ice-300); max-width: 52ch; }
.chapter .glow { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.chapter .glow::before { content: ""; position: absolute; top: 4%; bottom: 4%; width: 80%; background: url(uploads/mesh-work.webp) center / cover no-repeat; opacity: 0.55; -webkit-mask-image: radial-gradient(70% 60% at 50% 50%, #000 30%, transparent 75%); mask-image: radial-gradient(70% 60% at 50% 50%, #000 30%, transparent 75%); }
.chapter .glow.right::before { right: -18%; }
.chapter .glow.left::before { left: -18%; transform: scaleX(-1); }

.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(28px, 4vw, 64px); align-items: start; }
.duo.wide-left { grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.9fr); }
.duo.wide-right { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr); }
.duo.mid { align-items: center; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.quad { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stack { display: grid; gap: clamp(20px, 3vw, 36px); }
.gap-top { margin-top: clamp(28px, 4vw, 56px); }

.prose { font-size: 17px; line-height: 1.72; max-width: 66ch; color: var(--ice-200); }
.prose p { margin: 0 0 18px; text-wrap: pretty; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 500; color: var(--ice-100); }
.prose.cols { max-width: none; columns: 2; column-gap: clamp(28px, 4vw, 64px); }
.prose.cols p { break-inside: avoid; }

/* ---- cards ---- */
.card { padding: clamp(22px, 2.6vw, 32px); }
.card h3, .card h4 { margin: 0 0 12px; font-family: var(--font-display); font-weight: 400; font-size: clamp(22px, 2vw, 28px); line-height: 1.2; color: var(--ice-100); }
/* stages: a short path in the homepage timeline's materials (glass pebbles on a hairline; red is now) */
.stages { position: relative; list-style: none; margin: 0 0 clamp(32px, 4vw, 48px); padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px clamp(20px, 3vw, 40px); }
.stages::before { content: ""; position: absolute; left: 8px; right: 8px; top: 8px; height: 1px; background: var(--ice-hairline); }
.stages li { position: relative; padding-top: 36px; }
.stages .pebble { position: absolute; top: calc(8px - var(--ph) / 2); left: calc(8px - var(--pw) / 2); }
.stages li[aria-current] .pebble { --ps: 1.35; background: var(--pebble-active); border-color: var(--pebble-rim-active); }
.stages b { display: block; font-family: var(--font-display); font-weight: 400; font-size: clamp(22px, 2vw, 28px); line-height: 1.2; color: var(--ice-100); }
.stages p { margin: 6px 0 0; font-size: var(--text-base); line-height: 1.55; color: var(--ice-200); }
.chapter .subhead { margin: clamp(40px, 5vw, 64px) 0 20px; font-family: var(--font-display); font-weight: 400; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.2; color: var(--ice-100); }
.card p { margin: 0; font-size: var(--text-base); line-height: 1.6; color: var(--ice-200); text-wrap: pretty; }
.card p + p { margin-top: 12px; }
.ticks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ticks li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--raven-line); font-size: var(--text-base); line-height: 1.55; color: var(--ice-100); }
.ticks li:first-child { border-top: 0; padding-top: 0; }
.ticks i { color: var(--poppy-300); font-size: var(--text-md); margin-top: 2px; }
.ticks.goals i, .ticks.issues i { color: var(--ice-300); }

.stat { padding: clamp(22px, 2.6vw, 32px); }
.stat b { display: block; font-family: var(--font-display); font-weight: 400; font-size: clamp(40px, 4.4vw, 56px); line-height: 1; color: var(--ice-100); }
.stat > span { display: block; margin-top: 12px; font-size: var(--text-base); line-height: 1.55; color: var(--ice-200); }

.rules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 36px; }
.rules h3 { margin: 0 0 8px; font-size: clamp(20px, 1.7vw, 24px); }
.card .stat { padding: 22px 0 0; margin-top: 18px; border-top: 1px solid var(--raven-line); }
.credits { margin: 0; display: grid; gap: 0; }
.credits div { display: grid; grid-template-columns: minmax(110px, 0.5fr) 1fr; gap: 6px 18px; padding: 12px 0; border-top: 1px solid var(--raven-line); }
.credits div:first-child { border-top: 0; padding-top: 0; }
.credits dt { font-size: 14px; color: var(--ice-300); padding-top: 2px; }
.credits dd { margin: 0; font-size: var(--text-base); line-height: 1.55; color: var(--ice-100); }
.note { margin: 18px 0 0; font-size: var(--text-base); line-height: 1.6; color: var(--ice-200); }

/* swatches: the product's own colors, shown as chips */
.swatches { display: grid; gap: 8px; }
.swatches div { display: flex; justify-content: space-between; gap: 14px; padding: 14px 18px; border-radius: var(--radius-control); font-size: 14px; border: 1px solid var(--glass-rim-dark); }

/* ---- the film: a 16:9 glass frame with visible controls ---- */
.film { margin: 0; padding: 10px; }
.film .well { position: relative; overflow: hidden; border-radius: var(--radius-glass-sm); background: var(--raven); aspect-ratio: 16 / 9; }
.film video { width: 100%; height: 100%; object-fit: contain; cursor: pointer; }
.film-controls { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 6px; padding: 5px; border-radius: 999px; }
.film-controls button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; min-width: 40px; justify-content: center; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ice-100); font: inherit; font-size: var(--text-ui); cursor: pointer; transition: background-color 0.3s ease; }
.film-controls button:hover { background: rgba(238, 246, 252, 0.12); }
.film-controls button i { font-size: var(--text-md); }
.film figcaption { padding: 12px 8px 4px; font-size: 14px; color: var(--ice-200); }

/* ---- before and after: a toggle, so whole screens are compared with whole screens ---- */
.swap-tabs { display: inline-flex; gap: 4px; margin: 0 0 12px; }
.swap-tabs button { min-height: 36px; padding: 0 16px; border: 1px solid var(--ice-hairline); border-radius: 999px; background: transparent; color: var(--ice-200); font: inherit; font-size: var(--text-ui); cursor: pointer; transition: background-color 0.3s ease, color 0.3s ease; }
.swap-tabs button:hover { color: var(--ice-100); background: rgba(238, 246, 252, 0.08); }
.swap-tabs button[aria-pressed="true"] { background: var(--ice-100); color: var(--raven); }
.swap { position: relative; overflow: hidden; border-radius: var(--radius-glass-sm); background: var(--screen-well); }
.swap-in { display: grid; }
.swap-in > img { grid-area: 1 / 1; width: 100%; height: auto; transition: opacity 0.5s var(--ease-out); }
.swap[data-show="before"] .after, .swap[data-show="after"] .before { opacity: 0; }
.swap-hint { display: none; margin: 10px 4px 0; font-size: 14px; color: var(--ice-300); }

.screen { padding: clamp(18px, 2.4vw, 28px); }
.screen + .screen { margin-top: 16px; }
.screen-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; margin-bottom: 18px; }
.screen-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(24px, 2.4vw, 32px); color: var(--ice-100); }
.screen-head p { margin: 0; font-size: var(--text-base); color: var(--ice-300); max-width: 52ch; }
.ba { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 28px; margin-top: 20px; }
.ba h4 { margin: 0 0 6px; font-size: 14px; font-weight: 500; color: var(--ice-300); }
.ba h4.after { color: var(--poppy-300); }
.ba h4 span { font-weight: 400; }
.ba p { margin: 0; font-size: var(--text-base); line-height: 1.6; color: var(--ice-200); }

/* ---- a row of phone screens that scrolls sideways ---- */
.rail { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: 2px; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { flex: 0 0 calc((100% - 28px) / 3); scroll-snap-align: start; }
.rail-nav { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.rail-nav button { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--glass-rim-dark); background: var(--glass-dark); color: var(--ice-100); cursor: pointer; font-size: var(--text-md); display: inline-flex; align-items: center; justify-content: center; transition: background-color 0.3s ease; }
.rail-nav button:hover { background: rgba(238, 246, 252, 0.12); }

/* ---- the close: an ice panel, then the way on ---- */
.case-close { padding: clamp(40px, 6vw, 80px) 0 clamp(72px, 9vw, 120px); }
.case-close .ice-panel p { position: relative; z-index: 1; margin: 22px 0 0; max-width: 40ch; font-size: var(--text-md); line-height: 1.6; color: var(--raven); }
.case-close .ice-panel a { color: var(--raven); border-bottom: 1px solid var(--raven); font-weight: 500; }
.next-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: clamp(28px, 4vw, 48px); }
.next-nav a { display: flex; flex-direction: column; gap: 6px; padding: 22px 26px; transition: transform 0.4s var(--ease-out), border-color 0.3s ease; }
.next-nav a:hover { transform: translateY(-3px); border-color: var(--ice-underline); }
.next-nav small { font-size: 14px; color: var(--ice-300); }
.next-nav span { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: clamp(22px, 2.2vw, 30px); color: var(--ice-100); }
.next-nav .to { text-align: right; align-items: flex-end; }
.next-nav i { color: var(--poppy-300); font-size: var(--text-md); }

/* ---- the gate for protected studies ---- */
.gate { position: fixed; inset: 0; z-index: 90; display: grid; justify-items: center; align-content: start; padding: clamp(72px, 18vh, 200px) 24px 24px; isolation: isolate; overflow: auto; background: var(--raven); }
.gate .mesh { z-index: -1; }
.gate-card { width: 100%; max-width: 440px; padding: clamp(26px, 4vw, 40px); }
.gate-card h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 3.4vw, 40px); line-height: 1.12; color: var(--ice-100); }
.gate-card p { margin: 14px 0 0; font-size: var(--text-base); line-height: 1.6; color: var(--ice-200); }
.gate-card form { display: grid; gap: 16px; margin-top: 26px; }
.gate-card label { display: grid; gap: 8px; font-size: var(--text-ui); color: var(--ice-100); }
.gate-card input { font: inherit; font-size: var(--text-base); color: var(--ice-100); background: var(--input-fill); border: 1px solid var(--ice-hairline); border-radius: var(--radius-control); padding: 13px 14px; transition: border-color 0.3s ease; }
.gate-card input:focus { border-color: var(--ice-300); }
.gate-card .btn { justify-self: start; }
.gate-card .err { margin: 0; font-size: var(--text-ui); color: var(--poppy-300); }
.gate-card .alt { margin-top: 22px; font-size: var(--text-ui); color: var(--ice-300); }

.site-head { transition: transform 0.5s var(--ease-out); }
.site-head.tucked { transform: translateY(-130%); }
.site-head.tucked:focus-within { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .next-nav a, .next-nav a:hover, .site-head { transition: none; transform: none; }
  .swap-in > img { transition: none; }
}

@media (max-width: 1080px) {
  .case-hero-in { grid-template-columns: minmax(0, 1fr); }
  .case-hero .floor { height: 14%; }
  .trio, .rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .case-hero { padding-top: 150px; }
  .duo, .duo.wide-left, .duo.wide-right, .ba, .next-nav { grid-template-columns: minmax(0, 1fr); }
  .prose.cols { columns: 1; }
  .rail > * { flex-basis: 62%; }
  .chapter .glow::before { top: 0; bottom: auto; height: min(70vh, 620px); width: 110%; opacity: 0.35; }
  .next-nav .to { text-align: left; align-items: flex-start; }
}
@media (max-width: 560px) {
  .trio, .quad, .rules { grid-template-columns: minmax(0, 1fr); }
  .stages { grid-template-columns: minmax(0, 1fr); }
  .stages::before { left: 8px; right: auto; top: 8px; bottom: 8px; width: 1px; height: auto; }
  .stages li { padding: 0 0 0 40px; }
  .stages .pebble { top: calc(14px - var(--ph) / 2); }
  .swap { overflow-x: auto; scrollbar-width: none; }
  .swap::-webkit-scrollbar { display: none; }
  .swap-in { width: 220%; }
  .swap-hint { display: block; }
  .credits div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .film-controls { left: 8px; bottom: 8px; }
  .fig.phone { max-width: 250px; }
  .rail > * { flex-basis: 78%; }
}
