/* Stile condiviso Monitor A, B, C - Porte della Tuscia */
@import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Fira+Sans+Condensed:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #611232;
    --accent-green: #5a8257;
    --accent-orange: #ec720f;
    --text-dark: #1e1f1f;
    --text-light: #4a5568;
    --title-color: #302d2d;
    --bg-light: #f7fafc;
    --border-light: #e2e8f0;
}

body {
    font-family: 'Fira Sans Condensed', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--primary);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* Header */
.header {
    background: white;
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 30px;
}

.header-logo {
    height: 56px;
    flex-shrink: 0;
}
.header-logo img {
    height: 100%;
    width: auto;
    display: block;
}
.monitor-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 8px 18px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    margin-left: auto;
    margin-right: 16px;
}

.header-content h1 {
    font-family: 'Abril Fatface', serif;
    font-size: 2.5em;
    color: var(--title-color);
    margin-bottom: 10px;
}

.header-content p {
    font-family: 'Fira Sans Condensed', sans-serif;
    font-size: 1.2em;
    color: var(--text-light);
}
.header-hint {
    font-family: 'Fira Sans Condensed', sans-serif;
    font-size: 1rem;
    color: var(--text-light);
    margin-top: 8px;
    font-weight: 500;
}

/* Main Sections Grid */
.sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

/* Section Card */
.section-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
}

.section-card:hover {
    transform: translateY(-5px);
}
.section-card:active {
    transform: translateY(-2px);
}

/* Sezione a tutta larghezza (es. Monitor B - Storia e ritualità) */
.single-section {
    grid-column: 1 / -1;
    background: white;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary);
}

.section-icon {
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}
.section-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.section-header h2 {
    font-family: 'Abril Fatface', serif;
    font-size: 1.6em;
    color: var(--title-color);
}

/* Content Items */
.content-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.content-item {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    background: white;
}
.content-item:active {
    opacity: 0.92;
}

.item-icon {
    font-size: 20px;
    opacity: 0.6;
}
.item-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    opacity: 0.6;
}

.content-item h3 {
    font-family: 'Abril Fatface', serif;
    font-size: 1.05em;
    color: var(--title-color);
    flex: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background: white;
    border-radius: 25px;
    padding: 0;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: var(--primary);
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.modal-title h3 {
    font-family: 'Abril Fatface', serif;
    font-size: 2em;
    margin-bottom: 8px;
}

.modal-section-badge {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9em;
}

.modal-close-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.modal-close-wrapper:active .close-label {
    transform: scale(0.97);
}
.close-label {
    font-family: 'Fira Sans Condensed', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    background: var(--accent-orange);
    padding: 10px 18px;
    border-radius: 999px;
    transition: transform 0.2s ease;
}

.modal-body {
    padding: 40px;
    overflow-y: scroll;
    flex: 1;
    /* Scrollbar sempre visibile quando c'è overflow */
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) rgba(0,0,0,0.1);
}
.modal-body::-webkit-scrollbar {
    width: 10px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.08);
    border-radius: 10px;
}
.modal-body::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-dark);
}

.scroll-hint {
    flex-shrink: 0;
    padding: 20px 40px 8px;
    text-align: center;
}
.scroll-hint span {
    font-family: 'Fira Sans Condensed', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 999px;
}
.scroll-hint.is-hidden {
    display: none;
}

/* Image container: img (se caricata) o placeholder (se file assente) */
.image-container {
    margin: 20px 0;
}
.image-container .content-image,
.image-container .image-placeholder {
    margin: 0;
}

/* Image Placeholder */
.image-placeholder {
    width: 100%;
    height: 300px;
    background: #e2e8f0;
    border-radius: 15px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #718096;
    border: 3px dashed #a0aec0;
    position: relative;
    overflow: hidden;
}

.image-placeholder::before {
    content: '📷';
    font-size: 60px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.image-placeholder-text {
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
    padding: 0 20px;
}

.image-placeholder-label {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.9);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--primary);
}

