/* ════════════════════════════════════════════════════════════
   Case study layer · Solaris Instrument v2.1
   Loads after solaris.css. Restyles the case-study markup on Solaris tokens.
   Illustration panels (.visual, .visual-item, .visual-item-solo) stay as light
   "paper" in every theme: their SVG artwork is drawn for a light ground.
   ════════════════════════════════════════════════════════════ */

/* Page-level accent hooks the per-page styles still reference */
:root { --cs-accent: var(--sig); --cs-accent-rgb: 110, 242, 196; --cs-body-bg: var(--bg); --cs-shadow-rgb: 0, 0, 0; --paper: #fbfcfb; --paper-2: #f2f5f4; --paper-ink: #0d1213; --paper-line: #dde3e1; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --cs-accent-rgb: 15, 118, 110; --cs-shadow-rgb: 13, 18, 19; } }
:root[data-theme="light"] { --cs-accent-rgb: 15, 118, 110; --cs-shadow-rgb: 13, 18, 19; }
:root[data-contrast="high"] { --cs-accent-rgb: 255, 255, 0; --paper: #ffffff; --paper-2: #ffffff; --paper-line: #000000; }

/* Layout */
.stage { position: relative; }
.content {
  position: relative; z-index: 1;
  max-width: 1120px; margin: 0 auto;
  padding-block: var(--s-8) var(--s-9);
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
main:focus { outline: none; }

/* Header */
.eyebrow { margin-bottom: var(--s-5); }
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sig); box-shadow: 0 0 0 3px var(--sig-soft); }
.content h1 {
  font-size: clamp(42px, 6.2vw, 80px); font-weight: 700; letter-spacing: -0.045em; line-height: 0.98;
  margin-bottom: var(--s-5); color: var(--fg); max-width: 15ch;
}
.content h1 .line { display: block; }
.content h1 em { padding-right: 0.04em; }
.lede { font-size: 19px; line-height: 1.55; color: var(--fg-2); max-width: 62ch; margin-bottom: var(--s-6); }
.tags { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-8); }
.content .tag { height: 28px; padding: 0 11px; }

/* Sections */
section { margin-bottom: var(--s-9); }
.section-eyebrow {
  display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4);
  font: 500 11px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--sig);
}
.section-eyebrow::before { content: ""; width: 24px; height: 1px; background: var(--sig); }
.content h2 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; margin-bottom: var(--s-5); color: var(--fg); max-width: 24ch; }
.content h3 { color: var(--fg); }
section p { font-size: 16.5px; line-height: 1.7; color: var(--fg-2); max-width: 66ch; margin-bottom: var(--s-4); }
section p strong { color: var(--fg); font-weight: 600; }
section p a, footer a { text-decoration: underline; }

/* Stats: readouts */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-4); margin-top: var(--s-6); }
.stats .stat { padding: var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--highlight); display: grid; gap: 10px; align-content: start; }
.stat-value { font: 500 40px/1 var(--font-mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--fg); }
.stat-value em { font-style: normal; color: var(--sig); }
.stat-label { font: 500 11px/1.45 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); }

