/* =====================================================================
   RADAR METEO ITALIA — pagina /radar-meteo-italia/
   (mantenere questo file sotto ~15KB: Aruba azzera i CSS troppo grandi)
   ===================================================================== */

/* Container article: full-bleed per la mappa, testo con padding generoso */
.rd-article { position: relative; }
.rd-article > .eg-section,
.rd-article > .rd-hero {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-left: clamp(20px, 5vw, 80px);
    padding-right: clamp(20px, 5vw, 80px);
}
.rd-article > .eg-section p,
.rd-article > .eg-section ul,
.rd-article > .rd-hero .eg-subtitle {
    max-width: 1400px; /* leggibilita' su monitor ultra-wide */
}
body.evergreen-page:has(.rd-article) .eg-main {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}

.rd-hero h1 {
    background: linear-gradient(135deg, #00b4ff 0%, #00e676 50%, #ffd600 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* STAGE: blocco full-width con toolbar + mappa + controlli */
.rd-stage {
    position: relative;
    margin: 24px calc(50% - 50vw) 40px;  /* full-bleed */
    width: 100vw;
    background: linear-gradient(180deg, #06090d 0%, #0a0f15 100%);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

/* Toolbar */
.rd-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 12, 16, 0.6);
    backdrop-filter: blur(8px);
}
.rd-toolbar::-webkit-scrollbar { height: 6px; }
.rd-toolbar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.rd-prod-sep {
    flex-shrink: 0;
    width: 1px;
    height: 30px;
    background: var(--border-strong);
    margin: 0 10px;
}

/* Toggle sorgente RainViewer / DPC */
.rd-src-group {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.rd-src {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 7px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    text-align: left;
    transition: all .15s ease;
    white-space: nowrap;
}
.rd-src:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.rd-src.is-active {
    background: linear-gradient(135deg, rgba(0,180,255,.22), rgba(0,230,118,.10));
    border-color: var(--accent-blue);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(0,180,255,.35), 0 2px 12px -2px rgba(0,180,255,.45);
}
/* DPC attivo: accento verde (sorgente ufficiale italiana) */
.rd-src[data-source="dpc"].is-active {
    background: linear-gradient(135deg, rgba(0,230,118,.20), rgba(0,180,255,.08));
    border-color: var(--accent-green);
    box-shadow: 0 0 0 1px rgba(0,230,118,.35), 0 2px 12px -2px rgba(0,230,118,.45);
}
.rd-src-ico {
    display: inline-block;
    margin-right: 6px;
    font-size: 14px;
}
.rd-src-lbl {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
}
.rd-src-sub {
    display: block;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-top: 1px;
}
.rd-src.is-active .rd-src-sub { color: var(--accent-blue); }
.rd-src[data-source="dpc"].is-active .rd-src-sub { color: var(--accent-green); }

/* Velocita' animazione (a destra nella toolbar) */
.rd-speed-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    margin-left: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.rd-speed-lbl {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-muted);
    font-weight: 700;
    padding: 0 8px 0 6px;
    user-select: none;
}
.rd-speed {
    width: 34px; height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all .15s ease;
}
.rd-speed:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.rd-speed.is-active {
    background: rgba(0,180,255,.18);
    border-color: var(--accent-blue);
    color: #fff;
    box-shadow: 0 0 8px -2px rgba(0,180,255,.5);
}

/* MAPPA */
.rd-map-wrap {
    position: relative;
    width: 100%;
    height: clamp(520px, 70vh, 840px);
    background: #04070a;
}
.rd-map {
    width: 100%;
    height: 100%;
    background: #04070a;
}
/* Vignettatura leggera per fondere mappa, toolbar e controlli */
.rd-map-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 500;
    box-shadow: inset 0 22px 28px -22px rgba(0,0,0,.85),
                inset 0 -22px 28px -22px rgba(0,0,0,.85);
}

/* LEGGENDA fluttuante (bottom-left) */
.rd-legend {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 600;
    min-width: 270px;
    max-width: calc(100% - 28px);
    padding: 12px 14px 10px;
    background: rgba(8, 12, 16, .9);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: 0 8px 24px -8px rgba(0,0,0,.6);
    backdrop-filter: blur(8px);
    pointer-events: none;
}
.rd-legend-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 8px;
}
.rd-legend-unit {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: none;
    letter-spacing: 0;
    padding: 1px 8px;
    background: rgba(0,180,255,.1);
    border: 1px solid rgba(0,180,255,.3);
    border-radius: 999px;
}
.rd-legend-bar {
    height: 13px;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,.1);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.4);
    margin-bottom: 5px;
}
.rd-legend-scale {
    display: flex;
    justify-content: space-between;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Badge frame corrente (top-right). Il pallino segue lo stato:
   verde = dal vivo, giallo = storico, azzurro = previsione */
.rd-frame-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 12px;
    background: rgba(8, 12, 16, .9);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    box-shadow: 0 4px 16px -4px rgba(0,0,0,.5);
    backdrop-filter: blur(8px);
    pointer-events: none;
}
.rd-frame-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse-dot 1.6s ease-in-out infinite;
}
.rd-frame-badge.is-past .rd-frame-dot {
    background: var(--accent-yellow);
    box-shadow: 0 0 8px var(--accent-yellow);
    animation: none;
}
.rd-frame-badge.is-future .rd-frame-dot {
    background: var(--accent-blue);
    box-shadow: 0 0 10px var(--accent-blue);
}
.rd-frame-time {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.rd-frame-mode {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .14em;
    font-weight: 700;
    color: var(--accent-green);
    padding: 2px 8px;
    background: rgba(0, 230, 118, .12);
    border-radius: 5px;
    border: 1px solid rgba(0, 230, 118, .35);
    white-space: nowrap;
}
.rd-frame-mode.is-past {
    color: var(--accent-yellow);
    background: rgba(255, 214, 0, .12);
    border-color: rgba(255, 214, 0, .35);
}
.rd-frame-mode.is-future {
    color: var(--accent-blue);
    background: rgba(0, 180, 255, .12);
    border-color: rgba(0, 180, 255, .35);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .45; transform: scale(1.25); }
}

