/* ============================================================
   PregaOgniGiorno.it — Design System v2.0
   Vanilla CSS · No framework · No terze parti
   ============================================================ */

/* --- Variabili CSS (tema) --- */
:root {
    /* Colori principali — Tau Francescano + notte stellata */
    --bg:          #f0f4fa;
    --bg-card:     #ffffff;
    --bg-elevated:  #ffffff;
    --testo:       #1a2332;
    --testo-soft:   #5a6b82;
    --testo-muted:  #8899ad;

    /* Brand */
    --primario:     #1a3a6b;   /* blu notte */
    --primario-light:#2d5a9e;
    --accento:      #d4a843;   /* oro/ambra */
    --accento-light:#e8c97a;

    /* Stati */
    --successo:     #2e7d52;
    --pericolo:     #c0392b;
    --info:          #3498db;

    /* UI */
    --border:       #dde4ee;
    --border-soft:  #eaf0f7;
    --ombra:        0 2px 8px rgba(26,58,107,0.08);
    --ombra-lg:     0 8px 32px rgba(26,58,107,0.12);
    --ombra-card:   0 1px 3px rgba(26,58,107,0.06), 0 4px 12px rgba(26,58,107,0.04);
    --radius:       16px;
    --radius-sm:    10px;
    --radius-lg:    24px;
    --radius-full:  100px;

    /* Tipografia */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;

    /* Spaziatura */
    --sp-xs:  4px;
    --sp-sm:  8px;
    --sp-md:  16px;
    --sp-lg:  24px;
    --sp-xl:  40px;
    --sp-xxl: 64px;

    /* Layout */
    --topbar-h:  60px;
    --bottomnav-h: 64px;
    --max-w:     720px;
    --max-w-lg:  960px;

    /* Transizioni */
    --ease:       cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Dark mode --- */
@media (prefers-color-scheme: dark) {
    :root:not(.light-mode) {
        --bg:          #0d1520;
        --bg-card:     #162238;
        --bg-elevated:  #1c2d45;
        --testo:       #e8edf5;
        --testo-soft:   #a0b4cc;
        --testo-muted:  #6b7f99;
        --primario:     #4a7ec4;
        --primario-light:#6a9ede;
        --accento:      #e8c97a;
        --accento-light:#f0d998;
        --border:       #253650;
        --border-soft:  #1e3048;
        --ombra:        0 2px 8px rgba(0,0,0,0.3);
        --ombra-lg:     0 8px 32px rgba(0,0,0,0.4);
        --ombra-card:   0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.15);
    }
}
:root.dark-mode {
    --bg:          #0d1520;
    --bg-card:     #162238;
    --bg-elevated:  #1c2d45;
    --testo:       #e8edf5;
    --testo-soft:   #a0b4cc;
    --testo-muted:  #6b7f99;
    --primario:     #4a7ec4;
    --primario-light:#6a9ede;
    --accento:      #e8c97a;
    --accento-light:#f0d998;
    --border:       #253650;
    --border-soft:  #1e3048;
    --ombra:        0 2px 8px rgba(0,0,0,0.3);
    --ombra-lg:     0 8px 32px rgba(0,0,0,0.4);
    --ombra-card:   0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.15);
}
:root.light-mode {
    --bg:          #f0f4fa;
    --bg-card:     #ffffff;
    --bg-elevated:  #ffffff;
    --testo:       #1a2332;
    --testo-soft:   #5a6b82;
    --testo-muted:  #8899ad;
    --primario:     #1a3a6b;
    --primario-light:#2d5a9e;
    --accento:      #d4a843;
    --accento-light:#e8c97a;
    --border:       #dde4ee;
    --border-soft:  #eaf0f7;
    --ombra:        0 2px 8px rgba(26,58,107,0.08);
    --ombra-lg:     0 8px 32px rgba(26,58,107,0.12);
    --ombra-card:   0 1px 3px rgba(26,58,107,0.06), 0 4px 12px rgba(26,58,107,0.04);
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--testo);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

a { color: var(--primario); text-decoration: none; transition: color 0.2s var(--ease); }
a:hover { color: var(--primario-light); }

img { max-width: 100%; height: auto; display: block; }

