/* ---------------------------------------------------------------------------
   Filip Croatia BI portal — shared design system.

   One stylesheet for every page. Panels, KPI tiles and the nav are all defined
   here so a new analysis block inherits the house style by default instead of
   inventing its own. Palette continues the reference dashboard: Croatian red
   as the accent, navy for the chrome.
   --------------------------------------------------------------------------- */

:root {
  --bg:        #f5f6f8;
  --card:      #ffffff;
  --ink:       #14181f;
  --muted:     #6b7280;
  --line:      #e3e6ea;
  --accent:    #c8102e;   /* Croatian red */
  --navy:      #12233d;
  --navy-2:    #1e5aa8;
  --good:      #14804a;
  --bad:       #b42318;
  --warn:      #b54708;
  --shadow:    0 1px 2px rgba(18,35,61,.06), 0 1px 8px rgba(18,35,61,.04);
  --radius:    10px;

  /* Categorical series palette. Fixed order, never cycled -- a series keeps
     its hue when the chart beside it has fewer lines. Validated for the light
     card surface (#fff): worst adjacent CVD dE 9.1, normal-vision dE 19.6.
     Three of these sit below 3:1 contrast on white, which is why every chart
     ships a table view rather than relying on colour alone. */
  --series-1: #2a78d6;   /* blue    */
  --series-2: #eb6834;   /* orange  */
  --series-3: #1baf7a;   /* aqua    */
  --series-4: #eda100;   /* yellow  */
  --series-5: #e87ba4;   /* magenta */
  --series-6: #008300;   /* green   */

  /* A second, longer palette for the one chart that needs more than six
     categories: a stacked share of ten languages plus a remainder. Ten hues is
     past the point where a legend alone is comfortable, which is why that chart
     is interactive and carries a table twin.

     The ORDER is the stack order, and it was solved for rather than chosen:
     in a stack only neighbouring segments touch, so the ordering was searched
     until every adjacent pair clears the CVD and normal-vision floors in both
     themes. Light: worst adjacent CVD dE 9.2, normal-vision 27.5. Reordering
     these by hand will quietly break that. */
  --stack-1:  #008300;
  --stack-2:  #e87ba4;
  --stack-3:  #2a78d6;
  --stack-4:  #eb6834;
  --stack-5:  #1baf7a;
  --stack-6:  #4a3aa7;
  --stack-7:  #eda100;
  --stack-8:  #be185d;
  --stack-9:  #0e9aa7;
  --stack-10: #e34948;
  /* The remainder bucket is deliberately not a hue: it is not an entity, it is
     what is left, and it should recede rather than compete for attention. */
  --stack-other: #9aa3ad;
}

:root { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
    --bg:     #0e1116;
    --card:   #161b22;
    --ink:    #e8eaed;
    --muted:  #8b949e;
    --line:   #262c36;
    --accent: #f2415a;
    --navy:   #0b1522;
    --navy-2: #17406f;
    --good:   #3fb950;
    --bad:    #f85149;
    --warn:   #d29922;
    --shadow: none;

    /* The same six hues re-stepped for the dark card surface (#161b22), not an
       automatic flip. Validated as a set: all six clear 3:1 here. */
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;

    /* Same ten hues restepped for the dark card surface, and re-searched as a
       set: worst adjacent CVD dE 8.2, normal-vision 21.4, all ten above 3:1.
       Dark green is NOT #008300 here -- against dark aqua it fell to dE 11.9,
       under the normal-vision floor. */
    --stack-1:  #4ba63c;
    --stack-2:  #d55181;
    --stack-3:  #3987e5;
    --stack-4:  #d95926;
    --stack-5:  #199e70;
    --stack-6:  #9085e9;
    --stack-7:  #c98500;
    --stack-8:  #d6336c;
    --stack-9:  #22a5b3;
    --stack-10: #e66767;
    --stack-other: #6b7683;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:     #0e1116;
    --card:   #161b22;
    --ink:    #e8eaed;
    --muted:  #8b949e;
    --line:   #262c36;
    --accent: #f2415a;
    --navy:   #0b1522;
    --navy-2: #17406f;
    --good:   #3fb950;
    --bad:    #f85149;
    --warn:   #d29922;
    --shadow: none;

    /* The same six hues re-stepped for the dark card surface (#161b22), not an
       automatic flip. Validated as a set: all six clear 3:1 here. */
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;

    /* Same ten hues restepped for the dark card surface, and re-searched as a
       set: worst adjacent CVD dE 8.2, normal-vision 21.4, all ten above 3:1.
       Dark green is NOT #008300 here -- against dark aqua it fell to dE 11.9,
       under the normal-vision floor. */
    --stack-1:  #4ba63c;
    --stack-2:  #d55181;
    --stack-3:  #3987e5;
    --stack-4:  #d95926;
    --stack-5:  #199e70;
    --stack-6:  #9085e9;
    --stack-7:  #c98500;
    --stack-8:  #d6336c;
    --stack-9:  #22a5b3;
    --stack-10: #e66767;
    --stack-other: #6b7683;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* --- chrome --------------------------------------------------------------- */

.masthead {
  background: linear-gradient(120deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: 26px 32px 0;
}

.masthead-inner {
  max-width: 1500px;
  margin: 0 auto;
}

.brand {
  display: inline-block;
  text-decoration: none;
  color: #fff;
}

.brand h1 {
  margin: 0 0 3px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0;
  font-size: 13.5px;
  opacity: .75;
}

/* Tab nav. Wraps rather than scrolls, so no destination is ever hidden
   off-screen on a phone. */
nav.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 20px;
}

nav.tabs a {
  display: block;
  padding: 9px 15px 10px;
  font-size: 13.5px;
  font-weight: 550;
  color: rgba(255, 255, 255, .74);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
  transition: background .14s ease, color .14s ease;
}

nav.tabs a:hover {
  background: rgba(255, 255, 255, .10);
  color: #fff;
}

nav.tabs a[aria-current="page"] {
  color: #fff;
  border-bottom-color: var(--accent);
  background: rgba(255, 255, 255, .07);
}

nav.tabs a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* --- page body ------------------------------------------------------------ */

main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 26px 32px 72px;
}

