/* Kite Spots v3 — carte d'abord, feuille glissante sur téléphone, panneau fixe sur ordinateur. */

@font-face {
  font-family: "Rethink Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/rethink-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Rethink Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/rethink-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --encre: #0E2433;
  --secondaire: #5B6B77;
  --mer: #13507A;
  --clair: #8DB4D3;
  --pale: #D6E6F1;
  --gris: #EEF1F3;
  --gris-fort: #DDE2E6;
  --terre: #FAFAF7;
  --rouge: #FF4F2E;
  --rouge-texte: #D93A1C; /* même rouge, assez foncé pour porter du texte blanc (4,6 pour 1) */
  --blanc: #fff;
  --rayon: 16px;
  --ombre: 0 1px 2px rgba(14, 36, 51, .10), 0 4px 14px rgba(14, 36, 51, .08);
  --feuille-h: 180px;
  --haut-sur: max(12px, env(safe-area-inset-top));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; height: 100%; }

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--terre);
  color: var(--encre);
  font: 15px/1.45 "Rethink Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--mer); }
:focus-visible { outline: 2px solid var(--mer); outline-offset: 2px; border-radius: 6px; }
code { font-size: .9em; }

/* --- Carte ------------------------------------------------------------ */

.carte { position: fixed; inset: 0; background: var(--terre); }
.maplibregl-ctrl-attrib { font: 11px/1.4 "Rethink Sans", system-ui, sans-serif; }
.maplibregl-ctrl-bottom-right { transition: bottom 280ms cubic-bezier(.2, .9, .3, 1.15); }

.sources {
  position: fixed;
  right: 10px;
  bottom: calc(var(--feuille-h) + 34px);
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--blanc);
  box-shadow: var(--ombre);
  color: var(--secondaire);
  font-weight: 600;
  font-style: italic;
  transition: bottom 280ms cubic-bezier(.2, .9, .3, 1.15);
}

/* --- Pastilles du haut --------------------------------------------------- */

