/* ============================================================
   PARA ARI 🌼 — Experiencia primavera
   Estética: romántica cinematográfica, elegante, delicada
   Mobile-first: 360x800 / 390x844 / 412x915 → desktop
   ============================================================ */

:root {
  --bg-deep: #070d08;
  --bg-green-dark: #0a1a0f;
  --bg-green: #132419;
  --cream: #f5f1e8;
  --cream-dim: rgba(245, 241, 232, 0.72);
  --cream-faint: rgba(245, 241, 232, 0.45);
  --yellow-warm: #f2cf4a;
  --yellow-light: #ffe98a;
  --yellow-soft: #f5d84a;
  --gold: #c9a86a;
  --gold-light: #e8d5a3;
  --green-leaf: #3a7a32;
  --green-stem: #2d5a27;
  --soil: #1c130c;
  --soil-light: #2e2116;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  --ease-cinema: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  background: var(--bg-deep);
  color: var(--cream);
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ============ APP LAYOUT ============ */
.app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 60% at 50% 110%, rgba(45, 90, 39, 0.35) 0%, transparent 60%),
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(201, 168, 106, 0.08) 0%, transparent 60%),
    linear-gradient(180deg, #050805 0%, #0a140d 40%, #0d1a10 70%, #070d08 100%);
  transition: background 3s ease;
}

.app[data-mood="dark"] {
  background:
    radial-gradient(ellipse 90% 50% at 50% 60%, rgba(242, 207, 74, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 120% 60% at 50% 110%, rgba(45, 90, 39, 0.25) 0%, transparent 60%),
    linear-gradient(180deg, #030503 0%, #060b07 50%, #0a120c 100%);
}

.particles-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  opacity: 0.9;
}

/* ============ SCENES ============ */
.scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.04);
  transition: opacity 1.6s var(--ease-cinema), visibility 1.6s, transform 2.2s var(--ease-cinema);
  z-index: 1;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.scene--active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  z-index: 2;
}

.scene__content {
  width: 100%;
  max-width: 430px;
  height: 100%;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 24px 28px 48px;
  position: relative;
  margin: 0 auto;
}

.scene__content--final {
  justify-content: center;
  padding-bottom: 48px;
}

/* ============ TEXT ============ */
.scene__text-container {
  width: 100%;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 18px;
  z-index: 10;
}

.scene__text-container--personal,
.scene__text-container--final {
  min-height: 150px;
}

.scene__text {
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(1.25rem, 5.6vw, 1.55rem);
  line-height: 1.5;
  text-align: center;
  color: var(--cream);
  text-wrap: balance;
  max-width: 20ch;
  opacity: 0;
  transform: translateY(18px);
  filter: blur(6px);
  transition: opacity 1.8s var(--ease-cinema), transform 1.8s var(--ease-cinema), filter 1.8s var(--ease-cinema);
  position: absolute;
  pointer-events: none;
  text-shadow: 0 2px 24px rgba(0,0,0,0.6);
}

.scene__text-container { position: relative; }

.scene__text.visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
  position: relative;
}

.scene__text.leaving {
  opacity: 0;
  transform: translateY(-16px);
  filter: blur(6px);
  position: absolute;
}

.scene__text--emphasis {
  font-size: clamp(1.9rem, 8vw, 2.4rem);
  font-style: normal;
  font-weight: 400;
  color: var(--yellow-light);
  text-shadow: 0 0 40px rgba(242, 207, 74, 0.35), 0 2px 20px rgba(0,0,0,0.6);
}

.scene__text--finale {
  font-size: clamp(1.5rem, 6.8vw, 1.9rem);
  font-style: normal;
  color: var(--yellow-light);
  text-shadow: 0 0 50px rgba(242,207,74,0.4);
}

.scene__text--finale-large {
  font-family: var(--serif);
  font-style: normal;
  font-weight: 600;
  font-size: clamp(2rem, 9vw, 2.7rem);
  color: #fff;
  text-shadow: 0 0 60px rgba(242,207,74,0.5), 0 4px 30px rgba(0,0,0,0.7);
}

.scene__text--signature {
  font-size: 1.15rem;
  color: var(--gold-light);
  letter-spacing: 0.12em;
  font-style: normal;
}

/* ============ SOIL / SEED / PLANT ============ */
.soil-container, .plant-container, .garden-container {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 280px;
  perspective: 600px;
}

.soil {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(78vw, 300px);
  height: 56px;
  background: radial-gradient(ellipse 60% 50% at 50% 30%, var(--soil-light) 0%, var(--soil) 70%);
  border-radius: 50%;
  filter: blur(0.5px);
  box-shadow: 0 18px 50px rgba(0,0,0,0.6), inset 0 -8px 20px rgba(0,0,0,0.5);
}

.soil-surface {
  position: absolute;
  bottom: 38px;
  left: 50%;
  transform: translateX(-50%);
  width: min(64vw, 240px);
  height: 22px;
  background: radial-gradient(ellipse at center, #3a2a1c 0%, #241a10 60%, transparent 75%);
  border-radius: 50%;
  opacity: 0.95;
}

.soil--wide, .soil-surface--wide { width: min(92vw, 420px); }

.seed {
  width: 34px;
  height: auto;
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.6));
  animation: seed-breathe 4s ease-in-out infinite;
  z-index: 3;
}