/* --- Tipografia --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--testo);
    margin-bottom: var(--sp-md);
}
h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 4vw, 1.9rem); }
h3 { font-size: clamp(1.15rem, 3vw, 1.4rem); }
h4 { font-size: 1.05rem; }

p { margin-bottom: var(--sp-md); }

.serif { font-family: var(--font-serif); }
.text-soft { color: var(--testo-soft); }
.text-muted { color: var(--testo-muted); }
.text-center { text-align: center; }
.text-accento { color: var(--accento); }
.text-primario { color: var(--primario); }

/* ============================================================
   TOPBAR — responsive con menu orizzontale su desktop
   ============================================================ */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-md);
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.3s var(--ease);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    flex: 1;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    color: var(--testo);
    font-weight: 700;
    font-size: 1.1rem;
}
.brand:hover { color: var(--testo); }

.brand-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accento);
    box-shadow: 0 0 0 2px var(--bg-card);
    flex-shrink: 0;
}

.brand-nome { display: flex; flex-direction: column; line-height: 1.1; }
.brand-nome small { font-size: 0.7rem; font-weight: 400; color: var(--testo-muted); }

.menu-toggle, .theme-toggle {
    background: none; border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--testo-soft);
    padding: var(--sp-xs) var(--sp-sm);
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}
.menu-toggle:hover, .theme-toggle:hover { background: var(--border-soft); color: var(--testo); }

/* Menu orizzontale desktop (visibile da 992px) */
.topnav {
    display: none;
    align-items: center;
    gap: 2px;
    flex: 1;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }

.topnav a {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--sp-xs) var(--sp-sm);
    color: var(--testo-soft);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
    position: relative;
}
.topnav a:hover { background: var(--border-soft); color: var(--testo); }
.topnav a.attivo { color: var(--primario); background: var(--border-soft); }
.topnav a.attivo::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 20%; right: 20%;
    height: 2px;
    background: var(--accento);
    border-radius: 2px 2px 0 0;
}
.topnav .icona { font-size: 1rem; }

@media (min-width: 992px) {
    .topnav { display: flex; }
    .menu-toggle { display: none; }
    .drawer, .drawer-overlay { display: none !important; }
}

@media (max-width: 991px) {
    .topnav { display: none; }
}

/* ============================================================
   DRAWER (menu laterale)
   ============================================================ */
.drawer {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    height: 100vh; height: 100dvh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.drawer.aperto { transform: translateX(0); }

.drawer-header {
    padding: var(--sp-xl) var(--sp-lg);
    text-align: center;
    border-bottom: 1px solid var(--border-soft);
    background: linear-gradient(135deg, var(--primario) 0%, var(--primario-light) 100%);
    color: #fff;
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-sm);
}

.drawer-tau {
    width: 56px; height: 56px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.drawer-menu { padding: var(--sp-sm) 0; flex: 1; }

.drawer-menu a {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    padding: var(--sp-md) var(--sp-lg);
    color: var(--testo-soft);
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s, padding-left 0.2s;
    border-left: 3px solid transparent;
}
.drawer-menu a:hover { background: var(--border-soft); color: var(--testo); }
.drawer-menu a.attivo {
    background: var(--border-soft);
    color: var(--primario);
    border-left-color: var(--accento);
    font-weight: 600;
}
.drawer-menu .icona { font-size: 1.2rem; width: 24px; text-align: center; }

.drawer-footer {
    padding: var(--sp-md) var(--sp-lg);
    border-top: 1px solid var(--border-soft);
    text-align: center;
    color: var(--testo-muted);
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease);
}
.drawer-overlay.visibile { opacity: 1; pointer-events: auto; }

/* ============================================================
   MAIN CONTENT — padding dinamico per banner install
   ============================================================ */
.main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: calc(var(--topbar-h) + var(--sp-lg)) var(--sp-md) calc(var(--bottomnav-h) + var(--sp-xl));
    min-height: 100vh;
    min-height: 100dvh;
    transition: padding-bottom 0.3s var(--ease);
}

/* Quando il banner install è visibile, aggiungi spazio */
body.install-visible .main {
    padding-bottom: calc(var(--bottomnav-h) + var(--sp-xl) + 80px);
}
body.install-visible .footer-legale {
    padding-bottom: calc(var(--bottomnav-h) + var(--sp-lg) + 80px);
}

