/* Data Story - Scrollytelling Styles */

:root {
  --bg: #F5F0E8;
  --text: #1A1613;
  --text-mid: #4A4039;
  --text-light: #9B9083;
  --rule: #D4C9B8;
  --green: #22C55E;
  --green-muted: #86EFAC;
  --red: #EF4444;
  --red-muted: #FCA5A5;
  --blue: #3B82F6;
  --orange: #F97316;
  --purple: #A855F7;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

body {
  font-family: 'Source Serif 4', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Scroll sections */
.scroll-container {
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
}

.section {
  height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  position: relative;
}

/* Section content wrapper */
.section-inner {
  max-width: 900px;
  width: 100%;
  text-align: center;
}

/* Typography */
.section-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 1rem;
  opacity: calc(var(--progress, 0) * 2);
  transform: translateY(calc(20px * (1 - var(--progress, 0))));
}

.section-title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  opacity: calc(var(--progress, 0) * 1.5);
  transform: translateY(calc(30px * (1 - var(--progress, 0))));
  text-wrap: balance;
}

.section-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--text-mid);
  margin-bottom: 2.5rem;
  opacity: calc(var(--progress, 0) * 1.2 - 0.1);
  transform: translateY(calc(20px * (1 - var(--progress, 0))));
}

/* Chart container */
.chart-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}

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

/* SVG base styles */
svg text {
  font-family: 'Inter', sans-serif;
}

svg .axis-label {
  font-size: 11px;
  fill: var(--text-light);
}

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

svg .grid-line {
  stroke: var(--rule);
  stroke-width: 0.5;
  stroke-dasharray: 2, 4;
}

svg .data-label {
  font-size: 12px;
  font-weight: 600;
  fill: var(--text);
  opacity: calc(var(--progress, 0) * 2 - 0.5);
}

svg .annotation {
  font-size: 11px;
  fill: var(--text-mid);
  opacity: calc(var(--progress, 0) * 3 - 2);
}

/* Line chart animations */
svg .line-path {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

svg .line-path.reading {
  stroke: var(--blue);
}

svg .line-path.math {
  stroke: var(--red);
}

svg .line-path.gpa {
  stroke: var(--green);
}

svg .line-path.act {
  stroke: var(--red);
}

/* Scroll-driven line animation */
svg .line-path {
  stroke-dasharray: var(--path-length, 1000);
  stroke-dashoffset: calc(var(--path-length, 1000) * (1 - var(--progress, 0)));
}

/* Data points - fade in at end of line draw */
svg .data-point {
  fill: var(--bg);
  stroke-width: 2;
  opacity: calc(var(--progress, 0) * 2 - 1);
}

svg .data-point.reading {
  stroke: var(--blue);
}

svg .data-point.math {
  stroke: var(--red);
}

/* Highlight zones - fade in with scroll */
svg .zone-gain {
  fill: var(--green);
  opacity: calc(0.15 * var(--progress, 0));
}

svg .zone-loss {
  fill: var(--red);
  opacity: calc(0.15 * var(--progress, 0));
}

/* Bar chart - grow with scroll */
svg .bar {
  transform-origin: bottom;
  transform: scaleY(var(--progress, 0));
}

/* Stagger bars slightly based on position */
svg .bar-group:nth-child(2) .bar { transform: scaleY(calc(var(--progress, 0) * 0.95 + 0.05 * var(--progress, 0))); }
svg .bar-group:nth-child(3) .bar { transform: scaleY(calc(var(--progress, 0) * 0.9 + 0.1 * var(--progress, 0))); }

/* Bar colors */
svg .bar.white { fill: var(--blue); }
svg .bar.black { fill: var(--orange); }
svg .bar.hispanic { fill: var(--purple); }
svg .bar.gain { fill: var(--green); }
svg .bar.loss { fill: var(--red); }

/* Value callouts */
.callout {
  position: absolute;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 4px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.section.visible .callout {
  opacity: 1;
  transform: translateY(0);
}

.callout.gain {
  color: var(--green);
}

.callout.loss {
  color: var(--red);
}

/* Legend */
.legend {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  opacity: calc(var(--progress, 0) * 2 - 0.5);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-mid);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-dot.reading { background: var(--blue); }
.legend-dot.math { background: var(--red); }
.legend-dot.gpa { background: var(--green); }
.legend-dot.act { background: var(--red); }
.legend-dot.white { background: var(--blue); }
.legend-dot.black { background: var(--orange); }
.legend-dot.hispanic { background: var(--purple); }

/* Navigation dots */
.nav-dots {
  position: fixed;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 100;
}

.nav-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rule);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.nav-dot:hover {
  background: var(--text-mid);
}

.nav-dot.active {
  background: var(--text);
  transform: scale(1.3);
}

/* Back link */
.back-link {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text-mid);
  text-decoration: none;
  z-index: 100;
}

.back-link:hover {
  color: var(--text);
}

/* Scroll hint */
.scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: bounce 2s infinite;
}

.scroll-hint svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-light);
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(5px); }
}

/* Final section CTA */
.cta-link {
  display: inline-block;
  margin-top: 2rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}

.cta-link:hover {
  background: var(--text);
  color: var(--bg);
}

/* Mobile */
@media (max-width: 768px) {
  html {
    scroll-snap-type: y mandatory;
  }

  .section {
    min-height: 100vh;
    height: auto;
    padding: 1.5rem 1rem;
    justify-content: center;
    align-items: center;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .section-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-height: 100%;
  }

  .section-label {
    font-size: 0.65rem;
    margin-bottom: 0.75rem;
  }

  .section-title {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    max-width: 90%;
  }

  .section-subtitle {
    font-size: 0.9rem;
    margin-bottom: 2rem;
    max-width: 85%;
  }

  .chart-container {
    width: 100%;
    max-width: 100%;
  }

  .chart-container svg {
    width: 100%;
    height: auto;
    max-height: 45vh;
  }

  /* Simplify SVG text on mobile */
  svg .axis-label {
    font-size: 10px;
  }

  svg .data-label {
    font-size: 11px;
  }

  svg .annotation {
    font-size: 10px;
  }

  .nav-dots {
    right: 0.75rem;
    gap: 0.6rem;
  }

  .nav-dot {
    width: 4px;
    height: 4px;
  }

  .back-link {
    top: 0.75rem;
    left: 0.75rem;
    font-size: 0.7rem;
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
  }

  .legend {
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
    font-size: 0.75rem;
  }

  .chart-container {
    margin-top: 0.5rem;
  }

  .legend-dot {
    width: 10px;
    height: 10px;
  }

  .scroll-hint {
    bottom: 1rem;
    font-size: 0.6rem;
  }

  .scroll-hint svg {
    width: 16px;
    height: 16px;
  }

  .cta-link {
    font-size: 0.8rem;
    padding: 0.6rem 1.2rem;
    margin-top: 1.5rem;
  }
}

/* Extra small screens */
@media (max-width: 400px) {
  .section {
    padding: 1.25rem 1rem;
  }

  .section-title {
    font-size: 1.5rem;
    margin-bottom: 0.6rem;
  }

  .section-subtitle {
    font-size: 0.8rem;
    margin-bottom: 1.5rem;
  }

  .chart-container svg {
    max-height: 40vh;
  }

  .legend {
    gap: 0.75rem;
    font-size: 0.7rem;
    margin-top: 1.25rem;
  }
}
