/* =========================================================
   CASE-STUDY PAGE (classowl.html and future project pages).
   Shares the site's tokens/type so the cross-document View
   Transition from index.html lands on a same-feeling page.
   ========================================================= */

/* Opt in to seamless MPA navigation (must match index/style.css). */
@view-transition { navigation: auto; }

:root {
  --bg: #1e1e1e;
  --fg: #fffaee;
  --fg-dim: rgba(255, 250, 238, 0.12);
  --fg-mid: rgba(255, 250, 238, 0.55);
  --fg-soft: rgba(255, 250, 238, 0.82);
  --accent: #6dff7a;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "42dot Sans", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body.case {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  min-height: 100vh;
  overscroll-behavior: none;   /* no elastic bounce on the standalone page */
}

a { color: inherit; }

/* ── Film grain (same as the CV, rendered by noise.js) ── */
#noise {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.08;
  mix-blend-mode: overlay;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Crosshair cursor (same signature as the CV) ── */
html, body, body * { cursor: none; }
.crosshair {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100002;
}
.crosshair-h, .crosshair-v {
  position: absolute;
  background: rgba(255, 250, 238, 0.18);
  pointer-events: none;
  will-change: transform;
}
.crosshair-h { left: 0; top: 0; width: 100vw; height: 1px; transform: translateY(var(--cy, 50vh)); }
.crosshair-v { top: 0; left: 0; width: 1px; height: 100vh; transform: translateX(var(--cx, 50vw)); }
.cursor-hidden .crosshair { opacity: 0; }

/* Crosshair hover — crosshair.js flags body.ch-hot over interactive
   elements: a second 60×60 crosshair (same 1px weight, a bit more
   intense) grows over the crossing point. Main lines stay as-is.
   (Mirrors style.css for the standalone case pages.) */
.crosshair-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform: translate(var(--cx, 50vw), var(--cy, 50vh));
  pointer-events: none;
  will-change: transform;
}
.crosshair-dot::before,
.crosshair-dot::after {
  content: "";
  position: absolute;
  background: rgba(255, 250, 238, 0.5);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.crosshair-dot::before { left: -30px; top: 0; width: 60px; height: 1px; }
.crosshair-dot::after  { left: 0; top: -30px; width: 1px; height: 60px; }
body.ch-hot .crosshair-dot::before,
body.ch-hot .crosshair-dot::after {
  opacity: 1;
  transform: scale(1);
}

/* ── CLOSE — fixed top-right, back to the CV ── */
.case-close {
  position: fixed;
  top: 28px;
  right: 40px;
  z-index: 60;
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(22px, 2.4vw, 32px);
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: var(--fg-mid);
  text-decoration: none;
  transition: color 0.2s;
}
.case-close:hover { color: var(--fg); }

/* ── Layout shell ── */
.case-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px;
}

/* ── Header: title · meta · prototype buttons ── */
.case-head {
  display: grid;
  /* Title column sized so the meta column's left edge lands exactly on the
     content column below: 220px TOC + 64px body gap, minus the head's
     32px padding + 1px border and its own 48px gap. */
  grid-template-columns: calc(220px + 64px - 32px - 1px - 48px) 1fr auto;
  gap: 48px;
  align-items: start;
  border: 1px solid var(--fg-dim);
  padding: 32px;
}
.case-title {
  font-family: var(--sans);
  font-weight: 300;
  /* Same scale as the section headings (01 CONTEXT etc). */
  font-size: clamp(24px, 2.6vw, 32px);
  letter-spacing: -0.02em;
  /* Shared element — morphs from the ClassOwl card on index.html. */
  view-transition-name: vt-classowl;
}
.case-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 24px;
  align-self: center;
  max-width: 540px;
  font-size: 13px;
  line-height: 1.45;
}
.case-meta dt { color: var(--fg-mid); }
.case-meta dd { color: var(--fg); }

.case-protos {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proto-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 224px;
  padding: 14px 18px;
  border: 1px solid var(--fg-dim);
  background: transparent;
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 15px;
  text-align: left;
  text-decoration: none;   /* rendered as <a> links */
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.proto-btn:hover { border-color: var(--fg-mid); background: rgba(255, 255, 255, 0.03); }
.proto-btn svg { width: 15px; height: 15px; flex: none; }

/* ── Body: sticky TOC + content ── */
.case-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 64px;
  margin-top: 64px;
}

.case-toc {
  position: sticky;
  top: 40px;
  align-self: start;
}
.case-toc ol { list-style: none; }
.case-toc > ol > li { margin-bottom: 10px; }
.case-toc a {
  font-size: 22px;
  color: var(--fg-mid);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  transition: color 0.2s;
}
.case-toc a:hover { color: var(--fg); }
/* Scrollspy — the link for the section currently in view (set by the
   inline script in classowl.html) lights up white. */
