/* ============================================
   Pull-to-Refresh Component
   GitHub-inspired pull-to-refresh animation
   Mobile and tablet only
   ============================================ */

/* Container for the pull-to-refresh indicator */
.ptr-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 9999;
    transform: translateY(-100%);
    transition: none;
}

.ptr-container.ptr-transitioning {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The indicator circle */
.ptr-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--mlad-button-bg, #000000);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ptr-container.ptr-visible .ptr-indicator {
    opacity: 1;
    transform: scale(1);
}

/* SVG icon styling */
.ptr-indicator svg {
    width: 24px;
    height: 24px;
    color: var(--mlad-button-fg, #ffffff);
    transition: transform 0.1s ease;
}

/* Arrow icon - rotates based on pull progress */
.ptr-arrow {
    transform-origin: center;
}

.ptr-container.ptr-threshold .ptr-arrow {
    transform: rotate(180deg);
}

/* Spinner icon - hidden by default, shown during refresh */
.ptr-spinner {
    display: none;
}

.ptr-container.ptr-refreshing .ptr-arrow {
    display: none;
}

.ptr-container.ptr-refreshing .ptr-spinner {
    display: block;
    animation: ptr-spin 0.8s linear infinite;
}

/* Spin animation for the refresh indicator */
@keyframes ptr-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Progress ring around the indicator */
.ptr-progress-ring {
    position: absolute;
    width: 48px;
    height: 48px;
    transform: rotate(-90deg);
}

.ptr-progress-ring circle {
    fill: none;
    stroke: var(--mlad-button-fg, #ffffff);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 126; /* 2 * PI * 20 (radius) */
    stroke-dashoffset: 126;
    transition: stroke-dashoffset 0.1s ease;
    opacity: 0.3;
}

.ptr-container.ptr-threshold .ptr-progress-ring circle {
    stroke-dashoffset: 0;
}

/* Hide on desktop - only show on touch devices */
@media (hover: hover) and (pointer: fine) {
    .ptr-container {
        display: none !important;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .ptr-container,
    .ptr-indicator,
    .ptr-indicator svg {
        transition: none !important;
    }

    .ptr-container.ptr-refreshing .ptr-spinner {
        animation: none;
    }
}

/* Ensure proper display in PWA standalone mode */
@supports (padding-top: env(safe-area-inset-top)) {
    .ptr-container {
        padding-top: env(safe-area-inset-top);
    }
}
