:root {
  --wave-crest: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 24' preserveAspectRatio='none'%3E%3Cpath d='M0 12 C 18 2 37 2 55 12 S 92 22 110 12 S 147 2 165 12 S 202 22 220 12 L220 24 L0 24 Z' fill='%238FD8F2'/%3E%3C/svg%3E");
}

@property --waterline {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 100%;
}

@keyframes wave-run {
  from {
    background-position-x: 0, 0;
  }
  to {
    background-position-x: -220px, 0;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes neon-on {
  0% {
    opacity: 0;
  }
  8% {
    opacity: 0.8;
  }
  10% {
    opacity: 0.1;
  }
  18% {
    opacity: 0.9;
  }
  20% {
    opacity: 0.25;
  }
  32%, 100% {
    opacity: 1;
  }
}

@keyframes flood-swell {
  0%, 100% {
    --waterline: 58%;
  }
  50% {
    --waterline: 53.5%;
  }
}

@keyframes line-draw {
  from {
    opacity: 0;
    transform: scaleX(0.15);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hint-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.72;
  }
}

#landing {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  text-align: center;
  color: #EAF8FF;
  font-family: var(--font-sans);
  background: #02060F url(./assets/landing/poster.jpg) center / cover no-repeat;
}

#landing-gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1200ms ease;
  z-index: 0;
}

#landing.gl-ready #landing-gl {
  opacity: 1;
}

/* Scrim over the 3D scene: darkens the top for the title and the bottom for the caption and credits. */
#landing::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(2, 6, 15, 0.78) 0%, rgba(2, 6, 15, 0.35) 30%, rgba(2, 6, 15, 0) 52%),
    linear-gradient(0deg, rgba(2, 6, 15, 0.55) 0%, rgba(2, 6, 15, 0) 25%);
}

#hero {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  margin-top: clamp(4px, 4vh, 48px);
  padding: 0 16px;
}

#hero > * {
  max-width: 960px;
}

#landing-title {
  position: relative;
  z-index: 1;
  text-align: center;
  text-transform: uppercase;
  color: #FFFFFF;
  margin-bottom: 6px;
  line-height: 1.05;
}

.lt-line {
  display: block;
  font-weight: 800;
  color: #EAF8FF;
  text-shadow: 0 0 6px rgba(150, 230, 255, 0.48), 0 0 18px rgba(41, 182, 255, 0.4), 0 0 42px rgba(23, 120, 255, 0.3), 0 0 90px rgba(23, 120, 255, 0.2);
}

.lt-main {
  font-size: clamp(40px, 9vw, 120px);
  letter-spacing: 0.14em;
  line-height: 1;
  animation: neon-on 1400ms linear 300ms both;
}

.lt-sub {
  font-size: clamp(18px, 3.6vw, 46px);
  letter-spacing: 0.5em;
  margin-top: 0.25em;
  animation: neon-on 1400ms linear 700ms both;
}

.lt-tag {
  display: flex;
  justify-content: center;
  gap: 2.2em;
  font-size: clamp(11px, 1.5vw, 18px);
  font-weight: 600;
  letter-spacing: 0.32em;
  color: #9FE6FF;
  margin-top: 1.2em;
  animation: rise-in 900ms cubic-bezier(0.22, 0.61, 0.36, 1) 1300ms both;
}

#landing-title::after {
  content: "";
  display: block;
  height: 1px;
  width: min(560px, 76%);
  margin: 22px auto 0;
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(143, 216, 242, 0.55),
    rgba(255, 255, 255, 0)
  );
  animation: line-draw 1200ms cubic-bezier(0.22, 0.61, 0.36, 1) 760ms both;
}

#enter-hint {
  margin-top: 28px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid rgba(120, 220, 255, 0.7);
  background: rgba(4, 20, 40, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 18px rgba(41, 182, 255, 0.45);
  color: #EAF8FF;
  font: 600 13px/1.2 var(--font-sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  animation: rise-in 900ms cubic-bezier(0.22, 0.61, 0.36, 1) 1100ms both, hint-pulse 2400ms ease-in-out 2000ms infinite;
}

#enter-hint:hover {
  background: rgba(255, 255, 255, 0.14);
}

#enter-hint:focus-visible {
  outline: 2px solid #8FD8F2;
  outline-offset: 3px;
}

#enter-hint[aria-busy="true"] {
  animation: none;
  opacity: 1;
  transform: none;
  cursor: progress;
}

/* Idle hint: kept in place for screen readers and focus, not drawn. */
#enter-hint.quiet {
  animation: none;
  opacity: 0;
  pointer-events: none;
  outline: none;
}

#landing-logos {
  position: relative;
  z-index: 2;
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 26px 16px 8px;
  animation: rise-in 900ms cubic-bezier(0.22, 0.61, 0.36, 1) 200ms both;
}

