/* Soft light theme, newsroom style. Party colors live in js/parties.js. */

@font-face {
  font-family: 'Inter';
  src: url(../fonts/InterVariable.woff2) format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: block;  /* never show UI text in a fallback font */
}

:root {
  --font: 'Inter', sans-serif;
  --modal-duration: 350ms;  /* keep in sync with DURATION in js/overlay.js */
  --bg: #f4f3ef;            /* warm off-white page */
  --surface: #fbfaf7;       /* panel */
  --card: #ffffff;          /* boxes, legend */
  --text: #2b2b2b;
  --muted: #75736e;
  --faint: #9a978f;
  --border: #e2e0da;
  --border-soft: #ecebe6;
  --note: #efeee9;
  --link: #1f5fbf;
  --shadow: 0 2px 12px rgba(40, 35, 25, 0.12);
}

html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }

/* Map 2/3 left, panel 1/3 right, footer across the bottom */
.layout { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: minmax(0, 1fr) auto;
  height: 100vh; height: 100dvh; }
#map { height: 100%; min-height: 0; }
#panel { display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--border); }
#panel-content { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 24px 32px; }
.panel-close, #panel-backdrop, .results-button { display: none; }

/* Mobile: full-screen map, panel as a modal over it (see js/modal.js) */
@media (max-width: 767px) {
  .layout { grid-template-columns: 1fr; }
  /* Modal: .is-open shows it, .is-shown animates it in (js/overlay.js) */
  #panel { display: none; position: fixed; inset: 48px 10px 10px; z-index: 1101;
    border: 0; border-radius: 14px; box-shadow: 0 8px 40px rgba(40, 35, 25, 0.3);
    opacity: 0; transform: translateY(32px) scale(0.96);
    transition: opacity var(--modal-duration) ease, transform var(--modal-duration) cubic-bezier(0.2, 0.8, 0.2, 1); }
  #panel.is-open { display: flex; }
  #panel.is-shown { opacity: 1; transform: none; }
  #panel-backdrop.is-open { display: block; position: fixed; inset: 0; z-index: 1100;
    background: rgba(30, 28, 24, 0.45); opacity: 0; transition: opacity var(--modal-duration) ease; }
  #panel-backdrop.is-shown { opacity: 1; }
  #panel-content { padding: 4px 18px 24px; }
  /* Round X button, top right of the modal */
  .panel-close { display: block; position: relative; flex: none; align-self: flex-end;
    width: 36px; height: 36px; margin: 10px 10px 0 0; border: 0; border-radius: 50%;
    background: var(--note); cursor: pointer; }
  .panel-close::before, .panel-close::after { content: ''; position: absolute; left: 50%; top: 50%;
    width: 16px; height: 2px; border-radius: 1px; background: var(--text); }
  .panel-close::before { transform: translate(-50%, -50%) rotate(45deg); }
  .panel-close::after { transform: translate(-50%, -50%) rotate(-45deg); }
  /* "Rezultati izbora" button under the legend tab */
  .leaflet-container .results-button { display: block; padding: 6px 10px; border: 0; border-radius: 8px;
    background: var(--text); color: #fff; box-shadow: var(--shadow);
    font: 600 11.5px/1.2 var(--font); cursor: pointer; }
}

/* Footer: "O podacima", contact e-mail, last updated */
#footer { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px;
  padding: 8px 16px; border-top: 1px solid var(--border); background: var(--surface);
  font-size: 12px; color: var(--muted); }
#footer a, .footer-link { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.footer-link { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
#footer a:hover, .footer-link:hover { color: var(--text); }
.footer-updated { margin-left: auto; }
@media (max-width: 767px) {
  #footer { gap: 2px 12px; padding: 6px 12px; font-size: 11px; }
  .footer-updated { margin-left: 0; }
}

/* One-time notice (js/notice.js): above everything, including the mobile results modal */
.notice-overlay { display: none; position: fixed; inset: 0; z-index: 1200;
  align-items: center; justify-content: center; padding: 16px; background: rgba(30, 28, 24, 0.5);
  opacity: 0; transition: opacity var(--modal-duration) ease; }