.page-head { margin: 0 0 22px; }

.page-head h2 {
  margin: 0 0 5px;
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.page-head .tagline {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 68ch;
}

/* Small facts strip under a destination title: region, airport, coordinates. */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.facts li {
  font-size: 12px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
}

.facts b {
  color: var(--ink);
  font-weight: 600;
}

/* --- panels --------------------------------------------------------------- */

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px;
}

/* Match the card-grid gap where live destination charts meet the panels. */
.dash[data-destination]:not(:empty) + .panels {
  margin-top: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 17px 19px 19px;
  display: flex;
  flex-direction: column;
  min-height: 210px;
}

.panel h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.panel .question {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

/* The empty state a panel wears until a pipeline fills it. Deliberately plain:
   it should read as "nothing here yet", never as "zero". */
.placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  min-height: 96px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Sources this panel is wired to once ingestion exists. */
.wiring {
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.wiring li {
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
}

/* --- KPI tiles (unused today; here so the first pipeline has a house style) - */

/* Chart.js draws into a canvas sized by its container. maintainAspectRatio is
   off so the chart fills this box, which means the box must have a height --
   without one the canvas collapses to zero and nothing appears. */
.chart {
  position: relative;
  height: 240px;
  margin: 14px 0 10px;
}

@media (max-width: 640px) {
  .chart { height: 200px; }
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 17px;
}

.kpi .label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}

.kpi .value {
  font-size: 27px;
  font-weight: 650;
  margin: 6px 0 2px;
  letter-spacing: -0.02em;
}

.kpi .sub { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

.kpi .delta { font-size: 13px; font-weight: 600; }
.kpi .delta.up   { color: var(--good); }
.kpi .delta.down { color: var(--bad); }
.kpi .delta.flat { color: var(--muted); }

/* --- footer --------------------------------------------------------------- */

footer {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 32px 44px;
  color: var(--muted);
  font-size: 12.5px;
}

footer hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0 0 14px;
}

/* --- responsive ----------------------------------------------------------- */

@media (max-width: 640px) {
  .masthead { padding: 20px 18px 0; }
  main      { padding: 20px 18px 56px; }
  footer    { padding: 0 18px 36px; }
  .brand h1 { font-size: 21px; }
  .page-head h2 { font-size: 23px; }
  .panels { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}


/* ---------------------------------------------------------------------------
   Dashboard grid
   ------------------------------------------------------------------------- */

.dash {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  grid-column: span 12;
  min-width: 0;             /* lets a grid child shrink instead of overflowing */
  box-shadow: var(--shadow);
}

.card.half { grid-column: span 6; }

@media (max-width: 1050px) {
  .card.half { grid-column: span 12; }
}

.card > h3 {
  margin: 0 0 3px;
  font-size: 15.5px;
  letter-spacing: -0.01em;
}

.card .why {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 78ch;
}

.card .source {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------------------------------------------------------------------------
   Charts
   ------------------------------------------------------------------------- */

/* Sized to include the x-axis band and the legend beneath it: a container that
   fits only the plot gives the card its own tiny scrollbar. */
.chart {
  position: relative;
  height: 300px;
  margin: 4px 0 0;
}

.chart.tall { height: 360px; }

@media (max-width: 640px) {
  .chart      { height: 250px; }
  .chart.tall { height: 300px; }
}

/* Chart / table toggle. The table view is not a nicety: three series colours
   fall below 3:1 on the light surface, and this is the relief for that. */
.view-toggle {
  display: flex;
  gap: 4px;
  margin: 0 0 10px;
}

.view-toggle button {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;         /* keeps the hit target near 24px tall */
  cursor: pointer;
  line-height: 1.4;
}

.view-toggle button[aria-pressed="true"] {
  color: #fff;
  background: var(--navy-2);
  border-color: var(--navy-2);
}

.view-toggle button:focus-visible {
  outline: 2px solid var(--navy-2);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; max-height: 340px; overflow-y: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 650;
  padding: 7px 9px;
  border-bottom: 1.5px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
}

table.data td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
}

/* Aligned columns of figures, where equal-width digits actually help. */
table.data td.num, table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data tr:last-child td { border-bottom: none; }

.swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  margin-right: 7px;
  vertical-align: baseline;
}

/* ---------------------------------------------------------------------------
   Theme bars, weather tiles, pills
   ------------------------------------------------------------------------- */

.themes { display: grid; gap: 9px; }

.theme-row {
  display: grid;
  grid-template-columns: 150px 1fr 52px;
  gap: 11px;
  align-items: center;
}

.theme-name { font-size: 13px; }

.bar {
  background: var(--line);
  border-radius: 5px;
  height: 20px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: var(--series-1);
}

.theme-val {
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.wx {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.wx-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
}

.wx-card h4 { margin: 0 0 8px; font-size: 13.5px; }

.wx-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  font-size: 12.5px;
}

.wx-card dt { color: var(--muted); }
.wx-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.positive, .pill.ok      { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.pill.negative, .pill.failed  { background: color-mix(in srgb, var(--bad) 14%, transparent);  color: var(--bad); }
.pill.mixed, .pill.partial,
.pill.stale                   { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.neutral                 { background: var(--line); color: var(--muted); }

.note {
  background: color-mix(in srgb, var(--navy-2) 6%, transparent);
  border-left: 3px solid var(--navy-2);
  padding: 10px 14px;
  font-size: 12.5px;
  border-radius: 0 6px 6px 0;
  margin-top: 14px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 26px 4px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty strong { color: var(--ink); font-weight: 650; }


/* A hint that legend entries on the share chart are clickable, and a visible
   state for the series outside the current focus. */
.legend-note {
  font-size: 11.5px;
  color: var(--muted);
  margin: 0 0 10px;
}

.share-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 14px;
}

.share-legend button {
  font: inherit;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;          /* keeps the hit target near 24px tall */
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.4;
}

.share-legend button .swatch { margin: 0; width: 10px; height: 10px; }

.share-legend button.is-muted {
  color: var(--muted);
  background: var(--bg);
}

.share-legend button.is-muted .swatch { opacity: 0.3; }

.share-legend button:focus-visible {
  outline: 2px solid var(--navy-2);
  outline-offset: 2px;
}

/* Focus is emphasis, never visibility or a different denominator. */
.focus-legend button[aria-pressed="true"] {
  color: var(--ink);
  border-color: currentColor;
  font-weight: 700;
  box-shadow: inset 0 -2px currentColor;
}
.focus-legend button { min-height: 32px; }
.data .series-focused {
  background: var(--bg);
  font-weight: 700;
  box-shadow: inset 2px 0 var(--muted);
}

/* Shared header control: normal flow keeps it usable on narrow screens. */
.theme-toggle { display: flex; justify-content: flex-end; gap: 4px; margin-top: 12px; }
.theme-toggle button {
  min-height: 40px; padding: 7px 14px; font: inherit; font-size: 13px;
  color: #fff; background: transparent; border: 1px solid #ffffff70;
  border-radius: 6px; cursor: pointer;
}
.theme-toggle button[aria-pressed="true"] { background: #fff; color: #12233d; font-weight: 700; }
.theme-toggle button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
