/* ═══════════════════════════════════════════════════════════════
   CASE STUDY — "Research Dossier" editorial system
   A warm, high-contrast, print-inspired layout for the case studies.
   Light paper (not generic dark), the site's own Clash Display type, a sticky
   index, and deliberate hierarchy so a recruiter's eye lands in order:
   eyebrow → title → thesis → at-a-glance → the depth.

   Per-study accent is set by a body class (.cs-trust / .cs-alert /
   .cs-water). Everything below re-themes the shared palette variables so
   the page-scoped component styles inherit the light treatment for free.
═══════════════════════════════════════════════════════════════ */

body.case-study {
  /* Re-theme the shared palette to warm light editorial values. Every
     var()-based component (metric cards, bars, tables) follows automatically. */
  --cs-accent: #c0563a;
  --cs-accent-soft: color-mix(in srgb, var(--cs-accent) 14%, transparent);
  --paper: #f5f0e4;
  --paper-2: #efe8d8;
  --card: #fffdf7;
  --ink: #20242e;
  --ink-2: #474e5c;

  --bg: var(--paper);
  --bg-2: var(--paper-2);
  --text: var(--ink);
  --muted: #4b5261;
  --soft: #737b8a;
  --line: rgba(28, 32, 42, 0.12);
  --line-strong: rgba(28, 32, 42, 0.22);
  --tint: var(--cs-accent);
  --gold-2: var(--cs-accent);

  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255, 252, 244, 0.9), transparent 55%),
    linear-gradient(180deg, var(--paper), var(--paper-2));
  color: var(--ink);
  font-family: var(--sans);
}

body.cs-trust  { --cs-accent: #3b4bb0; }  /* indigo — rigor */
body.cs-alert  { --cs-accent: #c0563a; }  /* ember — urgency */
body.cs-water  { --cs-accent: #1893a1; }  /* teal — civic */

/* ── Navbar on light paper ─────────────────────────────────────── */
body.case-study .site-nav {
  background: rgba(255, 253, 247, 0.72);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid rgba(28, 32, 42, 0.1);
}
body.case-study .site-nav a { color: rgba(28, 32, 42, 0.6); }
body.case-study .site-nav a:hover,
body.case-study .site-nav a.active { color: var(--ink); }
body.case-study .scroll-progress { background: var(--cs-accent); }

/* ── Masthead (hero) ───────────────────────────────────────────── */
body.case-study .section { padding: clamp(96px, 15vh, 168px) 0 clamp(20px, 4vh, 44px); }
body.case-study .section-head {
  max-width: 1180px;
  gap: 0;
}

body.case-study .eyebrow {
  color: var(--cs-accent);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  margin-bottom: clamp(20px, 3vh, 32px);
}
body.case-study .eyebrow::before {
  background: var(--cs-accent);
  width: 34px;
  opacity: 0.6;
}

/* Big high-contrast display title — same family as the main page */
body.case-study .page-title {
  font-family: "Clash Display", var(--display);
  font-weight: 700;
  font-size: clamp(2.8rem, 8vw, 6.4rem);
  line-height: 0.98;
  letter-spacing: -0.015em;
  word-spacing: 0;
  color: var(--ink);
  max-width: 18ch;
}

/* Thesis line — the second thing the eye reads */
body.case-study .hero-sub {
  margin: clamp(24px, 3.5vh, 40px) 0 0;
  max-width: 60ch;
  font-size: clamp(1.1rem, 1.7vw, 1.5rem);
  line-height: 1.5;
  color: var(--ink-2);
  font-weight: 400;
}

/* Fact bar — paper metadata block under a hairline */
body.case-study .pill-row {
  margin-top: clamp(30px, 4.5vh, 52px);
  padding-top: clamp(18px, 2.5vh, 26px);
  border-top: 1px solid var(--line-strong);
  gap: clamp(20px, 3vw, 48px);
}
body.case-study .section-head .pill {
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
body.case-study .section-head .pill strong {
  display: block;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cs-accent);
  margin-bottom: 4px;
}

/* ── Body layout: sticky index + reading column ────────────────── */
body.case-study .section-tight { padding: clamp(24px, 4vh, 48px) 0 0; }
body.case-study .case-layout {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
  max-width: 1180px;
}

/* Numbered index — reads like a paper's table of contents */
body.case-study .case-toc {
  position: sticky;
  top: calc(var(--header-h) + 28px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  counter-reset: toc;
  border-left: 1px solid var(--line);
}
body.case-study .case-toc a {
  counter-increment: toc;
  position: relative;
  padding: 9px 0 9px 20px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--soft);
  transition: color 0.2s ease, border-color 0.2s ease;
}
body.case-study .case-toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.62rem;
  color: var(--cs-accent);
  opacity: 0.55;
  margin-right: 8px;
}
body.case-study .case-toc a:hover {
  color: var(--ink);
  border-left-color: var(--cs-accent);
}

/* ── Section cards ─────────────────────────────────────────────── */
body.case-study .resume-stack {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3vh, 32px);
  counter-reset: casesec;
  max-width: 760px;
}
body.case-study .case-card {
  counter-increment: casesec;
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(28px, 4vw, 48px);
  box-shadow: 0 1px 2px rgba(28, 32, 42, 0.04), 0 20px 40px -32px rgba(28, 32, 42, 0.5);
  scroll-margin-top: calc(var(--header-h) + 24px);
}
/* Faint marginal section number — editorial texture */
body.case-study .case-card::before {
  content: counter(casesec, decimal-leading-zero);
  position: absolute;
  top: clamp(20px, 3vw, 34px);
  right: clamp(22px, 3.5vw, 40px);
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  line-height: 1;
  color: var(--cs-accent-soft);
  pointer-events: none;
}

body.case-study .kicker {
  color: var(--cs-accent);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  margin-bottom: 14px;
}
body.case-study .kicker::before { background: var(--cs-accent); opacity: 0.5; }

body.case-study .section-display {
  font-family: "Clash Display", var(--display);
  font-weight: 600;
  font-size: clamp(1.5rem, 2.8vw, 2.3rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  word-spacing: 0;
  color: var(--ink);
  max-width: 20ch;
  margin: 0 0 16px;
}

body.case-study .case-card p {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-2);
  max-width: 64ch;
}
body.case-study .case-card p + p { margin-top: 14px; }

body.case-study .case-card ul {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
  max-width: 64ch;
}
body.case-study .case-card ul li {
  position: relative;
  padding-left: 26px;
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--ink-2);
}
body.case-study .case-card ul li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--cs-accent);
  transform: rotate(45deg);
}
body.case-study .case-card ul li strong { color: var(--ink); font-weight: 700; }

