@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600;9..40,700&family=Source+Serif+4:opsz,wght@8..60,600;8..60,700&display=swap');

:root {
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
  --color-bg: #0C1520;
  --color-surface: #131F2E;
  --color-surface-2: #19293B;
  --color-border: #243347;
  --color-text: #D6E0EA;
  --color-text-muted: #8298AE;
  --color-text-faint: #4A6178;
  --color-primary: #4FC4D3;
  --color-primary-dim: rgba(79,196,211,0.25);
  --color-sea: #1A6B8A;
  --color-sea-light: #2A9DB8;
  --color-land: #3D6B4F;
  --color-land-light: #5A8F6A;
  --color-flood: #4FB8D4;
  --color-danger: #E8664E;
  --color-warning: #F0C05A;
  --color-success: #5DD5C4;
  --color-heat: #E8664E;
  --color-rain: #4FB8D4;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

/* ─── Page ─── */
.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  gap: 20px;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 1rem + 2vw, 2rem);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
}

.page-subtitle {
  font-size: clamp(0.8rem, 0.7rem + 0.5vw, 0.95rem);
  color: var(--color-text-muted);
  text-align: center;
  max-width: 56ch;
  line-height: 1.5;
}

/* ─── Main Box ─── */
.viz-box {
  width: 100%;
  max-width: 1280px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  grid-template-rows: 1fr auto;
  aspect-ratio: 2 / 1;
  min-height: 520px;
  max-height: 720px;
}

/* ─── Left: Chart ─── */
.chart-half {
  position: relative;
  padding: 24px 20px 16px 20px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  overflow: hidden;
}

.chart-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.chart-area {
  flex: 1;
  position: relative;
  min-height: 0;
}

.chart-area svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ─── Right: Panels ─── */
.panels-half {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0;
}

.panel {
  position: relative;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel:nth-child(1) { border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); }
.panel:nth-child(2) { border-bottom: 1px solid var(--color-border); }
.panel:nth-child(3) { border-right: 1px solid var(--color-border); }

.panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-canvas {
  flex: 1;
  position: relative;
  min-height: 0;
}

.panel-canvas canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.panel-stat {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 0.8rem + 1vw, 1.6rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.1;
  margin-top: 6px;
}

.panel-stat-label {
  font-size: 11px;
  color: var(--color-text-faint);
  margin-top: 2px;
}

/* ─── Controls Bar ─── */
.controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
}

.play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 180ms ease;
}
.play-btn:hover { background: #3AAFBE; }

.timeline-track {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.timeline-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  pointer-events: none;
}

.timeline-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-bg);
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 8px rgba(79,196,211,0.5);
}

.year-display {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.speed-btn {
  font-size: 11px;
  color: var(--color-text-faint);
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 180ms ease;
}
.speed-btn:hover, .speed-btn.active {
  color: var(--color-primary);
  background: var(--color-primary-dim);
}

/* ─── Footer ─── */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1280px;
  font-size: 11px;
  color: var(--color-text-faint);
  padding: 0 4px;
}

.footer a {
  color: var(--color-text-faint);
  text-decoration: none;
}
.footer a:hover { color: var(--color-text-muted); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .viz-box {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr auto;
    aspect-ratio: auto;
    max-height: none;
    min-height: auto;
  }
  .chart-half {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    min-height: 300px;
  }
  .panels-half {
    min-height: 300px;
  }
}
