/* ==========================================================================
   Merry Christmas — 3D Luminous Particle Tree Stylesheet
   Pure obsidian stage, ethereal rose-silver calligraphy, whisper-quiet HUD
   ========================================================================== */

:root {
  --bg-obsidian: #010002;
  --text-pearl: #f8eff4;
  --glow-primary: rgba(238, 168, 206, 0.72);
  --glow-secondary: rgba(212, 134, 186, 0.42);
  --glow-gold: rgba(255, 220, 152, 0.35);
  --glass-bg: rgba(14, 10, 16, 0.56);
  --glass-border: rgba(255, 224, 240, 0.14);
  --glass-border-hover: rgba(255, 226, 242, 0.32);
  --accent: #f3b8d6;
  --accent-gold: #f6d48b;
  --ui-muted: rgba(248, 238, 244, 0.62);
}

/* Theme CSS variables for synchronized typography glow */
body[data-theme="champagne"] {
  --text-pearl: #fff8eb;
  --glow-primary: rgba(255, 214, 140, 0.72);
  --glow-secondary: rgba(226, 168, 86, 0.44);
  --accent: #f7d68d;
}

body[data-theme="aurora"] {
  --text-pearl: #eef8ff;
  --glow-primary: rgba(145, 216, 255, 0.74);
  --glow-secondary: rgba(114, 164, 245, 0.44);
  --accent: #9edbff;
}

body[data-theme="emerald"] {
  --text-pearl: #f2fff6;
  --glow-primary: rgba(154, 238, 192, 0.68);
  --glow-secondary: rgba(242, 202, 114, 0.42);
  --accent: #a6ebc6;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-obsidian);
  color: var(--text-pearl);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  touch-action: none;
}

#gl-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  opacity: 0;
  transition: opacity 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}

#gl-canvas.ready {
  opacity: 1;
}

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

/* ==========================================================================
   Calligraphic "Merry Christmas" Overlay (Top-Left)
   ========================================================================== */

.greeting-overlay {
  position: fixed;
  top: clamp(28px, 11.5vh, 118px);
  left: clamp(24px, 6.2vw, 108px);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 1.6s cubic-bezier(0.22, 1, 0.36, 1) 0.35s,
    transform 1.6s cubic-bezier(0.22, 1, 0.36, 1) 0.35s;
}

body.scene-ready .greeting-overlay {
  opacity: 1;
  transform: translateY(0);
}

.greeting-title {
  font-family: "Pinyon Script", "Snell Roundhand", "Great Vibes", "Apple Chancery",
    "Edwardian Script ITC", "Brush Script MT", cursive;
  font-weight: 400;
  font-size: clamp(2.25rem, 5.2vw, 4.35rem);
  line-height: 1.15;
  letter-spacing: 0.025em;
  color: var(--text-pearl);
  background: linear-gradient(
    115deg,
    rgba(255, 250, 253, 0.96) 0%,
    rgba(246, 224, 238, 0.92) 38%,
    rgba(255, 255, 255, 1) 52%,
    rgba(240, 210, 228, 0.9) 70%,
    rgba(255, 245, 250, 0.95) 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(0 0 6px rgba(255, 246, 252, 0.52))
    drop-shadow(0 0 18px var(--glow-primary))
    drop-shadow(0 0 38px var(--glow-secondary));
  animation: titleShimmer 7.5s ease-in-out infinite;
  transition: filter 0.8s ease;
  padding: 0.08em 0.14em 0.12em 0.04em;
}

@keyframes titleShimmer {
  0%, 100% {
    background-position: 0% 50%;
    opacity: 0.93;
  }
  50% {
    background-position: 100% 50%;
    opacity: 1;
  }
}

.greeting-subtitle {
  margin-top: 2px;
  padding-left: 8px;
  font-family: "Cormorant Garamond", "Songti SC", "STSong", Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.88rem, 1.35vw, 1.15rem);
  letter-spacing: 0.18em;
  color: rgba(255, 238, 246, 0.78);
  text-shadow:
    0 0 10px var(--glow-primary),
    0 0 22px var(--glow-gold);
}

