/* Planetarium mode — /constellations */

:root {
  --pl-sky-0: #070c1f;
  --pl-sky-1: #16244d;
  --pl-star: #f6f1e3;
  --pl-gold: #ffd166;
  --pl-teal: #8fe3d9;
  --pl-glass: rgba(12, 18, 40, 0.55);
  --pl-glass-border: rgba(246, 241, 227, 0.14);
  --pl-serif: "Cormorant SC", "Palatino Linotype", Palatino, serif;
  --pl-sans: "Nunito", "Segoe UI", sans-serif;
}

body:has(.planetarium) {
  background: var(--pl-sky-0);
  overflow: hidden;
}
body:has(.planetarium) > nav {
  position: relative;
  z-index: 40;
  background: rgba(7, 12, 31, 0.92);
  border-bottom: 1px solid var(--pl-glass-border);
}
body:has(.planetarium) > nav a { color: var(--pl-star); }
body:has(.planetarium) > main {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: calc(100dvh - var(--nav-height, 48px));
}
body:has(.planetarium) > footer { display: none; }

.planetarium {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100dvh - var(--nav-height, 48px));
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 70% at 50% 38%, #1a2a58 0%, transparent 55%),
    linear-gradient(168deg, #050914 0%, #0c1530 42%, #152448 78%, #0a1228 100%);
  font-family: var(--pl-sans);
  color: var(--pl-star);
  -webkit-tap-highlight-color: transparent;
}

.pl-stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.pl-quiz-dock {
  flex: 0 0 auto;
  padding: 0.65rem 1rem max(0.65rem, env(safe-area-inset-bottom));
  background: rgba(7, 12, 31, 0.96);
  border-top: 1px solid rgba(246, 241, 227, 0.08);
}
.planetarium[data-phase="complete"] .pl-quiz-dock {
  display: none;
}

.pl-bg-canvas {
  position: absolute;
  inset: -24px;
  width: calc(100% + 48px);
  height: calc(100% + 48px);
  z-index: 0;
  pointer-events: none;
}

.pl-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 95% 80% at 50% 44%, transparent 42%, rgba(3, 5, 14, 0.35) 78%, rgba(2, 4, 12, 0.72) 100%);
}

.pl-peek-dim {
  display: none;
}

.pl-sky {
  position: absolute;
  inset: 0;
  z-index: 1;
  touch-action: none;
  cursor: grab;
}
.pl-sky.is-dragging { cursor: grabbing; }
.pl-sky-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* ---- Planisphere dome ---- */

