:root {
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max-width: 1120px;
  --radius: 8px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
}

html[data-theme="light"] {
  --bg: #f7f5f2;
  --bg-elevated: #ffffff;
  --bg-muted: #efeeeb;
  --text: #111111;
  --text-muted: #68686d;
  --line: rgba(17, 17, 17, .11);
  --line-strong: rgba(17, 17, 17, .2);
  --accent: #e53935;
  --accent-strong: #b71c1c;
  --accent-soft: rgba(229, 57, 53, .1);
}

html[data-theme="dark"] {
  --bg: #101010;
  --bg-elevated: #1b1b1d;
  --bg-muted: #242426;
  --text: #f5f5f7;
  --text-muted: #b8b8bf;
  --line: rgba(255, 255, 255, .12);
  --line-strong: rgba(255, 255, 255, .24);
  --accent: #ff453a;
  --accent-strong: #ff6b61;
  --accent-soft: rgba(255, 69, 58, .13);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--text);
}

body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font-sans);
  line-height: 1.5;
  background:
    radial-gradient(circle at 8% 4%, color-mix(in srgb, var(--accent), transparent 80%), transparent 22rem),
    radial-gradient(circle at 92% 7%, color-mix(in srgb, var(--accent-strong), transparent 84%), transparent 24rem),
    var(--bg);
  color: var(--text);
}

@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 200;
  transform: translateY(-150%);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  padding: .75rem 1rem;
  transition: transform .2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elevated), transparent 16%);
  backdrop-filter: blur(22px) saturate(1.35);
}

.nav-shell {
  width: min(100% - 2rem, var(--max-width));
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-size: 1rem;
  font-weight: 850;
  white-space: nowrap;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
}

main {
  width: min(100% - 2rem, var(--max-width));
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6.5rem) 0 4rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, .78fr) minmax(260px, .32fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: end;
  padding-bottom: clamp(4rem, 9vw, 7rem);
}

.eyebrow,
.project-number {
  margin: 0;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 9ch;
  margin-bottom: 0;
  font-size: clamp(4rem, 13vw, 8rem);
  line-height: .9;
  letter-spacing: -.02em;
  text-transform: lowercase;
}

h2 {
  margin: .45rem 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(2rem, 4.2vw, 3.65rem);
  line-height: .98;
  letter-spacing: -.045em;
}

.hero-copy {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: clamp(1.04rem, 2vw, 1.22rem);
}

.project-list {
  display: grid;
  gap: clamp(4rem, 9vw, 7rem);
}

.analysis-project {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(360px, 1.1fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: clamp(1.5rem, 3vw, 2.25rem);
}

.analysis-project:nth-child(even) .project-copy {
  order: 2;
}

.analysis-project:nth-child(even) .analysis-visual {
  order: 1;
}

.project-copy {
  min-width: 0;
}

.project-summary {
  margin: 1.35rem 0;
  color: var(--text);
  font-size: clamp(1.04rem, 1.8vw, 1.2rem);
  font-weight: 720;
}

.project-copy > p:not(.project-number):not(.project-summary) {
  color: var(--text-muted);
}

.tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1.6rem 0 0;
  padding: 0;
  list-style: none;
}

.tool-list li {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-elevated), transparent 12%);
  color: var(--text-muted);
  font-size: .74rem;
  font-weight: 760;
  padding: .44rem .68rem;
}

.project-link {
  width: fit-content;
  min-height: 44px;
  margin-top: 1.5rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  box-shadow: 0 16px 36px color-mix(in srgb, var(--accent), transparent 76%);
  color: #ffffff;
  font-size: .86rem;
  font-weight: 820;
  padding: .7rem .9rem;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}

.project-link:hover,
.project-link:focus-visible {
  background: var(--accent-strong);
  box-shadow: 0 20px 44px color-mix(in srgb, var(--accent), transparent 68%);
  outline: none;
  transform: translateY(-2px);
}

.analysis-visual {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent), transparent 92%), transparent 45%),
    color-mix(in srgb, var(--bg-elevated), transparent 4%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .1);
  padding: clamp(1.1rem, 3vw, 1.75rem);
}

.visual-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

.visual-heading span {
  color: var(--text-muted);
  font-size: .74rem;
  font-weight: 820;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.visual-heading strong {
  color: var(--accent);
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  line-height: 1;
}

.visual-note {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: .8rem;
}

.confusion-matrix {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}

.confusion-matrix div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in srgb, var(--bg-muted), transparent 26%);
  padding: .9rem;
}

.confusion-matrix strong {
  display: block;
  font-size: 1.45rem;
}

.confusion-matrix span {
  color: var(--text-muted);
  font-size: .72rem;
}

