/* =====================================================================
   ZIKA PERFUME — الطبقة الحسية: جو العطر، الجسيمات، لحظة الرش، تفاصيل دقيقة
   (لا تغيّر تخطيط التطبيق — طبقات فوقه فقط)
   ===================================================================== */

:root {
  --mood-accent: #d4af37;
  --mood-secondary: #3a2a10;
}

/* ---------- جو العطر خلف الزجاجة ---------- */
.atmosphere {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(45% 42% at 50% 38%, color-mix(in srgb, var(--mood-accent) 26%, transparent), transparent 70%),
    radial-gradient(70% 55% at 50% 92%, color-mix(in srgb, var(--mood-secondary) 30%, transparent), transparent 72%);
  transition: opacity 0.8s ease, background 0.8s ease;
  z-index: 0;
}
.stage.has-mood .atmosphere { opacity: 1; }

/* دعم المتصفحات بدون color-mix */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .atmosphere {
    background:
      radial-gradient(45% 42% at 50% 38%, var(--mood-accent), transparent 70%),
      radial-gradient(70% 55% at 50% 92%, var(--mood-secondary), transparent 72%);
    opacity: 0;
  }
  .stage.has-mood .atmosphere { opacity: 0.28; }
}

/* ---------- جسيمات شخصية العطر ---------- */
.mood-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.9s ease;
  z-index: 0;
}
.stage.has-mood .mood-particles { opacity: 1; }
.mood-particles i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s, 4px);
  height: var(--s, 4px);
  border-radius: 50%;
  background: var(--mood-accent);
  opacity: 0;
  will-change: transform, opacity;
}

/* منعش / رياضي: خطوط هواء أفقية خفيفة */
[data-style='air'] i {
  width: calc(var(--s) * 7);
  height: 1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--mood-accent), transparent);
  animation: air-drift var(--d) linear infinite var(--delay);
}
@keyframes air-drift {
  0% { transform: translateX(60px) scaleX(0.4); opacity: 0; }
  20% { opacity: 0.55; }
  80% { opacity: 0.35; }
  100% { transform: translateX(-160px) scaleX(1); opacity: 0; }
}

/* مائي: انعكاسات ماء أفقية بطيئة */
[data-style='water'] i {
  width: calc(var(--s) * 10);
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--mood-accent), transparent);
  filter: blur(0.4px);
  animation: water-line var(--d) ease-in-out infinite var(--delay);
}
@keyframes water-line {
  0%, 100% { transform: translateX(-14px) scaleX(0.7); opacity: 0; }
  35% { opacity: 0.5; }
  50% { transform: translateX(14px) scaleX(1.1); opacity: 0.45; }
  70% { opacity: 0.3; }
}

/* خشبي: جسيمات دقيقة صاعدة */
[data-style='rise'] i { animation: rise-fine var(--d) linear infinite var(--delay); }
@keyframes rise-fine {
  0% { transform: translateY(70px) scale(0.5); opacity: 0; }
  18% { opacity: 0.5; }
  75% { opacity: 0.32; }
  100% { transform: translateY(-110px) scale(1); opacity: 0; }
}

/* زهري: بتلات ضوء تطفو وتتمايل */
[data-style='petal'] i {
  width: calc(var(--s) * 2.2);
  height: calc(var(--s) * 1.3);
  border-radius: 60% 40% 55% 45%;
  animation: petal-float var(--d) ease-in-out infinite var(--delay);
}
@keyframes petal-float {
  0% { transform: translate(0, 40px) rotate(0deg); opacity: 0; }
  25% { opacity: 0.5; }
  50% { transform: translate(-18px, -20px) rotate(120deg); opacity: 0.42; }
  75% { opacity: 0.3; }
  100% { transform: translate(10px, -90px) rotate(260deg); opacity: 0; }
}

/* حلو: طفو ناعم بطيء */
[data-style='float'] i { animation: soft-float var(--d) ease-in-out infinite var(--delay); }
@keyframes soft-float {
  0% { transform: translate(0, 30px) scale(0.6); opacity: 0; }
  30% { opacity: 0.45; }
  60% { transform: translate(12px, -25px) scale(1); opacity: 0.35; }
  100% { transform: translate(-8px, -70px) scale(0.8); opacity: 0; }
}

/* شرقي: جسيمات دافئة معلّقة تنبض */
[data-style='suspend'] i {
  filter: blur(0.3px);
  animation: suspend-glow var(--d) ease-in-out infinite var(--delay);
}
@keyframes suspend-glow {
  0%, 100% { transform: scale(0.5) translateY(6px); opacity: 0; }
  40% { transform: scale(1.1) translateY(-4px); opacity: 0.5; }
  70% { opacity: 0.3; }
}

/* داكن: جسيمات كبيرة بطيئة تهبط */
[data-style='deep'] i {
  width: calc(var(--s) * 1.8);
  height: calc(var(--s) * 1.8);
  filter: blur(1px);
  animation: deep-drift var(--d) linear infinite var(--delay);
}
@keyframes deep-drift {
  0% { transform: translateY(-60px) scale(0.8); opacity: 0; }
  25% { opacity: 0.34; }
  70% { opacity: 0.22; }
  100% { transform: translateY(90px) scale(1.1); opacity: 0; }
}

