/* Dark surface throughout: the map is the product, and coloured nodes read
   far better against a dark background than a light one. */

:root {
  --bg: #0d1117;
  --panel: #151b24;
  --panel-2: #1c2431;
  --line: #263041;
  --text: #e6edf6;
  --text-dim: #93a1b5;
  --accent: #5aa9ff;
  --ok: #7ddb6a;
  --gone: #ff7a6a;
  --amber: #ffc857;
  --radius: 10px;
  --shadow: 0 10px 30px rgb(0 0 0 / 45%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; flex-direction: column; height: 100vh; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #131a24, #10161e);
  border-bottom: 1px solid var(--line);
  z-index: 20;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: conic-gradient(from 210deg, var(--accent), #2fd4c4, #7ddb6a, var(--accent));
}

.topbar h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.subtitle { margin: 0; font-size: 12px; color: var(--text-dim); }

.corpus {
  margin-left: auto;
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--text-dim);
}
.corpus strong { color: var(--text); font-variant-numeric: tabular-nums; margin-right: 4px; }
.corpus .hint { border-bottom: 1px dotted var(--text-dim); cursor: help; }

/* ----------------------------------------------------------------- search */

.search { position: relative; flex: 1 1 320px; max-width: 480px; }

.search-input {
  width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-input::placeholder { color: var(--text-dim); }

/* One panel, however many lists it holds: titles and text matches answer
   different questions and are listed apart, but they share the dropdown.
   Absolutely positioning each list separately drew the second over the first. */
.results-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  z-index: 20;
}
.results { margin: 0; padding: 4px; list-style: none; }
.results li { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.results li:hover { background: var(--panel-2); }
.result-title { display: block; }
.result-meta { display: block; font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.result-meta b { margin-left: 8px; font-weight: 500; }
.result-meta .ok { color: var(--ok); }
.result-meta .gone { color: var(--gone); }
.result-meta .muted { color: var(--text-dim); }

/* ------------------------------------------------------------------ stage */

.stage { position: relative; flex: 1; min-height: 0; }

.canvas-wrap { position: absolute; inset: 0; }

.graph-canvas {
  width: 100%; height: 100%; display: block; cursor: grab;
  /* Without this a touchscreen hands the gesture to the page — the browser
     scrolls and zooms the document instead of the map, and the canvas never
     sees a drag at all. */
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.graph-canvas.grabbing { cursor: grabbing; }

.tooltip {
  position: absolute;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  max-width: min(720px, 80vw);
  padding: 7px 12px;
  background: rgb(10 14 20 / 92%);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.debug-readout {
  position: absolute; top: 12px; left: 16px;
  padding: 4px 9px; border-radius: 6px;
  background: rgb(10 14 20 / 92%); border: 1px solid var(--line);
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--amber); pointer-events: none; z-index: 25;
}

.zoom-controls { position: absolute; right: 16px; bottom: 16px; display: grid; gap: 6px; }
.zoom-controls button {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.zoom-controls button:hover { background: var(--panel-2); }

/* ------------------------------------------------------------------ panel */

.panel {
  position: absolute;
  top: 14px; right: 14px; bottom: 14px;
  width: min(400px, calc(100vw - 28px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow-y: auto;
  z-index: 15;
}

.panel .close {
  position: absolute; top: 10px; right: 12px;
  width: 28px; height: 28px;
  border: none; border-radius: 7px;
  background: transparent; color: var(--text-dim);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.panel .close:hover { background: var(--panel-2); color: var(--text); }

.panel-body { padding: 18px 20px 26px; }
.panel-loading { padding: 24px; color: var(--text-dim); }

.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.kind {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); font-weight: 650;
}

.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-dim);
}
.badge.ok { color: var(--ok); border-color: #2c5c2a; }
.badge.gone { color: var(--gone); border-color: #6b2f2a; }
.badge.amended { color: var(--amber); border-color: #6b552a; }

.panel h2 { margin: 0 0 14px; font-size: 17px; line-height: 1.35; padding-right: 24px; }
.panel h3 {
  margin: 22px 0 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600;
}

.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.meta dt { color: var(--text-dim); }
.meta dd { margin: 0; }

.note {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--panel-2);
  border-left: 3px solid var(--amber);
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.source {
  display: inline-block;
  margin-top: 16px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}
.source:hover { text-decoration: underline; }

.relations, .subjects { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.relations li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.relations li:last-child { border-bottom: none; }
.rel {
  display: block; font-size: 11px; color: var(--text-dim);
  text-transform: lowercase; margin-bottom: 2px;
}

.link {
  background: none; border: none; padding: 0;
  color: var(--accent); text-align: left; cursor: pointer;
  font: inherit; line-height: 1.4;
}
.link:hover { text-decoration: underline; }
.back { margin-bottom: 14px; }

.subjects li {
  display: inline-block; margin: 0 6px 6px 0; padding: 3px 9px;
  background: var(--panel-2); border-radius: 999px;
  font-size: 12px; color: var(--text-dim);
}

/* ----------------------------------------------------------------- legend */

.legend {
  position: absolute; left: 16px; bottom: 16px;
  max-width: min(480px, calc(100vw - 460px));
  padding: 10px 14px;
  background: rgb(16 22 30 / 92%);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-row.muted { color: var(--text-dim); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.hollow { background: transparent; border: 1.5px solid var(--text-dim); }
.dot.solid { background: var(--text-dim); }
.dot.faded { background: var(--text-dim); opacity: 0.35; }
/* The repeal mark, at legend size: the same cross the canvas draws. */
.dot.closed { background: var(--text-dim); opacity: 0.55; position: relative; }
.dot.closed::before,
.dot.closed::after {
  content: ""; position: absolute; left: 1px; right: 1px; top: 3.5px;
  border-top: 2px solid var(--bg);
}
.dot.closed::before { transform: rotate(45deg); }
.dot.closed::after { transform: rotate(-45deg); }

/* --------------------------------------------------------- law panel bits */

.area-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 650; color: var(--chip, var(--accent));
}

.metrics { display: flex; gap: 20px; margin: 16px 0 4px; }
.metric { display: flex; flex-direction: column; }
.metric b { font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.metric span { font-size: 11px; color: var(--text-dim); }

.history {
  margin: 0; font-size: 12.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; line-height: 1.7;
}
/* Publications are links now; the separator is drawn rather than typed, so it
   never lands inside a link's hit area. */
/* Dotted rather than accent-coloured: twelve blue links would out-shout the
   law's own title, but with no affordance at all nobody knows they are
   clickable. */
.history .pub {
  color: var(--text-dim);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  text-decoration-color: #3c4757;
}
.history .pub:hover { color: var(--accent); text-decoration: underline solid; }
.history .pub + .pub::before { content: " · "; color: var(--text-dim); text-decoration: none; }

.earlier-acts .earlier-act {
    display: block;
}
.earlier-acts a.earlier-act {
  color: var(--text-dim);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  text-decoration-color: #3c4757;
}
.earlier-acts a.earlier-act:hover { color: var(--accent); text-decoration: underline solid; }

.relations li { display: flex; align-items: baseline; gap: 8px; }
.relations .dot { margin-top: 1px; }
.weight { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
/* The regulation a search landed on, so the list agrees with the map. */
.relations li.target { background: var(--panel-2); border-radius: 6px; padding-left: 6px; }

/* ---------------------------------------------------------- splash/banner */

.splash {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; color: var(--text-dim);
}
.splash-error { color: var(--gone); }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; font-size: 13px; z-index: 40;
}
.banner.error { border-color: #6b2f2a; color: var(--gone); cursor: pointer; }
.banner code { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

@media (max-width: 720px) {
  /* Every pixel of header is a pixel the map does not get, and on a phone the
     map is already short of height. */
  .topbar { gap: 10px; padding: 8px 12px; }
  .subtitle { display: none; }
  .corpus { display: none; }
  .brand-mark { width: 24px; height: 24px; }
  .topbar h1 { font-size: 15px; }
  .search { flex: 1 1 100%; max-width: none; }

  /* The detail panel becomes a bottom sheet rather than a side panel — at this
     width a 400px column would cover the whole map. */
  .panel {
    top: auto; left: 8px; right: 8px; bottom: 8px;
    width: auto; height: min(62%, 560px);
    border-radius: 14px;
  }
  .panel-body { padding: 14px 16px 20px; }
  .metrics { gap: 14px; }
  .metric b { font-size: 17px; }

  /* The legend duplicates what the canvas already labels; the map needs the
     room more than the reader needs the key. */
  .legend { display: none; }

  .zoom-controls { right: 10px; bottom: 10px; }
  .zoom-controls button { width: 40px; height: 40px; font-size: 18px; }

  .results { max-height: 50vh; }
  .tooltip { max-width: calc(100vw - 24px); font-size: 12px; bottom: 10px; }
}

@media (max-width: 420px) {
  .topbar h1 { font-size: 14px; }
  .search-input { font-size: 16px; } /* 16px stops iOS zooming the page on focus */
}

/* ------------------------------------------------- amendment history page */

/* A document, not a map: a readable measure on a calm background, and no
   canvas furniture competing with the text. */
.doc-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 22px 24px 80px;
  overflow-y: auto;
  height: 100%;
}
.doc-bar { margin-bottom: 18px; }
.doc-page h1 { margin: 0 0 6px; font-size: 22px; line-height: 1.3; }
.doc-sub { margin: 0 0 18px; color: var(--text-dim); font-size: 13px; }

/* The distinction this page turns on: what it shows is what each act said,
   not the law as it now stands. Warmer than an ordinary note, and first. */
.note.caution { border-left-color: var(--gone); }

.generation.earlier > summary { cursor: pointer; font-weight: 600; margin: 1.5rem 0 0.5rem; }
/* The current act's heading has no bigger a claim on the page than the
   earlier acts' summaries do — sized to match its folded peer, not the UA
   default `h2`, which would otherwise print at ~21px beside a 22px `h1`. */
.generation.current > h2.act { margin: 1.5rem 0 0.5rem; font-size: 14px; font-weight: 600; }

.articles { list-style: none; margin: 22px 0 0; padding: 0; }
.article { padding: 14px 0; border-top: 1px solid var(--line); }
.article h2 {
  margin: 0 0 8px; font-size: 15px; font-weight: 650;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.article .rubric { font-weight: 400; font-size: 13px; color: var(--text-dim); }

.edits { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.edits li {
  display: grid;
  grid-template-columns: 92px 120px 1fr;
  gap: 10px;
  padding: 5px 0;
  align-items: baseline;
}
.edits .src { color: var(--accent); text-decoration: none; font-variant-numeric: tabular-nums; }
.edits .src:hover { text-decoration: underline; }
.edits .op { color: var(--text-dim); font-size: 12px; }
.edits .ins { color: var(--text); line-height: 1.5; }

@media (max-width: 640px) {
  /* Stacked: three columns at this width leaves the instruction unreadable. */
  .edits li { grid-template-columns: 1fr; gap: 2px; padding: 8px 0; }
  .edits .op { font-size: 11px; }
}

/* ---------------------------------------------------------------- text page

   The reading view. Wider than the amendment history because it carries a
   navigation rail beside the text; the rail is where article-level marks live
   now (amendment counts) and later (diffs). */
.text-page { max-width: 1180px; }
.text-head { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 4px; }
.text-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.text-chips .kind {
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-dim); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px;
}
.text-links { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 0; }
/* The publication being read is not a place to navigate to. */
/* The comparison picker reuses the publication chips; a button, because it
   changes what the page shows rather than going somewhere. */
.history button.pub { background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
.history .pub.current { color: var(--text); border-bottom: 1px solid var(--accent); cursor: default; }

.text-body { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
/* Nothing to navigate: the prose takes the whole measure. */
.text-body.solo { grid-template-columns: minmax(0, 1fr); }
.rail { position: sticky; top: 12px; max-height: calc(100vh - 90px); overflow-y: auto; }
.rail ol { list-style: none; margin: 0; padding: 0; }
.rail li { display: flex; align-items: baseline; gap: 6px; }
.rail a {
  flex: 1; display: block; padding: 3px 0; color: var(--text-dim);
  text-decoration: none; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.rail a:hover { color: var(--accent); }
/* An article that has been amended, counted. Small: it is an annotation on the
   text, not a competing column. */
.rail b {
  font-size: 10px; font-weight: 600; color: var(--bg);
  background: var(--text-dim); border-radius: 999px; padding: 0 5px; cursor: help;
}

.art { padding: 18px 0; border-top: 1px solid var(--line); scroll-margin-top: 14px; }
.art:first-child { border-top: none; }
.art h2 {
  margin: 0 0 8px; font-size: 14px; display: flex; flex-wrap: wrap;
  align-items: baseline; gap: 10px;
}
.art-no { color: var(--text); text-decoration: none; }
.art-no:hover { color: var(--accent); }
.art .rubric { font-weight: 400; font-size: 13px; color: var(--text-dim); }
.art-edits { margin-left: auto; font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.art-edits:hover { text-decoration: underline; }
.art p { margin: 0 0 8px; line-height: 1.65; }
.art p:last-child { margin-bottom: 0; }
/* Unsegmented text: the same measure, so it reads the same way. */
.plain { margin: 0 0 10px; line-height: 1.65; }

@media (max-width: 860px) {
  .text-body { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  /* Above the text rather than beside it, and no taller than a glance. */
  .rail { position: static; max-height: 190px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .rail ol { display: flex; flex-wrap: wrap; gap: 2px 12px; }
  .art-edits { margin-left: 0; }
}

/* ------------------------------------------------------------------- diffs

   What an amending act did to an article, in that act's own words. Red is
   what it removed, green what it added; text with neither is the wording both
   sides share, kept so the change reads in context. Nothing is reconstructed:
   an act that quoted only one side gets its sentence verbatim instead. */
.art-edits {
  margin-left: auto; font-size: 12px; color: var(--accent);
  background: none; border: 0; padding: 0; cursor: pointer; white-space: nowrap;
}
.art-edits:hover, .art-edits.open { text-decoration: underline; }
.diff-mode { margin-left: 14px; display: inline-flex; gap: 10px; font-size: 12px; }
.diff-mode .on { color: var(--text); text-decoration: underline; }

.art .edits { margin-top: 10px; border-left: 2px solid var(--line); padding-left: 12px; }
.art .edits li { display: block; padding: 8px 0; }
.art .edits .src { margin-right: 10px; }
.art .edits .op { text-transform: lowercase; }
.art .edits li + li { border-top: 1px solid var(--line); }
.diff { margin-top: 4px; line-height: 1.6; }
.diff del, .diff ins {
  text-decoration: none; border-radius: 3px; padding: 0 2px;
  /* Translucent so the text stays the thing being read, not the highlight. */
  background: color-mix(in srgb, var(--gone) 26%, transparent);
}
.diff ins { background: color-mix(in srgb, #51cf66 26%, transparent); }
.diff del { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--gone) 70%, transparent); }

/* Side by side: before on the left, after on the right, each column showing
   only what it holds. */
.diff.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.diff.cols .side { min-width: 0; }
.diff.cols .side.old { border-right: 1px solid var(--line); padding-right: 14px; }
@media (max-width: 640px) {
  .diff.cols { grid-template-columns: 1fr; gap: 6px; }
  .diff.cols .side.old { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 6px; }
}
/* An article that survived under a different number: nothing changed in it, so
   nothing is coloured. */
.moved { color: var(--text-dim); font-size: 13px; margin: 4px 0 0; }
/* The wording an amending act published, quoted as the gazette quotes it. */
.payload {
  display: block; margin-top: 6px; padding-left: 10px;
  border-left: 2px solid var(--line); color: var(--text); quotes: "»" "«";
}

/* ---------------------------------------------------------------- divisions

   GLAVA, DIO, ODJELJAK — the structure the act is printed with, above the
   article. Set apart from article rubrics, which are sentence case and belong
   to a single article. */
.section {
  margin: 28px 0 6px; font-size: 13px; letter-spacing: 0.06em;
  color: var(--accent); scroll-margin-top: 14px; font-weight: 600;
}
.section .sec-name { display: block; margin-top: 3px; color: var(--text); letter-spacing: 0.02em; }
/* Deeper divisions read as subordinate without shouting. */
.section.level-2 { font-size: 12.5px; }
.section.level-3, .section.level-4, .section.level-5 { font-size: 12px; color: var(--text-dim); }
.section.level-3 .sec-name, .section.level-4 .sec-name, .section.level-5 .sec-name { color: var(--text-dim); }

.rail-section { margin-top: 10px; }
.rail-section:first-child { margin-top: 0; }
.rail-section a { color: var(--text); font-size: 11.5px; letter-spacing: 0.04em; }
.rail-section .sec-name { display: block; color: var(--text-dim); letter-spacing: 0; }
/* One indent per level, so a GLAVA sits inside its DIO. Articles hang under
   whichever division is innermost. */
.rail-section.level-2 { padding-left: 8px; }
.rail-section.level-3 { padding-left: 16px; }
.rail-section.level-4 { padding-left: 24px; }
.rail-section.level-5 { padding-left: 32px; }

/* ------------------------------------------------------- full-text results

   Matches in the text of the acts, listed under the title matches because they
   answer a different question: not "which act is called this" but "which act
   says this". */
.results.in-text { border-top: 1px solid var(--line); }
.results-head {
  padding: 8px 12px 4px; font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-dim); cursor: default;
}
.results.in-text li { padding: 0; }
.result-link { display: block; padding: 8px 12px; text-decoration: none; color: inherit; }
.result-link:hover { background: var(--line); }
.snippet {
  display: block; margin-top: 3px; font-size: 12px; line-height: 1.5;
  color: var(--text-dim);
}
.snippet mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text); border-radius: 2px; }

/* --------------------------------------------------------- cross-references

   A statute refers to its own articles about once per article, and every such
   mention used to be a dead end. Underlined rather than coloured: at this
   density colour would turn the page into a field of links and stop the text
   reading as text. */
.xref { color: inherit; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.xref:hover { color: var(--accent); text-decoration-style: solid; }
/* A reference that leaves this act is worth distinguishing before it is
   followed. */
.xref.away { text-decoration-color: var(--accent); }