.pl-dome-disc {
  fill: url(#pl-dome-grad);
  pointer-events: none;
}
.pl-dome-grid {
  fill: none;
  stroke: rgba(180, 200, 255, 0.08);
  stroke-width: 1.2;
  stroke-dasharray: 4 10;
  pointer-events: none;
}
.pl-dome-rim {
  fill: none;
  stroke: rgba(246, 241, 227, 0.32);
  stroke-width: 2.5;
  pointer-events: none;
}
.pl-compass-tick {
  fill: rgba(8, 12, 28, 0.95);
  stroke: rgba(255, 209, 102, 0.9);
  stroke-width: 1.6;
  pointer-events: none;
}
.pl-compass {
  fill: rgba(255, 209, 102, 0.95);
  font-family: var(--pl-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  pointer-events: none;
  user-select: none;
}

/* ---- Constellations ---- */

.pl-const {
  opacity: 0.82;
  cursor: pointer;
  transition: opacity 0.35s ease;
}
.planetarium.is-peeking .pl-const-layer > .pl-const {
  opacity: 0.18;
}
.planetarium.is-peeking .pl-dome-disc,
.planetarium.is-peeking .pl-dome-grid,
.planetarium.is-peeking .pl-dome-rim,
.planetarium.is-peeking .pl-compass,
.planetarium.is-peeking .pl-compass-tick {
  opacity: 0.35;
  transition: opacity 0.35s ease;
}
.pl-const .pl-scale {
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
.pl-const .pl-hit {
  fill: transparent;
  pointer-events: all;
}
.pl-const .pl-lines {
  fill: none;
  stroke: rgba(186, 198, 255, 0.55);
  stroke-width: var(--pl-stroke, 1.4);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pl-const .pl-star {
  pointer-events: none;
  fill: url(#pl-star-core);
}
.pl-const .pl-brightest {
  fill: #fff8e8;
}
.pl-const .pl-label {
  fill: var(--pl-teal);
  font-family: var(--pl-serif);
  font-size: var(--pl-label-size, 18px);
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
}
.pl-const .pl-symbol-float {
  font-size: var(--pl-symbol-size, 36px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.pl-const.is-peek:not(.is-active) { opacity: 1; }
.pl-const.is-peek .pl-star,
.pl-const.is-peek .pl-brightest {
  fill: #dffef8;
}
.pl-const.is-peek:not(.is-active) .pl-lines {
  stroke: rgba(246, 241, 227, 0.88);
  stroke-width: calc(var(--pl-stroke, 1.4) * 1.35);
}
/* Name lives in the HTML peek card — hide the SVG label so it doesn't cover stars */
.pl-const.is-peek .pl-label,
.pl-const.is-peek .pl-symbol-float {
  opacity: 0 !important;
  animation: none !important;
}

.pl-const.is-active { opacity: 1; }
.pl-const.is-active .pl-star,
.pl-const.is-active .pl-brightest {
  fill: var(--pl-gold);
}
.pl-const.is-active .pl-lines {
  stroke: var(--pl-gold);
  stroke-width: calc(var(--pl-stroke, 1.4) * 1.35);
}
.pl-const.is-active .pl-lines.pl-draw {
  stroke-dasharray: var(--pl-len, 200);
  stroke-dashoffset: var(--pl-len, 200);
  animation: pl-draw-line 1.1s ease forwards;
}
.planetarium[data-mode="brightest"] .pl-const.is-active .pl-brightest {
  animation: pl-pulse 1.2s ease-in-out infinite;
}
.planetarium[data-mode="symbol"] .pl-const.is-active .pl-symbol-float {
  opacity: 1;
  animation: pl-float-symbol 2.8s ease-in-out infinite;
}

.pl-const.is-lit { opacity: 1; }
.pl-const.is-lit .pl-star,
.pl-const.is-lit .pl-brightest {
  fill: var(--pl-teal);
}
.pl-const.is-lit .pl-lines {
  stroke: rgba(143, 227, 217, 0.9);
  stroke-width: calc(var(--pl-stroke, 1.4) * 1.1);
  stroke-dasharray: none;
  stroke-dashoffset: 0;
  animation: none;
}
.pl-const.is-lit .pl-label { opacity: 1; }
.pl-const.is-lit .pl-symbol-float { opacity: 0; animation: none; }
.pl-const.is-lit .pl-brightest { animation: none; }

.pl-const.is-dim { opacity: 0.5; }
.pl-const.is-dim .pl-star,
.pl-const.is-dim .pl-brightest {
  fill: rgba(143, 227, 217, 0.5);
}
.pl-const.is-dim .pl-lines {
  stroke: rgba(143, 227, 217, 0.32);
  stroke-dasharray: none;
  stroke-dashoffset: 0;
  animation: none;
}
.pl-const.is-dim .pl-label {
  opacity: 0.7;
  fill: rgba(246, 241, 227, 0.55);
}

@keyframes pl-draw-line {
  to { stroke-dashoffset: 0; }
}
@keyframes pl-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: 0.92; }
}
@keyframes pl-float-symbol {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes pl-toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes pl-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---- HUD ---- */

.pl-hud {
  position: absolute;
  z-index: 10;
  pointer-events: none;
}
.pl-hud > * { pointer-events: auto; }

.pl-hud-glass {
  background: rgba(12, 18, 40, 0.82);
  border: 1px solid var(--pl-glass-border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.pl-hud-top {
  top: max(0.65rem, env(safe-area-inset-top));
  left: max(0.65rem, env(safe-area-inset-left));
  right: max(0.65rem, env(safe-area-inset-right));
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.65rem;
  justify-content: space-between;
}

.pl-select-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  max-width: min(100%, 16rem);
}
.pl-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.55rem 0.3rem 0.45rem;
}
.pl-select {
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--pl-star);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 1.5rem 0.35rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23f6f1e3' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.35rem center;
  background-size: 10px 6px;
}
.pl-select:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(143, 227, 217, 0.45);
}
.pl-select option {
  color: #111;
  background: #fff;
}
.pl-select-wrap .pl-pts {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--pl-gold);
  font-size: 0.82rem;
  min-width: 1.25rem;
  flex: 0 0 auto;
}
.pl-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pl-hud-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.pl-streak,
.pl-lit {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.pl-lit { color: var(--pl-teal); }
.pl-streak-fire { font-size: 0.95rem; }

/* ---- Question + answers ---- */

.pl-quiz-dock .pl-hud {
  position: static;
  z-index: auto;
}

.pl-question-wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 0 0.35rem;
  text-align: center;
  pointer-events: none;
  background: none;
}
.pl-question {
  margin: 0;
  font-family: var(--pl-serif);
  font-size: clamp(1.15rem, 3.8vw, 1.55rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75);
}
.pl-progress {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(246, 241, 227, 0.55);
}

.pl-answers {
  position: static;
  transform: none;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  pointer-events: none;
}
.pl-answers > * { pointer-events: auto; }
.pl-chip {
  flex: 1 1 calc(33.333% - 0.45rem);
  min-width: 7.5rem;
  max-width: 12rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--pl-glass-border);
  background: var(--pl-glass);
  color: var(--pl-star);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.pl-chip:hover:not(:disabled) {
  border-color: rgba(255, 209, 102, 0.4);
  background: rgba(22, 36, 77, 0.75);
  transform: translateY(-1px);
}
.pl-chip:disabled { cursor: default; }
.pl-chip.is-correct {
  background: rgba(52, 211, 153, 0.28);
  border-color: #34d399;
  color: #bbf7d0;
}
.pl-chip.is-wrong {
  background: rgba(248, 113, 113, 0.22);
  border-color: #f87171;
  animation: pl-shake 0.4s ease;
}
.pl-chip.is-reveal {
  border-color: var(--pl-gold);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.35);
}

.pl-toast {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 20;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.18);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: var(--pl-gold);
  font-weight: 800;
  font-size: 1.05rem;
  pointer-events: none;
  animation: pl-toast-in 0.35s ease;
}
.pl-toast.is-error {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.55);
  color: #fca5a5;
  font-size: 0.9rem;
}

