/* ============================================
   ZAYAN Interior Design - Animations
   Luxury animations and micro-interactions
   ============================================ */

/* ============================================
   FADE & REVEAL ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================
   SCALE & ZOOM ANIMATIONS
   ============================================ */

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes zoomOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.5);
  }
}

/* ============================================
   FLOAT & LEVITATE ANIMATIONS
   ============================================ */

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes floatSlow {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes floatRight {
  0%,
  100% {
    transform: translateX(0px);
  }
  50% {
    transform: translateX(15px);
  }
}

@keyframes floatLeft {
  0%,
  100% {
    transform: translateX(0px);
  }
  50% {
    transform: translateX(-15px);
  }
}

/* ============================================
   PULSE & GLOW ANIMATIONS
   ============================================ */

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes pulseGrow {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.05);
    opacity: 0.7;
  }
}

@keyframes glowPulse {
  0%,
  100% {
    box-shadow: 0 0 20px rgb(var(--color-gold-rgb) / 0.2);
  }
  50% {
    box-shadow: 0 0 40px rgb(var(--color-gold-rgb) / 0.4);
  }
}

@keyframes goldGlow {
  0%,
  100% {
    text-shadow: 0 0 10px rgb(var(--color-gold-rgb) / 0.3);
  }
  50% {
    text-shadow: 0 0 20px rgb(var(--color-gold-rgb) / 0.6);
  }
}

/* ============================================
   ROTATION ANIMATIONS
   ============================================ */

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes spinReverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

@keyframes rotate3d {
  0% {
    transform: rotateY(0deg);
  }
  100% {
    transform: rotateY(360deg);
  }
}

/* ============================================
   BOUNCE ANIMATIONS
   ============================================ */

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

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

/* ============================================
   SLIDE ANIMATIONS
   ============================================ */

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================
   SHIMMER & LOADING ANIMATIONS
   ============================================ */

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes skeleton {
  0%,
  100% {
    background-color: var(--color-tertiary);
  }
  50% {
    background-color: var(--color-secondary);
  }
}

@keyframes loading {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* ============================================
   UNDERLINE & BORDER ANIMATIONS
   ============================================ */

@keyframes underlineGold {
  from {
    width: 0;
    left: 0;
  }
  to {
    width: 100%;
    left: 0;
  }
}

@keyframes borderGlow {
  0%,
  100% {
    border-color: var(--color-border);
  }
  50% {
    border-color: var(--color-gold);
  }
}

/* ============================================
   TEXT ANIMATIONS
   ============================================ */

@keyframes typewriter {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes textGlow {
  0%,
  100% {
    color: var(--color-white);
    text-shadow: 0 0 10px rgb(var(--color-gold-rgb) / 0);
  }
  50% {
    color: var(--color-gold);
    text-shadow: 0 0 20px rgb(var(--color-gold-rgb) / 0.5);
  }
}

/* ============================================
   PARALLAX EFFECT
   ============================================ */

@keyframes parallaxMove {
  0% {
    transform: translateY(0px);
  }
  100% {
    transform: translateY(30px);
  }
}

/* ============================================
   GRADIENT ANIMATIONS
   ============================================ */

@keyframes gradientShift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* ============================================
   MOTION TOKENS
   ============================================ */

:root {
  --reveal-duration: 0.95s;
  --reveal-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --reveal-distance: 42px;
  --curtain-ease: cubic-bezier(0.76, 0, 0.24, 1);
}

/* ============================================
   SCROLL REVEAL
   Hidden only while html.motion-ready is set (added in <head> and
   confirmed by js/animations.js). The reveal itself is a keyframe
   animation with `backwards` fill: once it ends, the element's own
   transitions and hover transforms work normally again.
   ============================================ */

html.motion-ready :is(
    .animate-fade-up,
    .animate-fade-down,
    .animate-fade-left,
    .animate-fade-right,
    .animate-scale-in,
    .animate-zoom-in
  ):not(.animate-visible) {
  opacity: 0;
}

html.motion-ready :is(
    .animate-fade-up,
    .animate-fade-down,
    .animate-fade-left,
    .animate-fade-right,
    .animate-scale-in,
    .animate-zoom-in
  ).animate-visible {
  animation-duration: var(--reveal-duration);
  animation-timing-function: var(--reveal-ease);
  animation-fill-mode: backwards;
  /* !important: older templates still carry inline animation-delay
     values; the engine's own stagger (--reveal-delay) replaces them */
  animation-delay: var(--reveal-delay, 0ms) !important;
}

html.motion-ready .animate-fade-up.animate-visible {
  animation-name: revealUp;
}
html.motion-ready .animate-fade-down.animate-visible {
  animation-name: revealDown;
}
html.motion-ready .animate-fade-left.animate-visible {
  animation-name: revealLeft;
}
html.motion-ready .animate-fade-right.animate-visible {
  animation-name: revealRight;
}
html.motion-ready .animate-scale-in.animate-visible {
  animation-name: revealScale;
}
html.motion-ready .animate-zoom-in.animate-visible {
  animation-name: revealZoom;
}

/* Horizontal slides mirror in RTL */
html.motion-ready[dir="rtl"] .animate-fade-left.animate-visible {
  animation-name: revealRight;
}
html.motion-ready[dir="rtl"] .animate-fade-right.animate-visible {
  animation-name: revealLeft;
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translate3d(0, var(--reveal-distance), 0);
  }
}
@keyframes revealDown {
  from {
    opacity: 0;
    transform: translate3d(0, calc(var(--reveal-distance) * -1), 0);
  }
}
@keyframes revealLeft {
  from {
    opacity: 0;
    transform: translate3d(calc(var(--reveal-distance) * -1), 0, 0);
  }
}
@keyframes revealRight {
  from {
    opacity: 0;
    transform: translate3d(var(--reveal-distance), 0, 0);
  }
}
@keyframes revealScale {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}
@keyframes revealZoom {
  from {
    opacity: 0;
    transform: scale(1.06);
  }
}

/* Image wipe: the picture opens from the bottom and settles into place.
   The clip sits on the <img>, never on the observed .reveal-clip frame:
   Chrome's IntersectionObserver treats a fully clipped target as not
   intersecting, so the reveal would never fire. */
html.motion-ready .reveal-clip > img {
  clip-path: inset(100% 0 0 0);
}
html.motion-ready .reveal-clip > img:not([data-parallax]) {
  transform: scale(1.18);
}
html.motion-ready .reveal-clip.animate-visible > img {
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.3s var(--reveal-ease) var(--reveal-delay, 0ms);
}
html.motion-ready .reveal-clip.animate-visible > img:not([data-parallax]) {
  transform: scale(1);
  transition:
    clip-path 1.3s var(--reveal-ease) var(--reveal-delay, 0ms),
    transform 1.8s var(--reveal-ease) var(--reveal-delay, 0ms);
}

/* ============================================
   PARALLAX
   js/animations.js writes --parallax-y
   ============================================ */

[data-parallax] {
  transform: translate3d(0, var(--parallax-y, 0px), 0);
  will-change: transform;
}

/* Images that drift inside a clipped frame need headroom */
.parallax-frame {
  overflow: hidden;
}
.parallax-frame > img[data-parallax] {
  transform: translate3d(0, var(--parallax-y, 0px), 0) scale(1.14);
}

/* ============================================
   PAGE TRANSITIONS
   A logo curtain lifts on every page load and drops again before
   an internal link navigates (see initPageTransitions()).
   ============================================ */

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  background:
    url("../imgs/logo.png") center / min(240px, 55vw) auto no-repeat,
    radial-gradient(ellipse 60% 50% at 50% 50%, rgb(var(--color-gold-rgb) / 0.08), transparent 70%),
    var(--color-primary);
  border-bottom: 1px solid var(--color-gold);
  transform: translate3d(0, -101%, 0);
}

