
/* Layout: full-bleed globe as the instrument; floating console panels (layers left, detail right, live feed bottom). Dark and light themes share one token set; the toggle sets data-theme on <html>. */
:root {
  color-scheme: dark;
  --abyss: #0a1622;        /* page ground */
  --sea: #1a4f86;          /* ocean on the globe: a clear mid blue */
  --sea-rim: #3a78b4;
  --land: #6f7c66;         /* muted sage, low contrast against the blue */
  --land-edge: #8f9c84;
  --grat: #8fb3d6;
  --panel: rgba(10, 24, 38, 0.86);
  --panel-line: rgba(150, 190, 220, 0.2);
  --tip: rgba(6, 16, 26, 0.94);
  --ink: #e6eef4;
  --ink-dim: #9fb2c0;
  --ink-faint: #6c8394;
  --shade: 0.38;
  --border: #d9e2cf;       /* country borders on sage land */
  --label: #f1f5ec;
  --eez: #9fd0ff;          /* EEZ outlines */
  --hl: #ffcf5c;           /* focused country */
  --cable: #5fe0e4;        /* telecom */
  --landing: #f2fbfc;
  --port: #f0bd5e;         /* sand / harbour light */
  --rig: #ff6b4a;          /* flare */
  --reserve: #d48aff;      /* seabed hydrocarbons */
  --company: #a9cbff;      /* energy companies and offices */
  --ship-cargo: #5fd6b8; --ship-tanker: #ff9466; --ship-pass: #ffe27a; --ship-fish: #c3a8ff; --ship-other: #a7bccb; /* live vessels by AIS type */
  --real: #5fd38a;
  --curated: #f0c25a;
  --focus: #ffffff;
  --display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --abyss: #eef2f5;
  --sea: #7fb6e3;          /* daylight sea blue */
  --sea-rim: #4f8fc6;
  --land: #f1ead8;         /* soft sand */
  --land-edge: #b9ad90;
  --grat: #ffffff;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-line: rgba(30, 60, 90, 0.16);
  --tip: rgba(255, 255, 255, 0.97);
  --ink: #142231;
  --ink-dim: #4a5e6e;
  --ink-faint: #75889a;
  --shade: 0.16;
  --border: #8f8063;
  --label: #4d4433;
  --eez: #1d5c96;
  --hl: #c4720a;
  --cable: #0b7d8c;
  --landing: #17394d;
  --port: #b5730f;
  --rig: #e0431f;
  --reserve: #8a3dd0;
  --company: #2c5fc4;
  --ship-cargo: #0e8a72; --ship-tanker: #cc4e1e; --ship-pass: #9a7b00; --ship-fish: #6b47d6; --ship-other: #5d7384;
  --real: #1d8f50;
  --curated: #a87b0c;
  --focus: #0d1b28;
}
html, body { height: 100%; }
body {
  margin: 0; background: var(--abyss); color: var(--ink); font: 14px/1.45 var(--body);
  overflow: hidden;
}
#stage { position: fixed; inset: 0; }
#map { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }

.panel {
  position: absolute; background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 10px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Masthead */
#mast {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  pointer-events: none;
}
#mast > * { pointer-events: auto; }
.brand h1 {
  margin: 0; font: 800 30px/0.95 var(--display); letter-spacing: 0.04em; text-transform: uppercase;
}
.brand p { margin: 4px 0 0; color: var(--ink-dim); font-size: 12.5px; max-width: 34ch; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 8px; padding: 3px; }
.seg button { background: none; border: 0; padding: 6px 10px; border-radius: 6px; font-size: 12.5px; color: var(--ink-dim); }
.seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--cable) 18%, transparent); color: var(--ink); }
#detail .sect { margin-top: 12px; font: 600 10.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); border: 0; padding-top: 4px; }
#detail .lnk { background: none; border: 0; padding: 0; color: var(--cable); text-align: left; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, var(--cable) 40%, transparent); }
#detail .interest { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12.5px; }
#detail .interest li { padding: 6px 0; border-top: 1px solid var(--panel-line); }
#detail .interest .head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
#detail .interest .count { font: 11px var(--mono); color: var(--ink-faint); font-weight: 400; }
#detail .interest .who { margin-top: 2px; color: var(--ink-dim); font-size: 12px; }
#detail .line { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-dim); }
#detail .line .lbl { color: var(--ink-faint); }
#detail .muted { font-size: 12.5px; color: var(--ink-faint); margin: 6px 0 0; }
/* Intro: logo pops in with a red/blue glow, the name wipes in, then the overlay clears onto the moving globe */
#intro { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background-color: var(--abyss); transition: background-color 0.9s ease; cursor: pointer; }
#intro.clear { background-color: transparent; pointer-events: none; }
#intro .logo { position: relative; display: grid; justify-items: center; gap: 22px; transition: transform 1.1s cubic-bezier(0.5, 0, 0.2, 1), opacity 1s ease 0.2s; }
#intro.shrink .logo { transform: scale(0.42); opacity: 0; }
#intro .shield { width: 150px; height: auto; position: relative; animation: wrr-pop 0.85s cubic-bezier(0.2, 1.4, 0.4, 1) both; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.18)); }
#intro .glow { position: absolute; top: -70px; width: 330px; height: 330px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 38% 45%, rgba(255, 30, 30, 0.6), transparent 42%), radial-gradient(circle at 64% 52%, rgba(30, 110, 255, 0.6), transparent 42%);
  filter: blur(26px); animation: wrr-glow 1.7s ease-out both; }
