@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

/* ==========================================
   INDULGENCE - SOLEMN CINEMATIC ANIMATIONS
   ========================================== */

@layer utilities {
  /* Ambient drifts for back layers (3-8px) */
  @keyframes driftBackLeft {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(-5px, 2px, 0) scale(1.01); }
  }
  @keyframes driftBackRight {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(5px, -2px, 0) scale(1.01); }
  }

  /* Ambient drifts for middle layers (6-14px) */
  @keyframes driftMidLeft {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(-10px, 4px, 0) scale(1.015); }
  }
  @keyframes driftMidRight {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(10px, -4px, 0) scale(1.015); }
  }

  /* Ambient drifts for front layers (8-18px) */
  @keyframes driftFrontLeft {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(-14px, 6px, 0) scale(1.02); }
  }
  @keyframes driftFrontRight {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(14px, -6px, 0) scale(1.02); }
  }
  @keyframes driftFrontBottom {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(0, 8px, 0) scale(1.01); }
  }

  /* Upward Particle Float */
  @keyframes floatUp {
    0% { transform: translateY(0) scale(0.6); opacity: 0; }
    30% { opacity: 0.7; }
    80% { opacity: 0.5; }
    100% { transform: translateY(-120px) scale(1.2); opacity: 0; }
  }

  /* Fade In Up for Secondary Action */
  @keyframes fadeInUp {
    0% { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: translateY(0); }
  }
}

/* Custom CSS Variables for Cloud Layout Positioning */
.cloud-back-left-wrap {
  --idle-x: 0px; --idle-y: 0px; --idle-scale: 1.0;
  --part-x: -12px; --part-y: -3px; --part-scale: 1.01;
}
.cloud-back-right-wrap {
  --idle-x: 0px; --idle-y: 0px; --idle-scale: 1.0;
  --part-x: 12px; --part-y: -3px; --part-scale: 1.01;
}
.cloud-mid-left-wrap {
  --idle-x: 0px; --idle-y: 0px; --idle-scale: 1.0;
  --part-x: -48px; --part-y: -8px; --part-scale: 1.02;
}
.cloud-mid-right-wrap {
  --idle-x: 0px; --idle-y: 0px; --idle-scale: 1.0;
  --part-x: 48px; --part-y: -8px; --part-scale: 1.02;
}
.cloud-front-left-wrap {
  --idle-x: 0px; --idle-y: 0px; --idle-scale: 1.0;
  --part-x: -30px; --part-y: 8px; --part-scale: 1.015;
}
.cloud-front-right-wrap {
  --idle-x: 0px; --idle-y: 0px; --idle-scale: 1.0;
  --part-x: 30px; --part-y: 8px; --part-scale: 1.015;
}
.cloud-front-bottom-wrap {
  --idle-x: 0px; --idle-y: 0px; --idle-scale: 1.0;
  --part-x: 0px; --part-y: 40px; --part-scale: 0.98;
}
.light-bloom-wrap {
  --idle-x: 0px; --idle-y: 0px; --idle-scale: 1.0;
  --part-x: 0px; --part-y: 0px; --part-scale: 1.08;
}

