/* =====================================================
   Glassmorphism Button Component
   Dipende da: variabili CSS --primary-text definite nel tema
   ===================================================== */

/* Container posizionamento */
.cta-container {
  position: fixed;
  /* bottom: non definito — da impostare nella singola pagina */
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  pointer-events: none;
}

/* Wrapper per effetti avanzati (3D tilt on active) */
.button-wrap {
  position: relative;
  z-index: 2;
  transition: transform 400ms cubic-bezier(0.25, 1, 0.5, 1);
}

/* Shadow disabilitato */
.button-shadow {
  display: none;
}

/* ---- Stile base ---- */
.glassmorphism-btn {
  --highlight: 0.2; /* controlla bordo superiore, inset shadow e ::after */
  position: relative;
  display: inline-block;
  padding: 2.2vh 4.4vh;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.30) 0%,
      rgba(255, 255, 255, 0.14) 40%,
      rgba(255, 255, 255, 0.06) 100%
    );
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-top-color: rgba(255, 255, 255, var(--highlight));
  border-left-color: rgba(255, 255, 255, var(--highlight));
  border-radius: 50px;
  color: var(--primary-text);
  text-decoration: none;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 2vh;
  letter-spacing: 1px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.10),
    0 1px 3px rgba(0, 0, 0, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, var(--highlight)),
    inset 0 0 20px rgba(255, 255, 255, 0.05);
  transition: background 400ms cubic-bezier(0.25, 1, 0.5, 1),
              border-color 400ms cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow 400ms cubic-bezier(0.25, 1, 0.5, 1),
              transform 400ms cubic-bezier(0.25, 1, 0.5, 1),
              backdrop-filter 400ms cubic-bezier(0.25, 1, 0.5, 1),
              -webkit-backdrop-filter 400ms cubic-bezier(0.25, 1, 0.5, 1);
  cursor: pointer;
  pointer-events: auto;
  z-index: 3;
  overflow: hidden;
  will-change: transform;
  isolation: isolate;
}

/* Specular highlight along top edge */
.glassmorphism-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, var(--highlight)),
    transparent
  );
  pointer-events: none;
  z-index: 3;
}

/* Il testo resta sopra l'effetto riflesso */
.glassmorphism-btn * {
  position: relative;
  z-index: 2;
}

/* ---- Riflesso animato (pseudo-elemento) ---- */
.glassmorphism-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.08),
    transparent
  );
  transition: left 500ms ease;
  z-index: 1;
  pointer-events: none;
}

/* ---- Hover ---- */
.glassmorphism-btn:hover {
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.42) 0%,
      rgba(255, 255, 255, 0.22) 40%,
      rgba(255, 255, 255, 0.10) 100%
    );
  border-color: rgba(255, 255, 255, 0.45);
  border-top-color: rgba(255, 255, 255, 0.32);
  border-left-color: rgba(255, 255, 255, 0.30);
  transform: scale(0.975);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.14),
    0 1px 3px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 0 30px rgba(255, 255, 255, 0.08);
}

.glassmorphism-btn:hover::before {
  left: 100%;
}

/* ---- Active / Press ---- */
.glassmorphism-btn:active {
  transform: scale(0.95);
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.38) 0%,
      rgba(255, 255, 255, 0.18) 40%,
      rgba(255, 255, 255, 0.08) 100%
    );
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.14),
    0 1px 2px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 0 20px rgba(255, 255, 255, 0.06);
}

.button-wrap:has(.glassmorphism-btn:active) {
  transform: rotate3d(1, 0, 0, 15deg);
}
/* =====================================================
   Social Button Variant (circular icon buttons)
   ===================================================== */

.social-btn {
  --highlight: 0.12; /* controlla bordo superiore, inset shadow e ::after */
  position: relative;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.30) 0%,
      rgba(255, 255, 255, 0.14) 40%,
      rgba(255, 255, 255, 0.06) 100%
    );
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-top-color: rgba(255, 255, 255, var(--highlight));
  border-left-color: rgba(255, 255, 255, var(--highlight));
  color: var(--primary-text);
  text-decoration: none;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.10),
    0 1px 3px rgba(0, 0, 0, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, var(--highlight)),
    inset 0 0 20px rgba(255, 255, 255, 0.05);
  transition: background 400ms cubic-bezier(0.25, 1, 0.5, 1),
              border-color 400ms cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow 400ms cubic-bezier(0.25, 1, 0.5, 1),
              transform 400ms cubic-bezier(0.25, 1, 0.5, 1),
              backdrop-filter 400ms cubic-bezier(0.25, 1, 0.5, 1),
              -webkit-backdrop-filter 400ms cubic-bezier(0.25, 1, 0.5, 1);
  cursor: pointer;
  overflow: hidden;
  will-change: transform;
  isolation: isolate;
}

/* Specular highlight along top edge */
.social-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, var(--highlight)),
    transparent
  );
  pointer-events: none;
  z-index: 3;
}

/* Il contenuto resta sopra il riflesso, tranne le icone che stanno sotto il glow */
.social-btn * {
  position: relative;
  z-index: 2;
}

.social-btn img,
.social-btn svg {
  z-index: 0;
}

/* Riflesso animato */
.social-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 80%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.08),
    transparent
  );
  transition: left 500ms ease;
  z-index: 1;
  pointer-events: none;
}

.social-btn:hover {
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.42) 0%,
      rgba(255, 255, 255, 0.22) 40%,
      rgba(255, 255, 255, 0.10) 100%
    );
  border-color: rgba(255, 255, 255, 0.45);
  border-top-color: rgba(255, 255, 255, 0.32);
  border-left-color: rgba(255, 255, 255, 0.30);
  transform: scale(0.92);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.14),
    0 1px 3px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 0 30px rgba(255, 255, 255, 0.08);
}

.social-btn:hover::before {
  left: 100%;
}

.social-btn:active {
  transform: scale(0.85);
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.38) 0%,
      rgba(255, 255, 255, 0.18) 40%,
      rgba(255, 255, 255, 0.08) 100%
    );
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.14),
    0 1px 2px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 0 20px rgba(255, 255, 255, 0.06);
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
  .social-btn:hover {
    transform: none;
  }

  .social-btn:active {
    transform: scale(0.95);
  }
}

@media (max-width: 768px) {
  .cta-container {
    position: absolute;
    bottom: 8vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    width: calc(100vw - 40px);
    display: flex;
    justify-content: center;
  }

  .button-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .glassmorphism-btn {
    padding: 1.8vh 3.5vh;
    font-size: 1.8vh;
    max-width: 280px;
    text-align: center;
    white-space: nowrap;
  }

  .button-shadow {
    display: none;
  }

  .button-wrap:has(.glassmorphism-btn:active) {
    transform: none;
  }

  /* Touch devices: disabilita hover, mantieni active */
  @media (hover: none) and (pointer: coarse) {
    .glassmorphism-btn:hover {
      transform: none;
    }

    .glassmorphism-btn:active {
      transform: scale(0.95);
    }
  }
}

/* =====================================================
   Mouse-following glow (requires glassmorphism-btn.js)
   ===================================================== */
.btn-mouse-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    40vh circle at var(--glow-x, 50%) var(--glow-y, 50%),
    rgba(255, 255, 255, 0.40),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 350ms ease;
  pointer-events: none;
  z-index: 1;
}

.glassmorphism-btn:hover .btn-mouse-glow,
.social-btn:hover .btn-mouse-glow {
  opacity: 1;
}

@media (hover: none) and (pointer: coarse) {
  .btn-mouse-glow { display: none; }
}