.case-toc a.is-active { color: var(--fg); }
.case-toc ol ol { margin: 6px 0 16px; padding-left: 28px; }
.case-toc ol ol a { color: rgba(255, 250, 238, 0.34); }
.case-toc ol ol a.is-active { color: var(--fg); }
.toc-tag {
  margin-left: 8px;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg-mid);
}

/* ── Content ── */
.case-content { max-width: 760px; }
.case-content section { margin-bottom: 88px; }
.case-content h2 {
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(24px, 2.6vw, 32px);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin-bottom: 24px;
}
.case-content h3 {
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(18px, 2vw, 22px);
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 44px 0 16px;
}
.case-content p {
  font-size: 16px;
  line-height: 1.62;
  color: var(--fg-soft);
  margin-bottom: 18px;
  max-width: 68ch;
}
.section-rule { height: 1px; background: var(--fg-dim); border: 0; margin: 4px 0 24px; }

.case-content strong { font-weight: 600; color: var(--fg); }

/* Bulleted decision lists */
.case-content ul {
  list-style: disc outside;
  padding-left: 22px;
  max-width: 68ch;
  margin-bottom: 18px;
}
.case-content ul li {
  font-size: 16px;
  line-height: 1.62;
  color: var(--fg-soft);
  margin-bottom: 10px;
}

/* Minor sub-heading inside a subsection (e.g. "How it relates to Lists") */
.case-content h4 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin: 26px 0 12px;
}

/* ── Decision trade-off cards (Feasibility / Usability) ── */
.case-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 28px 0;
  max-width: 68ch;
}
.case-card {
  border: 1px solid var(--fg-dim);
  padding: 24px 20px;
}
.case-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin-bottom: 12px;
}
.case-card-title svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.case-card p {
  font-size: 15px;
  margin-bottom: 0;
}
@media (max-width: 900px) {
  .case-cards { grid-template-columns: 1fr; }
}

/* ── Outcome status bar (target icon + shipped state) ── */
.case-status {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 68ch;
  padding: 18px 20px;
  border: 1px solid var(--fg-dim);
  background: rgba(255, 255, 255, 0.02);
}
.case-status svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--fg-mid);
}
.case-status span {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--fg);
}
/* Maturity palette — three distinct muted tones so the state reads at a
   glance: shipped (sage green) > designed (ochre) > concept (slate blue). */
.case-status--shipped svg  { color: #7fae7a; }
.case-status--designed svg { color: #c9b458; }
.case-status--concept svg  { color: #7f9bb3; }

/* ── Inline prototype banner (wide play card) ── */
.proto-banner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 48px;
  width: 100%;
  max-width: 68ch;
  min-height: 170px;
  margin: 28px 0;
  padding: 20px;
  border: 1px solid var(--fg-dim);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.06));
  color: var(--fg);
  font-family: var(--sans);
  /* weight 300 on the box so its 68ch cap resolves with the same glyph
     width as body text (ch varies with font weight); the label span
     carries the visual 600. */
  font-weight: 300;
  font-size: 16px;
  letter-spacing: -0.02em;
  text-align: left;
  text-decoration: none;   /* rendered as <a> links */
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.proto-banner span { font-weight: 600; }
.proto-banner:hover {
  border-color: var(--fg-mid);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.09));
}
.proto-banner svg {
  width: 26px;
  height: 26px;
}

/* ── Media figures (screenshots / recordings) ──
   Capped at the same measure as body text (68ch) so media never sticks
   out past the reading column. */
.case-fig { margin: 28px 0; max-width: 68ch; }
.case-fig img,
.case-fig video {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--fg-dim);
}
.case-fig figcaption {
  margin-top: 10px;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--fg-mid);
  text-align: center;
}

/* Clickable media — every figure opens in the lightbox (lightbox.js). */
.fig-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  position: relative;
  color: inherit;
}
.fig-open img,
.fig-open video {
  pointer-events: none;   /* clicks land on the button */
  transform: scale(1) translate(0, 0);
  transition: transform 0.35s ease-out, border-color 0.2s;
  will-change: transform;
}
/* Hover: the WHOLE framed image lifts — a very gentle scale plus a faint
   drift after the cursor (no clipping, the element moves as one object).
   --fx/--fy ∈ [-1, 1] are set by lightbox.js from the pointer position. */
.fig-open:hover img,
.fig-open:hover video {
  border-color: var(--fg-mid);
  transform: scale(1.02)
             translate(calc(var(--fx, 0) * 4px), calc(var(--fy, 0) * 4px));
}

/* Video preview play badge */
.fig-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 250, 238, 0.6);
  border-radius: 50%;
  background: rgba(18, 18, 18, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: transform 0.2s ease, background 0.2s;
}
.fig-play::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 54%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent var(--fg);
}
.fig-open:hover .fig-play {
  transform: translate(-50%, -50%) scale(1.12);
  background: rgba(18, 18, 18, 0.78);
}

