/* =========================================================================
   meteo.css — page des météogrammes (meteo.html)
   Version compacte v2 : un bloc de prévisions complet tient dans un écran PC à 100 %.
   ========================================================================= */

body {
    --color-page: #3d3d3d;
    --color-surface: #4a4a4a;
    --color-surface-inset: #2c2c2c;
    --color-border: #666;
    --color-text-dim: #e0e0e0;
}

/* -------------------------------------------------------------------------
   Structure générale
   ------------------------------------------------------------------------- */

.container {
    width: min(calc(100% - 24px), 960px);
    margin: 6px auto 18px;
    padding: 10px 12px 18px;
    background: var(--color-surface);
    border-radius: 9px;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
}

.page-header {
    margin-bottom: 10px;
    color: var(--color-text-dim);
    text-align: center;
}

.page-header h1 {
    margin: 0 0 8px;
    color: #eee;
    font-size: 1.45rem;
    line-height: 1.15;
}

.location-picker {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: min(100%, 720px);
    margin: 0 auto;
}

/* -------------------------------------------------------------------------
   Contrôles
   ------------------------------------------------------------------------- */

.location-select {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 32px;
    margin: 0;
    padding: 6px 8px;
    background: var(--color-surface-inset);
    color: var(--color-text-dim);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    font-size: 0.84rem;
}

.location-select:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.btn {
    min-height: 34px;
    border: none;
    border-radius: var(--radius-control);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    transition:
        background 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.btn--map {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 6px 11px;
    white-space: nowrap;
    background: var(--color-primary);
    font-size: 0.74rem;
}

.btn--map:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 7px rgba(0, 0, 0, 0.22);
}

.btn--refresh {
    display: block;
    min-height: 36px;
    margin: 16px auto;
    padding: 7px 20px;
    background: var(--color-primary);
    font-size: 0.74rem;
    font-weight: 400;
}

.btn--refresh:hover {
    background: var(--color-primary-hover);
}

/* -------------------------------------------------------------------------
   États : chargement, erreur, alerte
   ------------------------------------------------------------------------- */

.loading {
    padding: 30px 10px;
    color: var(--color-text-dim);
    font-size: 0.84rem;
    text-align: center;
}

.loading[hidden],
.error-message[hidden],
.snow-alert[hidden],
.meteogram[hidden] {
    display: none;
}

.loading__spinner {
    width: 38px;
    height: 38px;
    margin: 14px auto;
    border: 3px solid #555;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-message {
    margin: 12px 0;
    padding: 12px 14px;
    background: var(--color-danger);
    border-radius: var(--radius-control);
    color: #fff;
    font-size: 0.88rem;
}

.error-message h2 {
    margin: 0 0 7px;
    font-size: 0.9rem;
}

.error-message p {
    margin: 0;
}

.error-message__detail {
    margin-top: 7px;
    font-size: 0.74rem;
}

.snow-alert {
    margin: 12px 0;
    padding: 10px 14px;
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
    border: 2px solid #fff;
    border-radius: var(--radius-card);
    box-shadow: 0 0 14px rgba(255, 68, 68, 0.55);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    animation: blink 1s infinite;
}

.snow-alert__period {
    font-size: 0.85em;
}

@keyframes blink {
    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0.35;
    }
}

/* -------------------------------------------------------------------------
   Météogrammes
   ------------------------------------------------------------------------- */

.meteogram {
    width: 100%;
}

.meteogram__title {
    margin: 10px 0 6px;
    padding: 6px 8px;
    overflow-wrap: anywhere;
    background: var(--color-surface-inset);
    border-radius: var(--radius-control);
    color: var(--color-text-dim);
    font-size: 0.74rem;
    line-height: 1.35;
    text-align: left;
}

.meteogram__panel {
    position: relative;
    width: 100%;
    margin-bottom: 10px;
    overflow: hidden;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.28);
}

/*
   Graphique des précipitations.
   Hauteur volontairement limitée pour éviter une page géante sur PC.
*/
.meteogram__precip {
    position: relative;
    width: 100%;
    height: 135px;
    padding: 3px 5px;
    overflow: hidden;
    background: #fff;
    border-bottom: 1px solid #ddd;
}

