/* Money Markets — Main CSS Design System */
/* Palette: Parchment #F5F0EB, Charcoal #2C2C2C, Gold #B8860B, Navy #1B3A5C */

@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Source+Sans+Pro:wght@400;600;700&display=swap');

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --parchment: #F5F0EB;
  --charcoal: #2C2C2C;
  --gold: #B8860B;
  --navy: #1B3A5C;
  --light-gold: #D4A843;
  --faded: #8C8279;
  --border: #D6CFC6;
  --card-bg: #FFFDF9;
  --shadow: rgba(0,0,0,0.08);
  --max-text: 900px;
  --max-wide: 1200px;
}

html { font-size: 17px; scroll-behavior: smooth; }
body {
  font-family: 'Libre Baskerville', 'Georgia', serif;
  background: var(--parchment);
  color: var(--charcoal);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ─── Typography ─── */
h1, h2, h3, h4 {
  font-family: 'Libre Baskerville', 'Georgia', serif;
  color: var(--navy);
  line-height: 1.3;
}
h1 { font-size: 2.2rem; margin-bottom: 0.5em; }
h2 { font-size: 1.6rem; margin: 1.5em 0 0.5em; border-bottom: 2px solid var(--gold); padding-bottom: 0.3em; }
h3 { font-size: 1.2rem; margin: 1.2em 0 0.4em; color: var(--gold); }
h4 { font-size: 1rem; margin: 1em 0 0.3em; }

p { margin-bottom: 1em; }
a { color: var(--navy); transition: color 0.2s; }
a:hover { color: var(--gold); }

.subtitle {
  font-style: italic;
  color: var(--faded);
  font-size: 1.1rem;
  margin-bottom: 1.5em;
}

/* ─── Layout ─── */
.container { max-width: var(--max-text); margin: 0 auto; padding: 0 1.5rem; }
.container-wide { max-width: var(--max-wide); margin: 0 auto; padding: 0 1.5rem; }

/* ─── Header / Nav ─── */
.site-header {
  background: var(--navy);
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px var(--shadow);
}
.site-header .container-wide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.site-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.site-title:hover { color: var(--light-gold); }
.site-title span { color: var(--light-gold); }

nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color 0.2s;
}
nav a:hover, nav a.active { color: var(--light-gold); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

/* ─── Hero ─── */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, #2a4a6b 100%);
  color: #fff;
  padding: 4rem 1.5rem;
  text-align: center;
}
.hero h1 {
  color: #fff;
  font-size: 2.8rem;
  margin-bottom: 0.3em;
}
.hero .tagline {
  font-style: italic;
  font-size: 1.2rem;
  color: var(--light-gold);
  margin-bottom: 1.5em;
}
.hero p {
  max-width: 700px;
  margin: 0 auto 2em;
  font-size: 1.05rem;
  line-height: 1.8;
  color: rgba(255,255,255,0.9);
}