.pastilles {
  position: fixed;
  top: var(--haut-sur);
  left: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.pastille {
  pointer-events: auto;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--blanc);
  box-shadow: var(--ombre);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#pastille-dates { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pastille.active { background: var(--encre); color: var(--blanc); }

/* --- Feuille (téléphone) ----------------------------------------------- */

.feuille {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: calc(100% - 64px);
  display: flex;
  flex-direction: column;
  background: var(--blanc);
  border-radius: var(--rayon) var(--rayon) 0 0;
  box-shadow: 0 -1px 2px rgba(14, 36, 51, .06), 0 -6px 24px rgba(14, 36, 51, .08);
  will-change: transform;
}
.poignee {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  padding: 0;
  border: 0;
  background: none;
  touch-action: none;
}
.poignee span { width: 40px; height: 5px; border-radius: 3px; background: var(--gris-fort); }
.entete { flex: none; display: flex; align-items: baseline; gap: 10px; padding: 0 20px 10px; touch-action: none; }
.entete h1 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.depart { color: var(--secondaire); font-size: 14px; }
.feuille[data-hauteur="basse"] .entete { display: none; }

.progression { flex: none; height: 2px; margin: 0 20px; overflow: hidden; background: var(--gris); border-radius: 2px; }
.progression span { display: block; width: 30%; height: 100%; background: var(--mer); animation: avance 1.1s ease-in-out infinite; }
@keyframes avance { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.contenu {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 2px 20px calc(28px + env(safe-area-inset-bottom));
}
.feuille[data-hauteur="haute"] .contenu,
.feuille[data-hauteur="panneau"] .contenu { overflow-y: auto; }

/* --- Boutons communs ---------------------------------------------------- */

.y-aller, .principal, .secondaire {
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.y-aller { background: var(--rouge-texte); color: var(--blanc); }
.y-aller:hover { background: #C4321A; }
.principal { width: 100%; height: 48px; background: var(--mer); color: var(--blanc); }
.secondaire { background: var(--gris); color: var(--encre); }
.plein { width: 100%; }
.lien { padding: 0; border: 0; background: none; color: var(--mer); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* --- Meilleur choix ------------------------------------------------------ */

.meilleur { padding: 4px 0 18px; cursor: pointer; }
.meilleur-corps { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.meilleur-nom { font-size: 22px; line-height: 1.15; font-weight: 700; letter-spacing: -.015em; }
.nom-lien {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  letter-spacing: inherit;
}
.details { margin-top: 4px; color: var(--secondaire); font-size: 14px; font-variant-numeric: tabular-nums; }

/* --- Classement --------------------------------------------------------- */

.invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.bloc-classement { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--gris); }
.classement { margin: 0 -10px; }
.ligne {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 6px;
  width: 100%;
  padding: 12px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
}
.ligne:hover { background: var(--gris); }
.rang { color: var(--mer); font-weight: 700; font-variant-numeric: tabular-nums; }
.ligne-corps { display: grid; gap: 2px; min-width: 0; }
.ligne-tete { display: flex; justify-content: space-between; gap: 12px; }
.ligne .nom { font-weight: 600; }
.route { flex: none; color: var(--secondaire); font-size: 14px; font-variant-numeric: tabular-nums; }
.ligne-region { color: var(--secondaire); font-size: 13px; }
.ligne-creneau { font-size: 13px; font-variant-numeric: tabular-nums; }
.bandes { display: flex; gap: 6px; margin-top: 6px; }
.bande { display: flex; gap: 1px; width: 84px; }
.bande i { flex: 1; height: 6px; border-radius: 1px; }

.c-bon { background: var(--mer); }
.c-limite { background: var(--clair); }
.c-mediocre { background: var(--pale); }
.c-trop_faible { background: var(--gris-fort); }
.c-maree { background: repeating-linear-gradient(45deg, var(--pale) 0 2px, #B9D3E6 2px 4px); }
.c-danger { background: repeating-linear-gradient(45deg, var(--gris) 0 2px, #B9C1C7 2px 4px); }

.masques { margin: 8px 0; color: var(--secondaire); font-size: 13px; }
.masques .lien { padding: 12px 0; }
.ne-marchent-pas { margin-top: 12px; }
.ne-marchent-pas summary { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; cursor: pointer; list-style: none; }
.ne-marchent-pas summary::-webkit-details-marker { display: none; }
.ne-marchent-pas summary::before { content: "›"; color: var(--secondaire); font-size: 18px; line-height: 1; transition: transform 160ms; }
.ne-marchent-pas[open] summary::before { transform: rotate(90deg); }
.ligne-ko {
  display: grid;
  width: calc(100% + 20px);
  margin: 0 -10px;
  padding: 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
}
.ligne-ko:hover { background: var(--gris); }
.ko-detail { color: var(--secondaire); font-size: 13px; }

.message { padding: 14px 0; }
.message p { color: var(--secondaire); }
.message .secondaire { margin-top: 12px; }

/* --- Fiche -------------------------------------------------------------- */

.retour { height: 44px; margin: -6px 0 2px; padding: 0; border: 0; background: none; color: var(--mer); font-weight: 600; }
.fiche-nom { font-size: 26px; line-height: 1.12; font-weight: 700; letter-spacing: -.02em; outline: none; }
.fiche-region { margin-top: 4px; color: var(--secondaire); font-size: 14px; }
.verdict { margin-top: 16px; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.verdict.ko { color: var(--secondaire); }
.fiabilite { color: var(--secondaire); font-size: 13px; }
.note { margin-top: 6px; color: var(--secondaire); font-size: 13px; }
.fiche .y-aller-bloc { margin-top: 16px; }
.trajet { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 20px; }
.trajet dt { color: var(--secondaire); font-size: 13px; }
.trajet dd { font-variant-numeric: tabular-nums; }
.jour { margin-top: 28px; }
.jour-nom { font-size: 14px; font-weight: 600; }

/* Frise en barres chiffrées */
.frise { position: relative; margin-top: 8px; }
.frise-defile { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; padding-bottom: 2px; }
.frise-svg { display: block; overflow: visible; font-variant-numeric: tabular-nums; }
.frise-svg text { font-family: "Rethink Sans", system-ui, sans-serif; text-anchor: middle; }
.col .vent, .col .rafale { fill: var(--gris-fort); }
.col .rafale { opacity: .45; }
.c-bon .vent, .c-bon .rafale { fill: var(--mer); }
.c-bon .rafale { opacity: .22; }
.c-limite .vent, .c-limite .rafale { fill: var(--clair); }
.c-limite .rafale { opacity: .35; }
.c-mediocre .vent, .c-mediocre .rafale { fill: var(--pale); }
.c-mediocre .rafale { opacity: .6; }
.c-maree .rafale { fill: var(--pale); }
.c-danger .rafale { fill: var(--gris-fort); }
.frise-svg .chiffre { font-size: 11px; font-weight: 600; fill: var(--encre); }
.c-bon .chiffre.dedans { fill: var(--blanc); }
.chiffre-rafale { font-size: 9px; fill: var(--secondaire); }
.mot { font-size: 9px; font-weight: 600; fill: var(--secondaire); text-anchor: start; }
.zone { fill: transparent; cursor: pointer; }
.col.active .vent { stroke: var(--encre); stroke-width: 1.5; }
.fond-maree { fill: var(--pale); }
.trait-maree { fill: #B9D3E6; }
.fond-danger { fill: var(--gris); }
.trait-danger { fill: #B9C1C7; }
.seuil { stroke: var(--secondaire); stroke-width: 1; stroke-dasharray: 2 3; opacity: .55; }
.accolade { fill: none; stroke: var(--rouge); stroke-width: 1.5; stroke-linejoin: round; }
.accolade-texte { font-size: 11px; font-weight: 700; fill: var(--rouge-texte); }
.frise-pied { display: grid; margin-top: 4px; }
.pied-h { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.pied-h .h { color: var(--secondaire); font-size: 11px; font-variant-numeric: tabular-nums; }
.fleche { width: 12px; height: 12px; fill: none; stroke: var(--secondaire); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pied-h .pm { min-height: 12px; color: var(--mer); font-size: 9px; font-weight: 700; }
.bulle {
  position: absolute;
  top: 0;
  z-index: 2;
  width: max-content;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--encre);
  color: var(--blanc);
  font-size: 12px;
  transform: translate(-50%, -100%);
  pointer-events: none;
}

.legende { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; color: var(--secondaire); font-size: 12px; }
.leg { display: inline-flex; align-items: center; gap: 5px; }
.leg i { width: 10px; height: 10px; border-radius: 2px; }
.leg-bon i { background: var(--mer); }
.leg-limite i { background: var(--clair); }
.leg-trop_faible i { background: var(--gris-fort); }
.leg-maree i { background: repeating-linear-gradient(45deg, var(--pale) 0 2px, #B9D3E6 2px 4px); }
.leg-danger i { background: repeating-linear-gradient(45deg, var(--gris) 0 2px, #B9C1C7 2px 4px); }
.leg-seuil i { height: 0; border-radius: 0; border-top: 1px dashed var(--secondaire); }

/* Rose des vents */
.bloc-rose { margin-top: 28px; }
.bloc-rose h3, .a-savoir h3 { font-size: 14px; font-weight: 600; }
.rose-ligne { display: flex; align-items: center; gap: 20px; margin-top: 8px; }
.rose { flex: none; overflow: visible; }
.rose-fond { fill: var(--gris); }
.rose-bon { fill: var(--mer); }
.rose-moyen { fill: var(--clair); }
.rose-centre { fill: var(--blanc); }
.fond-terre { fill: var(--gris); }
.trait-terre { fill: #B9C1C7; }
.rose-plage { stroke: var(--encre); stroke-width: 1.5; stroke-linecap: round; }
.rose-fleche { fill: none; stroke: var(--encre); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.rose-lettre { font: 600 10px "Rethink Sans", system-ui, sans-serif; fill: var(--secondaire); text-anchor: middle; }
.rose-legende { display: grid; gap: 6px; color: var(--secondaire); font-size: 13px; }
.rose-legende li { display: flex; align-items: center; gap: 8px; }
.rose-legende i { width: 12px; height: 12px; border-radius: 3px; }
.rose-legende .leg-bon i { background: var(--mer); }
.rose-legende .leg-moyen i { background: var(--clair); }
.rose-legende .leg-terre i { background: repeating-linear-gradient(45deg, var(--gris) 0 2px, #B9C1C7 2px 4px); }
.rose-legende .leg-fleche i { height: 0; border-radius: 0; border-top: 2.5px solid var(--encre); }

.a-savoir { margin-top: 28px; }
.a-savoir p { margin-top: 6px; font-size: 14px; line-height: 1.55; }

/* --- Panneaux (dates, filtres, sources, Y aller) ------------------------- */

.dialogue {
  width: 100%;
  max-width: 100%;
  margin: auto 0 0;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: var(--rayon) var(--rayon) 0 0;
  background: var(--blanc);
  color: var(--encre);
  box-shadow: 0 -6px 24px rgba(14, 36, 51, .12);
}
.dialogue[open] { animation: monte 220ms ease-out; }
.dialogue::backdrop { background: rgba(14, 36, 51, .28); }
@keyframes monte { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.panneau-tete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panneau-tete h2 { font-size: 18px; font-weight: 700; }
.fermer {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: -4px -6px -4px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--gris);
  color: var(--secondaire);
}
.fermer svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fermer::after { content: ""; position: absolute; inset: -4px; } /* cible tactile de 44 px */
.fermer { position: relative; }
.dialogue:focus { outline: none; }
.sous-titre { margin: 18px 0 8px; color: var(--secondaire); font-size: 13px; font-weight: 600; }

.raccourcis { display: grid; gap: 8px; }
.choix {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--gris);
  text-align: left;
  font-weight: 500;
}
.choix[aria-pressed="true"] { background: var(--mer); color: var(--blanc); }
.champs { display: flex; gap: 12px; margin-bottom: 14px; }
.champs label { flex: 1; display: grid; gap: 4px; color: var(--secondaire); font-size: 13px; }
.champs input { height: 44px; padding: 0 10px; border: 0; border-radius: 12px; background: var(--gris); color: var(--encre); font-size: 15px; }
.erreur { margin-bottom: 12px; font-weight: 600; }

.champ { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.champ select { height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--gris); font-weight: 500; }
.regions { display: flex; flex-wrap: wrap; gap: 8px; }
.regions .choix { border-radius: 999px; }
#filtres-defaut { margin-top: 20px; min-height: 44px; }

.liste-sources { display: grid; gap: 8px; color: var(--secondaire); }

.y-aller-choix { display: none; }
.y-aller-choix[open] { display: grid; gap: 10px; }
.dialogue-titre { margin-bottom: 4px; font-size: 17px; font-weight: 700; }
.choix-appli {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  background: var(--gris);
  color: var(--encre);
  font-weight: 600;
  text-decoration: none;
}

/* --- Carte indisponible : la feuille prend tout l'écran -------------------- */

.sans-carte .carte, .sans-carte .sources, .sans-carte .poignee { display: none; }
.sans-carte .feuille {
  top: 0;
  height: auto !important;
  transform: none !important;
  border-radius: 0;
  box-shadow: none;
  padding-top: calc(var(--haut-sur) + 52px);
}
.sans-carte .feuille .entete { display: flex; }
.sans-carte .contenu { overflow-y: auto; }
.sans-carte .pastilles { z-index: 5; }
.sans-carte .pastille { box-shadow: none; background: var(--gris); }

/* --- Ordinateur : panneau fixe de 400 px à gauche ------------------------ */

@media (min-width: 800px) {
  .carte { left: 400px; }
  .feuille {
    top: 0;
    right: auto;
    width: 400px;
    height: 100% !important;
    transform: none !important;
    border-radius: 0;
    box-shadow: 1px 0 0 var(--gris-fort);
  }
  .poignee { display: none; }
  .entete { padding: 28px 24px 72px; }
  .feuille[data-hauteur] .entete { display: flex; }
  .pastilles { top: 74px; left: 24px; right: auto; width: 352px; z-index: 5; }
  .pastille { box-shadow: none; background: var(--gris); }
  .pastille.active { background: var(--encre); }
  .progression { margin: 0 24px; }
  .contenu { padding: 6px 24px 32px; }
  .sources { bottom: 34px; }
  .maplibregl-ctrl-bottom-right { bottom: 0; }

  .dialogue.panneau {
    position: fixed;
    top: 126px;
    left: 24px;
    width: 352px;
    max-height: calc(100% - 150px);
    margin: 0;
    padding: 16px 18px 18px;
    border-radius: var(--rayon);
    box-shadow: var(--ombre), 0 12px 32px rgba(14, 36, 51, .12);
  }
  .dialogue.panneau.petit { top: auto; left: auto; right: 52px; bottom: 34px; width: 320px; }
  .dialogue.panneau::backdrop { background: transparent; }
  .y-aller-choix { width: 340px; margin: auto; border-radius: var(--rayon); padding: 20px; }

  .sans-carte .feuille { width: 100%; padding-top: 0; }
  .sans-carte .contenu { width: 100%; max-width: 720px; }
}

@media (max-width: 799px) {
  .maplibregl-ctrl-bottom-right { bottom: var(--feuille-h); }
  /* Feuille en haut : la carte est cachée, ses boutons aussi. */
  body[data-feuille="haute"] .sources,
  body[data-feuille="haute"] .maplibregl-ctrl-bottom-right { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Prochain bon jour (rien de « bon » sur les dates choisies) */
.prochain {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--pale);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.prochain .secondaire { padding: 0 16px; background: var(--blanc); }
.prochain.vide { margin: 0 0 12px; padding: 0; background: none; color: var(--secondaire); }