/* Illustration panels: light paper in every theme */
.visual, .visual-item, .visual-item-solo {
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  color: var(--paper-ink);
  color-scheme: light;
}
:root[data-contrast="high"] .visual, :root[data-contrast="high"] .visual-item, :root[data-contrast="high"] .visual-item-solo { border: 2px solid #ffffff; box-shadow: none; }
.visual { margin: var(--s-7) 0; padding: var(--s-6); }
.visual svg, .visual-item svg { width: 100%; height: auto; display: block; }
.visual-grid { display: grid; grid-template-columns: 1fr; gap: var(--s-5); margin-top: var(--s-7); }
.visual-item { padding-bottom: var(--s-5); }
.visual-item-label {
  display: flex; align-items: center; gap: 10px; padding: 14px var(--s-5);
  background: var(--paper-2); border-bottom: 1px solid var(--paper-line);
  font: 500 11px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: #3d4745;
}
.visual-item-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #0f766e; }

/* Process flow */
.flow { gap: 0; margin: var(--s-7) 0; position: relative; display: grid; }
.flow::before { content: ""; position: absolute; top: 21px; height: 1px; z-index: 0; background: var(--line-2) !important; }
.flow-step { display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; z-index: 1; padding: 0 var(--s-2); }
.flow-badge {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; margin-bottom: var(--s-4);
  font: 600 13px/1 var(--font-mono); background: var(--surface) !important; color: var(--sig) !important;
  border: 1px solid var(--sig-line); box-shadow: 0 0 0 4px var(--bg) !important;
}
.flow-title { font-size: 13.5px; font-weight: 600; color: var(--fg) !important; letter-spacing: -0.01em; margin-bottom: 6px; line-height: 1.3; }
.flow-desc { font-size: 12px; color: var(--fg-3) !important; line-height: 1.55; }

/* Impact cards */
.impact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s-4); margin-top: var(--s-6); }
.impact-card { padding: var(--s-5); background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--r-3); box-shadow: var(--highlight); position: relative; }
.impact-card::before { content: ""; position: absolute; left: var(--s-5); top: 0; width: 24px; height: 2px; background: var(--sig); }
.impact-card h3 { font-size: 18px; font-weight: 600; color: var(--fg); margin-bottom: 10px; letter-spacing: -0.015em; }
.impact-card p { font-size: 14px; line-height: 1.65; color: var(--fg-2); margin: 0; }

/* Footer */
footer.cs-foot {
  margin-top: var(--s-9); padding-top: var(--s-5); border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s-3);
  font: 500 12px/1.5 var(--font-mono); color: var(--fg-3);
}
footer.cs-foot a { color: var(--fg-2); display: inline-flex; align-items: center; min-height: 24px; }
footer.cs-foot a:hover { color: var(--fg); }

/* Per-visual pause button row (added by the page script) */
.anim-controls { display: flex; justify-content: flex-end; padding: 10px 14px 12px; }
.content .anim-btn svg { width: 10px !important; height: 10px !important; flex: none; }

/* Flow badges: one look across pages; the number reads in signal */
.flow-badge span { background: none !important; -webkit-text-fill-color: currentColor !important; color: inherit !important; }

