/* Earth Jukebox. Black, one scope. Two colours with one job each: grey-white is
   the Earth and the controls, yellow is the data (NASA draws its flashes yellow). */
:root {
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --body: 'Schibsted Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --ink: #eef1f5;      /* text and outlines; set from config.js at load */
  --accent: #ffd84a;   /* sliders: the colour of the data */
  --glow: #ffbe00;
  --dim: rgb(255 255 255 / 0.62);
  --line: rgb(238 241 245 / 0.5);
  --bg: #000;
  color-scheme: dark;
}
/* dark in both system themes: it is a scope */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #000; } }
:root[data-theme="dark"] { --bg: #000; }

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: #fff; font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
}
::selection { background: var(--ink); color: #000; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#scope { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; z-index: 1; pointer-events: none; }

header { position: fixed; inset: 0 0 auto 0; z-index: 2; padding: max(16px, env(safe-area-inset-top)) 16px 0; pointer-events: none; }
header .bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
header button, header a { pointer-events: auto; }
h1 { font-weight: inherit; }
.label { font: 600 11px var(--body); text-transform: uppercase; letter-spacing: 0.12em; color: var(--dim); background: none; border: 0; padding: 0; min-height: 44px; cursor: pointer; white-space: nowrap; }
.in-world .label { font-size: 0; }
.in-world .label::before { content: "\2190\00a0 Menu"; font-size: 12px; }
@media (hover: hover) { .label:hover { color: var(--ink); } }
header nav { display: flex; gap: 8px; }
.tabs { margin-top: 2px; gap: 6px 18px; flex-wrap: wrap; }
.tab { font: 800 clamp(20px, 2.6vw, 30px)/1.1 var(--display); letter-spacing: 0.02em; text-transform: uppercase; color: rgb(255 255 255 / 0.45);
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 0 4px; min-height: 36px; cursor: pointer; }
.tab[aria-current="true"] { color: #fff; border-bottom-color: var(--accent); }
@media (hover: hover) { .tab:hover { color: #fff; } }
.start { position: fixed; z-index: 6; left: 50%; bottom: max(9vh, 44px); transform: translateX(-50%); cursor: pointer; white-space: nowrap;
  background: #000; border: 1px solid var(--accent); box-shadow: 0 0 0 4px #000, 0 0 22px rgb(255 190 0 / 0.25);
  font: 800 22px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); padding: 14px 22px; animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { color: rgb(255 216 74 / 0.35); } }
@media (prefers-reduced-motion: reduce) { .start { animation: none; } }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 16px;
  border: 1px solid var(--line); color: var(--ink); background: rgb(0 0 0 / 0.5);
  font: 500 13px var(--body); text-transform: uppercase; letter-spacing: 0.08em; text-decoration: none; cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.btn:active, .btn[aria-pressed="true"] { background: var(--ink); color: #000; }
@media (hover: hover) { .btn:hover { background: var(--ink); color: #000; box-shadow: 0 0 24px rgb(255 255 255 / 0.25); } }
.btn:disabled { opacity: 0.5; cursor: progress; }

.player {
  position: fixed; inset: auto 0 0 0; z-index: 2; display: grid; gap: 10px; justify-items: center;
  padding: 0 16px max(18px, env(safe-area-inset-bottom));
}
.globe { position: fixed; inset: 104px 0 96px 0; touch-action: none; cursor: grab; }
.globe:active { cursor: grabbing; }
.globe:focus-visible { outline: none; }   /* the scope draws a heavier rim instead */
.rows { width: min(760px, 100%); display: grid; gap: 2px; position: relative; }
.row { display: grid; grid-template-columns: 124px 1fr; align-items: center; gap: 12px; min-height: 40px; }
.value { font: 800 22px/1 var(--display); letter-spacing: 0.02em; text-transform: uppercase; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 40px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--line); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 3px; height: 22px; margin-top: -11px; background: var(--accent); box-shadow: 0 0 10px var(--glow); border-radius: 0; }
input[type="range"]::-moz-range-thumb { width: 3px; height: 22px; background: var(--accent); box-shadow: 0 0 10px var(--glow); border: 0; border-radius: 0; }

.download { position: relative; }
.download[hidden] { display: none; }
.status { position: fixed; inset: auto 0 4px 0; z-index: 3; font-size: 13px; color: var(--dim); text-align: center; }
.status:empty { display: none; }

[hidden] { display: none !important; }

/* NASA's own frame, beside ours */
.frame { position: fixed; z-index: 3; left: 16px; bottom: 156px; width: min(30vw, 440px); margin: 0; border: 1px solid var(--line); background: #000; }
.frame button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.frame video { display: block; width: 100%; height: auto; }
/* enlarged: the picture fills the window, over everything */
.frame.big { inset: 0 !important; width: auto !important; height: auto !important; transform: none !important; z-index: 9; border: 0; display: grid; place-items: center; background: rgb(0 0 0 / 0.94); }
.frame.big button { cursor: zoom-out; width: min(96vw, 190vh); }
.frame.big figcaption { display: block !important; left: 16px; bottom: auto; top: 14px; }
.frame figcaption { position: absolute; left: 0; bottom: 100%; padding: 0 0 4px; font: 600 11px var(--body); letter-spacing: 0.1em; text-transform: uppercase; }
.frame a { color: var(--dim); text-decoration: none; }
@media (max-width: 900px) { .frame { left: 50%; transform: translateX(-50%); top: 112px; bottom: auto; width: var(--fw, 62vw); height: calc(var(--fw, 62vw) / 2); display: grid; align-items: center; } .frame figcaption { display: none; } }

/* The 3D scene (machine, menu, flights) and the worlds to choose in it */
#scene { position: fixed; inset: 0; width: 100vw; height: 100dvh; z-index: 0; display: block; pointer-events: none; }
.hub { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.world { position: absolute; left: 0; top: 0; border-radius: 50%; background: none; border: 0; padding: 0; color: #fff; cursor: pointer; pointer-events: auto; }
.world:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
/* in the menu the sign on the machine carries the name */
.in-menu h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.in-menu header .bar { justify-content: flex-end; }

dialog {
  margin: auto; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px;
  background: #050505; color: #fff; border: 1px solid rgb(225 255 236 / 0.25);
}
dialog::backdrop { background: rgb(0 0 0 / 0.75); }
dialog p { margin-bottom: 12px; color: rgb(255 255 255 / 0.85); }
dialog a { color: var(--ink); }
.close { float: right; margin: 0 0 8px 12px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 16px 0; padding: 12px 0; border-block: 1px solid rgb(255 255 255 / 0.14); }
.keys dt { color: var(--ink); font-weight: 600; }
.keys dd { color: rgb(255 255 255 / 0.85); }
.fine { font-size: 13px; color: var(--dim); }

@media (max-width: 520px) {
  header nav { gap: 6px; }
  header nav .btn { padding: 9px 9px; font-size: 12px; letter-spacing: 0.05em; }
  .row { grid-template-columns: 104px 1fr; }
  .value { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }
