@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Outfit:wght@400;500;600;700&display=swap");

/* ===================================================================
   COSMOS — shared stylesheet
   Organised as:  1 tokens · 2 base · 3 layout · 4 header · 5 hero
                  6 cards · 7 planets · 8 constellations · 9 moon
                  10 facts+quiz · 11 about · 12 footer · 13 responsive
   =================================================================== */

/* ---------- 1. DESIGN TOKENS ---------------------------------------
   Every colour and size lives here as a CSS variable. Change a value
   once and the whole site follows. This is the single most useful
   habit in CSS.                                                      */

:root {
  --bg:          #050308;
  --bg-soft:     #0c0814;
  --panel:       rgba(22, 14, 28, 0.58);
  --panel-solid: #140e1c;
  --line:        rgba(232, 196, 122, 0.16);
  --line-bright: rgba(232, 196, 122, 0.42);

  --text:        #f4efe6;
  --muted:       #b7a99a;

  --purple:      #c4a1ff;
  --blue:        #7eb8ff;
  --teal:        #e8c47a;
  --pink:        #ff8a6a;
  --gold:        #e8c47a;

  --grad-cosmic: linear-gradient(120deg, #ff8a6a 0%, #e8c47a 42%, #c4a1ff 100%);
  --grad-panel:  linear-gradient(165deg, rgba(48, 28, 38, .72), rgba(12, 8, 18, .72));

  --radius:      22px;
  --radius-sm:   12px;
  --maxw:        1180px;

  --shadow:      0 22px 55px rgba(0, 0, 0, 0.55);
  --glow:        0 0 50px rgba(232, 196, 122, 0.18);

  --ease:        cubic-bezier(.22, 1, .36, 1);

  --font:        "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-display:"Instrument Serif", Georgia, "Times New Roman", serif;
  --font-myth:   "Instrument Serif", Georgia, "Times New Roman", serif;
}

/* ---------- 2. BASE ------------------------------------------------ */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Nebula clouds — three huge, very soft radial gradients painted behind
   everything. Fixed, so they don't move when the page scrolls.        */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(80ch 60ch at 8% 0%,  rgba(180, 60, 40, 0.28), transparent 58%),
    radial-gradient(70ch 55ch at 92% 12%, rgba(90, 40, 140, 0.32), transparent 60%),
    radial-gradient(80ch 70ch at 50% 100%, rgba(232, 196, 122, 0.08), transparent 55%),
    var(--bg);
}

/* The animated starfield canvas is painted by js/starfield.js */
#starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

h1, h2, h3, h4 {
  line-height: 1.12;
  margin: 0 0 .55em;
  font-weight: 400;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}
h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); font-style: italic; }
h2 { font-size: clamp(1.85rem, 3.8vw, 2.7rem); }
h3 { font-size: 1.22rem; }

p { margin: 0 0 1.05em; color: var(--muted); }

a { color: var(--blue); text-decoration: none; transition: color .2s; }
a:hover { color: var(--teal); }

/* Gradient text — used on big headings */
.grad {
  background: var(--grad-cosmic);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Visible keyboard focus. Never delete this: it's how people who
   navigate by Tab know where they are. */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Screen-reader-only text */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 3. LAYOUT ---------------------------------------------- */
.wrap {
  width: min(100% - 2.4rem, var(--maxw));
  margin-inline: auto;
}

section { padding: clamp(3rem, 7vw, 5.5rem) 0; }

.section-head { text-align: center; max-width: 60ch; margin: 0 auto 2.8rem; }
.section-head p { font-size: 1.03rem; }

.eyebrow {
  display: inline-block;
  font-size: .74rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: .7rem;
  font-weight: 600;
}

/* Fade-and-rise on scroll, switched on by js/main.js */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.reveal.visible { opacity: 1; transform: none; }

/* ---------- 4. HEADER / NAV ---------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(18px) saturate(1.2);
  background: rgba(5, 3, 8, 0.62);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 0;
  position: relative;
}
.logo {
  display: flex; align-items: center; gap: .6rem;
  font-family: var(--font-display);
  font-weight: 400; font-size: 1.28rem; font-style: italic;
  color: var(--text); letter-spacing: .06em;
}
.logo:hover { color: var(--text); }
.logo-mark {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--grad-cosmic);
  box-shadow: 0 0 18px rgba(167, 139, 250, .75);
  position: relative; flex: none;
}
/* little orbiting dot on the logo */
.logo-mark::after {
  content: "";
  position: absolute; inset: -6px;
  border: 1px solid rgba(180, 200, 255, .45);
  border-radius: 50%;
  transform: rotate(-22deg) scaleY(.42);
}

.nav-links { display: flex; gap: .3rem; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  display: block;
  padding: .5rem .85rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: .93rem;
  font-weight: 500;
  transition: color .2s, background .2s;
}
.nav-links a:hover { color: var(--text); background: rgba(120, 140, 255, .1); }
.nav-links a.active {
  color: var(--text);
  background: rgba(120, 140, 255, .17);
  box-shadow: inset 0 0 0 1px var(--line-bright);
}

.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--line);
  color: var(--text); border-radius: 10px;
  width: 42px; height: 38px; cursor: pointer;
  font-size: 1.1rem; line-height: 1;
}

