:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --surface: #ffffff;
  --surface-strong: #eef3ef;
  --panel: #f1f5f7;
  --text: #17201a;
  --muted: #5f6d66;
  --border: #d8e0dc;
  --accent: #167f7c;
  --accent-2: #d14c32;
  --accent-3: #e1a83a;
  --ink-on-dark: #f8fafc;
  --shadow: 0 18px 50px rgba(17, 32, 26, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101413;
  --surface: #171d1b;
  --surface-strong: #1f2825;
  --panel: #202a2d;
  --text: #eef4f0;
  --muted: #a8b5ae;
  --border: #33413c;
  --accent: #5fd0c8;
  --accent-2: #ff8a63;
  --accent-3: #f3c766;
  --ink-on-dark: #f8fafc;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

.testing-project-page {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(22, 127, 124, 0.08), transparent 42rem),
    var(--bg);
  color: var(--text);
  font-family: inherit;
  line-height: 1.5;
}

.testing-project-shell img,
.testing-project-shell svg {
  max-width: 100%;
}

.testing-project-shell a {
  color: inherit;
}

.testing-project-shell button,
.testing-project-shell summary {
  font: inherit;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.75rem;
  z-index: 100;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--ink-on-dark);
}

.skip-link:focus {
  left: 0.75rem;
}

.testing-project-shell .site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.testing-project-shell .header-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.7rem 0;
}

.testing-project-shell .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: max-content;
  text-decoration: none;
  font-weight: 800;
}

.testing-project-shell .brand-mark {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 65% 35%, var(--accent-3) 0 22%, transparent 23%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 14%, transparent);
}

.testing-project-shell .story-nav {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.testing-project-shell .story-nav::-webkit-scrollbar {
  display: none;
}

.testing-project-shell .story-nav a {
  flex: 0 0 auto;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.testing-project-shell .story-nav a.active,
.testing-project-shell .story-nav a:focus-visible,
.testing-project-shell .story-nav a:hover {
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}

.testing-project-shell .theme-toggle {
  min-width: 4.8rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
}

.testing-project-shell .theme-toggle:focus-visible,
.segmented-button:focus-visible,
.challenge-card:focus-visible,
.emotion-tab:focus-visible,
.testing-project-shell summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.testing-project-shell .progress-track {
  height: 3px;
  background: transparent;
}

.testing-project-shell .progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
}

.testing-project-shell {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
}

.intro-section {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: center;
  min-height: calc(92svh - 4.3rem);
  padding: clamp(1.25rem, 4vw, 3rem) 0;
}

.intro-media {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  grid-template-rows: 1fr 1fr;
  gap: 0.75rem;
  min-height: 34rem;
}

.intro-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-media img:first-child {
  grid-row: 1 / 3;
}

.article-preview {
  align-self: stretch;
  min-height: 34rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.article-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.35rem;
  padding: 0.35rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong);
}

.article-preview h3 {
  max-width: none;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0;
}

.article-preview a {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 900;
  text-decoration: none;
}

.article-preview a:hover,
.article-preview a:focus-visible {
  text-decoration: underline;
}

.article-preview iframe {
  display: block;
  width: 100%;
  height: calc(100% - 2.35rem);
  min-height: 30.8rem;
  border: 0;
  background: var(--panel);
}