@keyframes seed-breathe {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}

.plant {
  height: min(46vh, 380px);
  width: auto;
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  transform-origin: bottom center;
  overflow: visible;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.45));
  z-index: 3;
}

.plant--flower { height: min(50vh, 420px); }

/* Growth states driven by JS via --growth (0..1) and classes */
.plant__roots .root {
  stroke-dasharray: 80;
  stroke-dashoffset: 80;
  opacity: 0;
  transition: stroke-dashoffset 2s var(--ease-cinema), opacity 1s ease;
}
.plant.grow-roots .root { opacity: 0.9; stroke-dashoffset: 0; }
.plant.grow-roots .root--2 { transition-delay: 0.3s; }
.plant.grow-roots .root--3 { transition-delay: 0.6s; }
.plant.grow-roots .root--4 { transition-delay: 0.5s; }

.plant__stem {
  transform-origin: bottom center;
  transform: scaleY(0);
  transition: transform 3s var(--ease-cinema);
}
.plant.grow-stem .plant__stem { transform: scaleY(1); }

.plant__leaves .leaf {
  transform-origin: left center;
  transform-box: fill-box;
  transform: scale(0);
  opacity: 0;
  transition: transform 1.6s var(--ease-cinema), opacity 1s ease;
}
.plant__leaves .leaf--2, .plant__leaves .leaf--4 { transform-origin: right center; }
.plant.grow-leaf-1 .leaf--1 { transform: scale(1); opacity: 1; }
.plant.grow-leaf-2 .leaf--2 { transform: scale(1); opacity: 1; transition-delay: 0.2s; }
.plant.grow-leaf-3 .leaf--3 { transform: scale(1); opacity: 1; }
.plant.grow-leaf-4 .leaf--4 { transform: scale(1); opacity: 1; transition-delay: 0.2s; }

/* gentle living sway */
.plant.grown {
  animation: plant-sway 6s ease-in-out infinite;
  transform-origin: bottom center;
}
@keyframes plant-sway {
  0%, 100% { transform: translateX(-50%) rotate(-0.7deg); }
  50% { transform: translateX(-50%) rotate(0.7deg); }
}

.leaf { animation: leaf-flutter 5s ease-in-out infinite; }
.leaf--2 { animation-delay: -2s; }
.leaf--3 { animation-delay: -1s; }
.leaf--4 { animation-delay: -3s; }
@keyframes leaf-flutter {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}

/* Bud */
.plant__bud { transition: opacity 1.5s ease, transform 2s var(--ease-cinema); transform-origin: center; transform-box: fill-box; }
.plant.show-bud .plant__bud { opacity: 1 !important; }

/* Flower bloom */
.flower { transform-origin: center; transform-box: fill-box; }
/* NOTE: petals must NOT carry CSS transform-origin/box: their rotate()
   attributes have to pivot exactly on local (0,0) = flower/stem joint. */
.flower .petal {
  transition: opacity 2s ease;
}
.flower__petals-back,
.flower__petals-front,
.flower__center { transition: opacity 2.2s ease, transform 2.8s var(--ease-cinema); transform-box: fill-box; transform-origin: center; }
.flower--closed .flower__petals-back,
.flower--closed .flower__petals-front,
.flower--closed .flower__center { opacity: 0; transform: scale(0.2); }
.flower--closed .flower__bud-cover { opacity: 1; transform: scale(1); }
.flower__bud-cover { transition: opacity 1.6s ease, transform 2s var(--ease-cinema); transform-origin: center; transform-box: fill-box; }
.flower--bloomed .flower__bud-cover { opacity: 0; transform: scale(1.6); pointer-events: none; }
.flower--bloomed .flower__petals-back,
.flower--bloomed .flower__petals-front,
.flower--bloomed .flower__center { opacity: 1; transform: scale(1); }
/* Progressive opening: back petals -> front petals -> center (scene 4 only) */
#plant-svg-4 #flower.flower--bloomed .flower__petals-back { transition-delay: 0.15s; }
#plant-svg-4 #flower.flower--bloomed .flower__petals-front { transition-delay: 0.7s; }
#plant-svg-4 #flower.flower--bloomed .flower__center { transition-delay: 1.15s; }