/* Markers citta' (MapLibre HTML markers) */
.rd-city-marker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    white-space: nowrap;
    transform: translate(0, -50%);
}
.rd-city-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 6px rgba(255,255,255,.4);
}
.rd-city-name {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #f3fbff;
    text-shadow: 0 0 4px #000, 0 0 8px rgba(0,0,0,.8);
}

/* Marker posizione utente */
.rd-user-marker {
    position: relative;
    width: 18px; height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%);
}
.rd-user-dot {
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #00b4ff;
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px rgba(0,180,255,.7);
    z-index: 2;
}
.rd-user-pulse {
    position: absolute;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(0,180,255,.4);
    animation: rd-user-pulse 1.8s ease-out infinite;
    z-index: 1;
}
@keyframes rd-user-pulse {
    0%   { transform: scale(0.5); opacity: 0.9; }
    100% { transform: scale(2.4); opacity: 0;   }
}

/* MapLibre control overrides (tema dark) */
.maplibregl-ctrl-group {
    background: rgba(13, 19, 23, .92) !important;
    border: 1px solid var(--border-strong) !important;
}
.maplibregl-ctrl button {
    background-color: transparent !important;
    color: var(--text-primary) !important;
}
.maplibregl-ctrl button:hover {
    background-color: rgba(0, 180, 255, .15) !important;
}
.maplibregl-ctrl button .maplibregl-ctrl-icon {
    filter: invert(1) brightness(1.1);
}
.maplibregl-ctrl-attrib {
    background: rgba(8, 12, 16, .82) !important;
    color: var(--text-muted) !important;
}
.maplibregl-ctrl-attrib a { color: var(--text-secondary) !important; }
.maplibregl-popup-content {
    background: rgba(13, 19, 23, .95) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 8px !important;
}
.maplibregl-popup-tip { border-top-color: rgba(13, 19, 23, .95) !important; border-bottom-color: rgba(13, 19, 23, .95) !important; }

/* CONTROLLI sotto la mappa */
.rd-controls {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    padding: 16px 22px 18px;
    background: rgba(8, 12, 16, 0.65);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--border);
}

