/* ==========================================================================
   Instrument Sheet: Data Platform Portfolio Stylesheet
   Direction: Instrument Sheet (engineering paper in light, instrument panel in dark).
   Palette, typography, and diagram language approved from prototype raft1.html.
   ========================================================================== */

/* ===== Tokens ===== */
:root,
:root[data-theme="light"] {
  --ground: #F2F1EC;
  --surface: #FFFFFF;
  --ink: #10130F;
  --muted: #5F6663;
  --line: #D3D5D0;
  --signal: #C2410C;
  --pos: #15803D;
  --neg: #B91C1C;

  /* Chart tokens: independent series colors */
  --chart-1: #10130F;
  --chart-2: #C2410C;
  --chart-3: #8A8F8B;
  --chart-4: #15803D;

  --grid-pat: rgba(16, 19, 15, 0.05);
  --card-border: #D3D5D0;

  /* Typography */
  --font-display: 'Archivo Black', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-sans: 'Archivo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --header-h: 60px;

  /* Detail-page tokens referenced by project.css; colour aliases ride the active theme via var(). */
  --sp-4: 4px;
  --sp-8: 8px;
  --sp-12: 12px;
  --sp-16: 16px;
  --sp-24: 24px;
  --sp-32: 32px;
  --sp-48: 48px;
  --sp-64: 64px;
  --fs-mono-s: 12px;
  --fs-mono: 13px;
  --fs-body: 14px;
  --fs-lead: 17px;
  --fs-h3: 20px;
  --fs-h2: 28px;
  --r-md: 6px;
  --t-fast: 120ms ease-out;
  --text: var(--ink);
  --accent: var(--signal);
  --surface-2: var(--surface);
  --scrim: rgba(7, 9, 10, 0.78);
}

:root[data-theme="dark"] {
  --ground: #07090A;
  --surface: #101315;
  --ink: #EDEFEC;
  --muted: #98A09C;
  --line: #232829;
  --signal: #FF5A1F;
  --pos: #4ADE80;
  --neg: #FF6B5E;

  /* Chart tokens: independent series colors */
  --chart-1: #EDEFEC;
  --chart-2: #FF5A1F;
  --chart-3: #6B7370;
  --chart-4: #4ADE80;

  --grid-pat: rgba(237, 239, 236, 0.02);
  --card-border: #232829;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #07090A;
    --surface: #101315;
    --ink: #EDEFEC;
    --muted: #98A09C;
    --line: #232829;
    --signal: #FF5A1F;
    --pos: #4ADE80;
    --neg: #FF6B5E;

    --chart-1: #EDEFEC;
    --chart-2: #FF5A1F;
    --chart-3: #6B7370;
    --chart-4: #4ADE80;

    --grid-pat: rgba(237, 239, 236, 0.02);
    --card-border: #232829;
  }
}

/* ===== Reset and base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background-color: var(--ground);
}

body {
  background-color: var(--ground);
  background-image: linear-gradient(to right, var(--grid-pat) 1px, transparent 1px),
                    linear-gradient(to bottom, var(--grid-pat) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding: 0 16px 48px;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.wrap {
  width: 100%;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.2;
}

p {
  color: var(--ink);
}

a {
  color: var(--signal);
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Tabular numbers on all mono text */
code, pre, kbd, samp,
.mono,
.readout-label,
.readout-unit,
.readout-meta,
.cell-unit,
.cell-meta,
.step-num,
.timeline-period,
.timeline-company,
.timeline-caption,
.project-tech,
.project-delta,
.project-link,
.skill-count,
.fact-label,
.fact-value,
.contact-link,
.citation,
.footer-text,
.availability-tag,
.person-role,
.nav-links a,
.theme-toggle-btn {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Accessible visible focus on all interactive elements */
a:focus-visible,
button:focus-visible,
.theme-toggle-btn:focus-visible,
.project-link:focus-visible,
.contact-link:focus-visible,
.nav-links a:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: var(--signal);
  color: #FFFFFF;
}

/* ===== Site Header ===== */
.site-header {
  padding: 24px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.identity-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.person-role {
  font-size: 12px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.nav-links a {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 4px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-links a:hover {
  color: var(--ink);
  border-color: var(--signal);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--signal);
}

.toggle-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal);
  display: inline-block;
}

