/* Archivo (SIL OFL 1.1, see /fonts/OFL.txt), self-hosted latin subset */
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 500;
  font-stretch: 100% 125%;
  font-display: swap;
  src: url(/fonts/archivo-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Every scene colour is a custom property; js/scene.js rewrites them for the
   current sun altitude. These defaults are the night scene. */
:root {
  --sky-top: #04060B;
  --sky-low: #121827;
  --horizon: #1A1E2A;
  --glow: #B9824A;
  --glow-a: 0.18;
  --far: #151B29;
  --near: #07090F;
  --lit: #07090F;
  --water: #05070C;
  --lights: #F1C98A;
  --ink: #FFFFFF;
  --ink-top: #FFFFFF;
  --dark: 1;
  --win-a: 0.75;

  --city-h: max(44svh, 26vw);
  --water-h: max(4.5svh, 24px);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

.stage {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  touch-action: pan-y pinch-zoom; /* horizontal drags scrub the day; zoom stays available */
  cursor: default;
}
.stage.scrubbing { cursor: ew-resize; }

/* Wait for js/main.js to paint the right scene before the intro plays */
.booting .stage * { animation-play-state: paused !important; }

.sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
    var(--sky-top) 0%, var(--sky-top) 25%, var(--sky-low) 75%, var(--horizon) 100%);
  animation: fade 900ms ease-out both;
}

/* City light pollution by night, heat bloom by day */
.haze {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: 0;
  height: 75%;
  background: radial-gradient(50% 55% at 50% 100%,
    color-mix(in oklab, var(--glow) calc(var(--glow-a) * 100%), transparent), transparent 100%);
  animation: fade 1400ms 300ms ease-out both, breathe 8s 1.7s ease-in-out infinite alternate;
}

