/* ==========================================================================
   Tonight — the sky above you, as a horizon panorama. Tier 1, pure static,
   two optional keyless fetches (geocoding, cloud cover); astronomy is local.

   ART DIRECTION: NOCTURNE (+ two borrows). See docs/tonight-art-direction.md
   — read it, and its CHROME section, before changing anything visual.

   The gradient IS the interface. The chrome is marginalia written onto the
   field, not components on top of it:
     · no border-radius (except the scrub knob — a circle)
     · no backdrop-filter / blur, no box-shadow (text-shadow for legibility
       is fine — it's type, not a container)
     · Fraunces for everything; no system-UI font
     · nothing centred; chrome hangs on the lower-left optical margin
     · no pill / ghost buttons, no toolbar background
     · feedback is an underline + a dim, never a background wash
   Chrome colour is set from the live field by tonight.js each frame.
   ========================================================================== */

/* --- Fraunces (self-hosted, SIL OFL 1.1 — licence beside the woff2) ---- */
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-latin-var.woff2") format("woff2");
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
  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;
}
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-latin-ext-var.woff2") format("woff2");
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0b1020;
  --serif: "Fraunces", ui-serif, "Iowan Old Style", "Palatino Linotype",
           Palatino, Georgia, serif;

  /* Chrome colour — tonight.js overrides these every frame from the live
     field (warm at dusk, cool at midnight). These are the pre-JS / paused
     fallbacks: a warm dusk light. */
  --chrome:      rgba(244, 240, 232, 0.86);
  --chrome-soft: rgba(244, 240, 232, 0.56);
  --chrome-line: rgba(244, 240, 232, 0.26);

  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem;
  --sp-4: 1rem;   --sp-5: 1.5rem; --sp-6: 2rem;

  --edge:  max(var(--sp-5), env(safe-area-inset-left));   /* left optical margin */
  --floor: calc(env(safe-area-inset-bottom) + var(--sp-4));
  --sat:   env(safe-area-inset-top, 0px);                 /* read by tonight.js */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, p, ul { margin: 0; }
html, body { height: 100%; }
input, button { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

body {
  background: var(--bg);
  color: var(--chrome);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;      /* Fraunces display cut at large sizes */
  font-synthesis: none;           /* never fake a weight */
}

/* focus: a thin square outline in the chrome colour — never a rounded ring */
:focus-visible { outline: 1px solid var(--chrome); outline-offset: 3px; }

/* --- the sky ---------------------------------------------------------- */
#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#sky.dragging { cursor: grabbing; }

/* --- a word that acts as a control --------------------------------- */
.word {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--chrome);
  letter-spacing: 0.01em;
  min-height: 44px;                 /* touch target, though the ink is a word */
  display: inline-flex;
  align-items: center;
  position: relative;
  white-space: nowrap;
  transition: opacity 140ms ease, letter-spacing 160ms ease;
}
.word::after {                      /* the underline — the only affordance */
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: 11px;
  height: 1px;
  background: currentColor;
  opacity: 0.32;
  transition: opacity 150ms ease;
}
#btn-play { min-width: 3.1rem; justify-content: center; }   /* labels cycle: Play / Live / 10m … */
.word:hover { letter-spacing: 0.035em; }
.word:hover::after,
.word:focus-visible::after { opacity: 0.8; }
.word:active { opacity: 0.55; }
.word[aria-pressed="true"]::after { opacity: 0.85; }
@media (hover: none) { .word::after { opacity: 0.5; } }

/* --- placard: place name into the field ----------------------------- */
.placard {
  position: fixed;
  left: var(--edge);
  bottom: calc(var(--floor) + 3.4rem);
  z-index: 12;
  display: grid;
  gap: 0.12em;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.38);
}
.placard[hidden] { display: none; }
.placard-place {
  font-size: clamp(2.4rem, 10vw, 4.5rem);
  font-weight: 430;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--chrome);
}
.placard-sub {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--chrome-soft);
}
/* ISS pass callout — a quiet line under the sub; tap to play the pass */
.placard-iss {
  justify-self: start;
  margin-top: 0.3em;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: var(--chrome-soft);
  font-variant-numeric: lining-nums tabular-nums;
  pointer-events: auto;                /* the placard itself is inert */
  cursor: pointer;
  text-align: left;
  transition: color 140ms ease, letter-spacing 160ms ease;
}
.placard-iss[hidden] { display: none; }
.placard-iss::after {                  /* a hairline, drawn in like .word */
  content: "";
  display: block;
  height: 1px;
  margin-top: 2px;
  background: currentColor;
  opacity: 0.3;
  transition: opacity 150ms ease;
}
.placard-iss:hover,
.placard-iss:focus-visible { color: var(--chrome); letter-spacing: 0.045em; outline: none; }
.placard-iss:hover::after,
.placard-iss:focus-visible::after { opacity: 0.75; }
.placard-iss:active { opacity: 0.6; }

