/* Norman: chrome around the 3D scene. The instrument's own palette lives in themes.js; --ember follows the theme's accent. */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #06090f; --ink: #0b0d11; --mist: #eaeef3; --haze: #9aa6b2; --faint: #626c76; --soft: #c3cedb;
  --ember: #d8a95c; --line: rgba(200,214,228,0.12); --glass: rgba(11,13,17,0.78);
  --font: "Segoe UI Variable Display", "Segoe UI", "Inter", "Roboto", "Noto Sans", "DejaVu Sans", system-ui, sans-serif;
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }   /* no font boosting on phones: the chrome is sized on purpose */
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--mist); font-family: var(--font); user-select: none; }
body { height: 100dvh; }   /* phones: the real visible height, under the browser's own bars */
canvas#gl { display: block; width: 100%; height: 100%; cursor: grab; }
canvas#gl.dragging { cursor: grabbing; }
canvas#gl.hover { cursor: crosshair; }

/* ---- shared bits ---- */
.tb { font: 500 10px/1 var(--font); letter-spacing: 0.16em; text-transform: uppercase; color: var(--haze); background: var(--glass);
  border: 1px solid var(--line); border-radius: 4px; padding: 7px 10px; cursor: pointer; backdrop-filter: blur(6px); }
.tb:hover { color: var(--mist); border-color: rgba(200,214,228,0.3); }
.tb.on { color: var(--ember); border-color: rgba(216,169,92,0.5); }
.tb.icon { padding: 5px 6px; display: inline-grid; place-items: center; }
select { font: 500 10px/1 var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: var(--soft); background: var(--glass); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; }
input[type=text] { font: 400 12px/1 var(--font); color: var(--mist); background: var(--glass); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; width: 100%; }
input[type=text]:focus { outline: none; border-color: rgba(216,169,92,0.5); }

/* ---- top bar ---- */
#top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px; padding: 12px 16px; pointer-events: none;
  background: linear-gradient(rgba(6,9,15,0.55), rgba(6,9,15,0)); }
#top > * { pointer-events: auto; }
#brand { font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--haze); }
#brand b { color: var(--mist); font-weight: 600; }
#skynow { flex: 1; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--haze); text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
#skynow span b { color: var(--mist); font-weight: 500; }
#skynow span.down { opacity: 0.5; }
#skynow span i { font-style: normal; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: -0.5px; }
#topbtns { display: flex; gap: 6px; }

/* ---- drawer ---- */
#drawer { position: fixed; top: 48px; right: 16px; width: 300px; max-height: calc(100% - 120px); overflow: auto; background: var(--glass); border: 1px solid var(--line); border-radius: 6px;
  padding: 0 0 6px; backdrop-filter: blur(10px); font-size: 11px; color: var(--soft); scrollbar-width: thin; }