.notice-overlay.is-open { display: flex; }
.notice-overlay.is-shown { opacity: 1; }
.notice { width: 100%; max-width: 480px; max-height: 100%; overflow-y: auto; box-sizing: border-box;
  padding: 24px 24px 20px; border-radius: 14px; background: var(--card); box-shadow: 0 8px 40px rgba(40, 35, 25, 0.3);
  font-size: 14px; line-height: 1.55;
  transform: translateY(32px) scale(0.96); transition: transform var(--modal-duration) cubic-bezier(0.2, 0.8, 0.2, 1); }
.notice-overlay.is-shown .notice { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .notice-overlay, .notice, #panel, #panel-backdrop { transition: none !important; }
}
.notice-title { margin: 0 0 12px; font-size: 20px; font-weight: 800; }
.notice p { margin: 0 0 12px; }
.notice a { color: var(--link); }
.notice-button { display: block; margin: 18px 0 0 auto; padding: 9px 22px; border: 0; border-radius: 8px;
  background: var(--text); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.notice-button:hover { background: #000; }

/* Map */
.leaflet-container { background: var(--bg); font-family: var(--font); }
.leaflet-container .leaflet-control-attribution { font-size: 10px; color: var(--muted);
  background: rgba(255, 255, 255, 0.6); border-top-left-radius: 4px; }
.leaflet-container .leaflet-control-attribution a { color: var(--muted); }
/* Region name on hover: no tooltip box, dark text with a thin crisp white outline */
.region-name { background: none; border: none; box-shadow: none; padding: 0;
  font-weight: 700; font-size: 13px; color: #222; white-space: nowrap;
  text-shadow: -1px -1px 0 #fff, 0 -1px 0 #fff, 1px -1px 0 #fff, 1px 0 0 #fff,
    1px 1px 0 #fff, 0 1px 0 #fff, -1px 1px 0 #fff, -1px 0 0 #fff; }

/* Site name, centered at the top of the map: plain black text, no background */
.map-title { position: absolute; top: 12px; left: 50%; z-index: 1000; transform: translateX(-50%);
  max-width: calc(100% - 140px); margin: 0; text-align: center; pointer-events: none;
  font-size: 20px; font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; color: #111;
  /* thin crisp white outline, same as the hover labels */
  text-shadow: -1px -1px 0 #fff, 0 -1px 0 #fff, 1px -1px 0 #fff, 1px 0 0 #fff,
    1px 1px 0 #fff, 0 1px 0 #fff, -1px 1px 0 #fff, -1px 0 0 #fff; }
@media (max-width: 767px) {
  /* Between the zoom buttons (left) and the legend/results buttons (right) */
  .map-title { top: 10px; max-width: calc(100% - 230px); font-size: 14px; }
}

/* Legend card (bottom left of the map), collapsible */
.leaflet-container .legend { width: 240px; max-width: calc(100vw - 40px); box-sizing: border-box;
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(6px);
  border-radius: 10px; box-shadow: var(--shadow); font: 12px/1.4 var(--font); color: var(--text); }
.legend-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between;
  padding: 10px 14px; border: 0; background: none; cursor: pointer;
  font: 700 13px/1.2 var(--font); color: inherit; text-align: left; }
.legend-chevron { width: 7px; height: 7px; margin-right: 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform 0.2s; }
.legend.is-collapsed .legend-chevron { transform: rotate(-135deg) translateY(-2px); }
.legend-body { padding: 0 14px 12px; }
.legend.is-collapsed .legend-body { display: none; }
.legend-heading { margin: 2px 0 6px; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.legend-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.legend-bar { flex: none; width: 36px; height: 10px; border-radius: 5px; }
.legend-chip { flex: none; width: 14px; height: 14px; border-radius: 4px; margin: 0 11px; }
.legend-label { display: flex; flex-direction: column; min-width: 0; }
.legend-sub { font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.legend-scale { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px;
  font-size: 10px; color: var(--faint); white-space: nowrap; }
.legend-scale-line { flex: 1; height: 4px; border-radius: 2px; }
.legend-note { margin: 2px 0 0; font-size: 10.5px; color: var(--muted); }
.legend-divider { height: 1px; margin: 10px 0; background: var(--border-soft); }

/* Mobile legend: compact tab at the top right (js/map.js addLegend); opens to a small card */
@media (max-width: 767px) {
  .leaflet-container .legend { width: 178px; border-radius: 8px; font-size: 10.5px; }
  .leaflet-container .legend.is-collapsed { width: auto; }
  .legend-toggle { gap: 8px; padding: 6px 10px; font-size: 11.5px; }
  .legend-body { padding: 0 10px 8px; }
  .legend-heading { margin: 0 0 4px; font-size: 9px; }
  .legend-row { gap: 7px; margin: 4px 0; }
  .legend-bar { width: 24px; height: 8px; }
  .legend-chip { width: 11px; height: 11px; margin: 0 6px; }
  .legend-icon { margin: 0 4px; }
  .legend-sub, .legend-note { font-size: 9.5px; }
  .legend-scale { margin: 6px 0 2px; font-size: 9px; }
  .legend-divider { margin: 7px 0; }
  /* Opens downward here, so the arrow points down while closed and up while open */
  .legend-chevron { transform: rotate(-135deg) translateY(-2px); }
  .legend.is-collapsed .legend-chevron { transform: rotate(45deg) translateY(-2px); }
}

/* Side panel */
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.crest { flex: none; width: 53px; height: 64px; }
.kicker { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint); }
.panel-title { margin: 0 0 4px; font-size: 24px; font-weight: 800; line-height: 1.15;
  letter-spacing: -0.01em; }
.hint { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.group { border-top: 1px solid var(--border); }
.group:last-of-type { border-bottom: 1px solid var(--border); }
.group-head { display: flex; width: 100%; align-items: center; justify-content: space-between;
  padding: 15px 0; border: 0; background: none; cursor: pointer; text-align: left; }
.group-title { font-size: 13px; font-weight: 700; line-height: 1.2; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); }
.group-head:hover .group-title, .group.is-open .group-title { color: var(--text); }
.group-body { padding: 0 0 18px; }

.stats { display: flex; gap: 16px; margin-bottom: 14px; }
.stat { flex: 1; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11.5px; color: var(--muted); }

.pie { max-width: 180px; margin: 4px auto 14px; }

.party-list { list-style: none; margin: 0; padding: 0; }
.party { display: grid; grid-template-columns: 10px 22px 1fr auto 52px; gap: 6px; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.party-dot { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
.party-num { font-weight: 700; color: var(--muted); }
.party-name { min-width: 0; overflow-wrap: anywhere; }
.party-votes, .party-pct { text-align: right; font-variant-numeric: tabular-nums; }
.party-pct { font-weight: 700; }
.invalid { margin-top: 8px; font-size: 12px; color: var(--muted); }

.note { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--note);
  font-size: 12.5px; color: var(--muted); }
.note-with-icon { display: flex; align-items: flex-start; gap: 8px; color: var(--text); }
.note-with-icon .note-icon { flex: none; margin-top: 1px; }
/* Note icon on the map, legend */
.note-marker { background: none; border: 0; }
.note-marker .note-icon { display: block; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35)); }
.legend-icon { flex: none; display: flex; width: 14px; margin: 0 11px; }
.note-repeat { border-left: 3px solid #9e9e9e; }

.back { margin: 0 0 14px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); font-size: 13px; color: var(--text); cursor: pointer; }
.back:hover { background: var(--note); }

/* Polling station boxes: border in the station winner's color (gray = repeat) */
.station { margin-top: 12px; border: 2px solid; border-radius: 8px; background: var(--card); overflow: hidden; }
.station-head { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 12px; border: 0; background: none; font-size: 14px; font-weight: 600; color: inherit;
  text-align: left; cursor: pointer; }
.chevron { flex: none; width: 7px; height: 7px; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform 0.2s; }
.station.is-open .chevron, .group.is-open .chevron { transform: rotate(-135deg) translateY(-2px); }
.station-body { padding: 4px 12px 12px; }
.docs { margin: 10px 0 0; padding-left: 18px; }
.docs a { color: var(--link); }

/* 404.html */
.not-found main { max-width: 480px; margin: 15vh auto 0; padding: 0 24px; }
.not-found h1 { margin: 0 0 12px; font-size: 24px; font-weight: 800; }
.not-found a { color: var(--link); }