.intro-copy {
  max-width: 43rem;
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.testing-project-shell h1,
.testing-project-shell h2,
.testing-project-shell h3,
.testing-project-shell p {
  overflow-wrap: anywhere;
}

.testing-project-shell h1 {
  max-width: 15ch;
  margin: 0;
  font-size: clamp(2.2rem, 4.4vw, 4.1rem);
  line-height: 1.0;
  letter-spacing: 0;
}

.testing-project-shell h2 {
  margin: 0;
  max-width: 24ch;
  font-size: clamp(1.7rem, 3.2vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.lede {
  max-width: 38rem;
  margin: 1.35rem 0 0;
  color: var(--muted);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 2rem 0;
}

.metric-grid div {
  min-height: 7.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 35px rgba(17, 32, 26, 0.08);
}

.metric-grid dt {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-grid dd {
  margin: 0;
  color: var(--accent-2);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
  line-height: 1;
}

.metric-grid .period-value {
  font-size: clamp(1.45rem, 3vw, 2.35rem);
}

.abstract-drawer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.abstract-drawer summary {
  width: max-content;
  max-width: 100%;
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
}

.abstract-drawer p {
  max-width: 66ch;
  color: var(--muted);
}

.step {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: center;
  min-height: calc(92svh - 4.3rem);
  padding: clamp(1.75rem, 4.5vw, 3.5rem) 0;
  border-top: 1px solid var(--border);
}

.visual-step {
  align-items: stretch;
}

.visual-step .visual-column {
  display: flex;
  align-items: center;
  justify-content: center;
}

.visual-column {
  position: relative;
  min-width: 0;
}

.story-copy {
  align-self: center;
  max-width: 35rem;
}

.step-copy {
  max-width: 60ch;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.2rem);
}

.hero-visual {
  position: relative;
  width: 100%;
  max-width: 760px;
  height: min(50svh, 32rem);
  min-height: 22rem;
  overflow: hidden;
  border-radius: 8px;
  background: #111827;
  box-shadow: var(--shadow);
}

.hero-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 1600ms ease-in-out, transform 2600ms ease-in-out;
  will-change: opacity, transform;
}

.hero-visual img.active {
  opacity: 1;
  transform: scale(1);
}

.hero-captions,
.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.3rem 0 0.8rem;
}

.chart-toolbar {
  margin-top: 0;
}

.emotion-tab,
.segmented-button {
  min-height: 2.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
}

.emotion-tab {
  padding: 0.5rem 0.7rem;
}

.segmented-button {
  padding: 0.45rem 0.75rem;
}

.emotion-tab.active,
.emotion-tab[aria-selected="true"],
.segmented-button.active,
.segmented-button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 13%, var(--surface));
  color: var(--text);
}

