/* Cosmic Quest web — celestial-instrument design language.
   Palette and type mirror the app: obsidian/navy space, brass/gold accent,
   ivory text, Fraunces display / Inter UI / JetBrains Mono technical. */
:root {
  --space-deep: #070b16;
  --space-navy: #0c1224;
  --space-panel: #111a30;
  --glass: rgba(17, 26, 48, 0.72);
  --gold: #c9a24b;
  --gold-soft: #e2c47f;
  --hairline: rgba(201, 162, 75, 0.35);
  --ivory: #f3eee2;
  --ivory-dim: #b9b4a6;
  --aurora-cyan: #6fd3d0;
  --aurora-rose: #d99aa8;
  --danger: #d97b6c;
  --ok: #8fc9a2;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(111, 211, 208, 0.06), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(217, 154, 168, 0.05), transparent 60%),
    linear-gradient(180deg, var(--space-deep) 0%, var(--space-navy) 100%);
  color: var(--ivory);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
}
main { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.wide { max-width: 64rem; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; line-height: 1.25; color: var(--ivory); }
h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); margin: 0.5em 0 0.3em; }
h2 { font-size: clamp(1.35rem, 3.5vw, 1.7rem); margin-top: 2.2em; border-bottom: 1px solid var(--hairline); padding-bottom: 0.3em; }
h3 { font-size: 1.12rem; margin-top: 1.6em; color: var(--gold-soft); }
a { color: var(--aurora-cyan); text-underline-offset: 3px; }
a:hover, a:focus-visible { color: var(--gold-soft); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 2px;
}
code, .mono { font-family: var(--mono); font-size: 0.92em; color: var(--gold-soft); }
p { margin: 0.8em 0; }
ul { padding-left: 1.3rem; }
li { margin: 0.35em 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem; max-width: 64rem; margin: 0 auto;
  border-bottom: 1px solid rgba(201, 162, 75, 0.18);
}
.brand { font-family: var(--display); font-size: 1.15rem; letter-spacing: 0.04em; color: var(--ivory); text-decoration: none; }
.brand .star { color: var(--gold); }
.topnav a { margin-left: 1.1rem; font-size: 0.95rem; text-decoration: none; color: var(--ivory-dim); }
.topnav a:hover { color: var(--gold-soft); }

.card {
  background: var(--glass);
  border: 1px solid rgba(201, 162, 75, 0.22);
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  margin: 1.2rem 0;
  backdrop-filter: blur(4px);
}
.card.warn { border-color: rgba(217, 123, 108, 0.55); }
.card.ok { border-color: rgba(143, 201, 162, 0.5); }
.notice {
  border-left: 3px solid var(--gold);
  background: rgba(201, 162, 75, 0.08);
  padding: 0.7rem 1rem; margin: 1rem 0; border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
}
.notice.blocker { border-left-color: var(--danger); background: rgba(217, 123, 108, 0.08); }

