/* ============================================
STYLES.CSS - Luciano Longo Portfolio
Versione: 4.2 | WCAG 2.2 AA
============================================ */

/* 1. VARIABILI GLOBALI */
:root {
  --gold: #947a4b;
  --gold-light: #bfa577;
  --gold-dark: #7a633d;
  --brand-900: #0f172a;
  --brand-800: #1e293b;
  --brand-50: #f8fafc;
  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --header-gradient: linear-gradient(90deg, #ffffff 0%, #faf9f7 35%, #f3f0ea 65%, #ffffff 100%);
  --scroll-y: 0px; /* Inizializza variabile usata da JS per il modal lock */
}

/* 2. RESET & BASE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
  overflow-x: hidden;
}
body {
  margin: 0; padding: 0;
  overflow-x: hidden;
  width: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--brand-50);
  color: var(--brand-900);
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}

/* 3. HEADER / NAVBAR */
#navbar, header {
  background: var(--header-gradient) !important;
  border-bottom: 1px solid rgba(148, 122, 75, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
  transition: all 0.3s ease;
}
#mobile-menu {
  background: #ffffff;
  border-top: 1px solid rgba(148, 122, 75, 0.15);
}

/* 4. LAYOUT & CONTAINER */
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}
section, footer, header, main {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}
img, video, iframe, svg { max-width: 100%; height: auto; display: block; }
.grid, .flex { min-width: 0; }

/* 5. SCROLL & SPAZIATURE SEZIONI */
section[id], footer[id] { scroll-margin-top: 100px; }
@media (max-width: 768px) {
  html { scroll-padding-top: 80px; }
  section[id], footer[id] { scroll-margin-top: 80px; }
}

#presentation { min-height: 100vh; padding-top: 6rem; padding-bottom: 4rem; }
#chi-sono { padding-top: 5rem; padding-bottom: 6rem; }
#competenze { padding-top: 4rem; padding-bottom: 4rem; }
#ricerca { padding-top: 5rem; padding-bottom: 5rem; }
#pubblicazioni { padding-top: 6rem; padding-bottom: 6rem; }
#attivita { padding-top: 5rem; padding-bottom: 5rem; }
#outreach { padding-top: 6rem; padding-bottom: 6rem; }
#contatti { padding-top: 5rem; padding-bottom: 2.5rem; }

/* 6. ANIMAZIONI & REVEAL */
.section-animate {
  opacity: 0; 
  transform: translateY(30px);
  transition: opacity 0.6s var(--transition-smooth), transform 0.6s var(--transition-smooth);
  will-change: transform, opacity;
}
.section-animate.visible { 
  opacity: 1; 
  transform: translateY(0); 
  will-change: auto; 
}
.section-animate.delay-100 { transition-delay: 0.1s; }
.section-animate.delay-200 { transition-delay: 0.2s; }
.section-animate.delay-300 { transition-delay: 0.3s; }

.section-hidden { display: none !important; }
.section-reveal { animation: sectionFadeIn 0.6s ease-out forwards; }
@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   7.5 CARD DINAMICHE - Coppie Differenziate
   ============================================ */
.card-dinamica-float {
  animation: card-float 6s var(--transition-smooth) infinite;
  will-change: transform, box-shadow;
}
@keyframes card-float {
  0%, 100% { transform: translateY(0); box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05); }
  50% { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(148, 122, 75, 0.12); }
}

.card-dinamica-glow {
  animation: card-glow 5s var(--transition-smooth) infinite;
  will-change: border-color, box-shadow;
}
@keyframes card-glow {
  0%, 100% { border-color: rgba(148, 122, 75, 0.2); box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04); }
  50% { border-color: rgba(148, 122, 75, 0.5); box-shadow: 0 6px 18px rgba(148, 122, 75, 0.1); }
}

.card-dinamica-float:hover,
.card-dinamica-glow:hover {
  animation-play-state: paused;
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(148, 122, 75, 0.15);
  border-color: var(--gold);
}

