/* ==========================================================================
   Quarrata Meteo – Frontend Stylesheet
   ========================================================================== */

:root {
    --qm-maincolor:        #b61a0e;
    --qm-maincolor-dark:   #800800;
    --qm-yellow:       #f5c518;
    --qm-orange:       #f97316;
    --qm-red:          #dc2626;
    --qm-verde:        #22c55e;
    --qm-gray:         #9ca3af;
    --qm-white:        #ffffff;
    --qm-text-muted:   rgba(255,255,255,.72);
    --qm-radius:       14px;
    --qm-radius-sm:    8px;
}

.qm-main *,
.qm-sub-wrap *,
.qm-sub { box-sizing: border-box; margin: 0; padding: 0; }

/* --------------------------------------------------------------------------
   No-data placeholder
-------------------------------------------------------------------------- */
.qm-no-data {
    background: var(--qm-maincolor);
    border-radius: var(--qm-radius);
    padding: 40px 32px;
    text-align: center;
    color: var(--qm-text-muted);
}
.qm-no-data strong { display: block; color: var(--qm-white); font-size: 1.25rem; margin-bottom: 8px; }

.qm-no-data-sub {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: var(--qm-radius);
    padding: 32px;
    color: #6b7280;
    text-align: center;
}

.qm-nd       { color: var(--qm-text-muted); }
.qm-nd-msg   { color: var(--qm-text-muted); font-size: .9em; }

/* ==========================================================================
   MAIN SHORTCODE
   ========================================================================== */

.qm-main {
    border-radius: var(--qm-radius);
    overflow: hidden;
    width: 100%;
}

/* --- Sezione 1: Meteo --------------------------------------------------- */
.qm-meteo-section {
    background: var(--qm-maincolor);
    padding: 36px 44px 32px;
    color: var(--qm-white);
}

.qm-section-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -.5px;
    margin-bottom: 28px;
    color: var(--qm-white);
}

.qm-meteo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 44px;
    align-items: start;
}

.qm-col-label {
    font-size: .95em;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--qm-white);
    letter-spacing: .02em;
}

/* Today hero */
.qm-today-hero {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 18px;
}

.qm-today-icon-wrap { flex-shrink: 0; }

.qm-weather-icon-lg {
    width: 84px;
    height: 84px;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,.28));
}

.qm-today-date {
    font-size: 1.28em;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--qm-white);
}

.qm-today-details {
    list-style: none;
    font-size: .91em;
    color: var(--qm-text-muted);
}
.qm-today-details li + li { margin-top: 5px; }
.qm-today-details strong { color: var(--qm-white); font-weight: 600; }

/* Forecast cards */
.qm-forecast-cards {
    display: flex;
    gap: 14px;
}

.qm-fc-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.qm-weather-icon-sm {
    width: 54px;
    height: 54px;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,.2));
}

.qm-fc-day  { font-size: .88em; font-weight: 600; color: var(--qm-white); text-align: center; }
.qm-fc-temp { font-size: .82em; color: var(--qm-text-muted); text-align: center; }

.qm-forecast-credit {
    margin-top: 16px;
    font-size: .73em;
    color: var(--qm-text-muted);
    text-align: right;
}
.qm-forecast-credit a { color: var(--qm-text-muted); text-decoration: underline; text-underline-offset: 2px; }

/* --- Sezione 2: Bollettino Allerta ------------------------------------- */
.qm-allerta-section {
    background: var(--qm-maincolor-dark);
    padding: 36px 44px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 28px;
    align-items: center;
    color: var(--qm-white);
}

.qm-allerta-heading {
    font-size: 1.6em;
    font-weight: 800;
    color: var(--qm-white);
    line-height: 1.25;
    letter-spacing: -.3px;
}

.qm-bell-svg  { width: 210px; height: auto; display: block; }

.qm-allerta-date { font-size: .88em; color: var(--qm-text-muted); margin-bottom: 10px; }
.qm-allerta-date strong { color: var(--qm-white); }

