/* ============================================================================
   Ephemeris - mise en page propre au service.
   Composants, couleurs, espacements et typographie viennent du design system
   VNCT v2 : cette feuille n'emploie que ses variables.
   ============================================================================ */

/* Toute règle display l'emporte sur l'attribut hidden : on le rétablit. */
[hidden] { display: none !important; }

.eph-page {
  max-width: 44rem;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.vnct-header {
  --vnct-header-max: 44rem;
  /* Le header du DS n'a pas de marge latérale : on l'aligne sur la colonne de contenu. */
  padding-left: max(var(--space-4), env(safe-area-inset-left));
  padding-right: max(var(--space-4), env(safe-area-inset-right));
}

/* La pilule de compte se range à côté de la marque, pas au milieu du header. */
.vnct-header__account { margin-right: auto; }

/* Sur téléphone, la marque, la pilule de compte et les actions ne tiennent pas
   sur une ligne : quand la pilule est rendue elle prend la place de la marque
   (parti du design system pour la variante applicative). Le retour à l'accueil
   passe alors par le lien « Stations » des écrans Station et Favoris. */
@media (max-width: 34rem) {
  .vnct-header:has(.vnct-header__account:not(:empty)) .vnct-header__brand { display: none; }
}
/* Très petits écrans : on rogne les marges plutôt que de laisser déborder. */
@media (max-width: 23.5rem) {
  .vnct-header {
    padding-left: max(var(--space-2), env(safe-area-inset-left));
    padding-right: max(var(--space-2), env(safe-area-inset-right));
  }
  .vnct-header__inner { gap: var(--space-2); }
  .vnct-header .vnct-account-chip { padding: 0 var(--space-3); }
}

/* Lien de retour vers la liste, en tête des écrans Station et Favoris. */
.eph-retour {
  align-self: flex-start;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-decoration: none;
}
.eph-retour:hover { color: var(--text-primary); }
.eph-retour:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-md); }

.eph-titre-page {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin: 0;
}

.eph-titre-section {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin: 0 0 var(--space-3);
}

.eph-etat {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: center;
  margin: 0;
}

/* Invitation à se connecter, écran Favoris. */
.eph-invitation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: center;
}

/* Un prix déclaré il y a plus de 7 jours. */
.eph-vieux { color: var(--warning); }

/* --- Lieu ------------------------------------------------------------------- */
.eph-lieu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.eph-lieu__nom {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
  min-width: 0;
}