#intro .flare { position: absolute; top: 4px; left: calc(50% + 40px); width: 90px; height: 90px; pointer-events: none; z-index: 1;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 6%, rgba(255, 255, 255, 0.35) 12%, transparent 45%), linear-gradient(45deg, transparent 47%, rgba(255, 255, 255, 0.8) 50%, transparent 53%);
  animation: wrr-flare 1.4s ease-out 0.2s both; }
#intro .word { font: 800 44px/1 "Helvetica Neue", Helvetica, Arial, sans-serif; letter-spacing: 0.01em; color: var(--ink); animation: wrr-wipe 0.9s cubic-bezier(0.4, 0, 0.2, 1) 0.5s both; }
#intro .skip { position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); font: 11px var(--mono); letter-spacing: 0.08em; color: var(--ink-faint); transition: opacity 0.4s; }
#intro.clear .skip { opacity: 0; }
@keyframes wrr-pop { 0% { transform: scale(0.35); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes wrr-glow { 0% { opacity: 0; transform: scale(0.6); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes wrr-flare { 0% { opacity: 0; transform: scale(0.3) rotate(-20deg); } 35% { opacity: 1; } 100% { opacity: 0; transform: scale(1.4) rotate(15deg); } }
@keyframes wrr-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
#mast, #layers, #readout { transition: opacity 0.6s ease, transform 0.6s ease; }
#feed { transition: opacity 0.6s ease, transform 0.6s ease; }
html.intro #mast { opacity: 0; transform: translateY(-12px); }
html.intro #layers { opacity: 0; transform: translateX(-18px); }
html.intro #readout { opacity: 0; }
html.intro #feed { opacity: 0; transform: translateX(-50%) translateY(18px); }
@media (max-width: 760px) { #intro .word { font-size: 30px; } #intro .shield { width: 110px; } }
#themeBtn { display: inline-flex; align-items: center; gap: 6px; }
#themeBtn svg { width: 15px; height: 15px; }
#layers h2.sub { margin-top: 12px; }
.layer.base .src { color: var(--ink-faint); }
.layer .swatch-line { display: inline-block; width: 16px; height: 0; border-top: 1.5px dashed var(--c); vertical-align: middle; }
#search {
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 8px; padding: 7px 10px;
  width: 200px; font-size: 12.5px;
}
#search::placeholder { color: var(--ink-faint); }
.iconbtn { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; color: var(--ink-dim); }

/* Layers */
#layers { left: max(16px, env(safe-area-inset-left, 0px)); top: 112px; width: 252px; padding: 12px 12px 10px; }
#layers h2, #detail h2.eyebrow, #feed .label {
  margin: 0 0 8px; font: 600 11px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint);
}
.layer { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center; padding: 7px 4px; border-radius: 6px; }
.layer + .layer { border-top: 1px solid var(--panel-line); }
.layer input { appearance: none; width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--c); margin: 0; display: grid; place-items: center; cursor: pointer; }
.layer input:checked { background: var(--c); }
.layer input:checked::after { content: ""; width: 7px; height: 4px; border: 2px solid var(--abyss); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.layer label { cursor: pointer; font-weight: 500; }
.layer .count { font: 12px var(--mono); color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.layer .src { grid-column: 2 / 4; font-size: 11.5px; color: var(--ink-faint); display: flex; gap: 6px; align-items: center; }
.badge { font: 500 10px/1 var(--mono); letter-spacing: 0.08em; padding: 3px 5px; border-radius: 4px; text-transform: uppercase; }
.badge.real, .badge.live { color: var(--real); background: color-mix(in srgb, var(--real) 13%, transparent); }
.badge.curated { color: var(--curated); background: color-mix(in srgb, var(--curated) 13%, transparent); }
.badge.demo { color: var(--rig); background: color-mix(in srgb, var(--rig) 14%, transparent); }
.ves-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 2px 4px 8px 30px; font: 11px var(--mono); color: var(--ink-faint); }
.ves-legend[hidden] { display: none; }
.ves-legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 1px; background: var(--c); vertical-align: 0; }
#detail .ships .vstat { margin: 0 0 6px; }
#layers .foot { margin-top: 8px; font-size: 11.5px; color: var(--ink-faint); }
#layers .foot button { background: none; border: 0; padding: 0; color: var(--cable); text-decoration: underline; text-underline-offset: 2px; font-size: 11.5px; }

/* Detail */
#detail { right: max(16px, env(safe-area-inset-right, 0px)); top: 112px; width: 300px; max-height: calc(100% - 250px); overflow: auto; padding: 14px 14px 12px; }
#detail h3 { margin: 0 0 2px; font: 800 24px/1.05 var(--display); letter-spacing: 0.02em; text-wrap: balance; }
#detail .sub { color: var(--ink-dim); font-size: 12.5px; margin-bottom: 10px; }
#detail dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 12.5px; }
#detail dt { color: var(--ink-faint); }
#detail dd { margin: 0; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
#detail .note { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--panel-line); font-size: 13px; }
#detail .list { margin: 6px 0 0; padding: 0; list-style: none; max-height: 160px; overflow: auto; font-size: 12.5px; }
#detail .list li { padding: 3px 0; border-bottom: 1px dashed var(--panel-line); }
#detail .list button { background: none; border: 0; padding: 0; color: var(--cable); text-align: left; }
#detail .close { position: absolute; top: 8px; right: 8px; background: none; border: 0; color: var(--ink-dim); font-size: 18px; line-height: 1; padding: 4px 6px; }
#detail .srcline { margin-top: 10px; font-size: 11px; color: var(--ink-faint); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#detail a { color: var(--cable); }

/* Feed */
#feed {
  left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  width: min(720px, calc(100% - 32px)); padding: 10px 12px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
}
#feed .label { margin: 0; display: flex; align-items: center; gap: 6px; }
#regionBar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; border-bottom: 1px solid var(--panel-line); }
#regionBar::-webkit-scrollbar { display: none; }
#regionBar button { flex: none; background: none; border: 1px solid var(--panel-line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--ink-dim); white-space: nowrap; }
#regionBar button[aria-pressed="true"] { background: rgba(63, 208, 212, 0.16); border-color: rgba(63, 208, 212, 0.5); color: var(--ink); }
#detail .brief { margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; }
#detail .brief li { border-top: 1px solid var(--panel-line); }
#detail .brief button { display: block; width: 100%; background: none; border: 0; padding: 8px 0; text-align: left; color: var(--ink); line-height: 1.4; }
#detail .brief button:hover .t b { color: var(--cable); }
#detail .brief .k { display: block; font: 500 10px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 2px; }
#detail .brief .t { color: var(--ink-dim); }
#detail .brief .t b { color: var(--ink); font-weight: 600; }
#detail .brief .sea { display: block; margin-top: 2px; font: 11px var(--mono); color: var(--ink-faint); }
#detail .seas { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
#detail .seas button { background: none; border: 1px solid var(--panel-line); border-radius: 999px; padding: 3px 8px; font-size: 11.5px; color: var(--ink-dim); }
#detail .seas button[aria-pressed="true"] { background: rgba(63, 208, 212, 0.16); border-color: rgba(63, 208, 212, 0.5); color: var(--ink); }
#feed .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rig); box-shadow: 0 0 0 0 var(--rig); animation: ping 2s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255,107,74,0.7); } 80%,100% { box-shadow: 0 0 0 8px rgba(255,107,74,0); } }
#feedText { min-width: 0; font-size: 13.5px; transition: opacity 0.35s; }
#feedText b { font-weight: 600; }
#feedText .k { font: 500 10.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; margin-right: 6px; }
#feed .ctl { display: flex; gap: 4px; }
#feed .ctl button { background: none; border: 1px solid var(--panel-line); border-radius: 6px; padding: 4px 8px; color: var(--ink-dim); font-size: 12px; }

