/* ═══════════════════════════════════════════════════════
   Case study layout (editorial)
   Loaded after styles.css and each page's own <style>.
   Scope: body.ed. Layout classes are prefixed .ed-
   Rules: one white surface; purple only for links and the
   active section; few separators; no cards or containers
   around content; screenshots carry their own edge.
   ═══════════════════════════════════════════════════════ */

body.ed {
  --line: var(--border);
  --rail: 208px;
  --gap: 64px;
  --shot-shadow: 0 8px 28px rgba(0, 0, 0, 0.07);
  --error-bg: #fbeae9;
  --error-text: #b3261e;
  background: var(--surface);
}
@media (min-width: 1240px) { body.ed { --pad: max(64px, calc((100vw - 1112px) / 2)); } }
html:has(body.ed) { scroll-padding-top: calc(var(--nav-h) + 56px); }

/* ── Type ─────────────────────────────────────────────── */
.ed h1 { font: 400 var(--type-display-size)/var(--type-display-leading) var(--font-display); letter-spacing: var(--type-display-tracking); }
.ed main h2 { font: var(--type-h2-weight) var(--type-h2-size)/var(--type-h2-leading) var(--type-h2-family); letter-spacing: var(--type-h2-tracking); color: var(--text-strong); text-wrap: balance; text-align: left; margin: 0; }
.ed main h3 { font: var(--type-h4-weight) var(--type-h4-size)/var(--type-h4-leading) var(--type-h4-family); color: var(--text-dark); margin: 0; }
.ed-prose p, .ed-row p, .ed-lead, .ed main li { font: var(--type-body-weight) var(--type-body-size)/var(--type-body-leading) var(--type-body-family); color: var(--text-body); }
.ed main .ed-lead { font-size: var(--type-lead-size); line-height: var(--type-lead-leading); max-width: 62ch; margin: 0; }
.ed-prose { display: flex; flex-direction: column; gap: 12px; max-width: 68ch; }
.ed-prose p { margin: 0; }
.ed-meta { font: var(--type-small-weight) var(--type-small-size)/var(--type-small-leading) var(--type-small-family); color: var(--text-secondary); margin: 0; }
.ed main .content-list { list-style: disc; padding-left: 20px; margin: 0; }

.ed .btn-ink { align-self: flex-start; background: var(--neutral-900); color: var(--text-inverse); font-size: var(--font-size-16); padding: 12px 20px; }
.ed .btn-ink:hover { background: var(--neutral-700, #333); color: var(--text-inverse); }

/* ── Header ───────────────────────────────────────────── */
.ed-hero { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); column-gap: var(--gap); row-gap: 32px; padding: var(--space-16) var(--pad) var(--space-10); }
.ed-title { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.ed-side { grid-column: 1; grid-row: 2 / span 2; list-style: none; display: flex; flex-direction: column; gap: 6px; padding: 8px 0 0; margin: 0; }
.ed main .ed-side li { font: 400 var(--type-small-size)/1.5 var(--font); color: var(--text-secondary); }
.ed-claim { grid-column: 2; display: flex; flex-direction: column; gap: 16px; }
.ed main .ed-claim h2 { max-width: 26ch; }
.ed-claim .ed-prose { gap: var(--space-5); }
.ed-hero > .ed-figures { grid-column: 2; display: flex; flex-wrap: wrap; column-gap: var(--space-12); row-gap: var(--space-6); margin-top: 16px; }
.ed-hero > .ed-figures dd { white-space: nowrap; }
.ed-hero > .ed-figures dt { max-width: 24ch; }

.ed-cover { padding: 0 var(--pad); }
.ed-frame { position: relative; }
.ed-cover > img, .ed-cover video { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; object-position: top; border-radius: var(--radius-md); }
.ed-cover video { object-position: center; }

/* ── Figures (metrics) ────────────────────────────────── */
.ed-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); margin: 0; }
.ed-figures > div { display: flex; flex-direction: column; gap: 6px; }
.ed-figures dd { font: 400 var(--font-size-32)/1.2 var(--font-display); letter-spacing: -0.02em; margin: 0; }
.ed-figures dt, .ed-figures span { font: 400 var(--type-small-size)/1.4 var(--font); color: var(--text-secondary); }
.ed-figures--two { grid-template-columns: 1fr 1fr; }
.ed-figures--big dd { font-size: var(--font-size-56); }
.ed-figures--big.ed-figures--three dd { font-size: var(--font-size-40, 40px); }

