/* ICOS Curve.  Colour is a token: the light values here, the dark
   ones under both the system setting and an explicit data-theme, so
   the figure (whose own stylesheet uses the same two scopes) and the
   page always agree. */
:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --accent: #00abc9;
  --accent-ink: #00566a;
  --accent-wash: rgba(0, 171, 201, 0.12);
  --mark: #e41c63;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --line-strong: #383835;
    --accent: #00a3c0;
    --accent-ink: #7fdcee;
    --accent-wash: rgba(0, 163, 192, 0.18);
    --mark: #f0508a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink2: #c3c2b7;
  --muted: #898781;
  --line: #2c2c2a;
  --line-strong: #383835;
  --accent: #00a3c0;
  --accent-ink: #7fdcee;
  --accent-wash: rgba(0, 163, 192, 0.18);
  --mark: #f0508a;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent-ink); }
h1, h2, p { margin: 0; }
sub { font-size: 0.72em; line-height: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.logo { display: block; background: #fff; border-radius: 6px; padding: 4px 8px; line-height: 0; }
.logo img { height: 40px; width: auto; }
/* the dark theme's logo is the one zarr.icos-cp.eu shows on its dark
   header: the lettering light grey, the two marks in their colours, no
   white plate.  Two images and CSS, not a <picture>, because the
   theme can be PINNED by the switch as well as followed. */
.logo .on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo { background: none; padding-left: 0; padding-right: 0; }
  :root:not([data-theme="light"]) .logo .on-light { display: none; }
  :root:not([data-theme="light"]) .logo .on-dark { display: block; }
}
:root[data-theme="dark"] .logo { background: none; padding-left: 0; padding-right: 0; }
:root[data-theme="dark"] .logo .on-light { display: none; }
:root[data-theme="dark"] .logo .on-dark { display: block; }
.heading h1 { font-size: 20px; font-weight: 600; line-height: 1.2; }
.heading p { color: var(--ink2); font-size: 13px; }
.theme { margin-left: auto; font-size: 13px; flex: none; }
.theme span { padding: 4px 10px; }

.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  max-width: 1500px;
  margin: 0 auto;
}

/* ---- the controls ---- */
.controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  align-self: start;
  padding: 4px 14px 12px;
}
/* folded, the settings are a bar above the content and the figure
   takes the whole width */
.layout.folded { grid-template-columns: minmax(0, 1fr); }
.layout.folded .controls { padding-bottom: 4px; }
.controls > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 8px 0;
  list-style-position: inside;
}
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 600; font-size: 13px; padding: 0; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 6px; }

.segmented { display: flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.segmented label { flex: 1; text-align: center; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 6px 4px; color: var(--ink2); border-left: 1px solid var(--line-strong); }
.segmented label:first-child span { border-left: 0; }
.segmented input:checked + span { background: var(--accent-wash); color: var(--ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.presets button {
  font: inherit; font-size: 12px; cursor: pointer;
  color: var(--ink2); background: transparent;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px;
}
.presets button:hover { background: var(--accent-wash); }
.presets button[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); border-color: var(--accent); font-weight: 600; }

.dates, .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dates label, .pair label { font-size: 12px; color: var(--ink2); display: grid; gap: 2px; }
.pair { margin-top: 8px; }
input[type="date"], input[type="search"], select {
  font: inherit; font-size: 13px; width: 100%; min-width: 0;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 5px 6px;
}
.stations {
  margin-top: 6px; max-height: 190px; overflow-y: auto;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg);
}
.stations label { display: flex; gap: 6px; align-items: baseline; padding: 3px 8px; font-size: 13px; cursor: pointer; }
.stations label:hover { background: var(--accent-wash); }
.stations label.off { color: var(--muted); cursor: default; }
.stations .code { font-variant-numeric: tabular-nums; color: var(--ink2); white-space: nowrap; }
.stations .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stations .height { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 8px; align-items: baseline; font-size: 13px; padding: 2px 0; cursor: pointer; }
.check.off { color: var(--muted); cursor: default; }
input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }
.range { display: flex; gap: 10px; align-items: center; }
.range input { flex: 1; }
.range output { font-variant-numeric: tabular-nums; color: var(--ink2); min-width: 2ch; }

