/* ═══════════════════════════════════════════════════════════
   V3 — Base Styles
   Reset, variables, typography, global elements
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:          #080c15;
  --surface:     #111827;
  --surface2:    #1a2236;
  --surface3:    #222d42;
  --border:      #1f2937;
  --border-light:#2a3650;
  --text:        #f0f2f8;
  --text-dim:    #c8cdd8;
  --muted:       #7b8ba5;
  /* Brand gradient: V-I-T-A (warm amber → hot pink → soft violet → lavender) */
  --vita-v:      #ffb347;  /* bright warm amber */
  --vita-i:      #ff6b9d;  /* hot pink */
  --vita-t:      #c471ed;  /* soft violet */
  --vita-a:      #e8a0ff;  /* light lavender */
  --accent:      #ff6b9d;  /* hot pink — primary accent */
  --accent-dim:  rgba(255, 107, 157, .15);
  --accent-glow: rgba(255, 107, 157, .25);
  --warm:        #f5a623;
  --success:     #4ade80;
  --green:       #4ade80;
  --cyan:        #22d3ee;
  --error:       #f87171;
  --pink:        #e84393;
  --radius:      16px;
  --radius-sm:   10px;
  --radius-xs:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,.3);
  --shadow-lg:   0 8px 40px rgba(0,0,0,.5);
  --transition:  .2s ease;
  --font:        -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input {
  font-family: var(--font);
  font-size: 16px; /* prevent iOS zoom */
}

img { max-width: 100%; display: block; }

/* ─── Starfield ──────────────────────────────────────────── */
.starfield {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.star {
  position: absolute; border-radius: 50%; background: #fff;
  animation: twinkle var(--dur) ease-in-out infinite alternate;
}
@keyframes twinkle {
  from { opacity: var(--o1); }
  to   { opacity: var(--o2); }
}

/* ─── Shooting Stars — tiny dot, no trail ─────────────── */
.shooting-star {
  position: absolute;
  width: 1.5px; height: 1.5px;
  border-radius: 50%;
  background: rgba(255,255,255,.85);
  box-shadow: 0 0 2px .5px rgba(255,255,255,.35);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* ─── Sunrise Gradient ──────────────────────────────────── */
.sunrise-glow {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 55%;
  background: linear-gradient(
    to top,
    rgba(255, 154, 120, .14) 0%,
    rgba(255, 182, 150, .09) 15%,
    rgba(248, 160, 180, .07) 30%,
    rgba(200, 140, 200, .04) 50%,
    transparent 100%
  );
  pointer-events: none;
}

/* ─── Festival Light Motes ──────────────────────────────── */
.mote {
  position: absolute;
  bottom: -10px;
  width: var(--msize); height: var(--msize);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    hsla(var(--mhue), var(--msat), var(--mlight), .7),
    hsla(var(--mhue), var(--msat), var(--mlight), .2) 40%,
    transparent 100%
  );
  box-shadow: 0 0 4px hsla(var(--mhue), var(--msat), var(--mlight), .35);
  animation:
    moteRise var(--mdur) ease-out var(--mdelay) infinite,
    moteWobble calc(var(--mdur) * 0.35) ease-in-out var(--mdelay) infinite;
  opacity: 0;
  will-change: transform, opacity;
}
@keyframes moteRise {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  4%   { opacity: .65; }
  20%  { transform: translateY(-20vh) translateX(var(--mdrift1)); opacity: .55; }
  /* Wind gust — sudden sideways jolt */
  35%  { transform: translateY(-35vh) translateX(calc(var(--mdrift1) + var(--mgust))); opacity: .5; }
  50%  { transform: translateY(-50vh) translateX(var(--mdrift2)); opacity: .35; }
  70%  { transform: translateY(-70vh) translateX(calc(var(--mdrift2) - var(--mgust) * 0.5)); opacity: .2; }
  100% { transform: translateY(-105vh) translateX(calc(var(--mdrift1) + var(--mgust))); opacity: 0; }
}
@keyframes moteWobble {
  0%, 100% { margin-left: 0; }
  20%  { margin-left: var(--mwobble); }
  50%  { margin-left: calc(var(--mwobble) * -0.6); }
  80%  { margin-left: calc(var(--mwobble) * 0.4); }
}

/* ─── App Shell ──────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}

/* ─── Page transitions ──────────────────────────────────── */
#app.page-exit,
#app.page-enter {
  will-change: opacity, transform;
}
#app.page-exit {
  animation: pageExit .12s cubic-bezier(.45, 0, .15, 1) forwards;
}
#app.page-enter {
  animation: pageEnter .25s cubic-bezier(.16, 1, .3, 1) forwards;
}
@keyframes pageExit {
  to { opacity: 0; transform: translateY(4px) scale(.997); }
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(6px) scale(.997); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Animations ─────────────────────────────────────────── */
.fade-up {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity .7s ease, transform .7s ease;
}
.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ─── Dual Diamond Loading Animation ────────────────────── */
.loading-morph-wrap {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  animation: loadingScaleIn .35s cubic-bezier(.34,1.56,.64,1) both;
}
.loading-morph-wrap::before {
  content: '';
  position: absolute;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--vita-i), var(--vita-t));
  filter: blur(16px);
  opacity: .15;
}
.loading-morph-outer {
  position: absolute;
  width: 42px; height: 42px;
  border: 2px solid transparent;
  background: linear-gradient(var(--bg), var(--bg)) padding-box,
              linear-gradient(135deg, var(--vita-i), var(--vita-t)) border-box;
  animation: loadingDualSpin 2s cubic-bezier(.4, 0, .2, 1) infinite,
             loadingDualM1 2s cubic-bezier(.4, 0, .2, 1) infinite;
}
.loading-morph-inner {
  position: absolute;
  width: 24px; height: 24px;
  border: 2px solid transparent;
  background: linear-gradient(var(--bg), var(--bg)) padding-box,
              linear-gradient(135deg, var(--vita-a), var(--vita-i)) border-box;
  animation: loadingDualSpin 2s cubic-bezier(.4, 0, .2, 1) infinite,
             loadingDualM2 2s cubic-bezier(.4, 0, .2, 1) infinite;
}
@keyframes loadingScaleIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes loadingDualSpin {
  to { transform: rotate(360deg); }
}
@keyframes loadingDualM1 {
  0%, 100% { border-radius: 4px; opacity: .9; }
  50%      { border-radius: 50%; opacity: .5; }
}
@keyframes loadingDualM2 {
  0%, 100% { border-radius: 50%; opacity: .5; }
  50%      { border-radius: 4px; opacity: .9; }
}
/* Centered loading container — always dead center of available space */
.loading-morph-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
  width: 100%;
}

