:root {
  --color-bg:      #fafaf7;
  --color-surface: #f0efe9;
  --color-text:    #1a1a1a;
  --color-muted:   #6b6b6b;
  --color-border:  #dcdcd4;
  --color-win:     #2d6a4f;
  --color-loss:    #c1440e;
  --color-neutral: #8d8d8d;
  --color-accent:  #e8a838;
  --font-serif:    'Playfair Display', Georgia, serif;
  --font-sans:     'DM Sans', system-ui, sans-serif;
  --text-hero:     clamp(2.4rem, 6vw, 4.2rem);
  --text-h2:       clamp(1.4rem, 3vw, 2rem);
  --text-body:     1rem;
  --text-label:    0.8rem;
  --text-caption:  0.72rem;
  --max-prose:     640px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.7;
  margin: 0;
}

h1, h2, h3 { font-family: var(--font-serif); line-height: 1.2; }
p { max-width: var(--max-prose); }

/* ── INTRO ───────────────────────────────────────────── */
#intro {
  padding: 5rem 2rem 4rem;
  display: flex;
  justify-content: center;
}

.prose-col {
  width: 100%;
  max-width: 680px;
}

h1 {
  font-size: var(--text-hero);
  margin: 0.25rem 0 0.5rem;
}

.subhead {
  font-family: var(--font-sans);
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--color-muted);
  margin: 0 0 2rem;
  max-width: var(--max-prose);
}

.byline {
  font-size: var(--text-label);
  color: var(--color-muted);
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}

h2 {
  font-size: var(--text-h2);
  margin: 2.5rem 0 0.75rem;
}

.pull-quote {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  border-top: 2px solid var(--color-text);
  border-bottom: 2px solid var(--color-text);
  padding: 0.8rem 0;
  margin: 2rem 0;
  line-height: 1.3;
  font-style: normal;
}

/* ── DEMO BUTTON ─────────────────────────────────────── */
.demo-btn {
  display: inline-block;
  margin: 0 0 2rem;
  padding: 0.55rem 1.2rem;
  font-family: var(--font-sans);
  font-size: var(--text-label);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
  border-radius: 3px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.demo-btn:hover {
  background: var(--color-accent);
  color: var(--color-bg);
}

/* ── THESIS BANNER ───────────────────────────────────── */
#thesis-banner {
  background: var(--color-surface);
  border-top: 2px solid var(--color-border);
  border-bottom: 2px solid var(--color-border);
  padding: 3rem 2rem;
  text-align: center;
}

.banner-label {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin: 0 0 1.5rem;
  max-width: none;
}

.stat-cards {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin: 0 auto 1.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 200px;
}

.stat-num {
  font-family: var(--font-serif);
  font-size: var(--text-hero);
  line-height: 1;
  color: var(--color-text);
}

.stat-sub {
  font-family: var(--font-sans);
  font-size: var(--text-label);
  color: var(--color-muted);
  text-align: center;
  margin-top: 0.4rem;
}

.banner-cta {
  font-style: italic;
  color: var(--color-muted);
  font-size: var(--text-label);
  margin: 0;
  max-width: none;
}

/* ── SCROLL CONTAINER ────────────────────────────────── */
#scroll-container {
  display: flex;
  align-items: flex-start;
  position: relative;
}

#narrative {
  width: 40%;
  padding: 15vh 2rem 2rem 3rem;
}

.scroll-step {
  background: var(--color-bg);
  border-left: 3px solid var(--color-border);
  padding: 1.5rem 1.5rem 1.5rem 1.2rem;
  margin: 0 0 80vh 0;
  max-width: 420px;
  transition: border-left-color 0.25s ease;
}

.scroll-step.is-active {
  border-left-color: var(--color-accent);
}

.scroll-step p {
  margin: 0 0 0.8rem;
  max-width: none;
}

.scroll-step p:last-child { margin-bottom: 0; }

.step-footer {
  font-size: var(--text-caption);
  color: var(--color-muted);
  font-style: italic;
}

#viz-panel {
  width: 60%;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: sticky;
  top: 0;
}

#viz-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
}

#main-svg {
  width: 100%;
  height: auto;
  overflow: visible;
  display: block;
}

#controls {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── TOOLTIP ─────────────────────────────────────────── */
#tooltip {
  position: absolute;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
  font-size: var(--text-label);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 200px;
  line-height: 1.4;
  z-index: 10;
}

#tooltip.visible { opacity: 1; }

/* ── HOST CARD CAROUSEL ──────────────────────────────── */
#host-cards-section {
  background: var(--color-surface);
  padding: 4rem 2.5rem;
}

.host-cards-grid {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 4rem;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
}

.host-cards-left {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-flipper {
  perspective: 900px;
  width: 100%;
  height: 480px;
  z-index: 1;
}

.host-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1.5px solid var(--color-border);
  border-top: 4px solid var(--color-accent);
  overflow: hidden;
  position: relative;
  transition: transform 0.25s ease;
  box-sizing: border-box;
  box-shadow:
    0 2px 4px rgba(80,60,20,0.06),
    0 8px 20px rgba(80,60,20,0.10),
    0 18px 40px rgba(80,60,20,0.08);
}

