/**
 * Hope Group Wind Map - Stylesheet
 * Stili per la visualizzazione della mappa e modale
 *
 * @package Hope_Group_Wind_Map
 * @since 1.0.0
 */

/* ==========================================================================
   Container Principale Mappa
   ========================================================================== */

.hope-map-wrapper {
    position: relative;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Container mappa - fluido 100% width */
.hope-map-container {
    position: relative;
    width: 100%; /* Fluido */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    /* L'altezza viene impostata inline dallo shortcode su desktop */
}

/* Media query: Mobile < 768px → height fissa 400px */
@media (max-width: 767px) {
    .hope-map-container {
        height: 400px !important; /* Override inline style su mobile */
    }
}

/* Wrapper esterno opzionale per la sezione mappa nei template ACF block.
   Sostituisce inline `width: 70%` che spezzava su mobile.
   Desktop: centrato, max 1400px. Mobile: full-width con padding minimo. */
.hope-map-section {
    max-width: 1400px;
    margin: 4rem auto;
    padding: 0 1rem;
}
@media (max-width: 767px) {
    .hope-map-section {
        margin: 2rem auto;
        padding: 0 0.5rem;
    }
}

/* ==========================================================================
   Loader Caricamento
   ========================================================================== */

.hope-map-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    z-index: 10;
}

.hope-loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: hope-spin 1s linear infinite;
}

@keyframes hope-spin {
    to {
        transform: rotate(360deg);
    }
}

.hope-map-loader p {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

/* ==========================================================================
   Modale - Stile Moderno
   ========================================================================== */

/* Overlay fisso rgba(0,0,0,0.7) a tutto schermo */
.hope-map-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Modale aperta con classe .is-open */
.hope-map-modal.is-open {
    opacity: 1;
    visibility: visible;
}

/* Overlay scuro a tutto schermo */
.hope-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Sfondo scuro come richiesto */
    backdrop-filter: blur(3px);
}

/* Box centrale bianco con bordi arrotondati e ombra */
.hope-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background: #ffffff; /* Box bianco */
    border-radius: 12px; /* Bordi arrotondati */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); /* Ombra leggera */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Pulsante chiusura (X) */
.hope-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.hope-modal-close:hover {
    background: #fff;
    color: #d63638;
    transform: rotate(90deg);
}

.hope-modal-close:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Corpo della modale - overflow-y auto per contenuti lunghi */
.hope-modal-body {
    padding: 30px;
    overflow-y: auto; /* Scroll se contenuto lungo */
    max-height: calc(85vh - 60px);
}

/* Layout flessibile: Immagine in alto */
.hope-modal-image {
    margin-bottom: 20px;
}

.hope-modal-image img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

/* Titolo sotto l'immagine */
.hope-modal-header h2 {
    margin: 0 0 20px 0;
    padding-right: 50px; /* Spazio per il pulsante X */
    font-size: 28px;
    color: #1e1e1e;
    font-weight: 600;
    line-height: 1.3;
}

/* Dati tecnici in griglia */
.hope-modal-info {
    margin-bottom: 25px;
}

.hope-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.hope-info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hope-info-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #666;
    font-weight: 600;
    letter-spacing: 0.8px;
}

.hope-info-value {
    font-size: 16px;
    color: #1e1e1e;
    font-weight: 500;
}

/* Colori per tipo */
.hope-type-offshore {
    color: #0073aa;
}

.hope-type-onshore {
    color: #46b450;
}

.hope-type-osservatorio {
    color: #dc3232;
}

/* Descrizione completa */
.hope-modal-description {
    margin-bottom: 25px;
}

.hope-modal-description h3 {
    margin: 0 0 15px 0;
    font-size: 20px;
    color: #1e1e1e;
    font-weight: 600;
}

.hope-description-content {
    font-size: 15px;
    line-height: 1.7;
    color: #555;
}

.hope-description-content p {
    margin-bottom: 12px;
}

.hope-description-content p:last-child {
    margin-bottom: 0;
}

/* Footer con pulsante */
.hope-modal-footer {
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

/* Previeni scroll del body quando la modale è aperta */
body.hope-modal-open {
    overflow: hidden;
}

/* Mobile: box modale occupa 90% larghezza, overflow-y auto */
@media (max-width: 767px) {
    .hope-modal-content {
        width: 90%; /* 90% larghezza su mobile */
        max-height: 90vh;
    }

    .hope-modal-body {
        padding: 20px;
        max-height: calc(90vh - 40px);
        overflow-y: auto; /* Auto scroll su mobile */
    }

    .hope-modal-header h2 {
        font-size: 22px;
        padding-right: 40px;
    }

    .hope-modal-image img {
        max-height: 200px;
    }

    .hope-info-grid {
        grid-template-columns: 1fr; /* Una colonna su mobile */
        padding: 15px;
    }

    .hope-modal-close {
        width: 35px;
        height: 35px;
        font-size: 24px;
        top: 10px;
        right: 10px;
    }
}

/* ==========================================================================
   Bottoni
   ========================================================================== */

.hope-btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    line-height: 1.4;
}

