/* cosmos.css — "The Cosmos" view: your learning journey as a living galaxy.
   Canvas does the heavy lifting; this styles the floating UI that overlays it
   (legend, time scrubber, the memory card, the core readout). Theme-token based
   so it tracks light/dark automatically. */

.cosmos-view { position: relative; }

/* Cosmos is ALWAYS dark — a bright galaxy on a light surface looks bad. Re-declare
   the theme tokens locally so the stage + all token-based overlay UI stay dark even
   in light mode (the canvas star colours are hardcoded in JS, already dark-native). */
.cosmos-view{
  --ink:#08080f; --panel:#17172a; --panel2:#20203a;
  --line:rgba(255,255,255,.11); --line2:rgba(255,255,255,.20);
  --text:#ECECF4; --muted:#aeaecb; --faint:#8a8aa8;
  --violet:#7c5cff; --cyan:#22d3ee; --lime:#86ff6b; --amber:#f5b544; --rose:#ff6b8b;
}

/* Full-screen: CSS-driven so it works on every device (incl. iPhone, where the
   native Fullscreen API only allows <video>). JS also requests native fullscreen +
   landscape lock where supported; this class guarantees the stage fills the screen. */
.cosmos-stage.cosmos-fs{
  position: fixed; inset: 0; width: 100vw; height: 100dvh;
  min-height: 0; border-radius: 0; border: none; z-index: 9999;
}
.cosmos-fs-btn{
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line); color: var(--text); cursor: pointer;
  display: grid; place-items: center; transition: border-color .15s, transform .12s;
}
.cosmos-fs-btn:hover{ border-color: var(--line2); transform: scale(1.06); }
.cosmos-fs-btn svg{ width: 17px; height: 17px; }

/* The stage fills the main content area; canvas paints the universe. */
.cosmos-stage {
  position: relative;
  width: 100%;
  height: calc(100dvh - 150px);
  min-height: 460px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(124,92,255,.10), transparent 60%),
    radial-gradient(90% 70% at 80% 90%, rgba(34,211,238,.08), transparent 55%),
    var(--ink);
  cursor: grab;
  touch-action: none;
}
.cosmos-stage.dragging { cursor: grabbing; }
.cosmos-canvas { position: absolute; inset: 0; display: block; }

/* Loading / empty veil */
.cosmos-veil {
  position: absolute; inset: 0; display: grid; place-items: center;
  text-align: center; padding: 30px; z-index: 6; pointer-events: none;
}
.cosmos-veil .cv-inner { max-width: 380px; pointer-events: auto; }
.cosmos-veil .cv-orb {
  width: 70px; height: 70px; margin: 0 auto 18px; border-radius: 50%;
  background: var(--grad);
  box-shadow: 0 0 50px 6px rgba(124,92,255,.55), 0 0 120px 20px rgba(34,211,238,.25);
  animation: cosmosPulse 2.6s ease-in-out infinite;
}
.cosmos-veil h3 {
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800;
  font-size: 22px; letter-spacing: -.4px; margin: 0 0 8px;
}
.cosmos-veil p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 18px; }
@keyframes cosmosPulse {
  0%,100% { transform: scale(1);   opacity: .9; }
  50%     { transform: scale(1.12); opacity: 1; }
}

/* ── Header strip: title + live stats ── */
.cosmos-head {
  position: absolute; top: 16px; left: 18px; right: 18px; z-index: 5;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; pointer-events: none;
}
.cosmos-head .ch-title {
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800;
  font-size: 19px; letter-spacing: -.4px; text-shadow: 0 2px 18px rgba(0,0,0,.6);
}
.cosmos-head .ch-sub { font-size: 12px; color: var(--muted); margin-top: 2px; text-shadow: 0 1px 10px rgba(0,0,0,.6); }
.cosmos-stats { display: flex; gap: 8px; pointer-events: auto; }
.cosmos-stat {
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 7px 13px; text-align: center; min-width: 62px;
}
.cosmos-stat b {
  display: block; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800;
  font-size: 18px; line-height: 1; color: var(--text);
}
.cosmos-stat span { font-size: 10px; color: var(--faint); letter-spacing: .4px; text-transform: uppercase; }

