/* =========== Pipedreams Dark Theme =========== */
@import url('https://fonts.googleapis.com/css2?family=Russo+One&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap');
:root{
  --bg: #0a0a0a;
  --panel: #1a1a1a;
  --panel-2: #1e1e1e;
  --border: #2a2a2a;
  --fg: #e0e0e0;
  --muted: #bdbdbd;
  --accent: #b01515;
  --accent-700: #8c1111;
  --accent-900: #5f0b0b;
  --ok: #21c87a;
  --warn: #ffcc80;
  --err: #ef5350;
  --heading-font: 'Orbitron', sans-serif;
}

/* Base */
* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin:0;
  font-family: 'Russo One', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.45;
}

/* Header */
header{
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border-bottom: 2px solid var(--accent);
  padding: 18px 24px 16px 244px; /* leaves space for sidebar */
  position: sticky;
  top: 0;
  z-index: 50;
  font-family: 'Orbitron', sans-serif;
}
header h1{
  margin:0;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Orbitron', sans-serif;
}
header p{
  margin:.25rem 0 0 0;
  color: var(--muted);
  font-size: .95rem;
}

/* Sidebar Nav */
nav{
  width: 220px;
  position: fixed;
  inset: 0 auto 0 0; /* top/right/bottom/left */
  background: var(--panel);
  border-right: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  padding-top: 16px;
  z-index: 60;
}
nav a{
  padding: 12px 16px;
  color: var(--fg);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
nav a:hover{
  background: #242424;
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Main content */
main{
  margin-left: 220px;
  padding: 24px;
  max-width: 1500px;
}

/* Sections & Cards */
section{ margin-bottom: 24px; }
h2{
  color: var(--accent);
  margin: 0 0 12px 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  font-family: var(--heading-font);
}
.card{
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.2), 0 6px 24px rgba(0,0,0,.25);
  margin-bottom: 12px;
}

/* Links & Buttons */
a{ color: var(--accent); }
a:hover{ color: var(--accent-700); }
.btn{
  display:inline-block;
  background: var(--accent);
  color: #212121 !important;
  border:1px solid var(--accent-900);
  border-radius: 8px;
  padding: 10px 14px;
  text-decoration:none;

}
.btn:hover{ background: var(--accent-700); }

/* Lists */
ul{ margin: 0 0 0 1.1rem; }
.card ul{ margin: .25rem 0 0 1.1rem; }

/* Images */
img{
  max-width:100%;
  height:auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}
img.map{
  display:block;
  margin: 14px auto;
  max-width: 92%;
  border: 2px solid var(--accent);
}
img.chart{
  display:inline-block;
  max-width: 360px;
  margin: 10px;
  border: 1px solid var(--accent-900);
}

/* Charts Grid (auto-wrap) */
.charts-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.charts-grid img.chart{
  width:100%;
  max-width:100%;
  margin:0;
}

/* System tiles (optional) */
.tiles{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(240px,1fr));
  gap:12px;
}
.tile{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: 10px;
  padding:12px;
}
.tile h3{ margin:0 0 6px 0; color: var(--accent) !important; font-family: var(--heading-font); }
.tile .meta{ color: var(--muted); font-size: .9rem; }

