/* =============================================================================
   JS destekli animasyon kuralları
   Dosya: resources/css/animations.css
   React: framer-motion davranışlarının CSS karşılığı
   ============================================================================= */

/* --- Scroll reveal (Reveal.tsx) ---
   React: initial {opacity:0, y:32} → whileInView {opacity:1, y:0}
           transition {duration:0.7, delay, ease:[0.22,1,0.36,1]}
   PHP:   .reveal sınıfı + IntersectionObserver (resources/js/app.js)
   Not:   "js" sınıfı ancak JavaScript çalışıyorsa <html> üzerine eklenir.
          Aksi halde içerik görünür kalır (JS'siz erişim korunur). */
html.js .reveal {
  opacity: 0;
  transform: translateY(var(--reveal-y, 32px));
  transition:
    opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0s),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0s);
  /* NOT: Burada bilerek "will-change: transform" kullanilmaz.
     will-change, transform uygulanan her ic ogeyi ayri bir katmana cikarir
     (bellek maliyeti) ve position:fixed cocuklar icin containing block
     olusturur — lightbox gibi sabit konumlu ogeler viewport'a gore
     konumlanamaz. Geçiş zaten 0.7s suruyor; will-change gerekmiyor. */
}

html.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* --- LCP güvenli giriş: yalnız konum -------------------------------------
   İlk görünümde yer alan içerikte opacity animasyonu ilk boyamayı ve
   dolayısıyla LCP'yi geciktirir (opacity 0 iken öğe boyanmış sayılmaz).
   Bu varyant opaklığı hiç değiştirmez; yalnızca hafif translateY korur. */
html.js .reveal-soft {
  opacity: 1;
  transform: translateY(var(--reveal-y, 32px));
}

/* --- Reveal varyantları -------------------------------------------------
   React tarafındaki framer-motion varyantlarının CSS karşılığı.
   Düzen: temel .reveal kuralından SONRA gelir; aynı specificity
   (0,2,1) olduğu için sonraki kural kazanır. `.is-visible` kuralları
   daha yüksek specificity (0,3,1) taşır ve her zaman geçerlidir. */

/* X ekseni: opacity 0->1, translateX(-16px)->0
   React: Services.tsx <motion.li initial={{opacity:0, x:-16}} whileInView={{opacity:1, x:0}}> */
html.js .reveal-x {
  opacity: 0;
  transform: translateX(var(--reveal-x, -16px));
  transition:
    opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0s),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0s);
}
html.js .reveal-x.is-visible {
  opacity: 1;
  transform: none;
}

/* Yalnız ölçek (opacity değişmez) — spring hissi
   React: About.tsx motion.span initial={{scale:0}} / Testimonials.tsx yıldız
          / Contact.tsx ilçe rozeti initial={{opacity:0, scale:0.85}} */
html.js .reveal-scale {
  opacity: 1;
  transform: scale(var(--reveal-scale, 0));
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) var(--reveal-delay, 0s);
}
html.js .reveal-scale.is-visible {
  transform: scale(1);
}

/* Yalnız X ölçek (dayanıklılık çubuğu)
   React: Services.tsx <motion.span initial={{scaleX:0}} whileInView={{scaleX:1}}> */
html.js .reveal-scale-x {
  opacity: 1;
  transform: scaleX(0);
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0s);
}
html.js .reveal-scale-x.is-visible {
  transform: scaleX(1);
}

/* Opaklık + ölçek
   React: Contact.tsx <motion.button initial={{opacity:0, scale:0.85}} whileInView={{opacity:1, scale:1}}> */
html.js .reveal-fade-scale {
  opacity: 0;
  transform: scale(var(--reveal-scale, 0.85));
  transition:
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0s),
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) var(--reveal-delay, 0s);
}
html.js .reveal-fade-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

/* Yükseklik büyüme (zaman çizelgesi ilerleme çizgisi)
   React: About.tsx <motion.div initial={{height:"0%"}} whileInView={{height:"100%"}}
          transition={{duration:2.2, ease:"easeInOut"}}> */
html.js .reveal-grow {
  opacity: 1;
  transform: none;
  height: 0;
  transition: height 2.2s ease-in-out var(--reveal-delay, 0s);
}
html.js .reveal-grow.is-visible {
  height: 100%;
}

/* --- Sayfa geçişi (AnimatePresence) ---
   React: initial {opacity:0, y:18} → animate {opacity:1, y:0}, duration 0.35 */
