/* =========================================================
   Case study pages — builds on styles.css (tokens, header,
   buttons, footer). Poppins only. Light + dark.
   ========================================================= */

.case-page { --tint: var(--tint-oracle); --tag: var(--tag-oracle); }

/* ---------- Hero ---------- */
.cs-hero { position: relative; padding-top: calc(var(--nav-h) + clamp(32px, 6vh, 72px)); }
.cs-back {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 28px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: color .3s, gap .4s var(--ease);
}
.cs-back:hover { color: var(--ink); gap: 12px; }
.cs-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 18px; }
.pill-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500; line-height: 1.2;
  background: color-mix(in srgb, var(--tag) 12%, transparent); color: var(--tag);
}
.pill-tag--ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
/* Hero grid: text left, image right; both vertically centred so they line up */
.cs-hero__grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center; gap: clamp(32px, 5vw, 80px);
}
.cs-title { margin: 0; font-weight: 600; letter-spacing: -.04em; line-height: 1.06; font-size: clamp(34px, 4.1vw, 60px); }
.cs-title .accent { color: var(--tag); }
.cs-skills { margin: 24px 0 0 !important; }
.cs-lead { margin: 20px 0 0; max-width: 44ch; font-size: clamp(17px, 1.6vw, 21px); line-height: 1.6; font-weight: 300; color: var(--ink-2); }

.cs-meta { margin: clamp(40px, 5vw, 64px) 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.cs-meta div { padding: 20px 20px 0 0; }
.cs-meta div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.cs-meta dt { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.cs-meta dd { margin: 0; font-weight: 500; font-size: 15px; line-height: 1.45; }

.cs-hero__media {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 11;
  border-radius: var(--radius-lg); background: var(--tint); border: 1px solid color-mix(in srgb, var(--tag) 22%, transparent);
  padding: clamp(16px, 3vw, 40px); overflow: hidden; box-shadow: var(--shadow);
}
.cs-hero__media::before {
  content: ""; position: absolute; width: 60%; aspect-ratio: 1; left: 20%; top: 18%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tag) 22%, transparent), transparent);
  filter: blur(20px); pointer-events: none;
}
.cs-hero__media img { position: relative; width: 100%; max-width: 1100px; margin: 0 auto; filter: drop-shadow(0 40px 50px rgba(0,0,0,.18)); }

