/* ---------------- coquille : topbar + espace de travail ---------------- */

#app {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 0 24px;
  height: 64px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
  flex: 1;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  transition: all 0.15s ease;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-link.active {
  color: var(--ink);
  background: var(--surface-2);
}

/* Zone compte (connexion/déconnexion), tout à droite de la nav — voir
   refreshAuthUI() dans nav.js. */
.nav-auth {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-auth-email,
.nav-auth-login {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
}

.nav-auth-email:hover,
.nav-auth-login:hover {
  color: var(--ink);
}

.nav-auth-logout {
  background: none;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}

.nav-auth-logout:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.logo .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--pine);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo .name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--ink);
}

.logo .name-accent {
  color: var(--pine);
}

.beta-chip {
  font-family: var(--data);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sun);
  background: var(--sun-wash);
  border-radius: 4px;
  padding: 3px 6px;
}

#workspace {
  position: absolute;
  inset: 64px 0 0 0;
}

/* ---------------- sidebar (floating overlay, Komoot-style) ---------------- */

#sidebar {
  position: absolute;
  left: 16px;
  top: 16px;
  bottom: 16px;
  width: var(--rail-width);
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.rail-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 2px;
}

.hint {
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 0;
}

.hint-small {
  font-size: 0.76rem;
  margin: 10px 0 0;
}

/* ---------------- status ---------------- */

#status {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.85rem;
  min-height: 1.1em;
}

#status:empty,
#status:has(#status-text:empty):has(#status-dismiss.hidden) {
  min-height: 0;
}

#status-text {
  flex: 1;
}

#status-dismiss {
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink-2);
  text-decoration: underline;
  cursor: pointer;
}

#status-dismiss:hover {
  color: var(--ink);
}

#status-dismiss.hidden {
  display: none;
}

/* ---------------- summary card ---------------- */

.summary {
  overflow: hidden;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.summary-top {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0 0 12px 0;
}

.summary-top .big {
  font-family: var(--display);
  font-weight: 700;
  font-size: 44px;
  line-height: 0.85;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.summary-top .big-unit {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink-3);
  padding-bottom: 3px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-top: 12px;
}

.summary-grid .cell {
  padding: 0 12px 0 0;
}

.summary-grid .cell:last-child { }

.summary-grid .k {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 5px;
}

.summary-grid .v {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.summary-grid .v small {
  font-size: 11px;
  color: var(--ink-3);
  margin-left: 1px;
  font-family: var(--body);
  font-weight: 500;
}

/* ---------------- groups (cards) ---------------- */

.group {
  /* .rail-scroll (plus haut dans ce fichier) ajoute déjà 12px de gap entre
     ses enfants flex : ce padding-bottom + ce margin-bottom s'additionnaient
     par-dessus, jusqu'à 16+12+12 = 40px entre deux groupes ("Waypoints",
     "Vitesse moyenne"...) — beaucoup trop pour des sections liées. */
  padding: 0;
  flex-shrink: 0;
  margin-bottom: 0;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.group-head h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Bouton "···" pour déplier une liste repliée (montées, bosses, waypoints
   intermédiaires) : au moins une entrée reste toujours visible, le reste se
   cache derrière ce bouton plutôt que d'encombrer le panneau d'entrée de jeu. */
.climbs-toggle {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-3);
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.climbs-toggle:hover {
  color: var(--pine);
  background: var(--pine-wash);
}

.climbs-toggle.hidden {
  display: none;
}

/* Sous forme de bouton texte pleine largeur (pas un "···" compact) : posé
   sous la liste des waypoints, pas dans l'en-tête à côté du titre "Waypoints". */
.waypoints-toggle {
  width: 100%;
  text-align: center;
  font-size: 12px;
  margin-top: 6px;
}

/* ---------------- mode buttons ---------------- */

.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.mode {
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 11px 4px 9px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  font: inherit;
  color: inherit;
}

.mode .glyph { font-size: 17px; line-height: 1; }
.mode .glyph svg { display: block; }

.mode .label {
  display: block;
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.mode .sub {
  display: block;
  margin-top: 2px;
  font-size: 9.5px;
  color: var(--ink-3);
  line-height: 1.25;
}

.mode.on {
  border-color: var(--pine);
  background: var(--pine-wash);
}

.mode.on .label { color: var(--pine); }

/* ---------------- effort slider ---------------- */

/* ---------------- custom dropdown ---------------- */

.dropdown {
  position: relative;
}

.dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.dropdown-trigger:hover {
  border-color: var(--line-2);
}

.dropdown-trigger[aria-expanded="true"] {
  border-color: var(--pine);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--pine-wash);
}

.dropdown-current {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dropdown-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--surface-2);
}

.select-caret {
  color: var(--ink-3);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.dropdown-trigger[aria-expanded="true"] .select-caret {
  transform: rotate(180deg);
}

.dropdown-panel {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}

.dropdown-panel.hidden {
  display: none;
}

.dropdown-option {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
}

.dropdown-option:hover,
.dropdown-option:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.dropdown-option.on {
  background: var(--pine-wash);
}

.dropdown-option .dropdown-swatch {
  width: 14px;
  height: 14px;
  box-shadow: none;
}

.opt-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.opt-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.dropdown-option.on .opt-label {
  color: var(--pine);
}

.opt-sub {
  font-size: 11px;
  color: var(--ink-3);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--line-2);
  background: var(--surface);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.check-row input[type="checkbox"]:checked {
  background: var(--pine);
  border-color: var(--pine);
}

.check-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

/* ---------------- speed slider ---------------- */

#speed-control {
  display: block;
  cursor: pointer;
}

.speed-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

#speed-control strong {
  font-family: var(--display);
  font-weight: 700;
  color: var(--pine);
}

#speed {
  width: 100%;
  accent-color: var(--pine);
}

