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

:root {
  --bg-main: linear-gradient(180deg, #F785FF 0%, #FF6EA5 49.04%, #FF8D8F 100%);
  --bg-vector: linear-gradient(180deg, #CE7AFF 0%, #FFAEDF 100%);
  --text-accent: #ffe0f5;
  --text-glow: rgba(255, 160, 220, 0.8);
}

html,
body {
  margin: 0;
  height: 100%;
  color: #e8dfd7;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}

.pink-bg {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: var(--bg-main);
  overflow: hidden;
  transition: background 0.5s ease;
}

.site-nav {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.site-brand,
.return-button {
  pointer-events: auto;
  color: #fff;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  text-shadow: 0 1px 5px rgba(51, 20, 52, 0.45);
  transition: opacity 0.2s ease;
}

.site-brand {
  margin-left: auto;
  padding: 10px 16px;
  letter-spacing: 0.06em;
  background: rgba(51, 20, 52, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
}
.site-brand[hidden] { display: none; }
.return-button { width: 44px; height: 44px; display: grid; place-items: center; }
.return-button svg { filter: drop-shadow(0 1px 3px rgba(51, 20, 52, 0.35)); }
.return-button[hidden] { display: none; }
.site-brand:hover,
.return-button:hover { opacity: 0.7; }
.site-brand:focus-visible,
.return-button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.vector-shadow-wrapper {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 0;
  filter:
    drop-shadow(0px -5px 0px rgba(0, 0, 0, 0.2)) drop-shadow(0px -15px 20px rgba(0, 0, 0, 0.15)) drop-shadow(0px -30px 50px rgba(0, 0, 0, 0.1));
  pointer-events: none;
}

.vector-1 {
  position: absolute;
  width: 100%;
  height: 70%;
  left: 0px;
  bottom: 0px;
  background: var(--bg-vector);
  /* Truly smooth responsive wave using SVG clipPath */
  clip-path: url("#wave-clip");
  transition: background 0.5s ease;
}

.stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  gap: 0;
}

.viewer {
  width: 100%;
  height: 100vh;
  max-width: 100%;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Promote to GPU layer so Three.js canvas doesn't fight with CSS compositing */
  will-change: transform;
}

.viewer canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.hint {
  position: absolute;
  bottom: 2rem;
  margin: 0;
  font-size: 0.875rem;
  opacity: 0.7;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: opacity 0.5s ease;
  z-index: 5;
}

.hint.hidden {
  opacity: 0;
  pointer-events: none;
}

.btn-select {
  position: absolute;
  bottom: 5rem;
  padding: 1rem 2.5rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white;
  font-family: 'K2D', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  border-radius: 40px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), inset 0 0 15px rgba(255, 255, 255, 0.1);
  z-index: 10;
  text-transform: uppercase;
  animation: pulseButton 3s infinite alternate;
}

@keyframes pulseButton {
  0% {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(255, 255, 255, 0.2);
  }

  100% {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 20px 5px rgba(255, 255, 255, 0.15);
  }
}

.btn-select:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  animation: none;
}

.btn-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  font-size: 1.5rem;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 10;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.btn-nav:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-50%) scale(1.15);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25), inset 0 0 10px rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-prev {
  left: 2rem;
}

.btn-next {
  right: 2rem;
}

/* =============================================
   CAKE INFO PANEL (Left Side)
   â€” Michroma / K2D style, like "LET YOUR INTENTIONS BLOOM"
   ============================================= */
.cake-info {
  position: absolute;
  left: 12vw;
  /* Shifted right to keep the 'pasok' position */
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  max-width: 80vw;
  width: min(700px, 95vw);
  pointer-events: none;
  transition: opacity 0.5s ease;
  text-align: left;
  /* Left align text relative to each other */
}

/* "NOW SERVING" micro-label */
.cake-label {
  margin: 0 0 18px 0;
  font-family: 'K2D', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--text-accent, rgba(255, 255, 255, 0.5));
  opacity: 0.85;
}

/* The big headline block */
.cake-name {
  margin: 0 0 28px 0;
  line-height: 0.9;
  font-style: normal;
  font-weight: normal;
}

/* Each word line â€” Michroma, uppercase */
.cake-word {
  display: flex;
  width: 100%;
  font-family: 'Michroma', sans-serif;
  text-transform: uppercase;
  line-height: 1.0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  justify-content: flex-start;
  will-change: transform, opacity;
}

.svg-text-shadow {
  filter: drop-shadow(4px 6px 4px rgba(0, 0, 0, 0.35));
}


/* Top word: gradient (like "YOUR" / "BLOOM" in the reference) */
.gradient-word {
  font-size: clamp(3rem, 7vw, 5.5rem);
  background: linear-gradient(135deg, var(--text-accent, #9395dd) 0%, #ffffff 50%, var(--text-accent, #9395dd) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
  animation: shineGradient 6s linear infinite;
}

@keyframes shineGradient {
  to {
    background-position: 200% center;
  }
}

/* Bottom word: plain white (like "LET" / "INTENTIONS" in the reference) */
.plain-word {
  font-size: clamp(4rem, 10vw, 10rem);
  color: #ffffff;
  text-shadow: 0 0 60px var(--text-glow, rgba(147, 149, 221, 0.3)),
    0 4px 20px rgba(0, 0, 0, 0.3);
  width: min(640px, 80vw);
  overflow: visible;
}

.cake-svg-text {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.25));
}

/* Animation state when switching models */
.cake-word.switching {
  opacity: 0;
  transform: translateY(14px);
}