/* Play button */
.rd-play {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 1px solid var(--accent-blue);
    background: radial-gradient(circle at 35% 30%, rgba(0,180,255,.28), rgba(0,180,255,.05));
    color: var(--accent-blue);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .18s ease;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(0,180,255,.06);
}
.rd-play:hover {
    background: radial-gradient(circle at 35% 30%, rgba(0,180,255,.45), rgba(0,180,255,.1));
    box-shadow: 0 0 16px -2px rgba(0,180,255,.6), 0 0 0 5px rgba(0,180,255,.1);
    color: #fff;
    transform: scale(1.04);
}
.rd-play svg { width: 19px; height: 19px; }
.rd-play .rd-ico-play  { display: block; margin-left: 2px; }
.rd-play .rd-ico-pause { display: none; }
.rd-play.is-playing .rd-ico-play  { display: none; }
.rd-play.is-playing .rd-ico-pause { display: block; margin-left: 0; }
.rd-play.is-playing {
    border-color: var(--accent-green);
    color: var(--accent-green);
    background: radial-gradient(circle at 35% 30%, rgba(0,230,118,.3), rgba(0,230,118,.05));
    box-shadow: 0 0 0 4px rgba(0,230,118,.08);
}

/* Timeline con riempimento di progresso (var --rd-prog impostata dal JS) */
.rd-timeline {
    position: relative;
    padding: 4px 0 20px;
}
.rd-timeline input[type=range] {
    --rd-prog: 100%;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background:
        linear-gradient(90deg,
            rgba(0,180,255,.85) 0%,
            rgba(0,230,118,.9) var(--rd-prog),
            rgba(255,255,255,.07) var(--rd-prog),
            rgba(255,255,255,.07) 100%);
    border: 1px solid var(--border);
    outline: none;
    cursor: pointer;
    transition: box-shadow .2s ease;
}
.rd-timeline input[type=range]:hover {
    box-shadow: 0 0 10px -2px rgba(0,180,255,.4);
}
.rd-timeline input[type=range]:disabled { opacity: .4; cursor: default; }
.rd-timeline input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 19px; height: 19px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(0, 180, 255, .15), 0 2px 8px rgba(0,0,0,.4);
    cursor: grab;
    transition: transform .15s ease;
}
.rd-timeline input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.rd-timeline input[type=range]::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.05); }
.rd-timeline input[type=range]::-moz-range-thumb {
    width: 19px; height: 19px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(0, 180, 255, .15);
    cursor: grab;
}
.rd-timeline-ticks {
    position: absolute;
    bottom: 0;
    left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    padding: 0 4px;
}
.rd-tick {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .02em;
}
.rd-tick-now {
    color: var(--accent-green);
    font-weight: 700;
}
.rd-tick-future {
    color: var(--accent-blue);
    font-weight: 700;
}

/* Opacita' */
.rd-opacity {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 700;
    flex-shrink: 0;
}
.rd-opacity input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    outline: none;
    cursor: pointer;
}
.rd-opacity input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 2px solid #fff;
    cursor: pointer;
}
.rd-opacity input[type=range]::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 2px solid #fff;
    cursor: pointer;
}

/* MOBILE */
@media (max-width: 768px) {
    .rd-stage { margin: 16px calc(50% - 50vw) 28px; }
    .rd-toolbar { padding: 10px 12px; }
    .rd-src { padding: 6px 12px; }
    .rd-speed-lbl { display: none; }
    .rd-map-wrap { height: clamp(420px, 60vh, 620px); }

    .rd-legend { left: 10px; bottom: 10px; min-width: 220px; padding: 10px 12px 8px; }
    .rd-legend-title { font-size: 10px; }
    .rd-legend-scale { font-size: 9px; }
    .rd-legend-bar { height: 11px; }

    .rd-frame-badge { top: 10px; right: 10px; padding: 6px 12px 6px 10px; gap: 8px; }
    .rd-frame-time { font-size: 14px; }
    .rd-frame-mode { font-size: 9px; padding: 2px 6px; }

    .rd-controls {
        grid-template-columns: auto 1fr;
        gap: 12px;
        padding: 12px 14px 14px;
    }
    .rd-opacity {
        grid-column: 1 / -1;
        justify-content: center;
        gap: 10px;
        padding-top: 6px;
        border-top: 1px solid var(--border);
        margin-top: 2px;
    }
    .rd-opacity input[type=range] { width: 140px; }
    .rd-play { width: 42px; height: 42px; }
}