.hope-btn-primary {
    background: #2271b1;
    color: #fff;
}

.hope-btn-primary:hover {
    background: #135e96;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
}

.hope-btn:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

@media (max-width: 767px) {
    .hope-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* ==========================================================================
   Legenda Mappa
   ========================================================================== */

.hope-map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 150px;
}

.hope-map-legend h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e1e1e;
}

.hope-map-legend ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.hope-map-legend li {
    display: flex;
    align-items: center;
    margin: 6px 0;
    font-size: 13px;
    color: #555;
}

.legend-marker {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-right: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.legend-turbine {
    background: #f59e0b;
}

.legend-osservazione {
    background: #dc3232;
}

/* Mantenuti per retrocompatibilità */
.legend-offshore {
    background: #0073aa;
}

.legend-onshore {
    background: #46b450;
}

.legend-osservatorio {
    background: #dc3232;
}

@media (max-width: 767px) {
    .hope-map-legend {
        left: 10px;
        bottom: 10px;
        padding: 10px;
        min-width: 130px;
    }

    .hope-map-legend h4 {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .hope-map-legend li {
        font-size: 11px;
        margin: 4px 0;
    }

    .legend-marker {
        width: 14px;
        height: 14px;
        margin-right: 8px;
    }
}

/* ==========================================================================
   Messaggi di Errore
   ========================================================================== */

.hope-map-error {
    padding: 40px 20px;
    text-align: center;
    background: #f8f9fa;
    border: 2px dashed #d0d0d0;
    border-radius: 8px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hope-error-icon {
    margin-bottom: 15px;
}

.hope-error-icon .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #d63638;
}

.hope-map-error p {
    margin: 10px 0;
    font-size: 16px;
    color: #555;
    max-width: 500px;
}

.hope-map-error .button {
    margin-top: 15px;
}

@media (max-width: 767px) {
    .hope-map-error {
        padding: 30px 15px;
        min-height: 250px;
    }

    .hope-map-error p {
        font-size: 14px;
    }

    .hope-error-icon .dashicons {
        font-size: 40px;
        width: 40px;
        height: 40px;
    }
}

/* ==========================================================================
   Transizioni e Animazioni
   ========================================================================== */

/* Animazione apertura modale */
.hope-map-modal.is-open .hope-modal-content {
    animation: hopeModalSlideIn 0.4s ease-out;
}

@keyframes hopeModalSlideIn {
    from {
        transform: translate(-50%, -60%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* Animazione overlay */
.hope-map-modal.is-open .hope-modal-overlay {
    animation: hopeOverlayFadeIn 0.3s ease-out;
}

@keyframes hopeOverlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==========================================================================
   Scrollbar Personalizzata (WebKit)
   ========================================================================== */

.hope-modal-body::-webkit-scrollbar {
    width: 8px;
}

.hope-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.hope-modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.hope-modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Firefox scrollbar */
.hope-modal-body {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Nascondi elemento visivamente ma mantieni per screen reader */
.hope-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Accessibilità
   ========================================================================== */

/* Focus visibile per navigazione da tastiera */
*:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Riduci animazioni per chi preferisce */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Alto contrasto per accessibilità */
@media (prefers-contrast: high) {
    .hope-modal-content {
        border: 2px solid #000;
    }

    .hope-btn-primary {
        border: 2px solid #000;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .hope-map-legend,
    .hope-modal-close,
    .hope-btn {
        display: none;
    }

    .hope-map-modal {
        position: static;
        opacity: 1;
        visibility: visible;
    }

    .hope-modal-overlay {
        display: none;
    }

    .hope-modal-content {
        position: static;
        transform: none;
        box-shadow: none;
        max-height: none;
        width: 100%;
        max-width: none;
    }

    .hope-modal-body {
        overflow-y: visible;
        max-height: none;
        padding: 0;
    }

    .hope-map-container {
        height: 400px !important;
        break-inside: avoid;
    }
}

/* ==========================================================================
   Responsive Breakpoints Aggiuntivi
   ========================================================================== */

/* Tablet landscape (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .hope-modal-content {
        width: 85%;
    }

    .hope-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop large (> 1400px) */
@media (min-width: 1400px) {
    .hope-modal-content {
        max-width: 800px;
    }

    .hope-modal-header h2 {
        font-size: 32px;
    }

    .hope-modal-body {
        padding: 40px;
    }
}

/* Very small mobile (< 375px) */
@media (max-width: 374px) {
    .hope-map-container {
        height: 300px !important;
    }

    .hope-modal-content {
        width: 95%;
    }

    .hope-modal-body {
        padding: 15px;
    }

    .hope-modal-header h2 {
        font-size: 18px;
    }

    .hope-info-grid {
        padding: 12px;
        gap: 12px;
    }
}

/* ==========================================================================
   Dark Mode Support (Opzionale)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .hope-modal-content {
        background: #1e1e1e;
        color: #e0e0e0;
    }

    .hope-modal-header h2,
    .hope-modal-description h3 {
        color: #ffffff;
    }

    .hope-info-grid {
        background: #2a2a2a;
    }

    .hope-info-label {
        color: #b0b0b0;
    }

    .hope-info-value {
        color: #e0e0e0;
    }

    .hope-description-content {
        color: #b0b0b0;
    }

    .hope-modal-footer {
        border-top-color: #444;
    }

    .hope-modal-close {
        background: rgba(50, 50, 50, 0.95);
        color: #e0e0e0;
    }

    .hope-modal-close:hover {
        background: #2a2a2a;
        color: #ff6b6b;
    }

    .hope-modal-body::-webkit-scrollbar-track {
        background: #2a2a2a;
    }

    .hope-modal-body::-webkit-scrollbar-thumb {
        background: #555;
    }

    .hope-modal-body::-webkit-scrollbar-thumb:hover {
        background: #777;
    }
}

/* ==========================================================================
   Immagine Featured Panoramica
   ========================================================================== */

.hope-modal-featured-image,
.hope-single-featured-image {
    width: 100%;
    margin: 0 0 24px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
}

.hope-modal-featured-image img,
.hope-single-featured-image img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: cover;
    object-position: center;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.hope-modal-featured-image img:hover,
.hope-single-featured-image img:hover {
    transform: scale(1.02);
}

/* ==========================================================================
   Galleria Fotografica
   ========================================================================== */

.hope-modal-gallery,
.hope-single-gallery {
    margin: 30px 0;
}

.hope-modal-gallery h3,
.hope-single-gallery h2 {
    font-size: 1.3em;
    margin: 0 0 15px 0;
    color: #2c3e50;
}

.hope-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.hope-gallery-thumb {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 1;
}

.hope-gallery-thumb:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hope-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.hope-gallery-thumb:hover img {
    transform: scale(1.1);
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.hope-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hope-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.hope-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    z-index: 1;
}

.hope-lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.hope-lightbox-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 30px;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 2;
}

.hope-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.hope-lightbox-prev,
.hope-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 36px;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 2;
}

.hope-lightbox-prev {
    left: 20px;
}

.hope-lightbox-next {
    right: 20px;
}

.hope-lightbox-prev:hover,
.hope-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.hope-lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

body.hope-lightbox-open {
    overflow: hidden;
}

/* ==========================================================================
   Template Pagina Singola
   ========================================================================== */

.hope-single-point-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.hope-single-point {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.hope-single-content {
    padding: 30px;
}

.hope-single-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.hope-single-title {
    font-size: 2.2em;
    margin: 0 0 15px 0;
    color: #2c3e50;
    line-height: 1.3;
}

.hope-single-type {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hope-single-type.hope-type-offshore {
    background: #e3f2fd;
    color: #1976d2;
}

.hope-single-type.hope-type-onshore {
    background: #e8f5e9;
    color: #388e3c;
}

.hope-single-type.hope-type-osservatorio {
    background: #ffebee;
    color: #c62828;
}

.hope-single-details,
.hope-single-description,
.hope-single-gallery {
    margin-bottom: 30px;
}

.hope-single-details h2,
.hope-single-description h2,
.hope-single-gallery h2 {
    font-size: 1.5em;
    margin: 0 0 20px 0;
    color: #2c3e50;
}

.hope-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.hope-detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hope-detail-label {
    font-size: 0.85em;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.hope-detail-value {
    font-size: 1.1em;
    color: #2c3e50;
    font-weight: 500;
}

.hope-description-content {
    line-height: 1.8;
    color: #555;
}

.hope-description-content p {
    margin: 0 0 15px 0;
}

.hope-single-back {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    /* Galleria */
    .hope-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    /* Lightbox */
    .hope-lightbox-prev,
    .hope-lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    .hope-lightbox-prev {
        left: 10px;
    }

    .hope-lightbox-next {
        right: 10px;
    }

    .hope-lightbox-close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 25px;
    }

    .hope-lightbox-counter {
        bottom: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }

    /* Pagina singola */
    .hope-single-point-wrapper {
        padding: 10px;
    }

    .hope-single-content {
        padding: 20px;
    }

    .hope-single-title {
        font-size: 1.6em;
    }

    .hope-details-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .hope-modal-featured-image img,
    .hope-single-featured-image img {
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .hope-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .hope-single-title {
        font-size: 1.4em;
    }

    .hope-details-grid {
        padding: 15px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .hope-single-point {
        background: #1e1e1e;
    }

    .hope-single-title,
    .hope-single-details h2,
    .hope-single-description h2,
    .hope-single-gallery h2 {
        color: #ffffff;
    }

    .hope-details-grid {
        background: #2a2a2a;
    }

    .hope-detail-value {
        color: #e0e0e0;
    }

    .hope-description-content {
        color: #b0b0b0;
    }

    .hope-modal-gallery h3 {
        color: #ffffff;
    }
}
