/**
 * Bouton Scroll to Top
 * Design moderne avec animations et mode dark/light
 */

/* === BASE DU BOUTON === */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  z-index: 998;
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--color-accent-start),
    var(--color-accent-end)
  );
  color: #ffffff;
  border: none;
  border-radius: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(1, 112, 168, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scroll-to-top-left {
  left: 2rem;
}

.scroll-to-top-right {
  right: 2rem;
}

/* === CONTENU DU BOUTON === */
.scroll-to-top-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.25rem;
}

.scroll-to-top-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  transition: transform 0.3s ease;
}

.scroll-to-top-icon svg {
  width: 100%;
  height: 100%;
}

.scroll-to-top-text {
  font-family: var(--font-primary);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.scroll-to-top:hover .scroll-to-top-icon {
  transform: translateY(-3px);
}

/* === EFFET DE SURVOL === */
.scroll-to-top-hover-effect {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.scroll-to-top:hover .scroll-to-top-hover-effect {
  opacity: 1;
  transform: scale(1);
}

/* === CERCLE DE PROGRESSION === */
.scroll-progress-circle {
  position: absolute;
  top: -4px;
  left: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.progress-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 3;
}

.progress-bar {
  fill: none;
  stroke: #ffffff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 163.36; /* 2 * PI * 26 */
  stroke-dashoffset: 163.36;
  transition: stroke-dashoffset 0.1s linear;
}

/* === ANIMATIONS D'APPARITION === */

.scroll-to-top-animation-fade {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.scroll-to-top-animation-fade-slide {
  animation: fadeSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scroll-to-top-animation-scale {
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.scroll-to-top-animation-bounce {
  animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(30px);
  }
  50% {
    opacity: 1;
    transform: scale(1.05) translateY(-5px);
  }
  70% {
    transform: scale(0.95) translateY(2px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

/* === ÉTATS HOVER & ACTIVE === */
.scroll-to-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(1, 112, 168, 0.4);
}

.scroll-to-top:active {
  transform: translateY(-1px) scale(0.95);
  box-shadow: 0 4px 15px rgba(1, 112, 168, 0.3);
}

/* === MODE DARK === */
[data-theme='dark'] .scroll-to-top {
  background: linear-gradient(
    135deg,
    var(--color-accent-start),
    var(--color-accent-end)
  );
  box-shadow: 0 4px 20px rgba(25, 184, 216, 0.3);
}

[data-theme='dark'] .scroll-to-top:hover {
  box-shadow: 0 8px 30px rgba(25, 184, 216, 0.4);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .scroll-to-top {
    width: 3rem;
    height: 3rem;
    bottom: 1.5rem;
  }

  .scroll-to-top-left {
    left: 1.5rem;
  }

  .scroll-to-top-right {
    right: 1.5rem;
  }

  .scroll-to-top-icon {
    width: 1.25rem;
    height: 1.25rem;
  }

  .scroll-to-top-text {
    font-size: 0.6rem;
  }
}

@media (max-width: 480px) {
  .scroll-to-top {
    bottom: 1rem;
  }

  .scroll-to-top-left {
    left: 1rem;
  }

  .scroll-to-top-right {
    right: 1rem;
  }

  .scroll-to-top-text {
    display: none;
  }
}

/* === ACCESSIBILITÉ === */

.scroll-to-top:focus-visible {
  outline: 3px solid var(--color-accent-start);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-to-top,
  .scroll-to-top-icon,
  .scroll-to-top-hover-effect,
  .progress-bar {
    transition: none !important;
    animation: none !important;
  }
}
