/* ==========================================================================
   27-scroll-top.css
   زر العودة لأعلى مع شريط تقدم دائري (Circular Progress)
   ========================================================================== */

.scroll-top {
    position: fixed;
    bottom: 30px;
    left: 30px; /* في RTL يظهر على اليسار */
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease;
}

.scroll-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ---------- حاوية الزر الدائري ---------- */
.scroll-top__btn {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-surface);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.scroll-top__btn:hover {
    background-color: var(--color-primary);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.18);
    transform: scale(1.08);
}

/* الأيقونة (السهم) */
.scroll-top__icon {
    font-size: 20px;
    color: var(--color-primary);
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 2;
    line-height: 1;
}

.scroll-top__btn:hover .scroll-top__icon {
    color: #fff;
    transform: translateY(-2px);
}

/* ---------- الحلقة الدائرية (SVG Progress Ring) ---------- */
.scroll-top__progress {
    position: absolute;
    inset: 0;
    width: 48px;
    height: 48px;
    transform: rotate(-90deg); /* البداية من الأعلى */
    z-index: 1;
}

.scroll-top__progress-bg {
    fill: none;
    stroke: var(--color-border);
    stroke-width: 2.5;
}

.scroll-top__progress-bar {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 2.5;
    stroke-linecap: round;
    /* المحيط الكامل للدائرة (2 * π * r) حيث r = 20 */
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66; /* يبدأ فارغاً */
    transition: stroke-dashoffset 0.15s ease-out;
}

.scroll-top__btn:hover .scroll-top__progress-bar {
    stroke: #fff;
}

.scroll-top__btn:hover .scroll-top__progress-bg {
    stroke: rgba(255, 255, 255, 0.25);
}

/* ---------- تأثير النبض عند الوصول لنهاية الصفحة ---------- */
.scroll-top.is-complete .scroll-top__btn {
    animation: scroll-top-pulse 1.5s ease-in-out;
}

@keyframes scroll-top-pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(var(--color-primary-rgb, 0, 145, 60), 0.15),
                    0 4px 20px rgba(0, 0, 0, 0.12);
    }
}

/* ---------- تجاوب الموبايل ---------- */
@media (max-width: 767px) {
    .scroll-top {
        bottom: 20px;
        left: 20px;
    }

    .scroll-top__btn {
        width: 42px;
        height: 42px;
    }

    .scroll-top__progress {
        width: 42px;
        height: 42px;
    }

    .scroll-top__icon {
        font-size: 18px;
    }
}
