/* ==========================================================================
   Stratoterra — Design System & Global Styles
   Style: Concept 2 — Wave Strata
   ========================================================================== */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Background */
  --bg-primary: #0a1628;
  --bg-secondary: #0f1f3a;
  --bg-panel: #132744;
  --bg-card: #1a3050;
  --bg-hover: #1e3a5f;

  /* Text */
  --text-primary: #EDF2F7;
  --text-secondary: #8DA4BF;
  --text-accent: #4A9FE5;       /* Datalogic Blue accent */
  --text-muted: #5A7A99;

  /* Trend colors */
  --trend-strong-growth: #00c853;
  --trend-growth: #69f0ae;
  --trend-stable: #ffd54f;
  --trend-decrease: #ff8a65;
  --trend-strong-decrease: #ff1744;

  /* Alert colors */
  --alert-critical: #ff4757;
  --alert-warning: #ffab40;
  --alert-watch: #60a5fa;

  /* Relationship quality */
  --relation-allied: #00c853;
  --relation-friendly: #69f0ae;
  --relation-neutral: #94A3B8;
  --relation-cool: #ff8a65;
  --relation-hostile: #ff1744;

  /* Map-specific */
  --map-ocean: #061220;
  --map-land-default: #1a3050;
  --map-border: #2a4a6b;
  --map-highlight: #4A9FE5;

  /* Layout */
  --header-height: 52px;
  --footer-height: 44px;
  --panel-width: 40%;
  --panel-max-width: 560px;
  --panel-min-width: 360px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease-out;

  /* Critical blink */
  --critical-blink-color: #ff4757;

  /* Borders */
  --border-subtle: 1px solid #1a3050;
  --border-card: 1px solid rgba(74, 159, 229, 0.15);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }

.mono, .data-value {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

a {
  color: var(--text-accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* --- App Layout --- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* --- Header --- */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: var(--border-subtle);
  z-index: 1000;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* --- Logo (Wave Strata) --- */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.logo:hover { text-decoration: none; }

.logo__icon {
  flex-shrink: 0;
  display: block;
}

.logo__wordmark {
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 2px;
  color: #F1F5F9;
  font-family: 'Outfit', sans-serif;
}

.header-center {
  flex: 0 1 320px;
}

#search {
  width: 100%;
  padding: 6px 12px;
  background: var(--bg-primary);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  outline: none;
  transition: border-color var(--transition-fast);
}

#search:focus {
  border-color: var(--text-accent);
}

#search::placeholder {
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#main-nav {
  display: flex;
  gap: 4px;
}

/* --- Language Selector --- */
.lang-selector {
  position: relative;
  margin-left: 4px;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-primary);
  border: var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: 'Outfit', sans-serif;
}

.lang-toggle:hover {
  border-color: var(--text-accent);
  color: var(--text-primary);
}

#lang-flag {
  font-size: 14px;
  line-height: 1;
}

.lang-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1100;
  min-width: 120px;
  overflow: hidden;
}

.lang-dropdown.open {
  display: block;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-family: 'Outfit', sans-serif;
}

.lang-option:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.lang-option.active {
  color: var(--text-accent);
}

.lang-option__flag {
  font-size: 16px;
  line-height: 1;
}

.lang-option__label {
  flex: 1;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card);
  text-decoration: none;
}

.nav-link.active {
  color: var(--text-accent);
  background: rgba(74, 159, 229, 0.08);
}

/* --- Main Content --- */
#main-content {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  min-height: 0;
  z-index: 0;  /* Create stacking context — contain Leaflet z-indices within map area */
}

#map-container {
  flex: 1;
  position: relative;
  transition: flex var(--transition-normal);
}

/* Panel open state: map shrinks */
#main-content.panel-open #map-container {
  flex: 0 0 60%;
}

/* --- Country Panel --- */
.panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--panel-width);
  max-width: var(--panel-max-width);
  min-width: var(--panel-min-width);
  height: 100%;
  background: var(--bg-secondary);
  border-left: var(--border-subtle);
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  z-index: 900;
}

.panel.open {
  transform: translateX(0);
}

.panel.hidden {
  display: none;
}

.force-hidden {
  display: none !important;
}