@media (min-width: 768px) {
    .main {
        max-width: var(--max-w-lg);
        padding-bottom: var(--sp-xxl);
    }
    body.install-visible .main {
        padding-bottom: calc(var(--sp-xxl) + 80px);
    }
    body.install-visible .footer-legale {
        padding-bottom: calc(var(--sp-lg) + 80px);
    }
    .bottomnav { display: none !important; }
}

/* ============================================================
   BOTTOM NAVIGATION (mobile app-style)
   ============================================================ */
.bottomnav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--bg-card);
    border-top: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--testo-muted);
    font-size: 0.65rem;
    font-weight: 500;
    transition: color 0.2s;
    padding: var(--sp-xs);
    position: relative;
}
.bottomnav a .icona { font-size: 1.3rem; }
.bottomnav a.attivo { color: var(--primario); }
.bottomnav a.attivo::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 3px;
    background: var(--accento);
    border-radius: 0 0 3px 3px;
}

/* ============================================================
   HERO SECTION (Home)
   ============================================================ */
.hero {
    position: relative;
    text-align: center;
    padding: var(--sp-xxl) var(--sp-lg);
    margin: calc(-1 * var(--sp-lg)) calc(-1 * var(--sp-md)) var(--sp-xl);
    background: linear-gradient(160deg, var(--primario) 0%, #0d1f3c 60%, #0a1628 100%);
    color: #fff;
    overflow: hidden;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(212,168,67,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255,255,255,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.hero-avatar {
    width: 120px; height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accento);
    box-shadow: 0 0 0 8px rgba(212,168,67,0.2), 0 8px 32px rgba(0,0,0,0.3);
    margin: 0 auto var(--sp-lg);
    position: relative;
    z-index: 1;
    animation: float 4s ease-in-out infinite;
}

.hero-tau {
    width: 48px;
    margin: 0 auto var(--sp-md);
    opacity: 0.6;
    filter: brightness(0) invert(1);
    position: relative;
    z-index: 1;
}

.hero h1 {
    color: #fff;
    font-size: clamp(2rem, 6vw, 3rem);
    margin-bottom: var(--sp-sm);
    position: relative;
    z-index: 1;
}

.hero .sottotitolo {
    color: rgba(255,255,255,0.7);
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: 300;
    position: relative;
    z-index: 1;
}

.hero .data-oggi {
    display: inline-block;
    margin-top: var(--sp-md);
    padding: var(--sp-xs) var(--sp-lg);
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(8px);
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ============================================================
   CARD SYSTEM
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: var(--sp-lg);
    box-shadow: var(--ombra-card);
    border: 1px solid var(--border-soft);
    margin-bottom: var(--sp-md);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--ombra); }

.card-titolo {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accento);
    font-weight: 700;
    margin-bottom: var(--sp-sm);
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
}

.card h2, .card h3 { margin-bottom: var(--sp-sm); }