/* ── Page-specific pieces, moved onto tokens ─────────────── */
/* Accessibility: layer intros */
.layer-heading { color: var(--fg) !important; font-weight: 600 !important; letter-spacing: -0.02em !important; }
.layer-desc { color: var(--fg-2) !important; }
.layer-desc strong { color: var(--fg); }
/* Accessibility: cost insight */
.cost-insight { background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--r-3) !important; box-shadow: var(--highlight) !important; }
.cost-insight-amount { font-family: var(--font-mono) !important; letter-spacing: -0.03em !important; }
.cost-insight-amount.green { color: var(--pass) !important; }
.cost-insight-amount.red { color: var(--fail) !important; }
.cost-insight-label, .cost-insight-times { color: var(--fg-3) !important; font-family: var(--font-mono); }
.cost-insight-note { color: var(--fg-2) !important; }
.cost-insight-track-fill { background: var(--pass) !important; }
.cost-insight-track-bg { background: color-mix(in srgb, var(--fail) 35%, transparent) !important; }
.cost-insight-track-badge { color: var(--fail) !important; background: var(--fail-soft) !important; }
/* Accessibility: checklist card */
.a11y-checklist { background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--r-3) !important; box-shadow: var(--shadow-1) !important; backdrop-filter: none !important; }
.a11y-checklist::before { display: none !important; }
.a11y-cl-header { background: var(--sunken) !important; border-bottom: 1px solid var(--line) !important; }
.a11y-cl-badge, .a11y-cl-title, .a11y-cl-doc-title { color: var(--fg) !important; }
.a11y-cl-desc, .a11y-cl-doc-desc { color: var(--fg-3) !important; }
.a11y-cl-col-label { color: var(--fg-3) !important; font-family: var(--font-mono) !important; letter-spacing: 0.1em !important; }
.a11y-cl-dot, .a11y-cl-item-dot { background: var(--sig) !important; box-shadow: none !important; }
.a11y-cl-doc { background: var(--sunken) !important; border: 1px solid var(--line) !important; }
.a11y-cl-doc-icon { color: var(--sig) !important; }
.a11y-cl-cta { background: var(--sig) !important; color: var(--sig-ink) !important; }
.a11y-cl-footer { background: var(--sunken) !important; border-top: 1px solid var(--line) !important; color: var(--sig) !important; }
.a11y-checklist .anim-controls { border-top: 1px solid var(--line); }
/* Solaris: its token visuals are dark product screens, so frame them as screens */
.visual.screen, .visual-item.screen { background: var(--scene-bg); }
:root:not([data-contrast="high"]) .visual.screen { padding: var(--s-4); }
.visual.screen .anim-controls, .visual-item.screen .anim-controls { padding-inline: 0; }
/* Episode Connect: label above its illustrations */
.visual-label { color: #3d4745 !important; font-family: var(--font-mono) !important; }

/* Responsive */
@media (max-width: 768px) {
  .flow { grid-template-columns: repeat(3, 1fr) !important; row-gap: var(--s-5); }
  .flow::before { display: none; }
  .visual { padding: var(--s-4); }
}
@media (max-width: 480px) {
  .flow { grid-template-columns: repeat(2, 1fr) !important; }
}
/* Solaris screens stay dark in every theme, so their header colors are fixed to that surface */
.visual-item.screen { background: #0b151b; border-color: #22323a; }
.visual-item.screen .visual-item-header { background: #0f1e26 !important; border-bottom: 1px solid #22323a !important; }
.visual-item.screen .vih-title { color: #edf2f1 !important; }
.visual-item.screen .vih-accent { color: #6fd3e0 !important; }
.visual.screen { background: #0b151b; border-color: #22323a; }
:root[data-contrast="high"] .visual.screen, :root[data-contrast="high"] .visual-item.screen { background: #000; border-color: #fff; }
/* The pause row inside a flow spans the whole grid instead of taking a step's cell */
.flow > .anim-controls { grid-column: 1 / -1; padding: var(--s-4) 0 0; }

/* Hero framed as a selected Figma component, matching the Work page */
.cs-hero { margin-bottom: var(--s-8); padding-bottom: var(--s-6); }
.cs-hero .tags { margin-bottom: 0; }
.cs-hero h1 { max-width: 15ch; }

/* Dark versions of the illustration panels (colors inside are remapped by cs-graphics.js) */
:root[data-graphics="dark"] { --paper: #121819; --paper-2: #0e1314; --paper-ink: #e3e9e7; --paper-line: #253030; }
:root[data-graphics="dark"] .visual, :root[data-graphics="dark"] .visual-item, :root[data-graphics="dark"] .visual-item-solo {
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%); border-color: var(--line-2); color-scheme: dark;
}
:root[data-graphics="dark"] .visual-item-label { color: var(--fg-2); }
:root[data-graphics="dark"] .visual-item-label::before { background: var(--sig); }
:root[data-graphics="dark"] .visual-label { color: var(--fg-2) !important; }

/* At a glance: the whole story in three lines, for people who skim */
.glance { margin: calc(var(--s-8) * -1 + var(--s-6)) 0 var(--s-8); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); box-shadow: var(--highlight); }
.glance dl { display: grid; margin: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.glance dl > div { padding: var(--s-5); border-right: 1px solid var(--line); }
.glance dl > div:last-child { border-right: 0; }
.glance dt { font: 500 11px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--sig); margin: 0 0 10px; max-width: none; }
.glance dd { margin: 0; font-size: 15px; line-height: 1.55; color: var(--fg); }
@media (max-width: 760px) { .glance dl { grid-template-columns: minmax(0, 1fr); } .glance dl > div { border-right: 0; border-bottom: 1px solid var(--line); } .glance dl > div:last-child { border-bottom: 0; } }

/* Who the work was for: company, role, years */
.cs-meta { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6); margin: 0 0 var(--s-5); }
.cs-meta dt { font: 500 11px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-3); }
.cs-meta dd { margin: 8px 0 0; font-size: 15px; font-weight: 600; color: var(--fg); }
/* A quiet note about how the visuals were made */
.cs-note { margin: calc(var(--s-7) * -1 + var(--s-4)) 0 var(--s-8); padding: var(--s-4) var(--s-5); border-left: 2px solid var(--sig); background: var(--sunken); border-radius: 0 var(--r-2) var(--r-2) 0; }
.cs-note .t-label { color: var(--sig); }
.cs-note p { margin: 8px 0 0; font-size: 15px; line-height: 1.6; color: var(--fg-2); max-width: 70ch; }

/* ── Solaris graphic panels (.g-sol) ───────────────────────
   Artwork drawn with tokens: the panel is a kit frame, and every color
   inside comes from the theme, so dark, light and high contrast need no remapping. */
.visual.g-sol, .visual-item.g-sol, .visual-item-solo.g-sol,
:root[data-graphics="dark"] .visual.g-sol, :root[data-graphics="dark"] .visual-item.g-sol, :root[data-graphics="dark"] .visual-item-solo.g-sol {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3);
  box-shadow: var(--highlight); color: var(--fg); color-scheme: normal; overflow: hidden;
}
.visual-item-solo.g-sol { padding-bottom: 0; }
.visual-item-solo.g-sol svg { width: 100%; height: auto; display: block; }
.g-sol .anim-controls { border-top: 1px solid var(--line); padding: 10px 14px; }
:root[data-contrast="high"] .g-sol { border: 2px solid var(--fg) !important; box-shadow: none !important; }
/* A mono caption strip, the same on every graphic */
.g-head { display: flex; align-items: center; gap: 10px; padding: 12px var(--s-5); border-bottom: 1px solid var(--line); background: var(--sunken);
  font: 500 11px/1.3 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-2); }
.g-head::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sig); flex: none; }
.g-head .g-meta { margin-left: auto; color: var(--fg-3); letter-spacing: 0.06em; white-space: nowrap; }
@media (max-width: 600px) { .g-head .g-meta { display: none; } }