/* Badges */
.badges{ display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 8px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: #222;
  color: var(--fg);
  font-size: .85rem;
}
.badge--ok{ border-color: #125c3f; background:#0d3b2a; color:#c9f7df; }
.badge--warn{ border-color:#5c4212; background:#3b2b0d; color:#ffe3b3; }
.badge--err{ border-color:#5c1212; background:#3b0d0d; color:#ffc9c8; }
.badge-dot{
  width:8px; height:8px;
  border-radius:50%;
  background: var(--accent);
}

/* Tables (for quick stats) */
.table{
  width:100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.table th, .table td{
  padding:10px 12px;
  border-bottom:1px solid var(--border);
}
.table thead th{
  text-align:left;
  background: #222;
  color: var(--fg);
}
.table tr:hover td{ background:#191919; }

/* Legend chips */
.legend{
  display:flex; flex-wrap:wrap; gap:8px; margin-top:10px;
}
.legend .chip{
  display:inline-flex; align-items:center; gap:8px;
  background:#202020; border:1px solid var(--border);
  padding:6px 10px; border-radius:999px; color:#fff;
}
.legend .dot{
  width:10px; height:10px; border-radius:50%; background:#ccc; outline:1px solid #222;
}
.dot--hq{ background: var(--accent); }
.dot--controlled{ background: #dddddd; }
.dot--front{ background: #bdbdbd; }
.dot--hop{ background: #ffcc80; }
.dot--target{ background: #90caf9; }

/* Code blocks (if you render markdown) */
pre, code{
  background:#141414;
  border:1px solid #272727;
  border-radius:8px;
  color:#f3f3f3;
}
pre{ padding:12px; overflow:auto; }
code{ padding:2px 6px; }

/* Footer (optional) */
footer{
  margin: 40px 0 20px;
  text-align:center;
  color: var(--muted);
}

/* Scrollbar (WebKit) */
*::-webkit-scrollbar{ width:10px; height:10px; }
*::-webkit-scrollbar-thumb{
  background: #2d2d2d;
  border:2px solid #151515;
  border-radius:10px;
}
*::-webkit-scrollbar-thumb:hover{ background:#3a3a3a; }

/* Responsive */
@media (max-width: 980px){
  nav{
    position: sticky;
    top: 0;
    height: auto;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 2px solid var(--accent);
  }
  nav a{ white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  nav a:hover{ border-bottom-color: var(--accent); }
  header{ padding-left: 24px; }
  main{ margin-left: 0; padding: 16px; }
  img.chart{ max-width: 100%; }
}

/* --- Active Fronts grid + cards --- */
.front-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap:12px;
}

.front-card__header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}
.front-card__header h3{
  margin:0;
  font-family: var(--heading-font);
  color: var(--accent) !important;
}
.chip--accent{ border-color: var(--accent-900); background: #2a0f0f; color:#ffd6d6; }

/* progress bar for conflicts (0–7 days) */
.progress{
  width:100%;
  height:10px;
  background:#191919;
  border:1px solid var(--border);
  border-radius:999px;
  overflow:hidden;
  margin:8px 0 4px;
}
.progress__bar{
  height:100%;
  background: var(--accent);
}
.progress__caption{
  font-size:.85rem;
  color: var(--muted);
  margin-bottom:8px;
}

/* small meta line under tables in cards */
.meta{ color: var(--muted); font-size:.9rem; margin:.4rem 0 0 0; }

/* optional sections inside cards */
.front-card__notes p{ margin:.6rem 0; }
.front-card__plays h4{ margin:.6rem 0 .25rem 0; font-family: var(--heading-font); }
.front-card__plays ul{ margin:.25rem 0 0 1rem; }

/* Influence delta badges */
.delta{ font-weight:600; }
.delta--up{ color: var(--ok); }
.delta--down{ color: var(--err); }
.delta--flat, .delta--none{ color: var(--muted); }

/* Sparklines in table */
img.spark{ width:140px; height:auto; display:block; }

/* Top Movers layout */
.top-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(280px,1fr));
  gap:12px;
}
.stat{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:#111;
  margin-bottom:8px;
}
.stat-up{ border-color:#125c3f; background:#0d3b2a; }
.stat-down{ border-color:#5c1212; background:#3b0d0d; }
.stat .name a{ color: var(--fg); }
.stat .num{ white-space: nowrap; }
.muted{ color: var(--muted); }
/* Two-column split for movers */
.split-two{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  align-items:start;
  border-radius:8px;
  border:1px solid var(--border);
  padding:8px 10px;
}
.split-two h3{ margin:0 0 8px 0; font-weight: normal;}
@media (max-width: 980px){
  .split-two{ grid-template-columns: 1fr; }
}

/* ========= Conflict / Active Fronts ========== */
.conflict-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap:14px;
}
.conflict-card{
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  padding: 12px; /* basic fallback for simple cards */
  box-shadow: 0 0 0 1px rgba(0,0,0,.2), 0 6px 24px rgba(0,0,0,.25);
}
.conflict-card .title{ font-weight:700; margin-bottom:6px; }

/* fancy layout applies only when we also add .is-rich */
.conflict-card.is-rich{
  display:grid;
  grid-template-columns: 1fr 120px 1fr;
  align-items: stretch;
  padding:0;
}
.conflict-card.is-rich .side{
  padding:14px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  gap:8px;
}
.conflict-card.is-rich .side .name{ color: var(--accent); font-weight: normal !important; }
.conflict-card.is-rich .side .score{ font-size:1.8rem; font-weight:800; }
.conflict-card.is-rich .side.ours{
  background: #151515;
  border-right: 1px solid var(--border);
  outline: 2px solid rgba(176,21,21,.25);
}
.conflict-card.is-rich .center{
  background: #101010;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding:12px 10px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  text-align:center;
}
.conflict-chip{
  display:inline-flex; align-items:center; gap:8px;
  padding:4px 10px; border-radius:999px;
  background:#201010; border:1px solid var(--accent-900);
  color:#ffd6d6; font-weight:700; font-size:.9rem;
}
.status-chip{
  display:inline-block; padding:2px 8px; border-radius:999px;
  border:1px solid var(--border); color:var(--muted); font-size:.8rem;
}
.stake{ color: var(--muted); font-size:.9rem; }
.series{ width:100%; }
.series .progress{ height:8px; border-radius:999px; background:#191919; border:1px solid var(--border); overflow:hidden; }
.series .progress__bar{ height:100%; background: var(--accent); }
.conflict-footer{
  grid-column: 1 / -1;
  padding:10px 12px;
  border-top:1px solid var(--border);
  display:flex; justify-content:space-between; align-items:center;
  background:#131313; color: var(--muted);
}
.conflict-footer a{ color: var(--fg); }
.conflict-footer .when{ font-size:.9rem; }
.conflict--war .center{ box-shadow: inset 0 0 0 1px rgba(176,21,21,.15); }
.conflict--election .center{ box-shadow: inset 0 0 0 1px rgba(144,202,249,.15); }
.conflict--civilwar .center{ box-shadow: inset 0 0 0 1px rgba(255,204,128,.15); }
@media (max-width: 520px){
  .conflict-card.is-rich{ grid-template-columns: 1fr; }
  .conflict-card.is-rich .center{ order:-1; border-left:none; border-right:none; border-top:1px solid var(--border); border-bottom:1px solid var(--border); }
  .conflict-card.is-rich .side.ours{ outline:none; }
}

/* ---------- Compatibility for builder hooks ---------- */
.badge{ /* already present, keep for builder tables */ }
.table .delta{ font-weight:700; }
.table .ctl{ color: var(--muted); }
img.spark{ border: none; }

/* === States chip colors (transparent tints when count > 0) === */
#states-overview .chip--state { transition: background .18s ease, border-color .18s ease; }
#states-overview .chip--state.chip--on { box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }

/* Happiness */
#states-overview [data-key="happy"].chip--on        { background: rgba(144,202,249,.12); border-color: rgba(144,202,249,.35); }
#states-overview [data-key="elated"].chip--on       { background: rgba(100,181,246,.12); border-color: rgba(100,181,246,.35); }
#states-overview [data-key="unhappy"].chip--on      { background: rgba(239,83,80,.12);  border-color: rgba(239,83,80,.35); }
#states-overview [data-key="discontented"].chip--on { background: rgba(255,112,67,.12);  border-color: rgba(255,112,67,.35); }
#states-overview [data-key="despondent"].chip--on   { background: rgba(183,28,28,.12);   border-color: rgba(183,28,28,.35); }

/* Economy */
#states-overview [data-key="boom"].chip--on         { background: rgba(66,165,245,.12);  border-color: rgba(66,165,245,.35); }
#states-overview [data-key="investment"].chip--on   { background: rgba(38,166,154,.12);  border-color: rgba(38,166,154,.35); }
#states-overview [data-key="bust"].chip--on         { background: rgba(211,47,47,.12);   border-color: rgba(211,47,47,.35); }

/* Security */
#states-overview [data-key="civil liberty"].chip--on{ background: rgba(102,187,106,.12); border-color: rgba(102,187,106,.35); }
#states-overview [data-key="civil unrest"].chip--on { background: rgba(255,204,128,.14); border-color: rgba(255,204,128,.45); color:#ffe3b3; }
#states-overview [data-key="lockdown"].chip--on     { background: rgba(239,83,80,.12);   border-color: rgba(239,83,80,.35); }

/* Headline */
#states-overview [data-key="war"].chip--on          { background: rgba(176,21,21,.18);   border-color: rgba(176,21,21,.55); }
#states-overview [data-key="civil war"].chip--on    { background: rgba(255,204,128,.14); border-color: rgba(255,204,128,.45); color:#ffe3b3; }
#states-overview [data-key="election"].chip--on     { background: rgba(144,202,249,.14); border-color: rgba(144,202,249,.45); }
#states-overview [data-key="expansion"].chip--on    { background: rgba(176,21,21,.22);   border-color: rgba(176,21,21,.55); }

/* A few common "Other" states */
#states-overview [data-key="outbreak"].chip--on            { background: rgba(139,195,74,.12);  border-color: rgba(139,195,74,.35); }
#states-overview [data-key="blight"].chip--on              { background: rgba(121,85,72,.12);   border-color: rgba(121,85,72,.35); }
#states-overview [data-key="drought"].chip--on             { background: rgba(253,216,53,.10);  border-color: rgba(253,216,53,.35); }
#states-overview [data-key="famine"].chip--on              { background: rgba(255,138,101,.12); border-color: rgba(255,138,101,.35); }
#states-overview [data-key="infested"].chip--on            { background: rgba(156,204,101,.12); border-color: rgba(156,204,101,.35); }
#states-overview [data-key="incursion"].chip--on           { background: rgba(171,71,188,.12);  border-color: rgba(171,71,188,.35); }
#states-overview [data-key="cold war"].chip--on            { background: rgba(100,181,246,.10); border-color: rgba(100,181,246,.32); }
#states-overview [data-key="trade war"].chip--on           { background: rgba(144,164,174,.12); border-color: rgba(144,164,174,.35); }
#states-overview [data-key="natural disaster"].chip--on    { background: rgba(206,147,216,.12); border-color: rgba(206,147,216,.35); }
#states-overview [data-key="pirate attack"].chip--on       { background: rgba(239,83,80,.12);   border-color: rgba(239,83,80,.35); }
#states-overview [data-key="terrorist attack"].chip--on    { background: rgba(229,115,115,.12); border-color: rgba(229,115,115,.35); }
#states-overview [data-key="public holiday"].chip--on      { background: rgba(100,181,246,.10); border-color: rgba(100,181,246,.32); }
#states-overview [data-key="technological leap"].chip--on  { background: rgba(121,134,203,.12); border-color: rgba(121,134,203,.35); }
#states-overview [data-key="historic event"].chip--on      { background: rgba(77,208,225,.12);  border-color: rgba(77,208,225,.35); }
#states-overview [data-key="colonisation"].chip--on        { background: rgba(38,166,154,.12);  border-color: rgba(38,166,154,.35); }
#states-overview [data-key="retreat"].chip--on             { background: rgba(176,21,21,.14);   border-color: rgba(176,21,21,.45); }
.series.series--empty .progress{ background:#141414; border-color:#2a2a2a; }
.series.series--empty .progress__bar{ opacity:.35; }
nav a.active {
  font-weight: bold;
  color: var(--accent);
  text-decoration: underline;
}