/* --- Bottom Bar / Footer --- */
#bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--footer-height);
  padding: 0 16px;
  background: var(--bg-secondary);
  border-top: var(--border-subtle);
  z-index: 1000;
  flex-shrink: 0;
}

.metric-selector,
.overlay-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-selector label,
.overlay-selector label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#metric-select,
#overlay-select {
  padding: 4px 8px;
  background: var(--bg-primary);
  border: var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

#metric-select:focus,
#overlay-select:focus {
  border-color: var(--text-accent);
}

#metric-select option,
#overlay-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.last-updated {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.3px;
}

/* --- Alert Ticker — Two-bar system --- */

/* Outer container: fixed, stacks bars above bottom bar */
.alert-ticker {
  position: fixed;
  bottom: var(--footer-height);
  left: 0;
  right: 0;
  z-index: 950;
  display: flex;
  flex-direction: column;
}

.alert-ticker.hidden { display: none; }

/* ── Primary bar (critical / warning) ── */
.ticker-primary {
  display: none;
  height: 44px;
  align-items: stretch;
  overflow: hidden;
}

.ticker-primary.active {
  display: flex;
  animation: ticker-primary-in 300ms ease-out;
}

@keyframes ticker-primary-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Severity tag */
.ticker-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}

.ticker-tag--critical { background: #DC2626; }
.ticker-tag--warning  { background: #D97706; }

/* Gradient bleed from tag into content */
.ticker-tag--critical::after {
  content: '';
  position: absolute;
  right: -12px; top: 0; bottom: 0; width: 12px;
  background: linear-gradient(90deg, #DC2626, rgba(220,38,38,0));
  z-index: 1;
}
.ticker-tag--warning::after {
  content: '';
  position: absolute;
  right: -12px; top: 0; bottom: 0; width: 12px;
  background: linear-gradient(90deg, #D97706, rgba(217,119,6,0));
  z-index: 1;
}

/* Pulsing dot (critical only) */
.ticker-tag__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  animation: ticker-dot-pulse 1s ease-in-out infinite;
}
.ticker-tag__dot.hidden { display: none; }

@keyframes ticker-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* Content area */
.ticker-content {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 20px;
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.4s;
}

.ticker-content--critical {
  background: rgba(220,38,38,0.12);
  border-top: 1px solid rgba(220,38,38,0.25);
  animation: ticker-critical-pulse 2s ease-in-out infinite;
}
.ticker-content--warning {
  background: rgba(217,119,6,0.10);
  border-top: 1px solid rgba(217,119,6,0.20);
}

@keyframes ticker-critical-pulse {
  0%, 100% { background-color: rgba(220,38,38,0.12); }
  50%       { background-color: rgba(220,38,38,0.20); }
}

.ticker-headline {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker-content--critical .ticker-headline { color: #FCA5A5; }
.ticker-content--warning  .ticker-headline { color: #FCD34D; }

.ticker-timestamp {
  flex-shrink: 0;
  padding-left: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.ticker-content--critical .ticker-timestamp { color: rgba(252,165,165,0.5); }
.ticker-content--warning  .ticker-timestamp { color: rgba(252,211,77,0.4); }

/* ── Secondary bar (watch) ── */
.ticker-secondary {
  display: none;
  height: 30px;
  align-items: stretch;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
}

.ticker-secondary.active { display: flex; }

.ticker-tag-sm {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #3B82F6;
  background: rgba(59,130,246,0.08);
  white-space: nowrap;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
}

.ticker-scroll-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ticker-scroll-track {
  display: flex;
  align-items: center;
  width: max-content;
  height: 100%;
  animation: ticker-scroll 45s linear infinite;
}

.ticker-scroll-track:hover { animation-play-state: paused; }

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-scroll-item {
  padding: 0 32px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #94A3B8;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.ticker-scroll-item:hover { color: var(--text-primary); }

.ticker-scroll-sep {
  font-size: 8px;
  color: #253557;
  padding: 0;
  user-select: none;
  flex-shrink: 0;
}

/* Main-content margin adjustments */
#app.ticker-watch-on #main-content              { margin-bottom: 30px; }
#app.ticker-primary-on #main-content            { margin-bottom: 44px; }
#app.ticker-watch-on.ticker-primary-on #main-content { margin-bottom: 74px; }

/* --- Disclaimer --- */
#disclaimer {
  position: fixed;
  bottom: var(--footer-height);
  left: 0;
  right: 0;
  padding: 4px 16px;
  background: rgba(11, 17, 32, 0.88);
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  z-index: 500;
  pointer-events: none;
}

#disclaimer a {
  pointer-events: auto;
  color: var(--text-secondary);
}

/* --- View Containers --- */
.view-container {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  background: var(--bg-primary);
  padding: 24px;
}

.view-container.active {
  display: block;
}

/* --- Component: Trend Indicators --- */
.trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}

.trend--strong-growth { color: var(--trend-strong-growth); }
.trend--growth { color: var(--trend-growth); }
.trend--stable { color: var(--trend-stable); }
.trend--decrease { color: var(--trend-decrease); }
.trend--strong-decrease { color: var(--trend-strong-decrease); }

.trend-arrow::after { font-size: 14px; }
.trend--strong-growth .trend-arrow::after { content: '⬆'; }
.trend--growth .trend-arrow::after { content: '↗'; }
.trend--stable .trend-arrow::after { content: '→'; }
.trend--decrease .trend-arrow::after { content: '↘'; }
.trend--strong-decrease .trend-arrow::after { content: '⬇'; }

/* --- Component: Confidence Bar --- */
.confidence-bar {
  display: inline-block;
  width: 60px;
  height: 4px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
}

.confidence-bar__fill {
  height: 100%;
  border-radius: 2px;
  transition: width var(--transition-normal);
}

.confidence-bar__fill--high { background: var(--trend-strong-growth); }
.confidence-bar__fill--medium { background: var(--trend-stable); }
.confidence-bar__fill--low { background: var(--trend-decrease); }

/* --- Component: Alert Badge --- */
.alert-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.alert-badge--critical {
  background: rgba(255, 71, 87, 0.15);
  color: var(--alert-critical);
  text-shadow: 0 0 8px rgba(255, 71, 87, 0.4);
}

.alert-badge--warning {
  background: rgba(255, 171, 64, 0.12);
  color: var(--alert-warning);
}

.alert-badge--watch {
  background: rgba(96, 165, 250, 0.12);
  color: var(--alert-watch);
}

/* --- Component: Factor Card --- */
.factor-card {
  padding: 12px;
  background: var(--bg-card);
  border: var(--border-card);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: background var(--transition-fast);
}

.factor-card:hover {
  background: var(--bg-hover);
}

.factor-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.factor-card__label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.factor-card__value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.factor-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

/* --- Component: Loading Skeleton --- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Component: Error Card --- */
.error-card {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 23, 68, 0.2);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--text-secondary);
}

.error-card__title {
  color: var(--alert-critical);
  margin-bottom: 8px;
}

.error-card__retry {
  margin-top: 12px;
  padding: 6px 16px;
  background: var(--bg-hover);
  border: var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-accent);
  cursor: pointer;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
}

/* --- Leaflet Overrides --- */
.leaflet-container {
  background: var(--map-ocean);
  font-family: 'Outfit', sans-serif;
}

.leaflet-control-zoom a {
  background: var(--bg-panel) !important;
  color: var(--text-primary) !important;
  border-color: #1E293B !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-hover) !important;
}

.leaflet-control-attribution {
  background: rgba(11, 17, 32, 0.85) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* Tooltip styling */
.leaflet-tooltip {
  background: var(--bg-panel) !important;
  border: 1px solid #1E293B !important;
  border-radius: var(--radius-md) !important;
  color: var(--text-primary) !important;
  padding: 8px 12px !important;
  font-family: 'Outfit', sans-serif !important;
  font-size: 13px !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-tooltip::before {
  display: none !important;
}

.country-tooltip { min-width: 180px; }

.country-tooltip__name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.country-tooltip__metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  margin-bottom: 2px;
}

.country-tooltip__metric-label { color: var(--text-secondary); }

.country-tooltip__metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

/* --- Color Legend --- */
.color-legend {
  position: absolute;
  bottom: 24px;
  left: 12px;
  z-index: 800;
  background: var(--bg-panel);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-width: 140px;
}

.color-legend__title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.color-legend__gradient {
  height: 8px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.color-legend__labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
}

/* --- Chokepoint Markers --- */
.chokepoint-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: rgba(255, 171, 64, 0.15);
  border: 2px solid var(--alert-warning);
  border-radius: 50%;
  font-size: 10px;
  color: var(--alert-warning);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.chokepoint-icon:hover { transform: scale(1.3); }

.chokepoint-icon--critical {
  background: rgba(255, 23, 68, 0.15);
  border-color: var(--alert-critical);
  color: var(--alert-critical);
}

.chokepoint-icon--high {
  background: rgba(255, 171, 64, 0.15);
  border-color: var(--alert-warning);
  color: var(--alert-warning);
}

/* --- Search Dropdown --- */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: var(--border-subtle);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  max-height: 300px;
  overflow-y: auto;
  z-index: 2000;
  display: none;
}

.search-dropdown.open { display: block; }

.search-dropdown__item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition-fast);
}

