/* TheWorldStatus.com: dark theme (palette per dataviz reference instance) */

:root {
  --page:        #0d0d0d;
  --surface:     #1a1a19;
  --surface-2:   #222221;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --muted:       #898781;
  --hairline:    rgba(255,255,255,0.10);
  --grid:        #2c2c2a;
  --accent:      #3987e5;
  --good:        #0ca30c;
  --warning:     #fab219;
  --critical:    #d03b3b;
}

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

html, body { height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  flex: 0 0 auto;
}
.logo { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap; }
.logo .dot-com { color: var(--accent); }
.logo-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.spacer { flex: 1; }

/* page tabs (Globe / History) */
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab {
  color: var(--ink-2); text-decoration: none;
  font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: 6px;
  border: 1px solid transparent;
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.active { color: var(--ink); background: var(--surface-2); border-color: var(--hairline); }

.metric-switch { display: flex; gap: 6px; align-items: center; }
.metric-switch .label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.metric-btn {
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--hairline); border-radius: 6px;
  font: 500 12.5px system-ui, sans-serif;
  padding: 6px 12px; cursor: pointer;
}
.metric-btn:hover { color: var(--ink); border-color: rgba(255,255,255,0.25); }
.metric-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* country / state search */
.search-wrap { position: relative; margin-left: 12px; }
#search {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 6px;
  font: 400 13px system-ui, sans-serif;
  padding: 7px 12px; width: 210px;
  outline: none;
}
#search::placeholder { color: var(--muted); }
#search:focus { border-color: var(--accent); }
#search-results {
  display: none;
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  min-width: 260px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.search-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.search-item img { width: 20px; height: auto; border-radius: 2px; flex: 0 0 auto; }
.search-item-pad { width: 20px; flex: 0 0 auto; }
.search-item.active, .search-item:hover { background: var(--surface-2); color: var(--ink); }
.search-tag {
  margin-left: auto; font-size: 10.5px; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 4px; padding: 1px 6px;
}

/* ---------- layout ---------- */
main { flex: 1 1 auto; display: flex; min-height: 0; }

#globe-wrap { flex: 1 1 auto; position: relative; min-width: 0; }
#globe { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#globe:active { cursor: grabbing; }

/* legend */
#legend {
  position: absolute; left: 18px; bottom: 16px;
  background: rgba(26,26,25,0.85); backdrop-filter: blur(4px);
  border: 1px solid var(--hairline); border-radius: 8px;
  padding: 10px 14px; font-size: 11.5px; color: var(--ink-2);
  width: 210px;
}
#legend-title { font-weight: 600; color: var(--ink); margin-bottom: 6px; }
#legend-bar { height: 8px; border-radius: 4px; margin-bottom: 4px; }
.legend-ends { display: flex; justify-content: space-between; color: var(--muted); }
.legend-war { margin-top: 8px; display: flex; align-items: center; gap: 6px; color: var(--ink-2); line-height: 1.4; }
.legend-war .war-stripes {
  width: 22px; height: 12px; border-radius: 2px; flex: 0 0 auto;
  background: repeating-linear-gradient(45deg,
    transparent 0 3px, rgba(208,59,59,0.85) 3px 5px);
  border: 1px solid rgba(208,59,59,0.4);
}
.legend-nodata { margin-top: 4px; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.legend-nodata .swatch { width: 8px; height: 8px; border-radius: 2px; background: #30302d; flex: 0 0 auto; }

/* tooltip */
#tooltip {
  position: fixed; display: none; z-index: 50; pointer-events: none;
  background: rgba(13,13,13,0.92); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 8px 11px;
  font-size: 12.5px; line-height: 1.5; color: var(--ink-2); max-width: 260px;
}
#tooltip strong { color: var(--ink); }

/* ---------- side panel ---------- */
#panel {
  flex: 0 0 400px; max-width: 44vw;
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  overflow-y: auto;
  padding: 22px 22px 34px;
}
.panel-eyebrow { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
#panel h2 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.asof { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.panel-head { margin-bottom: 14px; position: relative; padding-right: 84px; }
.panel-flag {
  position: absolute; top: 0; right: 0;
  width: 72px; height: auto;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
  outline: 1px solid var(--hairline);
}
.panel-flag-emoji { font-size: 44px; line-height: 1; width: auto; box-shadow: none; outline: none; }
.tip-flag { width: 18px; height: auto; vertical-align: -2px; border-radius: 2px; }

.back {
  background: none; border: 1px solid var(--hairline); color: var(--ink-2);
  border-radius: 6px; padding: 5px 12px; font-size: 12.5px; cursor: pointer;
  margin-bottom: 16px;
}
.back:hover { color: var(--ink); border-color: rgba(255,255,255,0.3); }

.summary { font-size: 13.5px; line-height: 1.6; color: var(--ink-2); margin-bottom: 16px; }

/* leaders / capital / known-for rows */
.kvs { margin-bottom: 16px; }
.kv {
  display: flex; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 12.5px; line-height: 1.5;
}
.kv:first-child { border-top: 1px solid var(--hairline); }
.kv-label {
  flex: 0 0 84px; color: var(--muted);
  text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.8px; padding-top: 2px;
}
.kv-value { color: var(--ink-2); }

/* status badge: icon + label, never color alone */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600;
  border-radius: 20px; padding: 4px 12px; margin: 4px 0 6px;
  border: 1px solid;
}
.badge-peace   { color: var(--good);     border-color: rgba(12,163,12,0.4);  background: rgba(12,163,12,0.08); }
.badge-tension { color: var(--warning);  border-color: rgba(250,178,25,0.4); background: rgba(250,178,25,0.08); }
.badge-war     { color: var(--critical); border-color: rgba(208,59,59,0.5);  background: rgba(208,59,59,0.10); }
.conflict-note { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.tile {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px; padding: 12px 14px;
}
.tile-label { font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.tile-value { font-size: 20px; font-weight: 700; color: var(--ink); }
.tile-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.nodata { color: var(--muted); font-weight: 500; font-size: 15px; }

.meter { height: 5px; background: var(--grid); border-radius: 3px; margin-top: 9px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 3px; }

/* trend tile value colors: improving = blue, declining = red, neutral = plain.
   Direction word + arrow accompany the color so it never carries meaning alone. */
.trend-up   { color: var(--accent); }
.trend-down { color: var(--critical); }
.trend-flat { color: var(--ink); }

/* headlines / facts */
.section-title { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 4px 0 10px; }
.headlines { list-style: none; margin-bottom: 18px; }
.headlines li {
  font-size: 13px; line-height: 1.55; color: var(--ink-2);
  padding: 9px 0; border-bottom: 1px solid var(--hairline);
}
.headlines li:first-child { border-top: 1px solid var(--hairline); }
.tag {
  display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--accent);
  border: 1px solid rgba(57,135,229,0.35); border-radius: 4px;
  padding: 1px 6px; margin-right: 8px; vertical-align: 1px;
}

.hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 10px; }
.us-hint { color: var(--ink-2); background: rgba(57,135,229,0.10); border: 1px solid rgba(57,135,229,0.3); border-radius: 6px; padding: 8px 12px; }

