/* ================= Design tokens ================= */
:root {
  --midnight: #0c0a1a;
  --night-sky: #0a0715;
  --purple-deep: #241436;
  --purple-royal: #3d2359;
  --purple-glow: #6b4a94;
  --indigo: #4b3789;
  --red-river: #6e1b26;
  --red-river-bright: #9c2c3a;
  --gold: #d4af37;
  --gold-bright: #f0cf6e;
  --sunset: #d9713c;
  --sunset-bright: #e89a5f;
  --sand: #c9a876;
  --parchment: #e9dcc0;
  --parchment-dim: #cbb98f;
  --star-white: #f7f2e6;
  --ink: #120d1e;

  --room-body: #9c2c3a;
  --room-mind: #6b4a94;
  --room-soul: #d4af37;
  --room-connect: #d9713c;
  --room-business: #398174;
  --room-events: #6e1b26;

  --inji-gold: #d4af37;
  --inji-teal: #398174;
  --inji-silver: #a8a9ad;
  --inji-bronze: #c5832b;

  --font-display: 'Cinzel', 'Trajan Pro', 'Times New Roman', serif;
  --font-body: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;

  --radius: 4px;
  --ease-ritual: cubic-bezier(0.16, 0.7, 0.2, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night-sky);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--gold-bright);
  text-transform: uppercase;
  margin: 0 0 0.6em;
}

a { color: var(--sunset-bright); }
button {
  font-family: var(--font-display);
  cursor: pointer;
  background: none;
  border: 1px solid var(--gold);
  color: var(--parchment);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
  padding: 0.85em 1.6em;
  border-radius: var(--radius);
  transition: background 0.25s var(--ease-soft), color 0.25s var(--ease-soft), box-shadow 0.25s var(--ease-soft);
}
button:hover, button:focus-visible {
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 0 24px rgba(212, 175, 55, 0.45);
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost { border-color: var(--parchment-dim); color: var(--parchment-dim); }
button.ghost:hover { background: transparent; color: var(--gold-bright); border-color: var(--gold); box-shadow: none; }

input, select, textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  background: rgba(233, 220, 192, 0.06);
  border: 1px solid var(--parchment-dim);
  color: var(--star-white);
  padding: 0.7em 0.9em;
  border-radius: var(--radius);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.25);
}
label { display: block; font-size: 0.85rem; letter-spacing: 0.04em; color: var(--parchment-dim); margin: 1em 0 0.35em; text-transform: uppercase; }

.hidden { display: none !important; }
.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;
}
.hidden-field { position: absolute; left: -9999px; }

.badge-soon {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--night-sky) !important;
  background: var(--sand);
  padding: 0.3em 0.7em;
  border-radius: 100px;
  vertical-align: middle;
  margin-left: 0.6em;
}

