/* Styles for the RIN Grad Zagreb report page. Mobile-first; targets ≥320px.
   Civic-ledger identity: warm paper tone, Fraunces display serif on headings,
   sun-mark fleuron as h2 bullet, printer's rules under hero and table header. */

:root {
  --bg: #f6f1e3;
  --panel: #fffdf7;
  --ink: #1c1a14;
  --ink-muted: #6b6254;
  --line: #e5dcc4;
  --line-strong: #c9bd9c;
  --accent: #00334c;
  --accent-2: #b75a2b;
  --good: #2f7d5b;
  --warn: #c97a1f;
  --bad: #b23a3a;
  --shadow: 0 1px 2px rgba(60, 48, 20, 0.05), 0 2px 6px rgba(60, 48, 20, 0.04);
  --serif: "Fraunces", "Iowan Old Style", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: "Helvetica Neue", Arial, sans-serif;

  /* Sun-mark fleuron, inline SVG as data URI; tinted via the fill= color.
     Two variants so we can key by context (orange on cards, cream on hero). */
  --sun-orange: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='50' r='20' fill='%23b75a2b'/><g stroke='%23b75a2b' stroke-width='7' stroke-linecap='round'><line x1='50' y1='8' x2='50' y2='22'/><line x1='50' y1='78' x2='50' y2='92'/><line x1='8' y1='50' x2='22' y2='50'/><line x1='78' y1='50' x2='92' y2='50'/><line x1='20' y1='20' x2='30' y2='30'/><line x1='70' y1='70' x2='80' y2='80'/><line x1='20' y1='80' x2='30' y2='70'/><line x1='70' y1='30' x2='80' y2='20'/></g></svg>");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

/* Subtle paper grain — a single SVG noise layer, pinned, very low opacity.
   Gives the cream tone a slight texture without hurting legibility. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.36  0 0 0 0 0.22  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

body > * {
  position: relative;
  z-index: 1;
}

/* Hero — gazette-style nameplate on page tone with double rules top and bottom,
   so the header reads like a masthead, not a colored banner. */

.hero {
  background: transparent;
  color: var(--ink);
  padding: 1.6rem 1rem 1.2rem;
  margin: 0 auto;
  max-width: 1200px;
  border-top: 3px double var(--line-strong);
  border-bottom: 3px double var(--line-strong);
  text-align: center;
  position: relative;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.9rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
}

.hero .subtitle {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
  font-style: italic;
  font-family: var(--serif);
  font-variation-settings: "opsz" 14;
}

.hero .subtitle::before,
.hero .subtitle::after {
  content: "❦";
  margin: 0 0.5rem;
  color: var(--accent-2);
  font-style: normal;
  opacity: 0.85;
}

.hero .meta {
  margin: 0.6rem 0 0;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hero a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(28, 26, 20, 0.3);
  text-underline-offset: 2px;
}

.hero a:hover {
  text-decoration-color: var(--ink);
}

.hero-logo {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-left: 0.35rem;
}

main {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* KPI row */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.6rem 0.75rem 0.65rem;
  box-shadow: var(--shadow);
}

.kpi .label {
  display: block;
  font-size: 0.62rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
  line-height: 1.25;
}

.kpi .value {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.2rem;
  line-height: 1.1;
  color: var(--ink);
  font-variation-settings: "opsz" 36;
  font-variant-numeric: lining-nums tabular-nums;
}

.kpi .hint {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
  font-style: italic;
  font-family: var(--serif);
  font-variation-settings: "opsz" 14;
  line-height: 1.3;
}

/* Wide single-row KPI — uses full page width, for long-text values. */

.kpi-wide {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 3px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.kpi-wide .label {
  display: block;
  font-size: 0.68rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.kpi-wide .value {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.1rem;
  line-height: 1.4;
  color: var(--ink);
  word-break: break-word;
  font-variation-settings: "opsz" 24;
}

.kpi-wide .hint {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 0.35rem;
  font-style: italic;
  font-family: var(--serif);
}

/* Cards & two-column layout */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1.1rem 1.1rem 1rem;
  box-shadow: var(--shadow);
}

/* h2 gets the sun-mark as a ::before fleuron, with a double rule underline
   that reads like a printer's separator. */
.card h2 {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: -0.005em;
  line-height: 1.25;
  color: var(--ink);
  padding-bottom: 0.55rem;
  border-bottom: 3px double var(--line-strong);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-variation-settings: "opsz" 36;
}

.card h2::before {
  content: "";
  flex: 0 0 auto;
  width: 0.95em;
  height: 0.95em;
  background-image: var(--sun-orange);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  opacity: 0.9;
}

.card .card-note {
  margin: 0.65rem 0 0.85rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
  font-style: italic;
  font-family: var(--serif);
  font-variation-settings: "opsz" 14;
  line-height: 1.5;
}

.card.muted {
  background: transparent;
  box-shadow: none;
  border-style: dashed;
}

.two-col {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }
}

/* Delta summary */

.delta-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 0.5rem;
  margin: 0.25rem 0 0.85rem;
}