.card--hero {
    background: linear-gradient(135deg, var(--primario) 0%, var(--primario-light) 100%);
    color: #fff;
    border: none;
}
.card--hero h2, .card--hero h3, .card--hero p { color: #fff; }
.card--hero .card-titolo { color: var(--accento-light); }

.card--accento {
    border-left: 4px solid var(--accento);
}

/* Griglia card */
.griglia {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-md);
}
@media (min-width: 600px) {
    .griglia { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
    .griglia { grid-template-columns: repeat(3, 1fr); }
}

.griglia .card { margin-bottom: 0; }

/* ============================================================
   FRASE DEL GIORNO (card speciale)
   ============================================================ */
.frase-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--sp-xl);
    text-align: center;
    box-shadow: var(--ombra-card);
    border: 1px solid var(--border-soft);
    position: relative;
    overflow: hidden;
}
.frase-card::before {
    content: '\201C';
    position: absolute;
    top: -10px; left: var(--sp-md);
    font-size: 6rem;
    font-family: var(--font-serif);
    color: var(--accento);
    opacity: 0.15;
    line-height: 1;
}
.frase-testo {
    font-family: var(--font-serif);
    font-size: clamp(1.2rem, 3.5vw, 1.6rem);
    line-height: 1.5;
    color: var(--testo);
    font-style: italic;
    margin-bottom: var(--sp-md);
    position: relative;
    z-index: 1;
}
.frase-fonte {
    font-size: 0.85rem;
    color: var(--testo-muted);
    font-style: normal;
}
.frase-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--border-soft);
    color: var(--testo-soft);
    cursor: pointer;
    border: none;
    font-size: 1.1rem;
    transition: background 0.2s, transform 0.3s var(--ease-bounce);
}
.frase-refresh:hover { background: var(--accento); color: #fff; transform: rotate(180deg); }

/* ============================================================
 * AUDIO PLAYER (podcast)
 * ============================================================ */
.audio-player {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: var(--sp-lg);
    border: 1px solid var(--border-soft);
    margin-bottom: var(--sp-md);
}
.audio-player audio {
    width: 100%;
    margin-top: var(--sp-sm);
    border-radius: var(--radius-sm);
    outline: none;
}
.audio-player audio::-webkit-media-controls-panel {
    background: var(--bg-card);
}
.audio-titolo {
    font-weight: 600;
    font-size: 1rem;
    color: var(--testo);
}
.audio-fonte {
    font-size: 0.8rem;
    color: var(--testo-muted);
    margin-bottom: var(--sp-sm);
}

/* ============================================================
 * VIDEO (YouTube nocookie)
 * ============================================================ */
.video-ratio {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--radius-sm);
    margin-bottom: var(--sp-md);
    background: #000;
}
.video-ratio iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: 0;
}

/* ============================================================
 * BOTTONI
 * ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-xs);
    padding: var(--sp-sm) var(--sp-lg);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.2s var(--ease), box-shadow 0.2s, background 0.2s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

.btn-primario {
    background: var(--primario);
    color: #fff;
}
.btn-primario:hover { background: var(--primario-light); color: #fff; box-shadow: 0 4px 16px rgba(26,58,107,0.3); }

.btn-accento {
    background: var(--accento);
    color: #1a1a1a;
}
.btn-accento:hover { background: var(--accento-light); box-shadow: 0 4px 16px rgba(212,168,67,0.3); }

.btn-ghost {
    background: transparent;
    color: var(--primario);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primario); background: var(--border-soft); }

.btn-sm { padding: var(--sp-xs) var(--sp-md); font-size: 0.8rem; }
.btn-lg { padding: var(--sp-md) var(--sp-xl); font-size: 1rem; }

/* ============================================================
 * FORM (ricerca, input)
 * ============================================================ */
.form-gruppo {
    display: flex;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-lg);
}
.form-gruppo input[type="search"],
.form-gruppo input[type="text"],
.form-gruppo input[type="url"],
.form-gruppo textarea {
    flex: 1;
    padding: var(--sp-sm) var(--sp-md);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--testo);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-gruppo input:focus {
    border-color: var(--primario);
    box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}

/* ============================================================
 * TAG / CHIP
 * ============================================================ */
.tag {
    display: inline-block;
    padding: 2px var(--sp-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--border-soft);
    color: var(--testo-soft);
    margin: 2px;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}
.tag:hover { background: var(--primario); color: #fff; }
.tag-accento { background: rgba(212,168,67,0.15); color: var(--accento); }

/* ============================================================
 * LISTA SEMPLICE
 * ============================================================ */
.lista {
    list-style: none;
    padding: 0;
}
.lista li {
    padding: var(--sp-md);
    border-bottom: 1px solid var(--border-soft);
    transition: background 0.15s;
}
.lista li:last-child { border-bottom: none; }
.lista li:hover { background: var(--border-soft); }

/* ============================================================
 * ACCORDION / COLLAPSIBLE
 * ============================================================ */
.accordion-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    margin-bottom: var(--sp-sm);
    overflow: hidden;
}
.accordion-header {
    padding: var(--sp-md) var(--sp-lg);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
    user-select: none;
}
.accordion-header:hover { background: var(--border-soft); }
.accordion-header::after {
    content: '+';
    font-size: 1.3rem;
    color: var(--testo-muted);
    transition: transform 0.3s var(--ease);
}
.accordion-item.aperto .accordion-header::after { transform: rotate(45deg); }
.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s var(--ease), padding 0.4s var(--ease);
    padding: 0 var(--sp-lg);
    color: var(--testo-soft);
}
.accordion-item.aperto .accordion-body {
    max-height: 2000px;
    padding: 0 var(--sp-lg) var(--sp-lg);
}

