/* Chaletier — Pilote automatique (instrument sombre, autonome sur fond clair ou foncé) */

.pil { --col-min: 42px; color: var(--neige); }
@media (min-width: 900px) { .pil { --col-min: 30px; } .pil--apercu { --col-min: 34px; } }
.pil [hidden] { display: none !important; }
.pil .instrument__barre { flex-wrap: wrap; }
.pil-titre { color: var(--neige) !important; letter-spacing: .06em; }
.pil-source { text-align: right; }

/* Entrées */
.pil-entree { display: grid; gap: 28px 40px; margin-bottom: 18px; }
@media (min-width: 980px) { .pil-entree { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); } }
.pil-form { display: grid; gap: 14px; align-content: start; }
.pil .champ label { color: var(--brume); }
.pil input[type=text], .pil input[type=url], .pil select {
  background: var(--nuit); border: 1px solid var(--mousse); color: var(--neige); border-radius: var(--r);
}
.pil input::placeholder { color: #6f7b74; }
.pil input:focus, .pil select:focus { outline: 2px solid var(--balise); outline-offset: 0; border-color: transparent; }
.pil-chalet { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; padding-bottom: 12px; border-bottom: 1px solid var(--mousse); }
.pil-chalet .mono { color: var(--brume); font-size: 11px; }
.pil-chalet b { font: 700 20px/1.2 var(--f-cond); }
.pil-mini {
  background: none; border: 0; padding: 4px 0; color: inherit; cursor: pointer; text-decoration: none;
  font: 500 11px/1.2 var(--f-mono); font-stretch: 87.5%; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--balise);
}
.pil-mini:hover { color: var(--balise); }
.pil-mini:disabled { opacity: .35; cursor: default; border-color: transparent; }
.pil-boutons { display: flex; flex-wrap: wrap; gap: 10px; }
.pil-form.is-occupe [type=submit] { opacity: .6; cursor: progress; }
.pil-depot {
  position: relative; display: grid; place-items: center; min-height: 64px; padding: 12px 16px; cursor: pointer;
  border: 1px dashed #3d5146; color: var(--brume); font-size: 15px; text-align: center; transition: border-color .15s, color .15s, background .15s;
}
.pil-depot b { color: var(--neige); font-weight: 600; }
.pil-depot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pil-depot:hover, .pil-depot.is-survol { border-color: var(--balise); color: var(--neige); background: rgba(255, 90, 31, .06); }
.pil-depot:focus-within { outline: 2px solid var(--balise); outline-offset: 2px; }
.pil-heures { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.pil-heures .mono { color: var(--brume); font-size: 10.5px; }
.pil-heures select { width: auto; min-height: 40px; padding: 6px 30px 6px 10px; font-size: 15px; }
.pil-heures label + select { margin-right: 10px; }
.pil-confid { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--brume); max-width: 62ch; }

