/* ========================================================
   DIGITAL SANCTUARY - A GHIBLI-INSPIRED PASTEL HAVEN
   ======================================================== */

:root {
  /* Default: Twilight Theme */
  --sky-top: #E6D2ED;
  --sky-mid: #F8D7DA;
  --sky-bot: #FEECE2;
  --cloud-tint: rgba(255, 245, 250, 0.75);
  --cloud-shadow: rgba(210, 185, 215, 0.35);
  --celestial-color: #FFF6DD;
  --celestial-glow: rgba(255, 235, 180, 0.45);
  --text-main: #4A3E56;
  --text-sub: #7A6989;
  --ui-bg: rgba(255, 255, 255, 0.45);
  --ui-border: rgba(255, 255, 255, 0.65);
  --ui-text: #594A67;
  --pacer-color: #D29BB9;
}

body.theme-dawn {
  --sky-top: #FFE5D9;
  --sky-mid: #FFCAD4;
  --sky-bot: #E8ECE9;
  --cloud-tint: rgba(255, 250, 245, 0.8);
  --cloud-shadow: rgba(255, 205, 195, 0.35);
  --celestial-color: #FFF9E6;
  --celestial-glow: rgba(255, 220, 150, 0.5);
  --text-main: #4F433F;
  --text-sub: #7D6B65;
  --ui-bg: rgba(255, 250, 245, 0.5);
  --ui-border: rgba(255, 255, 255, 0.7);
  --ui-text: #5A4C46;
  --pacer-color: #E5989B;
}

body.theme-noon {
  --sky-top: #D0E8F2;
  --sky-mid: #DEEDF0;
  --sky-bot: #F4F8F7;
  --cloud-tint: rgba(255, 255, 255, 0.85);
  --cloud-shadow: rgba(180, 215, 230, 0.35);
  --celestial-color: #FFFDF0;
  --celestial-glow: rgba(255, 245, 200, 0.6);
  --text-main: #334A52;
  --text-sub: #5C7780;
  --ui-bg: rgba(255, 255, 255, 0.55);
  --ui-border: rgba(255, 255, 255, 0.75);
  --ui-text: #415A63;
  --pacer-color: #79B4B7;
}

body.theme-twilight {
  --sky-top: #D8CCE5;
  --sky-mid: #FAD2E1;
  --sky-bot: #FDE2E4;
  --cloud-tint: rgba(255, 240, 248, 0.78);
  --cloud-shadow: rgba(200, 180, 215, 0.35);
  --celestial-color: #FFF5DA;
  --celestial-glow: rgba(255, 230, 175, 0.5);
  --text-main: #483B55;
  --text-sub: #746382;
  --ui-bg: rgba(255, 255, 255, 0.45);
  --ui-border: rgba(255, 255, 255, 0.65);
  --ui-text: #564666;
  --pacer-color: #C38D9E;
}

body.theme-night {
  --sky-top: #3D3552;
  --sky-mid: #52476B;
  --sky-bot: #7D6B91;
  --cloud-tint: rgba(138, 125, 163, 0.45);
  --cloud-shadow: rgba(45, 38, 62, 0.4);
  --celestial-color: #FFF9DB;
  --celestial-glow: rgba(255, 245, 195, 0.55);
  --text-main: #F4EEF7;
  --text-sub: #C8BFD6;
  --ui-bg: rgba(65, 55, 85, 0.5);
  --ui-border: rgba(160, 145, 190, 0.35);
  --ui-text: #E5DEF0;
  --pacer-color: #B5A0D3;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--sky-top);
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--text-main);
  transition: background-color 1.8s ease, color 1.8s ease;
  position: relative;
}

/* ========================================================
   WATERCOLOR PAPER TEXTURE
   ======================================================== */
.paper-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* ========================================================
   SKY GRADIENT & CELESTIAL ORB
   ======================================================== */
.sky-background {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 50%, var(--sky-bot) 100%);
  transition: background 1.8s ease;
}

.celestial-body {
  position: absolute;
  top: 10%;
  right: 18%;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--celestial-color) 0%, rgba(255, 255, 255, 0.8) 50%, transparent 80%);
  box-shadow: 0 0 70px 25px var(--celestial-glow);
  transition: all 1.8s ease;
  pointer-events: none;
  animation: celestialBreathe 8s ease-in-out infinite alternate;
}