/* 7. COMPONENTI & NAV LINKS */
@keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
.animate-marquee { display: flex; width: max-content; animation: marquee 40s linear infinite; }
.animate-marquee:hover { animation-play-state: paused; }

.logo-link { position: relative; display: inline-flex; align-items: center; text-decoration: none; }
.logo-dot { opacity: 0; transition: opacity 0.3s ease; }
.logo-link:hover .logo-dot { opacity: 1; }
.logo-underline { position: absolute; bottom: -2px; left: 0; width: 0; height: 1px; background: var(--gold); transition: width 0.4s ease; }
.logo-link:hover .logo-underline { width: 100%; }

.lux-link { position: relative; text-decoration: none; color: inherit; transition: color 0.3s ease; }
.lux-link::after { content: ''; position: absolute; width: 0; height: 1px; bottom: -2px; left: 0; background-color: var(--gold); transition: width 0.3s ease-in-out; }
.lux-link:hover::after { width: 100%; }
.lux-link:hover { color: var(--gold); }
.nav-link.active { color: var(--gold) !important; }

/* CONTATTO NAVBAR */
.nav-contact-outline {
  position: relative;
  color: var(--gold) !important;
  z-index: 1;
}
.nav-contact-outline::after { display: none; }
.nav-contact-outline::before {
  content: '';
  position: absolute;
  top: -4px; left: -5px; right: -5px; bottom: -4px;
  border: 1px solid rgba(148, 122, 75, 0.35);
  border-radius: 3px;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: -1;
}
.nav-contact-outline:hover::before {
  border-color: var(--gold);
  background: rgba(148, 122, 75, 0.06);
}

#ricerca article { transition: all 0.4s var(--transition-smooth); border-left: 1px solid rgba(255, 255, 255, 0.1); }
#ricerca article:hover { border-left: 1px solid var(--gold); background: rgba(255, 255, 255, 0.03); transform: translateY(-5px); }

.pub-card { transition: all 0.3s ease; }
.pub-card:hover { transform: translateY(-3px); box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); }

#outreach { position: relative; overflow: hidden; }
#outreach::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at 30% 50%, rgba(148, 122, 75, 0.1) 0%, transparent 50%);
  pointer-events: none;
}
.glass-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}
.glass-card:hover { border-color: var(--gold); background: rgba(255, 255, 255, 0.08); }

.timeline-item { position: relative; }
.timeline-dot {
  position: absolute; left: -9px; top: 1rem; width: 14px; height: 14px;
  background: var(--gold); border: 4px solid white; border-radius: 50%;
  transition: transform 0.3s ease; z-index: 1;
}
.timeline-item:hover .timeline-dot { transform: scale(1.2); }

.bg-brand-900 { animation: fadeInBg 1.5s ease-out; }
@keyframes fadeInBg {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 8. UTILITÀ & ACCESSIBILITÀ (WCAG 2.2 AA) */
details summary::-webkit-details-marker { display: none; }
details summary { list-style: none; cursor: pointer; }
::selection { background: var(--gold); color: white; }

/* Focus visibile globale per accessibilità tastiera */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Fallback per Tailwind group-hover */
.group:hover .scale-110, .group:hover [class*="scale-110"] { transform: scale(1.1); }
a, button, .card, article { transition: all 0.3s ease; }

.skip-link {
  position: absolute; top: -100%; left: 0; background: var(--brand-900); color: white;
  padding: 10px 20px; z-index: 100; transition: top 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; text-decoration: none;
}
.skip-link:focus { top: 0; outline: 2px solid var(--gold); outline-offset: 2px; }

svg text[class*="fill-brand-900"] {
  fill: #0f172a !important; font-family: 'Cormorant Garamond', serif !important;
  font-style: italic !important; opacity: 1 !important; letter-spacing: -0.02em !important;
}

/* 9. SCROLLBAR PERSONALIZZATA */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-light); }

