/* Global Ocean Data. Palette borrowed from the sibling directory site, globaldataocean.co. */
:root {
  --bg: #0a1628;
  --bg-deep: #050c18;
  --card: rgba(13, 34, 56, 0.94);
  --card-solid: #0d2238;
  --accent: #00b4d8;
  --accent-soft: rgba(0, 180, 216, 0.16);
  --text: #f0f4f8;
  --text-2: #a9bdd3;
  --muted: #8ea6bf;
  --border: rgba(255, 255, 255, 0.12);
  --warn: #ffc857;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% 45%, #0c2140 0%, var(--bg) 45%, var(--bg-deep) 100%);
  color: var(--text);
  font: 14px/1.45 var(--font);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
a:hover { color: #48cae4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

#globe, #labels { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#globe { touch-action: none; cursor: grab; }
#globe.dragging { cursor: grabbing; }
#globe:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
#labels { pointer-events: none; }

.brand { position: fixed; top: 14px; left: 16px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; text-shadow: 0 1px 3px #000; }
.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: 0.01em; }
.brand p { margin: 2px 0 0; color: var(--text-2); font-size: 0.82rem; }
.brand a { pointer-events: auto; white-space: nowrap; }

.coords {
  position: fixed; left: 16px; bottom: calc(14px + env(safe-area-inset-bottom));
  font: 12px/1.3 var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2);
  background: rgba(5, 12, 24, 0.6); padding: 4px 8px; border-radius: 6px; pointer-events: none;
}
.coords:empty { display: none; }

.zoom { position: fixed; right: 372px; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
.zoom button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); font-size: 1.2rem; line-height: 1;
}
.zoom button:hover { border-color: var(--accent); }

/* ---- layer panel ---- */
.panel {
  position: fixed; top: 14px; right: 14px; bottom: 14px; width: 344px;
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 0; }
.panel h2 { margin: 0; font-size: 1rem; }
.panel-close { display: none; }
.panel-note, .panel-foot { margin: 6px 14px 8px; color: var(--muted); font-size: 0.78rem; }
.panel-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.layers { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1 1 auto; overscroll-behavior: contain; }
.layer { padding: 8px 6px 10px; border-top: 1px solid var(--border); display: grid; grid-template-columns: auto 1fr; column-gap: 8px; }
.layer:first-child { border-top: 0; }
.layer > input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--accent); }
.layer > label { font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 24px; }
.layer > :not(input):not(label) { grid-column: 2; }
.layer .status { margin: 2px 0 0; font-size: 0.8rem; color: var(--text-2); }
.layer .status.bad { color: var(--warn); }
.layer .src { margin: 4px 0 0; font-size: 0.74rem; color: var(--muted); }
.layer .sub { margin: 6px 0 0; font-size: 0.8rem; display: flex; align-items: center; gap: 6px; }
.layer .sub input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.sw-temperature { background: linear-gradient(90deg, #2b3a9e, #2fb3b5, #e6d35a, #d9453b); }
.sw-currents { background: linear-gradient(135deg, transparent 40%, #7fe7ff 41%, #7fe7ff 52%, transparent 53%), #12324f; }
.sw-tides { background: linear-gradient(90deg, #12324f 30%, #59d2ff 30%, #59d2ff 50%, #12324f 50%, #12324f 65%, #ff9f6b 65%, #ff9f6b 85%, #12324f 85%); }
.sw-biology { background: radial-gradient(circle, #ff5d5d 0 35%, #ffd23f 36% 60%, #12324f 61%); }
.sw-ships { background: linear-gradient(180deg, #12324f 45%, #ff7a3d 46% 80%, #12324f 81%); }
.sw-plastics { background: radial-gradient(circle, #12324f 0 30%, #e879f9 31% 55%, #12324f 56%); }
.sw-depth { background: linear-gradient(90deg, #b8e6f0, #3a8bb6, #1b356d, #120f3a); }
.sw-storms { background: radial-gradient(circle, #ffffff 0 18%, #12324f 19% 32%, #ffffff 33% 42%, #12324f 43%); }
.sw-salinity { background: linear-gradient(90deg, #2a186c, #206e8b, #5ab978, #fdee99); }

.legend { margin: 6px 0 0; font-size: 0.76rem; color: var(--text-2); }
.legend .bar { height: 10px; border-radius: 3px; border: 1px solid var(--border); }
.legend .ticks { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; margin-top: 2px; }
.legend ul { list-style: none; margin: 4px 0 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.legend .key { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid rgba(255, 255, 255, 0.3); }
.legend p { margin: 4px 0 0; }

.panel-toggle { display: none; }

/* ---- info card ---- */
.card {
  position: fixed; left: 16px; top: 84px; width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 140px); overflow: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.card h2 { margin: 0 28px 6px 0; font-size: 1rem; }
.card dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 0.85rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card .card-src { margin: 8px 0 0; font-size: 0.78rem; color: var(--muted); }
.card .note { grid-column: 1 / -1; color: var(--muted); font-size: 0.78rem; }
.card-close {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px;
  border: 0; background: transparent; font-size: 1.3rem; color: var(--text-2);
}

.fallback { position: fixed; top: 84px; left: 16px; max-width: 420px; color: var(--warn); }

/* ---- no WebGL: the panel becomes the page ---- */
body.no-globe { overflow: auto; }
body.no-globe #globe, body.no-globe #labels, body.no-globe .zoom, body.no-globe .coords, body.no-globe .panel-toggle { display: none; }
body.no-globe .brand { position: static; padding: 16px; pointer-events: auto; }
body.no-globe .fallback { position: static; margin: 0 16px 12px; }
body.no-globe .panel { position: static; width: auto; max-width: 720px; margin: 0 16px 16px; }
body.no-globe .layer > input, body.no-globe .layer .sub, body.no-globe .panel-close { display: none; }
body.no-globe .layer { display: block; }
body.no-globe .panel-note { display: none; }

/* ---- phones: panel becomes a bottom sheet opened by a thumb-height button ---- */
@media (max-width: 720px) {
  .brand h1 { font-size: 1.05rem; }
  .brand p { font-size: 0.75rem; }
  .zoom { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .zoom button { width: 44px; height: 44px; }
  .coords { bottom: calc(76px + env(safe-area-inset-bottom)); left: 12px; max-width: calc(100% - 84px); font-size: 11px; }
  .panel-toggle {
    display: block; position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(14px + env(safe-area-inset-bottom)); min-width: 132px; height: 48px; padding: 0 22px;
    border-radius: 24px; border: 1px solid var(--accent); background: var(--card-solid);
    font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); z-index: 3;
  }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 72vh;
    border-radius: 16px 16px 0 0; padding-bottom: calc(70px + env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform 0.25s ease, visibility 0.25s; visibility: hidden; z-index: 2;
  }
  .panel.open { transform: none; visibility: visible; }
  .panel-close { display: block; width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.5rem; color: var(--text-2); }
  .layer > input { width: 22px; height: 22px; }
  .layer > label { min-height: 30px; }
  .card { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(72px + env(safe-area-inset-bottom)); max-height: 45vh; }
  body.no-globe .panel { transform: none; visibility: visible; max-height: none; border-radius: var(--radius); }
}
@media (max-width: 720px) and (max-height: 500px) {
  .panel { max-height: 90vh; }
}
@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}