/* ─── Utility ────────────────────────────────────────────── */
.accent {
  background: linear-gradient(135deg, var(--vita-v), var(--vita-i), var(--vita-t), var(--vita-a));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.warm   { color: var(--warm); }
.muted  { color: var(--muted); }

/* ─── Boot Loader — Gradient Reveal ───────────────────────── */
.boot-loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100dvh; position: relative; overflow: hidden;
}
.boot-reveal-words {
  position: relative;
  font-size: 38px; font-weight: 800; letter-spacing: -.03em;
  height: 50px; display: flex; align-items: center; justify-content: center;
}
.boot-word {
  position: absolute;
  opacity: 0;
  color: rgba(255,255,255,.9);
  -webkit-mask-image: linear-gradient(to right, black 0%, black 0%, transparent 0%);
  mask-image: linear-gradient(to right, black 0%, black 0%, transparent 0%);
  transition: opacity .3s ease;
}
.boot-word-active {
  opacity: 1;
  animation: bootRevealMask 1s cubic-bezier(.4,0,.2,1) forwards;
}
.boot-word-exit {
  opacity: 0;
  animation: bootFadeOut .3s ease forwards;
}
.boot-vita {
  background: linear-gradient(135deg, var(--vita-v), var(--vita-i), var(--vita-t), var(--vita-a));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.boot-live-dot {
  display: inline-block; width: 8px; height: 8px;
  background: #ffffff; border-radius: 50%;
  margin-left: 3px; vertical-align: middle;
  box-shadow: 0 0 6px rgba(255,255,255,.6);
}
@keyframes bootRevealMask {
  0%   { -webkit-mask-image: linear-gradient(to right, black 0%, transparent 20%); mask-image: linear-gradient(to right, black 0%, transparent 20%); }
  100% { -webkit-mask-image: linear-gradient(to right, black 0%, black 100%, transparent 100%); mask-image: linear-gradient(to right, black 0%, black 100%, transparent 100%); }
}
/* Fade out the boot loader when app hydrates */
.boot-loader.hiding {
  animation: bootFadeOut .35s ease forwards;
  pointer-events: none;
}
@keyframes bootFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ─── Reduced motion — accessibility ──────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  #app.page-exit,
  #app.page-enter { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Gradient Morph Loader ────────────────────────────────── */
.gm-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 200px;
  position: absolute;
  inset: 0;
  z-index: 10;
  animation: gmScaleIn 600ms cubic-bezier(.16, 1, .3, 1) both;
}
.gm-loader.gm-hiding {
  animation: gmFadeOut 350ms ease forwards;
  pointer-events: none;
}

@keyframes gmScaleIn {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes gmFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.gm-blob-wrapper {
  position: relative;
  width: 140px;
  height: 140px;
  margin-bottom: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gm-blob {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb347, #ff6b9d, #c471ed, #7c9cff);
  background-size: 300% 300%;
  animation: gmGradientShift 4s ease-in-out infinite, gmMorph 6s ease-in-out infinite;
  filter: blur(0.5px);
  box-shadow:
    0 0 40px rgba(255, 107, 157, 0.3),
    0 0 80px rgba(196, 113, 237, 0.15);
}

.gm-blob-glow {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb347, #ff6b9d, #c471ed, #7c9cff);
  background-size: 300% 300%;
  animation: gmGradientShift 4s ease-in-out infinite, gmMorph 6s ease-in-out infinite;
  filter: blur(20px);
  opacity: 0.4;
}

@keyframes gmGradientShift {
  0%   { background-position: 0% 50%; }
  25%  { background-position: 100% 50%; }
  50%  { background-position: 100% 100%; }
  75%  { background-position: 0% 100%; }
  100% { background-position: 0% 50%; }
}

@keyframes gmMorph {
  0%, 100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    transform: rotate(0deg) scale(1);
  }
  25% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    transform: rotate(45deg) scale(1.05);
  }
  50% {
    border-radius: 50% 60% 30% 60% / 30% 50% 70% 50%;
    transform: rotate(90deg) scale(0.95);
  }
  75% {
    border-radius: 40% 30% 60% 50% / 60% 40% 50% 70%;
    transform: rotate(135deg) scale(1.02);
  }
}

.gm-typewriter-wrapper {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gm-text {
  color: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.2px;
  text-align: center;
  white-space: nowrap;
  font-family: var(--font);
}

.gm-cursor {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.5);
  margin-left: 2px;
  vertical-align: middle;
  animation: gmBlink 0.8s ease-in-out infinite;
}

@keyframes gmBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