#drawer[hidden] { display: none; }
#drawer details[hidden] { display: none; }
#drawer .dhead { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 14px; font-size: 9px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--haze); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(11,13,17,0.92); z-index: 1; }
#drawer .dhead .tb { padding: 2px 7px; font-size: 13px; line-height: 1; }
#drawer details { border-bottom: 1px solid var(--line); }
#drawer details:last-child { border-bottom: 0; }
#drawer summary { list-style: none; cursor: pointer; padding: 10px 14px; font-size: 8.5px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--faint); font-weight: 600; display: flex; align-items: center; gap: 8px; user-select: none; }
#drawer summary::-webkit-details-marker { display: none; }
#drawer summary::before { content: ""; width: 0; height: 0; border-left: 4px solid var(--faint); border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent; transition: transform 0.15s; }
#drawer details[open] summary::before { transform: rotate(90deg); }
#drawer details[open] summary { color: var(--haze); }
/* one gutter for everything inside a section: 14px either side, nothing touches the edge */
#drawer details > :not(summary) { margin-left: 14px; margin-right: 14px; }
#drawer details > :last-child { margin-bottom: 12px; }
#drawer label { display: flex; align-items: center; gap: 7px; padding: 3px 0; cursor: pointer; min-width: 0; }
#drawer .grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; margin-bottom: 4px; }
#drawer .grid .wide { grid-column: 1 / -1; }
/* labelled controls share one column of labels so the selects and sliders line up */
#drawer .row, #drawer label.range { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; column-gap: 10px; margin-top: 6px; margin-bottom: 6px; }
#drawer label.range { grid-template-columns: 104px minmax(0, 1fr) 40px; padding: 0; }
#drawer .row > span:first-child, #drawer label.range > span:first-child { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--haze); line-height: 1.3; }
#drawer .row select { width: 100%; max-width: 180px; justify-self: start; }
#drawer label.range input { width: 100%; min-width: 0; }
#drawer label.range output { text-align: right; color: var(--haze); font-variant-numeric: tabular-nums; }
#drawer label.inline { display: inline-flex; padding: 0; }
#drawer input[type=checkbox] { accent-color: var(--ember); margin: 0; flex: 0 0 auto; }
#drawer input[type=range] { accent-color: var(--ember); }
#drawer input[type=number] { font: 500 11px var(--font); color: var(--mist); background: var(--glass); border: 1px solid var(--line); border-radius: 3px; padding: 2px 4px; width: 44px; }
#drawer .picker .row { display: flex; gap: 6px; }
#drawer .picker .row > input { flex: 1; min-width: 0; }
#drawer .picker + .row { margin-top: 12px; }
#drawer .blurb { margin-top: -2px; margin-bottom: 8px; font-size: 10px; line-height: 1.5; color: var(--faint); }
#drawer .foot { margin-top: 8px; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); line-height: 1.7; }
#drawer .foot b { color: var(--haze); font-weight: 500; }
#drawer .dbg-btns { display: flex; flex-wrap: wrap; gap: 4px; }
#drawer .dbg-btns .tb { padding: 5px 6px; letter-spacing: 0.04em; font-size: 9.5px; }
#dbg-out { font: 10px/1.5 ui-monospace, "Cascadia Mono", "Consolas", "DejaVu Sans Mono", monospace; color: var(--haze); white-space: pre; margin: 4px 0 0; overflow-x: auto; }
#dbg-out b { color: var(--ember); font-weight: 600; }
#bench-out { width: 100%; height: 190px; margin-top: 6px; font: 9.5px/1.45 ui-monospace, "Cascadia Mono", "Consolas", "DejaVu Sans Mono", monospace; color: var(--soft); background: rgba(6,9,15,0.8); border: 1px solid var(--line); border-radius: 4px; padding: 6px; white-space: pre; overflow: auto; resize: vertical; }
#bench-out[hidden] { display: none; }
#dbgtag { position: fixed; left: 50%; top: 52px; transform: translateX(-50%); font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ember);
  background: var(--glass); border: 1px solid rgba(216,169,92,0.4); border-radius: 4px; padding: 5px 10px; pointer-events: none; }
#dbgtag[hidden] { display: none; }

/* location picker */
.picker { position: relative; }
.picker #go { padding: 7px 9px; }
#loc-results { list-style: none; margin: 4px 0 0; border: 1px solid var(--line); border-radius: 4px; background: rgba(11,13,17,0.96); max-height: 240px; overflow: auto; }
#loc-results[hidden] { display: none; }
#loc-results li { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; }
#loc-results li:last-child { border-bottom: 0; }
#loc-results li:hover, #loc-results li.sel { background: rgba(216,169,92,0.12); }
#loc-results li.none { cursor: default; color: var(--faint); grid-template-columns: 1fr; }
#loc-results .nm { color: var(--mist); font-weight: 500; }
#loc-results .nm small { color: var(--haze); font-weight: 400; margin-left: 6px; }
#loc-results .co { color: var(--faint); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; }
#loc-results .ll { grid-column: 1 / -1; color: var(--faint); font-size: 9.5px; font-variant-numeric: tabular-nums; }
/* the place, as a sub-heading above the search box: name large, coordinates and zone small beneath it */
#loc-current { margin: 2px 0 10px; font-size: 10px; color: var(--haze); line-height: 1.5; letter-spacing: 0.04em; }
#loc-current b { display: block; color: var(--mist); font-weight: 500; font-size: 17px; letter-spacing: 0.02em; line-height: 1.2; margin-bottom: 2px; }
#loc-current .ll { color: var(--faint); font-variant-numeric: tabular-nums; }
#loc-current.bad { color: var(--bad, #c98a8a); }