/* 10. BACK TO TOP */
.back-to-top {
  position: fixed; bottom: 30px; left: 30px; right: auto;
  width: 50px; height: 50px; background: var(--brand-900);
  color: white; border: none; border-radius: 50%; cursor: pointer;
  z-index: 999; display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; box-shadow: 0 4px 15px rgba(15, 23, 42, 0.4);
  transition: all 0.3s ease; opacity: 0; visibility: hidden; transform: translateY(20px);
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--gold-dark); box-shadow: 0 6px 20px rgba(148, 122, 75, 0.6); transform: translateY(-3px); }
.back-to-top.pulse { animation: pulseButton 1s infinite; }
@keyframes pulseButton {
  0% { box-shadow: 0 0 0 0 rgba(148, 122, 75, 0.7); }
  70% { box-shadow: 0 0 0 15px rgba(148, 122, 75, 0); }
  100% { box-shadow: 0 0 0 0 rgba(148, 122, 75, 0); }
}
@media (max-width: 768px) {
  .back-to-top { bottom: 20px; left: 20px; width: 45px; height: 45px; font-size: 1rem; }
}

/* 11. CURSOR GLOW */
.cursor-glow {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 2;
  background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 50%), rgba(148, 122, 75, 0.06) 0%, transparent 70%);
  opacity: 0; transition: opacity 0.5s ease;
}
body:hover .cursor-glow { opacity: 1; }

/* 12. MODALI (Sincronizzati con JS v2.3) */
.modal .modal-scroll-container {
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  max-height: 85vh;
  padding-right: 4px;
}
.modal .modal-scroll-container::-webkit-scrollbar { width: 6px; }
.modal .modal-scroll-container::-webkit-scrollbar-track { background: transparent; }
.modal .modal-scroll-container::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }
.modal .modal-scroll-container::-webkit-scrollbar-thumb:hover { background: var(--gold-light); }
.modal .modal-scroll-container { scrollbar-width: thin; scrollbar-color: var(--gold) transparent; }

.modal .modal-content-wrapper { scrollbar-gutter: stable both-edges; }

/* Blocco scroll body coerente con JS: body.classList.add('modal-open') */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  top: var(--scroll-y, 0);
}

.modal[role="dialog"] {
  transition: opacity 0.3s var(--transition-smooth), visibility 0.3s var(--transition-smooth);
}
.modal[role="dialog"].hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}
.modal[role="dialog"]:not(.hidden) {
  opacity: 1; visibility: visible; pointer-events: auto;
}

/* 13. MEDIA QUERIES */
@media (max-width: 1024px) {
  .glass-card { backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
}
@media (max-width: 768px) {
  #presentation { padding-top: 5rem; padding-bottom: 3rem; min-height: 85vh; }
  #chi-sono, #ricerca, #attivita, #outreach { padding-top: 4rem; padding-bottom: 4rem; }
  #pubblicazioni { padding-top: 5rem; padding-bottom: 5rem; }
  #contatti { padding-top: 4rem; padding-bottom: 2rem; }
  
  .modal .modal-scroll-container { max-height: 80vh; padding: 1rem; }
  .modal .modal-content-wrapper { margin: 1rem; max-width: calc(100vw - 2rem); }
}

/* Riduzione movimento (Accessibilità) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .section-animate { opacity: 1 !important; transform: none !important; will-change: auto !important; }
  .cursor-glow { display: none !important; }
  .modal .modal-scroll-container { scroll-behavior: auto !important; }
}

/* Stampa */
@media print {
  .no-print, header, footer, nav, #mobile-menu { display: none !important; }
  body { background: white; color: black; font-size: 12pt; }
  a { text-decoration: underline; color: black; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
  section { page-break-inside: avoid; }
}

/* HERO SECTION BACKGROUND */
#presentation {
  background: 
    linear-gradient(to right, 
      rgba(255, 255, 255, 0.99) 0%,
      rgba(255, 255, 255, 0.93) 50%,
      rgba(248, 250, 252, 0.70) 100%
    );
  background-color: #ffffff;
}
