/* =====================================================================
   case-study.css: shared by every case study (work/<project>/index.html)
   Structure: intro + panel → at a glance → hero image → index →
   sections (sticky label | content) → next project.
   ===================================================================== */

/* ---------- Intro: text on the left, dithered panel on the right ---------- */
.cs-hero { padding: clamp(48px, 9vh, 112px) var(--gutter) 48px; }
.intro { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 32px clamp(24px, 4vw, 64px); align-items: stretch; }
.kicker { color: var(--muted); }
h1 { font-size: clamp(44px, 8vw, 104px); font-weight: 500; line-height: 1; letter-spacing: -.03em; margin-top: 16px; }
/* Same terminal cursor the project card shows on hover in the homepage: blinks a few times, then rests */
h1::after { content: "_"; color: var(--accent-text); opacity: 0; animation: blink 1s steps(1) 4 .6s; }
.sub { font-size: var(--fs-xl); line-height: 1.3; margin-top: 16px; }
.lead { margin-top: 16px; max-width: 60ch; color: var(--muted); }

/* The panel is the SAME on every case study (the homepage "flow").
   Per project only data changes: data-seed picks a region of the noise, .tag lists a few facts. */
.panel { position: relative; min-height: 240px; background: var(--dither-back); overflow: hidden; }
.panel canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tag { position: absolute; left: 12px; bottom: 12px; font-size: 12px; line-height: 1; padding: 4px 6px; background: var(--fg); color: var(--bg); white-space: nowrap; }
.tag b { font-weight: 500; background: var(--accent); color: #000; padding: 2px 4px; margin-right: 6px; }

/* ---------- At a glance: everything a recruiter needs in ~30 seconds ---------- */
.glance {
  margin-top: 48px; display: grid; gap: 24px 48px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  border-top: 1px solid var(--line); padding-top: 24px;
}
.glance dt, .facts dt { color: var(--muted); font-size: var(--fs-s); text-transform: uppercase; letter-spacing: .04em; }
.glance dd { margin-top: 4px; }
.glance .outcome { grid-column: 1 / -1; }
.glance .outcome dd { font-size: var(--fs-l); max-width: 70ch; display: flex; gap: 12px; align-items: baseline; }
.glance .outcome .dot { transform: translateY(-2px); }
.hero-actions { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.hero-fig { margin: 0 var(--gutter); }

/* ---------- Figures: small technical index "fig.01" before each image caption ---------- */
figure figcaption { margin-top: 10px; font-size: var(--fs-s); color: var(--muted); }
main { counter-reset: fig; }
figure:has(> img) { counter-increment: fig; }
figure:has(> img) figcaption::before { content: "fig." counter(fig, decimal-leading-zero); color: var(--accent-text); margin-right: 1.5ch; }

/* ---------- Section index ---------- */
.toc { padding: 32px var(--gutter); border-top: 1px solid var(--line); margin-top: 64px; }
.toc ol { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 28px; }
.toc .n { color: var(--muted); margin-right: 6px; }

/* ---------- Sections: sticky label | content ---------- */
.cs {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px clamp(24px, 4vw, 64px);
  padding: clamp(72px, 12vh, 128px) var(--gutter);
  border-top: 1px solid var(--line);
}
.cs-label { position: sticky; top: 80px; align-self: start; }
.cs-label .n { color: var(--accent-text); display: block; font-size: var(--fs-s); margin-bottom: 6px; }
.cs-label h2 { font-size: var(--fs-xl); font-weight: 500; line-height: 1.2; letter-spacing: -.01em; }

/* Body copy is one step quieter than headings and ledes: emphasis comes from contrast, not only weight */
.cs-body { color: var(--fg-2); }
.cs-body > * + * { margin-top: 24px; }
.cs-body p { max-width: 62ch; line-height: 1.65; }
.cs-body strong { color: var(--fg); font-weight: 500; }
.cs-body > figure, .cs-body > table, .cs-body > .pair { margin-top: 40px; }

/* Lede: the one sentence to read if you read nothing else */
.cs-body p.lede { font-size: var(--fs-xl); line-height: 1.35; color: var(--fg); max-width: 34ch; }
.cs-body > .lede + * { margin-top: 28px; }

/* Sub-sections: numbered (03.1…), clearly larger than body, with room above */
.cs-body h3 { font-size: var(--fs-l); font-weight: 500; color: var(--fg); line-height: 1.3; margin-top: clamp(64px, 9vh, 96px); }
.cs-body h3:first-child { margin-top: 0; }
.cs-body h3 .n { display: block; color: var(--accent-text); font-size: var(--fs-s); font-weight: 400; margin-bottom: 4px; }
.cs-body h3 + * { margin-top: 16px; }

.cs-body p.callout { font-size: var(--fs-xxl); line-height: 1.3; max-width: 30ch; color: var(--fg); }
.callout::before { content: "> "; color: var(--accent-text); }

/* Notes: a metadata row like "skills  a / b / c" on the homepage cards. The label says what kind of
   caveat it is, so it can be skipped or read at a glance. No box or bar: in this site a border means "clickable". */
.cs-body p.note {
  display: grid; grid-template-columns: 13ch minmax(0, 1fr); gap: 4px 16px; align-items: baseline;
  font-size: var(--fs-s); line-height: 1.6; color: var(--fg-2); max-width: 72ch;
}
.note::before { content: "* " attr(data-label); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }

/* Key facts: short label + value instead of a long sentence */
.facts { display: grid; gap: 16px 40px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); padding: 20px 0; border-block: 1px solid var(--line); }
.facts dd { margin-top: 4px; color: var(--fg); }

/* Quotes */
.quotes { list-style: none; display: grid; gap: 32px 40px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.quotes blockquote { font-size: var(--fs-l); line-height: 1.4; color: var(--fg); }
.quotes blockquote::before, .big-quote::before { content: "“"; color: var(--accent-text); }
.quotes blockquote::after, .big-quote::after { content: "”"; color: var(--accent-text); }
.quotes figcaption { margin-top: 8px; font-size: var(--fs-s); }

/* Tables: insight → decision, issue → before → after */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 400; color: var(--muted); font-size: var(--fs-s); text-transform: uppercase; letter-spacing: .04em; padding: 0 16px 10px 0; border-bottom: 1px solid var(--line); }
td { padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td:first-child { width: 42%; position: relative; }
td:last-child { color: var(--fg); }
td .to { color: var(--accent-text); }
tbody tr { transition: background .25s var(--ease); }
tbody tr:hover { background: color-mix(in srgb, var(--fg) 4%, transparent); }
/* Same ">" prompt as the homepage timeline */
td:first-child::after {
  content: ">"; position: absolute; left: -1.8ch; top: 14px; color: var(--accent-text);
  opacity: 0; transform: translateX(-6px); transition: opacity .25s var(--ease), transform .25s var(--ease);
}
tbody tr:hover td:first-child::after { opacity: 1; transform: none; }

/* Design principles */
.principles { list-style: none; counter-reset: p; }
.principles > li { counter-increment: p; display: grid; grid-template-columns: 4ch minmax(0, 1fr); gap: 0 12px; padding: 40px 0; border-top: 1px solid var(--line); }
.principles > li::before { content: counter(p, decimal-leading-zero); color: var(--accent-text); font-size: var(--fs-l); line-height: 1.3; }
.principles h4 { font-size: var(--fs-l); font-weight: 500; line-height: 1.3; color: var(--fg); }
.principles p { margin-top: 10px; }
.principles figure { margin-top: 28px; }
.levels { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.level { display: flex; align-items: center; gap: 10px; }
.swatch { width: 28px; height: 28px; flex: none; }

.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 24px; }

/* Placeholder for images still to export (all replaced in the final photo session) */
.ph {
  aspect-ratio: 4 / 5; display: grid; place-items: center; text-align: center; padding: 24px;
  background-image: radial-gradient(var(--line) 1.2px, transparent 1.2px); background-size: 10px 10px;
  border: 1px dashed var(--line); color: var(--muted); font-size: var(--fs-s);
}
.ph b { display: block; color: var(--fg); font-weight: 500; margin-bottom: 4px; }

/* Big numbers and the key quote */
.stat { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px; }
.stat .big { font-size: clamp(56px, 9vw, 112px); line-height: 1; font-weight: 500; letter-spacing: -.03em; color: var(--fg); }
.stat .big + span { color: var(--fg); }
.cs-body p.big-quote { font-size: var(--fs-xxl); line-height: 1.3; max-width: 32ch; color: var(--fg); }

.steps { list-style: none; }
.steps li { padding: 12px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 3ch minmax(0, 1fr); }
.steps li::before { content: "→"; color: var(--muted); }

/* ---------- Next project ---------- */
.next { padding: clamp(64px, 10vh, 112px) var(--gutter); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; align-items: end; }
.next-card { display: flex; flex-wrap: wrap; align-items: end; gap: 16px clamp(20px, 3vw, 40px); }
.next-card .thumb { width: clamp(160px, 20vw, 240px); outline: 1px solid var(--line); }
.next-card .eyebrow { display: block; }
.big-link { font-size: clamp(32px, 6vw, 72px); font-weight: 500; letter-spacing: -.02em; line-height: 1.05; }
.next-card .lbl { background-size: 0 2px; }
.next-card:hover .lbl, .next-card:focus-visible .lbl { background-size: 100% 2px; }
.next-card:hover .arr-e, .next-card:focus-visible .arr-e { transform: translateX(8px); }
.next-links { display: flex; flex-wrap: wrap; gap: 8px 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; }
  .panel { min-height: 0; aspect-ratio: 16 / 7; }
  .cs { grid-template-columns: 1fr; }
  .cs-label { position: static; display: flex; gap: 12px; align-items: baseline; }
}
@media (max-width: 600px) {
  .cs-body p.note { grid-template-columns: 1fr; }
  /* Tables become stacked cards so nothing scrolls sideways */
  table, thead, tbody, tr, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody tr { padding: 14px 0; border-bottom: 1px solid var(--line); }
  td { border: 0; padding: 2px 0; width: auto !important; }
  td::before { content: attr(data-label); display: block; color: var(--muted); font-size: var(--fs-s); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
  .hero-actions .cta { flex: 1 1 100%; text-align: center; }
}
@media (pointer: coarse) {
  td:first-child::after { display: none; }
  .next-links a, .toc a, .hero-actions a:not(.cta) { padding-block: 12px; display: inline-block; }
}