/* ---- timeline ---- */
#timeline { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%) translateY(14px); width: min(820px, calc(100% - 32px)); display: flex; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease; }
#timeline.shown { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
canvas#gl { touch-action: none; }
/* the way back to live when the bar is hidden: sits where the bar would, only while the clock is off "now" */
#backnow { position: fixed; left: 50%; bottom: 14px; z-index: 5; display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 12px; border-radius: 999px; white-space: nowrap; max-width: calc(100% - 20px);
  color: var(--soft); border-color: rgba(216,169,92,0.35); opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(14px); transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.2s ease; }
#backnow.shown { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
#backnow:hover { color: var(--mist); border-color: rgba(216,169,92,0.7); }
#backnow .ic { color: var(--ember); font-size: 14px; line-height: 1; margin-top: -1px; }
#backnow #backnow-when { color: var(--haze); letter-spacing: 0.12em; font-variant-numeric: tabular-nums; padding-left: 10px; border-left: 1px solid var(--line); }
#timeline input[type=range] { flex: 1; accent-color: var(--ember); height: 18px; }
#when { min-width: 150px; text-align: right; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--haze); font-variant-numeric: tabular-nums; }
#when-live { color: var(--ember); margin-right: 8px; font-weight: 600; }
#timeline.scrubbed #when-live { color: var(--faint); font-weight: 400; }
#when-time { color: var(--soft); }
#play.on { color: var(--ember); }

/* ---- body card (while orbiting the sun, the moon or a planet) ---- */
#bodycard { position: fixed; left: 16px; bottom: 76px; width: 240px; background: var(--glass); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px 8px; backdrop-filter: blur(10px); font-size: 10.5px; color: var(--soft); pointer-events: none; }
#bodycard[hidden] { display: none; }
#bodycard .bc-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
#bodycard .bc-head b { font-size: 15px; font-weight: 500; color: var(--mist); letter-spacing: 0.04em; }
#bodycard .bc-head span { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); }
#bodycard .bc-row { display: flex; justify-content: space-between; padding: 2px 0; }
#bodycard .bc-row span { color: var(--faint); letter-spacing: 0.06em; text-transform: uppercase; font-size: 9px; }
#bodycard .bc-row b { font-weight: 500; color: var(--mist); font-variant-numeric: tabular-nums; }
#bodycard .bc-foot { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
#bodycard .bc-foot b { color: var(--haze); font-weight: 500; }

#nogl { position: fixed; inset: 0; display: none; place-items: center; font-size: 12px; color: var(--haze); letter-spacing: 0.1em; text-align: center; line-height: 1.8; }
#nogl a { color: var(--ember); }

/* ---- small screens ---- */
@media (max-width: 720px) {
  #top { padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 8px calc(10px + env(safe-area-inset-left)); gap: 8px; }
  #brand { display: none; }
  #topbtns { margin-left: auto; }
  #skynow { font-size: 8.5px; gap: 2px 8px; }
  #skynow span:nth-child(n+3) { display: none; }
  .tb { padding: 6px 8px; font-size: 9px; letter-spacing: 0.1em; }
  #drawer { left: 10px; right: 10px; width: auto; top: calc(44px + env(safe-area-inset-top)); max-height: calc(100% - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); font-size: 12px; }
  #drawer .row select { max-width: none; }
  #timeline { width: calc(100% - 20px); bottom: calc(10px + env(safe-area-inset-bottom)); gap: 6px; padding: 6px 8px; }
  #backnow { bottom: calc(10px + env(safe-area-inset-bottom)); gap: 8px; padding: 8px 12px 8px 10px; font-size: 9px; }
  #when { min-width: 0; font-size: 9px; }
  #when-live { margin-right: 4px; }
  #speed { display: none; }
  #bodycard { left: 10px; right: 10px; width: auto; bottom: calc(66px + env(safe-area-inset-bottom)); }
}
/* very narrow (small phones): the view buttons shrink to a single row */
@media (max-width: 400px) {
  #topbtns { gap: 4px; }
  .tb { padding: 6px 6px; letter-spacing: 0.06em; }
}
@media (pointer: coarse) { .tb { padding: 9px 11px; } #timeline input[type=range] { height: 28px; } #drawer input[type=range] { height: 28px; } #drawer label { padding: 5px 0; } #drawer input[type=checkbox] { width: 16px; height: 16px; } }

@media (max-width: 760px) {
  #skynow { display: none; }
  #when { min-width: 0; }
  #speed { display: none; }
}