/* ---- Peek card ---- */

.pl-peek {
  position: absolute;
  z-index: 18;
  min-width: 10rem;
  max-width: min(16rem, 70vw);
  padding: 0.7rem 0.85rem 0.8rem;
  border-radius: 12px;
  background: rgba(10, 16, 36, 0.82);
  border: 1px solid rgba(246, 241, 227, 0.18);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transform: translate(-50%, -100%);
}
.pl-peek[hidden] { display: none !important; }
.pl-peek-name {
  margin: 0;
  font-family: var(--pl-serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--pl-star);
}
.pl-peek-meta {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--pl-gold);
}
.pl-peek-meta[hidden] { display: none; }
.pl-peek-meaning {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: rgba(246, 241, 227, 0.62);
  line-height: 1.3;
}
.pl-peek-meaning[hidden] { display: none; }

.pl-brand {
  margin: 0 0 0.35rem;
  font-family: var(--pl-serif);
  font-size: clamp(2rem, 7vw, 2.75rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--pl-star);
  text-shadow: 0 0 40px rgba(255, 209, 102, 0.25);
}

/* ---- Sky complete ---- */

.pl-complete {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(7, 12, 31, 0.72);
}
.pl-complete[hidden] { display: none !important; }
.pl-complete-panel {
  width: min(100%, 400px);
  text-align: center;
  padding: 1.75rem 1.5rem;
  border-radius: 18px;
  border: 1px solid var(--pl-glass-border);
  background: var(--pl-glass);
}
.pl-complete-title {
  margin: 0.25rem 0 0.75rem;
  font-family: var(--pl-serif);
  font-size: 1.5rem;
}
.pl-complete-score {
  margin: 0 0 1.25rem;
  color: rgba(246, 241, 227, 0.7);
}
.pl-complete-score strong {
  color: var(--pl-gold);
  font-size: 1.35rem;
}
.pl-complete-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}

