@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;800&display=swap");

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root{
  /* ===== Theme tokens (DARK default) ===== */
  --bg0:#05060a;
  --bg1:#0b0f18;

  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.62);

  --glass: rgba(255,255,255,.06);
  --stroke: rgba(255,255,255,.14);

  --panel: #131315;
  --panelStroke: rgba(255,255,255,.08);

  /* Social colors (HSL) */
  --ig: 330 85% 60%;
  --wa: 142 70% 45%;
  --yt: 0 85% 55%;
  --tt: 190 90% 55%;
  --fb: 214 89% 55%;
  --dc: 0 0% 100%;
}

html, body { height: 100%; }

body{
  font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;

  background:
    radial-gradient(1000px 600px at 15% 10%, rgba(120,180,255,.10), transparent 60%),
    radial-gradient(900px 700px at 90% 20%, rgba(255,120,220,.10), transparent 55%),
    radial-gradient(1200px 800px at 50% 100%, rgba(60,255,170,.08), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

a{ color: inherit; text-decoration: none; }

/* iOS / tap highlight + gesture */
a, button, .confetti-button, .theme-toggle{
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* Focus accessibile */
.pill:focus-visible,
.confetti-button:focus-visible,
.switch input:focus-visible + .slider{
  outline: 2px solid rgba(255,255,255,.35);
  outline-offset: 3px;
}

/* =========================
   HEADER
   ========================= */
.top{
  max-width: 1100px;
  margin: 18px auto 0;
  padding: 0 18px;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  flex-wrap: wrap;
}

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  flex: 1 1 420px;
}

.brand__logo{
  width: 54px;
  height: 54px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.brand__txt h1{
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
}

.brand__txt p{
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.top-actions{
  display:flex;
  align-items:center;
  gap: 12px;
  flex-wrap: wrap;
}

.pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding: 10px 14px;
  border-radius: 999px;

  background: var(--glass);
  border: 1px solid var(--stroke);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

@media (hover:hover){
  .pill:hover{
    transform: translateY(-1px);
    background: rgba(255,255,255,.09);
    border-color: rgba(255,255,255,.22);
  }
}

/* =========================
   GHOST TOGGLE (tema)
   ========================= */
.theme-toggle{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius: 999px;

  background: var(--glass);
  border: 1px solid var(--stroke);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.theme-ico{
  width: 18px;
  height: 18px;
  display:grid;
  place-items:center;
  opacity: .85;
  font-size: 14px;
}

.switch{
  position: relative;
  display: inline-block;
  width: 96px;
  height: 26px;
}

.switch input{
  opacity: 0;
  width: 0;
  height: 0;
}

.slider{
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.18);
  transition: .4s;
  border-radius: 999px;
}

.switch input:checked + .slider{
  background-color: #459def;
  border-color: rgba(69,157,239,.65);
}

.slider .knob{
  position:absolute;
  top: 50%;
  left: 6px;
  transform: translate(0, -50%);
  transition: transform .4s;
  width: 40px;
  height: 40px;
}

.switch input:checked + .slider .knob{
  transform: translate(58px, -50%);
}

.ghost{
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  background-color: white;
  border-radius: 100px;
  animation: bobble 4.3s infinite;
  filter: drop-shadow(0px 5px 12px rgba(255, 255, 255, 0.55));
}

@keyframes bobble{
  0%{ transform: translateY(0); }
  50%{ transform: translateY(15%); }
  100%{ transform: translateY(0); }
}
@keyframes sway{
  0%{ transform: translateX(-2px); }
  50%{ transform: translateX(2px); }
  100%{ transform: translateX(-2px); }
}
@keyframes sway-more{
  0%{ transform: translateX(-4px); }
  50%{ transform: translateX(4px); }
  100%{ transform: translateX(-4px); }
}
@keyframes blink{
  0%{ top: 16px; height: 8px; }
  39%{ top: 16px; height: 8px; }
  40%{ top: 20px; height: 2px; }
  50%{ top: 20px; height: 2px; }
  51%{ top: 16px; height: 8px; }
  100%{ top: 16px; height: 8px; }
}

.ghost:after{
  content:"";
  position:absolute;
  left: calc(50% - 7px);
  top: 16px;
  width: 10px;
  height: 8px;
  border-right: 3px solid black;
  border-left: 3px solid black;
  animation: bobble 2s infinite, sway-more 2s infinite 1s, blink 4.25s infinite;
}

.ghost:before{
  content:"";
  position:absolute;
  top: calc(50% - 6px);
  left: -10%;
  width: 120%;
  height: 12px;
  border-radius: 100px;
  background-color: white;
  animation: sway 2s infinite;
}

/* =========================
   MAIN
   ========================= */
.wrap{
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}

.intro{
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;

  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
}

.intro h2{ font-size: 16px; font-weight: 800; }
.intro p{
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255,255,255,.70);
}

/* =========================
   CARDS GRID
   ========================= */
#cards{
  width: 100%;
  margin-top: 16px;
  padding-inline: 2px;

  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px){
  #cards{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #cards > .card{ grid-column: span 2; }

  #cards > .card:last-child:nth-child(odd){
    grid-column: 2 / span 2;
  }
}

@media (min-width: 900px){
  #cards{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #cards > .card{ grid-column: span 2; }

  #cards > .card:last-child:nth-child(3n+1){
    grid-column: 3 / span 2;
  }

  #cards > .card:nth-last-child(2):nth-child(3n+1){
    grid-column: 2 / span 2;
  }
  #cards > .card:last-child:nth-child(3n+2){
    grid-column: 4 / span 2;
  }
}

