/* ── Design Tokens ────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:          #120726;
  --bg-1:        #1a0d33;
  --bg-2:        #2a1245;
  --surface:     rgba(168, 120, 240, 0.07);
  --surface-2:   rgba(190, 140, 255, 0.12);
  --surface-3:   rgba(200, 160, 255, 0.16);
  --border:      rgba(196, 150, 255, 0.16);
  --border-2:    rgba(196, 150, 255, 0.30);

  /* Violet / brand */
  --violet:      #7c3aed;
  --violet-2:    #9d5cff;
  --purple:      #7c3aed;
  --purple-light: #c084fc;
  --purple-dim:  rgba(124, 58, 237, 0.12);

  /* Petal (pink accent) */
  --petal:       #f0abfc;
  --rose:        #f0abfc;
  --rose-light:  #f5c4fc;
  --rose-dim:    rgba(240, 171, 252, 0.12);

  /* Gold */
  --gold:        #f6e2b0;
  --gold-light:  #f8ecc8;
  --gold-dim:    rgba(246, 226, 176, 0.12);

  /* Text */
  --text:        #f4ecff;
  --text-muted:  rgba(244, 236, 255, 0.66);
  --text-dim:    rgba(244, 236, 255, 0.42);

  --error:   #e05070;
  --success: #6abf9e;

  /* Fonts */
  --font-heading: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body:    "Outfit", system-ui, -apple-system, sans-serif;
  --font-serif:   "Cormorant Garamond", Georgia, serif;
  --font-ui:      "Outfit", system-ui, -apple-system, sans-serif;
  --font-mono:    "Space Mono", ui-monospace, monospace;

  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --shadow:      0 4px 32px rgba(0, 0, 0, 0.6);
  --shadow-gold: 0 0 40px rgba(124, 58, 237, 0.45);
  --shadow-rose: 0 0 32px rgba(240, 171, 252, 0.40);
  --shadow-card: 0 12px 48px rgba(0, 0, 0, 0.7);

  --nav-height: 68px;
  --max-width:  1100px;
  --page-pad:   1.5rem;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--bg);
}

body {
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Accessibility utility ─────────────────────────────── */
.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;
}

/* ── Auth gate flash prevention ───────────────────────── */
/* When JS confirms the client is authenticated, hide the SSR sign-in gate
   instantly so it never flickers before JS renders the real content. */
body.js-authed .signin-gate {
  visibility: hidden;
  pointer-events: none;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(196, 150, 255, 0.22); border-radius: 20px; }
::-webkit-scrollbar-track { background: transparent; }

::selection { background: rgba(240, 171, 252, 0.35); color: #fff; }

/* ── Fixed sky backdrop ───────────────────────────────── */
.page-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 80% -10%, rgba(58, 26, 99, 0.75) 0%, rgba(58, 26, 99, 0) 55%),
    radial-gradient(90% 70% at 10% 110%,  rgba(44, 15, 77, 0.70) 0%, rgba(44, 15, 77, 0) 60%),
    linear-gradient(180deg, #160a2c 0%, #1a0d33 40%, #120726 100%);
}