/* ---------------- actions ---------------- */

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field,
#actions input,
input.field {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
  font-family: inherit;
}

.field::placeholder {
  color: var(--ink-3);
}

.field:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 2px var(--pine-wash);
}

.btn-primary {
  background: var(--pine);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--pine-hi);
}

.btn-primary:disabled {
  background: var(--line-2);
  color: var(--ink-3);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--surface-2);
}

/* ---------------- climb list ---------------- */

.climb-list,
.saved-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Repliée : une seule bosse visible, tout le reste caché — y compris les
   titres de catégorie (Route/Gravel/Trail), qui n'ont plus de sens seuls
   avec une unique entrée en dessous. Ciblé en JS (applyNearbyClimbsCollapse,
   app-nearby-climbs.js) : .climb-heading et .climb-row sont mélangés dans le
   même <ul>, :first-of-type ne peut pas distinguer "1re .climb-row" d'un
   simple "1er <li>" (qui est presque toujours un .climb-heading). */
.climb-hidden {
  display: none !important;
}

.list-item-btn {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--pine);
  border-radius: 9px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  color: inherit;
}

.list-item-btn:hover {
  background: var(--pine-wash);
}

.list-item-btn .item-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.list-item-btn .item-meta {
  font-family: var(--data);
  font-size: 0.72rem;
  color: var(--ink-3);
  white-space: nowrap;
  flex-shrink: 0;
}

.list-empty {
  padding: 8px 2px;
  color: var(--ink-3);
}

/* ---------------- empty state (cards) ---------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 20px 14px;
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink-3);
}

.empty-state .empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--pine-wash);
  color: var(--pine);
  margin-bottom: 2px;
}

.empty-state .empty-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-2);
}

.empty-state .empty-sub {
  font-size: 0.78rem;
  line-height: 1.4;
  max-width: 220px;
}

/* ---------------- saved routes ---------------- */

.saved-list li {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 11px 13px;
  font-size: 0.85rem;
}

.saved-list li strong {
  display: block;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-list .route-stats {
  font-family: var(--data);
  font-size: 0.75rem;
  color: var(--ink-3);
  margin-top: 3px;
}

.saved-list .route-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.saved-list button,
.saved-list a {
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: 7px;
  padding: 5px 9px;
  cursor: pointer;
  color: var(--ink-2);
  text-decoration: none;
}

.saved-list button:hover,
.saved-list a:hover {
  background: var(--surface-2);
  border-color: var(--ink-3);
}

.saved-list button[data-action="delete"] {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line-2));
}

.saved-list button[data-action="delete"]:hover {
  background: var(--danger-wash);
}

/* ---------------- canvas: fullscreen map ---------------- */

.canvas {
  position: absolute;
  inset: 0;
}

#map {
  position: absolute;
  inset: 0;
  /* Isole les panes internes de Leaflet (z-index ~200-700) dans leur propre
     contexte d'empilement pour qu'elles ne passent jamais au-dessus des
     panneaux flottants (sidebar, profil, contrôles) malgré leur z-index élevé. */
  z-index: 1;
}