.btn {
  display: inline-block;
  font-family: var(--ui); font-size: 1rem; font-weight: 600;
  color: var(--space-deep); background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none; border-radius: 10px; padding: 0.8rem 1.5rem;
  min-height: 48px; min-width: 48px;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { filter: brightness(1.07); color: var(--space-deep); }
.btn.ghost {
  background: transparent; color: var(--ivory);
  border: 1px solid var(--hairline);
}
.btn.danger { background: linear-gradient(180deg, #e29a8c, var(--danger)); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

label { display: block; margin: 0.9rem 0 0.3rem; color: var(--ivory-dim); font-size: 0.95rem; }
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%; padding: 0.75rem 0.9rem; min-height: 48px;
  background: rgba(7, 11, 22, 0.75); color: var(--ivory);
  border: 1px solid rgba(201, 162, 75, 0.3); border-radius: 10px;
  font-family: var(--ui); font-size: 1rem;
}
.checkline { display: flex; gap: 0.65rem; align-items: flex-start; margin: 1rem 0; }
.checkline input { width: 1.25rem; height: 1.25rem; margin-top: 0.25rem; accent-color: var(--gold); }

.meta { font-family: var(--mono); font-size: 0.8rem; color: var(--ivory-dim); letter-spacing: 0.02em; }
.status-line { font-family: var(--mono); font-size: 0.9rem; padding: 0.5rem 0; }
.hidden { display: none !important; }

footer {
  border-top: 1px solid rgba(201, 162, 75, 0.18);
  margin-top: 3rem; padding: 1.6rem 1.25rem 2.4rem;
  text-align: center; color: var(--ivory-dim); font-size: 0.9rem;
}
footer a { color: var(--ivory-dim); margin: 0 0.6rem; }
footer a:hover { color: var(--gold-soft); }

/* Table of contents for legal pages */
.toc { columns: 2; gap: 2rem; font-size: 0.95rem; }
.toc a { text-decoration: none; color: var(--ivory-dim); }
.toc a:hover { color: var(--gold-soft); }
@media (max-width: 560px) { .toc { columns: 1; } .topnav { display: none; } }

table { border-collapse: collapse; width: 100%; font-size: 0.92rem; margin: 1rem 0; display: block; overflow-x: auto; }
th, td { border: 1px solid rgba(201, 162, 75, 0.2); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
th { color: var(--gold-soft); font-weight: 600; background: rgba(201, 162, 75, 0.06); }

@media print {
  body { background: #fff; color: #111; }
  .topbar, footer, .btn, .no-print { display: none; }
  a { color: #114; }
  .card, .notice { border-color: #999; background: #fff; }
  h1, h2, h3 { color: #111; }
}

/* ==================================================================
   Homepage: celestial observatory system (2026-07-29 rework).
   Legal-page styles above are untouched.
   ================================================================== */

/* Robust hidden state: state-dependent controls must truly disappear. */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--gold); color: var(--space-deep);
  padding: 0.6rem 1rem; border-radius: 0 0 8px 0; text-decoration: none;
}
.skip-link:focus { left: 0; }

h1, h2 { text-wrap: balance; }

/* Environmental palettes keyed by computed sky phase (JS sets data-phase). */
html[data-phase="dawn"] body {
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(224, 138, 84, 0.10), transparent 60%),
    linear-gradient(180deg, #10142a 0%, #2a1f33 70%, #4a2c33 100%);
}
html[data-phase="morning"] body,
html[data-phase="afternoon"] body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 222, 150, 0.10), transparent 60%),
    linear-gradient(180deg, #0d1e38 0%, #16345c 70%, #235a86 100%);
}
html[data-phase="dusk"] body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(158, 74, 74, 0.12), transparent 60%),
    linear-gradient(180deg, #0b0e20 0%, #251831 70%, #45222e 100%);
}

/* Homepage layout shell: sections own their width; legal `main` cap not used. */
main#main { max-width: none; padding: 0; margin: 0; }
.section-inner { max-width: 64rem; margin: 0 auto; padding: 0 1.25rem; }
main#main section { padding: clamp(4rem, 9vw, 7rem) 0 0; }
main#main section:last-of-type { padding-bottom: 4rem; }
.section-intro { color: var(--ivory-dim); max-width: 40rem; }
.section-support { color: var(--ivory-dim); max-width: 44rem; }
main#main h2 { border-bottom: none; margin-top: 0; font-size: clamp(1.5rem, 4vw, 2.1rem); }
main#main .lead, main#main .section-intro { font-size: 1.06rem; }

.kv {
  font-family: var(--mono); font-size: 0.82rem; color: var(--aurora-cyan);
  letter-spacing: 0.07em; text-transform: uppercase;
}
.kv.gold { color: var(--gold-soft); }
.kv.cyan { color: var(--aurora-cyan); }
.btn.small { padding: 0.45rem 1rem; min-height: 44px; font-size: 0.9rem; display: inline-flex; align-items: center; }

/* Header: sticky, translucent after scroll */
.topbar {
  position: sticky; top: 0; z-index: 50; max-width: none;
  padding: 0.7rem clamp(1rem, 4vw, 2rem);
  padding-left: max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-left));
  padding-right: max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-right));
  border-bottom-color: transparent;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.topbar.scrolled {
  background: rgba(7, 11, 22, 0.82);
  backdrop-filter: blur(8px);
  border-bottom-color: rgba(201, 162, 75, 0.18);
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; }
.brand-mark { border-radius: 7px; display: block; }
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }
.topnav a { padding: 0.4rem 0.2rem; }
.topnav a:focus-visible { color: var(--gold-soft); }

/* Mobile menu */
.menu-btn {
  display: none; background: transparent; border: 1px solid var(--hairline);
  border-radius: 10px; width: 44px; height: 44px; cursor: pointer;
  align-items: center; justify-content: center;
}
.menu-icon, .menu-icon::before, .menu-icon::after {
  content: ""; display: block; width: 18px; height: 2px;
  background: var(--ivory); border-radius: 2px; position: relative;
}
.menu-icon::before { position: absolute; top: -6px; }
.menu-icon::after { position: absolute; top: 6px; }
.mobile-menu {
  position: fixed; top: 60px; left: 0.75rem; right: 0.75rem; z-index: 49;
  display: flex; flex-direction: column;
  background: rgba(12, 18, 36, 0.97); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 0.5rem; backdrop-filter: blur(8px);
}
.mobile-menu a {
  color: var(--ivory); text-decoration: none; padding: 0.85rem 1rem;
  border-radius: 10px; min-height: 48px; display: flex; align-items: center;
}
.mobile-menu a:hover, .mobile-menu a:focus-visible { background: rgba(201, 162, 75, 0.12); }
@media (max-width: 700px) {
  .topnav { display: none; }
  .menu-btn { display: flex; }
}