/* ---- the content ---- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px 14px;
}
.tile-label { color: var(--ink2); font-size: 13px; }
.tile-value { font-size: 26px; font-weight: 600; line-height: 1.25; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tabs button {
  font: inherit; cursor: pointer; color: var(--ink2); background: transparent;
  border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 10px 10px; box-shadow: var(--shadow); padding: 12px;
}
.figure { position: relative; }
/* the figure alone, over everything: the browser's own full screen where
   it has one, and the same box filling the window where it does not */
.figure.full {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  background: var(--surface); padding: 8px 12px 12px;
}
.figure.full .plot { flex: 1; min-height: 0; }
.figure.full .plot svg { height: 100%; }
.full-exit { display: none; }
.figure.full .full-exit {
  display: block; align-self: flex-end; margin-bottom: 4px;
  font: inherit; font-size: 12px; cursor: pointer;
  color: var(--ink2); background: transparent;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px;
}
.figure.full .full-exit:hover { background: var(--accent-wash); color: var(--ink); }
.export { color: var(--ink2); }
button.link:disabled { color: var(--muted); cursor: progress; text-decoration: none; }
button.link {
  font: inherit; cursor: pointer; padding: 0; border: 0; background: none;
  color: var(--accent-ink); text-decoration: underline;
}
.plot { min-height: 320px; transition: opacity 0.15s; }
.plot.loading { opacity: 0.45; }
.plot svg { display: block; width: 100%; height: auto; }
.plot svg .cv-bg { fill: transparent; }
/* zoom and pan: a drag must not select the figure's text */
.plot svg { user-select: none; -webkit-user-select: none; cursor: crosshair; }
.plot.panning svg { cursor: grabbing; }
.plot svg .cv-zoom {
  fill: var(--accent-ink); fill-opacity: 0.12;
  stroke: var(--accent-ink); stroke-opacity: 0.6; stroke-width: 1;
  pointer-events: none;
}
.zoom-hint {
  margin: 0 0 4px; text-align: right; font-size: 12px; color: var(--ink2);
  display: flex; justify-content: flex-end; gap: 12px; align-items: baseline;
}
/* the ways in are a mouse's; Reset stays for a zoomed link opened anywhere */
@media (hover: none) { .zoom-how { display: none; } }
.message { color: var(--ink2); padding: 8px 4px; }
.links { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; padding: 8px 4px 0; }

.tip {
  position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(11, 11, 11, 0.14);
  padding: 8px 10px; font-size: 12px; min-width: 150px; max-width: 280px;
}
.tip-head { color: var(--ink2); margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 16px auto 1fr; gap: 6px; align-items: center; white-space: nowrap; }
.tip-key { height: 0; border-top: 3px solid var(--muted); border-radius: 2px; }
.tip-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-name { color: var(--ink2); overflow: hidden; text-overflow: ellipsis; }

.map { height: min(68vh, 620px); min-height: 360px; border-radius: 8px; z-index: 0; }
.pop { font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; min-width: 180px; }
.pop strong { font-size: 14px; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; margin: 6px 0; }
.pop dt { color: #52514e; }
.pop dd { margin: 0; font-variant-numeric: tabular-nums; }
.pop button { font: inherit; cursor: pointer; margin-top: 4px; }

#panel-animation h2 { font-size: 16px; font-weight: 600; text-align: center; margin-bottom: 8px; }
#panel-animation video { display: block; width: min(100%, 900px); margin: 0 auto; border-radius: 8px; background: #000; }
.about p { max-width: 78ch; color: var(--ink2); margin-bottom: 10px; }

@media (max-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .stats { grid-template-columns: 1fr; gap: 8px; }
  .tile { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  .tile-value { font-size: 20px; white-space: nowrap; }
  .heading p { display: none; }
  .heading h1 { white-space: nowrap; font-size: 18px; }
  .top { gap: 10px; padding: 10px; }
  .logo img { height: 32px; }
  .theme span { padding: 4px 7px; }
  .tabs { overflow-x: auto; }
  .tabs button { white-space: nowrap; padding: 8px 10px; }
}