.sun, .moon, .plane {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.sun {
  --sun-size: 24px;
  --sun-core: #FFF7E0;
  --sun-halo: #FFE9B8;
  width: var(--sun-size);
  height: var(--sun-size);
  margin: calc(var(--sun-size) / -2) 0 0 calc(var(--sun-size) / -2);
  border-radius: 50%;
  background: radial-gradient(circle, var(--sun-core) 0 34%,
    color-mix(in oklab, var(--sun-halo) 45%, transparent) 38%, transparent 70%);
  animation: fade 1200ms 400ms ease-out both;
}

.moon {
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  overflow: visible;
}
.moon-dark { fill: #C9CED8; opacity: 0.07; }
.moon-lit { fill: #F2EEE3; }

.city {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--water-h);
  height: var(--city-h);
}

.city svg, .reflection {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}

.far {
  fill: var(--far);
  animation: rise 1400ms 200ms var(--ease-out) both;
  transition: opacity 1.2s ease;
}
.heat .far { filter: url(#shimmer); }

.near { animation: reveal 1400ms 350ms var(--ease-in-out) both; }
.stop-lit { stop-color: var(--lit); }
.stop-near { stop-color: var(--near); }

.win {
  fill: var(--lights);
  opacity: 0;
  transition: opacity 1200ms ease;
}
.win.on { opacity: var(--win-a); }
.far-win.on { opacity: calc(var(--win-a) * 0.5); }
.scrubbing .win { transition-duration: 150ms; }

.beacon-wrap { opacity: var(--dark); }
.beacon {
  fill: #fff;
  opacity: 0;
  animation: blink 1.5s 2s steps(1, end) infinite;
}

/* Aviation obstruction lights: red, only once it's dark. LED lights switch
   hard on and off, so the flash is stepped (which also keeps repaints rare) */
.aviation { opacity: var(--dark); fill: #FF2B1C; }
.av-halo { opacity: 0.28; }
.av-steady { opacity: 0.8; }
.av-flash {
  opacity: 0.08;
  animation: av-flash 1.8s calc(var(--p) * -0.6s) steps(1, end) infinite;
}
@keyframes av-flash {
  0% { opacity: 1; }
  28% { opacity: 0.08; }
}

/* Landmarks after dark: each glow is its own small layer over the landmark,
   so their slow animations never repaint the skyline */
.landmarks { position: absolute; inset: 0; pointer-events: none; }
.lm { position: absolute; left: 0; top: 0; overflow: visible; }
.lm-frame { opacity: calc(var(--dark) * 0.75); }
.lm-museum { opacity: calc(var(--dark) * 0.5); }
.lm-sails { opacity: calc(var(--dark) * 0.38); }
.lm-sail { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.lm-sail-blue { animation: sail-cycle 24s 0s ease-in-out infinite; }
.lm-sail-violet { animation: sail-cycle 24s -16s ease-in-out infinite; }
.lm-sail-teal { animation: sail-cycle 24s -8s ease-in-out infinite; }
/* Each colour holds for a while, then hands over to the next */
@keyframes sail-cycle {
  0%, 25% { opacity: 1; }
  33.3%, 91.7% { opacity: 0; }
  100% { opacity: 1; }
}

/* Flamingos at dawn */
.flamingos { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.flock { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity 400ms ease; }
.flock.on { opacity: 1; }
.bird {
  position: absolute;
  width: 28px;
  height: 14px;
  animation: bob 3.2s var(--d, 0s) ease-in-out infinite alternate;
}
.bird svg { display: block; width: 100%; height: 100%; overflow: visible; fill: #F3A1AF; }
.fl-line { fill: none; stroke: #F3A1AF; stroke-width: 1.15; stroke-linecap: round; }
.fl-beak { fill: none; stroke: #000; stroke-width: 0.9; stroke-linecap: round; }
.fl-tip { fill: #000; }
.fl-wing {
  transform-box: view-box;
  transform-origin: 12px 7px;
  animation: wingbeat 0.55s var(--d, 0s) ease-in-out infinite alternate;
}
@keyframes wingbeat { to { transform: scaleY(-0.85); } }
@keyframes bob { to { transform: translateY(3px); } }

/* Dubai Metro: concrete viaduct and five-car trains */
.viaduct { fill: color-mix(in oklab, var(--near) 72%, var(--lit)); }
.metro {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  pointer-events: none;
}
.train {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--train-w);
  height: var(--train-h);
  opacity: 0;
  transition: opacity 300ms ease;
}
.train.on { opacity: 1; }
.train-body, .train-windows {
  position: absolute;
  inset: 0;
  border-radius: 1px;
}
.train-body { background: color-mix(in oklab, #D7DBDF calc((1 - var(--dark)) * 100%), #2A2F38); }
/* Five lit cars at night, with the couplings dark between them */
.train-windows {
  inset: 25% 2%;
  opacity: var(--dark);
  background: repeating-linear-gradient(to right, #FFE6B0 0 18.6%, transparent 18.6% 20%);
}
.train-east .train-body { border-radius: 1px 3px 3px 1px; }
.train-west .train-body { border-radius: 3px 1px 1px 3px; }

/* Sheikh Zayed Road: two lanes of masked, looping car strips */
.road {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
  pointer-events: none;
}
.lane {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
}
.lane-away { top: 8%; --car: color-mix(in oklab, #FF3B2F calc(var(--dark) * 100%), #4A4E55); }
.lane-toward { bottom: 4%; --car: color-mix(in oklab, #FFF0CF calc(var(--dark) * 100%), #C9CDD2); }
.cars {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% + 600px);
  height: 2px;
  background: var(--car);
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
  -webkit-mask-size: 600px 2px;
  mask-size: 600px 2px;
  opacity: 0;
  transition: opacity 2s ease;
}

/* Dubai Fountain: jets are bottom-anchored columns that scale and sway */
.fountain {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 50% 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms var(--ease-out);
}
.fountain.on { opacity: calc(0.75 + var(--dark) * 0.25); }
.fountain-reflection.on { opacity: 0.3; }
.jet {
  position: absolute;
  bottom: 0;
  width: var(--jet-w, 1.5px);
  height: 100%;
  margin-left: calc(var(--jet-w, 1.5px) / -2);
  transform-origin: 50% 100%;
  transform: scaleY(0.04);
  background: linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.75) 50%, rgba(255, 255, 255, 0));
  border-radius: 1px;
}
/* Spray around each column, wider towards the top */
.jet b {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: calc(var(--jet-w, 1.5px) * 6);
  height: 100%;
  transform: translateX(-50%);
  background: radial-gradient(50% 30% at 50% 22%, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0)),
    linear-gradient(to top, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.18) 65%, rgba(255, 255, 255, 0));
  border-radius: 50% 50% 0 0;
}
.mist {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -6%;
  height: 45%;
  background: radial-gradient(50% 60% at 50% 100%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
  opacity: 0;
}

/* Burj facade: national day flag and the light show */
.flag { opacity: 0; transition: opacity 1.5s ease; }
.national .flag { opacity: calc(0.35 + var(--dark) * 0.5); }
.show > * { opacity: 0; }

.water {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--water-h);
  overflow: hidden;
  background: linear-gradient(to bottom,
    color-mix(in oklab, var(--horizon) 35%, var(--water)) 0, var(--water) 1px, var(--water));
  animation: fade 1200ms 300ms ease-out both;
}

.reflection {
  top: calc(-1 * var(--city-h));
  height: var(--city-h);
  transform-origin: 50% 100%;
  transform: scaleY(-0.4);
  opacity: 0.22;
  -webkit-mask-image: linear-gradient(to top, #000, transparent 30%);
  mask-image: linear-gradient(to top, #000, transparent 30%);
  animation: ripple 5s ease-in-out infinite alternate;
}
.rain-on .reflection { opacity: 0.38; }

.abra {
  position: absolute;
  left: 0;
  top: 32%;
  width: 16px;
  height: 8px;
  opacity: 0;
}
.abra svg { display: block; width: 100%; height: 100%; fill: color-mix(in oklab, var(--near) 80%, #000); }
.lantern {
  position: absolute;
  left: 7px;
  top: 2px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--lights);
  opacity: var(--dark);
}

.plane { opacity: 0; }
.plane-body { position: absolute; left: 0; top: 0; }
.fuselage {
  position: absolute;
  left: -1.5px;
  top: -1px;
  width: 3px;
  height: 2px;
  border-radius: 1px;
  background: color-mix(in oklab, var(--near) 85%, #000);
  opacity: calc(1 - var(--dark));
}
.contrail {
  position: absolute;
  left: 2px;
  top: -0.5px;
  width: 90px;
  height: 1px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.85), transparent);
  opacity: calc((1 - var(--dark)) * 0.7);
}
.strobe {
  position: absolute;
  width: 2px;
  height: 2px;
  margin: -1px 0 0 -1px;
  border-radius: 50%;
  opacity: 0;
}
.strobe-white { background: #fff; animation: strobe 1.3s steps(1, end) infinite; }
.strobe-red { left: 4px; background: #FF4A3D; animation: strobe 1s 0.4s steps(1, end) infinite; }
.plane .strobe { --peak: var(--dark); }

/* Weather */
.fog, .sand, .rain, .fireworks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.fog { opacity: 0; transition: opacity 2s ease; }
.fog-on .fog { opacity: 1; }
.fog i {
  position: absolute;
  left: -30%;
  width: 160%;
  bottom: 0;
  height: calc(var(--water-h) + var(--city-h) * 0.55);
  background: linear-gradient(to top,
    color-mix(in oklab, var(--horizon) 70%, #fff) 0%,
    color-mix(in oklab, var(--horizon) 70%, #fff) 30%, transparent);
  opacity: 0.75;
  animation: drift 40s ease-in-out infinite alternate;
}
.fog i + i {
  height: calc(var(--water-h) + var(--city-h) * 0.35);
  opacity: 0.6;
  animation-duration: 27s;
  animation-direction: alternate-reverse;
}

.sand {
  opacity: 0;
  transition: opacity 2s ease;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.85 0 0 0 0 0.66 0 0 0 0 0.4 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(to bottom, rgba(196, 150, 92, 0.25), rgba(196, 150, 92, 0.5));
  animation: grain 1.6s steps(4) infinite;
}
.sand-on .sand { opacity: 1; }
.sand-on .far { opacity: 0.25; }

.rain { opacity: 0; transition: opacity 1.5s ease; }
.rain-on .rain { opacity: 1; }

/* Wordmark */
.mark {
  position: absolute;
  left: 50%;
  top: 37%;
  width: clamp(220px, 64vw, 560px);
  transform: translate(-50%, -50%);
  color: var(--ink);
  transition: color 1.2s ease;
  pointer-events: none;
}
.mark svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}
/* Write-on: trace each glyph's outline, then ink it in and let the line go */
.mark path {
  fill: currentColor;
  fill-opacity: 0;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation:
    draw 1400ms var(--ease-in-out) calc(700ms + var(--i) * 90ms) both,
    ink 700ms var(--ease-out) calc(1750ms + var(--i) * 90ms) both;
}

/* Clock */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: max(20px, env(safe-area-inset-top));
  padding: 0 max(clamp(16px, 4vw, 40px), env(safe-area-inset-right)) 0 max(clamp(16px, 4vw, 40px), env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  color: var(--ink-top);
  transition: color 1.2s ease;
  font-family: Archivo, system-ui, sans-serif;
  font-stretch: 112%;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  animation: fade 900ms 2200ms ease-out both;
}
.hud p { margin: 0; }
.hud-clock { text-align: right; }
.hud-weather {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 21px; /* one line of .hud-time, so both sit on the same row */
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 600ms var(--ease-out);
}
.hud-weather.is-live { opacity: 1; }
.line-icon { width: 15px; height: 15px; stroke-width: 2; }
.wx {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hud-time {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.colon { animation: colon 1s steps(1, end) infinite; }
.hud-line {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  min-height: 1.4em;
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

/* Burj Khalifa hit area: invisible, but reachable by keyboard */
.burj {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.burj:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
  border-radius: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@keyframes fade { from { opacity: 0; } }
@keyframes breathe { from { opacity: 0.85; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6%); } }
@keyframes reveal { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes ink { to { fill-opacity: 1; stroke-opacity: 0; } }
@keyframes blink { 0% { opacity: 0.95; } 8% { opacity: 0; } }
@keyframes strobe { 0% { opacity: var(--peak, 1); } 10% { opacity: 0; } }
@keyframes colon { 0% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes ripple {
  from { transform: scaleY(-0.4) translateX(-0.6px); }
  to { transform: scaleY(-0.41) translateX(0.6px); }
}
@keyframes drift { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
@keyframes grain {
  0% { background-position: 0 0, 0 0; }
  25% { background-position: -40px 20px, 0 0; }
  50% { background-position: 30px -50px, 0 0; }
  75% { background-position: -20px 60px, 0 0; }
}

/* Landscape phones: logo higher and smaller */
@media (orientation: landscape) and (max-height: 500px) {
  .mark { top: 31%; width: clamp(200px, 40vw, 420px); }
  .hud { top: max(10px, env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  .sky, .haze, .sun, .far, .near, .water, .hud, .mark path {
    animation: fade 400ms ease-out both;
  }
  .mark path { fill-opacity: 1; stroke: none; }
  .beacon { animation: none; opacity: 0.9; }
  .av-flash { animation: none; opacity: 0.85; }
  .flamingos { display: none; }
  .lm-sail { animation: none; }
  .lm-sail-blue { opacity: 1; }
  .colon, .reflection, .fog i, .sand, .strobe { animation: none; }
  .win { transition: none; }
}
