/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #F8FAFB;
  --surface:   #FFFFFF;
  --text:      #111827;
  --muted:     #6B7280;
  --blue:      #2563EB;
  --blue-lt:   #93C5FD;
  --green:     #10B981;
  --amber:     #F59E0B;
  --purple:    #7C3AED;
  --border:    #E5E7EB;
  --shadow:    0 2px 16px rgba(0,0,0,.07);
  --r:         8px;
  --font:      'Inter', system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

strong { font-weight: 600; }
em { font-style: italic; }
code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .85em;
  background: #EFF6FF;
  color: var(--blue);
  padding: .1em .35em;
  border-radius: 4px;
}

/* ============================================================
   SITE HEADER (fixed nav)
   ============================================================ */

#site-header {
  height: 56px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
  box-shadow: 0 1px 12px rgba(0,0,0,0.06);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.header-brand:hover { text-decoration: none; color: var(--blue); }

.header-icon {
  width: 20px;
  height: 20px;
  color: var(--blue);
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-nav a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.header-nav a:hover { color: var(--text); text-decoration: none; }

.header-cta {
  padding: 0.4rem 0.9rem;
  background: var(--blue);
  color: #fff !important;
  border-radius: 6px;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  transition: background .15s !important;
}
.header-cta:hover { background: #1D4ED8 !important; color: #fff !important; }

@media (max-width: 480px) {
  .header-nav a:not(.header-cta) { display: none; }
}

/* ============================================================
   THREEJS WRAPPER & CANVAS
   ============================================================ */

#threejs-wrapper {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

#site-hero {
  position: absolute;
  top: 3rem;
  left: clamp(1.25rem, 5vw, 4rem);
  z-index: 2;
  pointer-events: none;
}

#hero-title {
  font-size: clamp(3.5rem, 10vw, 7rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: #fff;
  text-shadow: 0 2px 40px rgba(37,99,235,0.45), 0 1px 4px rgba(0,0,0,0.12);
}

#bg-canvas {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: block;
  z-index: 0;
  background: linear-gradient(160deg, #F0F4FF 0%, #F8FAFB 60%, #F0FFF8 100%);
}

/* Scroll driver sits on top of the sticky canvas */
#scroll-driver {
  position: relative;
  z-index: 1;
  /* Negative margin pulls it up to overlap canvas */
  margin-top: -100vh;
}

/* ============================================================
   BEAT PANELS (scroll sections over canvas)
   ============================================================ */

.beat {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 2rem 1.25rem;
  pointer-events: none; /* let scroll pass through to page */
}

@media (min-width: 768px) {
  .beat { padding: 4rem 5vw; justify-content: flex-end; }
}

.beat-content {
  pointer-events: auto;
  max-width: min(480px, 90vw);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 14px;
  padding: clamp(1.25rem, 4vw, 2rem);
  box-shadow: 0 4px 32px rgba(37,99,235,0.08), 0 1px 4px rgba(0,0,0,0.05);
}

.beat-label {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--blue);
  background: #EFF6FF;
  padding: .2em .65em;
  border-radius: 99px;
  margin-bottom: .75rem;
}

.beat h1 {
  font-size: clamp(1.3rem, 3vw, 1.75rem);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: .75rem;
}

.beat h2 {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: .65rem;
}

.beat p {
  font-size: clamp(.875rem, 2vw, .95rem);
  color: #374151;
  margin-bottom: .65rem;
}

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

.beat-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: .75rem;
  padding: .75rem 1rem;
  background: #EFF6FF;
  border-radius: var(--r);
  border-left: 3px solid var(--blue);
}

.stats-row {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin: .65rem 0;
}

.stat-card {
  background: #F0FDF4;
  border-left: 3px solid var(--green);
  border-radius: 6px;
  padding: .5rem .75rem;
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--blue);
}

.stat-num.green { color: var(--green); }

.stat-label {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .2rem;
}

.beat-caveat {
  font-size: .78rem !important;
  color: var(--muted) !important;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  margin-top: .5rem !important;
}

/* ============================================================
   SECTION DIVIDER
   ============================================================ */

.section-divider {
  position: relative;
  background: linear-gradient(135deg, #1E3A8A 0%, #1D4ED8 50%, #2563EB 100%);
  color: #fff;
  text-align: center;
  padding: 5rem 1.25rem 4rem;
  margin-top: -1px;
  overflow: hidden;
}

.divider-inner { position: relative; z-index: 1; }

.divider-headline {
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: .75rem;
}

.divider-sub {
  font-size: clamp(.9rem, 2vw, 1.1rem);
  opacity: .85;
  max-width: 56ch;
  margin: 0 auto;
}

/* ============================================================
   HISTORY TIMELINE — RIVER
   ============================================================ */

#history-timeline {
  position: relative;
  background: linear-gradient(to bottom, var(--bg) 60%, #1E3A8A 100%);
  padding: 4rem 0 0;
  overflow: hidden;
}

/* Full-section river SVG, drawn by JS */
#river-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}

.timeline-track {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem 5rem;
  z-index: 1;
}

/* Timeline event row */
.tl-event {
  position: relative;
  display: flex;
  align-items: flex-start;
  margin-bottom: 4rem;
  z-index: 1;
}

/* Dot — centered on track, JS may move it via --dot-x */
.tl-dot {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 1.35rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--blue);
  z-index: 3;
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
  flex-shrink: 0;
  transition: left .4s ease;
}

