/* ============================================================
   style.css — Unione Europea · Presentazione interattiva
   Progetto LUTE · Erasmus+
   Desktop : slide singola + frecce laterali + fade
   Mobile  : scroll verticale di tutte le card
   ============================================================ */

:root {
    --bg:           #f5f6f8;
    --surface:      #ffffff;
    --surface-alt:  #eef1f7;
    --border:       #d8dce4;
    --text:         #1f2430;
    --text-muted:   #6a7080;
    --accent:       #2b5cb0;
    --accent-dark:  #1a3f80;
    --accent-hover: #204a93;
    --gold:         #f2c230;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:    0 4px 14px rgba(0,0,0,0.12);
    --shadow-lg:    0 12px 36px rgba(30,50,100,0.18);
    --radius:       10px;
    --radius-lg:    18px;
    --transition:   0.2s ease;
    --content-max:  1100px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}

/* ============================================================
   BARRA LOGHI
   ============================================================ */
.logo-bar {
    background: #ffffff;
    border-bottom: 2px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-bar__img {
    height: 64px;
    width: auto;
    display: block;
}

.logo-bar__left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Pulsante ← torna indietro */
.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--accent);
    color: #ffffff;
    border-radius: 50%;
    text-decoration: none;
    font-size: 1.6rem;
    line-height: 1;
    box-shadow: var(--shadow-md);
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}
.back-btn:hover        { background: var(--accent-hover); transform: translateX(-3px); }
.back-btn:active       { transform: translateX(-1px); }
.back-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ============================================================
   SELETTORE LINGUA
   ============================================================ */
.lang-switcher {
    display: flex;
    gap: 6px;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.lang-btn {
    background: none;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 4px 6px;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--transition), background var(--transition);
}
.lang-btn:hover        { border-color: var(--accent); background: var(--surface-alt); }
.lang-btn--active      { border-color: var(--accent); background: var(--surface-alt); }
.lang-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Pulsante mobile (una bandiera + freccia) — nascosto su desktop */
.lang-mobile-btn {
    display: none;
    align-items: center;
    gap: 6px;
    background: none;
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 6px 10px;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    transition: background var(--transition), color var(--transition);
}
.lang-mobile-btn:hover,
.lang-mobile-btn[aria-expanded="true"] { background: var(--accent); color: #fff; }
.lang-mobile-arrow {
    font-size: 0.85rem;
    line-height: 1;
    transition: transform 0.2s ease;
    pointer-events: none;
}
.lang-mobile-btn[aria-expanded="true"] .lang-mobile-arrow { transform: rotate(180deg); }
.lang-mobile-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Pannello a discesa (mobile) */
.lang-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 6px 22px rgba(0,0,0,0.18);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 200;
    min-width: 170px;
}
.lang-dropdown[hidden] { display: none; }

.lang-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    min-height: 48px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    width: 100%;
    transition: background var(--transition), border-color var(--transition);
}
.lang-dropdown-item:hover { background: #eef1f7; border-color: var(--accent); }
.lang-dropdown-item--active { border-color: var(--accent); background: #eef1f7; color: var(--accent); }
.lang-dropdown-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   BARRA PROGRESSO
   ============================================================ */
.progress-bar {
    height: 4px;
    background: var(--border);
    position: sticky;
    top: 98px;          /* sotto la logo-bar */
    z-index: 99;
}

.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    transition: width 0.35s ease;
    width: 0%;
}

/* ============================================================
   TOPBAR (titolo applicazione + contatore slide)
   ============================================================ */
.topbar {
    background: var(--accent);
    color: #fff;
    padding: 10px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 102px;        /* sotto logo-bar (98px) + progress-bar (4px) */
    z-index: 98;
}

.topbar__title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__counter {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.85;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================================
   AREA VIEWER (desktop: prevBtn · stage · nextBtn)
   ============================================================ */
.viewer {
    flex: 1;
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 32px 100px 40px;
    max-width: 1380px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Pulsanti navigazione ◀ ▶ — fixed, sempre visibili a centro viewport */
.nav-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: 50%;
    cursor: pointer;
    color: var(--accent);
    font-size: 3rem;
    line-height: 1;
    padding: 0;
    box-shadow: var(--shadow-md);
    z-index: 50;
    transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.nav-btn#prevBtn { left: 24px; }
.nav-btn#nextBtn { right: 24px; }

.nav-btn:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-lg);
}
.nav-btn#prevBtn:not(:disabled):hover { transform: translateY(-50%) translateX(-4px); }
.nav-btn#nextBtn:not(:disabled):hover { transform: translateY(-50%) translateX(4px); }

.nav-btn:disabled {
    color: var(--border);
    border-color: var(--border);
    background: var(--surface);
    cursor: default;
    box-shadow: var(--shadow-sm);
    opacity: 0.55;
}

.nav-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
}

