/* ------------------------------------------------------------------
   Fonts (subset to Latin + Greek, self-hosted, SIL Open Font License)
   ------------------------------------------------------------------ */
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('../fonts/atkinson-hyperlegible-regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('../fonts/atkinson-hyperlegible-bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Literata';
  src: url('../fonts/literata-roman.woff2') format('woff2');
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Literata';
  src: url('../fonts/literata-italic.woff2') format('woff2');
  font-weight: 400 600; font-style: italic; font-display: swap;
}

/* ------------------------------------------------------------------
   Tokens
   ------------------------------------------------------------------ */
:root {
  --abyss: #050A1F;          /* the night sky itself */
  --ink: #0E1736;            /* panels */
  --panel: rgba(12, 20, 48, 0.82);
  --panel-solid: rgba(10, 17, 42, 0.97);
  --brass: #E0B567;          /* the one accent: reticle, guide arrow, primary action */
  --brass-dim: rgba(224, 181, 103, 0.16);
  --on-brass: #1C1407;
  --starlight: #F4EFE1;      /* text */
  --mist: #8E9AC0;           /* secondary text */
  --ice: #A8E1FF;            /* satellites */
  --line: rgba(142, 154, 192, 0.2);
  --line-strong: rgba(142, 154, 192, 0.42);

  --sans: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Literata', Georgia, 'Times New Roman', serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --bar-gap: 12px;
  --dock-bottom: calc(var(--safe-b) + 76px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--abyss);
  color: var(--starlight);
  font: 400 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }

/* Names of things in the sky are set like an old star atlas:
   stars in italic serif, planets and constellations in roman serif, satellites in the UI face. */
.n-star { font-family: var(--serif); font-style: italic; font-weight: 400; }
.n-body { font-family: var(--serif); font-style: normal; font-weight: 500; }
.n-sat { font-family: var(--sans); font-weight: 700; color: var(--ice); }
.n-plain { font-family: var(--sans); font-weight: 700; }

/* ------------------------------------------------------------------
   Sky canvas and night filter
   ------------------------------------------------------------------ */
#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#night-filter {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  background: #ff1a00;
  mix-blend-mode: multiply;
  pointer-events: none;
}
body.night #night-filter { display: block; }

/* ------------------------------------------------------------------
   Top and bottom bars
   ------------------------------------------------------------------ */
