/* ============================================
   Amber · 30 — Style System
   ============================================ */

:root {
  /* Soul world palette */
  --cream-mint: #E8F4EC;
  --soft-purple: #C8B4D8;
  --peach: #FFD4B8;
  --sky-blue: #A8D8E0;

  /* Amber bridge */
  --amber-gold: #D4A574;
  --amber-glow: #F5C882;

  /* Special */
  --mizu-cyan: #7EC8D4;
  --deep-black: #0A0A0F;
  --deep-black-90: rgba(10, 10, 15, 0.9);

  /* Typography */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-cn: 'LXGW WenKai', 'PingFang SC', sans-serif;

  /* Spacing */
  --section-pad: clamp(3rem, 8vh, 6rem);
}

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

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

body {
  background: var(--deep-black);
  color: #E8E4DF;
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(212, 165, 116, 0.3); border-radius: 2px; }

/* ============================================
   Module 1: Orb Overlay
   ============================================ */
#orb-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--deep-black);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}

#orb-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

#orb-overlay.hidden {
  display: none;
}

#orb-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================
   Module 2: Hero
   ============================================ */
#hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(200, 180, 216, 0.08) 0%, transparent 70%);
  overflow: hidden;
}

.hero-inner {
  padding: 2rem;
  opacity: 0;
  transform: translateY(20px);
  animation: hero-fade-in 1.2s ease forwards;
  animation-delay: 0.3s;
}

@keyframes hero-fade-in {
  to { opacity: 1; transform: translateY(0); }
}

.hero-name {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(4rem, 12vw, 9rem);
  letter-spacing: 0.08em;
  color: #F0EBE3;
  margin-bottom: 0.3em;
  animation: gentle-float 6s ease-in-out infinite;
  cursor: default;
}

@keyframes gentle-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hero-name-cn {
  font-family: var(--font-cn);
  font-weight: 400;
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: 0.6em;
  color: var(--amber-glow);
  margin-bottom: 1.5em;
  opacity: 0.85;
}

.hero-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.95rem, 2.2vw, 1.3rem);
  color: rgba(232, 228, 223, 0.6);
  line-height: 1.9;
  max-width: 32em;
  margin: 0 auto;
}

/* ============================================
   Module 3: Counter
   ============================================ */
#counter {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--section-pad) 2rem;
  background: radial-gradient(ellipse at 50% 60%, rgba(232, 244, 236, 0.04) 0%, transparent 60%);
}

.counter-inner {
  max-width: 600px;
}

.counter-label {
  font-family: var(--font-cn);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: rgba(232, 228, 223, 0.7);
  margin-bottom: 1rem;
}

.counter-number {
  margin: 0.5rem 0;
}

.counter-value {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(3rem, 10vw, 6rem);
  color: var(--amber-glow);
  font-variant-numeric: tabular-nums;
}

.counter-unit {
  font-family: var(--font-cn);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: rgba(232, 228, 223, 0.5);
}

.counter-detail {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  color: rgba(232, 228, 223, 0.35);
  letter-spacing: 0.05em;
  min-height: 1.5em;
}

.counter-since {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: rgba(232, 228, 223, 0.3);
  letter-spacing: 0.1em;
  margin-top: 0.5rem;
}

.counter-divider {
  margin: 3rem 0 2rem;
}

.counter-poem {
  font-family: var(--font-cn);
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: rgba(232, 228, 223, 0.6);
  line-height: 2;
}

.counter-coda {
  font-family: var(--font-cn);
  font-size: clamp(0.85rem, 2vw, 1rem);
  color: rgba(232, 228, 223, 0.35);
  margin-top: 3rem;
  letter-spacing: 0.15em;
}

/* ============================================
   Module 4: Starfield
   ============================================ */
#starfield {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

#starfield-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: -1;
  pointer-events: none;
}

.starfield-overlay {
  position: absolute;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.5s ease;
}

.starfield-overlay.visible {
  opacity: 1;
}

.starfield-date {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 300;
  color: rgba(232, 228, 223, 0.8);
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
}

.starfield-sign {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  font-weight: 300;
  color: var(--amber-glow);
  letter-spacing: 0.3em;
  opacity: 0.7;
}

/* ============================================
   Module 5: Constellation (Core)
   ============================================ */
#constellation {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

#constellation-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: pan-y;
}

#constellation-canvas:active {
  cursor: grabbing;
}

.constellation-ui {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem;
  text-align: center;
  pointer-events: none;
  background: linear-gradient(to top, rgba(10, 10, 15, 0.6) 0%, transparent 100%);
}

.constellation-title {
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  font-weight: 300;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(232, 228, 223, 0.35);
  margin-bottom: 0.4rem;
}

.constellation-hint {
  font-family: var(--font-cn);
  font-size: clamp(0.8rem, 1.5vw, 0.9rem);
  color: rgba(232, 228, 223, 0.4);
  margin-bottom: 0.8rem;
  transition: opacity 0.5s ease;
}

