:root {
  --bg: #0B1B2B; --card: #12283D; --line: #2F5576; --btn: #173452; --btn-h: #1E4468;
  --text: #EAF2F8; --soft: #CFDDE8; --muted: #A9BDCD; --accent: #7DD3FC; --sel: #38BDF8;
  --warn: #FB923C; --ok: #4ADE80;
}
* { box-sizing: border-box; }
html { font-size: 19px; } /* 14 pt minimum partout */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, "Segoe UI", sans-serif; font-size: 1rem; line-height: 1.35;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.01em; }
h2 { margin: 0 0 14px; font-size: 22px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--muted); }
button { font: inherit; }

/* En-tête */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.title { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.status { display: flex; align-items: center; gap: 14px; }
.updated { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 6px; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); }

.btn, .src {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--btn); color: #E0F2FE; font-weight: 600; white-space: nowrap;
  text-decoration: none; cursor: pointer;
}
.btn:hover, .src:hover { background: var(--btn-h); color: #fff; }
.btn[disabled] { opacity: .6; cursor: wait; }
.src svg { flex: none; }

/* Deux écrans en alternance : Relevés puis Prévisions (rotation automatique) */
.layout { display: block; }
.layout[data-show="releves"] .previsions, .layout[data-show="previsions"] .releves { display: none; }
.col { display: flex; flex-direction: column; min-width: 0; }
.col h2 { display: none; }
.col > div { display: grid; gap: 16px; align-items: start; }
.releves > div { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.previsions > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.previsions > div > .card:first-child { grid-column: 1 / -1; }
.releves .badge { font-size: min(54px, 12.5cqi); }
.releves .badge small { font-size: 26px; }
.releves .live-info { font-size: 23px; }
/* taille limitée par la largeur de l'écran pour que « Rafales xx nds » tienne sur une ligne */
.releves .card { container-type: inline-size; }
.releves .gust { font-size: min(1.35em, 6.8cqi); line-height: 1.15; white-space: nowrap; }
.releves .dirl { font-size: 1.3em; line-height: 1.15; white-space: nowrap; font-weight: 600; }
.releves .dirl .arrow { width: 1em; height: 1em; }
.releves .gust .pill { display: inline-block; padding: 1px 8px; border-radius: 8px; margin-bottom: 3px; }
.releves .spark { height: 90px; }
.screen-tabs { display: flex; gap: 8px; margin-bottom: 4px; }
.screen-tabs button { flex: 1; min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font-weight: 600; cursor: pointer; }
.screen-tabs button[aria-selected="true"] { background: var(--sel); border-color: var(--sel); color: var(--bg); }
.screen-tabs button.pause { flex: 0 0 auto; padding: 0 18px; background: var(--btn); }
.screen-tabs button.pause[aria-pressed="true"] { background: #FACC15; border-color: #FACC15; color: var(--bg); }
.progress { height: 4px; border-radius: 2px; background: rgba(56,189,248,.18); margin-bottom: 14px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--sel); }
.progress span.run { animation: fill linear forwards; }
@keyframes fill { from { width: 0; } to { width: 100%; } }

.card { background: var(--card); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-title { font-size: 22px; font-weight: 700; }
.card-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.air { font-size: 22px; font-weight: 700; color: #FDE68A; }
.note { color: var(--muted); }
.alert { color: #FED7AA; background: rgba(251,146,60,.12); border: 1px solid rgba(251,146,60,.45); border-radius: 10px; padding: 8px 12px; }
.unavail { color: #FED7AA; font-weight: 600; padding: 18px 0; text-align: center; }

/* Onglets / puces */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: transparent;
  color: var(--text); font-weight: 500; cursor: pointer;
}
.tab[aria-selected="true"] { border-color: var(--sel); background: var(--sel); color: var(--bg); font-weight: 600; }
.tabs.grow .tab { flex: 1; }

/* Tableaux de prévisions : défilement horizontal, libellés collants */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
table.fc { border-collapse: separate; border-spacing: 3px; text-align: center; min-width: 100%; }
table.fc th, table.fc td { padding: 5px 4px; white-space: nowrap; min-width: 52px; }
table.fc thead th { color: var(--muted); font-weight: 600; }
table.fc thead th.day { color: var(--soft); }
table.fc th.lbl {
  position: sticky; left: 0; z-index: 1; background: var(--card); text-align: left; color: var(--soft);
  font-weight: 600; padding-right: 10px; min-width: 150px;
}
table.fc td { color: var(--text); border-radius: 6px; }
table.fc td.w { font-weight: 700; }
table.fc tr.daystart th:not(.lbl), table.fc td.daystart { box-shadow: inset 2px 0 0 var(--line); }
.arrow { display: inline-block; vertical-align: middle; }
.sky { width: 34px; height: 34px; display: block; margin: 0 auto; }

/* Couleurs du vent (nœuds) */
.w0 { background: #2563EB; color: #fff !important; }
.w1 { background: #4ADE80; color: #0B1B2B !important; }
.w2 { background: #FACC15; color: #0B1B2B !important; }
.w3 { background: #FB923C; color: #0B1B2B !important; }
.w4 { background: #DC2626; color: #fff !important; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; color: var(--muted); }
.legend .sw { display: flex; gap: 4px; }
.legend .sw span { padding: 0 8px; border-radius: 5px; }

/* Widget Windguru */
/* Le widget a un petit texte : on l'agrandit (zoom) dans une zone défilante */
.wg-frame { display: block; width: 1100px; height: 138px; border: 0; background: #fff; zoom: 1.7; }
.scroll { scrollbar-color: #2F5576 transparent; }

/* LaMMA */
.map-wrap { position: relative; border-radius: 10px; overflow: hidden; background: #0e2236; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.map-wrap img { width: 100%; height: auto; display: block; }
.map-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.icon-btn { width: 52px; height: 48px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 26px; cursor: pointer; }
.icon-btn:hover { background: var(--btn-h); }
.map-time { font-weight: 600; text-align: center; }

/* Relevés */
.live { display: flex; align-items: center; gap: 18px; }
.badge { font-size: 44px; font-weight: 800; line-height: 1; padding: 10px 14px; border-radius: 12px; white-space: nowrap; }
.badge small { font-size: 20px; font-weight: 600; }
.live-info { display: flex; flex-direction: column; gap: 2px; }
.spark { width: 100%; height: 56px; display: block; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.big { font-size: 30px; font-weight: 800; }
.big small { font-size: 19px; font-weight: 500; color: var(--soft); }
/* Bouée : grosses vagues / longue période → clignote en arc-en-ciel ; couleur de l'eau selon la température */
.rainbow { animation: rainbow 1.6s linear infinite, blink 0.8s steps(2, jump-none) infinite; }
@keyframes rainbow {
  0% { color: #FF4D4D; } 17% { color: #FF9F1C; } 33% { color: #FFE14D; } 50% { color: #4ADE80; }
  67% { color: #38BDF8; } 83% { color: #A78BFA; } 100% { color: #FF4D4D; }
}
@keyframes blink { 0% { opacity: 1; } 100% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .rainbow { animation-duration: 4s, 0s; } }
.t-cold { color: #60A5FA; } .t-mild { color: #FFFFFF; } .t-warm { color: #FB923C; } .t-hot { color: #EF4444; }

/* Téléphone : une colonne, onglets Relevés / Prévisions */
@media (max-width: 900px), (max-height: 500px) {
  body {
    padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
             calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }
  /* Mode plein écran (kiosque) : certains Android annoncent 0 pour le trou de la caméra, on garde au moins 32 px */
  @media (display-mode: fullscreen) {
    body { padding-top: calc(8px + max(env(safe-area-inset-top), 32px)); }
    .screen-tabs { top: max(env(safe-area-inset-top), 32px) !important; }
    body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: max(env(safe-area-inset-top), 32px); background: var(--bg); z-index: 6; }
  }
  /* Navigateur kiosque (classe ajoutée par app.js) : même réserve pour la caméra */
  .kiosk body { padding-top: calc(8px + max(env(safe-area-inset-top), var(--cam, 32px))); }
  .kiosk .screen-tabs { top: max(env(safe-area-inset-top), var(--cam, 32px)) !important; }
  .kiosk .releves .spark { height: 24px; }
  /* Bandeau fixe sous la caméra : le contenu qui défile passe dessous, sans rien masquer au repos */
  .kiosk body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: max(env(safe-area-inset-top), var(--cam, 32px)); background: var(--bg); z-index: 6; }
  @media (orientation: landscape) {
    .kiosk body { padding-top: calc(8px + env(safe-area-inset-top)); padding-left: calc(8px + max(env(safe-area-inset-left), var(--cam, 32px))); padding-right: calc(8px + max(env(safe-area-inset-right), var(--cam, 32px))); }
    .kiosk .screen-tabs { top: env(safe-area-inset-top) !important; }
    .kiosk body::before { display: none; }
  }
  @media (display-mode: fullscreen) and (orientation: landscape) {
    body { padding-left: calc(8px + max(env(safe-area-inset-left), 32px)); padding-right: calc(8px + max(env(safe-area-inset-right), 32px)); }
  }
  /* Texte en 11 pt sur téléphone (au lieu de 14 pt), le reste réduit dans la même proportion */
  html { font-size: 11pt; }
  /* Titre sur toute la largeur de l'écran (portrait) ; plafonné en paysage */
  h1 { font-size: min(calc((100vw - 26px) / 13.6), 30px); white-space: nowrap; }
  h2 { font-size: 16.5px; }
  .card-title { font-size: 16.5px; }
  .icon-btn { font-size: 20px; }
  .badge { font-size: 34px; }
  .badge small { font-size: 15px; }
  .big { font-size: 23px; }
  .big small { font-size: 15px; }
  .screen-tabs .pause, .progress, a.src { display: none; }
  .screen-tabs { position: sticky; top: env(safe-area-inset-top); z-index: 5; background: var(--bg); padding: 6px 0; }
  .previsions > div, .releves > div { grid-template-columns: minmax(0, 1fr); }
  .releves .badge { font-size: 34px; }
  .releves .badge small { font-size: 15.5px; }
  .releves .live-info { font-size: 15px; }
  .card { padding: 14px; }
  table.fc th.lbl { min-width: 118px; }
  /* En-tête et onglets plus compacts */
  .top { margin-bottom: 6px; gap: 4px 10px; }
  .title { gap: 2px 10px; }
  .btn { min-height: 34px; }
  .screen-tabs { padding: 4px 0; margin-bottom: 4px; }
  .screen-tabs button { min-height: 38px; }
  /* Relevés : tout tient sur un écran, sans défilement */
  .releves > div { gap: 8px; }
  .releves .card { padding: 10px 12px; gap: 6px; }
  .releves { font-size: 17px; }
  .releves .card-title, .releves .air { font-size: 19px; }
  .releves .live { gap: 10px; }
  .releves .gust { font-size: min(1.35em, 7.2cqi); }
  .releves .badge { font-size: 36px; padding: 6px 8px; }
  .releves .badge small { font-size: 18px; }
  .releves .live-info { font-size: 18px; gap: 0; }
  .releves .spark { height: 30px; }
  .releves .grid2 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; }
  .releves .big { font-size: 24px; }
}
