/* ==========================================================================
   HEADER "LIQUID GLASS"
   - Telefono/tablet (< 1140px): barra a tutta larghezza, attaccata in alto, in vetro
   - Computer (>= 1140px): pillola fluttuante in vetro con riflesso che segue il mouse
   Solo CSS + vetro.js (riflesso, solo dispositivi con mouse).
   ========================================================================== */

/* ---------- Base: vetro a tutta larghezza (telefono e tablet) ---------- */
.header {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.01) 100%),
    rgba(18, 19, 22, 0.55);
  backdrop-filter: blur(18px) saturate(180%) brightness(1.06);
  -webkit-backdrop-filter: blur(18px) saturate(180%) brightness(1.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    0 8px 24px -14px rgba(0, 0, 0, 0.6);
}

/* voci del menu: piccole "gocce" di vetro */
.nav-link {
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 1px 3px rgba(0, 0, 0, 0.3);
}

/* tema chiaro */
[data-theme="light"] .header {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.45) 100%),
    rgba(248, 249, 250, 0.4);
  border-bottom-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 8px 24px -16px rgba(15, 23, 42, 0.3);
}
[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active {
  background: rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 1), 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* menu mobile aperto: anche il pannello è in vetro */
@media (max-width: 1139px) {
  .nav {
    background: rgba(18, 19, 22, 0.72);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  [data-theme="light"] .nav {
    background: rgba(248, 249, 250, 0.82);
  }
}

/* ---------- Computer: pillola fluttuante ---------- */
@media (min-width: 1140px) {
  .header {
    top: 12px;
    margin: 12px auto 0;
    width: min(1180px, calc(100% - 32px));
    height: 64px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-bottom-color: rgba(255, 255, 255, 0.04);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.015) 100%),
      rgba(18, 19, 22, 0.42);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      inset 0 -1px 0 rgba(0, 0, 0, 0.25),
      0 10px 30px -10px rgba(0, 0, 0, 0.55),
      0 2px 6px rgba(0, 0, 0, 0.25);
    isolation: isolate;
  }

  .header-inner {
    padding: 0 10px 0 22px;
  }

  /* riflesso che segue il mouse (posizione impostata da vetro.js) */
  .header::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
    opacity: 0;
    background: radial-gradient(
      260px circle at var(--glass-x, 50%) var(--glass-y, 0%),
      rgba(255, 255, 255, 0.22),
      rgba(124, 135, 230, 0.12) 35%,
      transparent 70%
    );
    transition: opacity 0.35s ease;
  }
  .header.is-lit::before {
    opacity: 1;
  }

  /* bordo luminoso sottile, più forte in alto a sinistra */
  .header::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.04) 40%, rgba(94, 106, 210, 0.3));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
  }

  [data-theme="light"] .header {
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.95),
      0 10px 30px -12px rgba(15, 23, 42, 0.25);
  }
  [data-theme="light"] .header::before {
    background: radial-gradient(
      260px circle at var(--glass-x, 50%) var(--glass-y, 0%),
      rgba(255, 255, 255, 0.85),
      rgba(94, 106, 210, 0.10) 35%,
      transparent 70%
    );
  }
}

/* ---------- Accessibilità ---------- */
@media (prefers-reduced-motion: reduce) {
  .header::before { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .header,
  .nav {
    background: var(--bg-secondary);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ==========================================================================
   CARD DI VETRO (stesso linguaggio della barra, in tutte le sezioni)
   - sfondo sfumato fermo dietro la pagina, così il vetro ha qualcosa da sfocare
   - card semitrasparenti con sfocatura, filo di luce in alto e bordo luminoso
   - riflesso che segue il mouse (posizione impostata da vetro.js, solo con mouse)
   Telefono/tablet e "riduci trasparenza": niente sfocatura (più leggero e leggibile).
   ========================================================================== */
:root {
  --glass-fill: rgba(22, 24, 29, 0.5);
  --glass-fill-hover: rgba(30, 33, 40, 0.58);
  --glass-edge: rgba(255, 255, 255, 0.09);
}

[data-theme="light"] {
  --glass-fill: rgba(255, 255, 255, 0.55);
  --glass-fill-hover: rgba(255, 255, 255, 0.72);
  --glass-edge: rgba(255, 255, 255, 0.75);
}

/* sfondo ambiente: tre bagliori sfumati, fermi (non si animano e non pesano) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60vmax 46vmax at 12% 6%, rgba(94, 106, 210, 0.22), transparent 62%),
    radial-gradient(52vmax 40vmax at 94% 34%, rgba(124, 135, 230, 0.13), transparent 62%),
    radial-gradient(46vmax 38vmax at 28% 98%, rgba(228, 242, 34, 0.06), transparent 62%);
}

[data-theme="light"] body::before {
  background:
    radial-gradient(60vmax 46vmax at 12% 6%, rgba(94, 106, 210, 0.20), transparent 62%),
    radial-gradient(52vmax 40vmax at 94% 34%, rgba(124, 135, 230, 0.14), transparent 62%),
    radial-gradient(46vmax 38vmax at 28% 98%, rgba(120, 200, 140, 0.12), transparent 62%);
}

/* la pelle di vetro */
:is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card) {
  position: relative;
  isolation: isolate;
  background-color: var(--glass-fill);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.012) 100%);
  border-color: var(--glass-edge);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22),
    0 16px 34px -20px rgba(0, 0, 0, 0.7);
}

