/* ==========================================================================
   SOCIALISM.ORG - CALM & DIGNIFIED MANIFESTO FOR ECONOMIC SOVEREIGNTY
   Two-Chapter Narrative Design (Offline-First, Clean Modernist Typography)
   ========================================================================== */

:root {
  --bg-primary: #0e1115;
  --bg-surface: #151921;
  --bg-card: #1c222c;
  --bg-card-hover: #242c38;
  --border-subtle: #293240;
  --border-prominent: #3b4759;
  
  --text-primary: #f0f3f7;
  --text-secondary: #9aa9bc;
  --text-muted: #8b9bb0;

  --header-bg: rgba(21, 25, 33, 0.85);
  --btn-primary-bg: #1f7a6f;
  --btn-primary-hover: #1a6b61;
  
  --accent-emerald: #2a9d8f;
  --accent-emerald-subtle: rgba(42, 157, 143, 0.12);
  --accent-emerald-glow: rgba(42, 157, 143, 0.25);
  
  --accent-amber: #e9c46a;
  --accent-amber-subtle: rgba(233, 196, 106, 0.12);
  
  --accent-rust: #e76f51;
  --accent-rust-subtle: rgba(231, 111, 81, 0.12);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
  --bg-primary: #f7f9fa;
  --bg-surface: #ffffff;
  --bg-card: #f0f3f6;
  --bg-card-hover: #e6ebf0;
  --border-subtle: #dbe2e8;
  --border-prominent: #ccd5df;
  
  --text-primary: #12161b;
  --text-secondary: #475467;
  --text-muted: #526071;

  --header-bg: rgba(247, 249, 250, 0.88);
  --btn-primary-bg: #0f766e;
  --btn-primary-hover: #115e59;
  
  --accent-emerald: #0f766e;
  --accent-emerald-subtle: rgba(15, 118, 110, 0.08);
  --accent-emerald-glow: rgba(15, 118, 110, 0.15);
  
  --accent-amber: #b45309;
  --accent-amber-subtle: rgba(180, 83, 9, 0.08);
  
  --accent-rust: #c2410c;
  --accent-rust-subtle: rgba(194, 65, 12, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-display);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.header {
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 5.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-text {
  display: inline-block;
  transform: translateY(1.5px);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 3.75rem;
  height: 3.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-tld {
  color: var(--accent-emerald);
}

.brand-icon img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: -4px 2px 14px rgba(222, 80, 70, 0.14), 4px 6px 14px rgba(52, 196, 134, 0.14);
}

.brand-badge {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--accent-emerald-subtle);
  color: var(--accent-emerald);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--accent-emerald);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--text-primary);
}

.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Narrative Chapters Layout */
.main-flow {
  padding: 1.5rem 0 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chapter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  position: relative;
  transition: border-color 0.2s ease;
}

.chapter-past {
  /* Clean border without colored accent bar */
}

.chapter-future {
  /* Clean uniform border without colored accent bar */
  background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(42, 157, 143, 0.03) 100%);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.beanpool-link-banner {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-prominent);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.beanpool-link-banner:hover {
  transform: translateY(-2px);
  border-color: var(--accent-emerald);
  box-shadow: 0 6px 24px var(--accent-emerald-glow);
}

.chapter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  margin-bottom: 1rem;
}

.tag-past {
  background: var(--accent-amber-subtle);
  color: var(--accent-amber);
  border: 1px solid var(--accent-amber);
}

.tag-future {
  background: var(--accent-emerald-subtle);
  color: var(--accent-emerald);
  border: 1px solid var(--accent-emerald);
}

.chapter-title {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

/* News items: place and date above each one */
.news-meta {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chapter-subtitle {
  font-size: clamp(1.1rem, 2.4vw, 1.3rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  margin: 1.75rem 0 0.75rem;
}

.chapter-lead {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.65;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.chapter-body p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 1rem;
}

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

.chapter-body p.chapter-lead {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
}

.chapter-body p strong {
  color: var(--text-primary);
}

/* Transitional Bridge */
.bridge-box {
  text-align: center;
  padding: 0.5rem 1rem;
  position: relative;
}

.bridge-quote {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.65;
  text-wrap: balance;
}

.bridge-arrow {
  color: var(--accent-emerald);
  font-size: 1.25rem;
  margin-top: 0.25rem;
  display: block;
}

/* Feature List (Future Section) */
.solution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}

.solution-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.solution-icon {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
}

.solution-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.solution-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  min-height: 44px;
  line-height: 1.35;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-prominent);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-secondary);
  transform: translateY(-1px);
}

/* Footer */
.footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 3rem 0 2.5rem;
  margin-top: auto;
}

.footer-acknowledgment {
  max-width: 760px;
  margin: 0 auto 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: start;
}

.footer-acknowledgment p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.7;
  font-style: italic;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.footer-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.5rem;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  display: inline-block;
  padding: 0.6rem 0;
}

.footer-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.cite-ref {
  font-size: 0.72em;
  font-family: var(--font-mono);
  vertical-align: super;
  margin-inline-start: 0.15rem;
}