/* ===== Bands Common ===== */
.band {
  margin-bottom: 24px;
  border: 1px solid var(--card-border);
  background: var(--surface);
}

/* Reveal transition */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ===== Band 1: Hero (7fr / 5fr) ===== */
.band-hero {
  display: grid;
  grid-template-columns: 7fr 5fr;
}

.hero-editorial {
  padding: 36px 32px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.2vw, 36px);
  line-height: 1.16;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 12px;
}

.availability-tag {
  font-size: 12px;
  color: var(--signal);
  display: inline-block;
  margin-bottom: 12px;
}

.hero-lead {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 60ch;
}

.hero-lead p + p {
  margin-top: 10px;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.stack-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.hero-readout {
  padding: 36px 28px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.metric-lead-header {
  margin-bottom: 8px;
}

.readout-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.readout-figure-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.readout-huge {
  font-family: var(--font-display);
  font-size: clamp(46px, 5.5vw, 64px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--signal);
}

.readout-unit {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--signal);
}

.readout-summary {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-top: 8px;
}

.chart-container {
  margin: 12px 0;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.quality-svg {
  max-width: 220px;
}

.readout-meta {
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
  line-height: 1.5;
}

/* ===== Band 2: Secondary Metrics (Three equal columns) ===== */
.band-secondary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--card-border);
  background: var(--surface);
  align-items: stretch;
}

.impact-list {
  display: contents;
}

.cell-metric {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
}

.cell-metric + .cell-metric {
  border-left: 1px solid var(--line);
}

.cell-metric .chart-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  margin: 12px 0;
  min-height: 0;
}

.cell-metric .chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.cell-metric .cell-meta {
  margin-top: auto;
}

.cell-figure {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 6px;
}

.cell-figure .cell-unit {
  font-size: 18px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.cell-desc {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  margin-bottom: 8px;
  line-height: 1.4;
}

.cell-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

/* ===== Band 3: Data Platform Pipeline ===== */
.band-pipeline {
  margin-bottom: 24px;
  border: 1px solid var(--card-border);
  background: var(--surface);
}

.pipeline-column {
  padding: 28px 24px;
}

/* Dual-SVG pipeline variant defaults (wide layout). Narrow MQ swaps these. */
.pipeline-phone {
  display: none;
}

.pipeline-desktop {
  display: block;
}

.pipeline-svg-pair {
  width: 100%;
}

.pipeline-header {
  margin-bottom: 16px;
}

/* ===== Band 4: Proof (7fr / 5fr) ===== */
.band-proof {
  display: grid;
  grid-template-columns: 7fr 5fr;
  align-items: start;
}

.projects-column {
  padding: 28px 24px;
  border-right: 1px solid var(--line);
}

.section-heading {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.sub-heading {
  margin-top: 24px;
}

.section-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.projects-table-wrap,
.sidebuilds-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.proof-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  word-break: break-word;
}

.proof-table caption {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

.proof-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--ink);
  font-weight: 500;
}

.proof-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.project-name {
  font-weight: 600;
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}

.project-tech {
  font-size: 11px;
  color: var(--muted);
}

.project-delta {
  font-size: 12px;
  color: var(--ink);
  white-space: normal;
}

.highlight-pos {
  color: var(--pos);
  font-weight: 600;
}

.project-link {
  font-size: 11px;
  color: var(--signal);
  text-decoration: none;
  display: inline-block;
  margin-right: 8px;
}

.project-link:hover {
  text-decoration: underline;
}

.quality-column {
  padding: 28px 24px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quality-figure {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quality-note {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* ===== Band 5: Skills / Stack ===== */
.band-skills {
  margin-bottom: 24px;
  padding: 24px;
  border: 1px solid var(--card-border);
  background: var(--surface);
}

.skills-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.skill-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
}

.skill-badge .skill-name {
  font-weight: 500;
  color: var(--ink);
}

.skill-badge .skill-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--ground);
  padding: 2px 6px;
  border-radius: 2px;
}

