/* ============ Armenia 2026 Election Atlas ============ */
:root {
  --apricot: #F2A900;      /* Armenian flag apricot */
  --blue:    #0033A0;
  --red:     #D90012;
  --bg:      #0c0f16;
  --bg-2:    #11151f;
  --surface: #161b27;
  --surface-2:#1d2331;
  --line:    #2a3142;
  --text:    #eef1f7;
  --muted:   #9aa4ba;
  --accent:  var(--apricot);
  --radius:  16px;
  --shadow:  0 12px 40px rgba(0,0,0,.45);
  --maxw:    1180px;
  --font:    "Inter", "Noto Sans Armenian", system-ui, sans-serif;
  --serif:   "Fraunces", "Noto Sans Armenian", Georgia, serif;
}
[data-theme="light"] {
  --bg:#f6f5f1; --bg-2:#efede7; --surface:#ffffff; --surface-2:#f3f2ee;
  --line:#e2ddd2; --text:#1a1d26; --muted:#5d6577; --shadow:0 10px 30px rgba(40,30,10,.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; line-height: 1.55; overflow-x: hidden;
  background-image:
    radial-gradient(900px 500px at 85% -8%, rgba(242,169,0,.10), transparent 60%),
    radial-gradient(800px 500px at 0% 0%, rgba(0,51,160,.10), transparent 55%);
}
a { color: inherit; }
h1,h2,h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 12px max(20px, calc((100vw - var(--maxw))/2));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-weight: 900; text-decoration: none; font-size: 1.02rem; white-space: nowrap; }
.mainnav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.mainnav a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem;
  padding: 7px 12px; border-radius: 999px; transition: .18s;
}
.mainnav a:hover, .mainnav a.active { color: var(--text); background: var(--surface-2); }
.topctrl { display: flex; align-items: center; gap: 10px; }
.langswitch { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.langswitch button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-weight: 700; font-size: .8rem; padding: 5px 10px; border-radius: 999px; font-family: var(--font);
}
.langswitch button.active { background: var(--accent); color: #1a1206; }
.iconbtn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer; font-size: 1rem;
}

/* ---------- layout ---------- */
main { display: block; }
.section { max-width: var(--maxw); margin: 0 auto; padding: 64px 20px; }
.section.narrow { max-width: 880px; }
.section.wide { max-width: min(1340px, 95vw); }
.section-head { margin-bottom: 26px; }
.section-head h2 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); margin: 0 0 8px; }
.section-head .muted { max-width: 720px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 1.15rem; }
.chart { width: 100%; }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero-bg {
  position: absolute; inset: 0; opacity: .5;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
          mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
  display: flex; align-items: center; justify-content: flex-end;
}
.hero-bg svg { height: 115%; filter: drop-shadow(0 20px 60px rgba(0,0,0,.5)); }
.hero-inner { position: relative; max-width: var(--maxw); margin: 0 auto; padding: 90px 20px 70px; }
.kicker { text-transform: uppercase; letter-spacing: .16em; font-size: .76rem; font-weight: 800; color: var(--accent); margin: 0 0 14px; }
.hero-title { font-size: clamp(2.4rem, 6.5vw, 4.6rem); font-weight: 900; margin: 0 0 18px; max-width: 14ch; }
.hero-lede { font-size: clamp(1.05rem, 2.2vw, 1.4rem); max-width: 40ch; color: var(--text); opacity: .92; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 38px; max-width: 820px; }
.stat { background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line); border-radius: 14px; padding: 16px; backdrop-filter: blur(6px); }
.stat .v { font-family: var(--serif); font-size: 1.7rem; font-weight: 900; line-height: 1; }
.stat .l { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 8px; }

/* ---------- segmented / controls ---------- */
.map-controls, .data-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); font-weight: 600; font-family: var(--font);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: .9rem; transition: .15s;
}
.segmented button.active { background: var(--accent); color: #1a1206; }
.select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; font-family: var(--font); font-size: .9rem; min-width: 180px;
}
.sharebtn {
  margin-left: auto; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-family: var(--font); transition: .15s;
}
.sharebtn:hover { border-color: var(--accent); color: var(--accent); }
.callout { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 12px; padding: 12px 16px; font-size: .92rem; }

