/**
 * PWA App-Like Transitions & Micro-interactions
 * Mobil uygulama hissi icin animasyonlar
 */

/* ══════════════════════════════════════════════════════════════ */
/* 1. PAGE TRANSITIONS                                             */
/* ══════════════════════════════════════════════════════════════ */

/* Sayfa giris animasyonu */
@media (display-mode: standalone) {
    body {
        animation: pageEnter 0.3s ease-out;
    }
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 2. BUTTON INTERACTIONS                                          */
/* ══════════════════════════════════════════════════════════════ */

/* Tum butonlar icin tap efekti */
button,
[role="button"],
.btn,
a.btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Active state scale efekti */
@media (hover: none) {
    button:active,
    [role="button"]:active,
    .btn:active,
    a.btn:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 3. CARD INTERACTIONS                                            */
/* ══════════════════════════════════════════════════════════════ */

/* Kart tiklanabilir efekti */
.card-clickable,
[data-clickable],
.cursor-pointer {
    -webkit-tap-highlight-color: transparent;
}

@media (hover: none) {
    .card-clickable:active,
    [data-clickable]:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 4. LIST ITEM ANIMATIONS                                         */
/* ══════════════════════════════════════════════════════════════ */

/* Staggered list animation */
.pwa-list-animated > * {
    animation: listItemEnter 0.3s ease-out both;
}

.pwa-list-animated > *:nth-child(1) { animation-delay: 0.02s; }
.pwa-list-animated > *:nth-child(2) { animation-delay: 0.04s; }
.pwa-list-animated > *:nth-child(3) { animation-delay: 0.06s; }
.pwa-list-animated > *:nth-child(4) { animation-delay: 0.08s; }
.pwa-list-animated > *:nth-child(5) { animation-delay: 0.10s; }
.pwa-list-animated > *:nth-child(6) { animation-delay: 0.12s; }
.pwa-list-animated > *:nth-child(7) { animation-delay: 0.14s; }
.pwa-list-animated > *:nth-child(8) { animation-delay: 0.16s; }
.pwa-list-animated > *:nth-child(9) { animation-delay: 0.18s; }
.pwa-list-animated > *:nth-child(10) { animation-delay: 0.20s; }

@keyframes listItemEnter {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 5. MODAL / BOTTOM SHEET ANIMATIONS                              */
/* ══════════════════════════════════════════════════════════════ */

/* Bottom sheet acilis */
.pwa-bottom-sheet-enter {
    animation: bottomSheetEnter 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes bottomSheetEnter {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Modal fade */
.pwa-modal-enter {
    animation: modalEnter 0.25s ease-out;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 6. SKELETON LOADING                                             */
/* ══════════════════════════════════════════════════════════════ */

.pwa-skeleton {
    background: linear-gradient(
        90deg,
        #f1f5f9 25%,
        #e2e8f0 50%,
        #f1f5f9 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 7. TOAST NOTIFICATIONS                                          */
/* ══════════════════════════════════════════════════════════════ */

.pwa-toast {
    animation: toastEnter 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.pwa-toast-exit {
    animation: toastExit 0.2s ease-in forwards;
}

@keyframes toastEnter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastExit {
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 8. RIPPLE EFFECT                                                */
/* ══════════════════════════════════════════════════════════════ */

.pwa-ripple {
    position: relative;
    overflow: hidden;
}

.pwa-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.pwa-ripple:active::after {
    width: 200%;
    padding-bottom: 200%;
    opacity: 1;
    transition: width 0.3s ease-out, padding-bottom 0.3s ease-out, opacity 0.3s ease-out;
}

/* ══════════════════════════════════════════════════════════════ */
/* 9. SMOOTH SCROLLING                                             */
/* ══════════════════════════════════════════════════════════════ */

@media (display-mode: standalone) {
    html {
        scroll-behavior: smooth;
    }

    /* iOS momentum scrolling */
    .scroll-container,
    [data-scroll] {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 10. TAB BAR ACTIVE INDICATOR                                    */
/* ══════════════════════════════════════════════════════════════ */

.pwa-tab-active {
    position: relative;
}

.pwa-tab-active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 20px;
    height: 3px;
    background: currentColor;
    border-radius: 2px;
    transform: translateX(-50%);
    animation: tabIndicator 0.2s ease-out;
}

@keyframes tabIndicator {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 20px;
        opacity: 1;
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 11. PULL INDICATOR (Header)                                     */
/* ══════════════════════════════════════════════════════════════ */

.pwa-pull-hint {
    animation: pullHint 2s ease-in-out infinite;
}

@keyframes pullHint {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(4px);
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 12. FLOATING ACTION BUTTON                                      */
/* ══════════════════════════════════════════════════════════════ */

.pwa-fab {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(22, 163, 74, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pwa-fab:active {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

/* ══════════════════════════════════════════════════════════════ */
/* 13. KEYBOARD OPEN STATE                                         */
/* ══════════════════════════════════════════════════════════════ */

body.keyboard-open .pwa-fab,
body.keyboard-open .pwa-scroll-top,
body.keyboard-open .bottom-nav {
    display: none !important;
}

/* ══════════════════════════════════════════════════════════════ */
/* 14. SAFE AREA INSETS                                            */
/* ══════════════════════════════════════════════════════════════ */

@media (display-mode: standalone) {
    /* Header safe area */
    .pwa-header-safe {
        padding-top: env(safe-area-inset-top, 0);
    }

    /* Bottom nav safe area */
    .pwa-bottom-safe {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* Full screen content */
    .pwa-content-safe {
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
}

/* ══════════════════════════════════════════════════════════════ */
/* 15. LOADING STATES                                              */
/* ══════════════════════════════════════════════════════════════ */

.pwa-loading {
    pointer-events: none;
    opacity: 0.7;
}

.pwa-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-top-color: #16a34a;
    border-radius: 50%;
    animation: pwaSpinner 0.8s linear infinite;
}

@keyframes pwaSpinner {
    to {
        transform: rotate(360deg);
    }
}