/* ---------- 5. HERO ------------------------------------------------- */
.hero {
  position: relative;
  min-height: min(88vh, 780px);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4rem 0 3rem;
}
.hero h1 { margin-bottom: .3em; }
.hero .lede {
  font-size: clamp(1.02rem, 2vw, 1.22rem);
  max-width: 56ch;
  margin: 0 auto 2rem;
}

.btn-row { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: .78rem 1.6rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .96rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s, background .25s;
}
.btn-primary {
  background: var(--grad-cosmic);
  color: #07091b;
  box-shadow: 0 10px 30px rgba(120, 110, 255, .35);
}
.btn-primary:hover {
  color: #07091b;
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(120, 110, 255, .5);
}
.btn-ghost {
  background: rgba(255, 255, 255, .04);
  border-color: var(--line-bright);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .09); color: var(--text); transform: translateY(-3px); }

/* Slowly rotating ring behind the hero title */
.hero-orbit {
  position: absolute;
  width: min(72vw, 560px); aspect-ratio: 1;
  border: 1px solid rgba(150, 170, 255, .13);
  border-radius: 50%;
  z-index: -1;
  animation: spin 60s linear infinite;
}
.hero-orbit::before,
.hero-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px var(--gold);
  width: 9px; height: 9px;
}
.hero-orbit::before { top: -5px; left: 50%; }
.hero-orbit::after {
  bottom: -4px; left: 30%;
  width: 6px; height: 6px;
  background: var(--pink); box-shadow: 0 0 12px var(--pink);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Rotating "did you know" line under the hero */
.fact-ticker {
  margin-top: 2.6rem;
  min-height: 3.2em;
  font-size: .96rem;
  color: var(--muted);
  max-width: 54ch;
  margin-inline: auto;
}
.fact-ticker b { color: var(--gold); font-weight: 600; }
#tickerText { transition: opacity .45s; }

/* ---------- 6. CARDS ------------------------------------------------ */
.grid { display: grid; gap: 1.4rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(275px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.card {
  background: var(--grad-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  backdrop-filter: blur(14px);
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s;
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--line-bright);
  box-shadow: var(--shadow), var(--glow);
}
.card h3 { margin-bottom: .4rem; }
.card p  { margin-bottom: 0; font-size: .94rem; }

.card-icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: rgba(120, 140, 255, .13);
  border: 1px solid var(--line);
  font-size: 1.35rem;
  margin-bottom: 1rem;
}

/* ---------- SEARCH / FILTER BAR ------------------------------------ */
.toolbar {
  display: flex;
  gap: .8rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-bottom: 2.2rem;
}
.search-box { position: relative; flex: 1 1 300px; max-width: 420px; }
.search-box input {
  width: 100%;
  padding: .8rem 1rem .8rem 2.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 36, .8);
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  transition: border-color .25s, box-shadow .25s;
}
.search-box input::placeholder { color: #6f78a3; }
.search-box input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, .16);
}
.search-box .icon {
  position: absolute; left: 1rem; top: 50%;
  transform: translateY(-50%);
  color: var(--muted); font-size: .95rem; pointer-events: none;
}

.chip {
  padding: .55rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--muted);
  font-family: inherit; font-size: .88rem; font-weight: 500;
  cursor: pointer;
  transition: all .22s;
}
.chip:hover { color: var(--text); border-color: var(--line-bright); }
.chip[aria-pressed="true"] {
  background: var(--grad-cosmic);
  color: #07091b;
  border-color: transparent;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  display: none;
}
.empty-state.show { display: block; }
.empty-state .big { font-size: 2.6rem; display: block; margin-bottom: .5rem; }

