/* ==========================================================
   Linktree — Luca Difede (@difedewebdesigner)
   Colori e tipografia da Brand_Guidelines.md
   Stile: glassmorphism premium su fondo Nero Profondo
   ========================================================== */

:root {
  --violet: #6366F1;          /* Viola Innovazione */
  --violet-dark: #4F46E5;
  --violet-light: #A5B4FC;
  --black: #1A1A1A;           /* Nero Profondo */
  --white: #FFFFFF;           /* Bianco Puro */
  --grey-soft: #F9FAFB;       /* Grigio Soft */
  --text-muted: rgba(249, 250, 251, 0.66);

  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-hover: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-blur: blur(18px) saturate(170%);

  --radius: 16px;
  --font-title: 'Montserrat', system-ui, sans-serif;
  --font-body: 'Lora', Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #0E0E12;
  color: var(--grey-soft);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- Sfondo: aurore + grana ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, #1F1D3A 0%, transparent 60%),
    linear-gradient(180deg, #121218 0%, var(--black) 100%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  will-change: transform;
}

.orb--1 {
  width: 520px;
  height: 520px;
  top: -180px;
  left: 50%;
  margin-left: -360px;
  background: radial-gradient(circle, var(--violet) 0%, transparent 70%);
  animation: drift-1 22s ease-in-out infinite alternate;
}

.orb--2 {
  width: 420px;
  height: 420px;
  top: 35%;
  right: -160px;
  background: radial-gradient(circle, #8B5CF6 0%, transparent 70%);
  opacity: 0.4;
  animation: drift-2 26s ease-in-out infinite alternate;
}

.orb--3 {
  width: 460px;
  height: 460px;
  bottom: -200px;
  left: -140px;
  background: radial-gradient(circle, var(--violet-dark) 0%, transparent 70%);
  opacity: 0.45;
  animation: drift-3 30s ease-in-out infinite alternate;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes drift-1 {
  to { transform: translate(180px, 80px) scale(1.15); }
}

@keyframes drift-2 {
  to { transform: translate(-140px, -120px) scale(0.9); }
}

@keyframes drift-3 {
  to { transform: translate(160px, -100px) scale(1.1); }
}

/* ---------- Layout ---------- */
.page {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: 64px 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* ---------- Pulsante condividi ---------- */
.share-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: var(--white);
  cursor: pointer;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease);
}

.share-btn svg {
  width: 18px;
  height: 18px;
}

.share-btn:hover {
  background: rgba(99, 102, 241, 0.35);
  border-color: rgba(165, 180, 252, 0.5);
  transform: rotate(-8deg) scale(1.05);
}

/* ---------- Profilo ---------- */
.profile {
  text-align: center;
  margin-bottom: 36px;
  animation: rise 0.8s var(--ease) both;
}

.avatar {
  position: relative;
  width: 136px;
  height: 136px;
  margin: 0 auto 22px;
  padding: 3px;
  border-radius: 50%;
  isolation: isolate;
}

/* Anello conico rotante */
.avatar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--violet), var(--violet-light), #ffffff, var(--violet-light), var(--violet));
  animation: spin 8s linear infinite;
}

/* Alone morbido dietro l'avatar */
.avatar::after {
  content: '';
  position: absolute;
  inset: -18px;
  z-index: -2;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.55), transparent 70%);
  filter: blur(14px);
}

.avatar img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  border: 4px solid #121218;
  object-fit: cover;
  object-position: 50% 50%;
}

.name {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, #FFFFFF 30%, #C7CBFF 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.handle {
  display: inline-block;
  margin: 10px 0 14px;
  padding: 5px 14px;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--violet-light);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(165, 180, 252, 0.25);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.role {
  margin: 0 0 12px;
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.85);
}