/* ── Shell and section rail ───────────────────────────── */
.ed-shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); column-gap: var(--gap); padding: 0 var(--pad); }
.ed-rail { position: sticky; top: var(--space-10); align-self: start; margin-top: var(--space-20); transition: top 0.3s ease; }
.site-nav:not(.nav--hidden) ~ main .ed-rail { top: calc(var(--nav-h) + var(--space-4)); }
.ed-rail ol { list-style: none; margin: 0; padding: 0; }
.ed-rail a { display: grid; grid-template-columns: 32px 1fr; padding: 8px 0; font: 500 var(--type-small-size)/1.4 var(--font); color: var(--text-secondary); text-decoration: none; }
.ed-rail a span { font-variant-numeric: tabular-nums; }
.ed-rail a:hover { color: var(--text-dark); }
.ed-rail a[aria-current] { color: var(--action); font-weight: 600; }

/* ── Chapters and blocks ──────────────────────────────── */
.ed main .ed-chapter { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; padding: var(--space-20) 0 0; margin: 0; background: none; }
.ed main .ed-chapter + .ed-chapter { border-top: 1px solid var(--line); margin-top: 112px; padding-top: 112px; }
.ed-opener { display: flex; flex-direction: column; gap: var(--space-4); }
.ed main .ed-opener h2 { font-size: var(--type-h1-size); line-height: 1.1; }
.ed-block { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }
.ed main .ed-block > h2 { font-size: var(--font-size-24); line-height: 1.25; }
.ed-sub { margin-top: var(--space-8); }
/* A block that only introduces the sub-blocks stays close to the first one */
.ed-block--intro + .ed-sub { margin-top: calc(var(--space-8) - var(--space-16)); }
.ed-stack { display: flex; flex-direction: column; gap: var(--space-10); }

.ed-rows { display: flex; flex-direction: column; gap: var(--space-8); }
.ed-row { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-6); }
.ed-row p { margin: 0; max-width: 68ch; }
.ed-row > div { display: flex; flex-direction: column; gap: var(--space-3); }
.ed-rows--stacked .ed-row { grid-template-columns: 1fr; gap: 8px; }

.ed-spec { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); border-top: 1px solid var(--line); padding-top: var(--space-6); margin: 0; }
.ed-spec dt { font: 600 var(--type-label-size)/1.3 var(--font); margin-bottom: 6px; }
.ed-spec dd { font: 400 var(--type-small-size)/1.5 var(--font); color: var(--text-body); margin: 0; }

/* Two text columns (before / after, findings) */
.ed-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-8) var(--space-6); align-items: start; }
.ed-cols > div { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.ed-cols p { margin: 0; }
.ed-label { font: 600 var(--type-label-size)/1.4 var(--font); color: var(--text-dark); margin: 0; }

/* Text beside a narrow image */
.ed-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: var(--space-8); align-items: start; }

/* Left-bar note: insights, decisions, NDA notice */
.ed-note { border-left: 2px solid var(--neutral-900); padding: 4px 0 4px 16px; display: flex; flex-direction: column; gap: var(--space-2); max-width: 68ch; }
.ed-note p { margin: 0; font: var(--type-body-weight) var(--type-body-size)/var(--type-body-leading) var(--type-body-family); color: var(--text-body); }
.ed .nda-warning { display: flex; align-items: flex-start; background: none; border: 0; border-left: 2px solid var(--neutral-900); border-radius: 0; padding: 4px 0 4px 16px; margin: 0; max-width: 68ch; }