/* Stage: dove viene renderizzata la slide corrente */
.stage {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   CARD  (ogni singola slide)
   ============================================================ */
.card {
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    flex: 1;                /* riempie lo stage in verticale */
    transition: opacity 0.22s ease;
}

.card.is-fading { opacity: 0; }

/* Intestazione card */
.card__top {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #fff;
    padding: 28px 36px 24px;
    position: relative;
    overflow: hidden;
}
.card__top::after {
    content: "★";
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 80px;
    color: rgba(255,255,255,0.06);
    pointer-events: none;
    line-height: 1;
}

.card__title {
    margin: 0 0 6px;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.card__subtitle {
    margin: 0;
    font-size: 1.05rem;
    color: rgba(255,255,255,0.88);
}

/* Banner opzionale (testo accento centrato) */
.card__banner {
    background: var(--gold);
    color: var(--accent-dark);
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 10px 24px;
}

/* Meta-pills */
.card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 36px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1.5px solid var(--accent);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 0.92rem;
}

.meta-pill__label {
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
}

.meta-pill__value {
    color: var(--text);
    font-weight: 600;
}

/* Corpo card (testo + immagini) */
.card__body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 28px 36px;
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.card__body--no-images {
    grid-template-columns: 1fr;
}

.card__text {
    min-width: 0;
}

.card__images {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    justify-content: center;
}

.card__figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.card__figure img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: block;
}

.card__caption {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    line-height: 1.35;
    padding: 0 4px;
}

/* ============================================================
   SEZIONI  (all'interno della card)
   ============================================================ */
.section {
    margin-bottom: 24px;
}
.section:last-child { margin-bottom: 0; }

.section__heading {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-dark);
    margin: 0 0 10px;
    padding-left: 12px;
    border-left: 4px solid var(--gold);
    line-height: 1.3;
}

.section__text {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text);
}

.section__list {
    margin: 0;
    padding-left: 1.4em;
    font-size: 1.02rem;
    line-height: 1.7;
    color: var(--text);
}
.section__list li { margin-bottom: 6px; }
.section__list li:last-child { margin-bottom: 0; }

/* Tabella */
.section__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.98rem;
    margin: 0;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.section__table thead th {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    padding: 10px 14px;
    text-align: left;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}
.section__table tbody tr:nth-child(even) { background: var(--surface-alt); }
.section__table tbody tr:hover          { background: #e4ebf7; }
.section__table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.section__table tbody tr:last-child td { border-bottom: none; }

/* Video embed 16:9 */
.section__video-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;   /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin-top: 4px;
}
.section__video-wrap iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Chips (stati membri) */
.section__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px 5px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    min-width: 80px;
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: default;
}
.chip:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }

