/**
 * EAAS Theme - Back to Top Styles
 *
 * @package    EAAS
 * @version    2.5
 * @author     Rodolphe
 * @link       https://enaccordavecsoi.fr
 * @file       back-to-top.css
 */

/* ──────────────────────────────────────────
 * BOUTON RETOUR EN HAUT
 * ────────────────────────────────────────── */

.back-to-top {
    position: fixed;
    bottom: var(--back-to-top-offset-bottom, 30px);
    width: var(--back-to-top-size, 48px);
    height: var(--back-to-top-size, 48px);
    background: var(--back-to-top-bg, linear-gradient(135deg, var(--secondary-color), var(--accent-color)));
    color: var(--back-to-top-icon-color, #ffffff);
    border: var(--back-to-top-border-width, 0) solid var(--back-to-top-border-color, #ffffff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: var(--shadow-md, 0 4px 15px rgba(0,0,0,0.15));
    z-index: var(--z-fixed, 300);
    padding: 0;
    
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Position ── */
.back-to-top.position-right,
.back-to-top:not(.position-left) {
    right: var(--back-to-top-offset-side, 30px);
    left: auto;
}

.back-to-top.position-left {
    left: var(--back-to-top-offset-side, 30px);
    right: auto;
}

/* ── Formes ── */
.back-to-top.shape-circle,
.back-to-top:not(.shape-square):not(.shape-rounded):not(.shape-squircle):not(.shape-pill) {
    border-radius: 50%;
}

.back-to-top.shape-square {
    border-radius: 0;
}

.back-to-top.shape-rounded {
    border-radius: var(--border-radius-md, 12px);
}

.back-to-top.shape-squircle {
    border-radius: 28%;
}

.back-to-top.shape-pill {
    border-radius: 9999px;
    width: auto;
    padding: 0 16px;
    min-width: var(--back-to-top-size, 48px);
}

/* ── Show/Hide ── */
.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ── Hover ── */
.back-to-top:hover {
    transform: translateY(calc(-1 * var(--back-to-top-hover-lift, 5px))) scale(1.05);
    box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.2));
    background: var(--back-to-top-bg-hover, var(--accent-color));
}

.back-to-top:active {
    transform: translateY(-2px) scale(0.95);
}

/* ── Icône ── */
.back-to-top svg {
    width: var(--back-to-top-icon-size, 24px);
    height: var(--back-to-top-icon-size, 24px);
    display: block;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    transition: transform var(--transition-fast, 0.3s) ease;
}

/* Icônes qui utilisent fill au lieu de stroke */
.back-to-top svg.icon-fill {
    fill: currentColor;
    stroke: none;
}

.back-to-top:hover svg {
    transform: translateY(-2px);
}

/* ── Label ── */
.back-to-top .btt-label {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ── Ombre ── */
.back-to-top.no-shadow {
    box-shadow: none;
}

.back-to-top.no-shadow:hover {
    box-shadow: none;
}

/* ── Focus accessible ── */
.back-to-top:focus-visible {
    outline: var(--focus-outline-width, 3px) solid var(--focus-outline-color, #4a90e2);
    outline-offset: var(--focus-outline-offset, 2px);
}

/* ──────────────────────────────────────────
 * ANIMATIONS D'APPARITION
 * ────────────────────────────────────────── */

.back-to-top.animation-fade.show {
    animation: eaas-btt-fade 0.4s ease both;
}

.back-to-top.animation-slide-up.show {
    animation: eaas-btt-slide-up 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.back-to-top.animation-scale.show {
    animation: eaas-btt-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.back-to-top.animation-bounce.show {
    animation: eaas-btt-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.back-to-top.animation-rotate.show {
    animation: eaas-btt-rotate 0.5s ease both;
}

.back-to-top.animation-flip.show {
    animation: eaas-btt-flip 0.6s ease both;
}

@keyframes eaas-btt-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes eaas-btt-slide-up {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes eaas-btt-scale {
    from { opacity: 0; transform: scale(0); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes eaas-btt-bounce {
    0% { opacity: 0; transform: scale(0.3); }
    50% { transform: scale(1.1); }
    70% { transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes eaas-btt-rotate {
    from { opacity: 0; transform: rotate(-180deg) scale(0.5); }
    to { opacity: 1; transform: rotate(0) scale(1); }
}

@keyframes eaas-btt-flip {
    from { opacity: 0; transform: perspective(400px) rotateY(90deg); }
    to { opacity: 1; transform: perspective(400px) rotateY(0); }
}

/* ──────────────────────────────────────────
 * PULSE ANIMATION
 * ────────────────────────────────────────── */

.back-to-top.has-pulse::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    background: var(--back-to-top-bg, var(--secondary-color));
    opacity: 0;
    z-index: -1;
    animation: eaas-btt-pulse 2s infinite;
}

@keyframes eaas-btt-pulse {
    0% { transform: scale(1); opacity: 0.4; }
    70% { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* ──────────────────────────────────────────
 * RESPONSIVE
 * ────────────────────────────────────────── */

@media (min-width: 992px) and (max-width: 1199px) {
    .back-to-top {
        --back-to-top-size: var(--back-to-top-size-tablet-landscape, 50px);
    }
}

@media (max-width: 991px) and (min-width: 768px) {
    .back-to-top {
        --back-to-top-size: var(--back-to-top-size-tablet, 46px);
    }
}

@media (max-width: 768px) {
    .back-to-top {
        --back-to-top-size: var(--back-to-top-size-mobile, 40px);  /* Unifié avec WhatsApp */
        bottom: var(--back-to-top-offset-bottom, 15px);
    }

    .back-to-top.position-right,
    .back-to-top:not(.position-left) {
        right: var(--back-to-top-offset-side, 15px);
    }

    .back-to-top.position-left {
        left: var(--back-to-top-offset-side, 15px);
    }

    .back-to-top svg {
        width: calc(var(--back-to-top-icon-size, 24px) * 0.83);
        height: calc(var(--back-to-top-icon-size, 24px) * 0.83);
    }

    .back-to-top .btt-label {
        font-size: var(--font-size-2xs, 10px);
    }
}

@media (max-width: 480px) {
    .back-to-top {
        --back-to-top-size: calc(var(--back-to-top-size-mobile, 40px) * 0.9);
        bottom: var(--spacing-sm, 12px);
    }

    .back-to-top.position-right,
    .back-to-top:not(.position-left) {
        right: var(--spacing-sm, 12px);
    }

    .back-to-top.position-left {
        left: var(--spacing-sm, 12px);
    }

    .back-to-top svg {
        width: calc(var(--back-to-top-icon-size, 24px) * 0.75);
        height: calc(var(--back-to-top-icon-size, 24px) * 0.75);
    }

    .back-to-top .btt-label {
        display: none;
    }
}

@media (max-width: 360px) {
    .back-to-top {
        --back-to-top-size: calc(var(--back-to-top-size-mobile, 40px) * 0.8);
        bottom: var(--spacing-sm, 10px);
    }

    .back-to-top.position-right,
    .back-to-top:not(.position-left) {
        right: var(--spacing-sm, 10px);
    }

    .back-to-top.position-left {
        left: var(--spacing-sm, 10px);
    }

    .back-to-top svg {
        width: calc(var(--back-to-top-icon-size, 24px) * 0.67);
        height: calc(var(--back-to-top-icon-size, 24px) * 0.67);
    }
}