.page-enter {
  animation: page-enter 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes page-enter {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* --- Navbar scroll durumu (Navbar.tsx: scrolled ? ... ) --- */
html.js [data-navbar-top] {
  max-height: 2.5rem;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}
html.js [data-navbar].is-scrolled [data-navbar-top] {
  max-height: 0;
  opacity: 0;
}
html.js [data-navbar-main] {
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
html.js [data-navbar].is-scrolled [data-navbar-main] {
  background-color: color-mix(in srgb, var(--color-cream) 95%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 30px rgba(32, 25, 19, 0.10);
}

/* --- SSS akordeonu (Faq.tsx: height 0 <-> auto, duration 0.35) --- */
.faq-answer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.faq-answer > div { overflow: hidden; }
.faq-item.is-open .faq-answer { grid-template-rows: 1fr; }

/* --- Hero görsel kolajı giriş animasyonu ---
   React: initial {opacity:0, scale:0.96} → animate {opacity:1, scale:1}
           duration 0.9s, delay 0.2s, ease [0.22, 1, 0.36, 1]
   Not: Bu bir scroll-reveal DEĞİL, sayfa açılışında bir kez oynar. */
html.js .hero-collage {
  opacity: 1;
  transform: scale(0.96);
  animation: hero-collage-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}
@keyframes hero-collage-in {
  from { opacity: 1; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* --- Hero el yazısı alt çizgi çizim animasyonu ---
   React: Home.tsx <motion.path initial={{pathLength:0}} animate={{pathLength:1}}
          transition={{duration:0.9, delay:0.9}} />
   pathLength, stroke-dasharray + stroke-dashoffset ile taklit edilir. */
html.js .hero-underline-path {
  stroke-dasharray: 240;
  stroke-dashoffset: 240;
  animation: hero-underline-draw 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.9s forwards;
}
@keyframes hero-underline-draw {
  to { stroke-dashoffset: 0; }
}

/* --- Galeri kartı giriş animasyonu ---
   React: Gallery.tsx <motion.button initial={{opacity:0, scale:0.92}}
          animate={{opacity:1, scale:1}} transition={{duration:0.4}}> */
html.js .gallery-card-in {
  animation: gallery-card-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--card-index, 0) * 0.05s);
}
@keyframes gallery-card-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* --- Galeri lightbox ---
   React: Gallery.tsx overlay initial={{opacity:0}} + figure initial={{scale:0.94}} */
html.js [data-gallery-lightbox]:not(.hidden) {
  animation: gallery-lightbox-fade 0.2s ease-out;
}
html.js [data-gallery-lightbox]:not(.hidden) figure {
  animation: gallery-lightbox-zoom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes gallery-lightbox-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes gallery-lightbox-zoom {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* --- Teklif modalı ---
   React: QuoteModal.tsx overlay initial={{opacity:0}} + panel
          initial={{y:60, opacity:0, scale:0.98}} (spring) */
html.js [data-quote-modal]:not(.hidden) {
  animation: quote-modal-fade 0.2s ease-out;
}
html.js [data-quote-modal]:not(.hidden) [data-quote-modal-panel] {
  animation: quote-modal-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes quote-modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes quote-modal-in {
  from { opacity: 0; transform: translateY(60px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* --- Mobil menü ---
   React: Navbar.tsx motion.nav height 0->auto + motion.button initial={{opacity:0, x:-14}} */
html.js [data-mobile-menu]:not(.hidden) {
  animation: mobile-menu-fade 0.28s ease-in-out;
}
html.js [data-mobile-menu]:not(.hidden) .mobile-menu-item-in {
  animation: mobile-menu-item-in 0.28s ease-out both;
  animation-delay: calc(var(--menu-index, 0) * 0.05s);
}
@keyframes mobile-menu-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes mobile-menu-item-in {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}

/* --- Başarı onayı (spring) ---
   React: Contact.tsx / QuoteModal.tsx
          <motion.div initial={{scale:0, rotate:-20}} animate={{scale:1, rotate:0}}
          transition={{type:"spring", stiffness:260, damping:16}}> */
html.js .success-pop {
  animation: success-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes success-pop {
  from { opacity: 0; transform: scale(0) rotate(-20deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* --- Hesaplayıcı seçili seçenek rozeti ---
   React: Estimator.tsx <motion.span initial={{scale:0}} animate={{scale:1}}> */
html.js .est-badge {
  animation: est-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes est-badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* --- Yorum yıldızı giriş animasyonu ---
   React: <motion.span initial={{scale:0, rotate:-30}} animate={{scale:1, rotate:0}}
          transition={{delay: 0.1 + i * 0.07}} />
   React'te yildizlar slayt MOUNT oldugunda animasyonlanir (whileInView degil).
   Port'ta tum slaytlar DOM'da durdugu icin animasyon aktif slayda gecildiginde
   yeniden tetiklenir (testimonials.js -> replayStars). */
html.js .testimonial-star-in {
  animation: testimonial-star-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(0.1s + var(--star-index, 0) * 0.07s);
}
@keyframes testimonial-star-in {
  from { opacity: 0; transform: scale(0) rotate(-30deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* --- Content visibility (CWV): below-fold render maliyetini azaltir --- */
.cv-auto {
  content-visibility: auto;
  contain-intrinsic-size: 0 600px;
}

/* --- Hareket azaltma tercihi --- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html.js .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  html.js .reveal-x { opacity: 1 !important; transform: none !important; transition: none !important; }
  html.js .reveal-scale { opacity: 1 !important; transform: none !important; transition: none !important; }
  html.js .reveal-fade-scale { opacity: 1 !important; transform: none !important; transition: none !important; }
  html.js .reveal-scale-x { opacity: 1 !important; transform: none !important; transition: none !important; }
  html.js .reveal-grow { opacity: 1 !important; transform: none !important; height: 100% !important; transition: none !important; }
  html.js .hero-collage { opacity: 1 !important; transform: none !important; animation: none !important; }
  html.js .hero-underline-path { stroke-dashoffset: 0 !important; animation: none !important; }
  html.js .testimonial-star-in { opacity: 1 !important; transform: none !important; animation: none !important; }
  .page-enter { animation: none; }
  .faq-answer { transition: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