.cite-ref a {
  color: var(--accent-emerald);
  text-decoration: none;
  font-weight: 700;
}

.cite-ref a:hover {
  text-decoration: underline;
}

/* Footer Citations (Small, Muted, Borderless) */
.footer-citations {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: 760px;
  margin: 0 auto 1.5rem;
  text-align: start;
  padding: 0;
}

.footer-citations li {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.55;
  padding-inline-start: 1.5rem;
  text-indent: -1.5rem;
}

.footer-citations strong {
  color: var(--text-secondary);
}

.footer-citations em {
  color: var(--text-secondary);
}

.cite-num {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-emerald);
  margin-inline-end: 0.35rem;
}

/* Links inside the cards */
.chapter-body p a,
.plain-list a {
  color: var(--accent-emerald);
  font-weight: 600;
  text-underline-offset: 2px;
}

/* The BeanPool banner */
.banner-wrap {
  text-align: center;
  margin: 0 0 1.5rem;
}

.beanpool-link-banner {
  max-width: 100%;
  text-align: start;
}

.beanpool-link-banner img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
}

.banner-text {
  min-width: 0;
}

.banner-title {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
}

.banner-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* The doors: stacked at every width, label text wraps and never shrinks */
.doors {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.75rem 0 1.5rem;
}

.door-btn {
  width: 100%;
  white-space: normal;
  text-align: center;
}

.door-primary {
  font-size: 1.1rem;
  padding: 1rem 1.4rem;
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.chapter-body p.door-note {
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0.4rem 0 0;
  text-align: center;
}

.chapter-body p.source-line,
.chapter-body p.small-print,
.chapter-body p.more-questions {
  font-size: 0.88rem;
}

.chapter-body p.more-questions {
  margin-top: 1.25rem;
}

/* Plain lists (what to expect, straight answers) */
.plain-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.plain-list li {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.75;
}

.plain-list strong {
  color: var(--text-primary);
}

/* The longer argument (closed by default) */
.longer-argument {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.longer-argument summary {
  cursor: pointer;
  padding: 0.65rem 0;
  font-weight: 700;
  color: var(--accent-emerald);
}

.longer-argument summary:hover {
  text-decoration: underline;
}

.longer-argument-body {
  padding-top: 0.5rem;
}

.chapter-body .longer-argument-body p:last-of-type {
  margin-bottom: 1.25rem;
}

.argument-citations {
  margin: 0;
}

/* Footer brand and small print */
.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  font-size: 1.35rem;
  margin-top: 1.5rem;
}

.footer-brand img {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: -4px 2px 14px rgba(222, 80, 70, 0.14), 4px 6px 14px rgba(52, 196, 134, 0.14);
}

.footer-small {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.55;
  max-width: 560px;
}

.footer-small a {
  color: var(--text-secondary);
}

/* Three news tiles between the first card and "Why local" */
.news-tiles {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.news-tiles-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0.25rem 0 0;
}

.news-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
}

.news-tile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
}

.news-tile p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-secondary);
  flex: 1;
}

.news-tile-source,
.news-tiles-more {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-emerald);
  text-decoration: none;
}

.news-tile-source:hover,
.news-tiles-more:hover {
  text-decoration: underline;
}

.news-tiles-more {
  align-self: flex-end;
}

/* Illustrated news cards: the row is wider than the reading text, like a news site */
.news-tiles {
  width: min(1200px, calc(100vw - 3rem));
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

/* Phones and narrow windows: the row sits in the normal column. */
@media (max-width: 1000px) {
  .news-tiles {
    width: auto;
    left: 0;
    transform: none;
  }
}

.news-photo-credits {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0;
}

.news-photo-credits a {
  color: inherit;
}

.news-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: 1rem;
}

.news-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.news-card:hover {
  border-color: var(--accent-emerald);
  transform: translateY(-2px);
}

.news-card:focus-visible {
  outline: 2px solid var(--accent-emerald);
  outline-offset: 2px;
}

.news-card-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: cover;
}

.news-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.8rem 1rem 0.9rem;
  flex: 1;
}

.news-card .news-meta {
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.news-card-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-primary);
}

.news-card-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
  flex: 1;
}

.news-card-source {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-emerald);
}

/* Phones: a shorter picture and the headline only; the full story is in the news section below. */
@media (max-width: 640px) {
  .news-card-img {
    aspect-ratio: 5 / 2;
  }

  .news-card-text {
    display: none;
  }
}

/* Three tabs in one card (Why local / Off the big platforms / How it works).
   Without script the tab bar stays hidden and the three read one after another. */
.tab-card {
  scroll-margin-top: 5.5rem;
}

.tab-list[hidden] {
  display: none;
}

.js-tabs .tab-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25rem;
  margin: -0.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.tab {
  position: relative;
  background: none;
  border: none;
  padding: 0.7rem 0.4rem 0.85rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  min-width: 0;
  overflow-wrap: anywhere;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.tab:focus-visible {
  outline: 2px solid var(--accent-emerald);
  outline-offset: -2px;
}

.tab[aria-selected="true"] {
  color: var(--text-primary);
}

/* The chosen tab is underlined red to green, like the logo. */
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgb(222, 58, 52), rgb(52, 196, 134));
}