.tl-dot-big {
  width: 22px;
  height: 22px;
  background: var(--blue);
  border-color: #1D4ED8;
  box-shadow: 0 0 0 6px rgba(37,99,235,.22), 0 0 20px rgba(37,99,235,.3);
}

/* Cards alternate left/right — wider river gap */
.tl-left  { justify-content: flex-start;  padding-right: calc(50% + 2.5rem); }
.tl-right { justify-content: flex-end;    padding-left:  calc(50% + 2.5rem); }

/* Viral event: full-width card, centered */
.tl-viral {
  justify-content: center;
  padding: 0;
  min-height: 280px;
  align-items: center;
}

.tl-card-viral {
  max-width: 440px;
  text-align: center;
  border-left: none !important;
  border-top: 4px solid #2563EB;
  position: relative;
  z-index: 2;
}

@media (max-width: 767px) {
  .tl-left,
  .tl-right {
    justify-content: flex-start;
    padding-left: 3rem;
    padding-right: 0;
  }
  .tl-dot { left: 1.5rem; }
  .tl-viral { padding: 0; }
}

.tl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
  max-width: 380px;
  width: 100%;
}

/* Left-border era colouring */
[data-era="early"]  .tl-card { border-left: 4px solid #BFDBFE; }
[data-era="middle"] .tl-card { border-left: 4px solid #60A5FA; }
[data-era="recent"] .tl-card { border-left: 4px solid #3B82F6; }
[data-era="now"]    .tl-card { border-left: 4px solid #1D4ED8; }

.tl-highlight .tl-card {
  box-shadow: 0 4px 28px rgba(37,99,235,.18);
}


.tl-year {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: .35rem;
}

.tl-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .4rem;
}

.tl-card p {
  font-size: .875rem;
  color: #374151;
  line-height: 1.6;
}

.tl-link {
  display: inline-block;
  margin-top: .65rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--blue);
}

/* ============================================================
   REVEAL ANIMATION (IntersectionObserver)
   ============================================================ */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity .55s ease, transform .55s ease;
}

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

/* ============================================================
   CARDS SECTION
   ============================================================ */

#viral-tweet-inner {
  max-width: 550px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

#cards-section {
  background: #1E3A8A;
  padding: 4rem 1.25rem 5rem;
}

.cards-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .cards-inner { grid-template-columns: repeat(3, 1fr); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.card-icon {
  width: 40px;
  height: 40px;
  color: var(--blue);
}
.card-icon--green  { color: var(--green); }
.card-icon--purple { color: var(--purple); }

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.card-journal {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.card-body {
  font-size: .9rem;
  color: #374151;
}

.card-stats {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .875rem;
}

.card-stats li { display: flex; gap: .4rem; align-items: baseline; }
.card-stats li strong { font-size: 1rem; color: var(--blue); }

.card-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  font-size: .875rem;
  color: #374151;
  flex: 1;
}

.card-list li {
  padding-left: 1.1rem;
  position: relative;
}

.card-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--blue);
  font-size: .75rem;
  top: .15em;
}

.card-timeline {
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: .65rem;
}

.card-cta {
  display: inline-block;
  margin-top: auto;
  padding: .6rem 1.25rem;
  background: var(--blue);
  color: #fff;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
  text-align: center;
  transition: background .2s;
  text-decoration: none;
}
.card-cta:hover { background: #1D4ED8; text-decoration: none; }
.card-cta--green  { background: var(--green); }
.card-cta--green:hover  { background: #059669; }
.card-cta--purple { background: var(--purple); }
.card-cta--purple:hover { background: #6D28D9; }

/* ============================================================
   FOOTER
   ============================================================ */

#site-footer {
  background: #0D1B3E;
  color: #93C5FD;
  padding: 3.5rem 1.25rem 2rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 2.5rem;
}

.footer-brand strong {
  display: block;
  color: #DBEAFE;
  font-size: 1.1rem;
  margin-bottom: .5rem;
}

.footer-brand p {
  font-size: .8rem;
  line-height: 1.6;
  max-width: 38ch;
}

.footer-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem 1.25rem;
}

@media (min-width: 640px)  { .footer-nav { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .footer-nav { grid-template-columns: repeat(5, 1fr); } }

.footer-col h3 {
  color: #BFDBFE;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: .65rem;
}

.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: .35rem; }

.footer-col a {
  color: #93C5FD;
  font-size: .8rem;
  transition: color .15s;
  text-decoration: none;
}
.footer-col a:hover { color: #DBEAFE; }

.footer-legal {
  border-top: 1px solid rgba(147,197,253,.15);
  padding-top: 1.5rem;
  font-size: .75rem;
  color: #60A5FA;
}

/* ============================================================
   ACCESSIBILITY & UTILITIES
   ============================================================ */

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  #bg-canvas { display: none; }
}