/* ---------- ticker ---------- */
#ticker {
  flex: 0 0 auto; overflow: hidden; white-space: nowrap;
  border-top: 1px solid var(--hairline); background: var(--surface);
  padding: 8px 0;
}
#ticker-track { display: inline-block; animation: ticker 60s linear infinite; }
#ticker:hover #ticker-track { animation-play-state: paused; }
.tick { font-size: 12.5px; color: var(--ink-2); margin-right: 48px; }
.tick .tag { margin-right: 8px; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- footer sources ---------- */
footer {
  flex: 0 0 auto;
  font-size: 10.5px; color: var(--muted);
  padding: 6px 20px; background: var(--page);
  border-top: 1px solid var(--hairline);
  line-height: 1.5;
}

/* ---------- history page ---------- */
/* The history page scrolls normally (the globe page locks body scroll). */
body.page-scroll { overflow: auto; display: block; }

.history-wrap { max-width: 880px; margin: 0 auto; padding: 36px 24px 80px; }
.history-wrap h1 { font-size: 30px; margin-bottom: 6px; }
.history-intro { color: var(--ink-2); font-size: 14.5px; line-height: 1.7; margin-bottom: 8px; }
.history-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin-bottom: 34px; }

.era { margin-bottom: 44px; }
.era-title {
  font-size: 13px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.era-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }

/* vertical timeline: hairline spine, dot per event, date column */
.timeline { border-left: 2px solid var(--grid); margin-left: 8px; padding-left: 26px; }
.tl-item { position: relative; padding-bottom: 22px; }
.tl-item:last-child { padding-bottom: 4px; }
.tl-item::before {                 /* the dot on the spine */
  content: ""; position: absolute; left: -33px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--page);
}
.tl-item.tl-future::before { background: var(--warning); }  /* projections marked amber */
.tl-date { font-size: 12px; font-weight: 700; color: var(--ink); letter-spacing: 0.4px; margin-bottom: 3px; }
.tl-text { font-size: 13.5px; color: var(--ink-2); line-height: 1.65; }
.tl-text .src { color: var(--muted); font-size: 11.5px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  main { flex-direction: column; }
  #globe-wrap { height: 55vh; flex: 0 0 auto; }
  #panel { flex: 1 1 auto; max-width: none; border-left: none; border-top: 1px solid var(--hairline); padding: 16px 16px 28px; }
  header { flex-wrap: wrap; gap: 8px; row-gap: 10px; padding: 10px 14px; }
  .logo-sub { display: none; }

  /* search takes the rest of the first header row */
  .search-wrap { flex: 1 1 120px; margin-left: 4px; }
  #search { width: 100%; }
  #search-results { left: auto; right: 0; }

  /* metric buttons become a full-width scrollable row */
  .metric-switch {
    flex: 1 0 100%; order: 5;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px;
  }
  .metric-switch::-webkit-scrollbar { display: none; }
  .metric-btn { flex: 0 0 auto; white-space: nowrap; }

  /* compact legend so it doesn't cover the globe */
  #legend { left: 10px; bottom: 10px; width: 168px; padding: 8px 10px; font-size: 10.5px; }
  .legend-war, .legend-nodata { display: none; }

  .panel-head { padding-right: 68px; }
  .panel-flag { width: 56px; }
}

@media (max-width: 520px) {
  /* search gets its own full-width header row above the metric buttons */
  .search-wrap { flex: 1 0 100%; order: 4; margin-left: 0; }
  #search-results { left: 0; right: 0; min-width: 0; }
  .metric-switch .label { display: none; }
  .tabs { margin-left: 0; }
  .tab { padding: 6px 10px; }
  .logo { font-size: 16px; }
  #globe-wrap { height: 48vh; }
}
