/*
 * Scroll To Top — Premium · Anillo de progreso + núcleo neón
 * Ubicación: /modules/scrolltotop/views/css/scrolltotop.css
 *
 * Capas: anillo de progreso de scroll (SVG, gestionado por JS) · núcleo "glass"
 * navy con borde y brillo interior · doble chevron de impulso · glow neón ·
 * tooltip deslizante · onda de pulso al click. Cuidado al detalle y accesible.
 */

:root {
  --stt-show: 0.45s;
  --stt-hide: 0.32s;
}

/* ═══════════════════════════════════════════════════════
   BOTÓN (contenedor)
═══════════════════════════════════════════════════════ */
.scroll-to-top-btn {
  position: fixed;
  z-index: 998;
  display: none;                 /* JS → grid */
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 10px 22px rgba(8, 12, 30, 0.45));
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
}
.scroll-to-top-btn > * { grid-area: 1 / 1; }   /* todo apilado y centrado */

/* ─── Posiciones ─── */
.scroll-to-top-btn.stt-bottom-right { bottom: 30px; right: 30px; }
.scroll-to-top-btn.stt-bottom-left  { bottom: 30px; left:  30px; }
.scroll-to-top-btn.stt-top-right    { top:    30px; right: 30px; }
.scroll-to-top-btn.stt-top-left     { top:    30px; left:  30px; }

/* ─── Tamaños ─── */
.scroll-to-top-btn.stt-small  { width: 48px; height: 48px; }
.scroll-to-top-btn.stt-medium { width: 58px; height: 58px; }
.scroll-to-top-btn.stt-large  { width: 70px; height: 70px; }

