/* =============================================================================
   ORDINAMENTA(TM) - radici-overlay.css
   Overlay full-screen del Mondo "Radici" (12 tappe storiche, click sul Sole).
   Self-contained, no Tailwind. Plain CSS scoped con prefisso .ro- / #radici-overlay.
   ============================================================================= */

#radici-overlay {
    --ro-cream: #f5efe2;
    --ro-primary: #031f41;
    --ro-primary-container: #1d3557;
    --ro-accent: #c1121f;
    --ro-gold: #c9a55c;
    --ro-bg-overlay: rgba(3, 31, 65, 0.95);

    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--ro-cream);
    -webkit-font-smoothing: antialiased;
}

#radici-overlay.ro-open { display: block; }

/* Backdrop semitrasparente che lascia intravedere il cosmo dietro */
.ro-backdrop {
    position: absolute;
    inset: 0;
    background: var(--ro-bg-overlay);
    opacity: 0;
    transition: opacity 0.3s ease;
}
#radici-overlay.ro-visible .ro-backdrop { opacity: 1; }

/* Shell che ospita header + body + (poi) dettaglio */
.ro-shell {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease 0.05s, transform 0.3s ease 0.05s;
}
#radici-overlay.ro-visible .ro-shell {
    opacity: 1;
    transform: none;
}

/* Header con titolo + bottone X */
.ro-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem 2rem 1.1rem;
    border-bottom: 1px solid rgba(201, 165, 92, 0.25);
}
.ro-header-text { min-width: 0; }
.ro-header-text h2 {
    margin: 0;
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.75rem;
    line-height: 1.15;
    letter-spacing: 0.02em;
    color: var(--ro-cream);
}
.ro-header-text p {
    margin: 0.25rem 0 0;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 1rem;
    color: var(--ro-gold);
}