/* ==========================================================================
   Subtle Interaction Whisper
   ========================================================================== */

.hint-whisper {
  position: fixed;
  bottom: 24px;
  left: clamp(20px, 3vw, 38px);
  z-index: 12;
  pointer-events: none;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: rgba(255, 236, 214, 0.38);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 1.1s ease;
}

body.scene-ready .hint-whisper.visible {
  opacity: 1;
}

body.ui-hidden .hint-whisper,
body.ui-hidden .hud-dock,
body.ui-hidden .studio-drawer,
body.ui-hidden .gesture-pip {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ==========================================================================
   Top-Right Gesture Camera Preview PiP Card
   ========================================================================== */

.gesture-pip {
  position: fixed;
  top: clamp(16px, 2.4vw, 28px);
  right: clamp(16px, 2.4vw, 28px);
  z-index: 24;
  width: 224px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: rgba(12, 9, 16, 0.72);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 240, 248, 0.09);
  overflow: hidden;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.gesture-pip-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px 8px 12px;
  border-bottom: 1px solid rgba(255, 232, 244, 0.08);
}

.gesture-pip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #f6d48b;
  box-shadow: 0 0 8px rgba(246, 212, 139, 0.85);
}

.gesture-pip-dot.loading {
  background: #f3b8d6;
  animation: dotPulse 1.1s ease-in-out infinite;
}

.gesture-pip-dot.active {
  background: #7ef2b2;
  box-shadow: 0 0 8px rgba(126, 242, 178, 0.85);
}

@keyframes dotPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.gesture-pip-status {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: rgba(255, 244, 250, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gesture-pip-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.pip-icon-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: rgba(255, 238, 246, 0.65);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.pip-icon-btn svg {
  width: 13px;
  height: 13px;
}

.pip-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.gesture-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 10 / 7;
  background: radial-gradient(circle at center, rgba(36, 22, 34, 0.72) 0%, rgba(8, 5, 10, 0.95) 100%);
  overflow: hidden;
}

.gesture-stage.collapsed {
  display: none;
}

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

.gesture-legend {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 2px;
  padding: 7px 9px 8px;
  font-size: 10.5px;
  color: rgba(255, 238, 246, 0.68);
  text-align: center;
  border-top: 1px solid rgba(255, 232, 244, 0.06);
}

/* ==========================================================================
   Minimal Floating Action Dock (Bottom-Right)
   ========================================================================== */

.hud-dock {
  position: fixed;
  right: clamp(16px, 2.4vw, 30px);
  bottom: clamp(16px, 2.4vw, 28px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.36;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.hud-dock:hover,
.hud-dock:focus-within,
body.drawer-open .hud-dock {
  opacity: 1;
}

.hud-pill {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: rgba(255, 242, 248, 0.86);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.25s ease,
    background-color 0.25s ease,
    color 0.25s ease,
    box-shadow 0.25s ease;
}

.hud-pill svg {
  width: 17px;
  height: 17px;
}

.hud-pill:hover {
  transform: translateY(-2px);
  border-color: var(--glass-border-hover);
  background: rgba(28, 18, 30, 0.72);
  color: #ffffff;
  box-shadow: 0 0 18px rgba(243, 184, 214, 0.24);
}

.hud-pill:active {
  transform: scale(0.95);
}

.hud-pill.active {
  border-color: rgba(246, 212, 139, 0.55);
  color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(246, 212, 139, 0.26);
}

#btn-music .icon-music-on,
#btn-music.active .icon-music-off {
  display: none;
}

#btn-music.active .icon-music-on {
  display: block;
}

#btn-fullscreen .icon-fs-exit,
body.is-fullscreen #btn-fullscreen .icon-fs-enter {
  display: none;
}

body.is-fullscreen #btn-fullscreen .icon-fs-exit {
  display: block;
}

/* ==========================================================================
   Collapsible Glass Customization Drawer
   ========================================================================== */

