/* Bluefront AI: project (case study) pages, /work/<slug>. Markup from tools/build_case.py, behaviour in case.js.
   Hairline boxes with rounded corners, a sticky chapter list on wide screens, and "Up next": a dark blue screen where
   the "b" of the logo is a window onto the top of the next project page. Colours come only from the theme tokens. */

.cs { --cs-r: 18px; --cs-line: 1px solid var(--border); --cs-top: 112px; }

/* ---------- hero ---------- */
.cs-hero { padding: clamp(118px, 13vw, 168px) 0 0; }
.cs-hero__top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 32px; flex-wrap: wrap; margin-top: clamp(14px, 2vw, 24px); }
.cs-title { margin: 0; font-size: clamp(3.1rem, 9.2vw, 8.6rem); line-height: 0.95; font-weight: 500; letter-spacing: -0.045em; color: var(--ink); }
.cs-kind { margin: 0 0 0.55em; font-size: clamp(1.05rem, 1.5vw, 1.3rem); color: var(--muted); }

.cs-meta {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: clamp(26px, 3.6vw, 44px) 0 0;
  background: var(--border); border: var(--cs-line); border-radius: var(--cs-r); overflow: hidden;
}
.cs-meta__cell { padding: 18px 20px 20px; background: var(--card); }
.cs-meta dt { margin: 0 0 10px; font-size: 0.76rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.cs-meta dd { margin: 0; display: flex; flex-wrap: wrap; row-gap: 4px; font-weight: 500; color: var(--ink); }
.cs-meta dd span + span::before { content: "/"; margin: 0 0.5em; color: var(--accent); }

.cs-hero__media { margin-top: clamp(14px, 1.6vw, 20px); }

.cs-intro { display: grid; grid-template-columns: minmax(0, 0.32fr) minmax(0, 1fr); gap: 16px clamp(32px, 4vw, 64px); padding: clamp(40px, 5vw, 72px) 0 0; }
.cs-intro__label { margin: 0.45em 0 0; font-size: 0.76rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.cs-lede { margin: 0; max-width: 34ch; font-size: clamp(1.35rem, 2.3vw, 2.05rem); line-height: 1.32; letter-spacing: -0.015em; color: var(--ink); }
.cs-note { margin: 20px 0 0; font-size: 0.9rem; color: var(--muted); }

/* ---------- panels: a screen framed on a backdrop, thin border, rounded ---------- */
.cs-panel {
  position: relative; margin: 0; padding: clamp(14px, 4.6%, 56px); isolation: isolate; overflow: hidden;
  border: var(--cs-line); border-radius: var(--cs-r);
}
.cs-panel__glow { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.cs-panel--light { background: linear-gradient(165deg, var(--accent-soft), var(--surface) 70%); }
.cs-panel--light .cs-panel__glow { background: radial-gradient(60% 55% at 88% 0%, rgba(var(--accent-rgb), 0.16), transparent 70%); }
.cs-panel--deep { background: var(--navy); border-color: rgba(var(--accent-rgb), 0.3); }
.cs-panel--deep .cs-panel__glow {
  background: radial-gradient(70% 60% at 82% 0%, rgba(var(--accent-rgb), 0.55), transparent 66%),
              radial-gradient(55% 50% at 0% 100%, rgba(var(--accent-rgb), 0.22), transparent 70%);
}
.cs-shot {
  border-radius: 10px; overflow: hidden; background: var(--card);
  box-shadow: 0 30px 60px -30px rgba(var(--shadow-rgb), 0.45), 0 0 0 1px rgba(var(--ink-rgb), 0.08);
}
.cs-shot img, .cs-shot video { display: block; width: 100%; height: auto; }
.cs-hero__media .cs-shot .cs-video { aspect-ratio: 16 / 10; object-fit: cover; }

.cs-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(12px, 1.6vw, 20px); }
.cs-panel--crop { display: flex; align-items: center; justify-content: center; }
.cs-panel--crop .cs-shot { width: auto; max-width: 100%; }
.cs-panel--crop .cs-shot img { width: auto; max-width: 100%; max-height: min(620px, 70vh); }

/* ---------- chapters: sticky list on the left, screens on the right ---------- */
.cs-body { padding: clamp(72px, 9vw, 128px) 0 clamp(56px, 7vw, 96px); }
.cs-body__grid { display: grid; grid-template-columns: minmax(250px, 0.32fr) minmax(0, 1fr); gap: clamp(32px, 4vw, 64px); align-items: start; }
.cs-index { position: sticky; top: var(--cs-top); border: var(--cs-line); border-radius: var(--cs-r); background: var(--card); overflow: hidden; }
.cs-index__label { margin: 0; padding: 18px 22px 16px; border-bottom: var(--cs-line); font-size: 0.76rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.cs-index ol { margin: 0; padding: 0; list-style: none; }
.cs-index__item + .cs-index__item { border-top: var(--cs-line); }
.cs-index__link { display: flex; gap: 14px; padding: 15px 22px; text-decoration: none; font-weight: 500; line-height: 1.35; color: var(--muted); transition: color 0.3s var(--ease); }
.cs-index__link:hover { color: var(--ink); }
.cs-index__num { flex: none; width: 1.6em; padding-top: 0.12em; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.cs-index__item.is-active .cs-index__link { color: var(--ink); }
.cs-index__item.is-active .cs-index__num { color: var(--accent); }
.cs-index__text {
  margin: 0; padding: 0 22px 0 calc(22px + 1.6em + 14px); max-height: 0; overflow: hidden; opacity: 0;
  font-size: 0.95rem; line-height: 1.55; color: var(--muted);
  transition: max-height 0.55s var(--ease), opacity 0.4s var(--ease), padding-bottom 0.55s var(--ease);
}
.cs-index__item.is-active .cs-index__text { max-height: 14em; opacity: 1; padding-bottom: 20px; }

.cs-chapters { display: grid; gap: clamp(72px, 9vw, 140px); }
.cs-ch { scroll-margin-top: var(--cs-top); }
.cs-ch__media { display: grid; gap: clamp(14px, 1.8vw, 24px); }
/* wide screens: the chapter text is read from the sticky list, so the in-flow copy is for screen readers only */
@media (min-width: 901px) {
  .cs-ch__text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
}

/* ---------- commitments and private demo ---------- */
.cs-commit { padding: clamp(64px, 8vw, 112px) 0 clamp(72px, 9vw, 128px); }
.cs-commit__h { margin: 0 0 22px; font-size: 0.76rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.cs-commit__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; border-top: var(--cs-line); }
.cs-commit__list li { display: grid; gap: 12px; align-content: start; padding: 28px 28px 4px 0; }
.cs-commit__list li + li { padding-left: 28px; border-left: var(--cs-line); }
.cs-commit__list strong { font-size: clamp(2.1rem, 4.4vw, 3.9rem); line-height: 1; font-weight: 500; letter-spacing: -0.04em; color: var(--ink); }
.cs-commit__list span { max-width: 26ch; color: var(--muted); }
.cs-demo {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 18px 28px;
  margin-top: clamp(48px, 6vw, 80px); padding: 22px 22px 22px 28px;
  border: var(--cs-line); border-radius: var(--cs-r); background: var(--surface);
}
.cs-demo p { margin: 0; max-width: 48ch; font-size: 1.1rem; line-height: 1.45; color: var(--ink); }
.cs-demo__btn {
  display: inline-flex; align-items: center; gap: 0.55rem; min-height: 48px; padding: 0 1.4rem; border-radius: var(--radius-pill);
  background: var(--accent-fill, var(--accent)); color: var(--card); font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: transform 0.22s var(--ease), background-color 0.22s var(--ease);
}
html[data-theme="dark"] .cs-demo__btn { color: var(--ink); }
.cs-demo__btn:hover { transform: translateY(-1px); }
.cs-demo__btn svg { transition: transform 0.22s var(--ease); }
.cs-demo__btn:hover svg { transform: translateX(3px); }

/* ---------- up next ----------
   Without JS, with reduced motion or after "Pause motion" it is a plain card: the "b" in blue and a link.
   case.js adds .is-live: the section grows tall, the stage sticks, and .cs-next__page (a copy of the top of the next
   project page, laid out exactly as that page starts) shows through the "b". Scrolling grows the "b"; then its round
   part fills in and opens into a circle that covers the screen, and the next page opens on the same picture. */
.cs-next {
  --cs-on: var(--card);
  position: relative; margin-top: -1px; background: var(--navy); color: var(--cs-on);
  border-radius: 28px 28px 0 0; overflow: clip;
}
html[data-theme="dark"] .cs-next { --cs-on: var(--ink); }
.cs-next__stage {
  position: relative; display: grid; justify-items: center; gap: clamp(22px, 3vw, 36px);
  padding: clamp(72px, 9vw, 120px) 20px clamp(56px, 7vw, 88px); text-align: center; isolation: isolate;
}
.cs-next__glow {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(55% 50% at 50% 62%, rgba(var(--accent-rgb), 0.5), transparent 72%),
              radial-gradient(80% 60% at 50% 120%, rgba(var(--accent-rgb), 0.35), transparent 70%);
  opacity: calc(0.7 + 0.3 * var(--cs-k, 0));
}
.cs-next__head { display: grid; gap: 10px; }
.cs-next__label { margin: 0; font-size: 0.8rem; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.8; }
.cs-next__title { margin: 0; font-size: clamp(2.6rem, 7vw, 6rem); line-height: 1; font-weight: 500; letter-spacing: -0.04em; }
.cs-next__title a { color: inherit; text-decoration: none; }
.cs-next__title a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.12em; }
.cs-next__kind { margin: 0; font-size: 1.05rem; opacity: 0.8; }
.cs-next__win { display: block; width: auto; height: min(36vh, 300px); overflow: visible; }
.cs-b-stop1 { stop-color: var(--accent); }
.cs-b-stop2 { stop-color: var(--accent); stop-opacity: 0.35; }
.cs-next__foot { display: grid; justify-items: center; gap: 14px; }
.cs-next__open {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; padding: 0 1.2rem;
  border: 1px solid rgba(var(--accent-rgb), 0.55); border-radius: var(--radius-pill);
  color: inherit; font-weight: 500; text-decoration: none; transition: background-color 0.22s var(--ease);
}
.cs-next__open:hover { background: rgba(var(--accent-rgb), 0.22); }
.cs-next__page, .cs-next__edge, .cs-next__hint, .cs-next__track { display: none; }

.cs-next.is-live { height: 300vh; height: 300svh; }
.cs-next.is-live .cs-next__stage {
  position: sticky; top: 0; height: 100vh; height: 100svh; padding: 0; display: block; overflow: hidden;
}
.cs-next.is-live .cs-next__win { display: none; }
/* the copy of the next page: same tokens, same box as the screen, clipped by case.js (clip-path: path()) */
.cs-next.is-live .cs-next__page {
  display: block; position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none;
  background: var(--bg); color: var(--fg); text-align: start; clip-path: circle(0 at 50% 60%);
}
.cs-next.is-live .cs-next__edge {
  display: block; position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; overflow: visible; pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
.cs-next__edge path { fill: none; stroke: rgba(var(--accent-rgb), 0.9); stroke-width: 1.5; }
.cs-next.is-live .cs-next__head {
  position: absolute; left: 0; right: 0; top: clamp(92px, 14vh, 140px); z-index: 2; padding: 0 20px;
  opacity: calc(1 - 0.25 * var(--cs-k, 0)); transform: translateY(calc(-14px * var(--cs-k, 0)));
  transition: opacity 0.45s var(--ease), transform 0.6s var(--ease);
}
.cs-next.is-live .cs-next__foot {
  position: absolute; left: 0; right: 0; bottom: clamp(20px, 4vh, 40px); z-index: 2;
  width: min(var(--container), 100%); margin: 0 auto; padding: 0 var(--gutter, 20px);
  grid-template-columns: auto 1fr; align-items: center; justify-items: stretch; text-align: right;
  transition: opacity 0.4s var(--ease);
}
.cs-next.is-live .cs-next__hint { display: block; margin: 0; font-size: 0.9rem; opacity: 0.8; }
.cs-next.is-live .cs-next__track {
  display: block; grid-column: 1 / -1; height: 2px; border-radius: 2px; overflow: hidden; background: rgba(var(--accent-rgb), 0.28);
}
.cs-next__fill { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--cs-k, 0)); }
.cs-next.is-committed .cs-next__head { opacity: 0; transform: translateY(-16px); }
.cs-next.is-committed .cs-next__foot { opacity: 0; }
.cs-next.is-committed .cs-next__edge { opacity: 0; transition: none; }   /* gone at once: it would cross the opening page */

/* ---------- smaller screens ---------- */
@media (max-width: 900px) {
  .cs-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-intro { grid-template-columns: 1fr; }
  .cs-body__grid { grid-template-columns: 1fr; }
  .cs-index { display: none; }
  .cs-ch__text { display: grid; gap: 10px; margin-bottom: 22px; }
  .cs-ch__num { font-size: 0.8rem; color: var(--accent); font-variant-numeric: tabular-nums; }
  .cs-ch__text h2 { margin: 0; font-size: clamp(1.6rem, 5.5vw, 2.1rem); line-height: 1.15; font-weight: 500; letter-spacing: -0.02em; color: var(--ink); }
  .cs-ch__text p { margin: 0; color: var(--muted); }
  .cs-commit__list { grid-template-columns: 1fr; border-top: 0; }
  .cs-commit__list li, .cs-commit__list li + li { padding: 22px 0; border-left: 0; border-top: var(--cs-line); }
  .cs-next.is-live .cs-next__foot { grid-template-columns: 1fr; justify-items: center; text-align: center; }
}
@media (max-width: 560px) {
  .cs-pair { grid-template-columns: 1fr; }
  .cs-meta dd { flex-direction: column; }
  .cs-meta dd span + span::before { content: none; }
  .cs-panel { padding: 12px; }
  .cs-demo { padding: 20px; }
  .cs-demo__btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .cs-index__text, .cs-index__link, .cs-next__head, .cs-next__foot { transition: none; }
}
@media print {
  .cs-next, .cs-index { display: none !important; }
}