.qm-allerta-level-label {
    font-size: 1.12em;
    font-weight: 500;
    color: var(--qm-white);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.qm-level-badge {
    display: inline-block;
    padding: 4px 16px;
    border-radius: 5px;
    font-size: 1em;
    font-weight: 800;
    letter-spacing: .06em;
}

.qm-allerta-criticita { font-size: 1em; font-weight: 500; margin-bottom: 20px; }

.qm-btn-dettagli {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 2px solid rgba(255,255,255,.55);
    color: var(--qm-white);
    padding: 10px 22px;
    border-radius: 6px;
    font-size: .94em;
    font-weight: 600;
    text-decoration: none;
    transition: background .18s, border-color .18s;
    white-space: nowrap;
}
.qm-btn-dettagli:hover { background: rgba(255,255,255,.12); border-color: var(--qm-white); color: var(--qm-white); }

/* ==========================================================================
   SUB SHORTCODE
   ========================================================================== */

.qm-sub-wrap {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 28px;
    align-items: flex-start;
    width: 100%;
    color: #1a1a1a;
}

/* Il browser (adoption agency algorithm HTML5) può inserire un <code> spurio
   come primo figlio se lo shortcode è avvolto in <code> nell'editor della pagina.
   display:contents lo rende trasparente al layout flex. */
.qm-sub-wrap > code {
    display: contents;
}

/* --------------------------------------------------------------------------
   Sidebar column (wrapper per lo sticky)
-------------------------------------------------------------------------- */
.qm-sub-sidebar {
    flex: 0 0 220px !important;
    width: 220px !important;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Sidebar nav
-------------------------------------------------------------------------- */
.qm-sub-nav {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: var(--qm-radius);
    overflow: hidden;
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.qm-sub-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    background: #b61a0e;
    color: #fff;
    font-size: .82em;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.qm-nav-toggle {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: transform .2s;
}
.qm-nav-toggle svg { transition: transform .2s; }
.qm-nav-toggle.qm-nav-open svg { transform: rotate(180deg); }

.qm-nav-list {
    list-style: none;
    padding: 6px 0;
    transition: max-height .25s ease, opacity .2s;
    max-height: 600px;
    opacity: 1;
    overflow: hidden;
}
.qm-nav-list.qm-nav-collapsed { max-height: 0; opacity: 0; }

.qm-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: .88em;
    color: #374151;
    text-decoration: none;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.qm-nav-link:hover { background: #f3f4f6; color: #111827; }
.qm-nav-link--active {
    background: #f0f9f4;
    color: var(--qm-maincolor);
    border-left-color: var(--qm-maincolor);
    font-weight: 600;
}

.qm-nav-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,.1);
}

/* --------------------------------------------------------------------------
   Content area
-------------------------------------------------------------------------- */
.qm-sub-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 24px; }

.qm-sub-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: var(--qm-radius);
    padding: 28px 32px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    scroll-margin-top: 80px;
}

.qm-sub-h2 {
    font-size: 1.4em;
    font-weight: 800;
    color: #111827;
    margin-bottom: 20px;
    letter-spacing: -.3px;
}

/* Max allerta */
.qm-max-body {
    display: flex;
    align-items: center;
    gap: 32px;
}
.qm-max-bell .qm-bell-svg { width: 190px; height: auto; }