/* Star canvas lives inside .page-backdrop — injected by JS */
.page-backdrop canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Ambient orbs */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  z-index: 0;
  pointer-events: none;
}
.bg-orb--a {
  width: 600px; height: 600px;
  top: -10%; right: -8%;
  background: radial-gradient(circle, #7c3aed, transparent 70%);
}
.bg-orb--b {
  width: 500px; height: 500px;
  bottom: 5%; left: -8%;
  background: radial-gradient(circle, #c026d3, transparent 70%);
}

img, video { display: block; max-width: 100%; }
a { color: var(--purple-light); text-decoration: none; }
a:hover { color: var(--petal); }
ul { list-style: none; }

/* ── Typography ───────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: 0.01em;
}

h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.9rem); }
h3 { font-size: clamp(1.05rem, 2vw, 1.35rem); }
h4 { font-size: 1.05rem; }

p { color: var(--text); font-family: var(--font-body); }
small { font-size: 0.85rem; color: var(--text-muted); font-family: var(--font-ui); }

/* ── Layout helpers ───────────────────────────────────── */
main {
  position: relative;
  z-index: 1;
  padding-top: var(--pwa-banner-height, 0px);
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}

.page {
  padding-top: calc(var(--nav-height) + 2rem);
  padding-bottom: 4rem;
  min-height: 100vh;
}

.section { margin-bottom: 3rem; }

/* ── Navigation ───────────────────────────────────────── */
.nav {
  position: fixed;
  top: var(--pwa-banner-height, 0px); left: 0; right: 0;
  height: var(--nav-height);
  background: transparent;
  border-bottom: 1px solid transparent;
  z-index: 100;
  transition: background 0.3s, border-color 0.3s;
}

.nav.nav--scrolled {
  background: rgba(18, 7, 38, 0.80);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom-color: var(--border);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav__logo {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 500;
  font-style: italic;
  color: var(--text);
  letter-spacing: 0.04em;
}
.nav__logo:hover { color: var(--petal); }

.nav__links {
  display: flex;
  align-items: center;
  gap: 1.6rem;
}

.nav__links a {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color 0.2s;
  padding: 4px 0;
  position: relative;
}
.nav__links a:hover,
.nav__links a.active { color: var(--text); }

.nav__links a.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--violet), var(--petal));
}

.nav-signout {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.nav-signout:hover { color: var(--text); }

.nav-signin {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  background: none;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  transition: all 0.2s;
}
.nav-signin:hover {
  background: var(--surface-2);
  border-color: var(--purple-light);
  color: var(--text);
}

/* ── Hamburger ────────────────────────────────────────── */
.nav__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.nav__hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
.nav--open .nav__hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav--open .nav__hamburger span:nth-child(2) { opacity: 0; }
.nav--open .nav__hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile nav ───────────────────────────────────────── */
@media (max-width: 768px) {
  .nav__hamburger { display: flex; }
  .nav { background: rgba(18, 7, 38, 0.60); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

  .nav__links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: rgba(18, 7, 38, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0.25rem 0;
  }
  .nav--open .nav__links { display: flex; }
  .nav__links li { border-bottom: 1px solid rgba(196, 150, 255, 0.1); }
  .nav__links li:last-child { border-bottom: none; }
  .nav__links a,
  .nav-signout,
  .nav-signin {
    display: block;
    padding: 0.85rem var(--page-pad);
    font-size: 0.9rem;
    border-radius: 0;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
  }
}

/* ── Footer ───────────────────────────────────────────── */
.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 2rem var(--page-pad);
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text); }

/* ── Utility ──────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

.text-muted  { color: var(--text-muted); }
.text-gold   { color: var(--gold); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

/* ── Sign-in modal ────────────────────────────────────── */
.signin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 4, 22, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.signin-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.signin-modal {
  background: linear-gradient(180deg, rgba(190,140,255,0.10), rgba(120,80,200,0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 60px rgba(124,58,237,0.12);
}

.signin-modal__symbol {
  font-size: 2.5rem;
  margin-bottom: 1.25rem;
  display: block;
  opacity: 0.6;
}
.signin-modal h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.signin-modal p  { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1.75rem; line-height: 1.6; }

.signin-modal__close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s;
}
.signin-modal__close:hover { color: var(--text); }

/* ── Animations ───────────────────────────────────────── */
@keyframes rise    { from { opacity:0; transform:translateY(18px) } to { opacity:1; transform:none } }
@keyframes floaty  { 0%,100%{ transform:translateY(0) } 50%{ transform:translateY(-8px) } }
@keyframes breathe { 0%,100%{ transform:scale(1);opacity:.92 } 50%{ transform:scale(1.05);opacity:1 } }
.rise { animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