/* ============================================================
 * SEPARATORI & UTILITY
 * ============================================================ */
.divider {
    height: 1px;
    background: var(--border-soft);
    margin: var(--sp-lg) 0;
    border: none;
}

.spacer-sm { height: var(--sp-sm); }
.spacer-md { height: var(--sp-md); }
.spacer-lg { height: var(--sp-lg); }

.mb-0 { margin-bottom: 0; }
.mt-lg { margin-top: var(--sp-lg); }

/* ============================================================
 * ANIMAZIONI DI ENTRATA
   ============================================================ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in {
    animation: fadeUp 0.5s var(--ease) both;
}
.fade-in:nth-child(2) { animation-delay: 0.08s; }
.fade-in:nth-child(3) { animation-delay: 0.16s; }
.fade-in:nth-child(4) { animation-delay: 0.24s; }
.fade-in:nth-child(5) { animation-delay: 0.32s; }

/* ============================================================
 * INSTALL BANNER (PWA) — con animazione chiusura
   ============================================================ */
.install-banner {
    position: fixed;
    bottom: calc(var(--bottomnav-h) + var(--sp-md));
    left: var(--sp-md); right: var(--sp-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-md) var(--sp-lg);
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    box-shadow: var(--ombra-lg);
    z-index: 90;
    animation: fadeUp 0.4s var(--ease);
    transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
/* Fix: [hidden] deve vincere su display:flex */
.install-banner[hidden] { display: none; }
.install-banner.closing {
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
}
@media (min-width: 768px) {
    .install-banner { bottom: var(--sp-md); }
}
.install-banner span { flex: 1; font-size: 0.9rem; }
.install-banner button {
    padding: var(--sp-xs) var(--sp-md);
    border-radius: var(--radius-full);
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: transform 0.15s var(--ease);
}
.install-banner button:active { transform: scale(0.95); }
#installBtn { background: var(--primario); color: #fff; }
#installBtn:hover { background: var(--primario-light); }
#installClose {
    background: transparent;
    color: var(--testo-muted);
    font-size: 1.2rem;
    padding: var(--sp-xs) var(--sp-sm);
    line-height: 1;
}
#installClose:hover { color: var(--testo); background: var(--border-soft); }

/* Link "Installa app" nel drawer (per riaprire il banner) */
.drawer-install {
    padding: var(--sp-md) var(--sp-lg);
    border-top: 1px solid var(--border-soft);
}
.drawer-install button {
    width: 100%;
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--radius-full);
    border: 1.5px solid var(--accento);
    background: transparent;
    color: var(--accento);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}
.drawer-install button:hover { background: var(--accento); color: #1a1a1a; }

/* ============================================================
 * PAGINA SEZIONI — header
   ============================================================ */
.sezione-header {
    margin-bottom: var(--sp-xl);
}
.sezione-header .sezione-icona {
    font-size: 2.5rem;
    margin-bottom: var(--sp-sm);
    display: block;
}
.sezione-header h1 { margin-bottom: var(--sp-xs); }
.sezione-header p { color: var(--testo-soft); margin-bottom: 0; }

/* ============================================================
 * MESSAGGI MEDJUGORJE
   ============================================================ */
.messaggio-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: var(--sp-lg);
    border: 1px solid var(--border-soft);
    border-left: 4px solid var(--accento);
    margin-bottom: var(--sp-md);
}
.messaggio-data {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--testo-muted);
    margin-bottom: var(--sp-xs);
}
.messaggio-testo {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--testo);
}
.messaggio-veggente {
    font-size: 0.8rem;
    color: var(--accento);
    font-weight: 600;
    margin-top: var(--sp-sm);
    text-align: right;
}

/* ============================================================
 * PAGINA RISULTATI VUOTA
   ============================================================ */
.vuoto {
    text-align: center;
    padding: var(--sp-xxl) var(--sp-lg);
    color: var(--testo-muted);
}
.vuoto .icona-grande { font-size: 3rem; margin-bottom: var(--sp-md); display: block; }

