/*
 * Ajustements smartphone / petite tablette.
 *
 * Toutes les règles sont dans des media queries < 768 px : l'affichage PC
 * n'est pas concerné. Les sélecteurs sont préfixés par .app-shell (ou html:root)
 * pour l'emporter sur le bloc <style> injecté par styles.py, chargé après ce fichier.
 */

/* ---------- < 768 px : colonnes empilées ---------- */
@media (max-width: 767.98px) {
  /* Critères des onglets cartographiques : pastilles qui s'enroulent
     au lieu d'une longue liste verticale de boutons radio. */
  .app-shell .map-side-panel .dash-radioitems {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .app-shell .map-side-panel .dash-radioitems .dash-options-list-option {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--alpa-border);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    line-height: 1.2;
  }

  .app-shell .map-side-panel .dash-radioitems .dash-options-list-option-wrapper {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .app-shell .map-side-panel .dash-radioitems .dash-options-list-option-text {
    margin-bottom: 0 !important;
    font-size: 0.88rem;
  }

  .app-shell .map-side-panel .dash-radioitems .dash-options-list-option.selected {
    background: var(--alpa-blue-dark);
    border-color: var(--alpa-blue-dark);
  }

  .app-shell .map-side-panel .dash-radioitems .dash-options-list-option.selected .i18n {
    color: #fff !important;
  }

  .app-shell .map-side-panel .dash-radioitems .dash-options-list-option:has(input:disabled) {
    opacity: 0.45;
    border-style: dashed;
    cursor: not-allowed;
  }

  .app-shell .map-side-panel .dash-radioitems .dash-options-list-option:has(input:focus-visible) {
    outline: 2px solid var(--alpa-orange);
    outline-offset: 1px;
  }

  /* Légendes WMS posées sur les cartes : plus discrètes. */
  .app-shell #cf-legend-container,
  .app-shell #mf-legend-container,
  .app-shell #emc-legend-container {
    right: 6px !important;
    bottom: 26px !important;
    padding: 4px 6px !important;
    border-radius: 8px !important;
  }

  .app-shell #cf-legend-img,
  .app-shell #mf-legend-img,
  .app-shell #emc-legend-img {
    max-height: 34vh;
    width: auto;
  }

  /* Légende « Régions » de la carte Émissions. */
  .app-shell .map-region-legend {
    left: 8px !important;
    bottom: 8px !important;
    padding: 6px 8px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
  }

  .app-shell .map-region-legend > div {
    margin-bottom: 3px !important;
  }
}

/* ---------- < 576 px : smartphone ---------- */
@media (max-width: 575.98px) {
  html:root {
    /* Graphes : plus hauts pour laisser la place à la légende placée dessous. */
    --h-main: clamp(380px, 68vh, 560px);
    --h-pie: clamp(400px, 72vh, 580px);
    /* Cartes raster : on garde de la marge pour faire défiler la page au doigt. */
    --h-cf: clamp(320px, 58vh, 560px);
  }

  /* Barre de navigation sur une seule ligne. */
  .app-shell .app-navbar {
    margin-bottom: 0.5rem !important;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .app-shell .app-navbar .container-fluid {
    flex-wrap: nowrap;
    gap: 0.4rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .app-shell .app-navbar .app-navbar-left {
    min-width: 0;
    flex: 0 0 auto;
  }

  .app-shell .app-menu-button {
    padding: 0.3rem 0.65rem;
    font-size: 1.05rem;
  }

  .app-shell .app-menu-label {
    display: none;
  }

  .app-shell .app-navbar .app-navbar-title {
    font-size: 0.95rem !important;
    line-height: 1.15;
    letter-spacing: 0 !important;
  }

  .app-shell .app-navbar-meta .row {
    flex-wrap: nowrap;
    --bs-gutter-x: 0.3rem;
  }

  .app-shell .app-navbar-meta .row > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }

  .app-shell .lang-flag-button {
    padding: 3px 3px !important;
  }

  .app-shell .lang-flag-icon {
    width: 18px;
    height: 13px;
  }

  .app-shell .app-navbar-logo-wrap {
    padding: 3px 6px;
    border-radius: 8px;
  }

  .app-shell #alpaera-logo {
    max-height: 26px !important;
    max-width: 78px !important;
    margin-top: 0 !important;
  }

  /* Cartes plus compactes. */
  .app-shell .card-body {
    padding: 0.75rem;
  }

  .app-shell .intro-card .card-body {
    font-size: 0.92rem;
  }

  /* Barre d'outils Plotly masquée : elle recouvrait le titre. Le bouton ⤢
     (plein écran) et les exports CSV restent disponibles. */
  .app-shell #tab-content .js-plotly-plot .modebar-container {
    display: none !important;
  }

  /* Synthèse Observations (2 colonnes) */
  .app-shell #obs-stats-card .card-body .card-body {
    padding: 0.5rem 0.65rem;
  }

  /* Pied de page partenaires : logos en grille 2 colonnes. */
  .app-shell .footer-partner-logo-list .partner-logo-tile {
    width: 130px;
    height: 64px;
  }
}