/* Bottone close (X) */
.ro-close {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid rgba(245, 239, 226, 0.4);
    color: var(--ro-cream);
    font-size: 1.4rem;
    line-height: 1;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.ro-close:hover,
.ro-close:focus-visible {
    background: rgba(245, 239, 226, 0.08);
    border-color: var(--ro-gold);
    color: var(--ro-gold);
    outline: none;
}

/* Body: contenitore di timeline + dettaglio (Task 2/3 popolano) */
.ro-body {
    flex: 1 1 auto;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Errore di caricamento (mostrato se fetch JSON fallisce) */
.ro-error {
    margin: 2rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--ro-accent);
    border-radius: 8px;
    background: rgba(193, 18, 31, 0.15);
    color: var(--ro-cream);
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
}

/* Lock scroll del body sottostante quando overlay è aperto */
body.ro-locked { overflow: hidden; }

/* -----------------------------------------------------------------------------
   Intro + loader
   ----------------------------------------------------------------------------- */
.ro-intro {
    padding: 1.1rem 2rem 0.4rem;
    text-align: center;
}
.ro-intro p {
    margin: 0;
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 0.98rem;
    color: rgba(245, 239, 226, 0.88);
}
.ro-intro p.ro-intro-hint {
    margin-top: 0.3rem;
    font-style: italic;
    color: var(--ro-gold);
    font-size: 0.92rem;
}

.ro-loader {
    padding: 3rem 2rem;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    color: var(--ro-gold);
    text-align: center;
}

/* -----------------------------------------------------------------------------
   Timeline orizzontale (desktop/tablet)
   ----------------------------------------------------------------------------- */
.ro-timeline {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 1rem;
    padding: 1.25rem 2rem 2.25rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-color: var(--ro-gold) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.ro-timeline::-webkit-scrollbar { height: 8px; }
.ro-timeline::-webkit-scrollbar-track { background: transparent; }
.ro-timeline::-webkit-scrollbar-thumb {
    background: rgba(201, 165, 92, 0.45);
    border-radius: 4px;
}
.ro-timeline::-webkit-scrollbar-thumb:hover { background: var(--ro-gold); }

/* -----------------------------------------------------------------------------
   Node card (tappa cronologica)
   ----------------------------------------------------------------------------- */
.ro-node {
    position: relative;
    flex: 0 0 auto;
    width: 12rem;
    min-height: 11.5rem;
    padding: 1rem 0.9rem 0.85rem;
    border-radius: 12px;
    background: rgba(29, 53, 87, 0.55);
    border: 1px solid rgba(245, 239, 226, 0.18);
    color: var(--ro-cream);
    cursor: pointer;
    font: inherit;
    font-family: inherit;
    text-align: center;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease,
                border-color 0.2s ease, background 0.2s ease;
}
.ro-node:hover,
.ro-node:focus-visible {
    transform: translateY(-3px);
    border-color: var(--ro-gold);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    background: rgba(29, 53, 87, 0.88);
    outline: none;
}

.ro-node--starred {
    border: 2px solid var(--ro-gold);
    box-shadow: 0 0 0 1px rgba(201, 165, 92, 0.4),
                0 4px 14px rgba(201, 165, 92, 0.22);
}
.ro-node--starred:hover,
.ro-node--starred:focus-visible {
    box-shadow: 0 0 0 1px rgba(201, 165, 92, 0.6),
                0 8px 22px rgba(201, 165, 92, 0.35);
}

.ro-star {
    position: absolute;
    top: 0.4rem;
    right: 0.55rem;
    color: var(--ro-gold);
    font-size: 1.05rem;
    line-height: 1;
    text-shadow: 0 0 6px rgba(201, 165, 92, 0.6);
}

.ro-node-icon {
    font-size: 1.85rem;
    line-height: 1;
    margin-top: 0.1rem;
}
.ro-node-year {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--ro-gold);
    letter-spacing: 0.02em;
}
.ro-node-title {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 0.95rem;
    line-height: 1.25;
    color: var(--ro-cream);
}
.ro-node-place {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    color: rgba(245, 239, 226, 0.65);
    margin-top: auto;
    padding-top: 0.4rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* -----------------------------------------------------------------------------
   Active node highlight (quando una tappa e' selezionata)
   ----------------------------------------------------------------------------- */
.ro-node--active {
    background: rgba(245, 239, 226, 0.16);
    border-color: var(--ro-cream);
}
.ro-node--active.ro-node--starred {
    border-color: var(--ro-gold);
    box-shadow: 0 0 0 2px var(--ro-gold), 0 6px 22px rgba(201, 165, 92, 0.35);
}

/* -----------------------------------------------------------------------------
   Pannello dettaglio (espanso sotto la timeline)
   ----------------------------------------------------------------------------- */
.ro-detail {
    border-top: 1px solid rgba(201, 165, 92, 0.28);
    padding: 1.4rem 2rem 2rem;
    background: rgba(3, 31, 65, 0.55);
    overflow-y: auto;
    flex: 1 1 auto;
}

.ro-detail-head { margin-bottom: 1rem; }
.ro-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-bottom: 0.4rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ro-gold);
}
.ro-detail-place { color: rgba(245, 239, 226, 0.75); }
.ro-detail-starred { color: var(--ro-gold); font-weight: 600; }

.ro-detail-title {
    margin: 0 0 0.45rem;
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.55rem;
    line-height: 1.2;
    color: var(--ro-cream);
}
.ro-detail-headline {
    margin: 0 0 1.1rem;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 1.05rem;
    color: rgba(245, 239, 226, 0.9);
}

/* Tabs 3 fasce */
.ro-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.15rem;
    flex-wrap: wrap;
}
.ro-tab {
    flex: 1 1 0;
    min-width: 7.5rem;
    background: rgba(245, 239, 226, 0.06);
    border: 1px solid rgba(245, 239, 226, 0.22);
    color: var(--ro-cream);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
    line-height: 1.2;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.ro-tab:hover, .ro-tab:focus-visible {
    border-color: var(--ro-gold);
    background: rgba(201, 165, 92, 0.12);
    outline: none;
}
.ro-tab--active {
    background: var(--ro-cream);
    color: var(--ro-primary);
    border-color: var(--ro-cream);
}
.ro-tab-label {
    display: block;
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1rem;
}
.ro-tab-desc {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.78;
    margin-top: 0.08rem;
}

/* Body fascia (testo lungo) */
.ro-detail-body {
    margin: 0 0 1.4rem;
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.02rem;
    line-height: 1.55;
    color: rgba(245, 239, 226, 0.92);
}

/* Quiz interattivo */
.ro-quiz {
    background: rgba(245, 239, 226, 0.05);
    border: 1px solid rgba(201, 165, 92, 0.28);
    border-radius: 10px;
    padding: 1.1rem 1.2rem;
}
.ro-quiz-question {
    margin: 0 0 0.85rem;
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--ro-cream);
}
.ro-quiz-answers {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ro-quiz-choice {
    width: 100%;
    text-align: left;
    background: rgba(3, 31, 65, 0.55);
    color: var(--ro-cream);
    border: 1px solid rgba(245, 239, 226, 0.25);
    border-radius: 8px;
    padding: 0.7rem 0.95rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.ro-quiz-choice:hover:not(:disabled),
.ro-quiz-choice:focus-visible:not(:disabled) {
    border-color: var(--ro-gold);
    background: rgba(29, 53, 87, 0.7);
    outline: none;
}
.ro-quiz-choice:disabled { cursor: default; opacity: 0.95; }
.ro-quiz-choice--correct {
    background: rgba(76, 175, 80, 0.28);
    border-color: #6ec273;
    color: #ffffff;
}
.ro-quiz-choice--wrong {
    background: rgba(193, 18, 31, 0.3);
    border-color: var(--ro-accent);
    color: #ffffff;
}
.ro-quiz-choice--user { font-weight: 600; }
.ro-quiz-explanation {
    margin: 0.95rem 0 0;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 0.95rem;
    line-height: 1.45;
    color: rgba(245, 239, 226, 0.95);
    border-left: 3px solid var(--ro-gold);
    padding-left: 0.8rem;
}

/* =============================================================================
   Responsive: mobile / tablet stretto ≤ 900px
   Decisione D4: stack verticale, no scroll orizzontale.
   ============================================================================= */
@media (max-width: 900px) {
    .ro-header {
        padding: 1rem 1.1rem 0.85rem;
    }
    .ro-header-text h2 { font-size: 1.45rem; }
    .ro-header-text p  { font-size: 0.92rem; }
    .ro-close { width: 2.25rem; height: 2.25rem; font-size: 1.25rem; }

    .ro-body {
        overflow-y: auto;
        overflow-x: hidden;
    }
    .ro-intro {
        padding: 0.85rem 1.1rem 0.3rem;
    }
    .ro-intro p { font-size: 0.92rem; }

    .ro-timeline {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0.7rem;
        padding: 1rem 1.1rem 1.4rem;
        overflow-x: visible;
        overflow-y: visible;
        scroll-snap-type: none;
    }
    .ro-timeline::-webkit-scrollbar { display: none; }

    .ro-node {
        width: 100%;
        min-height: auto;
        padding: 0.85rem 0.95rem;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.4rem 0.85rem;
        text-align: left;
        scroll-snap-align: none;
    }
    .ro-node-icon {
        font-size: 1.6rem;
        flex: 0 0 auto;
    }
    .ro-node-year {
        font-size: 1.05rem;
        flex: 0 0 auto;
    }
    .ro-node-title {
        flex: 1 1 60%;
        font-size: 0.95rem;
    }
    .ro-node-place {
        flex: 0 0 100%;
        margin: 0;
        padding: 0;
        font-size: 0.7rem;
        text-align: left;
    }
    .ro-star {
        top: 0.4rem;
        right: 0.5rem;
    }

    .ro-detail {
        padding: 1.1rem 1.1rem 1.6rem;
    }
    .ro-detail-title { font-size: 1.35rem; }
    .ro-detail-headline { font-size: 1rem; }
    .ro-detail-body { font-size: 0.98rem; }

    .ro-tab {
        min-width: 0;
        padding: 0.5rem 0.55rem;
    }
    .ro-tab-label { font-size: 0.92rem; }
    .ro-tab-desc  { font-size: 0.62rem; }

    .ro-quiz { padding: 0.95rem 1rem; }
    .ro-quiz-question { font-size: 1rem; }
    .ro-quiz-choice { font-size: 0.92rem; padding: 0.65rem 0.8rem; }
}