.card{
  width: 100%;
  min-width: 0;
  height: 320px;

  background-color: rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  position: relative;
  overflow: visible;
}

/* colori per card */
.card--ig{ --color: var(--ig); }
.card--wa{ --color: var(--wa); }
.card--yt{ --color: var(--yt); }
.card--tt{ --color: var(--tt); }
.card--fb{ --color: var(--fb); }
.card--dc{ --color: var(--dc); }

@media (hover:hover){
  #cards:hover > .card{
    background: radial-gradient(
      420px circle at var(--mouse-x) var(--mouse-y),
      hsl(var(--color) / 1),
      rgba(255, 255, 255, 0.12) 42%
    );
  }
}

.card::before{
  content:"";
  position:absolute;
  inset:0;
  background: radial-gradient(
    520px circle at var(--mouse-x) var(--mouse-y),
    hsl(var(--color) / 0.35),
    transparent 40%
  );
  border-radius: inherit;
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}

@media (hover:hover){
  #cards:hover > .card::before{ opacity: 1; }
}

.card_content{
  position:absolute;
  inset: 1px;

  background-color: var(--panel);
  border: 1px solid var(--panelStroke);
  border-radius: inherit;

  display:flex;
  justify-content:center;
  align-items:center;
  flex-direction: column;
  gap: 14px;
  padding: 18px;

  text-align:center;
  z-index: 2;
  overflow: visible;
}

.card_content > i{
  font-size: 4.2rem;
  color: hsl(var(--color) / .95);
  filter: drop-shadow(0 16px 34px hsl(var(--color)/.18));
}

.card_content > h3{
  font-size: 18px;
  font-weight: 800;
}

.card_content > p{
  font-size: 13px;
  color: rgba(255,255,255,.55);
  line-height: 1.35;
  max-width: 28ch;
}

/* card whatsapp con due pulsanti */
.card--wa .card_content{
  gap: 12px;
}

.card--wa .card_content .confetti-button + .confetti-button{
  margin-top: -2px;
}

/* ==========================
   CONFETTI BUTTON
   ========================== */
.confetti-button{
  width: min(320px, 90%);
  padding: 12px 14px;

  background-color: rgba(255,255,255,.05);

  border: 1px solid hsl(var(--color) / .65);
  box-shadow: 0 0 0 1px hsl(var(--color) / .12);

  border-radius: 12px;

  display:flex;
  justify-content:center;
  align-items:center;
  gap: 8px;

  cursor:pointer;
  position: relative;

  overflow: visible;
  isolation: isolate;

  transition: background .2s ease, border-color .2s ease, transform .2s ease, box-shadow .2s ease;
  z-index: 10;
}

.confetti-button > *{
  position: relative;
  z-index: 2;
}

@media (hover:hover){
  .confetti-button:hover{
    background-color: rgba(255,255,255,.10);
    border-color: hsl(var(--color) / .95);
    box-shadow:
      0 0 0 1px hsl(var(--color) / .22),
      0 14px 40px hsl(var(--color) / .18);
    transform: translateY(-1px);
  }
}

/* Discord: stesso sistema, un filo più visibile */
.card--dc .confetti-button{
  border-width: 2px;
}

@media (hover:hover){
  .card--dc .confetti-button:hover{
    box-shadow:
      0 0 0 1px hsl(var(--color) / .28),
      0 14px 40px hsl(var(--color) / .24),
      0 0 24px hsl(var(--color) / .18);
  }
}

/* bolle sopra/sotto */
.confetti-button:before,
.confetti-button:after{
  position:absolute;
  content:"";
  display:none;
  width: 140%;
  height: 100%;
  left: -20%;
  z-index: 1;
  transition: all ease-in-out .5s;
  background-repeat: no-repeat;
  pointer-events: none;
}

.confetti-button:before{
  top: -75%;
  background-image:
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, transparent 20%, hsl(var(--color) / .95) 20%, transparent 30%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, transparent 10%, hsl(var(--color) / .95) 15%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%);
  background-size: 10% 10%, 20% 20%, 15% 15%, 20% 20%, 18% 18%, 10% 10%, 15% 15%, 10% 10%, 18% 18%;
}