.qm-badge-xl {
    display: inline-block;
    padding: 10px 32px;
    border-radius: 6px;
    font-size: 1.6em;
    font-weight: 900;
    letter-spacing: .08em;
    margin-bottom: 10px;
}
.qm-max-criticita { font-size: 1.05em; color: #374151; font-weight: 500; }

/* Risk table */
.qm-table-wrap {
    overflow-x: auto;
    border-radius: var(--qm-radius-sm);
    border: 1px solid #e5e7eb;
}

.qm-risk-table { width: 100%; border-collapse: collapse; font-size: .94em; }

.qm-risk-table thead tr { background: #b61a0e; color: #fff; }
.qm-th-label, .qm-th-date {
    padding: 13px 20px;
    font-weight: 700;
    text-align: left;
    letter-spacing: .02em;
}
.qm-th-date { text-align: center; min-width: 110px; }

.qm-td-label {
    padding: 11px 20px;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
    font-weight: 500;
}
.qm-risk-table tbody tr:last-child .qm-td-label,
.qm-risk-table tbody tr:last-child .qm-td-level { border-bottom: none; }

.qm-td-level {
    padding: 11px 20px;
    border-bottom: 1px solid rgba(255,255,255,.2);
    text-align: center;
    font-weight: 700;
    font-size: .86em;
    letter-spacing: .05em;
}

.qm-td-na { background: #f3f4f6 !important; color: #9ca3af !important; font-weight: 400; font-size: .84em; }

/* Legenda */
.qm-legenda { margin-top: 20px; padding-top: 16px; border-top: 1px solid #f0f0f0; }
.qm-legenda-title {
    font-size: .78em; font-weight: 700; color: var(--qm-maincolor);
    text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px;
}
.qm-legenda-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.qm-legenda-list li {
    display: flex; align-items: center; gap: 10px;
    font-size: .86em; color: #374151;
}
.qm-legenda-dot {
    width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0;
    border: 1px solid rgba(0,0,0,.1);
}

/* Emissione */
.qm-emissione-dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 9px 20px;
    font-size: .94em;
}
.qm-emissione-dl dt { color: #6b7280; font-weight: 600; }
.qm-emissione-dl dd { color: #111827; }

.qm-text-body { font-size: .94em; color: #374151; line-height: 1.6; }

.qm-link-sir {
    display: inline-block;
    margin-top: 14px;
    color: var(--qm-maincolor);
    font-weight: 600;
    font-size: .94em;
    text-decoration: none;
}
.qm-link-sir:hover { text-decoration: underline; }

/* ==========================================================================
   RESPONSIVE – TABLET (≤ 900px)
   ========================================================================== */

@media (max-width: 900px) {
    .qm-meteo-section { padding: 28px 28px 24px; }
    .qm-allerta-section { padding: 28px 28px; }
    .qm-meteo-grid { gap: 28px; }
    .qm-bell-svg { width: 170px; }
}

/* ==========================================================================
   RESPONSIVE – MOBILE LARGE (≤ 768px)
   ========================================================================== */

@media (max-width: 768px) {

    /* --- Main ----------------------------------------------------------- */
    .qm-meteo-section { padding: 22px 18px 20px; }
    .qm-section-title { font-size: 1.6em; margin-bottom: 20px; }
    .qm-meteo-grid    { grid-template-columns: 1fr; gap: 22px; }
    .qm-forecast-cards { gap: 8px; }

    .qm-allerta-section {
        padding: 24px 18px;
        grid-template-columns: 1fr;
        text-align: center;
        gap: 16px;
    }
    .qm-allerta-icon-col { display: flex; justify-content: center; }
    .qm-bell-svg { width: 180px; }
    .qm-allerta-heading { font-size: 1.35em; }
    .qm-allerta-level-label { justify-content: center; }
    .qm-btn-dettagli { width: 100%; justify-content: center; }

    /* --- Sub: adattamenti tipografici e padding (layout rimane a 2 colonne) */
    .qm-sub-card { padding: 20px 18px; }
    .qm-sub-h2   { font-size: 1.2em; }
    .qm-max-body { gap: 20px; }
    .qm-max-bell .qm-bell-svg { width: 150px; }
    .qm-badge-xl { font-size: 1.3em; padding: 8px 22px; }
}

/* Sub: colonna singola solo su schermi stretti (sidebar 220px + gap 28px + min content ~300px) */
@media (max-width: 580px) {
    .qm-sub-wrap {
        flex-direction: column !important;
        gap: 16px;
    }
    .qm-sub-sidebar {
        flex: none !important;
        width: 100% !important;
    }
    .qm-sub-nav {
        position: static;
        max-height: none;
        overflow: visible;
    }
}

/* ==========================================================================
   RESPONSIVE – MOBILE SMALL (≤ 480px)
   ========================================================================== */

@media (max-width: 480px) {
    .qm-meteo-section { padding: 18px 14px 16px; }
    .qm-allerta-section { padding: 20px 14px; }
    .qm-section-title { font-size: 1.4em; }

    .qm-today-hero { flex-direction: column; align-items: flex-start; gap: 12px; }
    .qm-weather-icon-lg { width: 64px; height: 64px; }
    .qm-today-date { font-size: 1.1em; }

    .qm-forecast-cards { flex-wrap: wrap; }
    .qm-fc-card { min-width: calc(33% - 6px); }
    .qm-weather-icon-sm { width: 42px; height: 42px; }

    .qm-bell-svg { width: 150px; }
    .qm-allerta-heading { font-size: 1.2em; }

    .qm-sub-card { padding: 16px 12px; }
    .qm-max-body { flex-direction: column; align-items: flex-start; gap: 14px; }
    .qm-max-bell .qm-bell-svg { width: 130px; }
    .qm-badge-xl { font-size: 1.1em; padding: 7px 18px; }
    .qm-max-criticita { font-size: .95em; }

    .qm-emissione-dl { grid-template-columns: 1fr; gap: 3px; }
    .qm-emissione-dl dt { margin-top: 8px; }

    .qm-th-label, .qm-th-date { padding: 10px 12px; }
    .qm-td-label, .qm-td-level { padding: 9px 12px; }

    .qm-nav-link { font-size: .82em; padding: 9px 10px; gap: 7px; }
    .qm-nav-marker { width: 8px; height: 8px; }
}



/** Nascondo l'index perché c'è già nella pagina usando il template giusto --Chiara **/
.qm-sub-sidebar {
  display: none;
}