/* Actual Image */
.content-image {
    width: 100%;
    height: auto;
    border-radius: 15px;
    margin: 20px 0;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

/* Immagini dentro il testo (max 1/4 larghezza per non sformattare il testo) */
.modal-body .image-wrap-float-left,
.modal-body .image-wrap-float-right {
    max-width: 25%;
    margin-bottom: 15px;
}
.modal-body .image-wrap-float-left {
    float: left;
    margin-right: 24px;
    margin-top: 4px;
}
.modal-body .image-wrap-float-right {
    float: right;
    margin-left: 24px;
    margin-top: 4px;
}
.modal-body .image-wrap-float-left .image-container,
.modal-body .image-wrap-float-right .image-container {
    margin: 0;
}
.modal-body .image-wrap-float-left .content-image,
.modal-body .image-wrap-float-right .content-image {
    margin: 0;
    display: block;
}
.modal-body .image-wrap-float-left .image-placeholder,
.modal-body .image-wrap-float-right .image-placeholder {
    margin: 0;
    height: 220px;
}

/* Immagini a tutta larghezza (float center) */
.modal-body .image-wrap-float-center {
    clear: both;
    margin: 20px 0;
}
.modal-body .image-wrap-float-center .image-container {
    margin: 0;
}
.modal-body .image-wrap-float-center .content-image {
    margin: 0;
}

.modal-body p {
    font-family: 'Fira Sans Condensed', sans-serif;
    line-height: 1.9;
    color: var(--text-dark);
    margin-bottom: 18px;
    font-size: 1.05em;
}

/*
 * Paragrafi come blocchi separati (come le righe nell'editor): devono iniziare sotto i float dei
 * blocchi immagine+testo precedenti, altrimenti il testo "serpeggia" lungo tutta la colonna accanto
 * alle immagini impilate a destra/sinistra.
 */
.modal-body > p {
    clear: both;
}

/* Inline emphasis (corsivo) */
.modal-body p em,
.modal-body .block-text-image-text em {
    display: inline;
    font-style: italic;
    color: inherit;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
}

/* Callout: <em> come unico contenuto del paragrafo (legacy) */
.modal-body p > em:only-child,
.modal-body > em {
    display: block;
    font-style: italic;
    color: var(--text-light);
    margin: 25px 0;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
}

/* Liste (per editor + pubblico) */
.modal-body ul,
.modal-body ol {
    margin: 0 0 18px 1.25em;
    padding: 0;
    font-family: 'Fira Sans Condensed', sans-serif;
    line-height: 1.9;
    color: var(--text-dark);
    font-size: 1.05em;
}

.modal-body li {
    margin: 0.25em 0;
}

.modal-body strong {
    color: var(--text-dark);
    font-weight: 600;
}

/*
 * Combo paragrafo + immagine: griglia a due colonne come nell’editor.
 * I float nel modale (flex) tendono a impilare l’immagine e mandare il testo sotto a tutta larghezza.
 */
.modal-body .block-text-image--left,
.modal-body .block-text-image--right {
    display: grid;
    gap: 24px;
    align-items: start;
    margin-bottom: 28px;
    width: 100%;
    box-sizing: border-box;
}

.modal-body .block-text-image--left {
    grid-template-columns: min(28%, 300px) minmax(0, 1fr);
}

.modal-body .block-text-image--right {
    grid-template-columns: minmax(0, 1fr) min(28%, 300px);
}

.modal-body .block-text-image--left .block-text-image-visual,
.modal-body .block-text-image--left > .image-wrap-float-left {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
}

.modal-body .block-text-image--left .block-text-image-text {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
}

.modal-body .block-text-image--right .block-text-image-visual,
.modal-body .block-text-image--right > .image-wrap-float-right {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
}

.modal-body .block-text-image--right .block-text-image-text {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
}

.modal-body .block-text-image .image-wrap-float-left,
.modal-body .block-text-image .image-wrap-float-right {
    float: none;
    margin: 0;
    max-width: none;
    width: 100%;
}

.modal-body .block-text-image .image-wrap-float-left .content-image,
.modal-body .block-text-image .image-wrap-float-right .content-image {
    width: 100%;
    margin: 0;
}

.modal-body > .content-gallery-masonry-wrap,
.modal-body > .content-gallery-slider {
    clear: both;
}

.modal-body .block-text-image-text {
    font-family: 'Fira Sans Condensed', sans-serif;
    line-height: 1.9;
    color: var(--text-dark);
    font-size: 1.05em;
}

.modal-body .block-text-image-text p {
    margin-bottom: 18px;
}

.modal-body .block-text-image-text p:last-child {
    margin-bottom: 0;
}

@media (max-width: 720px) {
    .modal-body .block-text-image--left,
    .modal-body .block-text-image--right {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .modal-body .block-text-image--left .block-text-image-visual,
    .modal-body .block-text-image--left > .image-wrap-float-left,
    .modal-body .block-text-image--left .block-text-image-text,
    .modal-body .block-text-image--right .block-text-image-visual,
    .modal-body .block-text-image--right > .image-wrap-float-right,
    .modal-body .block-text-image--right .block-text-image-text {
        grid-column: 1;
        grid-row: auto;
    }
}

.clearfix-block {
    clear: both;
    height: 0;
    overflow: hidden;
}

/* Galleria immagini */
.modal-body .content-gallery-masonry-wrap {
    margin: 24px 0;
}

/* Posizioni calcolate da js/gallery-masonry.js (colonna più bassa) */
.modal-body .content-gallery-grid.content-gallery-masonry-grid {
    position: relative;
    width: 100%;
}

.modal-body .content-gallery-grid.content-gallery-masonry-grid .content-gallery-figure {
    margin: 0;
    min-width: 0;
    box-sizing: border-box;
}

.modal-body .content-gallery-figure .image-container {
    margin: 0;
}

.modal-body .content-gallery-figure .content-image {
    margin: 0;
    width: 100%;
    height: auto;
    display: block;
}

/* Slider galleria */
.modal-body .content-gallery-slider {
    margin: 24px 0;
    position: relative;
}

/* Carosello: stesso meccanismo dello slider, cornice leggermente diversa */
.modal-body .content-image-carousel.content-gallery-slider {
    padding: 12px;
    background: var(--bg-light);
    border-radius: 20px;
    border: 1px solid var(--border-light);
}

.modal-body .content-image-carousel .content-gallery-slider-viewport {
    border-radius: 15px;
}

.modal-body .content-gallery-slider-viewport {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    width: 100%;
    border-radius: 15px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) rgba(0,0,0,0.1);
}

.modal-body .content-gallery-slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    box-sizing: border-box;
}