/* ─── Cards Grid ─── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover {
  box-shadow: 0 4px 16px var(--shadow);
  transform: translateY(-2px);
}
.card-image {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: var(--border);
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-image-placeholder {
  width: 100%;
  height: 180px;
  background: linear-gradient(135deg, var(--navy) 0%, #3a5a7c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.3);
  font-size: 2.5rem;
}
.card-body {
  padding: 1.2rem;
}
.card-body h3 {
  margin: 0 0 0.3em;
  font-size: 1.05rem;
  color: var(--navy);
}
.card-body h3 a {
  text-decoration: none;
  color: inherit;
}
.card-body h3 a:hover { color: var(--gold); }
.card-meta {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85rem;
  color: var(--faded);
  margin-bottom: 0.5em;
}
.card-tag {
  display: inline-block;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2em 0.6em;
  border-radius: 3px;
  background: var(--navy);
  color: #fff;
  margin-right: 0.4em;
}

/* ─── Exchange Page ─── */
.exchange-hero {
  position: relative;
  background: linear-gradient(135deg, var(--navy) 0%, #2a4a6b 100%);
  color: #fff;
  padding: 3rem 1.5rem 2rem;
}
.exchange-hero h1 { color: #fff; font-size: 2.2rem; }
.exchange-hero .subtitle { color: var(--light-gold); }

/* Hero with vignette image */
.hero-with-image {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
.hero-text { flex: 1; }
.hero-vignette {
  flex-shrink: 0;
}
.hero-vignette img {
  width: 220px;
  max-height: 180px;
  object-fit: contain;
  border-radius: 6px;
  border: 3px solid rgba(255,255,255,0.3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  background: rgba(0,0,0,0.15);
}

/* Links list */
.links-list {
  list-style: none;
  padding: 0;
}
.links-list li {
  padding: 0.4em 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.links-list li:last-child { border-bottom: none; }
.links-list a { text-decoration: none; }
.links-list a:hover { color: var(--gold); }

/* Images placeholder */
.images-placeholder {
  color: var(--faded);
  font-style: italic;
  font-size: 0.95rem;
  padding: 1.5rem;
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: 6px;
  text-align: center;
}

.exchange-content {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2.5rem;
  margin: 2rem auto;
  max-width: var(--max-wide);
  padding: 0 1.5rem;
}
.exchange-main { min-width: 0; }
.exchange-sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
}

/* Sidebar fact box */
.fact-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 6px;
  padding: 1.5rem;
}
.fact-box h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin: 0 0 1em;
  font-family: 'Source Sans Pro', sans-serif;
}
.fact-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5em 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.fact-row:last-child { border-bottom: none; }
.fact-label {
  font-family: 'Source Sans Pro', sans-serif;
  font-weight: 600;
  color: var(--faded);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
.fact-value { text-align: right; font-size: 0.9rem; }

/* Narrative sections */
.narrative-section { margin-bottom: 2rem; }
.narrative-section.empty {
  color: var(--faded);
  font-style: italic;
}

/* ─── Region Page ─── */
.region-header {
  background: linear-gradient(135deg, var(--navy) 0%, #2a4a6b 100%);
  color: #fff;
  padding: 3rem 1.5rem;
}
.region-header h1 { color: #fff; }
.region-header p { color: rgba(255,255,255,0.85); max-width: 700px; }
.exchange-count {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.9rem;
  color: var(--light-gold);
  margin-top: 0.5em;
}

/* ─── Table ─── */
.exchange-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95rem;
}
.exchange-table th {
  font-family: 'Source Sans Pro', sans-serif;
  text-align: left;
  padding: 0.8em 1em;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.exchange-table td {
  padding: 0.7em 1em;
  border-bottom: 1px solid var(--border);
}
.exchange-table tr:hover td { background: rgba(184,134,11,0.05); }
.exchange-table a { text-decoration: none; font-weight: 700; }

/* ─── Timeline ─── */
.timeline {
  position: relative;
  padding: 2rem 0;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gold);
  transform: translateX(-50%);
}
.timeline-epoch {
  margin-bottom: 3rem;
}
.timeline-epoch-header {
  text-align: center;
  position: relative;
  z-index: 1;
  margin-bottom: 1.5rem;
}
.timeline-epoch-header h2 {
  display: inline-block;
  background: var(--parchment);
  padding: 0.3em 1em;
  border: 2px solid var(--gold);
  border-radius: 4px;
  font-size: 1.1rem;
  margin: 0;
}
.timeline-epoch-header .year-range {
  display: block;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85rem;
  color: var(--faded);
  margin-top: 0.3em;
}

/* ─── Map ─── */
.map-page { padding: 0; }
.map-container {
  width: 100%;
  height: calc(100vh - 64px);
}
.map-controls {
  position: absolute;
  top: 80px;
  right: 20px;
  z-index: 999;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  box-shadow: 0 2px 8px var(--shadow);
  max-width: 260px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.map-controls h3 {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin: 0 0 0.8em;
}
.map-controls label {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85rem;
  padding: 0.2em 0;
  cursor: pointer;
}
.map-controls input[type="checkbox"] { accent-color: var(--gold); }
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

/* ─── Footer ─── */
.site-footer {
  background: var(--navy);
  color: rgba(255,255,255,0.7);
  padding: 2.5rem 1.5rem;
  margin-top: 4rem;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85rem;
}
.site-footer .container-wide {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.site-footer a { color: var(--light-gold); text-decoration: none; }
.site-footer a:hover { color: #fff; }

/* ─── Breadcrumb ─── */
.breadcrumb {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85rem;
  padding: 1rem 1.5rem;
  color: var(--faded);
  max-width: var(--max-wide);
  margin: 0 auto;
}
.breadcrumb a { text-decoration: none; }
.breadcrumb span { margin: 0 0.4em; }

/* ─── About Page ─── */
.about-content { margin: 2rem auto; }
.about-content img {
  max-width: 100%;
  border-radius: 6px;
  margin: 1em 0;
}

/* ─── Epoch badge ─── */
.epoch-badge {
  display: inline-block;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2em 0.5em;
  border-radius: 3px;
  color: #fff;
}

/* ─── Section intro ─── */
.section-intro {
  max-width: var(--max-text);
  margin: 2rem auto;
  padding: 0 1.5rem;
  text-align: center;
}
.section-intro p {
  font-size: 1.05rem;
  color: var(--faded);
}

/* ─── Map preview on home ─── */
.map-preview {
  width: 100%;
  height: 400px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 2rem 0;
}

/* ─── Button ─── */
.btn {
  display: inline-block;
  font-family: 'Source Sans Pro', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 0.7em 1.8em;
  border-radius: 4px;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--gold);
  color: #fff;
}
.btn-primary:hover {
  background: var(--light-gold);
  color: #fff;
}
.btn-outline {
  border: 2px solid rgba(255,255,255,0.5);
  color: #fff;
}
.btn-outline:hover {
  border-color: var(--light-gold);
  color: var(--light-gold);
}

/* ─── Image Gallery ─── */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.gallery img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s;
}
.gallery img:hover { transform: scale(1.02); }

/* ─── Search Box ─── */
.search-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  border-left: 4px solid var(--gold);
  padding: 1rem;
  position: relative;
}
#exchange-search {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.2s;
}
#exchange-search:focus {
  border-color: var(--gold);
}
.search-results {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px var(--shadow);
}
.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  text-decoration: none;
  color: var(--charcoal);
  border-bottom: 1px solid var(--border);
  font-family: 'Source Sans Pro', sans-serif;
  transition: background 0.15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(184,134,11,0.08); }
.search-result-name {
  font-weight: 600;
  color: var(--navy);
}
.search-result-meta {
  font-size: 0.85rem;
  color: var(--faded);
}
.search-no-results {
  color: var(--faded);
  font-style: italic;
  justify-content: center;
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .exchange-content {
    grid-template-columns: 1fr;
  }
  .exchange-sidebar {
    position: static;
    order: -1;
  }
}

@media (max-width: 768px) {
  html { font-size: 16px; }
  .hero h1 { font-size: 2rem; }
  .hero { padding: 2.5rem 1rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }

  .hero-with-image { flex-direction: column; text-align: center; }
  .hero-vignette img { width: 160px; height: 120px; }

  .nav-toggle { display: block; }
  nav ul {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--navy);
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 8px var(--shadow);
  }
  nav ul.open { display: flex; }
  nav li { padding: 0.5rem 0; }

  .card-grid {
    grid-template-columns: 1fr;
  }
  .exchange-table { font-size: 0.85rem; }
  .exchange-table th, .exchange-table td { padding: 0.5em; }

  .map-controls {
    position: static;
    max-width: 100%;
    margin: 0.5rem;
    max-height: none;
  }
  .map-container {
    height: 60vh;
  }
}