.chip__sub {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Tricolore */
.tricolor {
    display: flex;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    height: 56px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.tricolor__col {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    text-align: center;
    font-size: 0.85rem;
}

/* ============================================================
   TRIANGOLO ISTITUZIONALE (slide 15)
   ============================================================ */
.triangle-diagram {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 0 4px;
    width: 100%;
}

.td-row {
    display: flex;
    justify-content: center;
    gap: 16px;
    align-items: stretch;
}
.td-row--single { justify-content: center; }
.td-row--double { justify-content: center; align-items: center; }

.td-card {
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 10px 14px;
    text-align: center;
    flex: 0 1 280px;
    min-width: 200px;
    max-width: 320px;
    transition: transform var(--transition), box-shadow var(--transition);
}
.td-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.td-card__role {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.td-card__name {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--accent-dark);
    line-height: 1.25;
}
.td-card__action {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text);
    margin-top: 4px;
    line-height: 1.3;
}

/* Varianti colore per ogni istituzione */
.td-card--council-eu { border-color: #1a3f80; background: #f0f4fc; }
.td-card--commission { border-color: #d4a017; background: #fdf7e3; }
.td-card--parliament { border-color: #2b5cb0; background: #eaf1fa; }
.td-card--council    { border-color: #2b8049; background: #ecf6ef; }
.td-card--cjeu       { border-color: #8a2c5b; background: #f8ecf2; }

.td-arrow {
    text-align: center;
    font-size: 1.6rem;
    color: var(--accent);
    line-height: 1;
    margin: -2px 0;
    font-weight: 700;
}

.td-link {
    font-size: 1.6rem;
    color: var(--accent);
    font-weight: 700;
    align-self: center;
    padding: 0 6px;
}

.td-caption {
    text-align: center;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--accent-dark);
    background: var(--surface-alt);
    border-radius: var(--radius);
    padding: 6px 14px;
    margin: 4px auto;
    display: inline-block;
    align-self: center;
}

/* Mobile/tablet: il doppio diventa colonna */
@media (max-width: 1024px), (pointer: coarse) {
    .td-row--double { flex-direction: column; gap: 8px; }
    .td-link        { transform: rotate(90deg); padding: 4px 0; }
    .td-card        { max-width: 100%; flex: 1 1 auto; }
}

/* ============================================================
   FOOTER (suggerimento tasto)
   ============================================================ */
.footer-hint {
    text-align: center;
    padding: 12px 24px 24px;
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

/* ============================================================
   MOBILE SCROLL (nascosto su desktop)
   ============================================================ */
.mobile-scroll {
    display: none;
    flex-direction: column;
    gap: 28px;
    padding: 24px 16px 48px;
}

.mobile-scroll .card {
    box-shadow: var(--shadow-md);
}

/* ============================================================
   RESPONSIVE — tablet/mobile
   ============================================================ */
@media (max-width: 1024px), (pointer: coarse) {

    /* Logo-bar: griglia 3 colonne */
    .logo-bar {
        padding: 14px 20px;
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
    }
    .logo-bar__img  { height: 50px; }
    .logo-bar__left { gap: 10px; }
    .back-btn       { width: 44px; height: 44px; font-size: 1.4rem; }

    /* Lingua */
    .lang-switcher  { position: static; transform: none; justify-content: center; }
    .lang-btn       { display: none; }
    .lang-mobile-btn { display: flex; }

    /* Progress bar: aggiusta top dopo header ridotto */
    .progress-bar { top: 78px; }

    /* Viewer desktop → nascosto */
    .viewer   { display: none; }
    .topbar   { display: none; }
    .footer-hint { display: none; }

    /* Mobile scroll → visibile */
    .mobile-scroll { display: flex; }

    /* Card nel mobile scroll */
    .card__body {
        grid-template-columns: 1fr;
        padding: 20px 20px;
    }
    .card__top  { padding: 20px 20px 16px; }
    .card__meta { padding: 12px 20px; }
    .card__images { flex-direction: column; align-items: stretch; }
    .card__images img { max-width: 100%; width: 100%; }

    /* Testo slide più compatto su mobile (interlinea/margini ridotti).
       Su desktop resta arioso. Non riduco il corpo del testo (leggibilità). */
    .section { margin-bottom: 14px; }
    .section__heading { margin-bottom: 6px; }
    .section__text { line-height: 1.45; }
    .section__list { line-height: 1.45; }
    .section__list li { margin-bottom: 3px; }

    /* Chips più compatte */
    .chip { min-width: 70px; font-size: 0.82rem; padding: 5px 8px 4px; }
    .chip__sub { font-size: 0.68rem; }

    /* ----------------------------------------------------------
       Tabelle → schede impilate su mobile (niente scroll laterale)
       Ogni riga diventa un blocco; ogni cella mostra l'etichetta
       di colonna (data-label) sopra il valore.
       ---------------------------------------------------------- */
    .section__table {
        display: block;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }
    .section__table thead { display: none; }          /* intestazioni nascoste su mobile */
    .section__table tbody { display: block; width: 100%; }
    .section__table tr {
        display: block;
        width: 100%;
        margin-bottom: 8px;
        border: 1.5px solid var(--border);
        border-radius: var(--radius);
        overflow: hidden;
        background: #fff;
        box-shadow: var(--shadow-sm);
    }
    .section__table tr:last-child { margin-bottom: 0; }
    .section__table tr:nth-child(even) { background: #fff; }   /* annulla zebra desktop */
    .section__table td {
        display: block;
        width: 100%;
        border: none;
        border-bottom: 1px solid var(--border);
        padding: 6px 14px;
    }
    .section__table tr td:last-child { border-bottom: none; }
    .section__table td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: inline;
        font-weight: 700;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--accent);
        margin-right: 8px;
    }

    /* ----------------------------------------------------------
       Rete di sicurezza anti-sbordamento orizzontale su mobile
       (overflow-x: clip non crea scroll-container, quindi non
        rompe lo scroll verticale della pagina né gli sticky)
       ---------------------------------------------------------- */
    .mobile-scroll { overflow-x: clip; }
    .card,
    .card__body,
    .card__text { max-width: 100%; min-width: 0; }

    /* Il triangolo istituzionale (slide 15) non forza più 200px su schermi stretti */
    .td-card { min-width: 0; }

    /* Parole/sigle molto lunghe vanno a capo invece di spingere il bordo */
    .section__text,
    .section__list li,
    .section__heading,
    .card__title,
    .card__subtitle,
    .td-card__name,
    .td-card__action { overflow-wrap: anywhere; }
}

@media (max-width: 480px) {
    .logo-bar__img { height: 40px; }
    .logo-bar__left { gap: 8px; }
    .back-btn       { width: 40px; height: 40px; font-size: 1.2rem; }

    .card__title    { font-size: 1.3rem; }
    .card__top      { padding: 16px 16px 12px; }
    .card__body     { padding: 16px 16px; }
    .card__meta     { padding: 10px 16px; }

    .chip { min-width: 64px; font-size: 0.78rem; }
    .section__chips { gap: 6px; }
}

/* ============================================================
   SKIP-LINK (accessibilità: salta al contenuto)
   ============================================================ */
.skip-link {
    position: absolute;
    left: 8px;
    top: -56px;
    z-index: 2000;
    background: var(--accent-dark);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 8px;
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

/* ============================================================
   BANDIERA EUROPEA MINI nella topbar
   ============================================================ */
.topbar__left {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.flag-eu-mini {
    height: 22px;
    width: 33px;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
    display: block;
}
.flag-eu-mini svg { display: block; width: 100%; height: 100%; }

/* Bandierina del selettore lingua mobile: non si deve restringere */
.lang-mobile-btn img { flex: 0 0 auto; width: 32px; height: 22px; min-width: 32px; }

.lang-mobile-btn > svg { flex: 0 0 auto; width: 32px; height: 22px; display: block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.25); }
.lang-dropdown-item svg, .lang-btn svg { width: 100%; height: 100%; display: block; }
