/* s4-meteo — styles front
   Les icônes utilisent currentColor : régler la couleur via .s4m__icon { color: … }.
   Variables surchargeables depuis le thème (s4-meteo/s4-meteo.css). */

.s4m {
    --s4m-icon-size: 28px;   /* taille de l'icône (layout row) */
    --s4m-gap: 8px;          /* espace icône / texte */
    --s4m-card-gap: 14px;    /* espace entre les cartes */
    --s4m-muted: inherit;    /* couleur des infos secondaires */
    margin: .5em 0;
}

.s4m__title {
    margin: 0 0 .5em;
    font-size: 1.05rem;
}

.s4m__grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s4m-card-gap);
    align-items: center;
}

/* Une ville */
.s4m__card {
    display: inline-flex;
    align-items: center;
    gap: var(--s4m-gap);
}

.s4m__icon {
    flex: 0 0 auto;
    width: var(--s4m-icon-size);
    height: var(--s4m-icon-size);
    line-height: 0;
    color: inherit; /* l'icône (currentColor) hérite de la couleur du texte */
}

.s4m__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.s4m__data {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.s4m__temp {
    font-weight: 600;
}

.s4m__city {
    font-weight: 600;
}

.s4m__label,
.s4m__meta {
    color: var(--s4m-muted);
    opacity: .85;
    font-size: .9em;
}

.s4m__meta {
    display: inline-flex;
    gap: 8px;
}

/* Données périmées */
.s4m__card.is-stale {
    opacity: .6;
}

/* ---- Layout "card" : bloc vertical encadré ---- */
.s4m--card {
    --s4m-icon-size: 52px;
}

.s4m--card .s4m__card {
    padding: 12px 16px;
    border: 1px solid #e3e8ef;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}

.s4m--card .s4m__data {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.s4m--card .s4m__temp {
    font-size: 1.5rem;
}

/* ---- Layout "list" : cartes empilées pleine largeur ---- */
.s4m--list {
    --s4m-icon-size: 40px;
}

.s4m--list .s4m__grid {
    flex-direction: column;
    align-items: stretch;
}

.s4m--list .s4m__card {
    width: 100%;
}

/* ---- Plusieurs villes : bouton (ville principale) + liste déroulante ou fenêtre ---- */
.s4m--switch,
.s4m-popup {
    --s4m-surface: #fff;          /* fond des panneaux */
    --s4m-text: #1f2933;          /* texte des panneaux */
    --s4m-accent: #1f2933;        /* titre, jour courant */
    --s4m-border: rgba(0, 0, 0, .1);
    --s4m-radius: 10px;
    --s4m-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    --s4m-today-bg: rgba(0, 0, 0, .03);
    --s4m-backdrop: rgba(0, 0, 0, .45);
}

.s4m--switch {
    position: relative;
    display: inline-block;
    margin: 0;
}

.s4m__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.s4m__chevron {
    flex: 0 0 auto;
    transition: transform .25s ease;
}

.s4m--dropdown.is-open .s4m__chevron {
    transform: rotate(180deg);
}

.s4m__dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 100;
    min-width: 200px;
    padding: 6px 0;
    background: var(--s4m-surface);
    color: var(--s4m-text);
    border: 1px solid var(--s4m-border);
    border-radius: var(--s4m-radius);
    box-shadow: var(--s4m-shadow);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .25s ease, transform .25s ease;
}

.s4m__dropdown.is-open {
    opacity: 1;
    transform: none;
}

.s4m__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.s4m__list-item {
    margin: 0;
    padding: 8px 14px;
}

.s4m__list-item + .s4m__list-item {
    border-top: 1px solid var(--s4m-border);
}

.s4m__list .s4m__card {
    display: flex;
    width: 100%;
}

.s4m__list .s4m__data {
    flex: 1;
    flex-direction: row-reverse;
    justify-content: space-between;
}

.s4m__credit,
.s4m-popup__credit {
    margin: 0;
    font-size: 11px;
    opacity: .6;
}

.s4m__credit {
    padding: 6px 14px 2px;
}

/* ---- Fenêtre des prévisions ---- */
.s4m-popup {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.s4m-popup[hidden] {
    display: none;
}

.s4m-popup__backdrop {
    position: absolute;
    inset: 0;
    background: var(--s4m-backdrop);
    opacity: 0;
    transition: opacity .25s ease;
}

.s4m-popup__dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 820px;
    max-height: 100%;
    overflow: hidden;
    padding: 20px 24px;
    background: var(--s4m-surface);
    color: var(--s4m-text);
    border-radius: var(--s4m-radius);
    box-shadow: var(--s4m-shadow);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .25s ease, transform .25s ease;
}

.s4m-popup.is-open .s4m-popup__backdrop {
    opacity: 1;
}

.s4m-popup.is-open .s4m-popup__dialog {
    opacity: 1;
    transform: none;
}

.s4m-popup__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.s4m-popup__title {
    margin: 0;
    font-size: 1.4rem;
    color: var(--s4m-accent);
}

.s4m-popup__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid var(--s4m-border);
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.s4m-popup__close:hover,
.s4m-popup__close:focus-visible {
    background: var(--s4m-today-bg);
}

.s4m-popup__body {
    overflow: auto;
    overscroll-behavior: contain;
}

.s4m-forecast {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.s4m-forecast th,
.s4m-forecast td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--s4m-border);
    text-align: center;
    vertical-align: middle;
}

.s4m-forecast thead th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.s4m-forecast__day.is-today {
    color: var(--s4m-accent);
}

.s4m-forecast .is-today {
    background: var(--s4m-today-bg);
}

.s4m-forecast__city {
    text-align: left !important;
    white-space: nowrap;
    font-weight: 500;
}

.s4m-forecast tbody th.s4m-forecast__city {
    position: sticky;
    left: 0;
    background: var(--s4m-surface);
}

.s4m-forecast__slots {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.s4m-slot {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 52px;
}

.s4m-slot .s4m__icon {
    --s4m-icon-size: 26px;
}

.s4m-slot__temp {
    font-weight: 600;
}

.s4m-slot__period {
    font-size: 10px;
    opacity: .6;
}

.s4m-popup .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.s4m-popup__credit {
    text-align: right;
}

html.s4m-locked {
    overflow: hidden;
}

@media (max-width: 640px) {
    .s4m-popup {
        padding: 12px;
    }

    .s4m-popup__dialog {
        padding: 16px;
    }

    .s4m-forecast__slots {
        gap: 6px;
    }

    .s4m-slot {
        min-width: 44px;
    }
}