/* ---------- map ---------- */
.map-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.map-stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.choropleth svg { width: 100%; height: auto; display: block; }
.marz { stroke: var(--bg); stroke-width: 1.1; cursor: pointer; transition: opacity .15s, stroke .15s; }
.marz:hover { stroke: var(--text); stroke-width: 1.8; }
.marz.selected { stroke: var(--text); stroke-width: 2.4; }
.marz-label { font-size: 10px; font-weight: 700; fill: var(--text); paint-order: stroke; stroke: var(--bg); stroke-width: 2.4px; pointer-events: none; }
.legend { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.legend .bar { height: 12px; border-radius: 6px; }
.legend .ticks { display: flex; justify-content: space-between; }
.legend .swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.legend .sw { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

.zoom-ctrl { position: absolute; top: 22px; right: 22px; z-index: 5; display: flex; flex-direction: column; gap: 6px; }
.zoom-ctrl .iconbtn { width: 30px; height: 30px; font-weight: 700; }
.community-bubble { cursor: pointer; stroke: rgba(0,0,0,.35); stroke-width: .5; transition: stroke-width .12s; }
.community-bubble:hover { stroke: var(--text); stroke-width: 1.5; }
.marz-base { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.dot-pt { stroke: var(--bg); stroke-width: 1.2; }
.dot-label { font-size: 9px; fill: var(--muted); pointer-events: none; }
.map-panel { min-height: 320px; }
.panel-name { font-family: var(--serif); font-size: 1.5rem; font-weight: 900; margin: 0; }
.panel-stats { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin: 16px 0; }
.panel-stats .ps { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.panel-stats .ps .v { font-weight: 800; font-size: 1.1rem; }
.panel-stats .ps .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.barrow { display: grid; grid-template-columns: 1fr 56px; gap: 4px 10px; align-items: center; margin: 10px 0; font-size: .85rem; }
.barrow .track { background: var(--surface-2); border-radius: 6px; height: 14px; overflow: hidden; }
.barrow .fill { height: 100%; border-radius: 6px; }
.barrow .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.barrow .nm { grid-column: 1 / -1; white-space: normal; line-height: 1.25; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.datatable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.datatable th, .datatable td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.datatable th:first-child, .datatable td:first-child { text-align: left; white-space: normal; max-width: 320px; }
.datatable th { color: var(--muted); font-weight: 700; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.datatable th:hover { color: var(--text); }
.datatable tbody tr:hover { background: var(--surface-2); }
.datatable .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }
/* National result table: always fit the container, never scroll sideways */
#overview .table-wrap { overflow-x: visible; }
#nationalTable th, #nationalTable td { white-space: normal; }
.pill { font-size: .72rem; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.pill.gov { background: color-mix(in srgb, var(--apricot) 25%, transparent); color: var(--apricot); }
.pill.opp { background: color-mix(in srgb, #6aa3ff 22%, transparent); color: #8bb8ff; }
.pill.below { background: var(--surface-2); color: var(--muted); }
.tabnum { font-variant-numeric: tabular-nums; }

/* ---------- parties ---------- */
.party-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.party-chips button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-family: var(--font); font-size: .88rem;
  display: inline-flex; align-items: center; gap: 8px; transition: .15s;
}
.party-chips button .dot { width: 11px; height: 11px; border-radius: 50%; }
.party-chips button.active { border-color: currentColor; transform: translateY(-1px); }
.party-detail { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; }
.party-head h3 { font-size: 1.7rem; margin: 0; }
.party-names { color: var(--muted); margin: 4px 0 16px; font-size: .95rem; }
.party-prose { font-size: 1.02rem; }
.party-meta { display: grid; gap: 10px; margin-top: 16px; }
.party-meta .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 8px; font-size: .9rem; }
.party-meta .row .k { color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.party-meta .row span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.reflinks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.reflinks a { text-decoration: none; font-size: .82rem; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); }
.reflinks a:hover { border-color: var(--accent); color: var(--accent); }
.minimap svg { width: 100%; height: auto; }

/* ---------- overseas / about ---------- */
.overseas { display: flex; gap: 20px; align-items: flex-start; }
.overseas .globe { font-size: 2.4rem; line-height: 1; }
.about-grid { display: grid; gap: 16px; }
.about-grid .ab { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.about-grid .ab h4 { margin: 0 0 6px; font-family: var(--serif); }
.about-grid a { color: var(--accent); }

/* ---------- tooltip / toast ---------- */
.tooltip {
  position: fixed; pointer-events: none; z-index: 100; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: .82rem;
  box-shadow: var(--shadow); max-width: 240px; opacity: 0; transition: opacity .12s;
}
.tooltip .tt-title { font-weight: 800; margin-bottom: 6px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .tt-row .d { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #1a1206; font-weight: 700; padding: 11px 20px;
  border-radius: 999px; box-shadow: var(--shadow); z-index: 200;
}

.footer { max-width: var(--maxw); margin: 0 auto; padding: 40px 20px 60px; border-top: 1px solid var(--line); }
.footer a { color: var(--accent); }
.repo-badge { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; text-decoration: none; vertical-align: middle; font-size: .8rem; line-height: 1; transition: border-color .15s; }
.repo-badge:hover { border-color: var(--accent); }
.repo-badge svg { display: block; }
.repo-badge .rb-mark { display: inline-flex; align-items: center; padding: 5px 8px; background: var(--surface-2); color: var(--text); }
.repo-badge .rb-stars { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-left: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }
.repo-badge .rb-stars svg { color: #e3b341; }
.repo-badge:hover .rb-stars { color: var(--text); }
.dl-links { display: flex; gap: 8px; flex-wrap: wrap; }
.dl-links a { text-decoration: none; font-size: .82rem; font-weight: 700; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.dl-links a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid-2, .map-layout, .party-detail { grid-template-columns: 1fr; }
  /* Keep navigation on mobile: a horizontally scrollable strip under the brand */
  .topbar { flex-wrap: wrap; row-gap: 8px; column-gap: 12px; }
  .topctrl { margin-left: auto; }
  .mainnav {
    order: 3; width: 100%; margin-left: 0; flex-wrap: nowrap;
    overflow-x: auto; gap: 2px; padding-bottom: 2px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .mainnav::-webkit-scrollbar { display: none; }
  .mainnav a { white-space: nowrap; }
  .map-panel { min-height: 0; }
}
@media (max-width: 600px) {
  .section { padding: 40px 16px; }
  .section-head { margin-bottom: 18px; }
  .hero-inner { padding: 48px 16px 40px; }
  .hero-bg { opacity: .22; }
  .hero-title { margin-bottom: 14px; }
  .card { padding: 16px; }
  .map-stage { padding: 10px; }
  .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 26px; }
  .stat { padding: 13px; border-radius: 12px; }
  .stat .v { overflow-wrap: anywhere; }
  .stat .v { font-size: 1.4rem; }
  .select { min-width: 0; flex: 1 1 140px; }
  .sharebtn { margin-left: 0; width: 100%; text-align: center; }
  .zoom-ctrl { top: 14px; right: 14px; }
  .datatable th, .datatable td { padding: 8px 9px; }
  /* National table has 6 columns; on phones drop raw vote count + leader so the
     essentials (party, %, seats, bloc) fit without horizontal scroll. */
  #nationalTable { font-size: .78rem; }
  #nationalTable th, #nationalTable td { padding: 7px 4px; }
  #nationalTable th:nth-child(2), #nationalTable td:nth-child(2),
  #nationalTable th:nth-child(6), #nationalTable td:nth-child(6) { display: none; }
  #nationalTable th:first-child, #nationalTable td:first-child { max-width: 116px; }
  #nationalTable .pill { font-size: .64rem; padding: 2px 6px; }
  #nationalTable .swatch { margin-right: 5px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