.confetti-button:after{
  bottom: -75%;
  background-image:
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, transparent 10%, hsl(var(--color) / .95) 15%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%),
    radial-gradient(circle, hsl(var(--color) / .95) 20%, transparent 20%);
  background-size: 15% 15%, 20% 20%, 18% 18%, 20% 20%, 15% 15%, 10% 10%, 20% 20%;
}

.confetti-button.animate:before{
  display:block;
  animation: topBubbles ease-in-out 0.75s forwards;
}
.confetti-button.animate:after{
  display:block;
  animation: bottomBubbles ease-in-out 0.75s forwards;
}

@keyframes topBubbles{
  0%{
    background-position: 5% 90%, 10% 90%, 10% 90%, 15% 90%, 25% 90%, 25% 90%, 40% 90%, 55% 90%, 70% 90%;
  }
  50%{
    background-position: 0% 80%, 0% 20%, 10% 40%, 20% 0%, 30% 30%, 22% 50%, 50% 50%, 65% 20%, 90% 30%;
  }
  100%{
    background-position: 0% 70%, 0% 10%, 10% 30%, 20% -10%, 30% 20%, 22% 40%, 50% 40%, 65% 10%, 90% 20%;
    background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%;
  }
}

@keyframes bottomBubbles{
  0%{
    background-position: 10% -10%, 30% 10%, 55% -10%, 70% -10%, 85% -10%, 70% -10%, 70% 0%;
  }
  50%{
    background-position: 0% 80%, 20% 80%, 45% 60%, 60% 100%, 75% 70%, 95% 60%, 105% 0%;
  }
  100%{
    background-position: 0% 90%, 20% 90%, 45% 70%, 60% 110%, 75% 80%, 95% 70%, 110% 10%;
    background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%;
  }
}

.footer{
  margin: 18px 0 8px;
  text-align:center;
  color: rgba(255,255,255,.55);
  font-size: 12px;
}

/* =========================
   RESPONSIVE TWEAKS
   ========================= */
@media (max-width: 520px){
  .top{ justify-content: center; }
  .brand{ justify-content:center; text-align:center; }
  .top-actions{ width: 100%; justify-content:center; }
  .pill{ width: 100%; justify-content:center; }
  .theme-toggle{ width: 100%; justify-content:center; }

  .card{ height: 300px; }
  .card_content > i{ font-size: 3.6rem; }

  .card--wa{
    height: 360px;
  }
}

/* =========================
   LIGHT MODE
   ========================= */
html[data-theme="light"]{
  --bg0:#f6f8ff;
  --bg1:#ffffff;

  --text: rgba(10,12,16,.92);
  --muted: rgba(10,12,16,.55);

  --glass: rgba(0,0,0,.04);
  --stroke: rgba(0,0,0,.10);

  --panel: rgba(255,255,255,.86);
  --panelStroke: rgba(0,0,0,.08);

  --dc: 0 0% 0%;
}

html[data-theme="light"] body{
  background:
    radial-gradient(1000px 600px at 15% 10%, rgba(120,180,255,.22), transparent 60%),
    radial-gradient(900px 700px at 90% 20%, rgba(255,120,220,.18), transparent 55%),
    radial-gradient(1200px 800px at 50% 100%, rgba(60,255,170,.14), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

html[data-theme="light"] .brand__logo{
  border-color: rgba(0,0,0,.12);
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
}

html[data-theme="light"] .intro{
  background: rgba(0,0,0,.03);
  border-color: rgba(0,0,0,.08);
}
html[data-theme="light"] .intro p{ color: rgba(10,12,16,.62); }

html[data-theme="light"] .card{
  background-color: rgba(0,0,0,.06);
}

@media (hover:hover){
  html[data-theme="light"] #cards:hover > .card{
    background: radial-gradient(
      460px circle at var(--mouse-x) var(--mouse-y),
      hsl(var(--color) / .55),
      rgba(0,0,0,.06) 50%
    );
  }
  html[data-theme="light"] .card::before{
    background: radial-gradient(
      540px circle at var(--mouse-x) var(--mouse-y),
      hsl(var(--color) / 0.22),
      transparent 42%
    );
  }
}

html[data-theme="light"] .card_content > p{
  color: rgba(10,12,16,.62);
}

html[data-theme="light"] .confetti-button{
  background-color: rgba(0,0,0,.03);
}
@media (hover:hover){
  html[data-theme="light"] .confetti-button:hover{
    background-color: rgba(0,0,0,.06);
  }
}

html[data-theme="light"] .slider{
  background-color: rgba(0,0,0,.08);
  border-color: rgba(0,0,0,.12);
}

html[data-theme="light"] .footer{
  color: rgba(10,12,16,.55);
}

html[data-theme="light"] .pill:focus-visible,
html[data-theme="light"] .confetti-button:focus-visible,
html[data-theme="light"] .switch input:focus-visible + .slider{
  outline-color: rgba(0,0,0,.25);
}

/* Riduci animazioni se richiesto dal sistema */
@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}