/* ── HEADER BAND ── */
.card-header {
  background: var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 1.1rem 1.2rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}

.hd-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-country {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}

.card-year {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-top: 0.18rem;
}

.card-flag {
  font-size: 4.4rem;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.12));
}

/* ── CARD BODY ── */
.card-body {
  background: var(--color-surface);
  padding: 1.1rem 1.2rem 1.2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.card-stat-cell { padding-bottom: 0.7rem; }

.card-stat-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--color-muted);
  margin-bottom: 0.15rem;
}

.card-stat-value {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
}

.card-delta-value { font-size: 2.4rem; }

.card-stat-value.positive { color: var(--color-win); }
.card-stat-value.negative { color: var(--color-loss); }

.card-divider {
  height: 1px;
  background: var(--color-border);
  border: none;
  margin: 0.2rem 0 0.75rem;
}

.card-results {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--color-muted);
}

.card-results .upset { color: var(--color-accent); font-weight: 500; margin-left: 0.5em; }

.card-note {
  font-family: var(--font-sans);
  font-size: 0.73rem;
  font-style: italic;
  color: var(--color-muted);
  line-height: 1.55;
  margin: 0.5rem 0 0;
}

.card-flip-btn {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(0,0,0,0.12);
  color: var(--color-accent);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}

.card-flip-btn:hover { background: rgba(0,0,0,0.28); }
.card-flip-btn.hidden { display: none; }

.card-dots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.card-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid #444;
  opacity: 0.6;
  transition: background 0.2s, opacity 0.2s;
}

.card-dot.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  opacity: 1;
}

/* right column static text */
.host-cards-heading {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 1rem;
  max-width: none;
}

.host-cards-body {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.75;
  color: var(--color-muted);
  margin: 0 0 0.8rem;
  max-width: none;
}

/* spread mode */
#host-cards-section.spread-mode .host-cards-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  justify-content: center;
  align-items: stretch;
  max-width: none;
}

#host-cards-section.spread-mode .host-cards-left {
  flex: 0 0 calc((100% - 5rem) / 6);
  min-width: 0;
  position: relative;
}

#host-cards-section.spread-mode .host-cards-right { display: none; }
#host-cards-section.spread-mode .card-flipper { flex: 1; height: auto; }
#host-cards-section.spread-mode .host-card { height: 100%; }
#host-cards-section.spread-mode .card-dots { display: none; }
#host-cards-section.spread-mode .card-note { margin-top: auto; padding-top: 0.5rem; }

#host-cards-section.spread-mode .card-country    { font-size: 1.04rem; }
#host-cards-section.spread-mode .card-flag       { font-size: 2.75rem; }
#host-cards-section.spread-mode .card-year       { font-size: 0.7rem; }
#host-cards-section.spread-mode .card-stat-value { font-size: 1rem; }
#host-cards-section.spread-mode .card-delta-value { font-size: 1.83rem; }
#host-cards-section.spread-mode .card-stat-label { font-size: 0.55rem; }
#host-cards-section.spread-mode .card-results    { font-size: 0.72rem; }
#host-cards-section.spread-mode .card-note       { font-size: 0.65rem; }
#host-cards-section.spread-mode .card-flip-btn   { display: none; }

/* ── CONCLUSION ──────────────────────────────────────── */
#conclusion {
  padding: 5rem 2rem;
  display: flex;
  justify-content: center;
}

.conclusion-cards {
  margin-top: 3rem;
}

.conclusion-cards .stat-card {
  border-top: 2px solid var(--color-border);
  padding-top: 1rem;
}

/* ── TA WRITEUP ──────────────────────────────────────── */
#ta-writeup {
  background: var(--color-surface);
  border-top: 2px dashed var(--color-border);
  padding: 3rem 2rem;
  display: flex;
  justify-content: center;
}

.ta-inner {
  width: 100%;
  max-width: 680px;
}

.ta-label {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin: 0 0 1rem;
  max-width: none;
}

#ta-writeup h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin: 0 0 1rem;
}

#ta-writeup p {
  color: var(--color-text);
  margin: 0 0 0.9rem;
}

/* ── SVG SHARED STYLES ───────────────────────────────── */
.axis text {
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  fill: var(--color-muted);
}

.axis line, .axis path {
  stroke: var(--color-border);
}

.annotation {
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  fill: var(--color-muted);
}

.annotation-gold {
  fill: var(--color-accent);
  font-weight: 500;
  font-family: var(--font-sans);
}

#callout-strip {
  min-height: 80px;
  padding: 1rem 1.5rem 0.5rem;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#callout-strip.is-visible {
  opacity: 1;
}

/* ── ERA FILTER BUTTONS ──────────────────────────────── */
#era-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0 0.25rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

#era-note {
  width: 100%;
  margin: 0.1rem 0 0;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--color-muted);
  line-height: 1.5;
  text-align: center;
  display: none;
}

#era-filter.visible {
  opacity: 1;
  pointer-events: all;
}

.era-btn {
  font-family: var(--font-sans);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.era-btn:hover {
  color: var(--color-text);
  border-color: var(--color-muted);
}

.era-btn.active {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: transparent;
}