/* Tagline â€” K2D, subtle, small */
.cake-tagline {
  margin: 0 auto;
  font-family: 'K2D', sans-serif;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  font-weight: 300;
  letter-spacing: 0.8px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: opacity 0.4s ease;
  text-align: center;
}

/* Hide the info panel after cake is selected */
.cake-info.hidden {
  opacity: 0;
  pointer-events: none;
}

/* =============================================
   CURVED HAPPY BIRTHDAY BANNER
   â€” Dancing Script arc text, top-center
   ============================================= */
.birthday-banner {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(700px, 95vw);
  z-index: 20;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.8s ease;
}

.birthday-banner.hidden {
  opacity: 0;
}

.birthday-banner svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.bday-text {
  font-family: 'Dancing Script', cursive;
  font-size: 44px;
  font-weight: 700;
  fill: #fff;
  filter: drop-shadow(0 0 14px var(--text-glow, rgba(147, 149, 221, 0.6))) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
  letter-spacing: 0.02em;
  animation: bdayPulse 2.8s ease-in-out infinite;
}

@keyframes bdayPulse {

  0%,
  100% {
    opacity: 1;
    filter: drop-shadow(0 0 14px var(--text-glow, rgba(147, 149, 221, 0.6))) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
  }

  50% {
    opacity: 0.88;
    filter: drop-shadow(0 0 28px var(--text-glow, rgba(147, 149, 221, 0.9))) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
  }
}

/* Desktop-specific: align text blocks without mutating SVG internals */
@media (min-width: 769px) {
  .cake-word {
    justify-content: flex-start;
  }

  .cake-svg-text {
    margin-left: clamp(-100px, -6vw, -24px);
    margin-right: auto;
  }

  .cake-label,
  .cake-tagline {
    text-align: left;
  }
}

/* =============================================
   MOBILE RESPONSIVE â€” max-width: 768px
   ============================================= */
@media (max-width: 768px) {

  html,
  body {
    overflow: hidden;
    overscroll-behavior: none;
    height: 100%;
  }

  .pink-bg,
  .stage,
  .viewer {
    height: 100dvh;
    min-height: 100dvh;
  }

  .viewer {
    touch-action: none;
  }

  /* Kill the expensive multi-layer drop-shadow on mobile GPU */
  .vector-shadow-wrapper {
    filter: none;
  }

  /* Pause shine animation on mobile — saves continuous repaint */
  .gradient-word {
    animation: none;
    background-position: 0% center;
  }

  /* Reduce birthday banner glow filter cost on mobile */
  .bday-text {
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
    animation: none;
    opacity: 1;
  }

  /* Reduce blur radius on nav buttons — each blur = GPU compositing layer */
  .btn-nav,
  .btn-select {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  /* Pause select button pulse animation on mobile */
  .btn-select {
    animation: none;
  }

  /* Text panel: centered, upper area, floats clean over the 3D cake */
  .cake-info {
    left: 50%;
    top: 36%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 95vw;
    width: fit-content;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    padding: 0;
  }

  /* Keep cake-word block but left-align them */
  .cake-word {
    width: 100%;
    display: flex;
    justify-content: center;
    text-align: center;
  }

  /* Smaller gradient word on mobile */
  .gradient-word {
    font-size: clamp(2rem, 10vw, 3.5rem);
  }

  /* Smaller plain-word + SVG candy on mobile */
  .plain-word {
    font-size: clamp(2.5rem, 12vw, 4rem);
    width: min(320px, 85vw);
  }

  .cake-svg-text {
    width: 100%;
    margin: 0 auto;
  }

  /* Bigger tagline for readability */
  .cake-tagline {
    font-size: clamp(0.85rem, 3.5vw, 1rem);
    text-align: center;
  }

  /* Move nav buttons to bottom center */
  .btn-nav {
    top: auto;
    bottom: 3.5rem;
    transform: none;
    width: 50px;
    height: 50px;
    font-size: 1.35rem;
  }

  .btn-prev {
    left: calc(50% - 165px);
  }

  .btn-next {
    right: calc(50% - 165px);
  }

  .btn-nav:hover {
    transform: scale(1.1);
    /* Remove translateY(-50%) to prevent jumping up on mobile */
  }

  /* Select button: keep at bottom center but adjust spacing */
  .btn-select {
    bottom: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    padding: 0.8rem 1.6rem;
  }

  .btn-select:hover {
    transform: translateX(-50%) scale(1.05);
    /* Preserve centering and remove translateY(-4px) */
  }

  /* Hint text spacing */
  .hint {
    bottom: 1.2rem;
    font-size: 0.75rem;
  }

  /* Birthday banner smaller on mobile */
  .birthday-banner {
    width: min(360px, 95vw);
  }

  .bday-text {
    font-size: 28px;
  }

}

/* --- Premium Loader Styles --- */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

.loader-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  text-align: center;
  width: 280px;
}

.loader-logo {
  font-size: 3rem;
  margin-bottom: 2rem;
  animation: floatLoader 2s ease-in-out infinite;
}

@keyframes floatLoader {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.loader-bar-container {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
  position: relative;
}

.loader-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ff9a9e, #fad0c4, #ff9a9e);
  background-size: 200% auto;
  box-shadow: 0 0 15px rgba(255, 154, 158, 0.6);
  transition: width 0.3s ease;
  animation: shineGradient 2s linear infinite;
}

.loader-status {
  font-family: 'K2D', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

.loader-percentage {
  font-family: 'Michroma', sans-serif;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 5px;
}
