/**
 * tpl_vco24 - Template CSS
 * Layout: CSS Grid, responsive scaling (no reflow)
 * Sfondo: tema colore configurabile via parametro backend
 */

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body.site {
    background-color: var(--theme-bg);
    color: var(--theme-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

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

a {
    color: var(--theme-text);
    text-decoration: none;
}

a:hover {
    opacity: 0.85;
}

/* ============================================================
   PAGE WRAPPER
   ============================================================ */
.page-wrapper {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--gap);
}

/* ============================================================
   FASCIA (sezione generica)
   ============================================================ */
.fascia {
    margin-bottom: var(--gap);
}

.fascia-inner {
    width: 100%;
}

/* ============================================================
   FASCIA 1 — TG Live (2 colonne uguali)
   ============================================================ */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
}

.position-tg-vco,
.position-tg-novara {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    overflow: hidden;
    min-height: 80px;
}

/* Iframe YouTube responsivo nelle posizioni TG */
.position-tg-vco iframe,
.position-tg-novara iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    display: block;
    border: 0;
}

/* Se il modulo wrappa in un div, forza full-width */
.position-tg-vco > div,
.position-tg-novara > div {
    width: 100%;
}

/* ============================================================
   FASCIA 2 — Header (logo | search | banner)
   ============================================================ */
.grid-header {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: var(--gap);
    align-items: center;
}

.position-logo {
    min-width: 120px;
}

.site-logo-fallback {
    display: flex;
    align-items: center;
}

.site-name {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.position-search-links {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.position-banner-header {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   FASCIA 3 — Hero Slideshow (full-width)
   ============================================================ */
.fascia-hero .fascia-inner {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    min-height: 300px;
    overflow: hidden;
    position: relative;
}

/* ============================================================
   FASCIA 4 — News Flash (2 colonne: sinistra 2 righe, destra foto)
   ============================================================ */
.grid-newsflash {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--gap);
}

.newsflash-left {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

.position-sommario-tg,
.position-meteo {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    overflow: hidden;
    flex: 1;
}

/* Video embed responsivo dentro sommario-tg e meteo */
.position-sommario-tg iframe,
.position-sommario-tg video,
.position-meteo iframe,
.position-meteo video {
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    display: block;
    object-fit: cover;
    border: 0;
}

/* Quando il contenuto è un modulo custom (non video diretto) */
.position-sommario-tg > div,
.position-meteo > div {
    width: 100%;
    height: 100%;
}

/* Wrapper responsivo per iframe video (usato dai moduli) */
.position-sommario-tg .video-wrapper,
.position-meteo .video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
}

.position-sommario-tg .video-wrapper iframe,
.position-meteo .video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.position-foto-notizie {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 170px;
}

/* ============================================================
   FASCE 5-7 — Macro sezione con sidebar
   ============================================================ */
.grid-macro {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--gap);
}

.macro-main {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

.position-banner-ads-main {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.position-provincia {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 200px;
}

.position-foto-precedenti-1 {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 120px;
}

/* Sidebar: reel + funebri + pdf impilati */
.macro-sidebar {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

.position-reel-embed {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    padding: var(--gap-sm);
    min-height: 300px;
    flex: 1;
}

.position-funebri,
.position-pdf {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   FASCIA 8 & 12 — Redazionale + Banner (proporzioni variabili)
   ============================================================ */
.grid-redazionale {
    display: grid;
    grid-template-columns: var(--redazionale-columns);
    gap: var(--gap);
}

.position-redazionale {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap);
    min-height: 100px;
}

/* Stile differenziato per articolo a pagamento */
.position-redazionale::before {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
    margin-bottom: var(--gap-sm);
}

.position-banner-agenzie {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   FASCIA 9 — Foto articoli precedenti (full-width)
   ============================================================ */
.fascia-archivio .fascia-inner {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 120px;
}

/* ============================================================
   FASCIA 10 — Categorie (full-width)
   ============================================================ */
.fascia-categorie .fascia-inner {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap);
    min-height: 60px;
}

/* ============================================================
   FASCIA 11 & 13 — Banner Classico (full-width)
   ============================================================ */
.fascia-banner .fascia-inner {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: var(--gap-sm);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   CONTENUTO ARTICOLI (solo pagine interne, nascosto in homepage)
   ============================================================ */
.fascia-content .fascia-inner {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    padding: var(--gap);
}

/* ============================================================
   FOOTER
   ============================================================ */
.fascia-footer {
    margin-top: var(--gap);
    padding-top: var(--gap);
    border-top: 1px solid var(--theme-border);
}

.footer-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--theme-text-muted);
}

/* ============================================================
   RESPONSIVE — Scaling proporzionale (layout identico)
   Il layout NON cambia struttura, i contenuti si rimpiccioliscono.
   ============================================================ */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --content-max-width: 100%;
        --gap: 12px;
        --gap-sm: 8px;
    }

    html {
        font-size: 14px;
    }

    .macro-sidebar {
        width: 180px;
    }

    .position-reel-embed {
        min-height: 240px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --gap: 8px;
        --gap-sm: 6px;
    }

    html {
        font-size: 12px;
    }

    .page-wrapper {
        padding: var(--gap-sm);
    }

    .macro-sidebar {
        width: 140px;
    }

    .position-reel-embed {
        min-height: 180px;
    }

    .site-name {
        font-size: 1.2rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    html {
        font-size: 10px;
    }

    .macro-sidebar {
        width: 110px;
    }

    .position-reel-embed {
        min-height: 140px;
    }

    .fascia-hero .fascia-inner {
        min-height: 160px;
    }
}

/* ============================================================
   PLACEHOLDER LABELS (per debug / anteprima vuota)
   Rimossi in produzione
   ============================================================ */
[class^="position-"]:empty::after {
    content: attr(data-position);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: inherit;
    font-size: 0.75rem;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}