/* ── Images ───────────────────────────────────────────── */
.ed-fig { display: flex; flex-direction: column; gap: var(--space-2); margin: 0; min-width: 0; }
.ed-fig img { display: block; width: 100%; height: auto; }
.ed-shot img, .ed-grid img { border: 1px solid var(--neutral-200); border-radius: var(--radius-md); box-shadow: var(--shot-shadow); }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); align-items: start; }
.ed-grid img { display: block; width: 100%; height: auto; }
.ed-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.ed-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.ed-grid--lead > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.ed-diagram { max-width: 560px; }
.ed-diagram--wide { max-width: 100%; }

.ed-quickhead { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.ed-quickhead a { color: var(--action); font: 600 var(--type-small-size) var(--font); }

/* Blurred or dense boards: small thumbnails */
.ed-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-8); }
.ed-pair > div { display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-5); }
.ed-thumb > div { aspect-ratio: 16 / 10; overflow: hidden; border-radius: var(--radius-sm); background: var(--neutral-50); }
.ed-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.ed-thumb--board { width: min(100%, 400px); }
.ed-thumb--board > div { aspect-ratio: 800 / 277; }

.ed-reflinks { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: baseline; font: 600 var(--type-label-size)/1.4 var(--font); margin: 0; }
.ed-zoom { background: none; border: 0; padding: 0; font: 600 var(--type-small-size)/1.4 var(--font); color: var(--action); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ed-fs img { display: none; }
.ed-crop { aspect-ratio: 2306 / 1215; overflow: hidden; border-radius: var(--radius-md); border: 1px solid var(--neutral-200); }
.ed-crop img { width: 100%; height: auto; }
.ed-figcaption { display: flex; justify-content: space-between; gap: 16px; }

/* ── Quotes ───────────────────────────────────────────── */
.ed-quotes { display: flex; flex-direction: column; gap: var(--space-10); }
.ed-quote { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-6); margin: 0; }
.ed-quote figcaption { font: 600 var(--type-label-size)/1.4 var(--font); }
.ed-quote blockquote { font: 400 var(--font-size-24)/1.35 var(--font-display); letter-spacing: -0.01em; margin: 0; }
.ed-pullquote { font: 400 var(--font-size-32)/1.25 var(--font-display); letter-spacing: -0.02em; max-width: 24ch; margin: 0; }
.ed .ed-pullquote p { font: inherit; color: var(--text-strong); margin: 0; }

/* ── Tables ───────────────────────────────────────────── */
.ed-table { overflow-x: auto; }
.ed-table table { width: 100%; border-collapse: collapse; background: none; border: 0; border-radius: 0; min-width: 0; }
.ed .ed-table th, .ed .ed-table td { background: none; border: 0; padding: 12px 16px; text-align: left; vertical-align: top; font: 400 var(--type-small-size)/1.5 var(--font); color: var(--text-body); }
.ed .ed-table th { font-weight: 600; color: var(--text-dark); }
.ed .ed-table tbody tr:nth-child(odd) > td { background: var(--neutral-50); }
.ed .ed-table td strong { color: var(--text-dark); font-weight: 600; }
.ed .ed-table--log table { min-width: 760px; }
.ed .priority-badge { display: inline-block; background: none; color: var(--text-body); padding: 3px 8px; margin-left: -9px; border: 1px solid transparent; border-radius: var(--radius-xs); white-space: nowrap; }
.ed .priority-badge--highest { background: var(--neutral-900); color: var(--text-inverse); }
.ed .priority-badge--high { border-color: var(--neutral-900); color: var(--text-dark); }
.ed .priority-badge--lowest { color: var(--text-secondary); }
.ed .audit-tag--error { display: inline-block; background: var(--error-bg); color: var(--error-text); border: 0; border-radius: var(--radius-xs); padding: 2px 8px; }