.modal-body .content-gallery-slide-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.modal-body .gallery-slider-nav {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 14px;
}

.modal-body .gallery-slider-btn {
    min-width: 56px;
    min-height: 56px;
    border-radius: 999px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1.75rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    padding-bottom: 4px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}

.modal-body .gallery-slider-btn:active {
    transform: scale(0.96);
}

.modal-body .gallery-slider-dots {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.modal-body .gallery-slider-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    border: 2px solid var(--border-light);
    background: white;
    cursor: pointer;
    padding: 0;
}

.modal-body .gallery-slider-dot.is-active {
    background: var(--primary);
    border-color: var(--primary);
}

/* Home Button */
.home-btn {
    position: fixed;
    top: 30px;
    left: 30px;
    min-width: 72px;
    min-height: 72px;
    padding: 10px;
    background: white;
    border: none;
    border-radius: 999px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.3s ease;
    z-index: 999;
}
.home-icon {
    font-size: 28px;
    line-height: 1;
}
.home-label {
    font-family: 'Fira Sans Condensed', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dark);
}
.home-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.home-btn:active {
    transform: scale(0.98);
}

/* Responsive: tablet portrait e schermi stretti (orizzontale e verticale) */
@media (max-width: 900px) {
    .sections-grid {
        grid-template-columns: 1fr;
    }
    .header {
        flex-direction: column;
        text-align: center;
        padding: 25px;
    }
    .monitor-badge {
        margin-left: 0;
    }
    .header-content h1 {
        font-size: 1.8em;
    }
    .header-hint {
        font-size: 0.9rem;
    }
    .modal-body {
        padding: 25px;
    }
    .modal-header {
        padding: 20px;
    }
    .modal-title h3 {
        font-size: 1.4em;
    }
}