.bar {
  position: fixed;
  left: calc(var(--safe-l) + var(--bar-gap));
  right: calc(var(--safe-r) + var(--bar-gap));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.bar-top { top: calc(var(--safe-t) + 10px); }
.bar-bottom { bottom: calc(var(--safe-b) + 14px); }

.icon-btn {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(5, 10, 31, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--starlight);
}
.icon-btn.small { width: 38px; height: 38px; background: transparent; border-color: transparent; color: var(--mist); }
.icon-btn.small:hover { color: var(--starlight); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px 0 12px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(5, 10, 31, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip svg { width: 18px; height: 18px; color: var(--mist); }
.chip.active { border-color: var(--brass); color: var(--brass); }
.chip.active svg { color: var(--brass); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 48px;
  padding: 0 20px 0 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(5, 10, 31, 0.6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-weight: 700;
  font-size: 15.5px;
}
.pill svg { color: var(--mist); }
#btn-motion[aria-pressed='true'] { border-color: rgba(224, 181, 103, 0.7); }
#btn-motion[aria-pressed='true'] svg { color: var(--brass); }

/* ------------------------------------------------------------------
   Docked panels: what you're aiming at, guidance, compass alignment
   ------------------------------------------------------------------ */
.dock {
  position: fixed;
  z-index: 15;
  left: calc(var(--safe-l) + var(--bar-gap));
  right: calc(var(--safe-r) + var(--bar-gap));
  bottom: var(--dock-bottom);
  max-width: 460px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.aim-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 13px 18px;
  border: 0;
  background: transparent;
  text-align: left;
}
.aim-btn:disabled .aim-icon { visibility: hidden; }
.aim-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.aim-name {
  font-size: 22px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aim-sub { color: var(--mist); font-size: 14.5px; }
.aim-icon { color: var(--mist); width: 24px; height: 24px; }

.guide { padding: 14px 10px 14px 18px; }
.guide-head { display: flex; align-items: flex-start; gap: 8px; }
.guide-name {
  flex: 1;
  min-width: 0;
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.15;
}
.guide-head .icon-btn { margin: -6px -2px 0 0; }
.guide-step {
  margin: 6px 8px 0 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
  min-height: 1.35em;
}
.guide.locked { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass) inset; }
.guide.locked .guide-step { color: var(--brass); }
.guide-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 8px 0 0; }

.align { padding: 16px 18px; }
.align-text { margin: 0 0 12px; font-size: 16.5px; line-height: 1.45; }

/* ------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(5, 10, 31, 0.35);
  color: var(--starlight);
  font-weight: 700;
  font-size: 15.5px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--mist); }
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--on-brass); }
.btn.primary:hover { background: #e9c47e; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mist); }
.btn.ghost:hover { color: var(--starlight); }
.btn.small { min-height: 38px; padding: 0 13px; border-radius: 10px; font-size: 14.5px; }
.btn.big { min-height: 54px; width: 100%; font-size: 17px; border-radius: 14px; }
.btn:disabled { opacity: 0.45; }

.link {
  display: block;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--mist);
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(142, 154, 192, 0.5);
  text-underline-offset: 3px;
  font-size: 15px;
  line-height: 1.4;
}
.link.inline { display: inline; margin: 0; font-size: inherit; color: var(--starlight); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ------------------------------------------------------------------
   Bottom sheet (side panel on wide screens)
   ------------------------------------------------------------------ */
.sheet {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  max-height: min(80vh, 760px);
  max-height: min(80dvh, 760px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--panel-solid);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
  transform: translateY(104%);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.open { transform: translateY(0); }
.sheet-close { position: absolute; top: 12px; right: 10px; z-index: 1; }
.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 24px 22px calc(var(--safe-b) + 28px);
}
body.sheet-open .dock { visibility: hidden; }
body.intro-open .bar, body.intro-open .dock { visibility: hidden; }

/* round tools next to Tonight: visible satellites, red screen, hold, motion */
.tools { display: flex; gap: 8px; }
.icon-btn.tool { position: relative; }
.icon-btn.tool[aria-pressed='true'] { border-color: rgba(224, 181, 103, 0.8); color: var(--brass); }
#btn-night[aria-pressed='true'] { border-color: rgba(255, 106, 85, 0.85); color: #ff6a55; }
.badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--ice); color: var(--abyss);
  font: 700 11.5px/20px var(--sans); text-align: center;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* phones only: computers have no motion sensors to point with */
@media (hover: hover) and (pointer: fine) {
  #btn-motion { display: none; }
}

.sheet-title {
  margin: 0 46px 2px 0;
  font-size: 31px;
  line-height: 1.12;
  font-weight: 500;
}
.sheet-title.n-star { font-weight: 400; }
.sheet-sub { margin: 0 0 18px; color: var(--mist); font-size: 16px; }
.sheet-h3 {
  margin: 28px 0 6px;
  font: 700 15px/1.3 var(--sans);
  color: var(--mist);
}
.para { margin: 14px 0 0; font-size: 16px; line-height: 1.55; max-width: 62ch; }
.muted { color: var(--mist); margin: 10px 0 0; }
.small { font-size: 13.5px; line-height: 1.5; }
.note {
  margin: 4px 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(142, 154, 192, 0.1);
  color: var(--mist);
  font-size: 14.5px;
}

.facts { margin: 20px 0 0; }
.fact {
  display: grid;
  grid-template-columns: minmax(6.5em, 30%) 1fr;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.fact dt { color: var(--mist); font-size: 14.5px; padding-top: 1px; }
.fact dd { margin: 0; font-size: 15.5px; }

/* passes */
.passes { margin-top: 8px; }
.pass-list { list-style: none; margin: 0; padding: 0; }
.pass { padding: 12px 0; border-top: 1px solid var(--line); }
.pass-main { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pass-when { font-weight: 700; font-size: 16px; color: var(--mist); }
.pass.vis .pass-when { color: var(--starlight); }
.pass-status { color: var(--mist); font-size: 14px; text-align: right; }
.pass.vis .pass-status { color: var(--ice); }
.pass-detail { color: var(--mist); font-size: 14.5px; margin-top: 2px; }
.pass-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* search */
.search-label { display: block; margin: 0 46px 10px 0; color: var(--mist); font-size: 15px; }
.search-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(5, 10, 31, 0.7);
  font-size: 18px;
  -webkit-appearance: none;
  appearance: none;
}
.search-input:focus { outline: none; border-color: var(--brass); }
.results { margin-top: 6px; }
.result {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'name where' 'sub where';
  column-gap: 12px;
  padding: 11px 2px;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
}
.results .sheet-h3 + .result { border-top: 0; }
.r-name { grid-area: name; font-size: 19px; line-height: 1.25; }
.r-sub { grid-area: sub; color: var(--mist); font-size: 14px; }
.r-where { grid-area: where; align-self: center; color: var(--mist); font-size: 14px; text-align: right; }
.r-where.up { color: var(--starlight); font-weight: 700; }

/* tonight */
.t-row { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); }
.sheet-h3 + .t-row { border-top: 0; }
.t-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 11px 0;
  border: 0;
  background: none;
  text-align: left;
}
.t-name { font-size: 19px; line-height: 1.25; }
.t-detail { color: var(--mist); font-size: 14.5px; }

/* time */
.time-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 4px 0 18px; }
.time-row .btn { padding: 0 4px; font-size: 14px; }

