/* Layout of the Space: dark theme, a globe filling the page, a notice bar
   that is always visible, controls at the bottom and a legend. */

:root {
  --bg: #0b1020;
  --panel: rgba(16, 22, 40, 0.86);
  --line: rgba(255, 255, 255, 0.18);
  --text: #e8ecf5;
  --muted: #a9b2c7;
  --accent: #6aa6ff;
  --warn: #ffd479;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

button, select, input { font: inherit; color: inherit; }

button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}
button:hover { background: rgba(255, 255, 255, 0.16); }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

select {
  background: #121a30;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  max-width: 100%;
}

/* Notice: never hidden, only shortened to its first sentence. */
#notice-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.8rem;
  padding: 0.4rem 0.8rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#notice { margin: 0; font-weight: 600; color: var(--warn); }
#notice-more {
  flex: 1 1 24rem;
  color: var(--muted);
  font-size: 12px;
}
#notice-more p { margin: 0; }
#notice-bar.compact #notice-more { display: none; }
#credits-open { margin-left: auto; }

main {
  position: fixed;
  inset: 0;
}
#globe {
  position: absolute;
  inset: 0;
}

#status {
  position: absolute;
  top: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  background: var(--panel);
  max-width: 90%;
  z-index: 5;
}
#status:empty { display: none; }
#status.error { color: #ff9a9a; border: 1px solid #ff9a9a; }

#controls {
  position: absolute;
  left: 0.8rem;
  bottom: 3rem;
  z-index: 5;
  width: min(34rem, calc(100% - 1.6rem));
  padding: 0.6rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
#player {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
#slider { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); }
#valid { white-space: nowrap; font-variant-numeric: tabular-nums; }
#pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}
#pickers label { display: flex; align-items: center; gap: 0.4rem; }
#sheet-toggle { display: none; }

#legend {
  position: absolute;
  right: 0.8rem;
  bottom: 3rem;
  z-index: 5;
  width: 15rem;
  padding: 0.6rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}
#legend:empty { display: none; }
#legend .title { font-weight: 600; margin-bottom: 0.3rem; }
#legend canvas { display: block; width: 100%; height: 14px; border-radius: 3px; }
#legend .ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.2rem;
  color: var(--muted);
}
#legend .swatches { display: grid; gap: 0.15rem; }
#legend .swatch { display: flex; align-items: center; gap: 0.4rem; }
#legend .chip {
  width: 1.4rem;
  height: 0.8rem;
  border-radius: 2px;
  border: 1px solid var(--line);
}
#legend .note { margin-top: 0.3rem; color: var(--muted); }

footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 0.3rem 0.8rem;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
#version { margin: 0; overflow-wrap: anywhere; }

dialog {
  max-width: min(40rem, calc(100% - 2rem));
  max-height: 80vh;
  overflow: auto;
  background: #121a30;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog a { color: var(--accent); }

.noscript {
  position: fixed;
  top: 3.5rem;
  left: 0.8rem;
  right: 0.8rem;
  z-index: 20;
  margin: 0;
  padding: 0.6rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--warn);
  border-radius: 6px;
  color: var(--warn);
}

/* Mobile: notice as a top badge, controls as a bottom sheet that shows
   only the slider and play until opened, legend above the sheet. */
@media (max-width: 700px) {
  #notice-bar { padding: 0.3rem 0.5rem; font-size: 12px; }
  #notice-more { flex-basis: 100%; }
  #credits-open { padding: 0.2rem 0.5rem; }
  #controls {
    left: 0;
    right: 0;
    bottom: 2.6rem;
    width: 100%;
    border-radius: 12px 12px 0 0;
    border-left: 0;
    border-right: 0;
  }
  #sheet-toggle { display: inline-block; margin-top: 0.4rem; }
  #pickers { display: none; flex-direction: column; }
  #controls.open #pickers { display: flex; }
  #valid { font-size: 12px; white-space: normal; }
  #legend {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 9.5rem;
    width: auto;
  }
  #controls.open ~ #legend { bottom: 15rem; }
  #status { top: 5.5rem; }
}