/* Tooltip */
#tip {
  position: fixed; pointer-events: none; z-index: 5; max-width: 260px; padding: 7px 9px; border-radius: 7px;
  background: var(--tip); border: 1px solid var(--panel-line); font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,0.18); transform: translate(12px, 12px);
}
#tip .t { font-weight: 600; }
#tip .m { color: var(--ink-dim); font-size: 11.5px; }

/* Scale readout */
#readout { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); font: 11px var(--mono); color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* About */
#about { inset: 0; margin: auto; width: min(560px, calc(100% - 32px)); height: fit-content; max-height: calc(100% - 64px); overflow: auto; padding: 18px 20px; z-index: 6; }
#about h3 { margin: 0 0 8px; font: 800 26px/1 var(--display); letter-spacing: 0.03em; text-transform: uppercase; }
#about table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#about td, #about th { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--panel-line); vertical-align: top; }
#about th { font: 600 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
#about p { color: var(--ink-dim); font-size: 13px; }

#layersToggle { display: none; }
@media (max-width: 760px) {
  .brand h1 { font-size: 24px; }
  .brand p { display: none; }
  #search { width: 140px; }
  #layersToggle { display: inline-block; }
  #layers { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 136px); width: min(280px, calc(100% - 32px)); }
  #layers.collapsed { display: none; }
  #detail { left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); width: auto; top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 136px); max-height: 46%; z-index: 4; }
  #feed { grid-template-columns: 1fr auto; }
  #regionBar { margin: 0 -2px; flex-wrap: nowrap; }
  #feed .label { display: none; }
  #readout { display: none; }
}
@media (prefers-reduced-motion: reduce) { #feed .dot { animation: none; } #feedText { transition: none; } }