.meteogram__precip canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Icônes météo entre les deux graphiques */
.meteogram__icons {
    display: flex;
    align-items: center;
    justify-content: space-around;
    min-height: 32px;
    padding: 3px 24px;
    overflow: hidden;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.meteogram__icon {
    flex: 1 1 0;
    min-width: 0;
    font-size: 0.9rem;
    line-height: 1;
    text-align: center;
}

/* Graphique température / vent / autres données */
.meteogram__canvas-wrap {
    position: relative;
    width: 100%;
    height: 175px;
    overflow: hidden;
    background: #fff;
}

.meteogram__canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

canvas {
    max-width: 100%;
}

/* -------------------------------------------------------------------------
   Encart partenaire
   ------------------------------------------------------------------------- */

.partner {
    margin: 10px 0;
    padding: 8px 10px;
    background: #bdc3c7;
    border-radius: var(--radius-control);
    color: #2c3e50;
    text-align: center;
}

.partner p {
    margin: 0;
}

.partner__label {
    margin-bottom: 4px;
    font-size: 0.74rem;
}

.partner__name {
    font-size: 0.9rem;
    font-weight: 700;
}

.partner__models {
    margin-top: 3px;
    font-size: 0.74rem;
}

/* -------------------------------------------------------------------------
   Pied de page
   ------------------------------------------------------------------------- */

.site-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
    color: #bdc3c7;
    font-size: 0.68rem;
    line-height: 1.4;
    text-align: center;
}

.site-footer p {
    margin: 0;
}

.site-footer p + p {
    margin-top: 3px;
}

.site-footer__timestamp {
    margin-top: 6px;
    font-size: 0.7rem;
}

/* -------------------------------------------------------------------------
   Sélecteur cartographique
   ------------------------------------------------------------------------- */

.map-dialog {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.85);
    animation: fade-in 0.25s ease;
}

.map-dialog[hidden] {
    display: none;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.map-dialog__panel {
    display: flex;
    flex-direction: column;
    width: min(100%, 760px);
    max-height: 88vh;
    padding: 14px;
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
}

.map-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.map-dialog__title {
    color: #2c3e50;
    font-size: 0.9rem;
    font-weight: 700;
}

.map-dialog__close {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--color-danger);
    border-radius: 50%;
    font-size: 0.9rem;
    line-height: 1;
}

.map-dialog__close:hover {
    background: var(--color-danger-hover);
}

.map-dialog__map {
    width: 100%;
    height: min(55vh, 440px);
    min-height: 260px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.map-dialog__info {
    margin-top: 9px;
    padding: 9px;
    background: #ecf0f1;
    border-radius: 7px;
    color: #34495e;
    font-size: 0.8rem;
    line-height: 1.35;
    text-align: center;
}

.map-dialog__info .btn--map {
    margin-top: 7px;
}

/* Repères de carte */
.map-marker {
    width: 18px;
    height: 18px;
    background: var(--marker-color, var(--color-primary));
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.map-marker--selected {
    width: 26px;
    height: 26px;
    background: var(--color-danger);
    border-width: 3px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

/* -------------------------------------------------------------------------
   Grand écran
   ------------------------------------------------------------------------- */

@media (min-width: 1400px) {
    .container {
        max-width: 1020px;
    }

    .meteogram__precip {
        height: 145px;
    }

    .meteogram__canvas-wrap {
        height: 185px;
    }
}

/* -------------------------------------------------------------------------
   Tablette
   ------------------------------------------------------------------------- */

@media (max-width: 850px) {
    .container {
        width: min(calc(100% - 18px), 760px);
    }

    .location-picker {
        grid-template-columns: 1fr auto;
    }

    .meteogram__precip {
        height: 155px;
    }

    .meteogram__canvas-wrap {
        height: 195px;
    }
}

/* -------------------------------------------------------------------------
   Téléphone
   ------------------------------------------------------------------------- */

@media (max-width: 560px) {
    .container {
        width: calc(100% - 12px);
        margin-top: 6px;
        padding: 10px 7px 18px;
    }

    .page-header h1 {
        margin-bottom: 10px;
        font-size: 1.4rem;
    }

    .location-picker {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .location-select,
    .btn--map {
        width: 100%;
    }

    .location-select {
        min-height: 42px;
    }

    .btn--map {
        min-height: 32px;
    }

    .meteogram__title {
        margin-top: 11px;
        padding: 7px 8px;
        font-size: 0.68rem;
    }

    .meteogram__precip {
        height: 145px;
        padding: 4px;
    }

    .meteogram__icons {
        min-height: 34px;
        padding: 4px 8px;
    }

    .meteogram__icon {
        font-size: 0.84rem;
    }

    .meteogram__canvas-wrap {
        height: 175px;
    }

    .partner {
        padding: 9px 8px;
    }

    .site-footer {
        font-size: 0.68rem;
    }

    .map-dialog {
        align-items: flex-end;
        padding: 0;
    }

    .map-dialog__panel {
        width: 100%;
        max-height: 94vh;
        border-radius: 14px 14px 0 0;
    }

    .map-dialog__map {
        height: 55vh;
        min-height: 260px;
    }
}

/* -------------------------------------------------------------------------
   Réduction des animations
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .snow-alert {
        animation: none;
        opacity: 1;
    }
}