/* Scene 4 entrance: stem draws up, leaves pop in sequence, bud develops */
.scene--active #plant-svg-4 .stem-main {
  stroke-dasharray: 230;
  stroke-dashoffset: 230;
  animation: stem-draw 1.7s var(--ease-cinema) 0.1s forwards;
}
@keyframes stem-draw { to { stroke-dashoffset: 0; } }
.scene--active #plant-svg-4 .leaf,
.scene--active #plant-svg-5 .leaf { opacity: 0; animation: leaf-in 0.9s var(--ease-cinema) forwards; }
.scene--active #plant-svg-4 .leaf--1,
.scene--active #plant-svg-5 .leaf--1 { animation-delay: 0.7s; }
.scene--active #plant-svg-4 .leaf--2,
.scene--active #plant-svg-5 .leaf--2 { animation-delay: 0.95s; }
.scene--active #plant-svg-4 .leaf--3,
.scene--active #plant-svg-5 .leaf--3 { animation-delay: 1.2s; }
.scene--active #plant-svg-4 .leaf--4,
.scene--active #plant-svg-5 .leaf--4 { animation-delay: 1.4s; }
@keyframes leaf-in { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
.scene--active #plant-svg-4 #flower.flower--closed .flower__bud-cover { animation: bud-develop 1.8s ease-out; }
@keyframes bud-develop { from { transform: scale(0.82); } to { transform: scale(1); } }

.flower--bloomed { animation: flower-sway 7s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes flower-sway {
  0%, 100% { rotate: -1.2deg; }
  50% { rotate: 1.2deg; }
}

.flower__center { filter: drop-shadow(0 0 18px rgba(242,207,74,0.55)); }

/* Garden mini flowers */
.mini-flower {
  position: absolute;
  bottom: 40px;
  width: 44px;
  height: 90px;
  opacity: 0;
  transform: scale(0) translateY(20px);
  transition: opacity 2s ease, transform 2.4s var(--ease-cinema);
  z-index: 2;
}
.mini-flower.visible { opacity: 1; transform: scale(1) translateY(0); animation: mini-sway 5s ease-in-out infinite; }
@keyframes mini-sway { 0%,100% { rotate: -2deg; } 50% { rotate: 2deg; } }

.garden-wide {
  position: relative;
  width: 100%;
  height: 34vh;
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform-origin: center bottom;
  transition: transform 4s var(--ease-cinema);
}
.scene--active .garden-wide.zoom-out { transform: scale(0.92); }

/* ============ BUTTONS ============ */
.btn {
  font-family: var(--sans);
  border: 1px solid rgba(201,168,106,0.45);
  background: rgba(245,241,232,0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--cream);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 20;
  transition: opacity 1.2s ease, transform 0.5s var(--ease-cinema), background 0.4s, box-shadow 0.4s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}

.btn--start {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 38px;
  font-size: 1rem;
  letter-spacing: 0.06em;
  font-weight: 400;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}
.btn--start.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.btn--start:active { transform: scale(0.96); }
.btn__icon { font-size: 1.1em; }

.interaction-hint {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--cream-dim);
  text-align: center;
  margin-bottom: 14px;
  opacity: 0;
  transition: opacity 1s ease;
  z-index: 10;
  animation: hint-pulse 2.6s ease-in-out infinite;
}
.interaction-hint.visible { opacity: 1; }
@keyframes hint-pulse { 0%,100% { opacity: 0.55; } 50% { opacity: 1; } }

.btn--grow {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 1px solid rgba(242,207,74,0.4);
  background: radial-gradient(circle at 35% 30%, rgba(242,207,74,0.18), rgba(245,241,232,0.05) 70%);
  overflow: hidden;
  touch-action: none;
}
.btn--grow::after { content: '🌱'; filter: saturate(0.9); }
.btn--grow .btn__hold-indicator {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--yellow-warm) var(--hold, 0%), transparent var(--hold, 0%));
  opacity: 0.28;
  pointer-events: none;
}
.btn--grow.holding { transform: scale(1.06); box-shadow: 0 0 40px rgba(242,207,74,0.25), 0 8px 32px rgba(0,0,0,0.4); }
.btn--grow.done { opacity: 0; pointer-events: none; transform: scale(0.8); }

/* ============ MUSIC TOGGLE ============ */
.music-toggle {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(245,241,232,0.18);
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
  color: var(--cream-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease, color 0.3s, border-color 0.3s;
}
.music-toggle.visible { opacity: 1; pointer-events: auto; }
.music-toggle.playing { color: var(--yellow-warm); border-color: rgba(242,207,74,0.45); }
.music-icon { width: 20px; height: 20px; position: absolute; transition: opacity 0.3s; }
.music-icon--on { opacity: 0; }
.music-icon--off { opacity: 1; }
.music-toggle.playing .music-icon--on { opacity: 1; }
.music-toggle.playing .music-icon--off { opacity: 0; }

/* glow behind flower scenes */
.scene[data-scene="4"] .plant-container::before,
.scene[data-scene="5"] .garden-container::before,
.scene[data-scene="6"] .garden-wide::before {
  content: '';
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(242,207,74,0.14) 0%, transparent 65%);
  pointer-events: none;
  filter: blur(10px);
}

/* vignette */
.app::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse 105% 90% at 50% 45%, transparent 60%, rgba(0,0,0,0.5) 100%);
}

/* ============ DESKTOP ============ */
@media (min-width: 700px) {
  .scene__content { max-width: 520px; padding-bottom: 60px; }
  .scene__text { font-size: 1.6rem; max-width: 26ch; }
  .plant { height: 420px; }
}

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.3s !important; }
}