/* ===== Band 6: Experience Timeline ===== */
.band-experience {
  margin-bottom: 24px;
  padding: 28px 24px;
  border: 1px solid var(--card-border);
  background: var(--surface);
}

.experience-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.experience-title-group .section-sub {
  margin-bottom: 0;
}

.timeline-caption {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
}

.timeline-axis {
  width: 100%;
  height: 2px;
  background: var(--line);
  position: relative;
  margin-top: 20px;
}

.timeline,
.timeline-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  position: relative;
  align-items: stretch;
  margin-top: 0;
}

.timeline::before,
.timeline-strip::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--line);
}

.timeline-card {
  padding-top: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.timeline-card::before,
.timeline-marker {
  content: "";
  position: absolute;
  top: -6px;
  left: 0;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border: 2px solid var(--signal);
  border-radius: 50%;
  box-sizing: border-box;
}

.timeline-period {
  font-size: 11px;
  color: var(--signal);
  margin-bottom: 4px;
}

.timeline-role {
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
  margin-bottom: 2px;
}

.timeline-company {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.timeline-desc {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
  flex-grow: 1;
}

/* ===== Band 7: About ===== */
.band-about {
  margin-bottom: 24px;
  padding: 28px 24px;
  border: 1px solid var(--card-border);
  background: var(--surface);
}

.about-prose {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  max-width: 72ch;
  margin-bottom: 18px;
}

.about-prose p + p {
  margin-top: 10px;
}

.about-prose mark {
  background: transparent;
  color: var(--signal);
  font-weight: 600;
}

.about-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 13px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.fact-label {
  color: var(--muted);
  font-weight: 500;
}

.fact-value {
  color: var(--ink);
}

/* ===== Band 8: Contact ===== */
.band-contact {
  padding: 24px;
  border-top: 2px solid var(--ink);
  border: 1px solid var(--card-border);
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.contact-copy {
  max-width: 60ch;
}

.contact-title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 4px;
}

.contact-text {
  font-size: 13px;
  color: var(--muted);
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.contact-link {
  font-size: 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 14px;
  background: var(--surface);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.contact-link:hover {
  border-color: var(--signal);
  color: var(--signal);
}

.citation {
  width: 100%;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 8px;
}

.citation a {
  color: var(--muted);
  text-decoration: underline;
}

/* ===== Site Footer ===== */
.site-footer {
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   SVG Diagram and Chart Language (Instrument Sheet)
   Wireframe line & label in light mode; soft fill in dark mode.
   Connectors are visibly thinner than the shapes they connect.
   ========================================================================== */

/* Connectors: visibly thinner (1px to 1.5px) */
.wf-connector {
  stroke: var(--chart-3);
  stroke-width: 1px;
  stroke-dasharray: 3 3;
}

.pipe-connector {
  fill: none;
  stroke: var(--chart-3);
  stroke-width: 1.5px;
}

.chart-connector {
  fill: none;
  stroke: var(--chart-3);
  stroke-width: 1.5px;
}

.mean-line {
  stroke: var(--chart-3);
  stroke-width: 1px;
  stroke-dasharray: 2 2;
  opacity: 0.6;
}

.grid-line {
  stroke: var(--line);
  stroke-width: 1px;
  stroke-dasharray: 2 2;
}

.axis-line {
  stroke: var(--line);
  stroke-width: 1px;
}

.baseline-line {
  stroke: var(--ink);
  stroke-width: 1.5px;
}

/* Shapes in Light Mode (Wireframe line and label only) */
.wf-bar {
  stroke-width: 1.5px;
  fill: none;
}
.wf-bar.opening-bar {
  stroke: var(--chart-3);
}
.wf-bar.step-bar {
  stroke: var(--chart-1);
  stroke-dasharray: 2 2;
}
.wf-bar.closing-bar {
  stroke: var(--chart-2);
}

.speed-bar {
  stroke-width: 1.5px;
  fill: none;
}
.speed-bar.speed-base {
  stroke: var(--chart-3);
}
.speed-bar.speed-opt {
  stroke: var(--chart-2);
}

.model-bar {
  stroke-width: 1.5px;
  fill: none;
}
.model-bar.bar-table {
  stroke: var(--chart-2);
}
.model-bar.bar-view {
  stroke: var(--chart-3);
}
.model-bar.bar-incr {
  stroke: var(--chart-1);
}

.scatter-dot {
  stroke-width: 1.5px;
  fill: none;
  stroke: var(--chart-3);
}
.scatter-dot.dot-peak {
  stroke-width: 2px;
  fill: none;
  stroke: var(--chart-2);
}

.pipe-node-shape {
  stroke-width: 1.5px;
  fill: none;
  stroke: var(--chart-3);
}
.pipe-node-shape.hub {
  stroke-width: 2px;
  fill: none;
  stroke: var(--chart-2);
}

.cell-test {
  fill: none;
  stroke: var(--chart-4);
  stroke-width: 0.75px;
}

.cell-table {
  fill: none;
  stroke: var(--chart-1);
  stroke-width: 0.75px;
}

/* Shapes in Dark Mode (Soft fill under line) */
:root[data-theme="dark"] .wf-bar.opening-bar {
  fill: rgba(107, 115, 112, 0.25);
  stroke: var(--chart-3);
}
:root[data-theme="dark"] .wf-bar.step-bar {
  fill: rgba(237, 239, 236, 0.15);
  stroke: var(--chart-1);
}
:root[data-theme="dark"] .wf-bar.closing-bar {
  fill: rgba(255, 90, 31, 0.35);
  stroke: var(--chart-2);
}

:root[data-theme="dark"] .speed-bar.speed-base {
  fill: rgba(107, 115, 112, 0.25);
  stroke: var(--chart-3);
}
:root[data-theme="dark"] .speed-bar.speed-opt {
  fill: rgba(255, 90, 31, 0.35);
  stroke: var(--chart-2);
}

:root[data-theme="dark"] .model-bar.bar-table {
  fill: rgba(255, 90, 31, 0.35);
  stroke: var(--chart-2);
}
:root[data-theme="dark"] .model-bar.bar-view {
  fill: rgba(107, 115, 112, 0.25);
  stroke: var(--chart-3);
}
:root[data-theme="dark"] .model-bar.bar-incr {
  fill: rgba(237, 239, 236, 0.2);
  stroke: var(--chart-1);
}

:root[data-theme="dark"] .scatter-dot {
  fill: rgba(107, 115, 112, 0.4);
  stroke: var(--chart-3);
}
:root[data-theme="dark"] .scatter-dot.dot-peak {
  fill: rgba(255, 90, 31, 0.6);
  stroke: var(--chart-2);
}

:root[data-theme="dark"] .pipe-node-shape {
  fill: var(--chart-3);
  stroke: var(--chart-3);
}
:root[data-theme="dark"] .pipe-node-shape.hub {
  fill: var(--chart-2);
  stroke: var(--chart-2);
}

:root[data-theme="dark"] .cell-test {
  fill: var(--chart-4);
  stroke: var(--chart-4);
}
:root[data-theme="dark"] .cell-table {
  fill: var(--chart-1);
  stroke: var(--chart-1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wf-bar.opening-bar {
    fill: rgba(107, 115, 112, 0.25);
    stroke: var(--chart-3);
  }
  :root:not([data-theme="light"]) .wf-bar.step-bar {
    fill: rgba(237, 239, 236, 0.15);
    stroke: var(--chart-1);
  }
  :root:not([data-theme="light"]) .wf-bar.closing-bar {
    fill: rgba(255, 90, 31, 0.35);
    stroke: var(--chart-2);
  }

  :root:not([data-theme="light"]) .speed-bar.speed-base {
    fill: rgba(107, 115, 112, 0.25);
    stroke: var(--chart-3);
  }
  :root:not([data-theme="light"]) .speed-bar.speed-opt {
    fill: rgba(255, 90, 31, 0.35);
    stroke: var(--chart-2);
  }

  :root:not([data-theme="light"]) .model-bar.bar-table {
    fill: rgba(255, 90, 31, 0.35);
    stroke: var(--chart-2);
  }
  :root:not([data-theme="light"]) .model-bar.bar-view {
    fill: rgba(107, 115, 112, 0.25);
    stroke: var(--chart-3);
  }
  :root:not([data-theme="light"]) .model-bar.bar-incr {
    fill: rgba(237, 239, 236, 0.2);
    stroke: var(--chart-1);
  }

  :root:not([data-theme="light"]) .scatter-dot {
    fill: rgba(107, 115, 112, 0.4);
    stroke: var(--chart-3);
  }
  :root:not([data-theme="light"]) .scatter-dot.dot-peak {
    fill: rgba(255, 90, 31, 0.6);
    stroke: var(--chart-2);
  }

  :root:not([data-theme="light"]) .pipe-node-shape {
    fill: var(--chart-3);
    stroke: var(--chart-3);
  }
  :root:not([data-theme="light"]) .pipe-node-shape.hub {
    fill: var(--chart-2);
    stroke: var(--chart-2);
  }

  :root:not([data-theme="light"]) .cell-test {
    fill: var(--chart-4);
    stroke: var(--chart-4);
  }
  :root:not([data-theme="light"]) .cell-table {
    fill: var(--chart-1);
    stroke: var(--chart-1);
  }
}

/* Typography inside SVG: 12px mono, muted labels outside shapes */
.pipe-node-label {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--ink);
  font-weight: 500;
}

.pipe-node-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--muted);
}

.pipe-stage-label {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--muted);
  text-anchor: middle;
  font-weight: 600;
}

/* Phone pipeline text overrides: stage label left-anchored, node labels centered below circles. */
.pipe-stage-label-phone {
  text-anchor: start;
}

.pipe-node-label-phone {
  text-anchor: middle;
}

.pipe-node-sub-phone {
  text-anchor: middle;
}

.step-num {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--muted);
  color: var(--muted);
  font-weight: 400;
  margin-right: 6px;
}

.wf-axis-label,
.svg-axis-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--muted);
  text-anchor: middle;
}