.insight-stack {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.insight-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  opacity: 1;
  transform: translateX(0);
  transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.insight-stack .insight-panel {
  margin-top: 0;
  opacity: 0.62;
}

.insight-panel.active {
  opacity: 1;
  transform: translateX(4px);
  box-shadow: 0 12px 30px rgba(17, 32, 26, 0.12);
}

.insight-panel p {
  margin: 0;
}

.image-source {
  display: block;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.image-source a {
  color: var(--accent);
  font-weight: 800;
}

.tone-teal {
  --tone: var(--accent);
  border-left-color: var(--tone);
  background: color-mix(in srgb, var(--tone) 10%, var(--surface));
}

.tone-amber {
  --tone: var(--accent-3);
  border-left-color: var(--tone);
  background: color-mix(in srgb, var(--tone) 14%, var(--surface));
}

.tone-coral {
  --tone: var(--accent-2);
  border-left-color: var(--tone);
  background: color-mix(in srgb, var(--tone) 10%, var(--surface));
}

.tone-blue {
  --tone: #367dc0;
  border-left-color: var(--tone);
  background: color-mix(in srgb, var(--tone) 10%, var(--surface));
}

.tone-green {
  --tone: #18885a;
  border-left-color: var(--tone);
  background: color-mix(in srgb, var(--tone) 10%, var(--surface));
}

:root[data-theme="dark"] .tone-blue {
  --tone: #83bfff;
}

:root[data-theme="dark"] .tone-green {
  --tone: #5fd58f;
}

.chart {
  position: relative;
  width: 100%;
  height: min(60svh, 39rem);
  min-height: 22rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 12px 38px rgba(17, 32, 26, 0.1);
}

.chart svg {
  display: block;
}

.chart text {
  fill: var(--text);
}

.chart .labels text,
.chart .row-label text,
.chart .slice-label text,
.chart .label text {
  fill: #fff;
}

.chart .tick line,
.chart path.domain {
  stroke: color-mix(in srgb, var(--text) 22%, transparent);
}

.chart.is-emphasized {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 16px 44px color-mix(in srgb, var(--accent) 18%, transparent);
}

.chart-half {
  height: min(38svh, 25rem);
  min-height: 17rem;
}

.stacked-visuals {
  display: grid;
  gap: 0.75rem;
}

.chart-note {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.annotation {
  position: absolute;
  inset: auto 1rem 1rem 1rem;
  pointer-events: none;
}

.annotation .callout {
  display: inline-block;
  margin: 0.25rem 0.25rem 0 0;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-size: 0.85rem;
}

.tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  max-width: min(18rem, calc(100vw - 2rem));
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.94);
  color: #fff;
  font-size: 0.78rem;
  opacity: 0;
  transform: translate(-50%, -120%);
  transition: opacity 150ms ease;
}

.tooltip.show {
  opacity: 1;
}

.final-step {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-items: start;
}

.span-copy {
  grid-column: 1 / -1;
  max-width: none;
}

.challenge-cards {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.challenge-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  width: 100%;
  min-height: 10rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 32px rgba(17, 32, 26, 0.08);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.challenge-card:hover,
.challenge-card.active {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, currentColor 44%, var(--border));
  background: color-mix(in srgb, currentColor 8%, var(--surface));
}

.challenge-icon {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  background: color-mix(in srgb, currentColor 16%, transparent);
  color: currentColor;
  font-size: 0.72rem;
  font-weight: 900;
}

.challenge-card strong {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

.challenge-card small {
  color: var(--muted);
  font-size: 0.9rem;
}

.accent-green {
  color: #18885a;
}

.accent-amber {
  color: #a86704;
}

.accent-red {
  color: #b33d2d;
}

.accent-blue {
  color: #276fae;
}

:root[data-theme="dark"] .accent-green {
  color: #5fd58f;
}

:root[data-theme="dark"] .accent-amber {
  color: #f1be5a;
}

:root[data-theme="dark"] .accent-red {
  color: #ff8a70;
}

:root[data-theme="dark"] .accent-blue {
  color: #83bfff;
}

.testing-project-shell .site-footer {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.testing-project-shell .site-footer p {
  margin: 0.2rem 0;
}

.testing-project-shell .site-footer a {
  color: var(--text);
  font-weight: 800;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

@media (max-width: 1050px) {
  .testing-project-shell .header-main {
    grid-template-columns: 1fr auto;
  }

  .testing-project-shell .story-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    order: 3;
    padding-bottom: 0.1rem;
  }

  .intro-section,
  .step {
    grid-template-columns: 1fr;
  }

  .article-preview {
    min-height: 28rem;
    order: 2;
  }

  .article-preview iframe {
    min-height: 24.8rem;
  }

  .intro-copy,
  .story-copy {
    max-width: 48rem;
  }

  .testing-project-shell h1,
  .testing-project-shell h2 {
    max-width: 16ch;
  }

  .final-step {
    grid-template-columns: 1fr;
  }

  .challenge-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .testing-project-shell,
  .testing-project-shell .header-main,
  .testing-project-shell .site-footer {
    width: min(100% - 1rem, 1240px);
  }

  .testing-project-shell .brand span:last-child {
    max-width: 12rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .testing-project-shell .theme-toggle {
    min-width: 4.1rem;
  }

  .intro-section,
  .step {
    min-height: auto;
    padding: 1.75rem 0;
  }

  .article-preview {
    min-height: 25rem;
  }

  .article-preview iframe {
    min-height: 21.8rem;
  }

  .metric-grid,
  .challenge-cards {
    grid-template-columns: 1fr;
  }

  .metric-grid div {
    min-height: 5.8rem;
  }

  .chart {
    min-height: 19rem;
    height: 58svh;
  }

  .hero-visual {
    min-height: 16rem;
    height: 42svh;
  }

  .chart-half {
    min-height: 16rem;
    height: 42svh;
  }
}

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