/* ── Folded content ───────────────────────────────────── */
.ed .cs-collapse { margin: 0; border: 0; border-radius: 0; background: none; overflow: visible; }
.ed .cs-collapse > summary { background: var(--neutral-100); border: 0; border-radius: var(--radius-sm); padding: var(--space-4) var(--space-5); }
.ed .cs-collapse > summary:hover { background: var(--neutral-200); }
.ed .cs-collapse-body { background: none; border: 0; padding: var(--space-6) 0 0; }
.ed .cs-collapse-body.ed-notes img { display: block; width: min(100%, 443px); margin: 0 auto; }

/* ── Flows with arrows ────────────────────────────────── */
.ed .lifecycle-flow { display: flex; gap: var(--space-2); align-items: flex-start; max-width: none; margin: 0; }
.ed .lifecycle-step { display: flex; flex-direction: column; flex: 1 1 0; align-items: flex-start; text-align: left; gap: var(--space-2); border: 0; padding: 0; }
.ed .lifecycle-pill { background: var(--neutral-100); border: 0; border-radius: var(--radius-sm); padding: 8px 10px; text-align: left; color: var(--text-dark); font: 600 var(--type-small-size)/1.4 var(--font); }
.ed .lifecycle-pill--error { background: var(--error-bg); color: var(--error-text); }
.ed .lifecycle-caption { text-align: left; max-width: none; }
.ed .lifecycle-connector, .ed-arrow { display: block; position: relative; flex: 0 0 28px; align-self: flex-start; width: 28px; height: 1px; margin: 18px 0 0; background: var(--neutral-500); }
.ed .lifecycle-connector::after, .ed-arrow::after { content: ""; position: absolute; right: 0; top: -3px; width: 6px; height: 6px; border: solid var(--neutral-500); border-width: 1px 1px 0 0; transform: rotate(45deg); }
.ed .lifecycle-branch { display: flex; flex-direction: column; align-items: flex-start; }
.ed .lifecycle-branch-connector { display: block; position: relative; width: 1px; height: 20px; margin: 0 0 0 18px; background: var(--neutral-500); }
.ed .lifecycle-branch-connector::after { content: ""; position: absolute; bottom: 0; left: -3px; width: 6px; height: 6px; border: solid var(--neutral-500); border-width: 0 1px 1px 0; transform: rotate(45deg); }

/* Process steps in one line (methodology) */
.ed-road { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.ed main .ed-road span.ed-step { background: var(--neutral-100); border-radius: var(--radius-sm); padding: 8px 10px; font: 600 var(--type-small-size)/1.4 var(--font); color: var(--text-dark); }
.ed-road .ed-arrow { align-self: center; flex-basis: 20px; width: 20px; margin: 0; }

/* ── Annotated screenshots ────────────────────────────── */
.ed .annotated-shot-media { position: relative; width: 100%; }
.ed .annotation-pin, .ed .annotation-legend-num { background: var(--neutral-900); color: var(--text-inverse); border: 2px solid var(--text-inverse); }
.ed .annotation-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); margin: 0; max-width: none; }
.ed .annotation-legend-item { align-items: flex-start; border: 0; padding: 0; }
.ed .annotation-legend-item p { font: 400 var(--type-small-size)/1.5 var(--font); color: var(--text-body); margin: 0; }
.ed main h3.ed-stepno { display: flex; gap: 12px; font-size: var(--font-size-20); }
.ed-stepno span { color: var(--text-secondary); }

/* ── Status states (Pulse) ────────────────────────────── */
.ed-statelabel { display: flex; align-items: center; gap: 8px; font: 600 var(--type-label-size)/1.4 var(--font); }

/* ── Impact ───────────────────────────────────────────── */
.ed-impact .ed-opener { gap: var(--space-2); }

