/* ================================================
   CSS VARIABLES
================================================ */
:root {
    --rosso:  #FF0000;
    --rosso2: #FF0000;
    --rosso3: #e8173a;
    --oro:    #f0c040;
    --oro2:   #ffe082;
    --testo:  #fdebd0;
    --bianco: #fff8ee;
}

/* ================================================
   RESET & BASE
================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Space Mono', monospace;
    padding-top: 112px;
    color: var(--testo);
    overflow-x: hidden;
    min-height: 100vh;
    background-color: #FF0000;
    background-image:
        radial-gradient(ellipse 110% 80% at 0%   0%,   rgba(220,20,50,0.80)  0%, transparent 52%),
        radial-gradient(ellipse 70%  60% at 100% 0%,   rgba(139,0,0,0.70)    0%, transparent 48%),
        radial-gradient(ellipse 80%  70% at 50%  50%,  rgba(180,10,30,0.40)  0%, transparent 58%),
        radial-gradient(ellipse 55%  45% at 10%  85%,  rgba(240,130,30,0.28) 0%, transparent 52%),
        radial-gradient(ellipse 90%  60% at 88%  92%,  rgba(192,21,42,0.60)  0%, transparent 58%),
        radial-gradient(ellipse 50%  40% at 50%  100%, rgba(240,192,64,0.18) 0%, transparent 48%),
        linear-gradient(155deg, #3a0510 0%, #240008 28%, #1a0005 52%, #2e0c05 78%, #200000 100%);
}

/* ================================================
   SFONDO ANIMATO
================================================ */
body::before {
    content: '';
    position: fixed; inset: 0;
    background-image:
        radial-gradient(ellipse 130% 90% at 25% 35%, rgba(220,30,60,0.32) 0%, transparent 50%),
        radial-gradient(ellipse 80%  70% at 72% 68%, rgba(240,160,40,0.14) 0%, transparent 55%);
    animation: bgBreathe 8s ease-in-out infinite alternate;
    pointer-events: none; z-index: 0;
}
@keyframes bgBreathe {
    from { opacity: 0.5; transform: scale(1); }
    to   { opacity: 1;   transform: scale(1.05); }
}
body::after {
    content: '';
    position: fixed; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.04; pointer-events: none; z-index: 1; mix-blend-mode: overlay;
}

/* ================================================
   CANVAS PIOGGIA DI TESTO
================================================ */
#rain-canvas {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
    opacity: .2; will-change: transform;
}

/* ================================================
   ACCESSIBILITÀ
================================================ */
.skip-link {
    position: absolute; top: -40px; left: 0;
    background: var(--oro); color: #1a0005;
    padding: 8px 16px; z-index: 10000;
    text-decoration: none; font-weight: bold;
    transition: top 0.2s;
}
.skip-link:focus { top: 0; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--oro); outline-offset: 4px; }

