/* =========================================================
   ساخت‌یار | Back To Top
   دکمه بازگشت به بالا + حلقه پیشرفت اسکرول
   Namespace: .btt-*
   وابستگی: theme.css
   ========================================================= */

.btt {
    --btt-size: 50px;
    --btt-bg: var(--color-white, #ffffff);
    --btt-fg: var(--color-secondary, #24372f);
    --btt-accent: var(--color-primary, #b85c38);
    --btt-accent-dark: var(--color-primary-dark, #9a4b2c);
    --btt-border: var(--color-border, #e8e2d8);
    --btt-ring-track: var(--color-border-light, #f0ede6);
    --btt-ring-fill: var(--color-primary, #b85c38);
    --btt-shadow: 0 12px 30px rgba(23, 26, 24, 0.12);
    --btt-shadow-hover: 0 18px 42px rgba(184, 92, 56, 0.22);

    position: fixed;
    z-index: 1090;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    inset-inline-end: calc(24px + env(safe-area-inset-right, 0px));

    width: var(--btt-size);
    height: var(--btt-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid var(--btt-border);
    border-radius: 50%;
    background: var(--btt-bg);
    color: var(--btt-fg);
    box-shadow: var(--btt-shadow);
    cursor: pointer;
    overflow: hidden;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(14px) scale(0.94);

    transition:
        opacity 260ms ease,
        visibility 260ms ease,
        transform 260ms cubic-bezier(0.16, 1, 0.3, 1),
        background-color 180ms ease,
        color 180ms ease,
        border-color 180ms ease,
        box-shadow 220ms ease;
}

.btt.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* =========================================================
   Ring / Progress
   ========================================================= */

.btt__ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: rotate(-90deg);
}

.btt__ring svg {
    width: 100%;
    height: 100%;
    display: block;
}

.btt__track,
.btt__progress {
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
}

.btt__track {
    stroke: var(--btt-ring-track);
}

.btt__progress {
    stroke: var(--btt-ring-fill);
    stroke-dasharray: var(--btt-circumference, 126);
    stroke-dashoffset: var(--btt-circumference, 126);
    transition: stroke-dashoffset 120ms linear;
}

/* =========================================================
   Icon
   ========================================================= */

.btt__icon {
    position: relative;
    z-index: 1;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btt__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================================
   States
   ========================================================= */

.btt:hover {
    background: var(--btt-accent);
    border-color: transparent;
    color: var(--color-white, #ffffff);
    box-shadow: var(--btt-shadow-hover);
    transform: translateY(-3px) scale(1);
}

.btt:hover .btt__track {
    stroke: rgba(255, 255, 255, 0.22);
}

.btt:hover .btt__progress {
    stroke: var(--color-white, #ffffff);
}

.btt:active {
    transform: translateY(-1px) scale(0.97);
}

.btt:focus-visible {
    outline: 3px solid var(--color-accent, #d9e84a);
    outline-offset: 3px;
}

/* =========================================================
   Screen reader text
   ========================================================= */

.btt__sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 991px) {
    .btt {
        --btt-size: 48px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        inset-inline-end: calc(20px + env(safe-area-inset-right, 0px));
    }
}

@media (max-width: 767px) {
    .btt {
        --btt-size: 44px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        inset-inline-end: calc(16px + env(safe-area-inset-right, 0px));
        box-shadow: 0 10px 24px rgba(23, 26, 24, 0.12);
    }

    .btt__track,
    .btt__progress {
        stroke-width: 2.1;
    }

    .btt__icon {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 379px) {
    .btt {
        --btt-size: 42px;
    }
}

/* =========================================================
   Reduced Motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .btt,
    .btt__progress {
        transition: none !important;
    }

    .btt:hover,
    .btt:active {
        transform: none;
    }
}

/* =========================================================
   Print
   ========================================================= */

@media print {
    .btt {
        display: none !important;
    }
}