.pl-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--pl-gold);
  color: #1a1205;
}
.pl-btn-ghost {
  background: transparent;
  color: var(--pl-star);
  border: 1px solid var(--pl-glass-border);
}

/* ---- Extras drawer ---- */

.pl-extras-btn {
  position: absolute;
  z-index: 15;
  right: max(0.65rem, env(safe-area-inset-right));
  bottom: max(0.65rem, env(safe-area-inset-bottom));
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--pl-glass-border);
  border-radius: 999px;
  color: var(--pl-gold);
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.pl-extras {
  position: absolute;
  z-index: 35;
  top: max(0.5rem, env(safe-area-inset-top));
  right: max(0.5rem, env(safe-area-inset-right));
  bottom: max(0.5rem, env(safe-area-inset-bottom));
  width: min(100% - 1rem, 360px);
  overflow: auto;
  padding: 1.15rem 1.1rem 1.5rem;
  border-radius: 16px;
  background: rgba(7, 12, 31, 0.92);
  border: 1px solid var(--pl-glass-border);
}
.pl-extras[hidden] { display: none !important; }
.pl-extras h2 {
  margin: 1rem 0 0.55rem;
  font-family: var(--pl-serif);
  font-size: 1.15rem;
  font-weight: 600;
}
.pl-extras h2:first-of-type { margin-top: 0.25rem; }
.pl-extras-close {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  border: 0;
  background: transparent;
  color: var(--pl-star);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.pl-lb { display: flex; flex-direction: column; gap: 0.4rem; }
.pl-lb-row {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.9rem;
}
.pl-lb-row.current { outline: 1px solid rgba(255, 209, 102, 0.4); }
.pl-badges { display: flex; flex-direction: column; gap: 0.5rem; }
.pl-badge {
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
}
.pl-badge-rank { color: rgba(246, 241, 227, 0.5); }
.pl-badge-icons { margin-top: 0.25rem; letter-spacing: 0.05em; word-break: break-all; }
.pl-awards-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 160px;
}
.pl-awards-nav {
  border: 0;
  background: transparent;
  color: var(--pl-star);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
}
#pl-awards-img {
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
  cursor: pointer;
  border-radius: 8px;
}
#pl-awards-none {
  margin: 0;
  color: rgba(246, 241, 227, 0.45);
  font-size: 0.85rem;
  text-align: center;
}

/* ---- Modals / lightbox ---- */

.pl-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 1rem;
}
.pl-modal[hidden] { display: none !important; }
.pl-modal-card {
  background: #fff;
  color: #111;
  padding: 1.5rem;
  border-radius: 12px;
  max-width: 700px;
  width: 90%;
  text-align: center;
}
.pl-modal-card img {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.pl-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
}
.pl-lightbox[hidden] { display: none !important; }
.pl-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}
.pl-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}
.pl-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 1rem;
}
.pl-lightbox-prev { left: 1%; }
.pl-lightbox-next { right: 1%; }

/* ---- Motion + mobile ---- */

@media (prefers-reduced-motion: reduce) {
  .pl-const .pl-scale { transition: none; }
  .pl-const .pl-lines.pl-draw,
  .planetarium[data-mode="brightest"] .pl-const.is-active .pl-brightest,
  .planetarium[data-mode="symbol"] .pl-const.is-active .pl-symbol-float,
  .pl-chip.is-wrong,
  .pl-toast {
    animation: none !important;
  }
  .pl-const .pl-lines.pl-draw { stroke-dashoffset: 0; }
}

@media (max-width: 640px) {
  .pl-select-stack { max-width: min(100%, 14rem); }
  .pl-select { font-size: 0.8rem; }
  .pl-chip {
    flex: 1 1 calc(50% - 0.45rem);
    font-size: 0.85rem;
    padding: 0.6rem 0.5rem;
  }
}