/* Hero: copy column + dedicated celestial stage (body never behind text) */
.hero { position: relative; overflow: hidden; padding: clamp(1rem, 4vw, 3rem) 0 0 !important; }
.hero .sky {
  position: absolute; inset: 0; pointer-events: none; z-index: 0; opacity: 0.5;
  background:
    radial-gradient(1.5px 1.5px at 12% 30%, rgba(243,238,226,.8), transparent 60%),
    radial-gradient(1px 1px at 25% 68%, rgba(226,196,127,.7), transparent 60%),
    radial-gradient(2px 2px at 38% 22%, rgba(243,238,226,.6), transparent 60%),
    radial-gradient(1px 1px at 52% 55%, rgba(111,211,208,.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 64% 18%, rgba(243,238,226,.7), transparent 60%),
    radial-gradient(1px 1px at 78% 42%, rgba(226,196,127,.6), transparent 60%),
    radial-gradient(2px 2px at 88% 70%, rgba(243,238,226,.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 93% 12%, rgba(243,238,226,.7), transparent 60%);
}
.hero-grid {
  position: relative; z-index: 1;
  max-width: 72rem; margin: 0 auto; padding: 0 1.25rem;
  display: grid; gap: 1.5rem;
  grid-template-columns: 1fr;
}
.celestial-stage {
  position: relative; overflow: hidden; border-radius: 18px;
  height: clamp(190px, 32vh, 260px);
}
#hero-canvas { position: absolute; inset: 0; }
.hero-copy { max-width: 36rem; padding-bottom: 1rem; }
.hero-copy h1 { font-size: clamp(2rem, 5.5vw, 3rem); margin: 0.35em 0 0.3em; }
.hero-copy .lead { color: var(--ivory-dim); font-size: 1.1rem; max-width: 34rem; }
.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin: 1.4rem 0 0.8rem; }
.trust-line { color: var(--ivory-dim); font-size: 0.92rem; }
.scene-info { font-size: 0.88rem; color: var(--ivory-dim); max-width: 30rem; }
.scene-info summary { cursor: pointer; color: var(--aurora-cyan); }
.scene-info p { margin-top: 0.4em; }
@media (min-width: 861px) {
  .hero-grid { grid-template-columns: minmax(0, 46%) 1fr; align-items: center; }
  .hero-grid .celestial-stage { order: 2; height: clamp(340px, 46vh, 440px); }
  .hero-grid .hero-copy { order: 1; padding: 2rem 0 3rem; }
}

/* Body-local prompt: the single celestial control, inside the stage */
.body-prompt {
  position: absolute; left: 50%; bottom: 0.7rem; transform: translateX(-50%);
  z-index: 2; white-space: nowrap;
  background: rgba(7, 11, 22, 0.72); color: var(--ivory);
  border: 1px solid var(--hairline); border-radius: 999px;
  padding: 0.6rem 1.1rem; min-height: 44px;
  font-family: var(--ui); font-size: 0.88rem; cursor: pointer;
  backdrop-filter: blur(4px);
}
.body-prompt:hover { border-color: var(--gold-soft); }

/* Moon panel (inside stage, non-modal dialog) */
.moon-card {
  position: absolute; right: 0.8rem; bottom: 0.8rem; z-index: 3;
  background: rgba(12, 18, 36, 0.95); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 0.9rem 1.1rem; max-width: 17rem; text-align: left;
  backdrop-filter: blur(6px);
}
.moon-card p { margin: 0.25em 0 0.5em; }

/* Observation rail */
.rail {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(201, 162, 75, 0.35);
  border-bottom: 1px solid rgba(201, 162, 75, 0.14);
  margin-top: 1.4rem;
}
.rail-item {
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.3rem;
}
.rail-item + .rail-item { border-left: 1px solid rgba(201, 162, 75, 0.14); }
.rail-value { color: var(--ivory); font-size: 0.98rem; }
@media (max-width: 700px) {
  .rail { grid-template-columns: 1fr; }
  .rail-item + .rail-item { border-left: none; border-top: 1px solid rgba(201, 162, 75, 0.14); }
}

/* Sky-to-chart bridge */
.bridge-grid {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem;
  align-items: center; margin-top: 1.6rem;
}
.bridge-panel {
  margin: 0; padding: 1rem;
  border: 1px solid rgba(201, 162, 75, 0.18); border-radius: 14px;
  background: rgba(12, 18, 36, 0.5);
}
.bridge-panel figcaption { margin-bottom: 0.5rem; }
.bridge-panel svg { width: 100%; height: auto; display: block; }
.bridge-link { width: 3.2rem; display: flex; align-items: center; }
.bridge-link span {
  display: block; width: 100%; height: 1px;
  background: linear-gradient(90deg, var(--aurora-cyan), var(--gold));
}
.badge {
  display: inline-block; font-family: var(--mono); font-size: 0.72rem;
  letter-spacing: 0.05em; text-transform: uppercase;
  border: 1px solid rgba(111, 211, 208, 0.5); color: var(--aurora-cyan);
  border-radius: 999px; padding: 0.15rem 0.7rem; margin-left: 0.4rem;
}
@media (max-width: 700px) {
  .bridge-grid { grid-template-columns: 1fr; }
  .bridge-link { width: 100%; height: 2rem; justify-content: center; }
  .bridge-link span { width: 1px; height: 100%; background: linear-gradient(180deg, var(--aurora-cyan), var(--gold)); }
}

/* Product narratives: three alternating editorial compositions */
.narrative {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: clamp(1.2rem, 4vw, 3rem); align-items: center;
  margin-top: clamp(2.4rem, 6vw, 4rem);
}
.narrative-art svg { width: 100%; max-width: 22rem; height: auto; display: block; margin: 0 auto; }
.narrative-copy h3 { margin-top: 0; font-size: 1.35rem; color: var(--ivory); }
.narrative-copy p { color: var(--ivory-dim); max-width: 34rem; }
.narrative-copy .support { border-left: 2px solid rgba(201, 162, 75, 0.4); padding-left: 0.9rem; font-size: 0.95rem; }
.narrative-copy .support strong { color: var(--gold-soft); font-weight: 600; }
@media (min-width: 701px) {
  .narrative.flip .narrative-art { order: 2; }
  .narrative.flip .narrative-copy { order: 1; }
}
@media (max-width: 700px) {
  .narrative { grid-template-columns: 1fr; }
  .narrative-art svg { max-width: 16rem; }
}

/* Panchanga ledger (compact cells) */
.ledger { border: 1px solid rgba(201, 162, 75, 0.22); border-radius: 12px; overflow: hidden; margin-top: 1.4rem; }
.ledger-row {
  display: grid; grid-template-columns: 7rem 1fr; gap: 1rem;
  padding: 0.8rem 1.1rem; background: rgba(12, 18, 36, 0.5);
}
.ledger-row + .ledger-row { border-top: 1px solid rgba(201, 162, 75, 0.14); }
@media (max-width: 560px) { .ledger-row { grid-template-columns: 1fr; gap: 0.2rem; } }

/* Trust: quiet, concrete */
.trust-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 2rem; margin-top: 1.2rem; }
.trust-item { border-left: 2px solid rgba(201, 162, 75, 0.4); padding-left: 1rem; }
.trust-item h3 { margin-top: 0; font-size: 1.05rem; color: var(--ivory); }
.trust-item p { color: var(--ivory-dim); font-size: 0.95rem; }

/* Plans */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 2rem; margin: 1.4rem 0; }
.plan { border-top: 2px solid rgba(201, 162, 75, 0.4); padding-top: 0.9rem; }
.plan p { color: var(--ivory-dim); }

/* Closing */
.closing-band {
  max-width: 64rem; margin: 0 auto; text-align: center;
  padding: clamp(2.4rem, 6vw, 4rem) 1.5rem;
  border-top: 1px solid var(--hairline);
}
.closing-line { font-size: clamp(1.5rem, 4vw, 2.2rem) !important; margin-bottom: 0.4em; }
.closing-band .section-intro { margin: 0 auto 1.6rem; }

/* Footer seal */
.footer-seal { display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-family: var(--display); color: var(--ivory); }
.footer-seal img { border-radius: 6px; }

/* Motion family: reveal. Content is VISIBLE BY DEFAULT; JS adds .pre only to
   offscreen sections after the observer is armed, and a safety timeout clears
   any leftover .pre. Any failure leaves everything readable. */
.reveal.pre { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity 0.7s ease, transform 0.7s ease; }
@media (prefers-reduced-motion: reduce) {
  .reveal.pre { opacity: 1; transform: none; }
}