/* settings */
.toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.sheet-h3 + .toggle { border-top: 0; }
.toggle input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  position: relative;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 14px;
  background: rgba(142, 154, 192, 0.32);
  transition: background 0.15s;
  cursor: pointer;
}
.toggle input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--starlight);
  transition: transform 0.15s;
}
.toggle input:checked { background: var(--brass); }
.toggle input:checked::after { transform: translateX(18px); background: var(--on-brass); }
.t-label { display: flex; flex-direction: column; font-size: 16px; }
.t-hint { color: var(--mist); font-size: 13.5px; }

.field { display: block; color: var(--mist); font-size: 14px; }
.field input {
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(5, 10, 31, 0.7);
  color: var(--starlight);
  font-size: 16px;
  color-scheme: dark;
}
.field input:focus { outline: none; border-color: var(--brass); }
.loc-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-top: 14px; }

.ad-slot { margin: 26px 0 0; min-height: 0; }
.ad-slot:empty { display: none; }

/* ------------------------------------------------------------------
   Intro / arrival
   ------------------------------------------------------------------ */
.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background:
    linear-gradient(to top, rgba(5, 10, 31, 0.96) 0%, rgba(5, 10, 31, 0.86) 38%, rgba(5, 10, 31, 0.25) 72%, rgba(5, 10, 31, 0.05) 100%);
  transition: opacity 0.3s ease;
}
.intro.leaving { opacity: 0; pointer-events: none; }

.wordmark {
  position: absolute;
  top: calc(var(--safe-t) + 20px);
  left: calc(var(--safe-l) + 24px);
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 20px/1 var(--serif);
  letter-spacing: 0.005em;
}
.wordmark img { width: 36px; height: 36px; display: block; }

.intro-inner {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 24px calc(var(--safe-r) + 26px) calc(var(--safe-b) + 26px) calc(var(--safe-l) + 26px);
}
.intro-kicker { margin: 0 0 6px; color: var(--mist); font-size: 16px; }
.intro-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(40px, 11.5vw, 60px);
  line-height: 1.03;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.intro-title.n-star { font-weight: 400; }
