/* =========================================================
   Lingua Atlas · editorial / data-journalism aesthetic
   Cream paper, deep ink, restrained accent palette
   ========================================================= */

:root {
  /* multilingual.ai palette */
  --paper:        #FFF9F5;   /* warm cream body */
  --paper-2:      #F2DFCE;   /* warm peach (form borders, tints) */
  --rule:         #E8D9C8;   /* hairline rule */
  --ink:          #0E1A2B;   /* deep navy primary */
  --ink-2:        #1c2c46;   /* navy-2 */
  --ink-3:        #4a5a72;
  --ink-4:        #7a8699;

  --accent:       #F0A73A;   /* amber — primary accent */
  --accent-dark:  #D8911F;   /* darker amber for hover */
  --accent-2:     #F8D673;   /* gold — secondary */
  --sky:          #B0E3FF;   /* sky-blue button fill */
  --link:         #137DC5;   /* informational blue */
  --teal:         #0e6b5c;   /* data positive */
  --plum:         #8e44ad;   /* underrepresentation highlight (kept) */

  /* Type */
  --font-display: 'DM Serif Display', 'Georgia', serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', 'JetBrains Mono', ui-monospace, monospace;

  /* Sizes */
  --hero:    clamp(3rem, 9vw, 6.5rem);
  --h2:      clamp(1.75rem, 3.5vw, 2.75rem);
  --tag:     0.75rem;

  /* Layout */
  --container: 1180px;
  --gap:       2rem;
  --radius:    20px;   /* pill-rounded to match multilingual.ai */
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
}

/* ============= MASTHEAD ============= */
.masthead {
  border-bottom: none;
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 50;
  color: var(--paper);
}
.masthead-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0.9rem clamp(1.25rem, 4vw, 2.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--paper);
}
.logo { width: 24px; height: 24px; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.masthead-meta {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.78rem;
  color: rgba(255, 249, 245, 0.6);
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.05em;
}
.dateline { text-transform: uppercase; }
.sep { color: rgba(255, 249, 245, 0.3); }
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--sky);
  color: var(--ink);
  border: none;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}
.export-btn:hover { background: var(--accent); transform: translateY(-1px); }
.export-btn:active { transform: translateY(0); }

/* ============= HERO ============= */
.hero {
  padding: clamp(3rem, 8vw, 7rem) 0 clamp(2rem, 4vw, 4rem);
  border-bottom: 1px solid var(--rule);
}
.kicker {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--tag);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-dark);
  margin: 0 0 1.5rem;
}
.display {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--hero);
  line-height: 0.94;
  letter-spacing: -0.035em;
  margin: 0;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
}
.display em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}
/* DM Serif Display is not variable; remove opsz hints */
.display, .h2, .kpi-value { font-variation-settings: normal; }
.standfirst {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: clamp(1.05rem, 1.3vw, 1.2rem);
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 62ch;
  margin: 2rem 0 0;
  letter-spacing: -0.005em;
}

/* ============= KPIs ============= */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding: 2.5rem clamp(1.25rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--rule);
}
.kpi {
  padding: 0.5rem 1.5rem 0.5rem 0;
  border-right: 1px solid var(--rule);
}
.kpi:last-child { border-right: none; padding-right: 0; }
.kpi-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 72;
}
.kpi-value .unit {
  font-size: 0.55em;
  color: var(--ink-3);
  font-weight: 500;
  margin-left: 0.1em;
}
.kpi-label {
  font-size: 0.85rem;
  color: var(--ink-3);
  margin: 0.5rem 0 0.4rem;
  line-height: 1.4;
}
.kpi-trend {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.kpi-trend.up    { color: var(--teal); }
.kpi-trend.down  { color: var(--accent-dark); }
.kpi-trend.muted { color: var(--ink-4); }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); row-gap: 2rem; }
  .kpi:nth-child(2) { border-right: none; }
  .kpi { padding-right: 1rem; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi { border-right: none; border-bottom: 1px solid var(--rule); padding-bottom: 1.5rem; }
  .kpi:last-child { border-bottom: none; padding-bottom: 0; }
}

/* ============= FEATURE SECTIONS ============= */
.feature {
  padding: clamp(3rem, 6vw, 5.5rem) clamp(1.25rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--rule);
}
.feature-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 2rem;
  margin-bottom: 2.5rem;
}
@media (max-width: 800px) {
  .feature-head { grid-template-columns: 1fr; }
}
.section-tag {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--tag);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-dark);
  margin: 0 0 0.6rem;
}
.h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--h2);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--ink);
  font-variation-settings: "opsz" 72;
}
.lede {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 60ch;
  margin: 0.9rem 0 0;
  letter-spacing: -0.005em;
}
.footnote {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--ink-4);
  letter-spacing: 0.01em;
  margin: 1.25rem 0 0;
  line-height: 1.6;
}

/* ============= TOGGLE GROUP ============= */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-self: end;
}
.toggle-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  background: transparent;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.toggle-btn:hover { color: var(--ink); border-color: var(--ink-4); }
.toggle-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.toggle-btn .dot {
  width: 8px; height: 8px; border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}
.toggle-btn .label { color: inherit; }
.toggle-btn { color: var(--ink-3); }
.toggle-btn.active .label { color: var(--paper); }

/* ============= CHART FRAME ============= */
.chart-frame {
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  height: 460px;
  position: relative;
  box-shadow: 5px 10px 24px rgba(14, 26, 43, 0.06);
}
.chart-frame.tall { height: 720px; }
.chart-frame canvas { width: 100% !important; height: 100% !important; }