/* Layer Wrapper Base Styles & Transitions */
.cloud-back-left-wrap,
.cloud-back-right-wrap,
.cloud-mid-left-wrap,
.cloud-mid-right-wrap,
.cloud-front-left-wrap,
.cloud-front-right-wrap,
.cloud-front-bottom-wrap,
.light-bloom-wrap {
  transform: translate3d(var(--idle-x), var(--idle-y), 0) scale(var(--idle-scale));
  transition: transform 4s cubic-bezier(0.16, 1, 0.3, 1), opacity 4s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

/* Ambient Drifting Classes */
.animate-cloud-back-left { animation: driftBackLeft 42s ease-in-out infinite; }
.animate-cloud-back-right { animation: driftBackRight 46s ease-in-out infinite; }
.animate-cloud-mid-left { animation: driftMidLeft 32s ease-in-out infinite; }
.animate-cloud-mid-right { animation: driftMidRight 36s ease-in-out infinite; }
.animate-cloud-front-left { animation: driftFrontLeft 26s ease-in-out infinite; }
.animate-cloud-front-right { animation: driftFrontRight 28s ease-in-out infinite; }
.animate-cloud-front-bottom { animation: driftFrontBottom 30s ease-in-out infinite; }

/* Ritual Parting Transitions (triggered by .is-absolving state) */
.is-absolving .cloud-back-left-wrap,
.is-absolving .cloud-back-right-wrap,
.is-absolving .cloud-mid-left-wrap,
.is-absolving .cloud-mid-right-wrap,
.is-absolving .cloud-front-left-wrap,
.is-absolving .cloud-front-right-wrap,
.is-absolving .cloud-front-bottom-wrap,
.is-glowing .light-bloom-wrap {
  transform: translate3d(calc(var(--idle-x) + var(--part-x)), calc(var(--idle-y) + var(--part-y)), 0) scale(calc(var(--idle-scale) * var(--part-scale)));
}

.light-rays-wrap {
  transition: opacity 3.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.is-absolving .light-rays-wrap {
  opacity: 0.75 !important;
}

.is-absolving .particle-item {
  animation: floatUp 4s ease-out infinite;
}

.animate-fade-in-up {
  animation: fadeInUp 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Particle Stagger Delays */
.particle-item:nth-child(1) { animation-delay: 0.1s; left: 25%; }
.particle-item:nth-child(2) { animation-delay: 0.4s; left: 45%; }
.particle-item:nth-child(3) { animation-delay: 0.7s; left: 60%; }
.particle-item:nth-child(4) { animation-delay: 0.2s; left: 75%; }
.particle-item:nth-child(5) { animation-delay: 0.9s; left: 35%; }

/* Custom Solemn Button Styling */
.indulgence-button {
  max-width: calc(100vw - 2rem);
  box-sizing: border-box;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 25px rgba(212, 175, 55, 0.15), inset 0 0 15px rgba(255, 248, 220, 0.05);
}

.indulgence-button:hover:not(:disabled) {
  box-shadow: 0 0 45px rgba(212, 175, 55, 0.4), inset 0 0 25px rgba(255, 248, 220, 0.15);
  transform: translateY(-1px) scale(1.015);
  border-color: rgba(234, 198, 92, 0.8);
}

.indulgence-button:active:not(:disabled) {
  transform: scale(0.985);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.25);
}

.indulgence-button.is-absolved-state {
  box-shadow: 0 0 50px rgba(255, 250, 230, 0.3), inset 0 0 30px rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(18, 16, 24, 0.85);
}

/* Button physical stability override during active processing/pulsing phases */
.indulgence-button:disabled,
.indulgence-button.is-processing-state,
.indulgence-button.is-pulsing-state {
  transform: none !important;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.2), inset 0 0 15px rgba(255, 248, 220, 0.08) !important;
  border-color: rgba(212, 175, 55, 0.4) !important;
  cursor: default;
}

/* Overlapping Grid Layout inside Button */
.button-labels-grid {
  display: inline-grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  justify-items: center;
  align-items: center;
}

.button-label {
  grid-area: 1 / 1;
  opacity: 0;
  transform: translate3d(0, 0.15em, 0);
  filter: blur(2px);
  pointer-events: none;
  transition: opacity 360ms ease-out 80ms, transform 360ms cubic-bezier(0.16, 1, 0.3, 1) 80ms, filter 360ms ease-out 80ms;
}

.button-label.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  filter: blur(0);
  pointer-events: auto;
  transition: opacity 300ms ease-out, transform 300ms cubic-bezier(0.16, 1, 0.3, 1), filter 300ms ease-out;
}

.button-label.is-outgoing {
  opacity: 0;
  transform: translate3d(0, -0.15em, 0);
  filter: blur(2px);
  pointer-events: none;
  transition: opacity 200ms ease-in, transform 200ms ease-in, filter 200ms ease-in;
}

/* Top utility control atmospheric scrim */
.top-utility-scrim {
  height: 180px;
  background: linear-gradient(
    to bottom,
    rgba(4, 6, 10, 0.65) 0%,
    rgba(4, 6, 10, 0.4) 40%,
    rgba(4, 6, 10, 0.12) 75%,
    transparent 100%
  );
  z-index: 10;
}

/* Language link custom contrast designs */
.locale-link {
  color: rgba(248, 242, 226, 0.76);
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.85);
  font-weight: 500;
  transition: all 0.3s ease;
}

