@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #f2f6ff;
  --ink-soft: #a9b6d3;
  --ink-faint: #6f7d9c;
  --glass: rgba(9, 14, 28, 0.62);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #7fd0ff;
  --warm: #ffc857;
  --panel-w: 372px;
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }

body {
  overflow: hidden;
  background: #02030a;
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  opacity: 0;
  /* out of the dark after the opening film: smoothstep in seen brightness (opacity = smoothstep^2.2), no jump at the start */
  transition: opacity 5s linear(0, 0, 0.001, 0.007, 0.032, 0.097, 0.218, 0.392, 0.596, 0.786, 0.924, 0.989, 1);
}
#scene.dragging { cursor: grabbing; }
#scene.pointing { cursor: pointer; }
body.ready #scene { opacity: 1; }

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

/* Header */
.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 22px 28px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
/* the header and the counter show with the planet, not over the opening film */
.top, .count { opacity: 0; transition: opacity 2s ease 1s; }
body.ready .top, body.ready .count { opacity: 1; }
body:not(.ready) .top > * { pointer-events: none; }

.sound {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink-soft);
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.8));
  cursor: pointer;
}
.sound[hidden] { display: none; }
.sound svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound .cone { fill: currentColor; }
.sound .cross, .sound.off .waves { display: none; }
.sound.off .cross { display: inline; }
.sound:hover { color: var(--ink); }
.sound:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.picker { position: relative; }
.picker > button {
  padding: 10px 34px 10px 14px;
  border: 0;
  border-radius: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a9b6d3' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 14px center / 11px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}
.picker button:focus-visible, .close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* the list: frosted glass that lets the globe show through */
.cities {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 12px 32px rgba(0, 0, 0, 0.35);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.cities[hidden] { display: none; }
.cities button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.cities button:hover { background: rgba(255, 255, 255, 0.12); }
.cities button[aria-selected="true"] { color: var(--accent); }

/* Marker tag */
.tag {
  position: fixed;
  left: 0;
  top: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(var(--x, 0px), var(--y, 0px)) translate(-50%, -150%);
}
.tag b { margin-left: 8px; color: var(--accent); font-weight: 650; }
/* at the Sun: a white label beside the Earth's speck */
.home {
  position: fixed;
  left: 0;
  top: 0;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.85);
  cursor: pointer;
  transform: translate(var(--x, 0px), var(--y, 0px)) translate(calc(var(--r, 0px) + 8px), -50%);
  /* the Sun's disc and the nearer body's disc cut out of the label: it goes behind them as its body does */
  -webkit-mask-image: radial-gradient(circle at var(--sx, -9999px) var(--sy, -9999px), #00000000 var(--sr, 0px), #000000 calc(var(--sr, 0px) + 1px)),
    radial-gradient(circle at var(--ex, -9999px) var(--ey, -9999px), #00000000 var(--er, 0px), #000000 calc(var(--er, 0px) + 1px));
  -webkit-mask-composite: source-in;
  mask-image: radial-gradient(circle at var(--sx, -9999px) var(--sy, -9999px), #00000000 var(--sr, 0px), #000000 calc(var(--sr, 0px) + 1px)),
    radial-gradient(circle at var(--ex, -9999px) var(--ey, -9999px), #00000000 var(--er, 0px), #000000 calc(var(--er, 0px) + 1px));
  mask-composite: intersect;
}
.home[hidden] { display: none; }
.home { transition: opacity 2s ease-in-out; }
@starting-style { .home { opacity: 0; } } /* each time it is shown it comes up out of nothing */
.home:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ISS: broadcast window */
.live[hidden] { display: none; }

.live {
  position: fixed;
  left: 0;
  top: 0;
  width: min(400px, calc(100% - 24px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  transform: translate(var(--x, 0px), var(--y, 0px));
}
.stream {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: #000000;
  color: var(--ink-faint);
  font-size: 13px;
}
.stream iframe { width: 100%; height: 100%; border: 0; }

/* City panel */
.panel {
  position: fixed;
  top: 92px;
  right: 28px;
  width: var(--panel-w);
  max-height: calc(100% - 140px);
  overflow-y: auto;
  padding: 26px 26px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.panel[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}
.close:hover { background: rgba(255, 255, 255, 0.1); }
.close svg { width: 100%; height: 100%; fill: none; stroke: #f2f6ff; stroke-width: 2; stroke-linecap: round; }

.place { display: flex; align-items: center; gap: 16px; padding-right: 36px; }
.landmark {
  flex: none;
  width: 72px;
  height: 72px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(127, 208, 255, 0.07);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--accent);
}
.place h2 { font-size: 25px; font-weight: 650; line-height: 1.15; letter-spacing: -0.01em; }
.place p { margin-top: 4px; font-size: 13px; color: var(--ink-soft); }

.now { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.temp { font-size: 84px; font-weight: 250; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.now .wx { width: 92px; height: 92px; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35)); }
.cond { margin-top: 2px; font-size: 16px; color: var(--ink-soft); }

.range { display: flex; gap: 10px; margin-top: 16px; }
.range div {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.range dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); }
.range dd { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }

.panel h3 {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}
.days { margin-top: 6px; padding: 0; list-style: none; }
.days li {
  display: grid;
  grid-template-columns: 44px 30px 34px 1fr 34px;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-variant-numeric: tabular-nums;
}
.days .wx { width: 28px; height: 28px; }
.days .lo { color: var(--ink-soft); text-align: right; }
.days .hi { font-weight: 600; text-align: right; }
.days .bar { position: relative; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.09); }
.days .bar i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--from);
  width: var(--span);
  border-radius: 3px;
  background: linear-gradient(90deg, #5aa9ff, #ffc857);
}

/* Footer figure */
.count {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

/* Loading and fallback */
.loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity 0.8s ease;
}
body.ready .loader { opacity: 0; pointer-events: none; }
/* the opening film: in from the dark and back into it */
.intro {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--fade, 3s) ease-in-out; /* --fade: half the film each way, set from app.js */
  pointer-events: none;
}
/* never quite 1: at full opacity Chrome on a Mac shows the HDR film in true HDR, brighter, for the moment between fading in and
   fading out (a flash at 5-6 s); below 1 it is drawn the ordinary way, as through the rest of the film */
.intro.on { opacity: 0.99; }
.nogl {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(420px, 80%);
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--ink-soft);
}
body.open .nogl { display: none; }

@media (max-width: 760px) {
  .top { padding: 14px 16px; }
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 62%;
    padding: 20px 20px 16px;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
  }
  .landmark { width: 56px; height: 56px; padding: 6px; }
  .place h2 { font-size: 21px; }
  .temp { font-size: 64px; }
  .now { margin-top: 12px; }
  .now .wx { width: 68px; height: 68px; }
  body.open .count { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
  #scene, .loader { transition: none; }
}
/* the body off screen: only an arrow at the edge pointing to it */
.home.off {
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 0;
  transform: translate(var(--x, 0px), var(--y, 0px)) translate(-50%, -50%) rotate(var(--a, 0rad));
  -webkit-mask-image: none;
  mask-image: none;
}
.home.off::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-left: 11px solid #ffffff;
  border-top: 7px solid #ffffff00;
  border-bottom: 7px solid #ffffff00;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.85));
}
.home.faded { opacity: 0; pointer-events: none; } /* the body too large on screen, or the name not all on it: fades out (2 s, as it comes in) */