#landing-logos img {
  height: 52px;
  width: auto;
}

.lockup-bar {
  width: 2px;
  height: 40px;
  background: linear-gradient(#8FE6FF, #1E8BFF);
  box-shadow: 0 0 10px rgba(80, 200, 255, 0.9);
}

#landing-caption {
  position: fixed;
  left: 24px;
  bottom: 22px;
  z-index: 2;
  max-width: 60vw;
  margin: 0;
  padding-left: 12px;
  border-left: 2px solid #29B6FF;
  font: 600 19px/1.35 var(--font-sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  color: #BFEFFF;
  text-shadow: 0 0 10px rgba(41, 182, 255, 0.4);
  opacity: 0;
  transition: opacity 300ms;
}

#landing-caption.show {
  opacity: 1;
}

@media (max-width: 600px) {
  #landing-logos img {
    height: 36px;
  }

  .lockup-bar {
    height: 28px;
  }

  #landing-caption {
    bottom: 64px;
    left: 12px;
    max-width: 80vw;
    font-size: 14px;
  }
}

#morph-ph {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 45;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform, opacity;
  -webkit-mask: url(./assets/ph-outline.svg) 0 0 / 100% 100% no-repeat;
  mask: url(./assets/ph-outline.svg) 0 0 / 100% 100% no-repeat;
  background-image: var(--wave-crest), linear-gradient(180deg, #FFFFFF 0%, #FFFFFF var(--waterline), #8FD8F2 var(--waterline), #2E9BD6 100%);
  background-repeat: repeat-x, no-repeat;
}

#morph-ph[hidden] {
  display: none;
}

/* Hub: three wedges (Prevention, Planning, Life) split by seams from the centre disc. Geometry in contract.md section 3. */
#hub {
  position: fixed;
  inset: 0;
  z-index: 41;
  overflow: hidden;
  pointer-events: none;
  --hub-s: min(36vmin, 320px);
  color: #FFFFFF;
  font-family: var(--font-sans);
}

#hub[hidden] {
  display: none;
}

/* Only the panels and the Philippines outline take pointer events; the disc, seams and canvas must not swallow clicks. */
.hub-panel {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  outline: none;
}

#hub-prevention .hub-bg {
  left: 0;
  top: 0;
  width: 50%;
  height: calc(50% + 50vw * 0.57735);
  background-color: #14213D;
  background-image: url(./assets/landing/noah-preview.jpg);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/* The Planning clip covers the live map in its wedge's bounding box, mirroring Prevention's. */
#hub-planning .hub-bg {
  left: 50%;
  top: 0;
  width: 50%;
  height: calc(50% + 50vw * 0.57735);
}

/* Darken towards each title, over the clip or the still under it. */
#hub-prevention .hub-bg::after,
#hub-planning .hub-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(10, 14, 20, 0.9) 0%, rgba(10, 14, 20, 0.55) 55%, rgba(10, 14, 20, 0.3) 100%);
}

#hub-planning .hub-bg::after {
  background: linear-gradient(200deg, rgba(10, 14, 20, 0.9) 0%, rgba(10, 14, 20, 0.55) 55%, rgba(10, 14, 20, 0.3) 100%);
}

.hub-clip {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.8) brightness(0.85);
  transition: filter 400ms;
}

/* A clip waiting for its turn holds its frame, greyer and darker. */
.hub-clip.wait {
  filter: saturate(0.4) brightness(0.6);
}

/* The Life wedge is the lower half of the screen, so its clip fills only that half. */
#hub-life .hub-clip {
  top: 50%;
  height: 50%;
}

/* The Life page screenshot fills the whole screen behind the wedge, so the wedge can sweep open
   over it into the Life page (landing.js toLife). .hub-shade darkens it behind the title. */
#hub-life .hub-bg {
  inset: 0;
  background-color: #0E3D2A;
  background-image: url(./assets/landing/life-preview.jpg);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

#hub-life .hub-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(10, 14, 20, 0.88) 0%, rgba(10, 14, 20, 0.58) 22%, rgba(10, 14, 20, 0.24) 50%, rgba(10, 14, 20, 0) 60%);
}

/* No hover glow while the screenshot sweeps into the real page, or the page would look darker. */
body.morphing .hub-panel .hub-bg {
  filter: none;
}

.hub-bg {
  position: absolute;
  pointer-events: none;
  transition: filter 300ms;
}

.hub-panel:hover .hub-bg,
.hub-panel:focus-visible .hub-bg {
  filter: brightness(1.15);
}

#hub-planning::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.06);
  opacity: 0;
  transition: opacity 300ms;
}

#hub-planning:hover::before,
#hub-planning:focus-visible::before {
  opacity: 1;
}