/* ── Stat / metric cards ───────────────────────────────────────── */
body.case-study .case-stats,
body.case-study .cs-tldr {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 26px;
}
body.case-study .metric-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
body.case-study .metric-card strong {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cs-accent);
  margin-bottom: 8px;
}
body.case-study .metric-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-2);
}
@media (max-width: 760px) {
  body.case-study .case-stats,
  body.case-study .cs-tldr { grid-template-columns: 1fr; }
}

/* Pills inside cards (tag rows) */
body.case-study .case-card .pill-row { margin-top: 22px; border: none; padding: 0; gap: 8px; }
body.case-study .case-card .pill {
  background: var(--cs-accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 0.78rem;
  color: var(--cs-accent);
  font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────────────── */
body.case-study .btn { border-radius: 999px; font-weight: 600; }
body.case-study .btn-primary {
  background: var(--cs-accent);
  color: #fff;
  box-shadow: 0 14px 28px -14px var(--cs-accent);
}
body.case-study .btn-primary:hover { filter: brightness(1.06); transform: translateY(-2px); }
body.case-study .btn-secondary {
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}
body.case-study .btn-secondary:hover { border-color: var(--cs-accent); color: var(--cs-accent); }
body.case-study .btn-row { margin-top: 26px; gap: 12px; }

/* ── Footer ────────────────────────────────────────────────────── */
body.case-study .footer {
  background: none;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
}
body.case-study .footer-links a { color: var(--muted); }
body.case-study .footer-links a:hover { color: var(--cs-accent); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 860px) {
  body.case-study .case-layout { grid-template-columns: 1fr; gap: 28px; }
  body.case-study .case-toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 18px;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
  }
  body.case-study .case-toc a { padding: 4px 0; border-left: 0; }
  body.case-study .resume-stack { max-width: none; }
}