/* ═══════════════════════════════════════════════════════
   ANILLO DE PROGRESO
═══════════════════════════════════════════════════════ */
.stt-ring {
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);     /* el progreso arranca arriba (12 h) */
}
.stt-ring__track {
  stroke: rgba(120, 140, 190, 0.22);
  stroke-width: 5;
}
.stt-ring__progress {
  stroke: url(#stt-ring-grad);
  stroke-width: 5;
  stroke-linecap: round;
  /* circunferencia r=44 → 2πr ≈ 276.46; el JS ajusta el dashoffset */
  stroke-dasharray: 276.46;
  stroke-dashoffset: 276.46;     /* 0% al inicio */
  transition: stroke-dashoffset 0.18s linear;
}

/* ═══════════════════════════════════════════════════════
   NÚCLEO "GLASS"
═══════════════════════════════════════════════════════ */
.stt-core {
  position: relative;
  display: grid;
  place-items: center;
  width: 74%;
  height: 74%;
  border-radius: 50%;
  color: #eaf2ff;
  background:
    radial-gradient(120% 120% at 50% 22%, rgba(72, 198, 255, 0.18), transparent 58%),
    linear-gradient(160deg, #2b3358 0%, #21274a 52%, #161b34 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -6px 14px rgba(8, 10, 24, 0.55),
    inset 0 0 0 1px rgba(120, 160, 230, 0.16);
  transition: transform 0.2s ease, color 0.2s ease, box-shadow 0.25s ease;
}
/* Reflejo superior sutil */
.stt-core::before {
  content: "";
  position: absolute;
  top: 8%;
  left: 14%;
  width: 52%;
  height: 38%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  pointer-events: none;
}

/* ─── Doble chevron de impulso ─── */
.stt-glyph {
  position: relative;
  width: 46%;
  height: 46%;
  overflow: visible;
}
.stt-chevron {
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.24s ease;
}
.stt-chevron--bottom { opacity: 0.55; }

/* ═══════════════════════════════════════════════════════
   TOOLTIP
═══════════════════════════════════════════════════════ */
.stt-tooltip {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  white-space: nowrap;
  padding: 7px 12px;
  border-radius: 9px;
  font: 600 12.5px/1 'Outfit', sans-serif;
  letter-spacing: 0.01em;
  color: #eaf2ff;
  background: linear-gradient(160deg, #21274a, #141833);
  box-shadow: 0 8px 20px rgba(8, 12, 30, 0.4), inset 0 0 0 1px rgba(120, 160, 230, 0.18);
  opacity: 0;
  transform: translateY(-50%) translateX(8px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.stt-tooltip::after {       /* flecha del tooltip */
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: #141833;
}
/* Posiciones a la izquierda: el tooltip va a la derecha */
.scroll-to-top-btn.stt-bottom-left  .stt-tooltip,
.scroll-to-top-btn.stt-top-left     .stt-tooltip {
  right: auto;
  left: calc(100% + 14px);
  transform: translateY(-50%) translateX(-8px);
}
.scroll-to-top-btn.stt-bottom-left  .stt-tooltip::after,
.scroll-to-top-btn.stt-top-left     .stt-tooltip::after {
  left: auto;
  right: 100%;
  border-left-color: transparent;
  border-right-color: #141833;
}

/* ═══════════════════════════════════════════════════════
   ONDA DE PULSO (click)
═══════════════════════════════════════════════════════ */
.stt-ripple {
  width: 74%;
  height: 74%;
  border-radius: 50%;
  border: 2px solid var(--stt-accent);
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════
   ESTADOS
═══════════════════════════════════════════════════════ */
.scroll-to-top-btn.show {
  display: grid !important;
  animation:
    sttIn    var(--stt-show) cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
    sttBreath 4.5s ease-in-out 0.8s infinite;
}
.scroll-to-top-btn.hide {
  animation: sttOut var(--stt-hide) ease forwards;
}

/* Hover / focus: levanta, intensifica glow, chevrons suben y juntan, tooltip entra */
.scroll-to-top-btn:not(.hide):hover,
.scroll-to-top-btn:not(.hide):focus-visible {
  transform: translateY(-4px) scale(1.04);
  filter: drop-shadow(0 14px 26px rgba(8, 12, 30, 0.5))
          drop-shadow(0 0 16px rgba(72, 198, 255, 0.5));
  animation-play-state: paused;
}
.scroll-to-top-btn:not(.hide):hover .stt-core,
.scroll-to-top-btn:not(.hide):focus-visible .stt-core {
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -6px 14px rgba(8, 10, 24, 0.55),
    inset 0 0 0 1px rgba(120, 200, 255, 0.4);
}
.scroll-to-top-btn:not(.hide):hover .stt-chevron--top,
.scroll-to-top-btn:not(.hide):focus-visible .stt-chevron--top {
  transform: translateY(-1.5px);
}
.scroll-to-top-btn:not(.hide):hover .stt-chevron--bottom,
.scroll-to-top-btn:not(.hide):focus-visible .stt-chevron--bottom {
  transform: translateY(-1.5px);
  opacity: 0.85;
}
.scroll-to-top-btn:not(.hide):hover .stt-tooltip,
.scroll-to-top-btn:not(.hide):focus-visible .stt-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Focus accesible */
.scroll-to-top-btn:focus-visible { outline: none; }
.scroll-to-top-btn:focus-visible .stt-core {
  outline: 2px solid #48c6ff;
  outline-offset: 4px;
}

/* Click: pulsa el núcleo, los chevrons "disparan" y emerge la onda */
.scroll-to-top-btn.stt-press .stt-core { animation: sttPress 0.42s ease; }
.scroll-to-top-btn.stt-press .stt-chevron--top    { animation: sttShootTop 0.5s ease; }
.scroll-to-top-btn.stt-press .stt-chevron--bottom { animation: sttShootBottom 0.5s ease; }
.scroll-to-top-btn.stt-press .stt-ripple { animation: sttRipple 0.55s ease-out; }

/* ═══════════════════════════════════════════════════════
   KEYFRAMES
═══════════════════════════════════════════════════════ */
@keyframes sttIn {
  from { opacity: 0; transform: translateY(22px) scale(0.7); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes sttOut {
  from { opacity: 1; transform: translateY(0)   scale(1); }
  to   { opacity: 0; transform: translateY(16px) scale(0.8); }
}
/* Respiración del glow en reposo */
@keyframes sttBreath {
  0%, 100% { filter: drop-shadow(0 10px 22px rgba(8, 12, 30, 0.45))
                     drop-shadow(0 0 0 rgba(72, 198, 255, 0)); }
  50%      { filter: drop-shadow(0 10px 22px rgba(8, 12, 30, 0.45))
                     drop-shadow(0 0 12px rgba(72, 198, 255, 0.35)); }
}
@keyframes sttPress {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.86); }
  100% { transform: scale(1); }
}
@keyframes sttShootTop {
  0%   { transform: translateY(0); opacity: 1; }
  45%  { transform: translateY(-7px); opacity: 0; }
  46%  { transform: translateY(5px);  opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
@keyframes sttShootBottom {
  0%   { transform: translateY(0); opacity: 0.55; }
  45%  { transform: translateY(-7px); opacity: 0; }
  46%  { transform: translateY(5px);  opacity: 0; }
  100% { transform: translateY(0); opacity: 0.55; }
}
@keyframes sttRipple {
  0%   { opacity: 0.7; transform: scale(0.6); }
  100% { opacity: 0;   transform: scale(1.5); }
}

/* ═══════════════════════════════════════════════════════
   MOVIMIENTO REDUCIDO
═══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .scroll-to-top-btn.show { animation: none; opacity: 1; transform: none; }
  .scroll-to-top-btn.hide { animation: none; opacity: 0; }
  .scroll-to-top-btn.stt-press .stt-core,
  .scroll-to-top-btn.stt-press .stt-chevron--top,
  .scroll-to-top-btn.stt-press .stt-chevron--bottom,
  .scroll-to-top-btn.stt-press .stt-ripple { animation: none; }
  .stt-ring__progress { transition: none; }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .scroll-to-top-btn.stt-bottom-right { bottom: 18px; right: 18px; }
  .scroll-to-top-btn.stt-bottom-left  { bottom: 18px; left:  18px; }
  .scroll-to-top-btn.stt-top-right    { top:    18px; right: 18px; }
  .scroll-to-top-btn.stt-top-left     { top:    18px; left:  18px; }
  .scroll-to-top-btn.stt-medium { width: 52px; height: 52px; }
  .scroll-to-top-btn.stt-large  { width: 60px; height: 60px; }
  .stt-tooltip { display: none; }   /* en móvil no hay hover */
}