/* ================================================
   HEADER
================================================ */
.intestazione {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 100;
    background: linear-gradient(135deg, rgba(8,0,3,0.93) 0%, rgba(40,0,10,0.89) 50%, rgba(18,0,4,0.93) 100%);
    backdrop-filter: blur(18px);
    border-bottom: 2px solid var(--rosso3);
    display: grid; grid-template-columns: 1fr auto 1fr;
    align-items: center; padding: 18px 40px;
    box-shadow: 0 4px 50px rgba(220,20,50,0.30);
}
.intestazione::after {
    content: ''; position: absolute;
    bottom: -26px; left: 50%; transform: translateX(-50%);
    width: 70%; height: 26px;
    background: radial-gradient(ellipse, rgba(220,20,50,0.55) 0%, transparent 70%);
    pointer-events: none;
}
.img-logo {
    height: 72px; width: auto; object-fit: contain; justify-self: start;
    filter: drop-shadow(0 0 14px rgba(240,192,64,0.6));
    transition: filter .3s, transform .3s;
}
.img-logo:hover { filter: drop-shadow(0 0 30px rgba(240,192,64,1)); transform: scale(1.07); }
.header-center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.title {
    font-family: 'Bebas Neue', sans-serif; font-size: 64px;
    color: #fff; letter-spacing: 10px; line-height: 1;
    text-shadow: 0 0 20px rgba(240,192,64,0.55), 0 0 60px rgba(220,20,50,0.45);
    animation: titlePulse 4s ease-in-out infinite; position: relative;
}
@keyframes titlePulse {
    0%, 100% { text-shadow: 0 0 20px rgba(240,192,64,0.55), 0 0 60px rgba(220,20,50,0.45); }
    50%       { text-shadow: 0 0 45px rgba(240,192,64,1), 0 0 110px rgba(220,20,50,0.80); }
}
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
    content: attr(data-text); position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; background: transparent; pointer-events: none;
    font-family: 'Bebas Neue', sans-serif; font-size: 64px; letter-spacing: 10px;
}
.glitch::before { color: var(--rosso3); animation: glitch1 7s infinite; clip-path: polygon(0 0, 100% 0, 100% 40%, 0 40%); }
.glitch::after  { color: #00e5ff; animation: glitch2 7s infinite; clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%); }
@keyframes glitch1 {
    0%, 88%, 100% { transform: none; opacity: 0; }
    90% { transform: translate(-4px, 1px); opacity: .7; }
    93% { transform: translate(4px, -1px); opacity: .7; }
    96% { transform: translate(-2px, 0); opacity: .7; }
}
@keyframes glitch2 {
    0%, 88%, 100% { transform: none; opacity: 0; }
    91% { transform: translate(4px, -2px); opacity: .6; }
    94% { transform: translate(-4px, 2px); opacity: .6; }
    97% { transform: translate(2px, 1px); opacity: .6; }
}
.subtitle { font-family: 'Playfair Display', serif; font-size: 13px; color: var(--oro); font-style: italic; letter-spacing: 2px; opacity: .9; }
.header-right { display: flex; justify-content: flex-end; }
.btn-home {
    position: relative; background: transparent;
    color: var(--oro); border: 1.5px solid var(--oro);
    padding: 10px 26px; font-size: 13px; font-weight: 700;
    font-family: 'Space Mono', monospace; letter-spacing: 3px;
    text-transform: uppercase; overflow: hidden; transition: color .3s;
    cursor: pointer;
}
.btn-home::before {
    content: ''; position: absolute; inset: 0; background: var(--oro);
    transform: translateX(-101%); transition: transform .3s cubic-bezier(.77,0,.18,1); z-index: -1;
}
.btn-home:hover::before { transform: translateX(0); }
.btn-home:hover { color: #1a0005; }

/* ================================================
   MARQUEE
================================================ */
.hero-strip {
    position: relative; z-index: 10;
    background: var(--rosso3); height: 48px;
    display: flex; align-items: center; overflow: hidden;
    box-shadow: 0 4px 24px rgba(232,23,58,0.45);
}
.marquee-track { display: flex; animation: marquee 18s linear infinite; white-space: nowrap; }
.marquee-track span { font-family: 'Bebas Neue', sans-serif; font-size: 20px; letter-spacing: 6px; color: #1a0005; padding: 0 36px; }
.marquee-track span.sep { color: var(--oro); padding: 0 8px; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ================================================
   MAIN CONTENT
================================================ */
.main-content {
    position: relative;
    z-index: 20;
    padding: 60px 40px 80px;
    max-width: 1300px; margin: 0 auto;
}

/* ================================================
   SECTION LABEL & TITLE
================================================ */
.section-label { display: flex; align-items: center; gap: 16px; margin-bottom: 30px; }
.section-label::before { content: ''; display: block; width: 40px; height: 2px; background: var(--oro); }
.section-label span { font-size: 11px; letter-spacing: 4px; color: var(--oro); text-transform: uppercase; }
.section-label::after { content: ''; flex: 1; height: 1px; background: linear-gradient(to right, var(--oro), transparent); }
.section-title {
    font-family: 'Bebas Neue', sans-serif; font-size: 80px;
    line-height: .88; letter-spacing: 4px; color: var(--bianco);
    margin-bottom: 30px; text-shadow: 0 4px 40px rgba(220,20,50,0.35);
}
.section-title em { color: var(--oro); font-style: normal; }

/* ================================================
   LINK BIOGRAFIE
================================================ */
.bio-links-wrapper {
    position: relative;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 18px;
}
.bio-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 10px 0;
    border-bottom: 1px solid rgba(240,192,64,0.1);
    transition: padding-left .2s;
}
.bio-link-item:hover { padding-left: 8px; }
.bio-link-arrow {
    font-family: 'Space Mono', monospace;
    font-size: 14px; font-weight: 700;
    color: var(--oro); transition: color .2s;
}
.bio-link-label {
    font-family: 'Space Mono', monospace;
    font-size: 13px; font-weight: 700;
    letter-spacing: 2px; color: var(--oro); transition: color .2s;
}
.bio-link-name {
    font-family: 'Space Mono', monospace;
    font-size: 13px; font-weight: 400;
    letter-spacing: 1px; color: rgba(253,235,208,.5); transition: color .2s;
}
.bio-link-item:hover .bio-link-arrow,
.bio-link-item:hover .bio-link-label { color: var(--oro); }
.bio-link-item:hover .bio-link-name  { color: rgba(253,235,208,.8); }

/* ================================================
   MAPPA
================================================ */
.map-wrapper {
    position: relative;
    z-index: 20;
    border: 1px solid rgba(240,192,64,0.2);
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(220,20,50,0.3),
                0 30px 80px rgba(0,0,0,0.5),
                0 0 70px rgba(220,20,50,0.12),
                inset 0 1px 0 rgba(240,192,64,0.15);
}
.map-toolbar {
    background: linear-gradient(135deg, rgba(8,0,3,.97), rgba(30,0,10,.95));
    border-bottom: 1px solid rgba(240,192,64,0.2);
    padding: 14px 24px;
    display: flex; align-items: center; justify-content: space-between;
}
.map-toolbar-left { display: flex; align-items: center; gap: 14px; }
.map-toolbar-left i { font-size: 20px; color: var(--oro); filter: drop-shadow(0 0 6px rgba(240,192,64,.5)); }
.map-toolbar-left h2 { font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 4px; color: var(--bianco); }
.map-toolbar-right { display: flex; gap: 8px; }
#map { height: 520px; width: 100%; filter: saturate(.75) brightness(.9); transition: filter .4s; }
#map:hover { filter: saturate(1) brightness(1); }

/* ================================================
   BARRA DI RICERCA MAPPA
================================================ */
.map-search-wrapper {
    background: linear-gradient(135deg, rgba(8,0,3,.97), rgba(30,0,10,.95));
    border-bottom: 1px solid rgba(240,192,64,0.2);
    padding: 10px 24px;
    display: block;
}
#map-search {
    display: block;
    width: 100%;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    letter-spacing: 2px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(240,192,64,0.5);
    color: #fdebd0;
    padding: 8px 16px;
    outline: none;
    border-radius: 2px;
    box-sizing: border-box;
}
#map-search::placeholder {
    color: rgba(253,235,208,0.4);
    letter-spacing: 2px;
}
#map-search:focus {
    border-color: var(--oro);
    background: rgba(255,255,255,0.1);
}