.constellation-progress {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.85rem, 1.5vw, 1rem);
  color: var(--amber-glow);
  opacity: 0.7;
}

.constellation-reset {
  pointer-events: auto;
  background: none;
  border: 1px solid rgba(232, 228, 223, 0.15);
  color: rgba(232, 228, 223, 0.3);
  font-size: 0.85rem;
  padding: 0.2em 0.5em;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: color 0.3s, border-color 0.3s;
}

.constellation-reset:hover {
  color: rgba(232, 228, 223, 0.6);
  border-color: rgba(232, 228, 223, 0.3);
}

/* ============================================
   Spark Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 1.5rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  max-width: 440px;
  width: 100%;
  padding: clamp(2rem, 5vw, 3rem);
  background: rgba(30, 30, 40, 0.65);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(245, 200, 130, 0.12);
  border-radius: 16px;
  text-align: center;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  color: rgba(232, 228, 223, 0.4);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.3rem;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--amber-glow);
}

.modal-star {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: rgba(232, 228, 223, 0.3);
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}

.modal-title {
  font-family: var(--font-cn);
  font-weight: 400;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  color: var(--amber-glow);
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.modal-body {
  font-family: var(--font-cn);
  font-size: clamp(0.95rem, 2.2vw, 1.05rem);
  color: rgba(232, 228, 223, 0.85);
  line-height: 2;
  white-space: pre-line;
}

/* ============================================
   Module 6: Letter
   ============================================ */
#letter {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--section-pad) 2rem;
  background: radial-gradient(ellipse at 50% 50%, rgba(212, 165, 116, 0.06) 0%, transparent 60%);
}

.letter-inner {
  max-width: 520px;
  width: 100%;
  text-align: left;
}

.letter-greeting {
  font-family: var(--font-cn);
  font-size: clamp(1.1rem, 2.5vw, 1.3rem);
  color: var(--amber-glow);
  margin-bottom: 2rem;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.letter-greeting.visible {
  opacity: 1;
}

.letter-body {
  font-family: var(--font-cn);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  color: rgba(232, 228, 223, 0.75);
  line-height: 2.2;
  margin-bottom: 3rem;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.letter-body.visible {
  opacity: 1;
}

.letter-body p {
  margin-bottom: 1em;
}

.letter-sign {
  font-family: var(--font-cn);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  color: rgba(232, 228, 223, 0.5);
  text-align: right;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.letter-sign.visible {
  opacity: 1;
}

/* Typewriter cursor */
.tw-cursor {
  display: inline;
  color: var(--amber-glow);
  font-weight: 100;
  margin-left: 1px;
  animation: cursorBlink 0.85s step-end infinite;
  transition: opacity 1.5s ease;
}

.tw-cursor.fade-out {
  opacity: 0;
  animation: none;
}

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

/* ============================================
   Module 7: Ending
   ============================================ */
#ending {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ending-inner {
  padding: 2rem;
}

.ending-text {
  font-family: var(--font-cn);
  font-weight: 400;
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  color: var(--amber-glow);
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 1.5s ease, transform 1.5s ease;
}

.ending-text.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Easter Egg
   ============================================ */
.easter-egg-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.easter-egg-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.easter-egg-inner {
  text-align: center;
  padding: 2rem;
}

.easter-egg-text {
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 1.5vw, 1rem);
  color: rgba(232, 228, 223, 0.4);
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
}

.easter-egg-message {
  font-family: var(--font-cn);
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  color: var(--amber-glow);
  margin-bottom: 2rem;
}

.easter-egg-close {
  background: none;
  border: 1px solid rgba(245, 200, 130, 0.2);
  color: var(--amber-glow);
  font-size: 1.5rem;
  padding: 0.5rem 1.5rem;
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.3s, transform 0.3s;
}

.easter-egg-close:hover {
  border-color: var(--amber-glow);
  transform: scale(1.1);
}

/* ============================================
   Music Toggle
   ============================================ */
.music-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 800;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(245, 200, 130, 0.25);
  background: rgba(10, 10, 15, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(245, 200, 130, 0.6);
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 0.3s, color 0.3s, transform 0.3s;
  line-height: 1;
}

.music-toggle:hover {
  border-color: var(--amber-glow);
  color: var(--amber-glow);
  transform: scale(1.1);
}

.music-toggle.playing {
  animation: music-pulse 2s ease-in-out infinite;
}

@keyframes music-pulse {
  0%, 100% { border-color: rgba(245, 200, 130, 0.25); }
  50% { border-color: rgba(245, 200, 130, 0.6); }
}

/* ============================================
   Utility
   ============================================ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 600px) {
  .counter-value {
    font-size: clamp(4rem, 8vw, 6rem);
  }

  .modal-card {
    padding: 3rem;
  }
}

@media (min-width: 1024px) {
  .hero-tagline {
    font-size: 1.3rem;
  }

  .modal-card {
    max-width: 480px;
  }

  .letter-inner {
    max-width: 560px;
  }
}