@keyframes celestialBreathe {
  0% { transform: scale(1) translateY(0); opacity: 0.9; }
  100% { transform: scale(1.06) translateY(-5px); opacity: 1; }
}

/* ========================================================
   PASTEL DRIFTING CLOUDS (PARALLAX LAYERS)
   ======================================================== */
.cloud-layer {
  position: absolute;
  width: 250%;
  height: 100%;
  pointer-events: none;
  background-repeat: repeat-x;
}

/* Back clouds: Slow and dreamy */
.cloud-layer-back {
  top: 15%;
  height: 280px;
  opacity: 0.55;
  background-image: 
    radial-gradient(circle 90px at 10% 80%, var(--cloud-tint) 100%, transparent),
    radial-gradient(circle 140px at 30% 70%, var(--cloud-tint) 100%, transparent),
    radial-gradient(circle 110px at 50% 85%, var(--cloud-tint) 100%, transparent),
    radial-gradient(circle 150px at 75% 75%, var(--cloud-tint) 100%, transparent),
    radial-gradient(circle 90px at 95% 80%, var(--cloud-tint) 100%, transparent);
  animation: driftClouds 160s linear infinite;
  filter: blur(12px);
}

/* Mid clouds */
.cloud-layer-mid {
  top: 35%;
  height: 240px;
  opacity: 0.65;
  background-image: 
    radial-gradient(circle 80px at 15% 75%, var(--cloud-tint) 100%, transparent),
    radial-gradient(circle 120px at 35% 85%, var(--cloud-tint) 100%, transparent),
    radial-gradient(circle 100px at 60% 80%, var(--cloud-tint) 100%, transparent),
    radial-gradient(circle 130px at 85% 85%, var(--cloud-tint) 100%, transparent);
  animation: driftClouds 100s linear infinite reverse;
  filter: blur(6px);
}

/* Front soft fog clouds below the island */
.cloud-layer-front {
  bottom: 0;
  height: 260px;
  opacity: 0.45;
  background-image: 
    radial-gradient(ellipse 400px 140px at 20% 90%, var(--cloud-tint) 100%, transparent),
    radial-gradient(ellipse 550px 160px at 65% 95%, var(--cloud-tint) 100%, transparent),
    radial-gradient(ellipse 350px 130px at 95% 90%, var(--cloud-tint) 100%, transparent);
  animation: driftClouds 65s linear infinite;
  filter: blur(18px);
}

@keyframes driftClouds {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ========================================================
   CANVAS FOR PETALS, FIREFLIES & FAIRY DUST
   ======================================================== */
#ambientCanvas {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* ========================================================
   SCENE CONTAINER & FLOATING ISLAND
   ======================================================== */
.scene-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5;
  pointer-events: none;
  perspective: 1200px;
}

.floating-island-wrapper {
  position: relative;
  width: min(850px, 92vw);
  max-height: 82vh;
  margin-top: -4vh;
  transform-style: preserve-3d;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0.2, 1);
  animation: floatIsland 7s ease-in-out infinite alternate;
}

.island-svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 25px 35px rgba(55, 45, 75, 0.12));
}

/* Island Floating Bob */
@keyframes floatIsland {
  0% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-16px) rotate(0.4deg);
  }
  100% {
    transform: translateY(-4px) rotate(-0.3deg);
  }
}

/* The Swing swaying naturally in the wind */
.island-swing {
  transform-origin: 615px 198px;
  animation: swaySwing 5.5s ease-in-out infinite alternate;
}

@keyframes swaySwing {
  0% {
    transform: rotate(3.2deg);
  }
  50% {
    transform: rotate(-3.8deg);
  }
  100% {
    transform: rotate(2.8deg);
  }
}

/* Pulsing crystals under island */
.pulsing-crystal {
  animation: crystalPulse 3.5s ease-in-out infinite alternate;
}
.delay-1 { animation-delay: 1.1s; }
.delay-2 { animation-delay: 2.3s; }

@keyframes crystalPulse {
  0% { opacity: 0.4; r: 3.5; }
  100% { opacity: 1; r: 5.5; }
}

/* Satellite floating rocks */
.satellite-rock {
  animation: satelliteFloat 6s ease-in-out infinite alternate;
}
.rock-2 {
  animation-duration: 8s;
  animation-delay: -3s;
}

