:root {
  --abyss: #030d17;
  --deep: #061726;
  --surface: #0a2133;
  --surface-2: #0e2a40;
  --ink: #e4eff6;
  --muted: #8aa6bb;
  --faint: #5d7a90;
  --accent: #5fe3cf;
  --accent-soft: #5fe3cf1f;
  --amber: #f3b664;
  --sky: #7fb2ff;
  --line: #8cbee124;
  --line-strong: #8cbee147;
  --sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Instrument Serif', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--abyss); color: var(--ink); overflow: hidden; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
.mono { font-family: var(--mono); }
.serif { font-family: var(--serif); font-weight: 400; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#gl.pointer { cursor: pointer; }
#gl.probe { cursor: crosshair; }

.ui { transition: opacity .5s ease, transform .5s ease; }
body.ui-hidden .ui, body.ui-hidden #labels { opacity: 0; pointer-events: none; }

/* cabecera */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: flex; flex-direction: column; text-decoration: none; line-height: 1.15; }
.brand-name { font-family: var(--serif); font-size: 22px; }
.brand-kicker { font-size: 10.5px; letter-spacing: .14em; color: var(--muted); }
.top-actions { display: flex; gap: 10px; align-items: center; }
.lang { display: flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; font-size: 11px; }
.lang button { padding: 6px 10px; color: var(--muted); }
.lang button.on { background: var(--accent-soft); color: var(--accent); }
.chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 14px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: #030d1799; backdrop-filter: blur(8px); }
.chip:hover, .chip.on { border-color: var(--accent); color: var(--accent); }
.icon { width: 32px; height: 32px; border: 1px solid var(--line-strong); border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: #030d1799; }
.icon:hover { color: var(--accent); border-color: var(--accent); }

/* intro */
#intro {
  position: fixed; left: clamp(20px, 5vw, 72px); top: 50%; transform: translateY(-50%);
  max-width: 560px; z-index: 15;
}
#intro.gone { opacity: 0; transform: translateY(-46%); pointer-events: none; }
.fig { font-size: 11px; letter-spacing: .16em; color: var(--accent); margin: 0 0 14px; }
#intro h1 { font-size: clamp(46px, 7vw, 92px); line-height: .95; margin: 0 0 18px; letter-spacing: -.01em; }
#intro h1 em { color: var(--accent); }
.lede { color: var(--muted); font-size: 17px; max-width: 470px; margin: 0 0 26px; text-wrap: pretty; }
.stats { display: grid; grid-template-columns: repeat(4, auto); gap: 0; margin: 0 0 30px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); width: fit-content; }
.stats div { padding: 12px 22px 12px 0; margin-right: 22px; border-right: 1px solid var(--line); }
.stats div:last-child { border-right: 0; margin-right: 0; }
.stats dd { margin: 0; font-family: var(--serif); font-size: 34px; line-height: 1; }
.stats dt { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; color: var(--faint); text-transform: uppercase; margin-top: 6px; }
.intro-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.cta { background: var(--accent); color: var(--abyss); padding: 12px 22px; border-radius: 999px; font-weight: 500; font-size: 14px; }
.cta:hover { filter: brightness(1.1); }
.cta.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.cta.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* panel lateral */
#panel {
  position: fixed; right: 20px; top: 76px; max-height: calc(100vh - 168px); width: min(380px, calc(100vw - 40px));
  z-index: 12; overflow-y: auto; padding: 22px 22px 18px;
  background: linear-gradient(180deg, #0a2133e6, #061726e6);
  border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(14px);
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
#legend.hidden { opacity: 0; pointer-events: none; }
#panel.hidden { opacity: 0; transform: translateX(16px); pointer-events: none; }
#panel .p-fig { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--accent); margin-bottom: 10px; }
#panel h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.05; margin: 0 0 14px; }
.p-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 16px; font-family: var(--mono); font-size: 11px; }
.p-meta dt { color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
.p-meta dd { margin: 0; color: var(--ink); }
.p-body { color: #c8d9e5; margin: 0 0 18px; text-wrap: pretty; }
.p-metric { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; margin-bottom: 12px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.p-metric .v { font-family: var(--serif); font-size: 46px; line-height: 1; color: var(--amber); }
.p-metric .u { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.p-note, .p-extra { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; text-wrap: pretty; }
.p-links { display: flex; flex-direction: column; gap: 6px; margin: 16px 0 4px; }
.p-link { font-family: var(--mono); font-size: 11.5px; color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; width: fit-content; }
.p-link:hover { border-bottom-color: var(--accent); }
.p-next { margin-top: 18px; width: 100%; text-align: left; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; }
.p-next:hover { border-color: var(--accent); color: var(--accent); }
.p-toggle { display: none; }

/* leyenda */
#legend {
  position: fixed; left: 20px; bottom: 92px; z-index: 11; max-width: 330px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #030d17b3; backdrop-filter: blur(10px);
}
#legend .row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
#legend .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; background: currentColor; }
#legend .sw.line { width: 16px; height: 2px; border-radius: 1px; }
#legend .sw.ring { background: transparent; border: 1.5px solid currentColor; }
#legend .sw.sq { border-radius: 2px; box-shadow: none; }
#legend .note { color: var(--faint); font-size: 10px; margin-top: 8px; line-height: 1.45; }
#legend .scale { height: 8px; border-radius: 4px; margin: 8px 0 3px; background: linear-gradient(90deg, #2b8a92, #17566c 25%, #0e3753 50%, #09243b 75%, #061827); }
#legend .scale-l { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); }

/* dock */
#dock {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 14;
  display: flex; gap: 4px; padding: 5px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: #030d17cc; backdrop-filter: blur(12px);
}
#dock button { padding: 9px 16px; border-radius: 999px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; color: var(--muted); white-space: nowrap; }
#dock button:hover { color: var(--ink); }
#dock button.on { background: var(--accent-soft); color: var(--accent); }
#dock button .n { color: var(--faint); margin-right: 6px; }

#hint { position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); font-size: 10.5px; color: var(--faint); letter-spacing: .04em; margin: 0; z-index: 10; white-space: nowrap; pointer-events: none; }

/* etiquetas 3D */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
.lbl { text-shadow: 0 0 2px #030d17, 0 0 8px #030d17, 0 0 14px #030d17cc; position: absolute; left: 0; top: 0; white-space: nowrap; transform-origin: 0 0; will-change: transform; display: flex; flex-direction: column; font-size: 12px; transition: opacity .25s; }
.lbl span { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.lbl-obs, .lbl-obs2, .lbl-home { padding-left: 12px; border-left: 1px solid var(--accent); }
.lbl-obs b { font-family: var(--mono); font-weight: 500; font-size: 12.5px; letter-spacing: .1em; color: var(--accent); }
.lbl-obs.click { pointer-events: auto; cursor: pointer; }
.lbl-obs.click:hover b { text-decoration: underline; text-underline-offset: 3px; }
.lbl-home { border-left-color: var(--amber); }
.lbl-home b { font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: .1em; color: var(--amber); }
.lbl-obs2 { border-left-color: var(--amber); }
.lbl-obs2 span { color: var(--amber); font-size: 11.5px; }
.lbl-place span { color: #c8d9e5; font-size: 10.5px; }
.lbl-small span { color: var(--muted); font-size: 10px; font-style: italic; }
.lbl-region span { color: #8aa6bbcc; font-size: 10.5px; letter-spacing: .32em; }
.lbl-sea span { color: #7fb2ffaa; font-size: 10px; letter-spacing: .3em; font-style: italic; }
.lbl.off { opacity: 0; }

#probe {
  position: fixed; z-index: 16; pointer-events: none; font-size: 11px; padding: 7px 10px; border-radius: 8px;
  background: #030d17e6; border: 1px solid var(--line-strong); color: var(--ink); white-space: nowrap;
}
#probe .d { color: var(--accent); font-size: 13px; }
#probe .l { color: var(--muted); }
#tooltip {
  position: fixed; z-index: 16; pointer-events: none; padding: 8px 11px; border-radius: 9px;
  background: #030d17ee; border: 1px solid var(--line-strong); font-size: 12px; white-space: nowrap;
}
#tooltip b { font-weight: 500; }
#tooltip span { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

#fade { position: fixed; inset: 0; background: var(--abyss); z-index: 30; opacity: 1; pointer-events: none; transition: opacity .55s ease; display: grid; place-items: center; }
#fade.off { opacity: 0; }
#loading { font-size: 11px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; }

/* incrustado en otra web */
body.embed .top .brand, body.embed #hint { display: none; }
body.embed #panel { top: 60px; }

@media (max-width: 760px) {
  .top { padding: 12px 14px; }
  .brand-name { font-size: 18px; }
  #btn-tour { display: none; }
  #intro { top: auto; bottom: 0; transform: none; left: 0; right: 0; max-width: none; padding: 70px 18px 84px; background: linear-gradient(to top, var(--abyss) 62%, #030d17cc 82%, transparent); }
  #intro h1 { font-size: 44px; }
  #intro.gone { transform: translateY(10px); }
  .lede { font-size: 15px; }
  .stats { grid-template-columns: repeat(2, auto); }
  .stats div:nth-child(2) { border-right: 0; }
  .stats dd { font-size: 26px; }
  #panel { top: auto; bottom: 74px; right: 10px; left: 10px; width: auto; max-height: 46vh; padding: 16px; border-radius: 16px; }
  #panel.collapsed { max-height: 84px; overflow: hidden; }
  #panel h2 { font-size: 24px; }
  .p-toggle { display: block; position: absolute; right: 12px; top: 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 6px; }
  #legend { display: none; }
  #hint { display: none; }
  #dock { bottom: 14px; max-width: calc(100vw - 20px); overflow-x: auto; }
  #dock button { padding: 8px 11px; font-size: 10.5px; }
  #dock button .n { display: none; }
}