/* ============================================================
 * SCROLLBAR personalizzata (webkit)
   ============================================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--testo-muted); }

/* ============================================================
 * FOOTER LEGALE (visibile su ogni pagina)
   ============================================================ */
.footer-legale {
    border-top: 1px solid var(--border-soft);
    padding: var(--sp-md) var(--sp-lg);
    margin-top: var(--sp-xl);
    padding-bottom: calc(var(--bottomnav-h) + var(--sp-lg));
}
@media (min-width: 768px) {
    .footer-legale { padding-bottom: var(--sp-lg); }
}
.footer-legale-inner {
    max-width: var(--max-w-lg);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-sm) var(--sp-lg);
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--testo-muted);
}
.footer-legale-inner nav {
    display: flex;
    gap: var(--sp-md);
}
.footer-legale-inner a {
    color: var(--testo-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.footer-legale-inner a:hover { color: var(--primario); }

/* ============================================================
 * MESSAGGI — Layout sidebar anni + contenuto
   ============================================================ */
.messaggi-layout {
    display: flex;
    gap: var(--sp-lg);
    align-items: flex-start;
}
.messaggi-anni {
    flex-shrink: 0;
    width: 80px;
    position: sticky;
    top: calc(var(--topbar-h) + var(--sp-md));
    max-height: calc(100vh - var(--topbar-h) - var(--sp-xl));
    overflow-y: auto;
}
.messaggi-anni-titolo {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--testo-muted);
    margin-bottom: var(--sp-sm);
    text-align: center;
}
.messaggi-anni-lista {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}
.messaggi-anni-lista a {
    display: block;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--testo-soft);
    transition: background 0.15s, color 0.15s;
    text-align: center;
    min-width: 56px;
}
.messaggi-anni-lista a:hover {
    background: var(--border-soft);
    color: var(--testo);
}
.messaggi-anni-lista a.attivo {
    background: var(--primario);
    color: #fff;
    font-weight: 700;
}
.messaggi-contenuto {
    flex: 1;
    min-width: 0;
}
.messaggi-lista {
    list-style: none;
    padding: 0;
    margin: 0;
}
.messaggio-item {
    padding: var(--sp-md) 0;
    border-bottom: 1px solid var(--border-soft);
}
.messaggio-item:last-child { border-bottom: none; }
.messaggio-data {
    display: inline-block;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--testo-muted);
    margin-bottom: var(--sp-xs);
}
.messaggio-testo {
    font-size: 0.95rem;
    line-height: 1.7;
}