.bio {
  margin: 0 auto;
  max-width: 42ch;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.bio em {
  color: var(--white);
}

/* ---------- Tab in vetro ---------- */
.links {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.link {
  --mx: 50%;
  --my: 50%;
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px 14px 14px;
  overflow: hidden;
  isolation: isolate;
  color: var(--white);
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.03) 100%);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04),
    0 10px 30px -12px rgba(0, 0, 0, 0.6);
  transition:
    transform 0.45s var(--ease),
    border-color 0.45s var(--ease),
    box-shadow 0.45s var(--ease),
    background 0.45s var(--ease);
  animation: rise 0.8s var(--ease) both;
}

/* Alone che segue il puntatore */
.link::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(220px circle at var(--mx) var(--my), rgba(129, 140, 248, 0.35), transparent 65%);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

/* Riflesso di luce che attraversa il vetro */
.link::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  z-index: -1;
  background: linear-gradient(105deg, transparent 0%, rgba(255, 255, 255, 0.16) 50%, transparent 100%);
  transform: skewX(-20deg) translateX(0);
  transition: transform 0.9s var(--ease);
  pointer-events: none;
}

.link:nth-child(1) { animation-delay: 0.10s; }
.link:nth-child(2) { animation-delay: 0.18s; }
.link:nth-child(3) { animation-delay: 0.26s; }
.link:nth-child(4) { animation-delay: 0.34s; }
.link:nth-child(5) { animation-delay: 0.42s; }
.link:nth-child(6) { animation-delay: 0.50s; }

.link__icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--white);
  background: linear-gradient(145deg, rgba(129, 140, 248, 0.9), rgba(79, 70, 229, 0.9));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 6px 16px -6px rgba(99, 102, 241, 0.8);
  transition: transform 0.45s var(--ease);
}

.link__icon svg {
  width: 20px;
  height: 20px;
}

.link__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.link__title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.link__sub {
  font-family: var(--font-body);
  font-size: 0.86rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link__arrow {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  opacity: 0.7;
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease), background 0.45s var(--ease);
}

.link:hover,
.link:focus-visible {
  transform: translateY(-3px) scale(1.01);
  border-color: rgba(165, 180, 252, 0.45);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14) 0%, rgba(99, 102, 241, 0.12) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 0 0 1px rgba(99, 102, 241, 0.25),
    0 20px 40px -14px rgba(99, 102, 241, 0.55);
}

.link:hover::before,
.link:focus-visible::before {
  opacity: 1;
}

.link:hover::after,
.link:focus-visible::after {
  transform: skewX(-20deg) translateX(420%);
}

.link:hover .link__icon,
.link:focus-visible .link__icon {
  transform: rotate(-6deg) scale(1.06);
}

.link:hover .link__arrow,
.link:focus-visible .link__arrow {
  opacity: 1;
  background: var(--white);
  color: var(--violet-dark);
  transform: rotate(45deg);
}

.link:active {
  transform: translateY(0) scale(0.99);
}

/* ---------- Icone social ---------- */
.socials {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 36px 0 0;
  padding: 0;
  animation: rise 0.8s 0.58s var(--ease) both;
}

.socials a {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: var(--grey-soft);
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: color 0.35s var(--ease), background 0.35s var(--ease), border-color 0.35s var(--ease), transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.socials svg {
  width: 20px;
  height: 20px;
}

.socials a:hover,
.socials a:focus-visible {
  color: var(--white);
  background: rgba(99, 102, 241, 0.45);
  border-color: rgba(165, 180, 252, 0.5);
  transform: translateY(-3px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 10px 24px -8px rgba(99, 102, 241, 0.8);
}

/* ---------- Footer ---------- */
.footer {
  margin-top: auto;
  padding-top: 44px;
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(249, 250, 251, 0.38);
  text-align: center;
}

.footer p {
  margin: 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 12px 20px;
  color: var(--white);
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(30, 30, 40, 0.6);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Accessibilità ---------- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--violet-light);
  outline-offset: 3px;
}

/* Fallback per browser senza backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .link,
  .socials a,
  .share-btn,
  .toast {
    background: rgba(40, 40, 52, 0.92);
  }
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (min-width: 640px) {
  .page {
    padding-top: 88px;
  }

  .avatar {
    width: 152px;
    height: 152px;
  }

  .name {
    font-size: 2rem;
  }
}