/* clip-path clips outlines, so the focus ring is drawn on the title text. */
.hub-panel:focus-visible .hub-title {
  outline: 2px solid #8FD8F2;
  outline-offset: 6px;
  border-radius: 4px;
}

.hub-label {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(34vw, 420px);
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}

#hub-prevention .hub-label {
  left: 4vw;
  top: 6vh;
  align-items: flex-start;
  text-align: left;
}

#hub-planning .hub-label {
  right: 4vw;
  top: 6vh;
  align-items: flex-end;
  text-align: right;
}

/* translate, not transform: landing.js animates transform on labels. */
#hub-life .hub-label {
  left: 50%;
  bottom: 6vh;
  translate: -50% 0;
  align-items: center;
  text-align: center;
  max-width: 80vw;
}

.hub-title {
  font-weight: 700;
  font-size: clamp(18px, 2.4vw, 32px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.15;
}

.hub-sub {
  font-size: clamp(12px, 1.15vw, 16px);
  color: #D6ECFA;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

/* Each seam is a span hanging down from the centre, turned to its angle; landing.js grows it with the scale property. */
.hub-seam {
  position: absolute;
  left: calc(50% - 1px);
  top: 50%;
  z-index: 2;
  width: 2px;
  height: 80vmax;
  transform-origin: 50% 0;
  rotate: calc(var(--a) - 180deg);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(143, 216, 242, 0.95) 0%, rgba(143, 216, 242, 0.35) 45%, rgba(143, 216, 242, 0) 100%);
  box-shadow: 0 0 12px rgba(143, 216, 242, 0.55);
}

#hub-disc {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: calc(var(--hub-s) * 1.36);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, #173D96 0%, #14213D 62%, #0F1A33 100%);
  border: 1px solid rgba(143, 216, 242, 0.45);
  box-shadow: 0 0 0 6px rgba(20, 33, 61, 0.55), 0 0 48px rgba(46, 155, 214, 0.45), inset 0 0 32px rgba(0, 0, 0, 0.45);
}

#hub-gl {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#hub-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: var(--hub-s);
  height: auto;
  translate: -50% -50%;
  pointer-events: none;
}

#hub-logo[hidden] {
  display: none;
}

/* The outline's mask would hide its own focus ring, so the disc around it shows it. */
#hub:has(#hub-ph:focus-visible) #hub-disc {
  outline: 2px solid #8FD8F2;
  outline-offset: 3px;
}

/* Same look as the morph outline (#morph-ph); the font size makes its 0.14em crest match the title letter's proportions. */
#hub-ph {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  height: calc(var(--hub-s) * 0.46);
  aspect-ratio: 568.37 / 1000.0;
  translate: -50% -50%;
  margin: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
  pointer-events: auto;
  font-size: calc(var(--hub-s) * 0.46 / 1.42);
  --waterline: 58%;
  -webkit-mask: url(./assets/ph-outline.svg) center / contain no-repeat;
  mask: url(./assets/ph-outline.svg) center / contain no-repeat;
  background-image:
    var(--wave-crest),
    linear-gradient(
      180deg,
      #FFFFFF 0%,
      #FFFFFF var(--waterline),
      #8FD8F2 var(--waterline),
      #2E9BD6 100%
    );
  background-repeat: repeat-x, no-repeat;
  background-size: 220px 0.14em, 100% 100%;
  background-position: 0 var(--waterline), 0 0;
  filter: drop-shadow(0 6px 18px rgba(46, 155, 214, 0.45));
  animation: wave-run 3600ms linear infinite, flood-swell 7s ease-in-out infinite;
}

@media (max-width: 599px) {
  .hub-label {
    max-width: 42vw;
  }

  .hub-sub {
    display: none;
  }

  #hub-life .hub-sub {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lt-main,
  .lt-sub,
  .lt-tag,
  #landing-logos {
    animation: none;
  }

  #landing-gl {
    transition: none;
  }

  #hub-ph {
    animation: none;
  }

  .hub-panel::before,
  #hub-planning::before,
  .hub-bg {
    transition: none;
  }
}

body.view-landing #map .maplibregl-canvas { opacity: 0; }
body.view-landing .map-ui,
body.view-landing #legend,
body.view-landing #tooltip,
body.view-landing #panel,
body.view-landing #chart-fs,
body.view-landing #sv-card,
body.view-landing #loading,
body.view-landing #map .maplibregl-control-container { visibility: hidden; opacity: 0; pointer-events: none; }
body.view-hub > :not(#map, #hub) { visibility: hidden; pointer-events: none; }
/* No MapLibre credit or buttons show over the hub wedges. */
body.view-hub .maplibregl-control-container { visibility: hidden; }
body.view-hub #map > :not(.maplibregl-canvas-container) { visibility: hidden; }
body.view-hub #map { pointer-events: none; }
body.view-map #landing { opacity: 0; visibility: hidden; pointer-events: none; }
body.morphing #landing,
body.morphing #map,
body.morphing .map-ui,
body.morphing #legend { pointer-events: none; }

@media (max-height: 560px) {
  #hero {
    margin-top: 0;
  }
}