.wf-axis-label .step-num {
  font-size: 10px;
}

.wf-val {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--ink);
  text-anchor: middle;
  font-weight: 500;
}

.wf-val.step-val {
  fill: var(--chart-1);
}

.wf-val.closing-val {
  fill: var(--chart-2);
}

.speed-val {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--ink);
  text-anchor: middle;
}

.speed-val-opt {
  fill: var(--chart-2);
  font-weight: 600;
}

.model-val {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--ink);
  text-anchor: middle;
}

.mean-label {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--muted);
}

.matrix-stage-title {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--ink);
  font-weight: 500;
}

.matrix-count-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--muted);
  font-weight: 400;
}

.svg-footnote {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--muted);
}

/* Empty containers */
.hero-cta:empty,
.stack-strip:empty,
.hero-stats:empty,
.about-facts:empty,
.impact-list:empty,
.projects-grid:empty,
.timeline:empty,
.stack-grid:empty,
.contact-links:empty,
.citation:empty {
  display: none;
}

@media (max-width: 1023px) {
  .experience-header {
    display: block;
  }
  .experience-title-group .section-sub {
    margin-bottom: 16px;
  }
  .timeline-caption {
    display: none;
  }
  .timeline-axis {
    display: none;
  }
  .timeline,
  .timeline-strip {
    display: block;
    margin-top: 0;
  }
  .timeline::before,
  .timeline-strip::before {
    display: none;
  }
  .timeline-card {
    border-left: 2px solid var(--line);
    padding-left: 16px;
    padding-top: 0;
    width: auto;
  }
  .timeline-card::before,
  .timeline-marker {
    top: 0;
    left: -6px;
  }
}