.locale-link:hover {
  color: rgba(255, 248, 220, 1);
  text-shadow: 0 1px 8px rgba(212, 175, 55, 0.4);
}

.locale-link-active {
  color: rgba(252, 232, 178, 1) !important;
  font-weight: 600;
  border-bottom: 1.5px solid rgba(252, 232, 178, 0.8);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.95), 0 0 8px rgba(212, 175, 55, 0.3);
}

.locale-separator {
  color: rgba(248, 242, 226, 0.4);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  margin: 0 2px;
}

/* Sound control high-visibility button */
.sound-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 9999px;
  color: rgba(248, 242, 226, 0.82);
  background: rgba(8, 12, 20, 0.65);
  border: 1px solid rgba(248, 242, 226, 0.16);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
}

.sound-toggle-btn:hover {
  color: rgba(252, 232, 178, 1);
  background: rgba(8, 12, 20, 0.85);
  border-color: rgba(252, 232, 178, 0.4);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
}

/* Completed-state action contrast vignette */
.action-contrast-scrim {
  background: radial-gradient(
    circle,
    rgba(4, 6, 10, 0.8) 0%,
    rgba(4, 6, 10, 0.45) 55%,
    transparent 100%
  );
  filter: blur(14px);
  z-index: 0;
}

.donation-link {
  color: rgba(252, 232, 178, 0.95) !important;
  font-weight: 500;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.95);
  border-bottom: 1.5px solid rgba(252, 232, 178, 0.6);
  transition: all 0.3s ease;
}

.donation-link:hover {
  color: rgba(255, 248, 220, 1) !important;
  border-bottom-color: rgba(255, 248, 220, 1);
  text-shadow: 0 1px 12px rgba(212, 175, 55, 0.5);
}

.reset-btn {
  color: rgba(239, 232, 216, 0.8) !important;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
}

.reset-btn:hover {
  color: rgba(255, 255, 255, 1) !important;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.95), 0 0 14px rgba(255, 255, 255, 0.3);
}

/* Responsive and orientation rules */
@media (max-width: 400px) {
  .indulgence-button {
    font-size: 0.875rem !important;
    letter-spacing: 0.08em !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
  }
}

@media (max-width: 768px) {
  main {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  /* Bring side clouds further in, lift bottom foreground, scale up */
  .cloud-back-left-wrap {
    --idle-x: 8%;
    --idle-y: -2%;
    --idle-scale: 1.05;
    --part-x: -16px;
  }
  .cloud-back-right-wrap {
    --idle-x: -8%;
    --idle-y: -2%;
    --idle-scale: 1.05;
    --part-x: 16px;
  }
  .cloud-mid-left-wrap {
    --idle-x: 16%;
    --idle-y: 0px;
    --idle-scale: 1.12;
    --part-x: -28px;
  }
  .cloud-mid-right-wrap {
    --idle-x: -16%;
    --idle-y: 0px;
    --idle-scale: 1.12;
    --part-x: 28px;
  }
  .cloud-front-left-wrap {
    --idle-x: 10%;
    --idle-y: -3%;
    --idle-scale: 1.06;
    --part-x: -20px;
  }
  .cloud-front-right-wrap {
    --idle-x: -10%;
    --idle-y: -3%;
    --idle-scale: 1.06;
    --part-x: 20px;
  }
  .cloud-front-bottom-wrap {
    --idle-x: 0px;
    --idle-y: -8%;
    --idle-scale: 1.06;
    --part-y: 28px;
  }
  /* Shift layout slightly upward to make room for absolute button actions */
  .central-container {
    padding-bottom: 4.5rem;
  }
}

/* Accessibility: Reduced Motion Overrides */
@media (prefers-reduced-motion: reduce) {
  .animate-cloud-back-left,
  .animate-cloud-back-right,
  .animate-cloud-mid-left,
  .animate-cloud-mid-right,
  .animate-cloud-front-left,
  .animate-cloud-front-right,
  .animate-cloud-front-bottom,
  .is-absolving .particle-item,
  .animate-fade-in-up {
    animation: none !important;
    transition: opacity 0.3s ease-in-out !important;
  }
  .button-label {
    transition: opacity 0.2s ease-in-out !important;
    transform: none !important;
    filter: none !important;
  }
}