.eph-choix {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.eph-choix__titre {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.eph-choix__message {
  color: var(--warning);
  font-size: var(--text-sm);
  margin: 0;
}

.eph-choix__commune .vnct-input { width: 100%; }

.eph-communes {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.eph-communes__choix {
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--text-base);
  cursor: pointer;
}

.eph-communes__choix:hover,
.eph-communes__choix:focus-visible {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.eph-communes__vide {
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: var(--space-2) 0;
}

/* --- Filtres ---------------------------------------------------------------- */
.eph-filtres {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.eph-filtres__ligne {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.eph-filtres__ligne .vnct-seg { flex: 1 1 0; min-width: 0; }

.eph-rayon {
  flex: 0 0 auto;
  width: auto;
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
  font-size: var(--text-sm);
}

/* Six carburants dans un sélecteur : les libellés se resserrent sur petit écran. */
.eph-seg-carburant .vnct-seg__tab,
.eph-seg-periode .vnct-seg__tab {
  padding-left: var(--space-1);
  padding-right: var(--space-1);
  white-space: nowrap;
}

/* --- Liste des stations ------------------------------------------------------- */
.eph-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.eph-ligne {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  transition: border-color var(--duration-fast) var(--ease-smooth);
}

.eph-ligne:hover { border-color: var(--border-hover); }

.eph-ligne__lien {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: inherit;
  text-decoration: none;
}

.eph-ligne__lien:focus-visible {
  outline: 2px solid var(--iris-violet);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.eph-ligne__prix {
  flex: 0 0 auto;
  min-width: 5.6rem;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.eph-ligne__prix--absent {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
}

.eph-ligne__texte {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.eph-ligne__titre {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eph-ligne__lieu {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eph-ligne__details {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.eph-ligne__favori { flex: 0 0 auto; white-space: nowrap; }
.eph-ligne__favori[aria-pressed="true"] { color: var(--accent); }

/* --- Fiche station ------------------------------------------------------------ */
.eph-fiche {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.eph-fiche__texte { min-width: 0; flex: 1 1 14rem; }

.eph-fiche__titre {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin: 0 0 var(--space-1);
}

.eph-fiche__adresse { color: var(--text-secondary); margin: 0; }
.eph-fiche__mentions { color: var(--text-muted); font-size: var(--text-sm); margin: var(--space-1) 0 0; }

#fiche > section { margin-bottom: var(--space-6); }

.eph-tuiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: var(--space-2);
}

.eph-tuile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-smooth);
}

.eph-tuile:hover { border-color: var(--border-hover); }
.eph-tuile[aria-selected="true"] { border-color: var(--accent); box-shadow: var(--glow-iris-sm); }
.eph-tuile:focus-visible { outline: 2px solid var(--iris-violet); outline-offset: 2px; }

.eph-tuile__nom { font-size: var(--text-sm); color: var(--text-secondary); }

.eph-tuile__prix {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
}

.eph-tuile__age { font-size: var(--text-xs); color: var(--text-muted); }
.eph-tuile__age.eph-vieux { color: var(--warning); }

.eph-ruptures {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* --- Courbe ------------------------------------------------------------------- */
.eph-historique__entete {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.eph-historique__entete .eph-titre-section { margin: 0; }

/* Le doigt maintenu sur la courbe sert à lire un prix : sans ces règles, iOS y
   voit un appui long et sélectionne les libellés comme du texte. */
.eph-courbe {
  padding: var(--space-4);
}
/* La règle vise aussi chaque descendant : dans Safari, le texte d'un SVG reste
   sélectionnable quand seul son conteneur porte user-select. */
.eph-courbe,
.eph-courbe * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* Les libellés de la courbe ne reçoivent pas le toucher : il va à la zone de lecture. */
.eph-graphique text { pointer-events: none; }

.eph-courbe__lecture {
  min-height: 1.5em;
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.eph-courbe__vide { color: var(--text-muted); text-align: center; margin: var(--space-6) 0; }

.eph-graphique {
  display: block;
  width: 100%;
  height: 15rem;
  touch-action: pan-y;
  cursor: crosshair;
}

.eph-g-grille { stroke: var(--border-default); stroke-width: 1; vector-effect: non-scaling-stroke; }
.eph-g-texte { fill: var(--text-muted); font-family: var(--font-family); font-size: 12px; }
.eph-g-courbe { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.eph-g-aire { fill: var(--accent); fill-opacity: 0.12; stroke: none; }
.eph-g-repere { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.eph-g-point { fill: var(--accent); stroke: var(--bg-primary); stroke-width: 2; }

.eph-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
}

.eph-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}

.eph-stat dt { font-size: var(--text-sm); color: var(--text-secondary); }

.eph-stat dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.eph-stat dd.eph-stat__detail {
  font-family: var(--font-family);
  font-size: var(--text-xs);
  font-weight: var(--font-normal);
  color: var(--text-muted);
}

.eph-source {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.eph-source p { margin: 0 0 var(--space-1); }

@media (max-width: 30rem) {
  .eph-ligne__lien { gap: var(--space-3); }
  .eph-ligne__prix { min-width: 4.9rem; font-size: var(--text-lg); }
  .eph-fiche__titre { font-size: var(--text-2xl); }
}

/* --- Onglets Favoris / Alertes -------------------------------------------------- */
/* Liens de navigation dans un sélecteur segmenté : l'onglet courant reprend le
   rendu du segment actif du design system ([aria-selected] y vise des boutons). */
.eph-onglets .vnct-seg__tab { text-decoration: none; }
.eph-onglets .vnct-seg__tab[aria-current="page"] { background: var(--accent); color: #1a0f1f; }
[data-theme="light"] .eph-onglets .vnct-seg__tab[aria-current="page"] { color: #ffffff; }

.eph-fiche__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* --- Écran Alertes -------------------------------------------------------------- */
.eph-notifs,
.eph-creation {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.eph-notifs .eph-titre-section,
.eph-creation .eph-titre-section { margin: 0; }
.eph-notifs__texte,
.eph-notifs__aucun,
.eph-creation__station,
.eph-creation__prix,
.eph-creation__aide { margin: 0; font-size: var(--text-sm); color: var(--text-secondary); }
.eph-notifs__aucun { color: var(--warning); }
.eph-creation__station { color: var(--text-primary); font-weight: var(--font-semibold); }
.eph-notifs__actions,
.eph-creation__actions,
.eph-alerte__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.eph-notifs__actions:empty { display: none; }

.eph-reglages {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-5);
}
.eph-reglages .vnct-check { min-height: 44px; }
.eph-seuil { display: flex; flex-direction: column; gap: var(--space-1); }
.eph-seuil .vnct-input { width: 8rem; }
.eph-creation__champ { display: flex; flex-direction: column; gap: var(--space-1); max-width: 14rem; }

.eph-compteur { margin: 0; font-size: var(--text-sm); color: var(--text-muted); }

.eph-alertes { display: flex; flex-direction: column; gap: var(--space-3); }
.eph-alerte-groupe { display: flex; flex-direction: column; gap: var(--space-3); }
.eph-alerte-groupe__titre {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
}
.eph-alerte-groupe__titre a { color: var(--text-primary); text-decoration: none; }
.eph-alerte-groupe__titre a:hover { color: var(--accent); }
.eph-alerte-groupe__lieu { margin: calc(-1 * var(--space-2)) 0 0; font-size: var(--text-sm); color: var(--text-secondary); }

.eph-alerte {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-default);
}
.eph-alerte__tete { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-1) var(--space-2); }
.eph-alerte__carburant { font-weight: var(--font-semibold); color: var(--text-primary); }
.eph-alerte__prix { font-size: var(--text-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.eph-alerte__etat { margin: 0; font-size: var(--text-xs); color: var(--text-muted); }
.eph-alerte--pause .eph-reglages { opacity: 0.5; }

/* --- Alertes sur une commune ---------------------------------------------------- */
.eph-alertes__tete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.eph-creation__champ--large { max-width: none; }
.eph-creation__ligne { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); }
.eph-creation__ligne .eph-creation__champ { flex: 1 1 9rem; }
.eph-creation__lieu { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.eph-seuil .vnct-select { width: 8rem; }

.eph-lien-alerte {
  align-self: flex-start;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-decoration: none;
}
.eph-lien-alerte:hover { text-decoration: underline; }
.eph-lien-alerte:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-md); }