/* Side-by-side pair (e.g. heatmap + recording) — 50% / 50%, 20px gap.
   Same 68ch cap as single figures — stays inside the reading column. */
.case-fig-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 28px 0;
  max-width: 68ch;
  align-items: start;
}
.case-fig-row .case-fig { margin: 0; min-width: 0; }
/* A row nested inside a captioned figure (shared figcaption below the pair). */
.case-fig > .case-fig-row { margin: 0 0 4px; }
.case-fig-row .fig-open { min-width: 0; }
/* Same-size boxes regardless of the media's own proportions. */
.case-fig-row .fig-open img,
.case-fig-row .fig-open video {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}
@media (max-width: 900px) {
  .case-fig-row { grid-template-columns: 1fr; }
}

/* ── Lightbox — full-size media over everything (lightbox.js) ── */
.case-lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;   /* above the case overlay (300) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px;
  background: rgba(30, 30, 30, 0.8);   /* #1E1E1E @ 80% */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* Own snapshot group — the backdrop fades in/out over the SAME 0.45s as
     the media morph instead of popping in with the fast root crossfade. */
  view-transition-name: vt-lightbox-backdrop;
}
/* Explicit display beats the UA [hidden] rule — restore it. */
.case-lightbox[hidden] { display: none; }
/* Non-VT browsers: fall back to a plain keyframe fade on open. */
@supports not (view-transition-name: none) {
  .case-lightbox:not([hidden]) { animation: lb-fade 0.3s ease; }
}
@keyframes lb-fade { from { opacity: 0; } }
/* The clicked thumbnail morphs into the lightbox media — shared
   `vt-lightbox` name is assigned per-open by lightbox.js. */
::view-transition-group(vt-lightbox),
::view-transition-group(vt-lightbox-backdrop) {
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}
::view-transition-old(vt-lightbox-backdrop),
::view-transition-new(vt-lightbox-backdrop) {
  animation-duration: 0.45s;
  animation-timing-function: ease;
}
body.lightbox-open { overflow: hidden; }
/* The body is a flex item that can stretch wider than its media (intrinsic
   video width) — center the media within it. */
.case-lightbox .lightbox-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
}
.case-lightbox .lightbox-body img,
.case-lightbox .lightbox-body video {
  display: block;
  max-width: min(1200px, 90vw);
  max-height: 84vh;
  border: 1px solid var(--fg-dim);
  background: var(--bg);
}
.lightbox-close {
  position: fixed;
  top: 28px;
  right: 40px;
  font-family: var(--sans);
  font-weight: 400;
  /* Identical type to .case-close — the two CLOSE buttons must match. */
  font-size: clamp(22px, 2.4vw, 32px);
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: var(--fg-mid);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.2s;
}
.lightbox-close:hover { color: var(--fg); }
.stub {
  color: var(--fg-mid);
  border: 1px dashed var(--fg-dim);
  padding: 16px 18px;
  font-size: 14px;
}

/* ── In-page case overlay (index.html) ──
   Full-viewport scrollable layer the CV stays alive under: audio keeps
   playing, the 3D loop is paused via cvHero.pause() and hidden below. */
.case-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;   /* over drawer (200) & works button; under noise/crosshair */
  overflow-y: auto;
  background: var(--bg);
  /* `none` (not `contain`) — also suppresses the scroller's own elastic
     bounce, which briefly exposed the page behind the modal on overscroll. */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  /* The drawer ⇄ full-screen stretch is a plain scaleX animation driven by
     works.js (transform-origin right) — cheaper than a view transition. */
  will-change: transform;
}
body.case-open { overflow: hidden; }          /* freeze the page behind */
body.case-open .hero-3d { visibility: hidden; }

/* Overlay content stays hidden through the surface morph and fades in
   once the panel has finished stretching (works.js adds .content-in).
   Standalone case pages have no .case-overlay — unaffected. */
.case-overlay .case-close,
.case-overlay .case-wrap {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease,
              transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.case-overlay.content-in .case-close,
.case-overlay.content-in .case-wrap {
  opacity: 1;
  transform: none;
}
.case-overlay.content-in .case-wrap { transition-delay: 0.06s; }

/* ── View-transition tuning (site easing) ── */
::view-transition-group(vt-classowl) {
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.4s;
  animation-timing-function: ease;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .case-wrap { padding: 24px; }
  .case-head { grid-template-columns: 1fr; gap: 24px; }
  .case-protos { flex-direction: row; flex-wrap: wrap; }
  .proto-btn { min-width: 0; flex: 1 1 auto; }
  .case-body { grid-template-columns: 1fr; gap: 32px; margin-top: 40px; }
  .case-toc { position: static; }
  .case-close, .lightbox-close { top: 18px; right: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
  .case-overlay .case-close,
  .case-overlay .case-wrap {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

/* Touch devices: no mouse → restore the normal cursor. */
@media (hover: none) {
  html, body, body * { cursor: auto; }
  .crosshair { display: none; }
}