/* ── More case studies ────────────────────────────────── */
.ed main .ed-next { display: grid; grid-template-columns: calc(var(--rail) + 40px) minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--space-6); margin: 112px 0 0; padding: var(--space-20) var(--pad) var(--space-16); border-top: 1px solid var(--line); background: none; }
.ed main .ed-next h2 { font-size: var(--font-size-24); line-height: 1.25; padding-right: var(--space-6); }
.ed-next a { display: flex; flex-direction: column; gap: 12px; text-decoration: none; }
.ed-next img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius-sm); }
.ed-next a:hover h3 { color: var(--action); text-decoration: underline; text-underline-offset: 3px; }

/* ── Tablet ───────────────────────────────────────────── */
@media (max-width: 1023px) {
  .ed-hero, .ed-shell { grid-template-columns: minmax(0, 1fr); }
  .ed main .ed-next { grid-template-columns: 1fr 1fr; row-gap: var(--space-8); margin-top: 72px; padding-top: var(--space-12); }
  .ed main .ed-next h2 { grid-column: 1 / -1; }
  .ed-side { grid-row: auto; flex-direction: row; flex-wrap: wrap; column-gap: 12px; padding-top: 0; }
  .ed-claim, .ed-hero > .ed-figures { grid-column: 1; }
  .ed-rail { z-index: 90; top: 0; align-self: stretch; min-width: 0; margin: var(--space-6) calc(-1 * var(--pad)) 0; padding: 0 var(--pad); background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
  .site-nav:not(.nav--hidden) ~ main .ed-rail { top: var(--nav-h); }
  .ed-rail ol { display: flex; gap: 24px; width: max-content; }
  .ed-rail a { display: flex; gap: 8px; white-space: nowrap; padding: 12px 0; border-bottom: 2px solid transparent; }
  .ed-rail a[aria-current] { border-bottom-color: var(--action); }
  .ed main .ed-chapter { padding-top: var(--space-12); }
  .ed main .ed-chapter + .ed-chapter { margin-top: 72px; padding-top: 72px; }
  /* the rail is a direct child of the grid: keep it sticky over the whole column */
  .ed-shell { display: block; }
  .ed-grid--four { grid-template-columns: 1fr 1fr; }
  .ed-title { display: block; }
  .ed-title h1 { display: inline; margin-right: 12px; }
  .ed-title .nda-badge { display: inline-block; vertical-align: middle; }
}

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 767px) {
  body.ed { --pad: 24px; }
  .ed-hero { padding-top: var(--space-8); }
  .ed-title { display: flex; flex-direction: column; align-items: flex-start; }
  .ed-title h1 { margin-right: 0; }
  .ed-cover > img, .ed-cover video { aspect-ratio: 1440 / 1024; border-radius: var(--radius-sm); }
  .ed-cover video { aspect-ratio: 16 / 9; }
  .ed-hero > .ed-figures { flex-direction: column; }
  .ed-split > .ed-fig { width: min(100%, 360px); }
  .ed-figures, .ed-figures--two, .ed-spec, .ed-cols, .ed-split, .ed-grid, .ed-grid--three, .ed-pair, .ed .annotation-legend, .ed main .ed-next { grid-template-columns: 1fr; }
  .ed-pair { gap: var(--space-8); }
  .ed-row, .ed-quote { grid-template-columns: 1fr; gap: 8px; }
  .ed-shot img, .ed-grid img { border-radius: var(--radius-sm); }
  .ed .annotated-shot-media .annotation-pin { width: 16px; height: 16px; font-size: 9px; border-width: 1px; }
  .ed .lifecycle-flow { flex-direction: column; }
  .ed .lifecycle-step { flex: none; }
  .ed .lifecycle-connector { flex: 0 0 24px; width: 1px; height: 24px; margin: 0 0 0 18px; }
  .ed .lifecycle-connector::after { right: auto; left: -3px; top: auto; bottom: 0; transform: rotate(135deg); }
  .ed-diagram--scroll { overflow-x: auto; }
}
