/* ══════════════════════════════════════════════════════════════
   Discover Cape Town — Design System CSS
   docs/discover-design-system.md is the source of truth.
   Do NOT add per-page overrides. The constraint is the feature.
   ══════════════════════════════════════════════════════════════ */

/* ── Fonts ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,700;1,6..72,400&family=Instrument+Sans:wght@400;600;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg: #faf9f7;
  --card: #ffffff;
  --muted: #f2f0ec;
  --line: #e2dfd8;

  /* Text */
  --ink: #1c1917;
  --slate: #302b26;

  /* Accent */
  --accent: #1a5f7a;
  --accent-light: #eef7fb;
  --link: #1a5f7a;

  /* Semantic */
  --good: #2a6e5a;
  --gold: #b8860b;
  --danger: #a8271c;
  --wine: #8b2635;

  /* Highlight inline pills */
  --hl-blue-bg: #e3f0f7;   --hl-blue-fg: #0a3a52;
  --hl-good-bg: #e1f0ec;   --hl-good-fg: #1f4f3f;
  --hl-gold-bg: #fef3d3;   --hl-gold-fg: #7a5a09;
  --hl-danger-bg: #fbe5e2; --hl-danger-fg: #6b1a12;
}

/* ── Base Typography ───────────────────────────────────────── */
.discover-container {
  font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  font-size: 1.04rem;
  line-height: 1.68;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
}

.discover-container h1,
.discover-container h2,
.discover-container h3 {
  font-family: 'Newsreader', Georgia, serif;
  color: var(--ink);
  line-height: 1.25;
}

.discover-container h2 {
  padding-top: 2rem;
  border-top: 2px solid var(--line);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.discover-container a {
  color: var(--link);
  text-decoration-color: rgba(26, 95, 122, 0.4);
}
.discover-container a:hover {
  text-decoration-color: var(--link);
}

/* ── Layout ────────────────────────────────────────────────── */
.discover-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 3rem;
}

.discover-article {
  max-width: 76ch;
}

.discover-section {
  margin-top: 2.5rem;
}