/* HUD: decorative flight overlay drawn over the 3D scene. Hidden until the scene is ready; pointer-events off so it never blocks the page. */
#hud {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

#landing:not(.gl-ready) #hud {
  visibility: hidden;
}

.hud-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(120, 220, 255, 0.55);
  border-style: solid;
  border-width: 0;
}

.hud-tl {
  top: 14px;
  left: 14px;
  border-top-width: 2px;
  border-left-width: 2px;
}

.hud-tr {
  top: 14px;
  right: 14px;
  border-top-width: 2px;
  border-right-width: 2px;
}

.hud-bl {
  bottom: 14px;
  left: 14px;
  border-bottom-width: 2px;
  border-left-width: 2px;
}

.hud-br {
  bottom: 14px;
  right: 14px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

#hud-readout {
  position: absolute;
  top: 22px;
  left: 26px;
  font-weight: 600;
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.12em;
  color: #9FE6FF;
  text-shadow: 0 0 8px rgba(41, 182, 255, 0.35);
  font-variant-numeric: tabular-nums;
}

#hud-readout span {
  display: block;
}

#hud-compass {
  position: absolute;
  top: 22px;
  right: 26px;
  width: 220px;
  height: 46px;
  overflow: hidden;
}

#hud-heading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #9FE6FF;
  text-shadow: 0 0 8px rgba(41, 182, 255, 0.35);
}

#hud-compass-tape {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 30px;
  width: 1440px;
  border-bottom: 1px solid rgba(120, 220, 255, 0.35);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}

.hud-tick {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 6px;
  background: rgba(160, 230, 255, 0.6);
}

.hud-tick.major {
  height: 12px;
}

.hud-tick b {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 600;
  font-size: 10px;
  color: #BFEFFF;
  white-space: nowrap;
}

/* Centre caret: a down-pointing triangle at the bottom centre of the compass. */
#hud-compass::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #29B6FF;
}

/* landing.js moves #hud-card with transform; it fades in with the show class. */
#hud-card {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 420px;
  padding: 16px 18px;
  background: rgba(4, 20, 40, 0.58);
  border: 1px solid rgba(120, 220, 255, 0.45);
  border-left: 3px solid #29B6FF;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 24px rgba(41, 182, 255, 0.25);
  color: #EAF8FF;
  font: 17px/1.45 var(--font-sans);
  text-align: left;
  opacity: 0;
  /* Fades out slowly as the camera leaves a stop; fades in faster on arrival. */
  transition: opacity 1000ms;
}

#hud-card.show {
  opacity: 1;
  transition: opacity 500ms;
}

#hud-card-title {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #BFEFFF;
}

#hud-card-lines {
  margin: 0;
  padding: 0;
  list-style: none;
}

#hud-card-lines li {
  margin: 3px 0;
  padding-left: 16px;
  position: relative;
}

#hud-card-lines li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 7px;
  height: 1px;
  background: #29B6FF;
}

#hud-card-source {
  margin: 8px 0 0;
  font-size: 13px;
  color: rgba(190, 230, 255, 0.6);
}

/* Water level row in the card: a label, a large readout, and a bar that fills as the water rises. */
#hud-card-level {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 2px 10px;
  margin: 10px 0 0;
}

#hud-card-level[hidden] {
  display: none;
}

.hud-level-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8FE6FF;
}

.hud-level-text {
  font-size: 22px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #EAF8FF;
}

.hud-level-bar {
  grid-column: 1 / -1;
  height: 4px;
  background: rgba(120, 220, 255, 0.18);
  overflow: hidden;
}

.hud-level-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1E8BFF, #8FE6FF);
  transform-origin: left;
  transform: scaleX(0);
}

/* Leader line from a city to its card; the SVG is sized to #hud and drawn in its own coordinates. */
#hud-leader {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: 0;
  transition: opacity 1000ms;
}

#hud-leader.show {
  opacity: 1;
  transition: opacity 500ms;
}

#hud-leader polyline {
  fill: none;
  stroke: rgba(120, 220, 255, 0.8);
  stroke-width: 1.2;
}

#hud-leader circle {
  fill: #29B6FF;
}

@media (max-width: 600px) {
  #hud-readout,
  #hud-compass {
    display: none;
  }

  #hud-card {
    max-width: 260px;
    font-size: 13px;
  }

  #hud-card-title {
    font-size: 15px;
  }

  .hud-corner {
    width: 18px;
    height: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #hud-card,
  #hud-card.show,
  #hud-leader,
  #hud-leader.show {
    transition: none;
  }
}