@media (prefers-reduced-motion: no-preference) {
  body::after {
    animation: pageCurtainLift 0.85s var(--curtain-ease) 0.12s both;
  }

  /* Pages with their own opening sequence skip the entrance curtain */
  body.has-intro::after {
    animation: none;
  }

  html.is-leaving body::after {
    animation: pageCurtainDrop 0.48s var(--curtain-ease) both;
  }
}

@keyframes pageCurtainLift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(0, -101%, 0);
  }
}

@keyframes pageCurtainDrop {
  from {
    transform: translate3d(0, 101%, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

/* ============================================
   SCROLL PROGRESS BAR
   ============================================ */

.scroll-progress {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 9999;
  height: 2px;
  background: linear-gradient(90deg, var(--color-gold-dark), var(--color-gold-bright));
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

[dir="rtl"] .scroll-progress {
  transform-origin: right;
}

/* ============================================
   MARQUEE (infinite ticker)
   Markup: .marquee > .marquee-track > (.marquee-group x2)
   ============================================ */

.marquee {
  position: relative;
  display: flex;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.marquee-track {
  display: flex;
  flex-shrink: 0;
  animation: marqueeScroll var(--marquee-duration, 40s) linear infinite;
}

.marquee:hover .marquee-track {
  animation-play-state: paused;
}

.marquee-group {
  display: flex;
  flex-shrink: 0;
  align-items: center;
}

/* RTL: the track hangs off the left edge, so it travels right instead */
[dir="rtl"] .marquee-track {
  animation-name: marqueeScrollRtl;
}

@keyframes marqueeScroll {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

@keyframes marqueeScrollRtl {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(50%, 0, 0);
  }
}

/* ============================================
   UTILITY ANIMATIONS
   ============================================ */

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-float-slow {
  animation: floatSlow 4s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-glow {
  animation: glowPulse 2s ease-in-out infinite;
}

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-tertiary);
  border-top: 3px solid var(--color-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Toast (showNotification) */
.notification {
  position: fixed;
  top: 20px;
  inset-inline-end: 20px;
  z-index: 9999;
  min-width: 300px;
  padding: 1rem 1.5rem;
  color: var(--color-white);
  background: var(--color-tertiary);
  border-inline-start: 4px solid var(--color-gold);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease-out;
  transition: opacity 0.3s ease;
}

.notification.is-leaving {
  opacity: 0;
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  body::after {
    display: none;
  }

  [data-parallax] {
    transform: none !important;
  }

  .marquee-track {
    animation: none !important;
  }
}
