/* Nocturne — a quiet reading room under the stars */
:root {
  --bg: #0a0806;
  --bg2: #141007;
  --fg: #f2e9d9;
  --muted: #a99a84;
  --line: rgba(242, 233, 217, 0.08);
  --panel: rgba(242, 233, 217, 0.03);
  --accent: #d4a465;
  --accent2: #c07a3a;
  --radius: 12px;
  --sidebar-radius: 16px;
  --font-mono: "SF Mono", "Fira Code", "Consolas", "Liberation Mono", monospace;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  background-image: url();
}
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; color: inherit; background: none; border: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
::selection { background: rgba(212, 164, 101, 0.25); }

/* shared chrome */
.chrome-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.brand b { color: var(--fg); font-weight: 600; }
.site-nav { display: flex; gap: 0.8rem; font-size: 0.75rem; }
.site-nav a { color: var(--muted); padding: 0.1rem 0.6rem; border-radius: var(--radius); background: var(--panel); transition: color 0.15s, background 0.15s; }
.site-nav a:hover { color: var(--fg); background: rgba(0, 212, 170, 0.1); }
.site-nav a[aria-current="page"] { color: var(--fg); background: rgba(0, 212, 170, 0.2); border-radius: var(--radius); }
.chrome-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 0.75rem 1.2rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* page scaffolding */
.page { width: min(76rem, 100%); margin-inline: auto; padding: 3rem 1.4rem 4rem; flex: 1; }
.eyebrow { font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--accent); }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -0.02em; line-height: 1.15; margin: 0.6rem 0 1rem; font-weight: 700; }
.lede { color: var(--muted); max-width: 52rem; font-size: 1.05rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 3rem 0 1.2rem; display: flex; align-items: center; gap: 0.8rem; }
h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
h2:first-of-type { margin-top: 2.5rem; }
.prose { color: var(--muted); max-width: 54rem; font-size: 0.97rem; }
.prose b { color: var(--fg); font-weight: 600; }
.prose p + p { margin-top: 0.9rem; }
.prose ul { margin: 0.8rem 0 0.3rem 1.2rem; display: grid; gap: 0.4rem; font-size: 0.94rem; }
.prose li b { font-weight: 600; }

/* chips (buttons) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--panel);
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.08s;
}
.chip:active { transform: translateY(1px); }
.chip:hover { color: var(--fg); border-color: rgba(255, 255, 255, 0.2); }
.chip[aria-pressed="true"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

/* filter row */
.chips { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.countline { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); margin-top: 0.85rem; }

/* catalog cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; margin-top: 0.5rem; }
.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: transform 0.2s, border-color 0.2s;
}
.card:hover { transform: translateY(-3px); border-color: rgba(255, 255, 255, 0.15); }
.card h3 { font-size: 1.1rem; font-weight: 600; line-height: 1.3; }
.card h3 .cat { color: var(--muted); font-size: 0.78rem; font-family: var(--font-mono); font-weight: 400; margin-left: 0.5rem; }
.type-badge {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.t-galaxy { color: #9db4ff; border-color: rgba(157, 180, 255, 0.4); }
.t-nebula { color: #f0a6ff; border-color: rgba(240, 166, 255, 0.4); }
.t-cluster { color: #7fe3c0; border-color: rgba(127, 227, 192, 0.4); }
.t-star { color: #ffd98a; border-color: rgba(255, 217, 138, 0.4); }
.card .blurb { font-size: 0.88rem; color: var(--muted); }
.facts { display: grid; gap: 0.2rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.facts > div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.78rem; }
.facts dt { color: var(--muted); }
.facts dd { font-family: var(--font-mono); font-size: 0.75rem; text-align: right; }
details.more { border-top: 1px solid var(--line); padding-top: 0.6rem; margin-top: auto; }
details.more summary { cursor: pointer; font-size: 0.8rem; color: var(--accent); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+ "; font-family: var(--font-mono); }
details[open].more summary::before { content: "− "; }
details.more p { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.hidden { display: none !important; }

/* search input */
.search-input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  color: var(--fg);
  font-size: 0.9rem;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* observatory (index) */