/* ================================================
   DOTS
================================================ */
.dot { width: 13px; height: 13px; border-radius: 50%; display: inline-block; }
.dot-red    { background: #ff5f57; box-shadow: 0 0 6px #ff5f57; }
.dot-blue   { background: #4a90d9; box-shadow: 0 0 6px #4a90d9; }
.dot-green  { background: #28c840; box-shadow: 0 0 6px #28c840; }

/* ================================================
   STATS
================================================ */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin-top: 2px; }
.stat-card {
    background: linear-gradient(135deg, rgba(30,0,8,.88), rgba(55,5,18,.82));
    backdrop-filter: blur(10px); border: 1px solid rgba(240,192,64,0.12);
    padding: 30px; text-align: center; position: relative; overflow: hidden;
    transition: border-color .3s, transform .3s, box-shadow .3s;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(to right, transparent, var(--rosso3), transparent);
    transform: scaleX(0); transition: transform .4s;
}
.stat-card:hover::before { transform: scaleX(1); }
.stat-card:hover { border-color: rgba(240,192,64,.38); transform: translateY(-5px); box-shadow: 0 20px 50px rgba(220,20,50,.22); }
.stat-number { font-family: 'Bebas Neue', sans-serif; font-size: 56px; color: var(--oro); line-height: 1; text-shadow: 0 0 30px rgba(240,192,64,.4); }
.stat-label { font-size: 10px; letter-spacing: 3px; color: rgba(253,235,208,.5); text-transform: uppercase; margin-top: 6px; }

/* ================================================
   FOOTER
================================================ */
footer {
    position: relative; z-index: 20;
    background: linear-gradient(135deg, rgba(4,0,2,.98), rgba(18,0,4,.98));
    border-top: 1px solid rgba(220,20,50,.4); padding: 40px;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    box-shadow: 0 -12px 50px rgba(220,20,50,.12);
}
.footer-left { font-family: 'Playfair Display', serif; font-style: italic; font-size: 13px; color: rgba(253,235,208,.45); line-height: 1.6; }
.footer-center { font-family: 'Bebas Neue', sans-serif; font-size: 28px; letter-spacing: 6px; color: var(--rosso3); text-align: center; text-shadow: 0 0 24px rgba(220,20,50,.55); }
.footer-center1  { text-align: center; font-size: 11px; letter-spacing: 2px; color: rgba(253,235,208,.3); }
.footer-center1 a { color: var(--oro); text-decoration: none; opacity: .7; transition: opacity .2s; }
.footer-center1 a:hover { opacity: 1; }
.footer-right { text-align: right; font-size: 11px; letter-spacing: 2px; color: rgba(253,235,208,.3); }
.footer-right a { color: var(--oro); text-decoration: none; opacity: .7; transition: opacity .2s; }
.footer-right a:hover { opacity: 1; }
.footer-middle { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ================================================
   SCROLL REVEAL
================================================ */
.reveal { opacity: 0; transform: translateY(40px); transition: opacity .8s ease, transform .8s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ================================================
   LEAFLET OVERRIDES
================================================ */
.leaflet-control-attribution { background: rgba(5,0,2,.85) !important; color: #555 !important; font-family: 'Space Mono', monospace !important; font-size: 9px !important; }
.leaflet-control-layers { background: rgba(12,0,4,.96) !important; border: 1px solid rgba(240,192,64,.25) !important; border-radius: 0 !important; color: var(--testo) !important; }
.leaflet-control-layers-toggle { background-color: var(--rosso3) !important; }
.leaflet-bar a { background: rgba(12,0,4,.96) !important; color: var(--oro) !important; border-color: rgba(240,192,64,.25) !important; }
.leaflet-bar a:hover { background: var(--rosso3) !important; }
.popup-anpi .leaflet-popup-content-wrapper { background: transparent !important; border: none !important; box-shadow: 0 10px 40px rgba(0,0,0,0.7) !important; padding: 0 !important; border-radius: 4px !important; overflow: hidden; }
.popup-anpi .leaflet-popup-content { margin: 0 !important; width: auto !important; }
.popup-anpi .leaflet-popup-tip { background: #e8173a !important; }
.popup-anpi .leaflet-popup-close-button { color: var(--oro) !important; font-size: 18px !important; padding: 6px 8px !important; top: 4px !important; right: 4px !important; z-index: 10; }
.popup-anpi .leaflet-popup-close-button:hover { color: #fff !important; }

/* ================================================
   TOOLTIP HOVER MARKER
   Rimuove completamente lo stile default di Leaflet
   e lascia passare solo il nostro HTML inline
================================================ */
.tooltip-anpi.leaflet-tooltip {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    pointer-events: none !important;
    /* Piccola animazione di entrata */
    animation: tooltipFadeIn .15s ease;
}
.tooltip-anpi.leaflet-tooltip::before {
    /* Rimuove la freccia/coda del tooltip di Leaflet */
    display: none !important;
}
@keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ================================================
   MAP TITLE & ICON STAR
================================================ */
#map-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    font-size: 2rem;
    line-height: 1.4;
    margin: 20px auto;
    max-width: 1200px;
}
.icon-star {
    width: 50px;
    height: 50px;
    object-fit: cover;
    vertical-align: middle;
    display: inline-block;
}

/* ================================================
   DOWNLOAD COUNTER
================================================ */
.download-box-center {
    text-align: center;
    font-size: 11px;
    letter-spacing: 2px;
    color: rgba(253,235,208,.3);
}
.download-box-center a {
    color: var(--oro);
    text-decoration: none;
    opacity: .7;
    transition: opacity .2s;
}
.download-box-center a:hover { opacity: 1; }

/* ================================================
   MEDIA QUERIES
================================================ */
@media screen and (max-width: 1024px) {
    .intestazione { grid-template-columns: 1fr 1fr; padding: 15px 25px; }
    .header-center { grid-column: 1 / -1; grid-row: 2; margin-top: 10px; }
    .title, .glitch::before, .glitch::after { font-size: 48px; letter-spacing: 6px; }
    .section-title { font-size: 60px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
@media screen and (max-width: 768px) {
    body { padding-top: 140px; cursor: auto; }
    .intestazione { padding: 12px 15px; }
    .img-logo { height: 50px; }
    .title, .glitch::before, .glitch::after { font-size: 32px; letter-spacing: 4px; }
    .subtitle { font-size: 10px; }
    .btn-home { padding: 8px 16px; }
    .btn-home span { display: none; }
    .btn-home i { margin-right: 0 !important; font-size: 16px !important; }
    .main-content { padding: 30px 15px 50px; }
    .section-title { font-size: 42px; margin-bottom: 20px; }
    #map { height: 380px; }
    .bio-link-label, .bio-link-name { font-size: 11px; }
    .map-toolbar { flex-direction: column; gap: 10px; align-items: flex-start; }
    .stats-row { grid-template-columns: 1fr; }
    footer { grid-template-columns: 1fr; gap: 20px; text-align: center; padding: 30px 20px; }
    .footer-left, .footer-right { text-align: center; }
    #rain-canvas { opacity: .1; }
    /* Su mobile i tooltip non servono (niente hover), li nasconde */
    .tooltip-anpi.leaflet-tooltip { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    body::before { animation: none !important; }
    .marquee-track { animation: none !important; }
    .tooltip-anpi.leaflet-tooltip { animation: none !important; }
}