@media (max-width: 768px) {
    .messaggi-layout { flex-direction: column; }
    .messaggi-anni {
        position: static;
        width: 100%;
        max-height: 120px;
        border: 1px solid var(--border-soft);
        border-radius: var(--radius);
        padding: var(--sp-sm);
    }
    .messaggi-anni-lista {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ============================================================
 * OPUSCOLO FRASI — layout stampabile (x frasi per x giorni)
   ============================================================ */
.opuscolo-azioni {
    text-align: center;
    margin-bottom: var(--sp-lg);
}
.opuscolo-pagina {
    max-width: 600px;
    margin: 0 auto var(--sp-xl);
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    page-break-after: always;
}
.opuscolo-header {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    padding: var(--sp-lg);
    background: linear-gradient(135deg, var(--primario) 0%, var(--primario-light) 100%);
    color: #fff;
}
.opuscolo-header img {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    object-fit: cover;
}
.opuscolo-header .opuscolo-titolo {
    font-weight: 700;
    font-size: 1rem;
}
.opuscolo-header .opuscolo-data {
    font-size: 0.85rem;
    opacity: 0.9;
}
.opuscolo-corpo {
    padding: var(--sp-xl) var(--sp-lg);
    font-size: 1.15rem;
    line-height: 1.8;
    text-align: center;
}
.opuscolo-corpo .opuscolo-giorno {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--testo-muted);
    margin-bottom: var(--sp-md);
}
.opuscolo-copertina {
    text-align: center;
    padding: var(--sp-xxl) var(--sp-lg);
}
.opuscolo-copertina img {
    width: 80px; height: 80px;
    border-radius: 50%;
    border: 3px solid var(--accento);
    margin-bottom: var(--sp-md);
}
.opuscolo-copertina h2 {
    color: var(--primario);
    margin-bottom: var(--sp-xs);
}
.opuscolo-copertina p {
    color: var(--testo-muted);
    font-style: italic;
}
.opuscolo-finale {
    text-align: center;
    padding: var(--sp-xl) var(--sp-lg);
}
.opuscolo-finale h3 {
    margin-bottom: var(--sp-md);
    color: var(--primario);
}
.opuscolo-finale ul {
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
    list-style: none;
    padding: 0;
}
.opuscolo-finale li {
    padding: var(--sp-xs) 0;
    border-bottom: 1px solid var(--border-soft);
}
.opuscolo-finale li::before {
    content: '\2022';
    color: var(--accento);
    margin-right: var(--sp-sm);
}

@media print {
    .opuscolo-pagina {
        border: none;
        border-radius: 0;
        page-break-after: always;
    }
    .opuscolo-azioni, .sezione-header { display: none !important; }
}

/* ============================================================
 * PLAYLIST PODCAST — episodi con tasto play
   ============================================================ */
.playlist {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.playlist-item {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}
.playlist-item:hover {
    background: var(--border-soft);
}
.playlist-item.playing {
    background: var(--primario);
    color: #fff;
    border-color: var(--primario);
}
.playlist-item.playing .playlist-info small {
    color: rgba(255,255,255,0.8);
}
.play-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--border-soft);
    transition: background 0.15s;
}
.playlist-item:hover .play-icon {
    background: var(--accento);
}
.playlist-item.playing .play-icon {
    background: rgba(255,255,255,0.2);
}
.playlist-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.playlist-info strong {
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.playlist-info small {
    font-size: 0.75rem;
    color: var(--testo-muted);
}

/* ============================================================
 * ALEXA — pagina skill Amazon
   ============================================================ */
.pagina-alexa .card ul.lista li {
    padding: var(--sp-xs) 0;
    border-bottom: 1px solid var(--border-soft);
}
.pagina-alexa .card ul.lista li:last-child {
    border-bottom: none;
}
.pagina-alexa .card ul.lista strong {
    color: var(--primario);
    font-family: monospace;
    font-size: 0.85rem;
}

/* ============================================================
 * SANTI — Calendario
   ============================================================ */
.santi-calendario {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--sp-md);
}
.santi-mese {
    padding: var(--sp-sm);
}
.santi-mese-titolo {
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primario);
    margin-bottom: var(--sp-xs);
    text-align: center;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: var(--sp-xs);
}
.santi-giorni {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
}
.santi-giorno {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--testo-soft);
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.santi-giorno:hover {
    background: var(--border-soft);
    color: var(--testo);
}
.santi-giorno.oggi {
    background: var(--accento);
    color: #1a1a1a;
    font-weight: 700;
}
.santi-giorno.selezionato {
    background: var(--primario);
    color: #fff;
    font-weight: 700;
}
.santi-giorno.vuoto {
    opacity: 0.3;
    pointer-events: none;
}

/* ============================================================
 * TESTI E LETTURE — contenuti da file dati
   ============================================================ */
.testo-letto {
    line-height: 1.8;
    font-size: 0.95rem;
    color: var(--testo);
}
.testo-letto p {
    margin-bottom: var(--sp-sm);
}
.lista-link {
    list-style: none;
    padding: 0;
    margin: 0;
}
.lista-link li {
    padding: var(--sp-xs) 0;
    border-bottom: 1px solid var(--border-soft);
}
.lista-link li:last-child {
    border-bottom: none;
}
.lista-link a {
    color: var(--primario);
    text-decoration: none;
    font-size: 0.9rem;
}
.lista-link a:hover {
    text-decoration: underline;
}

/* ============================================================
 * STAMPA
   ============================================================ */
@media print {
    .topbar, .bottomnav, .drawer, .drawer-overlay,
    .install-banner, .frase-refresh, .menu-toggle, .theme-toggle { display: none !important; }
    .main { padding: 0; max-width: 100%; }
    body { background: #fff; color: #000; }
    .card, .frase-card, .messaggio-card { box-shadow: none; border: 1px solid #ddd; }
}