/* ---------- 7. PLANETS ---------------------------------------------- */
.planet-grid { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }

.planet-card {
  background: var(--grad-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.7rem 1.5rem 1.4rem;
  text-align: center;
  cursor: pointer;
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s;
  backdrop-filter: blur(9px);
}
.planet-card:hover {
  transform: translateY(-7px);
  border-color: var(--line-bright);
  box-shadow: var(--shadow), var(--glow);
}
.planet-card[aria-expanded="true"] {
  border-color: var(--line-bright);
  box-shadow: var(--shadow), var(--glow);
}

/* Stage keeps a constant height so cards don't jump when the
   to-scale toggle changes each planet's size. */
.planet-stage {
  height: 190px;
  display: grid;
  place-items: center;
  margin-bottom: .9rem;
}

/* THE PLANET ITSELF — a div with radial gradients. No image files. */
.planet-body {
  --size: 120px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  position: relative;
  transition: width .6s var(--ease), height .6s var(--ease);
  /* inset shadow on the lower-right = the planet's night side */
  box-shadow:
    inset -16px -12px 38px rgba(0, 0, 0, .72),
    inset 6px 6px 18px rgba(255, 255, 255, .07),
    0 0 34px rgba(140, 160, 255, .22);
  animation: planet-spin 26s linear infinite;
}
@keyframes planet-spin { to { background-position: 300px 0, 0 0, 0 0; } }

.planet-card:hover .planet-body { animation-duration: 9s; }

/* Each world gets its own palette. Layer order: detail, then base. */
.p-mercury {
  background:
    radial-gradient(circle at 62% 38%, rgba(255,255,255,.14) 0 6%, transparent 30%),
    radial-gradient(circle at 30% 70%, rgba(0,0,0,.3) 0 9%, transparent 26%),
    radial-gradient(circle at 35% 30%, #a8a29e, #57534e 68%, #292524);
}
.p-venus {
  background:
    repeating-linear-gradient(102deg, rgba(255,240,200,.16) 0 12px, transparent 12px 30px),
    radial-gradient(circle at 35% 30%, #fde68a, #d9a441 62%, #7c4a17);
}
.p-earth {
  background:
    radial-gradient(ellipse 34% 20% at 32% 40%, #4ade80 0 60%, transparent 62%),
    radial-gradient(ellipse 26% 16% at 66% 62%, #22c55e 0 60%, transparent 62%),
    radial-gradient(ellipse 30% 12% at 52% 22%, rgba(255,255,255,.6) 0 55%, transparent 60%),
    radial-gradient(circle at 35% 30%, #60a5fa, #1d4ed8 66%, #0c1f52);
}
.p-mars {
  background:
    radial-gradient(circle at 50% 12%, rgba(255,255,255,.5) 0 7%, transparent 20%),
    radial-gradient(circle at 62% 66%, rgba(0,0,0,.28) 0 12%, transparent 30%),
    radial-gradient(circle at 35% 30%, #fb923c, #b4442a 62%, #601f14);
}
.p-jupiter {
  background:
    radial-gradient(ellipse 15% 9% at 66% 60%, #dc2626 0 60%, rgba(220,38,38,.35) 62%, transparent 72%),
    repeating-linear-gradient(180deg,
      rgba(255,241,214,.55) 0 7px,
      rgba(190,130,80,.5)   7px 14px,
      rgba(245,222,179,.4)  14px 20px,
      rgba(150,95,60,.45)   20px 28px),
    radial-gradient(circle at 35% 30%, #f5deb3, #b57a45 66%, #5d3a1c);
}
.p-saturn {
  background:
    repeating-linear-gradient(180deg,
      rgba(255,245,220,.4) 0 9px,
      rgba(214,178,120,.4) 9px 18px),
    radial-gradient(circle at 35% 30%, #fde9b8, #c8a05e 64%, #6b4a20);
}
/* Saturn's rings: a flattened, rotated ellipse drawn with a border */
.p-saturn::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 195%; height: 195%;
  transform: translate(-50%, -50%) rotate(-19deg) scaleY(.2);
  border-radius: 50%;
  border: 11px solid rgba(226, 200, 150, .5);
  box-shadow:
    0 0 0 5px rgba(226, 200, 150, .2),
    inset 0 0 0 5px rgba(160, 130, 90, .35);
  pointer-events: none;
}
.p-uranus {
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.09) 0 14px, transparent 14px 34px),
    radial-gradient(circle at 35% 30%, #a5f3fc, #38bdf8 60%, #0e5c78);
}
/* Uranus rings are near-vertical — it orbits tipped on its side */
.p-uranus::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 168%; height: 168%;
  transform: translate(-50%, -50%) rotate(76deg) scaleY(.14);
  border-radius: 50%;
  border: 5px solid rgba(190, 235, 250, .38);
  pointer-events: none;
}
.p-neptune {
  background:
    radial-gradient(ellipse 16% 10% at 60% 58%, rgba(10,20,60,.85) 0 60%, transparent 70%),
    repeating-linear-gradient(96deg, rgba(255,255,255,.07) 0 10px, transparent 10px 26px),
    radial-gradient(circle at 35% 30%, #93c5fd, #2563eb 58%, #10245e);
}

.planet-name { font-size: 1.35rem; margin-bottom: .15rem; }
.planet-tag {
  font-size: .76rem;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: .9rem;
}
.planet-hint { font-size: .82rem; color: #7d86ae; margin: .8rem 0 0; }
.planet-card[aria-expanded="true"] .planet-hint { color: var(--teal); }

/* Expanding details panel. Animating grid-template-rows from 0fr to
   1fr is the modern trick for "slide open to fit the content".  */
.planet-details {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .45s var(--ease);
  text-align: left;
}
.planet-card[aria-expanded="true"] .planet-details { grid-template-rows: 1fr; }
.planet-details > div { overflow: hidden; }

.stat-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .5rem 0;
  border-bottom: 1px dashed rgba(140, 160, 255, .14);
  font-size: .89rem;
}
.stat-list li:last-child { border-bottom: none; }
.stat-list .k { color: var(--muted); }
.stat-list .v { color: var(--text); font-weight: 600; text-align: right; }

.fact-note {
  margin-top: 1rem;
  padding: .85rem 1rem;
  border-left: 3px solid var(--purple);
  background: rgba(167, 139, 250, .09);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .89rem;
  color: #c6cdf0;
}
.fact-note strong { color: var(--purple); }

.scale-note {
  text-align: center;
  font-size: .87rem;
  color: var(--muted);
  margin-top: 1.6rem;
  font-style: italic;
}

/* ---------- 8. CONSTELLATIONS --------------------------------------- */
.con-grid { grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)); }

.con-card {
  background: var(--grad-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s;
}
.con-card:hover {
  transform: translateY(-7px);
  border-color: var(--line-bright);
  box-shadow: var(--shadow), var(--glow);
}
.con-sky {
  background:
    radial-gradient(circle at 70% 20%, rgba(90, 70, 180, .3), transparent 60%),
    #060818;
  border-bottom: 1px solid var(--line);
}
.con-sky svg { display: block; width: 100%; height: auto; }
.con-sky .link { stroke: rgba(150, 180, 255, .42); stroke-width: .5; fill: none; }
.con-sky .star { fill: #fff; }
.con-card:hover .con-sky .star { filter: drop-shadow(0 0 2px #cfe0ff); }
.con-body { padding: 1.3rem 1.4rem 1.5rem; }
.con-body h3 { margin-bottom: .1rem; }
.con-latin {
  font-family: var(--font-myth);
  font-style: italic;
  color: var(--muted);
  font-size: .93rem;
  margin-bottom: .8rem;
}
.con-meta { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .9rem; }
.pill {
  font-size: .74rem;
  padding: .25rem .7rem;
  border-radius: 999px;
  background: rgba(120, 140, 255, .13);
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.season { color: var(--teal); border-color: rgba(45, 212, 191, .3); }

/* Modal used by the constellations page */
.modal {
  position: fixed; inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  padding: 1.5rem;
  background: rgba(2, 3, 10, .82);
  backdrop-filter: blur(7px);
}
.modal.open { display: grid; }
.modal-panel {
  position: relative;
  width: min(100%, 660px);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #131a3d, #080b21);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: pop .35s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(.97); } }
.modal-close {
  position: absolute; top: .9rem; right: .9rem;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 1.15rem; line-height: 1;
  cursor: pointer;
  transition: background .2s;
}
.modal-close:hover { background: rgba(255, 90, 90, .22); }
.myth {
  font-family: var(--font-myth);
  font-size: 1.02rem;
  line-height: 1.75;
  color: #ccd3f2;
}

/* ---------- 9. MOON -------------------------------------------------- */
.moon-layout {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 2.4rem;
  align-items: center;
}
.moon-viz { display: grid; place-items: center; gap: 1.2rem; }

/* The Moon disc. The lit shape is drawn by an SVG inside it. */
.moon-disc {
  width: min(74vw, 290px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #0a0c1c;
  box-shadow: 0 0 70px rgba(190, 205, 255, .22), inset 0 0 0 1px rgba(160,180,255,.16);
  position: relative;
  overflow: hidden;
}
.moon-disc svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.moon-readout { text-align: center; }
.moon-phase-name { font-size: 1.5rem; font-weight: 650; margin-bottom: .2rem; }
.moon-illum { color: var(--teal); font-weight: 600; }

.date-row {
  display: flex; gap: .7rem; flex-wrap: wrap;
  align-items: center; justify-content: center;
  margin-bottom: 1.6rem;
}
input[type="date"] {
  padding: .68rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 36, .85);
  color: var(--text);
  font-family: inherit; font-size: .95rem;
  color-scheme: dark;    /* makes the native picker dark too */
}
input[type="date"]:focus { outline: none; border-color: var(--teal); }

.moon-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .5rem;
  margin-top: 1.2rem;
}
.moon-cell {
  text-align: center;
  padding: .6rem .2rem .5rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, .025);
  transition: background .2s, border-color .2s, transform .2s;
  cursor: pointer;
}
.moon-cell:hover { background: rgba(120, 140, 255, .13); transform: translateY(-2px); }
.moon-cell.today { border-color: var(--teal); }
.moon-cell.today .d { color: var(--teal); }
.moon-cell.selected { border-color: var(--purple); background: rgba(167, 139, 250, .12); }
.moon-cell .d { font-size: .74rem; color: var(--muted); margin-bottom: .3rem; }
.moon-cell svg { width: 30px; height: 30px; }
.dow {
  text-align: center; font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: #6f78a3; padding-bottom: .2rem;
}

/* ---------- 10. FACTS + QUIZ ----------------------------------------- */
.fact-card { position: relative; overflow: hidden; }
.fact-card .cat {
  font-size: .7rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--purple); font-weight: 600; margin-bottom: .55rem; display: block;
}
.fact-card .num {
  position: absolute; top: .4rem; right: 1rem;
  font-size: 3.4rem; font-weight: 800;
  color: rgba(255, 255, 255, .035);
  line-height: 1; pointer-events: none;
}

.quiz {
  max-width: 720px; margin: 0 auto;
  background: var(--grad-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 4vw, 2.4rem);
  backdrop-filter: blur(9px);
}
.quiz-progress {
  height: 5px; border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  overflow: hidden; margin-bottom: 1.6rem;
}
.quiz-progress span {
  display: block; height: 100%; width: 0;
  background: var(--grad-cosmic);
  transition: width .45s var(--ease);
}
.quiz-q { font-size: 1.22rem; font-weight: 600; margin-bottom: 1.3rem; }
.quiz-options { display: grid; gap: .7rem; }
.quiz-opt {
  text-align: left;
  padding: .85rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  font-family: inherit; font-size: .96rem;
  cursor: pointer;
  transition: all .2s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--line-bright); background: rgba(120, 140, 255, .12); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.correct  { border-color: #34d399; background: rgba(52, 211, 153, .17); }
.quiz-opt.wrong    { border-color: #f87171; background: rgba(248, 113, 113, .15); }
.quiz-explain {
  margin-top: 1.1rem;
  padding: .9rem 1.1rem;
  border-radius: var(--radius-sm);
  background: rgba(96, 165, 250, .1);
  border-left: 3px solid var(--blue);
  font-size: .92rem; color: #c6cdf0;
  display: none;
}
.quiz-explain.show { display: block; animation: pop .3s var(--ease); }
.quiz-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.quiz-score { color: var(--muted); font-size: .92rem; }
.quiz-result { text-align: center; }
.quiz-result .big-score {
  font-size: 3.6rem; font-weight: 800;
  background: var(--grad-cosmic);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.1;
}

/* ---------- 11. ABOUT ------------------------------------------------ */
.about-lead {
  max-width: 68ch;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 2.2rem);
}
.about-lead p:last-child { margin-bottom: 0; }
.knowledge-grid h3 { margin-bottom: .45em; }
.knowledge-grid p { font-size: .95rem; }
.knowledge-grid p:last-child { margin-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.6rem; border-left: 1px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1.6rem 0; }
.timeline li::before {
  content: "";
  position: absolute; left: -1.95rem; top: .45rem;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--grad-cosmic);
  box-shadow: 0 0 12px rgba(167, 139, 250, .8);
}
.timeline h4 { margin-bottom: .2rem; }
.timeline p { margin-bottom: 0; font-size: .93rem; }

.lesson {
  max-width: 68ch;
  margin: 0 auto 2.2rem;
}
.lesson h3 {
  color: var(--gold);
  font-size: 1.45rem;
  margin-bottom: .4em;
}
.toc-grid a.card { color: inherit; }
.toc-grid a.card h3 { color: var(--text); }

/* ---------- 12. FOOTER ----------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(4, 5, 14, .6);
  padding: 2.6rem 0 2rem;
  margin-top: 2rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.8rem;
  margin-bottom: 1.8rem;
}
.footer-grid h4 { font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--teal); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: .4rem; }
.footer-grid a { color: var(--muted); font-size: .92rem; }
.footer-grid a:hover { color: var(--text); }
.footer-bottom {
  border-top: 1px solid var(--line);
  padding-top: 1.3rem;
  text-align: center;
  font-size: .86rem;
  color: #6f78a3;
}

/* ---------- 13. RESPONSIVE ------------------------------------------- */
@media (max-width: 1100px) {
  .nav-links a { padding: .45rem .58rem; font-size: .86rem; }
}

@media (max-width: 860px) {
  .moon-layout { grid-template-columns: 1fr; gap: 1.8rem; }
}

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    gap: .2rem;
    padding: .8rem 1.2rem 1.2rem;
    background: rgba(6, 8, 22, .97);
    border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .7rem .9rem; }
  .moon-calendar { gap: .3rem; }
  .moon-cell svg { width: 24px; height: 24px; }
  .modal-panel { padding: 1.5rem 1.2rem; }
}

/* Respect people who get motion sickness from animation.
   This is an accessibility setting in every modern OS. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ===================================================================
   19. LEVELLED QUIZ  (quiz.html)

   Reuses the existing .quiz, .quiz-opt, .quiz-explain and .btn styles
   above — only the level chooser, rank badge and result card are new.

   Each card sets a --lv custom property to its own level colour, so
   one set of rules covers all four levels instead of four near-copies.
   =================================================================== */

/* ---- rank banner ---- */
.rank-card {
  display: flex; align-items: center; gap: 1rem;
  max-width: 460px; margin: 0 auto 2.4rem;
  padding: 1rem 1.4rem;
  background: var(--grad-panel);
  border: 1px solid var(--rank, var(--line-bright));
  border-radius: var(--radius);
  box-shadow: 0 0 34px color-mix(in srgb, var(--rank, #7a6eff) 22%, transparent);
}
.rank-card--none { border-color: var(--line); box-shadow: none; }
.rank-medal { font-size: 2rem; color: var(--rank, var(--muted)); line-height: 1; }
.rank-label { display: block; font-size: .74rem; letter-spacing: .14em;
              text-transform: uppercase; color: var(--muted); }
.rank-name  { display: block; font-size: 1.16rem; color: var(--text); }

/* ---- the four level cards ---- */
.level-grid {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  margin-bottom: 1.6rem;
}
.level-card {
  position: relative; text-align: left;
  padding: 1.5rem 1.4rem 1.3rem;
  background: var(--grad-panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--lv, var(--line-bright));
  border-radius: var(--radius);
  color: var(--text); font: inherit; cursor: pointer;
  transition: transform .3s var(--ease), border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.level-card:hover:not(.is-locked) {
  transform: translateY(-5px);
  border-color: var(--lv);
  box-shadow: 0 18px 44px color-mix(in srgb, var(--lv) 26%, transparent);
}
.level-card:focus-visible { outline: 2px solid var(--lv); outline-offset: 3px; }
.level-card h3 { margin: .5rem 0 .4rem; font-size: 1.18rem; color: var(--lv); }
.level-card p  { font-size: .93rem; color: var(--muted); margin-bottom: .9rem; }

.level-num {
  position: absolute; top: 1.1rem; right: 1.2rem;
  font-size: 2.5rem; font-weight: 800; line-height: 1;
  color: var(--lv); opacity: .17;
}
.level-tier {
  display: inline-block; font-size: .7rem; letter-spacing: .15em;
  text-transform: uppercase; color: var(--lv);
  border: 1px solid currentColor; border-radius: 999px; padding: .16rem .6rem;
}
.level-meta   { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .5rem; }
.level-status { display: block; font-size: .85rem; color: var(--muted); }
.level-status.is-ok { color: #34d399; font-weight: 600; }

/* A locked card is a div, not a button — it cannot be focused or
   clicked at all, rather than looking dim but still being pressable. */
.level-card.is-locked { opacity: .5; cursor: not-allowed; border-top-color: var(--line); }
.level-card.is-locked h3, .level-card.is-locked .level-tier,
.level-card.is-locked .level-num { color: var(--muted); }
.level-card.is-passed { border-color: color-mix(in srgb, var(--lv) 45%, transparent); }

/* ---- in-quiz header ---- */
.quiz-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.quiz-head strong { color: var(--lv, var(--text)); font-size: 1.05rem; }

.linklike {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: .88rem;
  text-decoration: underline; text-underline-offset: 3px;
}
.linklike:hover { color: var(--text); }
.quiz-note { text-align: center; font-size: .9rem; color: var(--muted); max-width: 46rem; margin: 0 auto; }
.quiz-note .linklike { margin-left: .5rem; }

/* ---- result card ---- */
.quiz-result-card {
  max-width: 560px; margin: 2rem auto 0; text-align: center;
  padding: 2.2rem 1.6rem;
  background: var(--grad-panel);
  border: 1px solid var(--lv, var(--line));
  border-radius: var(--radius);
  box-shadow: 0 0 46px color-mix(in srgb, var(--lv) 24%, transparent);
  animation: pop .35s var(--ease);
}
.quiz-result-card.is-fail { border-color: var(--line-bright); box-shadow: none; }
.quiz-result-card h3 { font-size: 1.3rem; margin: .3rem 0 .5rem; }
.quiz-result-card p  { color: var(--muted); margin-bottom: 1.3rem; }
.result-score { font-size: 3.1rem; font-weight: 800; color: var(--lv); line-height: 1; }
.result-score small { font-size: 1.3rem; color: var(--muted); font-weight: 600; }

.rank-award {
  display: inline-block; margin-bottom: 1.3rem;
  padding: .5rem 1.3rem; border-radius: 999px;
  background: color-mix(in srgb, var(--lv) 18%, transparent);
  border: 1px solid var(--lv); color: var(--lv);
  font-weight: 700; letter-spacing: .06em;
}
.result-actions { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }

/* ---- rank pill in the site header, shown on every page ---- */
.nav-rank {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .7rem; border-radius: 999px;
  font-size: .76rem; font-weight: 700; letter-spacing: .04em;
  background: rgba(251, 191, 36, .14);
  border: 1px solid rgba(251, 191, 36, .5); color: var(--gold);
  text-decoration: none; white-space: nowrap;
}
.nav-rank:hover { background: rgba(251, 191, 36, .24); }

@media (max-width: 560px) {
  .level-grid { grid-template-columns: 1fr; }
  .rank-card { flex-direction: row; }
}

/* ---- quiz call-to-action on facts.html ---------------------------- */
.quiz-cta {
  max-width: 720px; margin: 0 auto; text-align: center;
  padding: 2rem 1.6rem;
  background: var(--grad-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.cta-ladder {
  list-style: none; display: flex; gap: .6rem; flex-wrap: wrap;
  justify-content: center; margin: 0 0 1.3rem; padding: 0;
  counter-reset: rung;
}
.cta-ladder li {
  counter-increment: rung;
  flex: 1 1 132px; padding: .8rem .6rem;
  border: 1px solid color-mix(in srgb, var(--lv) 45%, transparent);
  border-top: 3px solid var(--lv);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--lv) 8%, transparent);
}
.cta-ladder li::before {
  content: counter(rung); display: block;
  font-size: .72rem; letter-spacing: .1em; color: var(--muted); margin-bottom: .2rem;
}
.cta-ladder strong { display: block; color: var(--lv); font-size: .98rem; }
.cta-ladder span   { display: block; font-size: .76rem; letter-spacing: .1em;
                     text-transform: uppercase; color: var(--muted); margin-top: .15rem; }
.cta-note { font-size: .92rem; color: var(--muted); margin-bottom: 1.4rem; }

/* ===================================================================
   20. BEAST — chat page (js/chat.js, rendered into #beastChat on
   beast.html). Its own page rather than a floating overlay, so it
   never covers content on the pages you're actually reading.
   =================================================================== */
.beast-page {
  display: flex; flex-direction: column;
  height: min(560px, calc(100vh - 16rem));
  min-height: 380px;
  background: var(--grad-panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--glow);
  overflow: hidden;
}

.beast-log {
  flex: 1; overflow-y: auto; padding: 1.1rem 1.2rem;
  display: flex; flex-direction: column; gap: .6rem;
}
.beast-bubble {
  max-width: 78%; padding: .65rem .9rem; border-radius: var(--radius-sm);
  font-size: .92rem; line-height: 1.55; white-space: pre-line;
}
.beast-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
}
.beast-user {
  align-self: flex-end;
  background: var(--grad-cosmic);
  color: #07091b;
}
.beast-thinking { opacity: .6; font-style: italic; }
.beast-apod-card { display: flex; flex-direction: column; gap: .5rem; }
.beast-apod-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  font-size: .78rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}
.beast-apod-refresh {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); font: inherit; font-size: .72rem; letter-spacing: .03em;
  text-transform: uppercase; padding: .25rem .65rem; cursor: pointer;
}
.beast-apod-refresh:hover { border-color: var(--teal); color: var(--teal); }
.beast-apod-refresh:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.beast-apod-body { white-space: pre-wrap; }
.beast-apod-img {
  display: block; width: 100%; max-width: 100%;
  margin-top: .25rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.beast-form {
  display: flex; gap: .6rem; padding: .9rem 1rem;
  border-top: 1px solid var(--line);
}
.beast-form input {
  flex: 1; min-width: 0;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .65rem 1rem;
  color: var(--text);
  font: inherit; font-size: .92rem;
}
.beast-form input:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.beast-send { padding: .65rem 1.2rem; font-size: .92rem; }

/* ===================================================================
   21. ACCOUNT — sign-in/sign-up (js/account.js), on every page's nav
   and on the full account.html page.
   =================================================================== */
#navAccount a {
  display: inline-block;
  padding: .45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line-bright);
  font-size: .88rem;
  text-decoration: none;
}
#navAccount a:hover { background: rgba(255, 255, 255, .06); }

.btn-quiet {
  background: none;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-quiet:hover { background: rgba(255, 255, 255, .06); }

.account-panel {
  max-width: 26rem;
  margin: 0 auto;
  padding: 1.6rem;
  background: var(--grad-panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--glow);
}
.account-panel .who { font-size: 1.05rem; margin-bottom: .3rem; }
.account-panel .panel-hint { font-size: .86rem; color: var(--muted); margin-bottom: 1rem; }

.account-form { display: flex; flex-direction: column; gap: .9rem; }
.account-form .field {
  display: flex; flex-direction: column; gap: .35rem;
  font-size: .86rem; color: var(--muted);
}
.account-form input {
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .65rem .85rem;
  color: var(--text);
  font: inherit; font-size: .94rem;
}
.account-form input:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.account-form .actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.form-msg { min-height: 1.2em; font-size: .86rem; }
.form-msg.is-error { color: #ff8080; }

@media (max-width: 560px) { .cta-ladder li { flex-basis: 100%; } }


/* ---------- MOBILE HARDENING ------------------------------------------
   Phone-visitor fixes:
   - never pan sideways
   - iOS zooms into inputs under 16px — bump them on touch devices
   - chat height uses dvh so mobile browser chrome can't squeeze it
   - comfortable tap targets                                      */
html, body { overflow-x: clip; }
img, svg, video, iframe { max-width: 100%; }

.beast-form input { font-size: 16px; }
.nav-toggle { font-size: 1.4rem; line-height: 1; }

@media (max-width: 720px) {
  /* min() with plain 100vh overstates the visible height on phones
     (the URL bar takes a cut) — dvh tracks the real viewport */
  .beast-page {
    height: auto;
    min-height: 320px;
    max-height: 70dvh;
  }
  .beast-log { max-height: 46dvh; }
}

@media (max-width: 560px) {
  .wrap { padding-inline: 1rem; }
  .hero h1 { font-size: clamp(2rem, 9vw, 2.8rem); }
  .btn { padding-block: .75rem; }
  .beast-form { gap: .45rem; padding: .7rem .8rem; }
  .beast-send { padding: .65rem .95rem; }
}