/* دافئ: غبار ذهبي دقيق */
[data-style='dust'] i {
  width: calc(var(--s) * 0.8);
  height: calc(var(--s) * 0.8);
  box-shadow: 0 0 6px 1px color-mix(in srgb, var(--mood-accent) 55%, transparent);
  animation: gold-dust var(--d) linear infinite var(--delay);
}
@keyframes gold-dust {
  0% { transform: translate(0, 60px) scale(0.4); opacity: 0; }
  20% { opacity: 0.6; }
  60% { transform: translate(8px, -20px) scale(1); opacity: 0.4; }
  100% { transform: translate(-6px, -100px) scale(0.6); opacity: 0; }
}

/* ---------- اختيار الزجاجة: رفعة صغيرة + لمعة انعكاس ---------- */
.shelf-item.picked .shelf-bottle {
  animation: bottle-lift 0.5s cubic-bezier(0.25, 0.9, 0.3, 1);
}
@keyframes bottle-lift {
  0% { transform: translateY(0); }
  45% { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}
.shelf-item.picked::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.22) 48%, transparent 62%);
  transform: translateX(-120%);
  animation: reflection-sweep 0.75s ease-out;
}
@keyframes reflection-sweep {
  to { transform: translateX(120%); }
}

/* ---------- لحظة النهاية: عناصر التحكم الثانوية تتلاشى (الزجاجة تُسلَّم إلى مشهد الكشف) ---------- */
.builder .panel, .builder .topbar, .stage .price-panel, .stage .stage-caption, .stage .mood-particles { transition: opacity 0.45s ease; }
.builder.finale .panel, .builder.finale .topbar { opacity: 0; pointer-events: none; }
.builder.finale .price-panel, .builder.finale .stage-caption, .builder.finale .mood-particles { opacity: 0; }
.builder.finale .atmosphere { opacity: 0.6; }

/* ---------- طبقة الرذاذ (فوق كل الشاشات) ---------- */
#spray-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.45s ease;
}
#spray-layer.active { opacity: 1; }
#spray-layer .halo {
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  background: radial-gradient(circle, color-mix(in srgb, var(--mood-accent) 26%, transparent), transparent 68%);
  opacity: 0;
  animation: halo-bloom 1.1s ease-out forwards;
}
@keyframes halo-bloom {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  30% { opacity: 0.55; }
  100% { transform: translate(-50%, -50%) scale(1.25); opacity: 0; }
}
#spray-layer .puff {
  position: absolute;
  width: 150px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--mood-accent) 34%, #ffffff) 0%, color-mix(in srgb, var(--mood-accent) 16%, transparent) 55%, transparent 100%);
  filter: blur(6px);
  opacity: 0;
  transform-origin: 100% 50%;
  transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(0.3);
  animation: puff-out 0.95s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
@keyframes puff-out {
  0% { transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(0.3); opacity: 0; }
  15% { opacity: 0.5; }
  100% { transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(1.9); opacity: 0; }
}
#spray-layer .drop {
  position: absolute;
  width: var(--s, 5px);
  height: var(--s, 5px);
  border-radius: 50%;
  background: color-mix(in srgb, var(--mood-accent) 75%, #ffffff);
  filter: blur(0.6px);
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: mist-out var(--d, 0.9s) cubic-bezier(0.12, 0.7, 0.25, 1) forwards var(--delay, 0s);
}
@keyframes mist-out {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  12% { opacity: 0.85; }
  60% { opacity: 0.45; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--sc, 2.2)); opacity: 0; }
}

@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  #spray-layer .puff {
  position: absolute;
  width: 150px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--mood-accent) 34%, #ffffff) 0%, color-mix(in srgb, var(--mood-accent) 16%, transparent) 55%, transparent 100%);
  filter: blur(6px);
  opacity: 0;
  transform-origin: 100% 50%;
  transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(0.3);
  animation: puff-out 0.95s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
@keyframes puff-out {
  0% { transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(0.3); opacity: 0; }
  15% { opacity: 0.5; }
  100% { transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(1.9); opacity: 0; }
}
#spray-layer .drop { background: var(--mood-accent); }
  #spray-layer .halo { background: radial-gradient(circle, var(--mood-accent), transparent 68%); opacity: 0.25; }
  [data-style='dust'] i { box-shadow: 0 0 6px 1px var(--mood-accent); }
}

/* ---------- زر الصوت ---------- */
.icon-btn.sound-off { color: rgba(255, 255, 255, 0.22); }
.icon-btn.sound-on { color: var(--gold); border-color: rgba(212, 175, 55, 0.45); }

/* ---------- احترام تقليل الحركة ---------- */
@media (prefers-reduced-motion: reduce) {
  .mood-particles { display: none; }
  #spray-layer .puff {
  position: absolute;
  width: 150px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--mood-accent) 34%, #ffffff) 0%, color-mix(in srgb, var(--mood-accent) 16%, transparent) 55%, transparent 100%);
  filter: blur(6px);
  opacity: 0;
  transform-origin: 100% 50%;
  transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(0.3);
  animation: puff-out 0.95s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
@keyframes puff-out {
  0% { transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(0.3); opacity: 0; }
  15% { opacity: 0.5; }
  100% { transform: translate(-100%, -50%) rotate(var(--rot, -35deg)) scale(1.9); opacity: 0; }
}
#spray-layer .drop { animation-duration: 0.45s; }
  #spray-layer .halo { animation-duration: 0.5s; }
  .shelf-item.picked .shelf-bottle, .shelf-item.picked::before { animation: none; }
  .reveal.spraying .reveal-bottle { transform: none; }
  .atmosphere, .builder .panel, .builder .topbar { transition-duration: 0.2s; }
}