.delta-stat {
  background: #fbf6e7;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.5rem 0.6rem;
}

.delta-stat .label {
  display: block;
  font-size: 0.66rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.delta-stat .value {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.1rem;
  margin-top: 0.15rem;
  font-variation-settings: "opsz" 24;
  font-variant-numeric: lining-nums tabular-nums;
}

/* Charts */

.chart-box {
  position: relative;
  height: 240px;
}

.chart-box.tall {
  height: 360px;
}

@media (min-width: 720px) {
  .chart-box {
    height: 280px;
  }
  .chart-box.tall {
    height: 440px;
  }
}

/* Table — leaned into the ledger look: double rule under thead, warm row bg. */

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  background: #f1ead5;
  position: sticky;
  top: 0;
  border-bottom: 3px double var(--line-strong);
}

td.num {
  text-align: right;
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
  font-family: var(--serif);
  font-variation-settings: "opsz" 14;
}

/* Breakdown list — compact count + share rows with an inline bar. */

.breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.breakdown .row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: baseline;
  font-size: 0.9rem;
}

.breakdown .row .bar-track {
  grid-column: 1 / -1;
  height: 5px;
  background: #ece3cb;
  border-radius: 2px;
  overflow: hidden;
}

.breakdown .row .bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.breakdown .row .key {
  font-weight: 500;
}

.breakdown .row .count,
.breakdown .row .share {
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink-muted);
  white-space: nowrap;
  font-family: var(--serif);
}

.breakdown .row .count {
  font-weight: 500;
  color: var(--ink);
}

/* DQ list */

#dq-list {
  margin: 0;
  padding-left: 1.2rem;
}

#dq-list li {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

/* Map — Leaflet container plus civic-ledger styled legend and popups. */

.leaflet-map {
  width: 100%;
  height: 540px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--bg);
  /* OSM tiles are crisp on their own; faint warm wash blends them with the
     paper tone without obscuring labels. */
  filter: saturate(0.85) sepia(0.05);
}

@media (max-width: 720px) {
  .leaflet-map { height: 380px; }
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  margin-top: 0.85rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--ink);
}

.legend-swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex: 0 0 auto;
}

.legend-label {
  color: var(--ink);
}

.legend-count {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

.map-meta {
  margin: 0.7rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-style: italic;
  font-family: var(--serif);
  font-variation-settings: "opsz" 14;
  line-height: 1.5;
}

/* Popups — keep them light and aligned with the report's typography. */

.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--ink);
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  box-shadow: 0 4px 14px rgba(60, 48, 20, 0.18);
}

.leaflet-popup-tip {
  background: var(--panel);
  border: 1px solid var(--line-strong);
}

.leaflet-popup-content {
  margin: 0.6rem 0.75rem;
  font: 13px/1.45 var(--sans);
}

.map-popup .popup-svrha {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--ink);
  border-left: 3px solid var(--accent-2);
  padding-left: 0.5rem;
  margin-bottom: 0.35rem;
}

.map-popup .popup-amount {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.1rem;
  color: var(--accent);
  font-variant-numeric: lining-nums tabular-nums;
}

.map-popup .popup-meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

.map-popup .popup-parcel {
  font-size: 0.78rem;
  color: var(--ink);
  margin-top: 0.45rem;
  word-break: break-word;
}

.map-popup .popup-area {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

.map-popup .popup-area em {
  color: var(--accent-2);
  font-style: normal;
}

.map-popup .popup-raw {
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-style: italic;
  font-family: var(--serif);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--line);
  line-height: 1.4;
}

footer {
  padding: 1.25rem 1rem 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-style: italic;
  font-family: var(--serif);
  font-variation-settings: "opsz" 14;
}

footer::before {
  content: "❦";
  display: block;
  color: var(--accent-2);
  font-size: 1.1rem;
  margin-bottom: 0.45rem;
  font-style: normal;
  opacity: 0.85;
}