/* All three panels share one grid cell, so the card keeps the height of the longest
   and the page below never jumps when the tab changes. */
.js-tabs .tab-panels {
  display: grid;
}

.js-tabs .tab-panel {
  grid-area: 1 / 1;
  visibility: hidden;
}

.js-tabs .tab-panel.is-active {
  visibility: visible;
}

/* The tab already names the panel; the heading stays for screen readers and links. */
.js-tabs .tab-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.js-tabs .tab-heading + * {
  margin-top: 0;
}

@media (max-width: 640px) {
  .header-inner {
    height: 4.5rem;
  }

  .brand {
    font-size: 1.15rem;
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .brand-icon {
    width: 2.65rem;
    height: 2.65rem;
  }

  .brand-text {
    white-space: nowrap;
  }

  .nav-links {
    gap: 0.65rem;
    flex-shrink: 0;
  }

  .nav-link {
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .theme-toggle {
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
  }

  #themeLabel {
    display: none;
  }

  .chapter-card {
    padding: 1.5rem 1.25rem;
  }

  .tab {
    font-size: 0.88rem;
    padding: 0.6rem 0.2rem 0.75rem;
  }

  /* "Off big platforms" keeps every tab to two lines on a phone. */
  .tab-wide {
    display: none;
  }

  .solution-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .container {
    padding: 0 1rem;
  }

  .chapter-card {
    padding: 1.25rem 1rem;
  }

  .beanpool-link-banner {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .banner-title {
    font-size: 1.15rem;
  }

  .door-btn,
  .door-primary {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .footer-brand {
    font-size: 1.1rem;
  }

  .footer-brand img {
    width: 2.25rem;
    height: 2.25rem;
  }

  .brand {
    font-size: 1.05rem;
  }

  .brand-icon {
    width: 2.35rem;
    height: 2.35rem;
  }

  .nav-links {
    gap: 0.45rem;
  }

  .nav-link {
    font-size: 0.78rem;
  }
}

/* Welcome: the page's opening line, above The BeanPool Project */
.welcome {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.welcome-title {
  font-size: clamp(1.7rem, 4.5vw, 2.3rem);
}

/* A new site: a quiet note above the footer */
.new-site-note {
  overflow-wrap: anywhere;
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
}

.new-site-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.new-site-note p {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* Offline mode: under the doors in the first tile */
.offline-mode {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.chapter-subtitle.offline-title {
  margin-top: 0;
}

/* ---------- Languages: the machine-translation line, the language menu, right-to-left ---------- */

.mt-note {
  background: var(--accent-amber-subtle);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
  text-align: center;
  padding: 0.4rem 1rem;
}

.mt-note a {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: underline;
}

.header-inner {
  position: relative;
}

.lang-menu {
  position: static;
}

.lang-toggle {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.35rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  transition: all 0.2s;
}

.lang-toggle::-webkit-details-marker {
  display: none;
}

.lang-toggle::marker {
  content: "";
}

.lang-toggle:hover,
.lang-menu[open] > .lang-toggle {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.lang-toggle:focus-visible,
.lang-list a:focus-visible,
.mt-note a:focus-visible {
  outline: 2px solid var(--accent-emerald);
  outline-offset: 2px;
}

.lang-current {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-list {
  position: absolute;
  inset-inline-end: 1.5rem;
  top: calc(100% + 0.4rem);
  z-index: 110;
  list-style: none;
  width: min(19rem, calc(100vw - 2rem));
  max-height: min(70vh, 28rem);
  overflow-y: auto;
  padding: 0.4rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.15rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-prominent);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.lang-list a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.3;
}

.lang-list a:hover,
.lang-list a:focus-visible {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.lang-list a[aria-current="true"] {
  color: var(--accent-emerald);
  font-weight: 700;
}

/* Right-to-left (Arabic, Persian, Urdu) */
[dir="rtl"] .news-tiles {
  left: auto;
  right: 50%;
  transform: translateX(50%);
}

@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 4.5rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    row-gap: 0.35rem;
  }

  .nav-links {
    margin-inline-start: auto;
  }

  .lang-toggle {
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
  }

  .lang-current {
    max-width: 6.5rem;
  }
}

@media (max-width: 380px) {
  .lang-list {
    inset-inline-end: 1rem;
  }
}

/* Translated pages: longer words in the three tabs at phone width */
@media (max-width: 480px) {
  html:not([lang="en"]) .tab {
    font-size: 0.8rem;
    padding-left: 0.1rem;
    padding-right: 0.1rem;
    hyphens: auto;
  }
}

/* Joined scripts: letter-spacing pulls Arabic, Persian and Urdu letters apart and breaks Indic conjuncts, so it is off there. */
html:lang(ar) *, html:lang(fa) *, html:lang(ur) *, html:lang(bn) *, html:lang(hi) *, html:lang(ml) *, html:lang(ta) * {
  letter-spacing: normal !important;
}