@media (max-width: 1023px) and (min-width: 641px) {
  .band-secondary {
    grid-template-columns: repeat(2, 1fr);
  }
  .cell-metric {
    border-left: none;
    border-top: none;
  }
  .cell-metric:nth-child(2) {
    border-left: 1px solid var(--line);
  }
  .cell-metric:nth-child(3) {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: none;
  }
}

@media (max-width: 640px) {
  .band-secondary {
    grid-template-columns: 1fr;
  }
  .cell-metric {
    grid-column: auto;
    border-left: none;
  }
  .cell-metric + .cell-metric {
    border-top: 1px solid var(--line);
    border-left: none;
  }
}

@media (max-width: 960px) {
  .band-hero {
    grid-template-columns: 1fr;
  }
  .hero-editorial {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 28px 20px;
  }
  .hero-readout {
    padding: 28px 20px;
  }
  .band-proof {
    grid-template-columns: 1fr;
  }
  .projects-column {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 599px) {
  body {
    padding: 0 12px 32px;
  }
  .site-header {
    padding: 16px 0 12px;
  }
  .hero-editorial,
  .hero-readout,
  .cell-metric,
  .pipeline-column,
  .projects-column,
  .quality-column,
  .band-skills,
  .band-experience,
  .band-about,
  .band-contact {
    padding: 20px 16px;
  }
  .hero-title {
    font-size: 22px;
  }
  .readout-huge {
    font-size: 42px;
  }
  .cell-figure {
    font-size: 26px;
  }
  .proof-table th,
  .proof-table td {
    padding: 8px 6px;
  }

  /* Phone pipeline variant visible; desktop variant hidden. */
  .pipeline-phone {
    display: block;
  }

  .pipeline-desktop {
    display: none;
  }

}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Case study dialog (Goal A) =====
   Native dialog elevated from the Instrument Sheet surface: hairline border,
   no shadow (house rule: hairlines, no shadows), the backdrop veil carries
   the elevation. Radius --r-md (6px) matches the diagram frame rx. */
dialog.case-modal {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(880px, calc(100vw - 32px));
  max-height: min(86vh, 920px);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: none;
  overflow: hidden;
}
dialog.case-modal:not([open]) { display: none; }
dialog.case-modal[open] { animation: case-modal-appear 160ms ease-out; }
dialog.case-modal::backdrop { background: var(--scrim); }
dialog.case-modal[open]::backdrop { animation: case-modal-backdrop-appear 160ms ease-out; }
@keyframes case-modal-appear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes case-modal-backdrop-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}
.case-modal__bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; padding: var(--sp-8) var(--sp-24);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.case-modal__kicker {
  margin: 0; font-family: var(--font-mono); font-size: var(--fs-mono-s);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em;
  line-height: 1; color: var(--muted);
}
.case-modal__close {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0 var(--sp-8);
  background: transparent; border: 0; font-family: var(--font-mono);
  font-size: var(--fs-mono); line-height: 1; color: var(--muted);
  cursor: pointer; transition: color var(--t-fast);
}
.case-modal__close:hover { color: var(--ink); }
.case-modal__body {
  flex: 1 1 auto; overflow-y: auto; overflow-x: hidden;
  padding: var(--sp-32) var(--sp-24) var(--sp-48);
  overscroll-behavior: contain;
}
.case-modal__body .pj-header,
.case-modal__body .pj-main {
  max-width: 72ch; margin-left: auto; margin-right: auto;
  padding-left: 0; padding-right: 0;
}
.case-modal__body .pj-back { display: none; }
.case-modal__body .case-diagram { display: block; width: 100%; height: auto; }
.case-modal__loading,
.case-modal__error {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 280px;
  padding: var(--sp-48) var(--sp-24); gap: var(--sp-16);
  font-family: var(--font-mono); font-size: var(--fs-mono);
  color: var(--muted); text-align: center;
}
.case-modal__error a {
  font-family: var(--font-mono); font-size: var(--fs-mono);
  text-decoration: underline; text-underline-offset: 4px;
}
.case-modal__foot {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; gap: var(--sp-16); padding: var(--sp-8) var(--sp-24);
  background: var(--surface); border-top: 1px solid var(--line);
}
.case-modal__full {
  display: inline-flex; align-items: center; min-height: 44px;
  font-family: var(--font-mono); font-size: var(--fs-mono);
}
.case-modal__hint {
  font-family: var(--font-mono); font-size: var(--fs-mono-s); color: var(--muted);
}
html.case-modal-open { overflow: hidden; }
@media (max-width: 560px) {
  dialog.case-modal {
    width: 100%; max-width: 100vw;
    height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh;
    margin: 0; border: 0; border-radius: 0;
  }
  .case-modal__bar, .case-modal__foot { padding: var(--sp-8) var(--sp-16); }
  .case-modal__body { padding: var(--sp-16); }
  .case-modal__body .pj-header, .case-modal__body .pj-main { max-width: 100%; }
}