.pil-regles { border-top: 1px solid var(--mousse); padding-top: 18px; }
@media (min-width: 980px) { .pil-regles { border-top: 0; border-left: 1px solid var(--mousse); padding: 0 0 0 28px; } }
.pil-regles h4 { margin-bottom: 14px; }
.pil-regles ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; counter-reset: r; }
.pil-regles li { display: grid; grid-template-columns: 26px 1fr; gap: 8px; font-size: 15px; line-height: 1.4; color: #cfd6d2; counter-increment: r; }
.pil-regles li::before { content: counter(r, decimal-leading-zero); font: 500 11px/1.5 var(--f-mono); font-stretch: 87.5%; color: var(--balise); padding-top: 1px; }

.pil-etat { margin: 4px 0 16px; min-height: 1.4em; font: 500 12px/1.45 var(--f-mono); font-stretch: 87.5%; color: var(--brume); }
.pil-etat:empty { display: none; }
.pil-etat.is-alerte { color: #ff8a5c; }
.pil-etat.is-ok { color: var(--ok); }

/* Résumé */
.pil-resume { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--mousse); border: 1px solid var(--mousse); margin-bottom: 14px; }
@media (min-width: 760px) { .pil-resume { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pil-kpi { background: var(--nuit); padding: 14px 14px 12px; display: grid; gap: 6px; align-content: start; }
.pil-kpi b { font: 850 clamp(36px, 4vw, 52px)/.85 var(--f-aff); text-transform: uppercase; }
.pil-kpi span { color: var(--brume); font-size: 10.5px; line-height: 1.35; }
.pil-kpi.is-ok b { color: var(--ok); }
.pil-kpi.is-alerte b { color: var(--alerte); }

/* Tableau des jours */
.pil-board {
  position: relative; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity; background: var(--nuit); border: 1px solid var(--mousse);
  scrollbar-width: thin; scrollbar-color: var(--mousse) transparent;
}
.pil-board:focus-visible { outline: 2px solid var(--balise); outline-offset: 2px; }
.pil-grille { position: relative; min-width: calc(var(--n) * var(--col-min)); overflow: hidden; }
.pil-rang { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.pil-j, .pil-m { position: relative; border-left: 1px solid rgba(241, 243, 239, .06); scroll-snap-align: start; }
.pil-j:first-child, .pil-m:first-child { border-left: 0; }
.pil-j.is-lundi, .pil-m.is-lundi { border-left-color: rgba(241, 243, 239, .16); }
.pil-j.is-we, .pil-m.is-we { background: rgba(241, 243, 239, .025); }
.pil-j { height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 6px; border-bottom: 1px solid var(--mousse); }
.pil-j span { font: 500 9px/1 var(--f-mono); font-stretch: 75%; color: var(--brume); }
.pil-j b { font: 700 16px/1.05 var(--f-cond); margin-top: 3px; }
.pil-j i { position: absolute; top: 5px; left: 4px; font: 600 8.5px/1 var(--f-mono); font-stretch: 75%; font-style: normal; color: var(--balise); letter-spacing: .04em; }
.pil-j.is-auj b { color: var(--balise); }
.pil-j.is-auj::after { content: ''; position: absolute; left: 22%; right: 22%; bottom: 0; height: 2px; background: var(--balise); }

/* Météo du jour : température, barre de neige, hachures de verglas, rafales */
.pil-m { height: 70px; border-bottom: 1px solid var(--mousse); overflow: hidden; }
.pil-m__t { position: absolute; top: 5px; left: 0; right: 0; text-align: center; font: 500 9.5px/1.15 var(--f-mono); font-stretch: 75%; color: var(--neige); }
.pil-m__t i { display: block; font-style: normal; color: var(--brume); }
.pil-m__n { position: absolute; left: 30%; right: 30%; bottom: 7px; height: calc(var(--h) * 34px); background: var(--glace); }
.pil-m__cm { position: absolute; left: 0; right: 0; bottom: calc(var(--h, 0) * 34px + 9px); text-align: center; font: 600 9.5px/1 var(--f-mono); font-stretch: 75%; color: var(--glace); }
.pil-m__v { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: repeating-linear-gradient(135deg, var(--balise) 0 2px, transparent 2px 5px); }
.pil-m__r { position: absolute; top: 30px; right: 3px; font: 600 8.5px/1 var(--f-mono); font-stretch: 75%; color: #ff8a5c; }
.pil-m.is-inconnu { background: repeating-linear-gradient(135deg, rgba(241, 243, 239, .035) 0 1px, transparent 1px 7px); }
.pil-m.is-inconnu .pil-m__t { top: 26px; color: #56635c; }

/* Pistes : séjours et passages, positionnées dans le temps (en % de la fenêtre) */
.pil-piste {
  position: relative;
  background: linear-gradient(to right, rgba(241, 243, 239, .06) 1px, transparent 1px) 0 0 / calc(100% / var(--n)) 100%;
}
.pil-piste--sejours { height: 42px; border-bottom: 1px solid var(--mousse); }
.pil-sej {
  position: absolute; top: 8px; bottom: 8px; display: flex; align-items: center; overflow: hidden;
  padding: 0 6px; background: var(--neige); color: var(--nuit); border-radius: 1px;
  font: 600 10px/1 var(--f-mono); font-stretch: 75%; white-space: nowrap; letter-spacing: .02em;
  box-shadow: inset 3px 0 0 var(--nuit);
}
.pil-sej span { overflow: hidden; text-overflow: clip; }
.pil-sej--bloque { background: repeating-linear-gradient(135deg, rgba(241, 243, 239, .22) 0 4px, rgba(241, 243, 239, .06) 4px 8px); color: var(--neige); box-shadow: none; }
.pil-sej.is-coupe { box-shadow: none; -webkit-mask-image: linear-gradient(to right, transparent, #000 14px); mask-image: linear-gradient(to right, transparent, #000 14px); }
.pil-piste--passages { height: 118px; }
.pil--apercu .pil-piste--passages { height: 104px; }

/* Grappe de balises : piquet orange, réflecteurs à lettre */
.pil-grappe {
  position: absolute; bottom: 8px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.pil-piquet { width: 4px; height: 26px; background: var(--balise); transform-origin: 50% 100%; }
.pil-cap {
  width: 22px; height: 19px; padding: 0; border: 0; border-radius: 1px; cursor: pointer;
  background: var(--neige); color: var(--nuit); font: 700 10.5px/19px var(--f-mono); font-stretch: 87.5%; text-align: center;
  transition: background .15s, color .15s, transform .15s;
}
.pil-cap.is-sejour { background: var(--glace); }
.pil-cap:hover { transform: translateY(-1px); background: #fff; }
.pil-cap.is-choisie, .pil-cap.is-choisie:hover { background: var(--balise); color: var(--nuit); }
.pil-cap:focus-visible { outline: 2px solid var(--balise); outline-offset: 2px; }
.pil-plus { font-size: 9px; color: var(--brume); }
.pil-grappe.is-active .pil-piquet { box-shadow: 0 0 0 3px rgba(255, 90, 31, .22); }

/* Plantation (animation) */
.pil-grappe .pil-piquet { transform: scaleY(0); transition: transform .32s cubic-bezier(.2, .9, .2, 1.25); }
.pil-grappe .pil-cap, .pil-grappe .pil-plus { opacity: 0; transform: translateY(-10px); transition: opacity .25s ease .18s, transform .3s cubic-bezier(.2, .9, .2, 1.2) .18s, background .15s; }
.pil-grappe.is-plantee .pil-piquet { transform: scaleY(1); }
.pil-grappe.is-plantee .pil-cap, .pil-grappe.is-plantee .pil-plus { opacity: 1; transform: none; }
.pil-grappe.is-plantee .pil-cap:nth-last-of-type(2) { transition-delay: .24s, .24s, 0s; }
.pil-grappe.is-plantee .pil-cap:nth-last-of-type(3) { transition-delay: .3s, .3s, 0s; }
.pil-grappe.is-plantee .pil-cap:nth-last-of-type(4) { transition-delay: .36s, .36s, 0s; }

.pil-maintenant { position: absolute; top: 50px; bottom: 0; width: 0; border-left: 1px dashed var(--balise); pointer-events: none; z-index: 2; }
.pil-maintenant span { position: absolute; top: 118px; left: 0; padding: 2px 4px; background: var(--balise); color: var(--nuit); font-size: 7.5px; letter-spacing: .05em; white-space: nowrap; }
.pil-maintenant.is-fin span { left: auto; right: 0; }
.pil-balayage {
  position: absolute; top: 0; bottom: 0; left: 0; width: 2px; opacity: 0; pointer-events: none; z-index: 3;
  background: linear-gradient(transparent, var(--balise) 20%, var(--balise) 80%, transparent);
  box-shadow: 0 0 18px 4px rgba(255, 90, 31, .45);
}

/* Légende */
.pil-legende { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 0; color: var(--brume); font-size: 10.5px; align-items: center; }
.pil-legende span { display: inline-flex; align-items: center; gap: 6px; }
.pil-sw { display: inline-block; width: 14px; height: 10px; }
.pil-sw--sejour { background: var(--neige); }
.pil-sw--bloque { background: repeating-linear-gradient(135deg, rgba(241, 243, 239, .4) 0 3px, rgba(241, 243, 239, .08) 3px 6px); }
.pil-sw--neige { background: var(--glace); width: 6px; height: 12px; }
.pil-sw--verglas { background: repeating-linear-gradient(135deg, var(--balise) 0 2px, transparent 2px 4px); height: 6px; }
.pil-cap-l { display: inline-grid; place-items: center; width: 18px; height: 16px; background: var(--neige); color: var(--nuit); font: 700 9.5px/1 var(--f-mono); font-stretch: 87.5%; flex: none; }

/* Fiche du jour choisi */
.pil-detail { margin-top: 14px; background: var(--nuit); border: 1px solid var(--mousse); padding: 14px 16px 6px; min-height: 96px; }
.pil-detail__tete { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding-bottom: 10px; border-bottom: 1px solid var(--mousse); }
.pil-detail__tete > .mono { color: var(--neige); font-size: 11px; letter-spacing: .04em; }
.pil-nav { display: inline-flex; align-items: center; gap: 12px; }
.pil-nav .mono { color: var(--brume); font-size: 10.5px; }
.pil-passage + .pil-passage { border-top: 1px dashed var(--mousse); }
.pil-passage__h { padding-top: 10px; color: var(--balise); font-size: 11px; }
.pil-tache { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; padding: 12px 0; }
.pil-tache + .pil-tache { border-top: 1px solid rgba(241, 243, 239, .07); }
.pil-tache .pil-cap-l { margin-top: 2px; width: 22px; height: 19px; font-size: 10.5px; }
.pil-tache.is-choisie .pil-cap-l { background: var(--balise); }
.pil-tache__l { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 14px; }
.pil-tache__l b { font: 700 18px/1.2 var(--f-cond); }
.pil-tache__l em { font: 500 10px/1 var(--f-mono); font-stretch: 87.5%; font-style: normal; color: var(--glace); margin-left: 6px; text-transform: uppercase; letter-spacing: .04em; vertical-align: 2px; }
.pil-tache__l .chiffre { font-size: 12px; color: var(--neige); white-space: nowrap; }
.pil-tache p { margin: 4px 0 0; font-size: 15px; line-height: 1.45; color: #c9d1cc; max-width: 70ch; }
.pil-vide { margin: 6px 0 10px; color: var(--brume); font-size: 15px; }
.pil-vide:empty { display: none; }

.pil-sorties { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 16px; }
.pil-sorties:empty { display: none; }
.pil-sorties .btn--ligne { color: var(--neige); }
.pil-sorties .btn[disabled] { opacity: .4; pointer-events: none; }

/* Aperçu (accueil) : plus compact */
.pil--apercu .instrument__corps { padding: 14px; }
.pil--apercu .pil-kpi { padding: 12px 12px 10px; }
.pil--apercu .pil-kpi b { font-size: clamp(32px, 3vw, 42px); }
.pil--apercu .pil-detail { min-height: 0; }
.pil--apercu .pil-tache p { font-size: 14px; }
@media (min-width: 760px) { .pil--apercu .pil-resume { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

@media (max-width: 560px) {
  .pil .instrument__corps { padding: 14px; }
  .pil-source { text-align: left; }
  .pil-boutons .btn { flex: 1 1 auto; }
  .pil-detail { padding: 12px 12px 4px; }
  .pil-tache__l b { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .pil-grappe .pil-piquet, .pil-grappe .pil-cap, .pil-grappe .pil-plus { transition: none; }
  .pil-balayage { display: none; }
}