:is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card):hover {
  background-color: var(--glass-fill-hover);
}

/* scheda progetto in evidenza: bagliore indaco più marcato */
.project-card--featured {
  background-image:
    radial-gradient(70% 90% at 0% 0%, rgba(94, 106, 210, 0.2), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.012) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22),
    0 24px 50px -24px rgba(94, 106, 210, 0.45);
}

/* riflesso che segue il mouse */
:is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card)::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(
    240px circle at var(--glass-x, 50%) var(--glass-y, 0%),
    rgba(255, 255, 255, 0.14),
    rgba(124, 135, 230, 0.08) 40%,
    transparent 70%
  );
}

:is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card).is-lit::before {
  opacity: 1;
}

/* bordo luminoso sottile, più forte in alto a sinistra */
:is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.03) 40%, rgba(94, 106, 210, 0.22));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

[data-theme="light"] :is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card) {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.3) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 14px 30px -18px rgba(15, 23, 42, 0.28);
}

[data-theme="light"] :is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card)::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.2) 40%, rgba(94, 106, 210, 0.25));
}

/* superfici a comparsa: menu delle lingue e finestra "Richiedi il CV" */
.lang-menu {
  background: rgba(18, 19, 22, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
  border-color: rgba(255, 255, 255, 0.1);
}

.cv-dialog {
  background: rgba(22, 24, 29, 0.78);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  border-color: rgba(255, 255, 255, 0.1);
}

.cv-dialog::backdrop {
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

[data-theme="light"] .lang-menu,
[data-theme="light"] .cv-dialog {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(255, 255, 255, 0.8);
}

/* telefono e tablet o dispositivi touch: vetro leggero, senza sfocatura né riflesso */
@media (max-width: 767px), (hover: none) {
  :is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card) {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background-color: rgba(22, 24, 29, 0.78);
  }

  :is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card)::before {
    display: none;
  }

  [data-theme="light"] :is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card) {
    background-color: rgba(255, 255, 255, 0.85);
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card)::before {
    transition: none;
  }
}

/* browser senza backdrop-filter o utente che chiede meno trasparenza: sfondo quasi pieno */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass-fill: rgba(22, 24, 29, 0.9); --glass-fill-hover: rgba(30, 33, 40, 0.94); }
}

@media (prefers-reduced-transparency: reduce) {
  :is(.feature-card, .timeline-card, .project-card, .skill-card, .edu-card, .cert-card, .cert-badge-card, .contact-card),
  .lang-menu,
  .cv-dialog {
    background-color: var(--bg-card);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body::before { display: none; }
}

/* ==========================================================================
   PILLOLE, TAG E PULSANTI DI VETRO
   - pillole dell'intestazione e pulsante secondario: vetro con sfocatura (pochi elementi)
   - tag piccoli (competenze, tecnologie, periodi): solo trasparenza e filo di luce, senza sfocatura
   - il pulsante principale resta pieno (è la chiamata all'azione), con un filo di luce
   ========================================================================== */
.tag-badge,
.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.015) 100%);
  border-color: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  backdrop-filter: blur(10px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 6px 16px -10px rgba(0, 0, 0, 0.65);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
}

.btn-primary {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 10px 26px -12px rgba(255, 255, 255, 0.45);
}

:is(.skill-pill, .timeline-tag, .project-stack li) {
  background-color: rgba(255, 255, 255, 0.045);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.01) 100%);
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="light"] :is(.tag-badge, .btn-secondary) {
  background-color: rgba(255, 255, 255, 0.6);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.35) 100%);
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 1), 0 6px 16px -10px rgba(15, 23, 42, 0.25);
}

[data-theme="light"] :is(.skill-pill, .timeline-tag, .project-stack li) {
  background-color: rgba(255, 255, 255, 0.6);
  background-image: none;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 1);
}

[data-theme="light"] .btn-primary {
  box-shadow: 0 10px 26px -12px rgba(15, 23, 42, 0.45);
}

@media (max-width: 767px), (hover: none) {
  .tag-badge,
  .btn-secondary {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .tag-badge,
  .btn-secondary {
    background-color: var(--bg-pill);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ==========================================================================
   SCHEDA EMAIL: "Clicca per copiare"
   ========================================================================== */
.contact-hint {
  margin-top: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

#contact-email {
  cursor: copy;
}

#contact-email.is-copied {
  border-color: var(--color-lime-text);
}

#contact-email.is-copied .contact-hint {
  color: var(--color-lime-text);
}

#contact-email.is-copied .contact-hint::before {
  content: "\2713\00a0";
}