/* ── 1. Hero ───────────────────────────────────────────────── */
.discover-hero {
  background: linear-gradient(135deg, #1a3a52 0%, #0f2744 100%);
  color: #fff;
  padding: 4rem 24px 3rem;
  margin: -1rem -24px 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Table Mountain silhouette — subtle visual anchor */
.discover-hero::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 80' preserveAspectRatio='none'%3E%3Cpath d='M0 80 L0 60 L100 45 L180 50 L250 25 L350 20 L450 20 L550 25 L620 45 L700 55 L800 40 L900 35 L950 30 L1050 35 L1100 50 L1200 55 L1200 80 Z' fill='rgba(255,255,255,0.03)'/%3E%3C/svg%3E") no-repeat bottom center;
  background-size: 100% 100%;
  pointer-events: none;
}

/* Subtle radial glow behind the title */
.discover-hero::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 300px;
  background: radial-gradient(ellipse, rgba(26, 95, 122, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.discover-hero .hero-badge {
  display: inline-block;
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.8;
  margin-bottom: 0.75rem;
}

.discover-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.9rem);
  font-weight: 700;
  color: #fff;
  margin: 0 auto 1rem;
}

.discover-hero .hero-thesis {
  font-size: 1.08rem;
  max-width: 720px;
  margin: 0 auto;
  opacity: 0.9;
  line-height: 1.6;
}

/* ── 2. KPI Strip ──────────────────────────────────────────── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.15rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26, 95, 122, 0.08);
  border-color: var(--accent);
}

.kpi-card .kpi-value {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi-card .kpi-value.good  { color: var(--good); }
.kpi-card .kpi-value.gold  { color: var(--gold); }
.kpi-card .kpi-value.danger { color: var(--danger); }
.kpi-card .kpi-value.wine  { color: var(--wine); }

.kpi-card .kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--slate);
  margin-top: 0.3rem;
}

/* ── 3. Highlight Box ──────────────────────────────────────── */
.highlight-box {
  background: linear-gradient(135deg, var(--accent-light) 0%, #f8fcfd 100%);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  line-height: 1.65;
  box-shadow: 0 2px 8px rgba(26, 95, 122, 0.06);
  position: relative;
}

.highlight-box::before {
  content: '\201C'; /* opening quote */
  position: absolute;
  top: 0.5rem;
  left: 1rem;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 3rem;
  color: var(--accent);
  opacity: 0.15;
  line-height: 1;
}

.highlight-box strong {
  color: var(--accent);
}

/* ── 4. Key Takeaway ───────────────────────────────────────── */
.key-takeaway {
  background: var(--muted);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.96rem;
  margin-top: 1rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.key-takeaway strong {
  color: var(--gold);
}

/* ── 5. Alert Box ──────────────────────────────────────────── */
.alert-box {
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.96rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.alert-box.alert-good {
  background: var(--hl-good-bg);
  border-left: 4px solid var(--good);
  color: var(--hl-good-fg);
}
.alert-box.alert-gold {
  background: var(--hl-gold-bg);
  border-left: 4px solid var(--gold);
  color: var(--hl-gold-fg);
}
.alert-box.alert-danger {
  background: var(--hl-danger-bg);
  border-left: 4px solid var(--danger);
  color: var(--hl-danger-fg);
}

/* ── 6. Bar Chart ──────────────────────────────────────────── */
.chart {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chart h4 {
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 1rem;
}

.bar-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.55rem;
}

.bar-label {
  width: 130px;
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate);
  padding-right: 0.5rem;
}

.bar-track {
  flex: 1;
  height: 24px;
  background: var(--muted);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  animation: bar-grow 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes bar-grow {
  from { width: 0; }
}

.bar-fill.bar-good   { background: var(--good); }
.bar-fill.bar-gold   { background: var(--gold); }
.bar-fill.bar-danger  { background: var(--danger); }
.bar-fill.bar-accent  { background: var(--accent); }

.bar-value {
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  padding-left: 0.5rem;
}

.chart .legend {
  font-size: 0.78rem;
  color: var(--slate);
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

/* ── 7. FAQ Accordion ──────────────────────────────────────── */
.faq-section {
  margin-top: 2.5rem;
  margin-bottom: 2rem;
}

.faq-section h2 {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

details.faq {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

details.faq:hover {
  border-color: rgba(26, 95, 122, 0.3);
}

details.faq[open] {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(26, 95, 122, 0.08);
}

details.faq summary {
  padding: 1rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: color 0.2s;
}

details.faq:hover summary {
  color: var(--accent);
}

details.faq summary::-webkit-details-marker { display: none; }

details.faq summary::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--slate);
  flex-shrink: 0;
  margin-left: 1rem;
  transition: transform 0.2s, color 0.2s;
}

details.faq[open] summary::after {
  content: '\2212'; /* minus sign */
  color: var(--accent);
}

details.faq .faq-body {
  padding: 0 1rem 1rem;
  font-size: 0.94rem;
  color: var(--slate);
  line-height: 1.65;
}

/* ── 8. Sources Box ────────────────────────────────────────── */
.sources-box {
  background: var(--muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem;
  margin-top: 2.5rem;
  margin-bottom: 2rem;
  font-size: 0.88rem;
  line-height: 1.7;
}

.sources-box .source-category {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.sources-box .source-category:first-child {
  margin-top: 0;
}

.sources-box a {
  color: var(--link);
  text-decoration-color: rgba(26, 95, 122, 0.4);
}

.sources-box a:hover {
  text-decoration-color: var(--link);
}

/* ── 9. Timeline ───────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 2rem;
  margin: 1.5rem 0 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-event {
  position: relative;
  padding-bottom: 1.25rem;
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: -2rem;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px var(--line);
}

.timeline-event.tone-good::before { background: var(--good); box-shadow: 0 0 0 2px var(--hl-good-bg); }
.timeline-event.tone-danger::before { background: var(--danger); box-shadow: 0 0 0 2px var(--hl-danger-bg); }
.timeline-event.tone-gold::before { background: var(--gold); box-shadow: 0 0 0 2px var(--hl-gold-bg); }

.timeline-year {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.timeline-event.tone-good .timeline-year { color: var(--good); }
.timeline-event.tone-danger .timeline-year { color: var(--danger); }
.timeline-event.tone-gold .timeline-year { color: var(--gold); }

.timeline-text {
  font-size: 0.92rem;
  color: var(--slate);
  line-height: 1.55;
}

/* ── 10. Memorial / Place List ─────────────────────────────── */
.place-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
  margin: 1.5rem 0 2rem;
}

.place-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.15rem;
}

.place-card h4 {
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.4rem;
}

.place-card p {
  font-size: 0.88rem;
  color: var(--slate);
  line-height: 1.55;
  margin: 0;
}

/* ── 11. Related Topics Footer ─────────────────────────────── */
.related-footer {
  border-top: 2px solid var(--line);
  padding-top: 2rem;
  margin-top: 2.5rem;
}

.related-footer h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.related-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.related-card::before {
  content: '\2192'; /* arrow */
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%) translateX(5px);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  color: var(--accent);
}

.related-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(26, 95, 122, 0.12);
  text-decoration: none;
  color: var(--accent);
  transform: translateY(-2px);
}

.related-card:hover::before {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ── Inline Pills ──────────────────────────────────────────── */
.hl-blue {
  background: var(--hl-blue-bg);
  color: var(--hl-blue-fg);
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.hl-good {
  background: var(--hl-good-bg);
  color: var(--hl-good-fg);
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.hl-gold {
  background: var(--hl-gold-bg);
  color: var(--hl-gold-fg);
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.hl-danger {
  background: var(--hl-danger-bg);
  color: var(--hl-danger-fg);
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

/* ── Data Stamp ────────────────────────────────────────────── */
.data-stamp {
  font-size: 0.8rem;
  color: var(--slate);
  font-style: italic;
  text-align: right;
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

/* ══════════════════════════════════════════════════════════════
   Responsive — 640px breakpoint
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .discover-container {
    font-size: 1rem;
    padding: 0 16px 2rem;
  }

  .discover-hero {
    padding: 3rem 16px 2.5rem;
    margin: -1rem -16px 1.5rem;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-card {
    padding: 0.85rem;
  }

  .kpi-card .kpi-value {
    font-size: 1.55rem;
  }

  .chart {
    padding: 1rem 0.75rem;
  }

  .bar-label {
    width: 78px;
    font-size: 0.74rem;
    font-weight: 700;
  }

  .bar-track {
    height: 22px;
  }

  .bar-value {
    width: 78px;
    font-size: 0.72rem;
  }
}