/* ================= Ambient starfield ================= */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.ambient-pyramids {
  position: fixed; bottom: 0; left: 0; width: 100%; height: 20vh; z-index: 0;
  opacity: 0.5; pointer-events: none;
}
.welcome-moon {
  position: fixed; left: 50%; bottom: -8vw; transform: translateX(-50%);
  width: 34vw; height: 34vw; max-width: 340px; max-height: 340px; min-width: 200px; min-height: 200px;
  border-radius: 50%; z-index: 0; pointer-events: none;
  background: radial-gradient(circle at 42% 38%, #ffffff 0%, #e7e6ec 35%, #b9b8c6 68%, transparent 78%);
  box-shadow: 0 0 90px 30px rgba(230,230,240,0.35), 0 0 200px 80px rgba(200,200,220,0.15);
  opacity: 0.85;
}

/* ================= App shell / routing ================= */
#app { position: relative; z-index: 1; min-height: 100%; }
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ================= Entry: threshold ================= */
#view-threshold.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  text-align: center;
}
.threshold-card { max-width: 440px; }
.prototype-note-tiny {
  position: fixed; bottom: 0.9rem; right: 1.1rem; z-index: 1;
  color: var(--sand); font-size: 0.6rem; font-style: italic;
  letter-spacing: 0.02em; opacity: 0.35; pointer-events: none;
}
.threshold-title {
  font-family: var(--font-display); color: var(--gold-bright);
  font-size: 1.1rem; letter-spacing: 0.05em; margin: 0 0 0.7em;
  text-shadow: 0 0 18px rgba(212,175,55,0.3);
}
.threshold-card p.lede { color: var(--parchment-dim); margin-bottom: 1.6em; }
.threshold-card form { display: flex; gap: 0.6em; flex-wrap: wrap; justify-content: center; }
.threshold-card input { max-width: 240px; text-align: center; letter-spacing: 0.2em; text-transform: uppercase; }
.threshold-error { color: var(--red-river-bright); font-size: 0.85rem; min-height: 1.4em; margin-top: 0.8em; }
.threshold-card input::placeholder { color: var(--sand); opacity: 0.75; text-transform: none; letter-spacing: 0.04em; font-size: 0.75rem; }
.sigil {
  width: 72px; height: 72px; margin: 0 auto 1.2em;
  border: 1px solid var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  font-size: 1.6rem;
}

/* ================= Entry: light-burst transition ================= */
.light-burst {
  position: fixed; top: 50%; left: 50%; width: 6px; height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--purple-glow) 0%, var(--purple-royal) 35%, transparent 72%);
  z-index: 20; opacity: 0; pointer-events: none;
}
.light-burst.bursting { animation: light-burst 1.4s ease-out forwards; }
@keyframes light-burst {
  0% { width: 6px; height: 6px; opacity: 0; }
  35% { width: 250vmax; height: 250vmax; opacity: 1; }
  100% { width: 250vmax; height: 250vmax; opacity: 0; }
}

/* ================= Welcome ================= */
#view-welcome.active {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 3rem 1.25rem;
}
.welcome-card { max-width: 620px; }
.welcome-eyebrow { color: var(--sand); font-size: 0.72rem; letter-spacing: 0.24em; text-transform: uppercase; margin-bottom: 0.8em; }
.welcome-subtitle {
  color: var(--gold-bright); font-style: italic; font-family: var(--font-body);
  text-transform: none; letter-spacing: 0.02em; font-size: 1.15rem; margin: -0.4em 0 1.2em;
}
.welcome-card .message { font-family: var(--font-body); font-size: 1.35rem; font-style: italic; color: var(--star-white); margin: 1.4em 0 2em; }
.welcome-byline { color: var(--parchment-dim); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; margin-top: 1.8em; }

/* ================= Lobby ================= */
#view-lobby {
  min-height: 100vh; padding: 3rem 1.25rem 5rem; text-align: center;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(217,113,60,0.28) 0%, transparent 55%),
    linear-gradient(180deg, transparent 35%, rgba(156,44,58,0.1) 100%);
}
.lobby-quote {
  max-width: 560px; margin: 1.2rem auto 0; font-family: var(--font-body); font-style: italic;
  color: var(--parchment-dim); font-size: 1rem; line-height: 1.6;
}
.lobby-movement {
  max-width: 620px; margin: 0.9rem auto 0; font-family: var(--font-display);
  color: var(--gold-bright); font-size: 1.3rem; line-height: 1.45;
  letter-spacing: 0.02em; font-weight: 600; text-transform: none;
  text-shadow: 0 0 22px rgba(212,175,55,0.3);
}
.lobby-portals {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem;
  max-width: 980px; margin: 3rem auto 0;
}
.portal {
  --glow: var(--gold);
  position: relative;
  width: 170px; height: 220px;
  border: 1px solid var(--glow);
  border-radius: 85px 85px 6px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--purple-deep);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 1.4rem 1rem;
  text-decoration: none;
  color: var(--parchment);
  transition: transform 0.35s var(--ease-soft), box-shadow 0.35s var(--ease-soft);
  overflow: hidden;
}
.portal::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--glow) 35%, transparent), transparent 65%);
  opacity: 0.7;
}
.portal:hover, .portal:focus-visible {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px color-mix(in srgb, var(--glow) 45%, transparent);
}
.portal .label { position: relative; font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; font-size: 1rem; color: var(--star-white); }
.portal .sub { position: relative; font-size: 0.78rem; color: var(--parchment-dim); font-family: var(--font-body); margin-top: 0.3em; }
#portal-body { --glow: var(--room-body); }
#portal-mind { --glow: var(--room-mind); }
#portal-soul { --glow: var(--room-soul); }
#portal-connect { --glow: var(--room-connect); }
#portal-business { --glow: var(--room-business); }
#portal-events { --glow: var(--room-events); }
.portal .sub.badge-soon { margin-top: 0.5em; }