body { overflow: auto; }
.ui-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; }
.ui-top > div:first-child { max-width: 38rem; }
.top-nav { display: flex; gap: 0.5rem; pointer-events: auto; }
.top-nav a {
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.35rem 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(8px);
  transition: color 0.15s, border-color 0.15s;
}
.top-nav a:hover { color: var(--fg); border-color: rgba(255, 255, 255, 0.22); }
.ui h1 { font-size: clamp(2rem, 5vw, 3.5rem); margin: 0.4rem 0 0; font-weight: 500; letter-spacing: -0.02em; }
.hint { color: var(--muted); font-size: 0.9rem; margin-top: 0.4rem; }
.stats { display: flex; gap: 1.5rem; margin-top: 1.5rem; font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); }
.stats b { color: var(--accent); font-weight: 600; }
.toolbar {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  align-items: center;
  padding: 0.65rem;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  background: rgba(12, 10, 8, 0.6);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.glab { font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); padding: 0 0.6rem; }
.denval { font-family: var(--font-mono); font-size: 0.8rem; width: 2.8rem; text-align: center; }

@media (max-width: 640px) {
  .ui { padding: 1rem; }
  .ui-top { flex-direction: column; }
  .ui h1 { font-size: 1.6rem; }
  .stats { gap: 1rem; }
  .toolbar { gap: 0.5rem; padding: 0.55rem; }
  .glab { display: none; }
  .page { padding: 2.5rem 1.2rem 3.2rem; }
  .logbook-card { padding: 1rem; }
}

/* sky map */
.map-wrap { position: relative; width: min(690px, 100%); margin: 0.5rem auto 0; }
#map { display: block; width: 100%; margin-inline: auto; touch-action: none; }
.compass { position: absolute; inset: 16px; pointer-events: none; font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.22em; color: var(--muted); opacity: 0.7; }
.compass span { position: absolute; }
.c-n { top: 2px; left: 50%; transform: translateX(-50%); }
.c-s { bottom: 2px; left: 50%; transform: translateX(-50%); }
.c-e { right: 2px; top: 50%; transform: translateY(-50%); }
.c-w { left: 2px; top: 50%; transform: translateY(-50%); }
.hovercard {
  position: absolute;
  z-index: 2;
  min-width: 16rem;
  max-width: 20rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 17, 28, 0.9);
  backdrop-filter: blur(12px);
  pointer-events: none;
}
.hovercard.hidden { display: none; }
.hover-name { font-weight: 600; font-size: 0.95rem; }
.hover-sub { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); margin-top: 0.3rem; }

/* logbook overlay */
.logbook-overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.7); padding: 1.5rem; pointer-events: none; }
.logbook-overlay.show { display: flex; pointer-events: auto; }
.logbook-card { pointer-events: auto; background: rgba(14, 14, 14, 0.92); border: 1px solid var(--line); border-radius: var(--sidebar-radius); padding: 1.5rem; width: min(580px, 94vw); box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.logbook-overlay h2 { margin-bottom: 0.5rem; }
.logbook-overlay .lede { color: var(--muted); margin-bottom: 1.2rem; }

/* star trails and night mode overlay */
.status { position: fixed; left: 1.6rem; bottom: 6.4rem; z-index: 2; font-family: var(--font-mono); font-size: 0.84rem; letter-spacing: 0.04em; color: var(--muted); text-shadow: -1px -1px 0 rgba(0,0,0,0.8), 1px -1px 0 rgba(0,0,0,0.8), -1px 1px 0 rgba(0,0,0,0.8), 1px 1px 0 rgba(0,0,0,0.8), 0 0 12px rgba(0,0,0,0.6); }
.status .status-label { color: var(--accent); }
.status b { color: var(--fg); font-weight: 600; }

#trails { position: fixed; inset: 0; pointer-events: none; z-index: 0; mix-blend-mode: screen; }
#trails.hidden { display: none; }
.night-dial { position: fixed; bottom: 1.6rem; right: 1.6rem; z-index: 3; display: inline-flex; align-items: center; gap: 0.7rem; padding: 0.6rem 1rem; background: rgba(14, 14, 14, 0.75); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(12px); }
.night-dial .chip.icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; }
.trail-label { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); letter-spacing: 0.17em; text-transform: uppercase; }
.trail-label b { color: var(--accent); font-weight: 600; }

