:root {
  --ink: #1c2227;
  --muted: #77818a;
  --line: #d9dde0;
  --tick: #b9c0c6;
  --sea: #e3eaee;
  --panel: #fff;
  --hover: #f0f2f3;
  --bar: 58px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

/* 어두운 테마. 지도 바탕색은 js/map.js, 기온 색은 js/colors.js */
[data-theme="dark"] {
  --ink: #e4e8eb;
  --muted: #8a959f;
  --line: #353d45;
  --tick: #56606a;
  --sea: #191e24;
  --panel: #20262c;
  --hover: #2c343c;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--sea);
  color: var(--ink);
  font: 13px/1.3 var(--font);
  font-variant-numeric: tabular-nums;
}

/* 지도와 그 위의 관측값 */
#map, #obs-clip {
  position: absolute;
  inset: 0 0 var(--bar) 0;
}
/* 관측값 그림은 화면보다 크게 그려 두고, 끄는 동안에는 통째로 옮긴다. 넘치는 부분은 잘라 낸다. */
#obs-clip { overflow: hidden; pointer-events: none; }
#obs { position: absolute; will-change: transform; }
.maplibregl-canvas { outline: none; }

/* 요소 고르기. 낱말만 둔다. 고른 것은 짙게, 나머지는 옅게 */
#menu {
  position: absolute;
  z-index: 2;
  left: 14px;
  top: 12px;
  user-select: none;
}
#menu button {
  padding: 2px 0;
  margin-right: 16px;
  border: 0;
  background: none;
  font: 13px var(--font);
  color: var(--muted);
  text-shadow: 0 0 3px var(--sea), 0 0 3px var(--sea), 0 0 3px var(--sea);
  cursor: pointer;
}
#menu button:hover { color: var(--ink); }
#menu button.active { color: var(--ink); font-weight: 600; }
#menu-variants { margin-top: 2px; min-height: 20px; }
#menu-variants button { font-size: 12px; margin-right: 12px; }

/* 지점에 올렸을 때 */
#readout {
  position: absolute;
  z-index: 3;
  transform: translate(14px, -50%);
  padding: 6px 10px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}
#readout.left { transform: translate(calc(-100% - 14px), -50%); }
#readout div + div { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
#readout b { display: block; font-size: 20px; font-weight: 600; line-height: 1.2; }
#readout span { display: block; }
#readout .detail { color: var(--muted); font-size: 11px; }

/* 색 기준 */
#legend {
  position: absolute;
  z-index: 2;
  right: 16px;
  bottom: calc(var(--bar) + 18px);
  width: 34px;
  height: 200px;
  pointer-events: none;
}
#legend-bar { position: absolute; right: 0; top: 0; width: 8px; height: 200px; }
#legend-unit { position: absolute; right: 0; top: -20px; font-size: 11px; color: var(--muted); }
#legend-labels span {
  position: absolute;
  right: 13px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
}

/* 출처. 지도에는 약칭만, 누르면 정식 명칭 */
#credit {
  position: absolute;
  z-index: 2;
  left: 8px;
  bottom: calc(var(--bar) + 4px);
  padding: 2px 4px;
  border: 0;
  background: none;
  font: 10.5px var(--font);
  color: var(--muted);
  text-shadow: 0 0 2px var(--sea), 0 0 2px var(--sea);
  cursor: pointer;
}
#credit:hover { color: var(--ink); }

#sources {
  position: absolute;
  z-index: 3;
  left: 12px;
  bottom: calc(var(--bar) + 26px);
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 12px;
}
#sources a { display: block; color: var(--ink); line-height: 1.7; }
#sources p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }

/* 시각 */
#timeline {
  position: absolute;
  inset: auto 0 0 0;
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px 0 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  user-select: none;
}

#timeline button {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 7px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
#timeline button:hover { background: var(--hover); }
#timeline button svg { display: block; fill: currentColor; }
#play .icon-pause, #play.playing .icon-play { display: none; }
#play.playing .icon-pause { display: inline; }
#theme { color: var(--muted); }

#clock { display: flex; flex-direction: column; min-width: 96px; }
#clock-date { font-size: 11px; color: var(--muted); }
#clock-time { font-size: 20px; font-weight: 600; line-height: 1.15; }

#track { position: relative; flex: 1; height: 100%; }

#scrub {
  position: absolute;
  left: 0;
  top: 13px;
  width: 100%;
  height: 14px;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
#scrub:focus { outline: none; }
#scrub::-webkit-slider-runnable-track { height: 2px; background: var(--line); }
#scrub::-moz-range-track { height: 2px; background: var(--line); }
#scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}
#scrub::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--ink); }

#ticks { position: absolute; left: 0; right: 0; top: 31px; height: 22px; pointer-events: none; }
#ticks i { position: absolute; top: 0; width: 1px; height: 4px; background: var(--tick); }
#ticks i.day { height: 7px; background: var(--ink); }
#ticks span {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}
#ticks span.day { color: var(--ink); font-weight: 600; }

@media (max-width: 600px) {
  #timeline { gap: 10px; padding: 0 6px 0 8px; }
  #clock { min-width: 78px; }
  #clock-time { font-size: 17px; }
}