.bar-chart {
  margin-top: 1.35rem;
  display: grid;
  gap: .8rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(7.5rem, .7fr) minmax(8rem, 1fr) 2.8rem;
  gap: .65rem;
  align-items: center;
}

.bar-row > span,
.bar-row > strong {
  font-size: .72rem;
}

.bar-row > span {
  color: var(--text-muted);
  font-weight: 720;
}

.bar-row > strong {
  text-align: right;
}

.bar-track {
  height: .55rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-muted);
}

.bar-fill {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
}

.width-100 { width: 100%; }
.width-93 { width: 93%; }
.width-92 { width: 92%; }
.width-90 { width: 90%; }
.width-88 { width: 88%; }
.width-83 { width: 83%; }

.line-chart {
  width: 100%;
  height: auto;
  margin-top: 1rem;
  overflow: visible;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.country-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.country-line.chile { stroke: #ff453a; }
.country-line.china { stroke: #ff9f0a; }
.country-line.germany { stroke: #64d2ff; }
.country-line.mexico { stroke: #30d158; }
.country-line.usa { stroke: #bf5af2; }
.country-line.zimbabwe { stroke: #f5f5f7; }

html[data-theme="light"] .country-line.zimbabwe {
  stroke: #111111;
}

.axis-label {
  fill: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
}

.axis-label-end {
  text-anchor: end;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .55rem;
}

.metric-grid div {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: .8rem;
}

.metric-grid strong,
.metric-grid span {
  display: block;
}

.metric-grid strong {
  color: var(--accent);
  font-size: 1.08rem;
}

.metric-grid span {
  color: var(--text-muted);
  font-size: .66rem;
}

.correlation-chart {
  margin-top: 1.5rem;
}

.model-stat {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .2rem 1rem;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.model-stat span,
.model-stat small {
  color: var(--text-muted);
  font-size: .72rem;
}

.model-stat strong {
  grid-row: 1 / span 2;
  grid-column: 2;
  color: var(--accent);
  font-size: 1.5rem;
}

.region-chart {
  min-height: 17rem;
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.region-column {
  height: 16rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: .4rem;
  align-items: end;
  text-align: center;
}

.region-column strong {
  color: var(--text-muted);
  font-size: .7rem;
}

.region-column small {
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 820;
  padding-bottom: .5rem;
}

.region-bar {
  width: min(100%, 3.2rem);
  min-height: 1rem;
  margin: 0 auto;
  align-self: end;
  border-radius: .35rem .35rem 0 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
}

.height-98 { height: 98%; }
.height-89 { height: 89%; }
.height-83 { height: 83%; }
.height-82 { height: 82%; }

.cost-comparison {
  margin-top: 1.2rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
}

.cost-comparison > div {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in srgb, var(--bg-muted), transparent 30%);
  padding: .85rem;
}

.cost-comparison span,
.cost-comparison strong {
  display: block;
}

.cost-comparison span {
  color: var(--text-muted);
  font-size: .7rem;
}

.cost-comparison strong {
  margin-top: .25rem;
}

.cost-comparison p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--text-muted);
  font-size: .78rem;
  text-align: right;
}

.cost-comparison p strong {
  display: inline;
  color: var(--accent);
  font-size: 1rem;
}

.site-footer {
  width: min(100% - 2rem, var(--max-width));
  margin: clamp(5rem, 12vw, 9rem) auto 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2rem;
  color: var(--text-muted);
  font-size: .9rem;
}

@media (prefers-reduced-motion: no-preference) {
  .hero > * {
    opacity: 0;
    transform: translateY(20px);
    animation: analysis-rise .72s var(--ease-out) both;
  }

  .hero > *:nth-child(2) {
    animation-delay: .12s;
  }

  .analysis-project {
    animation: analysis-rise .72s var(--ease-out) both;
    animation-delay: calc(.12s + var(--i, 0) * 80ms);
  }
}

@keyframes analysis-rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-project {
    grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr);
    gap: 2.5rem;
  }
}

@media (max-width: 760px) {
  .analysis-project {
    grid-template-columns: 1fr;
  }

  .analysis-project:nth-child(even) .project-copy,
  .analysis-project:nth-child(even) .analysis-visual {
    order: initial;
  }
}

@media (max-width: 620px) {
  .nav-shell,
  main,
  .site-footer {
    width: min(100% - 1.25rem, var(--max-width));
  }

  .nav-shell {
    min-height: auto;
    padding: .75rem 0;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(3.6rem, 20vw, 6rem);
  }

  .bar-row {
    grid-template-columns: minmax(6.3rem, .8fr) minmax(5rem, 1fr) 2.5rem;
    gap: .45rem;
  }

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

  .site-footer {
    flex-direction: column;
  }
}