/* ============= TABLES ============= */
.filter-input {
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--paper-2);
  background: #ffffff;
  color: var(--ink);
  border-radius: 999px;
  width: 260px;
  max-width: 100%;
  outline: none;
  transition: border-color 0.18s ease;
}
.filter-input:focus { border-color: var(--accent); }

.table-wrap {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
  overflow-x: auto;
  box-shadow: 5px 10px 24px rgba(14, 26, 43, 0.06);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 760px;
}
.data-table thead th {
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
	white-space: normal;   /* lets long headers like "SPEAKER SHARE OF WORLD" wrap */
  min-width: 80px;       /* prevents columns from collapsing too narrow */
  cursor: pointer;
  user-select: none;
}
.data-table thead th.num { text-align: right; }
.data-table thead th[data-sort]:hover { color: var(--ink); }
.data-table thead th.sorted { color: var(--accent-dark); }
.data-table thead th.sorted::after { content: " ▾"; }
.data-table thead th.sorted.asc::after { content: " ▴"; }
.data-table tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(240, 167, 58, 0.06); }
.data-table td.num,
.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-body); font-weight: 500; font-size: 0.82rem; }
.data-table td.rank { color: var(--ink-4); font-family: var(--font-body); font-weight: 600; font-size: 0.78rem; width: 36px; letter-spacing: 0.04em; }
.data-table td.lang-name { font-weight: 500; color: var(--ink); }
.data-table td.spark { width: 130px; padding: 0.4rem 1rem; }
.data-table td.spark svg { display: block; }

.delta-pos { color: var(--teal); font-weight: 600; }
.delta-neg { color: var(--accent-dark); font-weight: 600; }
.delta-zero { color: var(--ink-4); }

.badge {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge.over   { background: rgba(14, 107, 92, 0.12); color: var(--teal); }
.badge.under  { background: rgba(142, 68, 173, 0.13); color: var(--plum); }
.badge.severe { background: var(--plum); color: white; }
.badge.even   { background: var(--paper-2); color: var(--ink-3); }

.row-highlight td { background: rgba(142, 68, 173, 0.06); }

/* ============= TAKEAWAYS ============= */
.takeaways .findings {
  list-style: none;
  counter-reset: finding;
  padding: 0;
  margin: 2rem 0 0;
  display: grid;
  gap: 1rem;
  max-width: 70ch;
}
.takeaways .findings li {
  counter-increment: finding;
  position: relative;
  padding: 1.25rem 1.4rem 1.25rem 3.6rem;
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink-2);
  box-shadow: 5px 10px 18px rgba(14, 26, 43, 0.05);
}
.takeaways .findings li::before {
  content: counter(finding, decimal-leading-zero);
  position: absolute;
  left: 1.3rem;
  top: 1.3rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--accent-dark);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.takeaways .findings li strong { color: var(--ink); font-weight: 600; }

/* ============= NEWSLETTER STRIP (mirrors multilingual.ai) ============= */
.newsletter-strip {
  background: var(--accent);
  color: var(--ink);
  padding: 3.5rem 0;
  border: none;
}
.newsletter-strip .h2 { color: var(--ink); margin: 0 0 0.5rem; }
.newsletter-strip p { font-family: var(--font-body); font-size: 1rem; color: var(--ink-2); max-width: 56ch; margin: 0; }
.newsletter-strip .strip-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2rem;
}
@media (max-width: 800px) { .newsletter-strip .strip-inner { grid-template-columns: 1fr; } }
.newsletter-strip a.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.18s ease, transform 0.18s ease;
}
.newsletter-strip a.btn:hover { background: var(--ink-2); transform: translateY(-1px); }

/* ============= COLOPHON ============= */
.colophon {
background: var(--ink);
  color: var(--paper);
  padding: 4rem 0 3rem;
  margin-top: 0;
  max-width: var(--container);   /* same 1180px cap as the tables */
  margin-left: auto;             /* center it */
  margin-right: auto;
  border-radius: var(--radius);  /* optional: rounds corners to match the table boxes */
}
}
.colophon .section-tag { color: var(--accent-2); }
.colophon .sources {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  gap: 0.7rem;
  max-width: 70ch;
}
.colophon .sources a {
  color: var(--paper);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 249, 245, 0.3);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.98rem;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.colophon .sources a:hover { border-bottom-color: var(--accent); color: var(--accent); }
.colophon .sources li {
  font-size: 0.9rem;
  color: rgba(255, 249, 245, 0.7);
  line-height: 1.6;
}
.colophon-note {
  max-width: 70ch;
  font-size: 0.9rem;
  color: rgba(255, 249, 245, 0.7);
  line-height: 1.6;
  margin: 1.5rem 0;
}
.colophon-meta {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.78rem;
  color: rgba(255, 249, 245, 0.45);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 2rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 249, 245, 0.15);
}

/* mobile masthead tightening */
@media (max-width: 700px) {
  .masthead-meta .dateline,
  .masthead-meta .sep { display: none; }
  .masthead-inner { gap: 0.5rem; }
  .brand-name { font-size: 0.95rem; }
  .export-btn { padding: 0.45rem 0.7rem; font-size: 0.75rem; }
}

/* tiny tweaks */
::selection { background: var(--accent); color: var(--paper); }
em { font-style: italic; }


/* AFTER */
.table-wrap {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: clip;      /* clips for border-radius, no scroll context created */
  overflow-x: auto;    /* clean horizontal scroll, no conflict */
  background: #ffffff;
  box-shadow: 5px 10px 24px rgba(14, 26, 43, 0.06);
}


/* AFTER */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-self: end;
  max-width: 420px;      /* ← caps how wide the button cluster grows */
  justify-content: flex-end;  /* ← right-aligns the wrapped rows */
}

/* AFTER */
@media (max-width: 960px) {
  .feature-head { grid-template-columns: 1fr; }
}