@keyframes satelliteFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-12px) translateX(4px); }
}

/* Soft Lantern Glow */
.hanging-lantern {
  animation: lanternGlow 4s ease-in-out infinite alternate;
}

@keyframes lanternGlow {
  0% { opacity: 0.75; transform: rotate(0deg); }
  50% { transform: rotate(2deg); }
  100% { opacity: 1; transform: rotate(-2deg); }
}

/* ========================================================
   POETIC TYPOGRAPHY & MESSAGE (CENTER BOTTOM)
   ======================================================== */
.message-container {
  position: fixed;
  bottom: 5vh;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  pointer-events: none;
  padding: 0 20px;
}

.quote-wrapper {
  max-width: 680px;
  text-align: center;
  padding: 18px 32px;
  background: var(--ui-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--ui-border);
  border-radius: 36px;
  box-shadow: 0 10px 30px rgba(50, 30, 60, 0.06);
  transition: all 1.2s ease;
  animation: fadeInSlow 2.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.quote-text {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1.25rem, 2.5vw, 1.85rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.03em;
  color: var(--text-main);
  margin-bottom: 6px;
  transition: color 1.2s ease;
}

.quote-subline {
  font-size: clamp(0.78rem, 1.2vw, 0.92rem);
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-sub);
  opacity: 0.85;
  transition: color 1.2s ease;
}

@keyframes fadeInSlow {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================================
   ZEN CONTROLS (TOP RIGHT CORNER)
   ======================================================== */
.zen-controls {
  position: fixed;
  top: 24px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
}

.zen-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--ui-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ui-border);
  border-radius: 30px;
  color: var(--ui-text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  cursor: pointer;
  outline: none;
  box-shadow: 0 4px 14px rgba(40, 25, 50, 0.05);
  transition: all 0.35s cubic-bezier(0.2, 0, 0, 1);
}

.zen-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 6px 18px rgba(40, 25, 50, 0.09);
}

.zen-btn:active {
  transform: translateY(0);
}

.zen-btn .icon {
  display: block;
}

/* Sound Toggle States */
.sound-mute-slash {
  transition: opacity 0.3s ease;
}
.zen-btn.sound-on .sound-mute-slash {
  opacity: 0;
}
.zen-btn.sound-on .wave-1 {
  animation: pulseWave 1.4s ease-in-out infinite alternate;
}
.zen-btn.sound-on .wave-2 {
  animation: pulseWave 1.4s ease-in-out infinite alternate 0.3s;
}

@keyframes pulseWave {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* Breathing Pacer Circle */
.breathe-pacer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--ui-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ui-border);
  border-radius: 30px;
  box-shadow: 0 4px 14px rgba(40, 25, 50, 0.05);
  pointer-events: auto;
}

.pacer-circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--pacer-color);
  box-shadow: 0 0 10px var(--pacer-color);
  animation: breatheCycle 9s ease-in-out infinite;
  transition: background-color 1.2s ease, box-shadow 1.2s ease;
}

.pacer-text {
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ui-text);
  min-width: 58px;
  text-align: center;
  font-weight: 400;
  transition: opacity 0.4s ease;
}

/* Inhale (4s), Hold (1s), Exhale (4s) */
@keyframes breatheCycle {
  0%, 100% {
    transform: scale(0.75);
    opacity: 0.55;
  }
  42% {
    transform: scale(1.4);
    opacity: 1;
  }
  55% {
    transform: scale(1.4);
    opacity: 1;
  }
  92% {
    transform: scale(0.75);
    opacity: 0.55;
  }
}

/* ========================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ======================================================== */
@media (max-width: 768px) {
  .zen-controls {
    top: 16px;
    right: 16px;
    gap: 8px;
  }

  .zen-btn .btn-label {
    display: none; /* Icon only for cleaner mobile header */
  }

  .zen-btn {
    padding: 8px 10px;
  }

  .breathe-pacer .pacer-text {
    display: none;
  }

  .breathe-pacer {
    padding: 8px 10px;
  }

  .floating-island-wrapper {
    width: 96vw;
    margin-top: -6vh;
  }

  .message-container {
    bottom: 3.5vh;
    padding: 0 16px;
  }

  .quote-wrapper {
    padding: 14px 20px;
    border-radius: 24px;
  }

  .quote-text {
    font-size: 1.2rem;
  }
}