/* Recreation note: the kit's info alert */
.cs-alert { margin: calc(var(--s-7) * -1 + var(--s-4)) 0 var(--s-8); }
.cs-alert p { margin: 0; max-width: 70ch; line-height: 1.6; }
/* Stat tiles, as in the kit: label first, then the readout */
.stats .stat { gap: var(--s-3); }
.stats .stat .stat-label { order: -1; font: 500 11px/1.45 var(--font-mono); letter-spacing: 0.1em; color: var(--fg-3); }
.stats .stat .stat-value { font: 500 28px/1 var(--font-mono); letter-spacing: -0.02em; color: var(--fg); }
.stats .stat .stat-value em { color: inherit; }

/* Every graphic opens with the same caption strip, flush with its frame */
.visual > .g-head:first-child { margin: calc(var(--s-6) * -1) calc(var(--s-6) * -1) var(--s-6); }
.visual.g-sol > .g-head:first-child { margin: 0; }
@media (max-width: 768px) { .visual:not(.g-sol) > .g-head:first-child { margin: calc(var(--s-4) * -1) calc(var(--s-4) * -1) var(--s-4); } }
:root[data-graphics="dark"] .g-head { background: rgba(0, 0, 0, 0.25); }
.visual.g-sol { padding: 0; }
.stats .stat { grid-template-rows: auto 1fr; align-content: stretch; }
.stats .stat .stat-value { align-self: end; }