.intro-title.n-sat { font-family: var(--serif); font-weight: 500; color: var(--starlight); }
.intro-text { margin: 0; font-size: 18px; line-height: 1.5; max-width: 36ch; color: rgba(244, 239, 225, 0.92); }
.loading { margin: 14px 0 0; color: var(--mist); font-size: 14.5px; }
.loading.failed { color: var(--starlight); font-weight: 700; }
.intro-actions { display: grid; gap: 8px; margin-top: 24px; }
.intro-fine { margin: 14px 0 0; color: var(--mist); font-size: 13.5px; line-height: 1.5; max-width: 46ch; }
.intro-links, .more-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 14px 0 0; }
.intro-links a, .more-links a { color: var(--mist); font-size: 14px; text-decoration: underline; text-decoration-color: rgba(142, 154, 192, 0.45); text-underline-offset: 3px; }
.intro-links a:hover, .more-links a:hover { color: var(--starlight); }

/* ------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------ */
.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: calc(var(--safe-t) + 68px);
  width: max-content;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(244, 239, 225, 0.96);
  color: var(--abyss);
  font-size: 15px;
  line-height: 1.4;
  font-weight: 700;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.noscript {
  position: fixed;
  inset: auto 20px 40px;
  z-index: 100;
  padding: 16px;
  border-radius: 12px;
  background: var(--ink);
}

/* ------------------------------------------------------------------
   Wider screens: the sheet becomes a side panel
   ------------------------------------------------------------------ */
@media (min-width: 900px) {
  .sheet {
    top: 0;
    left: auto;
    right: 0;
    width: 420px;
    max-width: none;
    max-height: none;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    transform: translateX(104%);
  }
  .sheet.open { transform: translateX(0); }
  .sheet-body { padding: calc(var(--safe-t) + 28px) 28px 32px; }
  .sheet-close { top: calc(var(--safe-t) + 16px); right: 14px; }
  body.sheet-open .dock { visibility: visible; right: 440px; }
  body.sheet-open .bar-top { right: 440px; }
  .intro-inner { margin: 0 0 0 max(6vw, 40px); padding-bottom: 7vh; }
  .wordmark { left: max(6vw, 40px); top: 32px; }
  .intro-actions { grid-template-columns: auto auto; justify-content: start; }
  .btn.big { width: auto; padding: 0 28px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  :root { --dock-bottom: calc(var(--safe-b) + 70px); }
  .intro-title { font-size: 34px; }
  .intro-text { font-size: 16px; }
  .intro-actions { grid-template-columns: auto auto; justify-content: start; margin-top: 14px; }
  .btn.big { width: auto; }
  .dock { max-width: 420px; }
}

/* Phones held sideways: panels move to the bottom-left corner and the buttons to a column
   on the right, so the middle of the screen (where the circle is) stays clear. */
@media (orientation: landscape) and (max-height: 600px) {
  .dock { left: calc(var(--safe-l) + 12px); right: auto; width: min(340px, 40vw); margin: 0; bottom: calc(var(--safe-b) + 12px); }
  .aim-btn { padding: 9px 12px 10px 14px; }
  .aim-name { font-size: 19px; }
  .guide { padding: 10px 8px 10px 14px; }
  .guide-name { font-size: 20px; }
  .guide-step { font-size: 15.5px; }
  .guide-actions { margin-top: 8px; }
  .bar-bottom { left: auto; bottom: calc(var(--safe-b) + 12px); flex-direction: column-reverse; align-items: flex-end; gap: 8px; }
  .bar-bottom .tools { flex-direction: column-reverse; }
  #btn-tonight { width: 46px; height: 46px; padding: 0; justify-content: center; }
  #btn-tonight span { display: none; }
  .sheet { top: 0; left: auto; right: 0; width: min(420px, 62vw); max-width: none; max-height: none;
    border: 0; border-left: 1px solid var(--line); border-radius: 0; transform: translateX(104%); }
  .sheet.open { transform: translateX(0); }
  .sheet-body { padding: calc(var(--safe-t) + 18px) calc(var(--safe-r) + 20px) 24px 22px; }
  .sheet-close { top: calc(var(--safe-t) + 10px); right: calc(var(--safe-r) + 8px); }
  body.sheet-open .dock { visibility: visible; }
  .toast { top: calc(var(--safe-t) + 60px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}