.studio-drawer {
  position: fixed;
  right: clamp(16px, 2.4vw, 30px);
  bottom: clamp(66px, calc(2.4vw + 50px), 78px);
  z-index: 25;
  width: min(304px, calc(100vw - 32px));
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: rgba(12, 9, 15, 0.78);
  backdrop-filter: blur(22px) saturate(135%);
  -webkit-backdrop-filter: blur(22px) saturate(135%);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.68),
    inset 0 1px 0 rgba(255, 240, 248, 0.09);
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  pointer-events: none;
  transition:
    opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

body.drawer-open .studio-drawer {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 232, 244, 0.08);
}

.drawer-title {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: rgba(255, 244, 250, 0.92);
}

.drawer-close {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ui-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.drawer-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.drawer-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--ui-muted);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.theme-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 230, 244, 0.11);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 244, 250, 0.82);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.22s ease;
}

.theme-chip:hover {
  border-color: rgba(255, 230, 244, 0.28);
  background: rgba(255, 255, 255, 0.07);
}

.theme-chip.active {
  border-color: rgba(246, 200, 224, 0.55);
  background: rgba(243, 184, 214, 0.14);
  color: #ffffff;
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.28);
}

.swatch-rose {
  background: linear-gradient(135deg, #ffd7ec 0%, #e7a0ca 52%, #f0c26b 100%);
}

.swatch-champagne {
  background: linear-gradient(135deg, #fff5d6 0%, #f5c96e 55%, #d18e3b 100%);
}

.swatch-aurora {
  background: linear-gradient(135deg, #e4f7ff 0%, #8cd2ff 55%, #b49cff 100%);
}

.swatch-emerald {
  background: linear-gradient(135deg, #d8ffe9 0%, #5fd49d 55%, #f0c66c 100%);
}

.glass-input {
  width: 100%;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 232, 244, 0.13);
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.22s ease, background-color 0.22s ease;
}

.glass-input:focus {
  border-color: rgba(243, 184, 214, 0.5);
  background: rgba(255, 255, 255, 0.07);
}

.glass-input::placeholder {
  color: rgba(255, 238, 246, 0.34);
}

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slider-val {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 240, 246, 0.72);
}

.glass-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 236, 246, 0.16);
  outline: none;
  cursor: pointer;
}

.glass-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff4fa;
  box-shadow: 0 0 10px var(--glow-primary);
  border: 1px solid rgba(255, 255, 255, 0.9);
  transition: transform 0.15s ease;
}

.glass-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 2px;
}

.drawer-btn {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 232, 244, 0.13);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 244, 250, 0.88);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.drawer-btn:hover {
  border-color: rgba(255, 232, 244, 0.3);
  background: rgba(255, 255, 255, 0.09);
}

.drawer-btn-accent {
  grid-column: 1 / -1;
  border-color: rgba(243, 184, 214, 0.35);
  background: linear-gradient(
    135deg,
    rgba(243, 184, 214, 0.2) 0%,
    rgba(246, 212, 139, 0.18) 100%
  );
  color: #fff8fc;
}

.drawer-btn-accent:hover {
  border-color: rgba(246, 212, 139, 0.56);
  background: linear-gradient(
    135deg,
    rgba(243, 184, 214, 0.3) 0%,
    rgba(246, 212, 139, 0.28) 100%
  );
}

/* ==========================================================================
   Toast & Fallback
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 40;
  transform: translate(-50%, 14px);
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 232, 244, 0.2);
  background: rgba(16, 11, 20, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff6fa;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.fallback-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, #140b14 0%, #020103 75%);
  padding: 24px;
}

.fallback-card {
  max-width: 420px;
  text-align: center;
  padding: 32px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: rgba(16, 12, 20, 0.78);
}

.fallback-card h1 {
  font-family: "Pinyon Script", "Snell Roundhand", cursive;
  font-size: 2.6rem;
  margin-bottom: 12px;
}

.fallback-card p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ui-muted);
}

@media (max-width: 640px) {
  .greeting-overlay {
    top: 7vh;
    left: 22px;
  }

  .hint-whisper {
    display: none;
  }
}