.lobby-foot { margin-top: 3rem; display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }

/* ================= Room shell ================= */
.room {
  min-height: 100vh;
  padding: 4.5rem 1.25rem 4rem;
}
.room[data-room="body"] { --accent: var(--room-body); }
.room[data-room="mind"] { --accent: var(--room-mind); }
.room[data-room="soul"] { --accent: var(--room-soul); }
.room[data-room="connect"] { --accent: var(--room-connect); }
.room[data-room="business"] { --accent: var(--room-business); }
.room[data-room="events"] { --accent: var(--room-events); }

.room-header {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto 1.5rem;
}
.room-header h2 { color: var(--accent); margin: 0; filter: brightness(1.3); }
.room-header .back { font-size: 0.65rem; padding: 0.6em 1.1em; }
.room-intro { max-width: 640px; margin: 0 auto 2rem; color: var(--parchment-dim); text-align: center; }

/* ================= Star map ================= */
.starmap-controls {
  display: flex; justify-content: center; gap: 0.6rem; margin-bottom: 1.4rem; flex-wrap: wrap;
}
.starmap-controls button.active { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.starmap-hint {
  text-align: center; margin: -0.6rem auto 1.2rem; max-width: 480px;
  color: var(--sand); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  font-style: italic; opacity: 0.7;
}
.starmap-wrap {
  max-width: 900px; margin: 0 auto; position: relative;
  transition: transform 0.55s var(--ease-ritual);
  transform-origin: center center;
}
.starmap-svg { width: 100%; height: auto; display: block; }
.star-line {
  stroke: color-mix(in srgb, var(--accent) 55%, var(--parchment-dim));
  stroke-width: 1;
  opacity: 0.35;
  fill: none;
  transition: opacity 0.4s ease, stroke-width 0.4s ease;
}
.star-line.dim { opacity: 0.08; }
.star-line.lit { opacity: 0.9; stroke-width: 1.6; }
.star-node circle.core {
  fill: var(--night-sky);
  stroke: var(--accent);
  stroke-width: 1.4;
  transition: r 0.3s ease, fill 0.3s ease, filter 0.3s ease;
  cursor: pointer;
}
.star-node:hover circle.core, .star-node.visited circle.core { fill: var(--accent); filter: drop-shadow(0 0 6px var(--accent)); }
.star-node.current circle.core { fill: var(--gold-bright); stroke: var(--gold-bright); filter: drop-shadow(0 0 10px var(--gold-bright)); }
.star-node.dim { opacity: 0.25; }
.label-backdrop { fill: var(--night-sky); opacity: 0.82; }
.star-node text {
  fill: var(--parchment);
  font-family: var(--font-display);
  font-size: 6px;
  text-anchor: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.star-detail {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(8,6,16,0.86);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease;
}
.star-detail.open { opacity: 1; pointer-events: auto; }
.star-detail-card {
  max-width: 560px; max-height: 80vh; overflow-y: auto;
  background: linear-gradient(160deg, var(--purple-deep), var(--ink));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.star-detail-card h3 { color: var(--accent); filter: brightness(1.4); }
.star-detail-card .kernel-index { color: var(--parchment-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.6em; }
.star-detail-card .explore-deeper { margin-top: 1.4rem; width: 100%; }
.star-detail-nav { display: flex; justify-content: space-between; margin-top: 1.6rem; gap: 0.6rem; }
.star-detail-close { position: absolute; top: 1rem; right: 1.2rem; font-size: 1.1rem; border: none; padding: 0.2em 0.5em; }

/* ================= Cycle tracker (coming soon) ================= */
.cycle-track-note { max-width: 560px; margin: 3rem auto 0; text-align: center; }
.cycle-track-btn { width: 100%; }
.cycle-track-why { font-size: 0.9rem; color: var(--parchment-dim); margin-top: 1.2rem; line-height: 1.65; }

/* ================= Toggle cards (Connect + Ethical Business) ================= */
.card-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem; max-width: 480px; margin: 0 auto 3rem;
}
.flip-card { perspective: 1200px; height: 210px; }
.flip-card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform 0.7s var(--ease-ritual);
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 1rem; display: flex; flex-direction: column;
  background: linear-gradient(160deg, var(--purple-deep), var(--ink));
}
.flip-front { justify-content: flex-end; }
.practitioner-photo { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 1px solid var(--gold-bright); margin-bottom: 0.5em; box-shadow: 0 0 10px rgba(0,0,0,0.5); }
.flip-front .name { color: var(--star-white); font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.92rem; }
.flip-front .specialty { color: var(--accent); filter: brightness(1.4); font-size: 0.74rem; margin-top: 0.25em; }
.flip-back { transform: rotateY(180deg); justify-content: space-between; overflow-y: auto; }
.flip-back p { font-size: 0.74rem; line-height: 1.4; }
.practitioner-links { font-size: 0.72rem; }
.practitioner-links a { color: var(--accent); filter: brightness(1.4); }
.flip-hint { font-size: 0.58rem; color: var(--parchment-dim); text-transform: uppercase; letter-spacing: 0.06em; align-self: flex-start; }

/* ================= Forms ================= */
.signup-panel {
  max-width: 480px; margin: 3rem auto 0; border-top: none;
  padding-top: 2.2rem; text-align: center; position: relative;
}
.signup-panel::before {
  content: '❦'; position: absolute; top: -0.55em; left: 50%; transform: translateX(-50%);
  color: var(--gold-bright); font-size: 1.2rem; text-shadow: 0 0 10px rgba(212,175,55,0.5);
}
.signup-panel::after {
  content: ''; position: absolute; top: 0; left: 15%; right: 15%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.4), transparent);
}
.signup-panel h3 { color: var(--accent); filter: brightness(1.3); }
.signup-panel form { text-align: left; margin-top: 1.2rem; }
.signup-panel button[type="submit"] { width: 100%; margin-top: 1.4rem; }
.form-msg { margin-top: 1rem; font-size: 0.85rem; color: var(--sand); min-height: 1.2em; }

/* ================= Follow-the-build ================= */
.follow-build {
  display: block; width: fit-content; margin: 2.5rem auto 2rem; z-index: 8;
  font-size: 0.68rem; padding: 0.6em 1.1em; text-align: center;
  background: rgba(12,10,26,0.7); backdrop-filter: blur(4px); border-radius: var(--radius);
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .lobby-portals { gap: 1.2rem; }
  .portal { width: 140px; height: 190px; }
  .follow-build { font-size: 0.6rem; padding: 0.5em 0.8em; }
  #view-welcome.active { align-items: flex-start; padding-top: 4rem; }
  .welcome-moon { bottom: -14vw; }
  .lobby-movement { font-size: 1.1rem; }
  .flip-card { height: 340px; }
}
