/**
 * RANDONNÉE PRAYOLS — Styles spécifiques
 * Complète /assets/css/common.css (inclus avant ce fichier)
 */

/* ============================================================================
   VARIABLES
   ========================================================================== */

:root {
  --color-facile:    var(--vert-vif);
  --color-moyen:     var(--orange-vif);
  --color-difficile: var(--rouge-vif);

  --panel-width: 33.333%;
}

/* ============================================================================
   LAYOUT PRINCIPAL  (panneau gauche + carte droite)
   ========================================================================== */

/* Viewport fixe : empêche la page de défiler (common.css utilise min-height,
   ici on verrouille à height pour que le panel défile en interne). */
body { height: 100dvh; }

main {
  display: flex;
  flex: 1;       /* remplit l'espace entre header et footer (sticky footer via common.css) */
  min-height: 0; /* autorise le shrink dans le flex parent */
}

/* ── Panneau ────────────────────────────────────────────────────────────── */

#panel {
  width: var(--panel-width);
  min-width: 280px;
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  background: var(--color-white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* ── Carte Leaflet ──────────────────────────────────────────────────────── */

#map {
  flex: 1;
  min-width: 0;
  z-index: 1;
}

/* Fond blanc au lieu du gris Leaflet par défaut */
#map .leaflet-container { background: var(--color-white); }

/* ============================================================================
   INTRODUCTION REPLIABLE
   ========================================================================== */

#intro-panel {
  border-bottom: 1px solid var(--color-border);
}

.intro-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-light);
  text-align: left;
}

.intro-toggle:hover { color: var(--color-accent); }

.intro-chevron { transition: color 0.15s; }

#intro-content {
  padding: 0 16px 12px;
}

#intro-content.collapsed { display: none; }

/* Le titre H1 du fichier wiki est redondant dans ce contexte */
#intro-content h1 { display: none; }

/* ============================================================================
   CARTES DE CIRCUIT (vue liste)
   ========================================================================== */

.circuit-card {
  padding: var(--spacing-lg);
  margin: var(--spacing-md) var(--spacing-md) 0;
  border-radius: 12px;
  border-top: 4px solid transparent;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  background: var(--color-white);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.circuit-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.13);
}

.circuit-card.active {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.circuit-card[data-difficulty="facile"]    { border-top-color: var(--color-facile); }
.circuit-card[data-difficulty="moyen"]     { border-top-color: var(--color-moyen); }
.circuit-card[data-difficulty="difficile"] { border-top-color: var(--color-difficile); }

.circuit-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin: var(--spacing-xs) 0 var(--spacing-xs);
}

.circuit-stats {
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-bottom: var(--spacing-sm);
}

.circuit-desc {
  font-size: 0.88rem;
  color: var(--color-text);
  line-height: 1.55;
}

#circuits-cards {
  padding-bottom: var(--spacing-md);
}

/* ── Badge difficulté ───────────────────────────────────────────────────── */

.badge-difficulty {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-facile    { background: var(--color-badge-facile-bg);    color: var(--color-badge-facile-text); }
.badge-moyen     { background: var(--color-badge-moyen-bg);     color: var(--color-badge-moyen-text); }
.badge-difficile { background: var(--color-badge-difficile-bg); color: var(--color-badge-difficile-text); }

/* ============================================================================
   VUE DÉTAIL
   ========================================================================== */

.back-circuits {
  display: block;
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--color-white);
  border: none;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  color: var(--color-accent);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  transition: background 0.15s;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.back-circuits:hover {
  background: var(--color-hero-bg);
}

#detail-content {
  padding: var(--spacing-lg);
}

.detail-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin: var(--spacing-sm) 0 var(--spacing-lg);
  color: var(--color-text);
}

/* Grille des stats (4 cases 2×2) */
.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: var(--spacing-lg);
}

.stat-item {
  background: var(--color-surface-light);
  padding: var(--spacing-md);
  text-align: center;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.detail-description {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--color-text);
  margin-bottom: var(--spacing-xl);
}

/* Boutons d'action */
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.btn-gpx,
.btn-wiki {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
}

.btn-gpx {
  background: var(--color-header-dark);
  color: var(--color-white);
}

.btn-wiki {
  background: var(--color-accent);
  color: var(--color-white);
}

.btn-gpx:hover,
.btn-wiki:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ============================================================================
   MARQUEURS WAYPOINTS (divIcon Leaflet)
   ========================================================================== */

.wpt-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--color-white);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-white);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* Tooltip Leaflet personnalisé */
.wpt-tooltip {
  font-size: 0.85rem;
  min-width: 180px;
  max-width: 300px;
  white-space: normal;
  line-height: 1.5;
}

/* ============================================================================
   ÉTATS VIDE / CHARGEMENT
   ========================================================================== */

.panel-loading,
.panel-empty {
  padding: var(--spacing-xl);
  text-align: center;
  color: var(--color-text-light);
  font-size: 0.95rem;
}

/* ── Bouton GPX compact (dans la carte circuit) ─────────────────────────── */

.circuit-card-footer {
  margin-top: var(--spacing-sm);
  display: flex;
  gap: var(--spacing-sm);
}

.btn-gpx-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--color-header-dark);
  color: var(--color-white);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn-gpx-sm:hover { opacity: 0.85; }

/* ============================================================================
   PANNEAU WIKI
   ========================================================================== */

#wiki-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#wiki-content {
  padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-xl);
  overflow-y: auto;
}

/* ============================================================================
   RENDU MARKDOWN (même style que l'app Documentation)
   ========================================================================== */

/* Overrides de taille pour le panneau latéral (base dans common.css) */
.markdown h1 { font-size: 1.5rem; margin-bottom: 16px; padding-bottom: 10px; }
.markdown h2 { font-size: 1.1rem; margin: 24px 0 10px; }
.markdown h3 { font-size: 0.97rem; margin: 18px 0 6px; }
.markdown p  { font-size: 0.9rem; margin-bottom: 12px; }
.markdown ul, .markdown ol { padding-left: 20px; margin-bottom: 12px; }
.markdown li { font-size: 0.9rem; margin-bottom: 3px; }
.markdown blockquote { padding: 6px 14px; margin: 12px 0; }
.markdown table { margin-bottom: 16px; font-size: 0.85rem; }
.markdown th, .markdown td { padding: 6px 10px; }
.markdown hr { margin: 20px 0; }

/* ============================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 680px) {
  /* Le hamburger prend le relais : bouton retour dans le panneau masqué */
  .back-circuits { display: none; }
}

@media (max-width: 768px) {
  main {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--header-h) - var(--footer-h));
  }

  #panel {
    width: 100%;
    min-width: 0;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  #map {
    height: 55vh;
    flex: none;
  }
}