@media (max-width: 480px) {
  html { font-size: 15px; }
  .hero h1 { font-size: 1.6rem; }
  .site-title { font-size: 1rem; }
  .container, .container-wide { padding: 0 1rem; }
  .site-footer .container-wide { flex-direction: column; text-align: center; }
}

/* ─── Growth Chart ─── */
.growth-chart-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 1rem 1rem;
  margin-bottom: 2.5rem;
  overflow: hidden;
}
.growth-chart-container h2 {
  text-align: center;
  font-size: 1.3rem;
  margin: 0 0 0.25rem;
  color: var(--charcoal);
}
.growth-chart-container .chart-subtitle {
  text-align: center;
  color: var(--faded);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.chart-tooltip {
  position: absolute;
  background: rgba(44, 44, 44, 0.92);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: 'Source Sans Pro', sans-serif;
  line-height: 1.5;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.chart-legend-item {
  font-size: 0.78rem;
  font-family: 'Source Sans Pro', sans-serif;
  color: var(--charcoal);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chart-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ─── Timeline Map ─── */
.timeline-map-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 1rem 1rem;
  margin-bottom: 2.5rem;
  overflow: hidden;
}
.timeline-map-container h2 {
  text-align: center;
  font-size: 1.3rem;
  margin: 0 0 0.25rem;
  color: var(--charcoal);
}
.timeline-map-container .chart-subtitle {
  text-align: center;
  color: var(--faded);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
#timeline-map-canvas {
  width: 100%;
  height: 420px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.timeline-slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0 0.25rem;
}
.timeline-slider-row input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.timeline-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
}
.timeline-slider-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
}
#timeline-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--card-bg);
  color: var(--gold);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
#timeline-play-btn:hover {
  background: var(--gold);
  color: #fff;
}
#timeline-year-label {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
  min-width: 70px;
  text-align: center;
  flex-shrink: 0;
}
#timeline-count-label {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85rem;
  color: var(--faded);
  min-width: 100px;
  text-align: right;
  flex-shrink: 0;
}
.timeline-marker {
  transition: opacity 0.3s ease-in;
}
@media (max-width: 768px) {
  #timeline-map-canvas { height: 300px; }
  .timeline-slider-row { flex-wrap: wrap; }
  #timeline-count-label { text-align: left; min-width: auto; }
}