.search-dropdown__item:hover,
.search-dropdown__item.active {
  background: var(--bg-hover);
}

.search-dropdown__item-region {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: auto;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(30, 41, 59, 0.9); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.6); }

/* ==========================================================================
   View-Specific Styles
   ========================================================================== */

/* --- Briefing View --- */
.briefing {
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 32px;
}

.briefing-headline { margin-bottom: 24px; }

.briefing-headline h2 {
  font-size: 24px;
  font-weight: 300;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.briefing-date {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.5px;
}

.market-strip {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: var(--border-card);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  overflow-x: auto;
}

.market-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  padding: 6px 12px;
}

.market-chip__label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.market-chip__value {
  font-size: 14px;
  font-weight: 600;
}

.market-chip__change { font-size: 11px; }

.briefing-section { margin-bottom: 24px; }

.briefing-section h3 {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: var(--border-subtle);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.story-card {
  padding: 16px;
  background: var(--bg-card);
  border: var(--border-card);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  transition: border-color var(--transition-fast);
}

.story-card:hover {
  border-color: rgba(74, 159, 229, 0.2);
}

.story-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.story-card__number {
  color: var(--text-accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
}

.story-card__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.story-card__body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.story-card__countries {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.story-card__action {
  margin-top: 8px;
  padding-top: 8px;
  border-top: var(--border-subtle);
  font-size: 12px;
  color: var(--text-accent);
}

/* Region tabs */
.region-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.region-tab {
  padding: 6px 12px;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.region-tab:hover { background: var(--bg-hover); color: var(--text-secondary); }
.region-tab.active { background: rgba(74, 159, 229, 0.12); color: var(--text-accent); }

.region-content {
  display: none;
  padding: 12px;
  background: var(--bg-card);
  border: var(--border-card);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  overflow-wrap: break-word;
}

.region-content.active { display: block; }

/* --- Article Grid (Briefing Listing) --- */
.article-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}


.article-card {
  display: block;
  background: var(--bg-card);
  border: var(--border-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  text-decoration: none;
  color: inherit;
}

.article-card:hover {
  border-color: var(--text-accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.article-card__image {
  aspect-ratio: 2 / 1;
  overflow: hidden;
  background: var(--bg-secondary);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.article-card__image svg {
  width: 100%;
  height: 100%;
  display: block;
}

.article-card__body {
  padding: 12px 16px 16px;
}

.article-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.article-card__date {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.article-card__category {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(96, 165, 250, 0.12);
  color: var(--alert-watch);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.article-card__headline {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0 0 6px;
}


.article-card__subheadline {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 6px;
  line-height: 1.4;
}

.article-card__excerpt {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

/* --- Article Card SVG Hover Animations --- */

/* Polygons: gentle vertical float */
.article-card__image svg polygon {
  animation-name: svg-float;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-play-state: paused;
  animation-duration: 3.5s;
  transform-box: fill-box;
  transform-origin: center;
}
.article-card__image svg polygon:nth-of-type(2) { animation-duration: 4s; animation-delay: 0.5s; }
.article-card__image svg polygon:nth-of-type(3) { animation-duration: 3.8s; animation-delay: 1s; }
.article-card__image svg polygon:nth-of-type(4) { animation-duration: 4.2s; animation-delay: 1.5s; }
.article-card__image svg polygon:nth-of-type(5) { animation-duration: 3.6s; animation-delay: 2s; }

/* Circles: scale + brightness pulse */
.article-card__image svg circle {
  animation-name: svg-circle-pulse;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-play-state: paused;
  animation-duration: 3s;
  transform-box: fill-box;
  transform-origin: center;
}
.article-card__image svg circle:nth-of-type(2) { animation-duration: 3.5s; animation-delay: 0.7s; }
.article-card__image svg circle:nth-of-type(3) { animation-duration: 2.8s; animation-delay: 1.4s; }
.article-card__image svg circle:nth-of-type(4) { animation-duration: 3.2s; animation-delay: 2.1s; }

/* Paths (waves, curves): horizontal drift */
.article-card__image svg path {
  animation-name: svg-drift;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-play-state: paused;
  animation-duration: 5s;
  transform-box: fill-box;
  transform-origin: center;
}
.article-card__image svg path:nth-of-type(2) { animation-duration: 5.5s; animation-delay: 0.8s; }
.article-card__image svg path:nth-of-type(3) { animation-duration: 4.5s; animation-delay: 1.6s; }

/* Polylines (chart lines): glow pulse */
.article-card__image svg polyline {
  animation-name: svg-glow;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-play-state: paused;
  animation-duration: 2s;
}

/* Activate all on hover */
.article-card:hover .article-card__image svg polygon,
.article-card:hover .article-card__image svg circle,
.article-card:hover .article-card__image svg path,
.article-card:hover .article-card__image svg polyline {
  animation-play-state: running;
}

@keyframes svg-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes svg-circle-pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.08); filter: brightness(1.3); }
}

@keyframes svg-drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(5px); }
}

@keyframes svg-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5) drop-shadow(0 0 4px currentColor); }
}

/* --- Article Detail --- */
.article {
  max-width: 740px;
  margin: 0 auto;
  padding: 16px;
}

.article__back {
  display: inline-block;
  color: var(--text-accent);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 16px;
  transition: opacity var(--transition-fast);
}

.article__back:hover { opacity: 0.8; }

.article__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.article__headline {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  margin: 0 0 8px;
}

.article__subheadline {
  font-size: 16px;
  font-weight: 300;
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.4;
}

.article__byline {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.article__ai-badge {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(74, 159, 229, 0.15);
  color: var(--text-accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.article__hero {
  margin: 0 0 24px;
}

.article__hero svg {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
}

.article__hero-caption {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

.article__body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.article__body h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 28px 0 12px;
  letter-spacing: 0.3px;
}

.article__body p {
  margin: 0 0 16px;
}

.article__lede {
  font-size: 17px;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 20px;
}

.article__countries {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.article__countries-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.article__sources {
  margin: 16px 0;
  padding: 16px;
  background: var(--bg-card);
  border: var(--border-card);
  border-radius: var(--radius-md);
}

.article__sources h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.article__sources ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.article__sources li {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.article__sources a {
  color: var(--alert-watch);
  text-decoration: none;
}

.article__sources a:hover {
  text-decoration: underline;
}

.article__source-date {
  font-size: 11px;
  color: var(--text-muted);
}

.article__disclaimer {
  margin: 20px 0;
  padding: 14px 16px;
  background: rgba(74, 159, 229, 0.06);
  border: 1px solid rgba(74, 159, 229, 0.15);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.6;
}

/* Mobile: single column */
@media (max-width: 768px) {
  .article-grid {
    grid-template-columns: 1fr;
  }
  .article__headline {
    font-size: 22px;
  }
}

/* --- Alerts Dashboard --- */
.alerts-dashboard {
  max-width: 900px;
  margin: 0 auto;
}

.alerts-dashboard h2 {
  margin-bottom: 16px;
  font-weight: 300;
  letter-spacing: 1px;
}

/* --- Alert Manga Hero --- */
.alert-manga-hero {
  margin-bottom: 20px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.alert-manga-hero svg {
  width: 100%;
  height: auto;
  display: block;
}

.alert-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}

.alert-filter-select {
  padding: 6px 10px;
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  cursor: pointer;
}

.alert-section { margin-bottom: 24px; }

.alert-section__title {
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.alert-card {
  padding: 16px;
  background: var(--bg-card);
  border: var(--border-card);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border-left: 3px solid transparent;
}

.alert-card--critical { border-left-color: var(--alert-critical); }
.alert-card--warning  { border-left-color: var(--alert-warning); }
.alert-card--watch    { border-left-color: var(--alert-watch); }

.alert-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.alert-card__type {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
  letter-spacing: 0.5px;
}

.alert-card__title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.alert-card__body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.alert-card__countries {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.alert-card__action {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-accent);
}

/* --- Rankings View --- */
.rankings { max-width: 1100px; margin: 0 auto; }

.rankings h2 {
  margin-bottom: 16px;
  font-weight: 300;
  letter-spacing: 1px;
}

.rankings-groups {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.rankings-table-wrap { overflow-x: auto; }

.rankings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rankings-table thead { position: sticky; top: 0; z-index: 1; }

.rankings-table th {
  padding: 10px 12px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
  border-bottom: var(--border-subtle);
  white-space: nowrap;
}

.rankings-table td {
  padding: 8px 12px;
  border-bottom: var(--border-subtle);
  white-space: nowrap;
}

.rankings-table tbody tr {
  transition: background var(--transition-fast);
  cursor: pointer;
}

.rankings-table tbody tr:hover { background: var(--bg-hover); }

.rankings-table tbody tr:nth-child(even) { background: rgba(22, 32, 50, 0.4); }
.rankings-table tbody tr:nth-child(even):hover { background: var(--bg-hover); }

.rank-col { width: 40px; text-align: center; color: var(--text-muted); }
.name-col { min-width: 160px; }

/* --- Comparison Tool --- */
.comparison { max-width: 1000px; margin: 0 auto; }

.comparison h2 {
  margin-bottom: 16px;
  font-weight: 300;
  letter-spacing: 1px;
}

.compare-selector { margin-bottom: 20px; position: relative; }

.compare-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.compare-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: 16px;
  font-size: 13px;
}

.compare-tag__remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.compare-tag__remove:hover { color: var(--alert-critical); }

.compare-search {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  outline: none;
}

.compare-search:focus { border-color: var(--text-accent); }

.compare-mode-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.radar-container { text-align: center; padding: 20px; }

.radar-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  background: var(--card-bg);
  border-radius: 8px;
}

.radar-legend__item {
  font-size: 0.85rem;
  color: var(--text-primary);
}

/* --- Relations Tab (country panel split layout) --- */
.relations-network {
  width: 100%;
  height: 240px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 4px;
}

.relations-network svg {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
}

.relations-network text { font-family: 'Outfit', sans-serif; }

.relations-table-wrap {
  overflow-x: hidden;
}

.relations-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.relations-table th {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 400;
  padding: 6px 4px;
  border-bottom: var(--border-subtle);
  text-align: left;
}

.relations-table__row {
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--transition-fast);
}

.relations-table__row:hover { background: var(--bg-hover); }

.relations-table td { padding: 6px 4px; vertical-align: middle; }

.relations-table__code {
  font-weight: 600;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

.relations-table__type {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: capitalize;
}

.relations-quality-bar {
  width: 36px;
  height: 4px;
  background: rgba(100, 100, 180, 0.2);
  border-radius: 2px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
}

.relations-quality-fill {
  height: 100%;
  border-radius: 2px;
}

.relations-table__score {
  font-size: 11px;
  color: var(--text-secondary);
  vertical-align: middle;
}

/* --- Bilateral Overlay --- */
.bilateral-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bilateral-overlay__card {
  position: relative;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--bg-secondary);
  border: var(--border-card);
  border-radius: var(--radius-md);
  padding: 24px;
  overflow-y: auto;
}

.bilateral-overlay__close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.bilateral-overlay__close:hover { color: var(--text-primary); }

/* --- Critical Alert Blink (country borders on map) --- */
@keyframes critical-border-blink {
  0%, 100% { stroke: #ff1744; stroke-opacity: 1; stroke-width: 2.5; }
  50% { stroke: #ff1744; stroke-opacity: 0.15; stroke-width: 1; }
}

.leaflet-interactive.critical-blink {
  animation: critical-border-blink 1.4s ease-in-out infinite;
}

/* --- Responsive fallback --- */
.view-container { padding: 24px; }

@media (max-width: 768px) {
  .view-container { padding: 12px; }
  .market-strip { flex-wrap: wrap; }
  .alert-summary-bar { flex-direction: column; }
  .factor-grid { grid-template-columns: 1fr; }
}