/* ── Legend (constellation toggles) ── */
.cosmos-legend {
  position: absolute; left: 18px; bottom: 78px; z-index: 5;
  display: flex; flex-direction: column; gap: 6px; max-width: 210px;
}
.cosmos-leg-btn {
  display: flex; align-items: center; gap: 9px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 11px;
  padding: 7px 11px; cursor: pointer; font: inherit; font-size: 12.5px;
  color: var(--text); transition: border-color .15s, opacity .15s, transform .12s;
  text-align: left;
}
.cosmos-leg-btn:hover { transform: translateX(3px); border-color: var(--line2); }
.cosmos-leg-btn.off { opacity: .38; }
.cosmos-leg-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 10px 1px currentColor; }
.cosmos-leg-name { flex: 1; font-weight: 600; }
.cosmos-leg-count { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--faint); }

/* ── Time scrubber (the Big Bang replay) ── */
.cosmos-time {
  position: absolute; left: 18px; right: 18px; bottom: 16px; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--panel) 74%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px;
}
.cosmos-play {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad); border: none; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 18px rgba(124,92,255,.45); transition: transform .12s;
}
.cosmos-play:hover { transform: scale(1.07); }
.cosmos-play svg { width: 17px; height: 17px; }
.cosmos-track-wrap { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.cosmos-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 5px;
  border-radius: 4px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, var(--violet) 0%, var(--cyan) var(--fill,100%), var(--line2) var(--fill,100%));
}
.cosmos-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--violet); cursor: pointer;
  box-shadow: 0 0 12px 2px rgba(124,92,255,.6);
}
.cosmos-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  border: 3px solid var(--violet); cursor: pointer;
}
.cosmos-time-label {
  display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; color: var(--faint);
}
.cosmos-time-now { color: var(--cyan); font-weight: 700; }

/* ── Hover tooltip ── */
.cosmos-tip {
  position: absolute; z-index: 7; pointer-events: none; opacity: 0;
  transform: translate(-50%, -120%); transition: opacity .12s;
  background: color-mix(in srgb, var(--panel2) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line2); border-radius: 10px; padding: 7px 11px;
  font-size: 12px; white-space: nowrap; max-width: 240px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.cosmos-tip.show { opacity: 1; }
.cosmos-tip b { font-weight: 700; }
.cosmos-tip .ct-meta { color: var(--faint); font-size: 10.5px; margin-top: 2px; }

/* ── Memory card (on star click) ── */
.cosmos-card {
  position: absolute; right: 18px; bottom: 78px; z-index: 8; width: 270px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line2); border-radius: 16px; padding: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  transform: translateY(14px) scale(.97); opacity: 0; pointer-events: none;
  transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .22s;
}
.cosmos-card.show { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }
.cosmos-card .cc-glyph {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; margin-bottom: 12px; box-shadow: 0 0 24px 1px currentColor;
}
.cosmos-card .cc-cons { font-size: 11px; letter-spacing: .5px; text-transform: uppercase; font-weight: 700; margin-bottom: 4px; }
.cosmos-card .cc-label { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 17px; line-height: 1.25; }
.cosmos-card .cc-title { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.4; }
.cosmos-card .cc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.cosmos-card .cc-when { font-size: 11.5px; color: var(--faint); }
.cosmos-card .cc-xp { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 13px; color: var(--cyan); }
.cosmos-card .cc-close {
  position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; border-radius: 7px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; display: grid; place-items: center; font-size: 14px; line-height: 1;
}
.cosmos-card .cc-close:hover { color: var(--text); }

/* Little reset/recenter hint */
.cosmos-hint {
  position: absolute; top: 64px; right: 18px; z-index: 5;
  font-size: 11px; color: var(--faint); text-shadow: 0 1px 8px rgba(0,0,0,.7);
  pointer-events: none; text-align: right;
}
.cosmos-recenter {
  pointer-events: auto; margin-top: 8px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  backdrop-filter: blur(10px); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 12px; cursor: pointer; font: inherit;
  font-size: 12px; color: var(--text); transition: border-color .15s;
}
.cosmos-recenter:hover { border-color: var(--line2); }

/* ── Mobile ── */
@media (max-width: 820px) {
  .cosmos-stage { height: calc(100dvh - 200px); border-radius: 16px; }
  .cosmos-legend { display: none; }      /* legend hidden; tap stars instead */
  .cosmos-card { left: 14px; right: 14px; width: auto; bottom: 84px; }
  .cosmos-head .ch-title { font-size: 16px; }
  .cosmos-stat { min-width: 52px; padding: 6px 9px; }
  .cosmos-stat b { font-size: 15px; }
}