/* --- object card: a quiet overlay tethered to a tapped object ------ */
.card {
  position: fixed;
  z-index: 14;
  width: min(17rem, calc(100vw - 2 * var(--edge)));
  display: grid;
  gap: 0.18em;
  padding: var(--sp-3) 0 0;
  border-top: 1px solid var(--chrome-line);   /* a hairline, not a box */
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.card[hidden] { display: none; }
.card-name   { font-size: 1.5rem; font-weight: 430; letter-spacing: -0.01em; color: var(--chrome); }
.card-pos    { font-size: 0.9rem; color: var(--chrome-soft); font-variant-numeric: lining-nums tabular-nums; }
.card-rise   { font-size: 0.9rem; color: var(--chrome-soft); font-variant-numeric: lining-nums tabular-nums; }
.card-advice { font-size: 0.98rem; color: var(--chrome); margin-top: 0.25em; max-width: 20rem; }
.card-rise:empty { display: none; }

/* --- time: a caption line on the field ---------------------------- */
.controls {
  position: fixed;
  left: var(--edge);
  right: var(--edge);
  bottom: var(--floor);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.38);
}
.controls[hidden] { display: none; }

.scrub {
  flex: 1 1 auto;
  min-width: 3rem;
  height: 44px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  --p: 0%;
}
.scrub::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(90deg,
    var(--chrome) 0 var(--p), var(--chrome-line) var(--p));
}
.scrub::-moz-range-track    { height: 1px; background: var(--chrome-line); }
.scrub::-moz-range-progress { height: 1px; background: var(--chrome); }
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 9px; height: 9px;
  border-radius: 50%;              /* the one permitted circle */
  background: var(--chrome);
  margin-top: -4px;
}
.scrub::-moz-range-thumb {
  width: 9px; height: 9px; border: 0;
  border-radius: 50%;
  background: var(--chrome);
}

.clock {
  flex: none;
  color: var(--chrome-soft);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.ctl-where {
  flex: none;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--chrome-soft);
  transition: opacity 140ms ease, color 140ms ease;
}
.ctl-where:hover,
.ctl-where:focus-visible { color: var(--chrome); }

@media (max-width: 30rem) {
  .controls { gap: var(--sp-4); }
  .clock { font-size: 0.9rem; }
  .placard { bottom: calc(var(--floor) + 4rem); }
  .placard-place { font-size: clamp(2rem, 12vw, 3rem); }
}
@media (max-width: 22rem) {
  .controls { gap: var(--sp-3); }
  .word { font-size: 0.98rem; }
  .clock { font-size: 0.82rem; }
}
/* short viewports (landscape phones): let the tall overlays scroll */
@media (max-height: 34rem) {
  .placard-place { font-size: clamp(1.7rem, 8vh, 2.4rem); }
  .placard { bottom: calc(var(--floor) + 3rem); }
  .locate h1 { font-size: clamp(1.8rem, 9vh, 2.6rem); }
}

/* --- locate: a prompt written into the field, not a card --------- */
.locate {
  position: fixed;
  left: var(--edge);
  right: var(--edge);
  bottom: calc(var(--floor) + 0.5rem);
  z-index: 20;
  max-width: 25rem;
  max-height: calc(100dvh - var(--floor) - 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: var(--sp-3);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.38);
}
.locate[hidden] { display: none; }
.locate h1 {
  font-size: clamp(2.4rem, 11vw, 4rem);
  font-weight: 430;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--chrome);
  margin-bottom: 0.1em;
}
.locate p {
  color: var(--chrome-soft);
  font-size: 0.98rem;
  max-width: 24rem;
}

.field {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--chrome-line);
  padding: var(--sp-2) 0;
  color: var(--chrome);
  font-size: 1.2rem;
  transition: border-color 140ms ease;
}
.field::placeholder { color: var(--chrome-soft); }
.field:focus { outline: none; border-bottom-color: var(--chrome); }

.place-results {
  list-style: none; padding: 0; margin: 0; display: grid;
  max-height: 42vh; overflow-y: auto; overscroll-behavior: contain;
}
.place-results[hidden] { display: none; }
.place-results li { border-bottom: 1px solid var(--chrome-line); }
.place-results li:first-child { border-top: 1px solid var(--chrome-line); }
/* each result is a real button: focusable, Enter-able, same quiet look */
.place-pick {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--sp-3) 0;
  min-height: 44px;
  color: var(--chrome-soft);
  font: inherit;
  transition: color 120ms ease, padding-left 160ms ease;
}
.place-pick:hover,
.place-pick:focus-visible { color: var(--chrome); padding-left: 0.5rem; outline: none; }
.place-pick:focus-visible .p-name { text-decoration: underline; text-underline-offset: 3px; }
.place-results .p-sub { color: var(--chrome-soft); font-size: 0.82em; }

.locate-actions { display: flex; gap: var(--sp-6); margin-top: var(--sp-1); }
.locate-msg { color: var(--chrome-soft); font-size: 0.9rem; }
.locate-msg[hidden] { display: none; }

/* --- motion opt-out --------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
