/* ===================================================================
   Case studies v2 — shared base
   Each page sets --accent, --accent-2, --accent-soft and --display,
   and their light-mode versions under html[data-theme="light"].
   The Figma chrome (sidebar, rulers, cursor, toggle) is figma.css; the
   case-study side of it is the "Figma file" block at the end.
   =================================================================== */
:root {
  --bg: #0f0f11;
  --surface: #141418;
  --surface-2: #1b1b21;
  --line: rgba(255,255,255,.08);
  --line-2: rgba(255,255,255,.14);
  --text: #ececef;
  --muted: #9b9ba5;
  --dim: #6b6b75;
  --accent: #a78bfa;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(167,139,250,.12);
  --display: 'Outfit', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 20px;
  --bar-h: 60px;
  --on-accent: #0b0b0d;  /* text on an accent fill */
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--bar-h) + 24px); } /* in-page links scroll at a constant speed (nav.js) */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Outfit', system-ui, sans-serif; font-size: 17px; line-height: 1.65;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.08; letter-spacing: -.02em; margin: 0; font-weight: 700; }
p { margin: 0 0 1em; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.narrow { max-width: 760px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.mono { font-family: var(--mono); }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.lead { font-size: clamp(18px, 1.8vw, 21px); color: var(--muted); max-width: 62ch; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 200; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }

/* (The old top bar and chapter rail are gone: the Figma sidebar in figma.css does their job now.) */

/* ── Hero ── */
.cs-hero { padding: calc(var(--bar-h) + clamp(48px, 8vw, 96px)) 0 clamp(56px, 8vw, 96px); position: relative; overflow: hidden; }
.cs-hero h1 { font-size: clamp(44px, 7vw, 92px); line-height: .98; letter-spacing: -.035em; margin: 16px 0 24px; }
.cs-meta { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 20px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.cs-meta dt { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.cs-meta dd { margin: 0; font-weight: 500; }
@media (max-width: 720px) { .cs-meta { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.glow { position: absolute; width: 900px; height: 900px; border-radius: 50%; background: radial-gradient(circle, var(--accent-soft), transparent 62%); pointer-events: none; z-index: 0; }

/* ── Chapters ── */
.chapter { padding: clamp(72px, 10vw, 132px) 0; border-top: 1px solid var(--line); position: relative; }
.chapter-head { display: grid; gap: 14px; margin-bottom: clamp(32px, 5vw, 56px); max-width: 820px; }
.chapter-head h2 { font-size: clamp(32px, 4.6vw, 56px); }
.chapter-num { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.chapter-num b { color: var(--accent); font-weight: 500; }
.sub-head { font-size: clamp(22px, 2.4vw, 28px); margin: 56px 0 18px; }

/* ── Grids & cards ── */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
@media (max-width: 960px) { .g4, .g5 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; } }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 80px); align-items: center; }
.split.wide-left { grid-template-columns: 1.3fr .7fr; }
@media (max-width: 860px) { .split, .split.wide-left { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card h3 { font-size: 20px; margin: 10px 0 8px; letter-spacing: -.01em; }
.card p { color: var(--muted); font-size: 15.5px; margin: 0; }
.card .idx { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.card.accent-edge { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.stat b { display: block; font-family: var(--display); font-size: clamp(34px, 4vw, 48px); line-height: 1; letter-spacing: -.03em; color: var(--accent); }
.stat span { display: block; margin-top: 8px; color: var(--muted); font-size: 14px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.quote { font-family: var(--display); font-size: clamp(26px, 3.6vw, 44px); line-height: 1.15; letter-spacing: -.02em; max-width: 24ch; }
.quote::before { content: "“"; color: var(--accent); }
.quote::after { content: "”"; color: var(--accent); }
.callout { border-left: 3px solid var(--accent); padding: 6px 0 6px 20px; font-size: 19px; color: var(--text); max-width: 64ch; }
.callout small { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
ul.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
ul.ticks li { display: flex; gap: 10px; color: var(--muted); font-size: 15.5px; }
ul.ticks li::before { content: "→"; color: var(--accent); }

/* ── Devices ── */
.phone {
  --w: 260px; width: var(--w); aspect-ratio: 390 / 844; flex: none; position: relative;
  border-radius: calc(var(--w) * .16); padding: calc(var(--w) * .035); background: #0a0a0c;
  box-shadow: 0 0 0 1.5px #3a3a42, 0 0 0 4px #17171b, 0 40px 80px -30px rgba(0,0,0,.8);
}
.phone::before { /* dynamic island */
  content: ""; position: absolute; z-index: 2; top: calc(var(--w) * .045); left: 50%; translate: -50% 0;
  width: 30%; height: calc(var(--w) * .085); border-radius: 99px; background: #000;
}
.phone .screen { width: 100%; height: 100%; border-radius: calc(var(--w) * .125); overflow: hidden; background: #fff; }
.phone .screen img { width: 100%; height: auto; }
.phone.scrolls .screen { overflow-y: auto; scrollbar-width: none; }
.phone.scrolls .screen::-webkit-scrollbar { display: none; }
.phone.scrolls::after {
  content: "scroll ↕"; position: absolute; bottom: -30px; left: 50%; translate: -50% 0; font-family: var(--mono); font-size: 11px; color: var(--dim);
}
.shot { width: var(--w, 260px); flex: none; filter: drop-shadow(0 40px 60px rgba(0,0,0,.55)); }
.device-row { display: flex; gap: clamp(16px, 3vw, 36px); align-items: flex-end; justify-content: center; flex-wrap: wrap; }
.rail {
  display: flex; gap: 28px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px 16px 44px; margin-inline: -16px;
  scrollbar-width: thin; scrollbar-color: #333 transparent;
}
.rail > figure { scroll-snap-align: start; }
figure { margin: 0; }
figcaption { margin-top: 18px; font-size: 14px; color: var(--muted); max-width: var(--w, 260px); }
figcaption b { display: block; color: var(--text); font-weight: 600; font-size: 15px; }
figcaption .mono { color: var(--accent); font-size: 11px; }
.rail-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 48px 0 20px; }
.rail-head h3 { font-size: 24px; }
.rail-ctrl { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  display: grid; place-items: center; cursor: pointer; font-size: 18px;
}
.icon-btn:hover { border-color: var(--accent); }
[data-zoom] { cursor: zoom-in; }

/* ── Tabs / segmented ── */
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.seg button {
  font: inherit; font-size: 14px; color: var(--muted); background: transparent; border: 0; border-radius: 10px;
  min-height: 40px; padding: 0 14px; cursor: pointer; transition: background .2s, color .2s;
}
.seg button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
[role="tabpanel"][hidden] { display: none; }

/* ── Diagrams ── */
.diagram { width: 100%; height: auto; color: var(--text); overflow: visible; }
.diagram text { font-family: 'Outfit', system-ui, sans-serif; fill: currentColor; }
.diagram .t-muted { fill: var(--muted); }
.diagram .t-mono { font-family: var(--mono); letter-spacing: .08em; }
.diagram .t-accent { fill: var(--accent); }
.figure-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 3vw, 36px); }
.figure-card.light { background: #f6f6f8; color: #111; }
.figure-note { font-size: 14px; color: var(--muted); margin-top: 14px; }
.scroll-x { overflow-x: auto; scrollbar-width: thin; }
.scroll-x > svg, .scroll-x > table { min-width: 720px; }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 500; }
.table td:first-child { color: var(--text); font-weight: 500; }
.table td { color: var(--muted); }
.table .col-us { background: var(--accent-soft); color: var(--text); }
.yes { color: #34d399; } .no { color: #f87171; } .mid { color: #fbbf24; }

/* ── Swatches ── */
.swatch { border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.swatch i { display: block; height: 96px; }
.swatch div { padding: 12px 14px; font-size: 14px; }
.swatch code { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ── At a glance summary ── */
.glance { margin-top: -24px; position: relative; z-index: 2; }
.glance-card {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 0; border-radius: 24px; overflow: hidden;
  border: 1px solid var(--line-2); background: var(--surface);
}
.glance-main { padding: clamp(22px, 3vw, 36px); display: grid; gap: 14px; align-content: start; border-right: 1px solid var(--line); }
.glance-main p { margin: 0; font-size: clamp(18px, 1.7vw, 21px); line-height: 1.45; }
.glance-main .outcome { padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 16px; }
.glance-main .outcome b { color: var(--accent); }
.glance-facts { margin: 0; padding: clamp(22px, 3vw, 36px); display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; align-content: start; }
.glance-facts dt { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.glance-facts dd { margin: 0; font-size: 15.5px; }
.glance-facts .wide { grid-column: 1 / -1; }
.honest { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--muted); }
.honest::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
@media (max-width: 820px) { .glance-card { grid-template-columns: 1fr; } .glance-main { border-right: 0; border-bottom: 1px solid var(--line); } }

/* ── Artefact slots: visible on localhost only, removed in production ── */
.slot { display: none; }
.show-slots .slot {
  display: grid; gap: 6px; place-content: center; text-align: center; min-height: 180px; padding: 24px;
  border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, transparent 0 12px, rgba(255,255,255,.015) 12px 24px);
  color: var(--muted); font-size: 15px;
}
.show-slots .slot b { color: var(--text); font-size: 16px; }
.show-slots .slot code { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.show-slots .slot::before { content: "ADD YOUR ARTEFACT · LOCAL PREVIEW ONLY"; font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; color: var(--accent); }

/* ── Illustration frames ── */
.illo { border-radius: var(--radius); overflow: hidden; }
.illo svg { display: block; width: 100%; height: auto; }
.illo-cap { font-size: 14px; color: var(--muted); margin-top: 12px; max-width: 70ch !important; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.steps figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.steps figcaption { margin: 0; padding: 16px 18px 20px; max-width: none; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }

/* ── Pager: previous / next case study ── */
.cs-pager { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.cs-pager a { display: grid; gap: 6px; padding: clamp(40px, 7vw, 88px) clamp(20px, 4vw, 56px); text-decoration: none; transition: background .3s; }
.cs-pager a + a { border-left: 1px solid var(--line); text-align: right; }
.cs-pager a:hover { background: var(--surface); }
.cs-pager .kicker { color: var(--muted); }
.cs-pager b { font-family: var(--display); font-size: clamp(28px, 4.4vw, 64px); line-height: 1; letter-spacing: -.03em; transition: color .3s; }
.cs-pager a:hover b { color: var(--to); }
@media (max-width: 640px) { .cs-pager { grid-template-columns: 1fr; } .cs-pager a + a { border-left: 0; border-top: 1px solid var(--line); text-align: left; } }

/* ── Next project ── */
.cs-next { display: block; text-decoration: none; padding: clamp(64px, 10vw, 120px) 0; border-top: 1px solid var(--line); text-align: center; }
.cs-next .kicker { color: var(--muted); }
.cs-next h2 { font-size: clamp(48px, 9vw, 120px); letter-spacing: -.045em; margin-top: 12px; transition: color .3s; }
.cs-next:hover h2 { color: var(--next, var(--accent)); }
.cs-foot { padding: 28px 0 40px; border-top: 1px solid var(--line); color: var(--dim); font-size: 14px; }
.cs-foot .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ── Lightbox ── */
.cs-lightbox { border: 0; padding: 0; background: transparent; max-width: 94vw; max-height: 92vh; overflow: visible; }
.cs-lightbox::backdrop { background: rgba(0,0,0,.9); backdrop-filter: blur(8px); }
.cs-lightbox img { max-width: 94vw; max-height: 88vh; width: auto; border-radius: 12px; }
.cs-lightbox .icon-btn { position: fixed; top: 16px; right: 16px; }

/* ── Draw: diagrams draw their strokes when they scroll into view (reveal.js adds .in; the fade-in for everything else is .reveal in figma.css) ── */
.draw path, .draw line, .draw circle, .draw polyline { stroke-dasharray: var(--len, 1200); stroke-dashoffset: var(--len, 1200); transition: stroke-dashoffset 1.8s cubic-bezier(.4,0,.2,1); }
.draw.in path, .draw.in line, .draw.in circle, .draw.in polyline { stroke-dashoffset: 0; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ===================================================================
   Figma file — each case study is a Page in Ajeet's Figma file, the
   same file as the homepage. figma.css gives the sidebar (Pages are
   the portfolio and the four case studies; Layers are this page's
   chapters as frames), the rulers, the cursor and the top-right
   cluster. Here: the canvas grid on the cover, frame names above the
   chapters, selection outlines on hover, and the progress line.
   =================================================================== */
/* the rulers sit over the left edge from 768px: keep content clear of them */
@media (min-width: 768px) { .wrap { width: min(1180px, 100% - 88px); } }

/* the whole page is the canvas: 2px squares every 24px (a softer --grid-soft, for reading over), and on the
   cover they light up purple around the cursor (case.js sets --mx/--my). The page grid starts at the window's
   corner and the cover at the sidebar's edge (264px, a multiple of 24), so the lit squares land on the dots. */
body { background-image: conic-gradient(from 270deg at 2px 2px, var(--grid-soft) 90deg, transparent 0); background-size: 24px 24px; }
.cs-hero { --mx: -999px; --my: -999px; }
.cs-spot { position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: conic-gradient(from 270deg at 2px 2px, var(--grid-lit) 90deg, transparent 0); background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(circle 200px at var(--mx) var(--my), #000, transparent 75%); mask-image: radial-gradient(circle 200px at var(--mx) var(--my), #000, transparent 75%);
}
.cs-hero > .wrap { position: relative; z-index: 1; }
@media (hover: none) { .cs-spot { display: none; } }

/* frame names, like Figma's, at the top left of each frame */
.cs-frame-name {
  position: absolute; z-index: 2; top: 18px; left: max(16px, calc((100% - 1180px) / 2));
  display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 'Outfit', sans-serif; color: var(--dim); letter-spacing: 0; transition: color .15s;
}
.cs-frame-name svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.cs-hero .cs-frame-name { top: calc(var(--bar-h) + 6px); }
@media (min-width: 768px) { .cs-frame-name { left: max(44px, calc((100% - 1180px) / 2)); } .cs-hero .cs-frame-name { top: 34px; } }
.chapter:hover > .cs-frame-name, .cs-hero:hover > .cs-frame-name { color: var(--brand); }

/* hover a block for Figma's selection outline (and its band on the rulers) */
@media (hover: hover) and (min-width: 768px) {
  .card, .figure-card, .illo, .swatch, .glance-card, .steps figure, .shot, .phone { transition: outline-color .15s; outline: 1.5px solid transparent; outline-offset: 5px; }
  .card:hover, .figure-card:hover, .illo:hover, .swatch:hover, .glance-card:hover, .steps figure:hover, .shot:hover, .phone:hover { outline-color: var(--brand); }
}

/* reading progress: a purple line along the bottom of the top ruler */
.cs-progress { position: fixed; z-index: 57; top: 0; left: var(--sb-w); right: 0; height: 2px; background: var(--brand); transform-origin: left; transform: scaleX(0); pointer-events: none; }
@media (min-width: 768px) { .cs-progress { top: 18px; left: calc(var(--sb-w) + 20px); } }

/* Back, first in the top-right cluster (case.js): to the portfolio */
.fn-back {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 8px; border-radius: 9px; text-decoration: none;
  color: #e4e4e7; font: 600 13px/1 'Outfit', sans-serif; transition: background .2s, color .2s;
}
.fn-back svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.fn-back:hover { background: rgba(255,255,255,.08); color: #fff; }
.fn-back:hover svg { transform: translateX(-2px); }
.fn-back:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
html[data-theme="light"] .fn-back { color: #27272a; }
html[data-theme="light"] .fn-back:hover { background: rgba(0,0,0,.05); color: #18181b; }
/* phones: Back is just its arrow, the avatar steps aside, and the file pill leaves room */
@media (max-width: 480px) {
  .fn-back { padding: 0 8px; }
  .fn-back span { display: none; }
  .fn-share .fn-avatar { display: none; }
}

/* Layers rows for frames with no layers inside: a gap where the caret would be */
.fn-caret-gap { flex: none; width: 22px; }
.fn-page[aria-current="page"] { font-weight: 600; }

/* ===================================================================
   Light mode (html[data-theme="light"], toggled in the sidebar's
   top-right cluster). Tokens first; each page also sets light versions
   of its own accents, dark enough for text on the light page.
   Artwork (phones, the Spacture simulation) stays as designed.
   =================================================================== */
html[data-theme="light"] {
  --bg: #f5f5f5; --surface: #ffffff; --surface-2: #efeff2;
  --line: rgba(0,0,0,.09); --line-2: rgba(0,0,0,.15);
  --text: #18181b; --muted: #4f4f59; --dim: #6b6b76;
  --accent: var(--brand); --accent-2: var(--brand-deep); --accent-soft: rgba(var(--brand-rgb), .1);
  --on-accent: #ffffff;
}
html[data-theme="light"] .yes { color: #047857; }
html[data-theme="light"] .no { color: #c81e1e; }
html[data-theme="light"] .mid { color: #a35a00; }
html[data-theme="light"] .card, html[data-theme="light"] .figure-card, html[data-theme="light"] .glance-card, html[data-theme="light"] .steps figure { box-shadow: 0 1px 2px rgba(0,0,0,.04); }
html[data-theme="light"] .shot { filter: drop-shadow(0 30px 40px rgba(0,0,0,.18)); }
html[data-theme="light"] .phone { box-shadow: 0 0 0 1.5px #3a3a42, 0 0 0 4px #d4d4da, 0 40px 80px -36px rgba(0,0,0,.45); }
html[data-theme="light"] .rail { scrollbar-color: #c4c4cc transparent; }
html[data-theme="light"] .show-slots .slot { background: repeating-linear-gradient(45deg, transparent 0 12px, rgba(0,0,0,.025) 12px 24px); }
html[data-theme="light"] .cs-lightbox::backdrop { background: rgba(245,245,245,.92); }
html[data-theme="light"] .cs-pager a:hover { background: #fff; }
/* keep dark artwork dark: the original tokens inside it */
html[data-theme="light"] .keep-dark {
  --surface: #141418; --surface-2: #1b1b21; --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
  --text: #ececef; --muted: #9b9ba5; --dim: #6b6b75; color: var(--text);
}