/* constellation cards */
.constellation-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); gap: 1.5rem; margin-top: 0.8rem; }
.constellation-card { border: 1px solid var(--line); background: linear-gradient(180deg, rgba(20,18,16,0.9),rgba(8,8,8,0.95)); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; transition: border-color 0.2s, transform 0.2s; box-shadow: 0 4px 20px rgba(0,0,0,0.4); backface-visibility: hidden; }
.constellation-card:hover { border-color: rgba(255, 255, 255, 0.18); transform: translateY(-3px); box-shadow: 0 6px 30px rgba(0,0,0,0.5); }
.const-svg { width: 100%; height: auto; border-radius: 10px; display: block; background: radial-gradient(ellipse at 50% 40%,rgba(20,22,28,1),rgba(8,6,6,1)); aspect-ratio: 1; }

/* loading state */
.loading { text-align: center; padding: 4rem; color: var(--muted); }

/* focus visible improvements */
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* night vision mode (red light) */
body.night-vision {
  --bg: #120000;
  --bg2: #220000;
  --fg: #ff5555;
  --muted: #883333;
  --line: rgba(255, 0, 0, 0.2);
  --panel: rgba(60, 0, 0, 0.4);
  --accent: #ff0000;
  --accent2: #aa0000;
}
body.night-vision #sky, 
body.night-vision #trails, 
body.night-vision .moon-canvas, 
body.night-vision #wheel-canvas, 
body.night-vision canvas {
  filter: grayscale(1) sepia(1) hue-rotate(-50deg) saturate(4) brightness(0.8);
}
.nv-toggle {
  margin-right: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* finder widget */
details.finder-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; max-width: 36rem; margin: 1rem auto; }
details.finder-panel summary { cursor: pointer; padding: 0.75rem 1rem; font-size: 0.9rem; color: var(--fg); list-style: none; }
details.finder-panel summary::-webkit-details-marker { display: none; }
.finder-content { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.75rem; }
.finder-info { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.finder-content label { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--muted); }
.finder-content input[type="month"] { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.7rem; font-family: inherit; font-size: 0.88rem; color: var(--fg); }
.finder-content input[type="month"]:focus { outline: none; border-color: var(--accent); }
.finder-results { margin-top: 0.35rem; font-size: 0.82rem; color: var(--muted); line-height: 1.6; max-height: 300px; overflow-y: auto; }
.finder-results > div { margin-bottom: 0.5rem; }
.finder-results .result-header { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.35rem; }
.finder-results .result-item { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.finder-results .result-item:last-child { border-bottom: none; }
.finder-results .result-name { color: var(--fg); font-weight: 500; font-size: 0.86rem; }
.finder-results .result-detail { text-align: right; font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); line-height: 1.35; }

/* discovery toast */
.discovery-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(14, 14, 14, 0.95);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--fg);
  z-index: 100;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  max-width: min(400px, 90vw);
}
.discovery-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.discovery-toast .toast-icon { color: var(--accent); font-size: 1.2rem; }
.discovery-toast .toast-content h4 { margin: 0; font-size: 0.9rem; color: var(--fg); }
.discovery-toast .toast-sub { color: var(--muted); font-size: 0.75rem; }

/* telescope view */
#telescope-view {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(10px);
}
.telescope-container {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 2rem;
  max-width: 1100px;
  width: 95vw;
  align-items: center;
}
.telescope-eyepiece {
  position: relative;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  border: 20px solid #1a1a1a;
  box-shadow: 0 0 0 10px #111, 0 0 50px rgba(0,0,0,0.5) inset;
  overflow: hidden;
  background: #000;
  margin: auto;
}
#telescope-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.telescope-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: var(--fg);
}
.telescope-info h2 { margin: 0; color: var(--accent); }
.telescope-info .prose { font-size: 1rem; color: #c0c0c0; }
.telescope-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 100px rgba(0,0,0,0.9);
}

@media (max-width: 800px) {
  .telescope-container {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .telescope-info {
    align-items: center;
  }
  .telescope-eyepiece {
    width: 300px;
    height: 300px;
    border-width: 12px;
  }
}
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--accent);
  color: var(--on-accent, #fff);
  padding: 0.3rem 1rem;
  z-index: 1000;
  transform: translateY(-100%);
  transition: transform 0.3s;
  font-size: 0.9rem;
  text-decoration: none;
}
.skip-link:focus {
  transform: translateY(0);
}

.moon-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  width: min(360px, 90vw);
  margin: 1rem auto;
}
.moon-content { padding: 0; }

.moon-text { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); text-align: center; margin-top: 0.4rem; }