/* ---------- Layout with sticky contents ---------- */
.cs-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: clamp(32px, 5vw, 80px); padding-top: clamp(64px, 9vw, 120px); }
.toc { position: sticky; top: calc(var(--nav-h) + 32px); align-self: start; }
.toc p { margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a {
  position: relative; display: block; padding: 7px 0 7px 16px; font-size: 14px; color: var(--muted);
  transition: color .3s, padding-left .4s var(--ease);
}
.toc a::before { content: ""; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 2px; background: var(--tag); transform: scaleY(0); transition: transform .4s var(--ease); }
.toc a:hover { color: var(--ink); }
.toc a.is-active { color: var(--ink); font-weight: 500; padding-left: 20px; }
.toc a.is-active::before { transform: scaleY(1); }

.cs-content { min-width: 0; }

/* ---------- Sections ---------- */
.cs-section { padding-block: clamp(48px, 7vw, 96px); border-top: 1px solid var(--line); scroll-margin-top: calc(var(--nav-h) + 16px); }
.cs-section:first-child { border-top: 0; padding-top: 0; }
.cs-section__num { display: inline-block; font-size: 13px; font-weight: 600; color: var(--tag); margin-bottom: 8px; letter-spacing: .04em; }
.cs-h2 { margin: 0 0 20px; font-weight: 600; letter-spacing: -.035em; line-height: 1.08; font-size: clamp(30px, 4vw, 52px); }
.cs-h3 { margin: 0 0 12px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; font-size: clamp(20px, 2vw, 26px); }
.cs-h4 { margin: 0 0 8px; font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.cs-sub { margin-top: clamp(40px, 5vw, 64px); }
.cs-content p { margin: 0 0 16px; font-size: 17px; line-height: 1.75; color: var(--ink-2); max-width: 68ch; }
.cs-content p.lede { font-size: clamp(18px, 1.7vw, 21px); line-height: 1.65; color: var(--ink); font-weight: 400; }
.cs-content strong { color: var(--ink); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.card {
  position: relative; padding: clamp(20px, 2.4vw, 30px); border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--line);
  transition: box-shadow .5s var(--ease), border-color .4s;
}
.card:hover { box-shadow: 0 24px 40px -28px rgba(0,0,0,.35); border-color: color-mix(in srgb, var(--tag) 30%, transparent); }
.card p { font-size: 15.5px; line-height: 1.7; margin-bottom: 0; }
.card__label { display: block; margin-bottom: 10px; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--tag); }
.card--tint { background: var(--tint); border-color: color-mix(in srgb, var(--tag) 18%, transparent); }

.ticks { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.ticks li { position: relative; padding-left: 30px; font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.ticks li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: color-mix(in srgb, var(--tag) 14%, transparent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12 4 4 8-8' fill='none' stroke='%23B5462A' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
[data-theme="dark"] .ticks li::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12 4 4 8-8' fill='none' stroke='%23FF9E80' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* Outcome stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.stat {
  padding: 24px; border-radius: var(--radius-md); background: var(--tint);
  border: 1px solid color-mix(in srgb, var(--tag) 18%, transparent);
  display: grid; align-content: space-between; gap: 18px; min-height: 180px;
}
.stat__num { white-space: nowrap; font-size: clamp(28px, 2.7vw, 42px); font-weight: 600; letter-spacing: -.04em; line-height: 1; color: var(--tag); }
.stat__num small { font-size: .5em; font-weight: 500; }
.stat__label { font-size: 14.5px; line-height: 1.45; color: var(--ink); font-weight: 500; }
.stat-note { margin-top: 16px !important; font-size: 14px !important; color: var(--muted) !important; display: flex; gap: 8px; align-items: center; }

/* Numbered list cards */
.num-list { list-style: none; margin: 24px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; counter-reset: n; }
.num-list li { counter-increment: n; position: relative; padding: 22px 22px 22px 70px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.num-list li::before { content: counter(n, decimal-leading-zero); position: absolute; left: 22px; top: 20px; font-weight: 600; font-size: 18px; color: var(--tag); }

/* Engagement funnel */
.funnel { display: grid; gap: 12px; margin: 28px 0; }
.funnel__step {
  position: relative; display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: start;
  padding: 22px 24px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line);
  width: var(--w, 100%); transition: transform .5s var(--ease);
}
.funnel__step h4 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.funnel__step h4 span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.funnel__step p { margin: 0 !important; font-size: 15px !important; line-height: 1.65 !important; }
.funnel__step.is-focus { background: var(--tint); border-color: var(--tag); box-shadow: 0 20px 40px -30px color-mix(in srgb, var(--tag) 80%, transparent); }
.funnel__badge { position: absolute; top: -11px; right: 18px; padding: 3px 12px; border-radius: 999px; background: var(--tag); color: var(--bg); font-size: 12px; font-weight: 600; }

/* Design process stepper */
.stepper { position: relative; list-style: none; margin: 36px 0 8px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
/* ::before = grey track, ::after = coloured fill that grows with scroll (--p set by case.js) */
.stepper::before, .stepper::after { content: ""; position: absolute; left: 10%; right: 10%; top: 31px; height: 2px; background: var(--line); }
.stepper::after { background: var(--tag); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
.stepper li { position: relative; display: grid; justify-items: center; align-content: start; text-align: center; gap: 12px; }
.stepper__dot {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  transition: background-color .5s var(--ease), color .5s, border-color .5s, transform .5s var(--ease);
}
.stepper li.is-on .stepper__dot { background: var(--tag); color: var(--bg); border-color: var(--tag); transform: scale(1.06); }
.stepper__dot svg { width: 26px; height: 26px; }
.stepper strong { font-size: 15px; font-weight: 600; }
.stepper span { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* Stage timeline (Discover → Take action) */
.stages { list-style: none; margin: 24px 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; counter-reset: s; }
.stages li { counter-increment: s; position: relative; padding: 20px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); }
.stages li::after { content: "→"; position: absolute; right: -12px; top: 50%; transform: translate(50%, -50%); color: var(--muted); font-size: 16px; z-index: 1; }
.stages li:last-child::after { display: none; }
.stages strong { display: block; font-size: 16px; margin-bottom: 6px; }
.stages strong::before { content: counter(s) ". "; color: var(--tag); }
.stages span { font-size: 14px; line-height: 1.5; color: var(--ink-2); }

/* Quote */
.pull {
  margin: 28px 0; padding: clamp(24px, 3vw, 36px); border-radius: var(--radius-md);
  background: var(--tint); border-left: 4px solid var(--tag);
}
.pull p { margin: 0 0 10px !important; font-size: clamp(18px, 1.8vw, 22px) !important; line-height: 1.55 !important; color: var(--ink) !important; font-style: italic; }
.pull p:last-child { margin-bottom: 0 !important; }

/* Figures, frames, lightbox triggers */
.fig { margin: 28px 0; }
.fig__frame {
  position: relative; display: block; width: 100%; padding: 0; border: 1px solid var(--line); cursor: zoom-in;
  border-radius: var(--radius-md); overflow: hidden; background: var(--surface);
  font: inherit; color: inherit; text-align: left;
}
.fig__frame img { width: 100%; transition: transform 1s var(--ease); }
.fig__frame:hover img { transform: scale(1.02); }
.fig__frame--pad { padding: clamp(12px, 2vw, 24px); background: var(--surface); }
.fig__frame--white { background: #fff; }
.fig__zoom {
  position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(20,20,20,.6); color: #fff;
  opacity: 0; transform: scale(.8); transition: opacity .3s, transform .4s var(--ease);
}
.fig__frame:hover .fig__zoom, .fig__frame:focus-visible .fig__zoom { opacity: 1; transform: none; }
@media (hover: none) { .fig__zoom { opacity: 1; transform: none; } }
.fig figcaption { margin-top: 12px; font-size: 14px; color: var(--muted); line-height: 1.5; }

/* Browser frame for videos */
.browser { border-radius: var(--radius-md); overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.browser__bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
.browser__bar i { width: 10px; height: 10px; border-radius: 50%; background: #FF5F57; }
.browser__bar i:nth-child(2) { background: #FEBC2E; }
.browser__bar i:nth-child(3) { background: #28C840; }
.browser__bar span { margin-left: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser video { width: 100%; display: block; background: #000; }
.browser--play { position: relative; }
.play-btn {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 2;
  display: inline-flex; align-items: center; gap: 10px; padding: 16px 26px 16px 20px; border: 0; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 15px;
  box-shadow: 0 20px 40px -16px rgba(0,0,0,.5); transition: transform .4s var(--ease), opacity .3s;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn span.ring { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--tag); color: #fff; }
.browser--play.is-playing .play-btn { opacity: 0; pointer-events: none; }

/* Explorations */
.explore { padding: clamp(24px, 3vw, 40px); border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); margin-top: 24px; }
.explore__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.explore__head .cs-h3 { margin: 0; flex: 1 1 320px; }
.status { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.status--go { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.explore p { font-size: 16px !important; }
.explore .fig { margin-bottom: 18px; }

/* Brainstorm gallery (drag / swipe) */
.gallery { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 12px; margin: 24px 0; cursor: grab; scrollbar-width: thin; }
.gallery.is-drag { cursor: grabbing; scroll-snap-type: none; }
.gallery .fig { flex: 0 0 min(320px, 72%); margin: 0; scroll-snap-align: start; }
.gallery img { aspect-ratio: 3 / 4; object-fit: cover; pointer-events: none; }

/* Next project */
.next {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 24px;
  padding: clamp(28px, 4vw, 56px); border-radius: var(--radius-lg); margin-top: clamp(48px, 6vw, 80px);
  background: var(--tint-deloitte); border: 1px solid color-mix(in srgb, var(--tag-deloitte) 20%, transparent);
  transition: transform .6s var(--ease);
}
.next:hover { transform: translateY(-4px); }
.next small { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.next strong { font-size: clamp(28px, 4vw, 48px); font-weight: 600; letter-spacing: -.035em; line-height: 1.1; }
.next__arrow { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); transition: transform .5s var(--ease); }
.next:hover .next__arrow { transform: rotate(-45deg); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px; background: rgba(10,10,10,.88); opacity: 0; pointer-events: none; transition: opacity .35s var(--ease); }
.lightbox.is-open { opacity: 1; pointer-events: auto; }
.lightbox img { max-width: min(1600px, 100%); max-height: calc(100vh - 120px); width: auto; border-radius: 12px; background: #fff; transform: scale(.96); transition: transform .45s var(--ease); }
.lightbox.is-open img { transform: none; }
.lightbox__close { position: absolute; top: 16px; right: 16px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: #fff; color: #111; font-size: 22px; line-height: 1; }
.lightbox__cap { position: absolute; bottom: 18px; left: 24px; right: 24px; text-align: center; color: #ddd; font-size: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .cs-hero__grid { grid-template-columns: 1fr; }
  .cs-lead { max-width: 56ch; }
  /* Image sits below the title here: the title flows as normal text, balanced over
     at most 2 lines. --title-em is the title's full width in em (measured per page);
     the size is set so that width fits in two lines with ~15% slack, capped at 56px. */
  .cs-title {
    font-size: min(56px, calc((100vw - 2 * var(--gutter)) * 2 / (var(--title-em, 25) * 1.15)));
    text-wrap: balance;
  }
  .cs-title .line, .cs-title .line__inner { display: inline; }
}
.case-page { --title-em: 21.85; }              /* Oracle */
.case-page--deloitte { --title-em: 27.33; }
.case-page--arborloop { --title-em: 24.83; }
.case-page--opal { --title-em: 25.11; }
@media (max-width: 1100px) {
  .cs-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .cs-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-meta div:nth-child(3) { padding-left: 0; border-left: 0; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stages li:nth-child(2)::after { display: none; }
  .stepper { grid-template-columns: repeat(5, minmax(110px, 1fr)); overflow-x: auto; padding-bottom: 8px; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .num-list { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { min-height: 150px; padding: 18px; }
  .funnel__step { grid-template-columns: 1fr; gap: 8px; width: 100% !important; }
  .stages { grid-template-columns: 1fr; }
  .stages li::after { display: none; }
  /* Phone: vertical timeline, line fills downward */
  .stepper { grid-template-columns: 1fr; gap: 14px; overflow: visible; padding: 0; }
  .stepper li { grid-template-columns: 52px 1fr; grid-template-rows: auto auto; justify-items: start; text-align: left; column-gap: 16px; row-gap: 2px; align-content: center; }
  .stepper__dot { grid-row: 1 / span 2; width: 52px; height: 52px; }
  .stepper__dot svg { width: 22px; height: 22px; }
  .stepper strong { align-self: end; }
  .stepper span:not(.stepper__dot) { align-self: start; }
  .stepper::before, .stepper::after { left: 25px; right: auto; top: 26px; bottom: 26px; width: 2px; height: auto; }
  .stepper::after { transform-origin: 50% 0; transform: scaleY(var(--p, 0)); }
  .cs-meta div { padding-right: 12px; }
  .cs-meta div + div { padding-left: 12px; }
  .next { grid-template-columns: 1fr; }
  .next__arrow { width: 52px; height: 52px; }
  .play-btn { padding: 12px 18px 12px 14px; font-size: 14px; }
  .explore { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .stepper { --p: 1; }
  .stepper li .stepper__dot { background: var(--tag); color: var(--bg); border-color: var(--tag); }
}
