/* ================================================================
   O-ANALYSE — DESIGN SYSTEM
   Direction : Terrain & Cartographique
   Inspiré des cartes d'orientation : sable, forêt, balises orange,
   courbes de niveau, précision topographique.
   ================================================================ */

/* ---- Variables globales (topo palette) ---- */
:root {
  --color-primary: #f27f0d;
  --primary-rgb: 242, 127, 13;
  --color-primary-hover: #d9700b;
  --color-primary-light: rgba(242, 127, 13, 0.12);

  --color-background-light: #f5f0e8;
  --color-background-dark: #1a130a;
  --color-surface-light: #fffdf8;
  --color-surface-dark: #221910;
  --color-surface-dark-raised: #2a1f14;

  --color-border-light: #e2d8cc;
  --color-border-dark: #3a2d21;

  --color-text-primary: #1c1009;
  --color-text-muted: #7a6a58;
  --color-text-primary-dark: #f2ede6;
  --color-text-muted-dark: #9a8a78;

  --shadow-card: 0 1px 3px rgba(26,19,10,.08), 0 4px 12px rgba(26,19,10,.05);
  --shadow-card-hover: 0 4px 20px rgba(242,127,13,.2), 0 1px 4px rgba(26,19,10,.1);
  --shadow-modal: 0 20px 60px rgba(26,19,10,.25);
  --shadow-nav: 0 1px 0 rgba(26,19,10,.08);
}

/* ================================================================
   TEXTURE COURBES DE NIVEAU — fond SVG subtle
   ================================================================ */
.topo-bg {
  background-color: var(--color-background-light);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cellipse cx='80' cy='80' rx='72' ry='40' fill='none' stroke='%23957555' stroke-width='.6' stroke-opacity='.07'/%3E%3Cellipse cx='80' cy='80' rx='52' ry='27' fill='none' stroke='%23957555' stroke-width='.6' stroke-opacity='.07'/%3E%3Cellipse cx='80' cy='80' rx='30' ry='14' fill='none' stroke='%23957555' stroke-width='.6' stroke-opacity='.07'/%3E%3Cpath d='M0 112 Q40 100 80 110 Q120 120 160 110' fill='none' stroke='%23957555' stroke-width='.5' stroke-opacity='.05'/%3E%3Cpath d='M0 132 Q40 120 80 130 Q120 140 160 130' fill='none' stroke='%23957555' stroke-width='.5' stroke-opacity='.05'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 160px 160px;
}
.dark .topo-bg {
  background-color: var(--color-background-dark);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cellipse cx='80' cy='80' rx='72' ry='40' fill='none' stroke='%23c8a87a' stroke-width='.6' stroke-opacity='.04'/%3E%3Cellipse cx='80' cy='80' rx='52' ry='27' fill='none' stroke='%23c8a87a' stroke-width='.6' stroke-opacity='.04'/%3E%3Cellipse cx='80' cy='80' rx='30' ry='14' fill='none' stroke='%23c8a87a' stroke-width='.6' stroke-opacity='.04'/%3E%3Cpath d='M0 112 Q40 100 80 110 Q120 120 160 110' fill='none' stroke='%23c8a87a' stroke-width='.5' stroke-opacity='.03'/%3E%3Cpath d='M0 132 Q40 120 80 130 Q120 140 160 130' fill='none' stroke='%23c8a87a' stroke-width='.5' stroke-opacity='.03'/%3E%3C/svg%3E");
}

/* ================================================================
   CARD TOPO
   ================================================================ */
.card-topo {
  background: var(--color-surface-light);
  border: 1px solid var(--color-border-light);
  border-radius: .5rem;
  box-shadow: var(--shadow-card);
  transition: box-shadow .2s ease, transform .18s ease;
}
.dark .card-topo {
  background: var(--color-surface-dark);
  border-color: var(--color-border-dark);
}
a.card-topo:hover,
button.card-topo:hover,
.card-topo.hoverable:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}

/* ================================================================
   SÉPARATEUR POINTILLÉ TOPO
   ================================================================ */
.sep-topo {
  border: none;
  height: 1px;
  background: repeating-linear-gradient(
    to right,
    var(--color-border-light) 0,
    var(--color-border-light) 5px,
    transparent 5px,
    transparent 10px
  );
  margin: 0;
}
.dark .sep-topo {
  background: repeating-linear-gradient(
    to right,
    var(--color-border-dark) 0,
    var(--color-border-dark) 5px,
    transparent 5px,
    transparent 10px
  );
}

/* ================================================================
   BOUTON PRIMAIRE
   ================================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: 2.75rem;
  padding: 0 1.5rem;
  border-radius: .5rem;
  background: var(--color-primary);
  color: #fff;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .01em;
  border: none;
  cursor: pointer;
  transition: background .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), .3);
  text-decoration: none;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 16px rgba(var(--primary-rgb), .4);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(var(--primary-rgb), .3);
}
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ================================================================
   BOUTON SECONDAIRE
   ================================================================ */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: 2.75rem;
  padding: 0 1.25rem;
  border-radius: .5rem;
  background: transparent;
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  border: 1.5px solid var(--color-border-light);
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
.dark .btn-secondary {
  color: var(--color-text-primary-dark);
  border-color: var(--color-border-dark);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ================================================================
   INPUT TERRAIN
   ================================================================ */
.input-topo {
  width: 100%;
  padding: .625rem 1rem;
  border: 1.5px solid var(--color-border-light);
  border-radius: .5rem;
  background: var(--color-surface-light);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: .875rem;
  line-height: 1.5;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.input-topo:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .15);
}
.dark .input-topo {
  background: var(--color-surface-dark-raised);
  border-color: var(--color-border-dark);
  color: var(--color-text-primary-dark);
}
.dark .input-topo:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .2);
}
.input-topo::placeholder { color: var(--color-text-muted); opacity: 1; }
.dark .input-topo::placeholder { color: var(--color-text-muted-dark); }

/* Desktop : selects filtres s'adaptent à leur contenu (override width:100% de input-topo) */
@media (min-width: 768px) {
  #filter-season, #filter-status, #filter-oscore {
    width: auto;
  }
}

/* label associé */
.label-topo {
  display: block;
  margin-bottom: .375rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: .02em;
}
.dark .label-topo { color: var(--color-text-muted-dark); }

.icon-size-sm {
  font-size: 1rem;
}

/* ================================================================
   BADGE O-SCORE
   ================================================================ */
.oscore-badge {
  display: inline-flex;
  align-items: center;
  padding: .125rem .5rem;
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.oscore-badge.high { background: #dcfce7; color: #166534; }
.oscore-badge.mid  { background: #fff7ed; color: #9a3412; }
.oscore-badge.low  { background: #fee2e2; color: #991b1b; }
.dark .oscore-badge.high { background: rgba(20,83,45,.6);  color: #86efac; }
.dark .oscore-badge.mid  { background: rgba(67,20,7,.6);   color: #fdba74; }
.dark .oscore-badge.low  { background: rgba(69,10,10,.6);  color: #fca5a5; }

/* ================================================================
   ACCENT GÉO — trait orange sous titre
   ================================================================ */
.geo-accent {
  display: inline-block;
}
.geo-accent::after {
  content: '';
  display: block;
  width: 2rem;
  height: 2.5px;
  background: var(--color-primary);
  border-radius: 1px;
  margin-top: 4px;
}

/* version centrée */
.geo-accent-center::after {
  margin-left: auto;
  margin-right: auto;
}

/* ================================================================
   TAG TYPE DE COURSE
   ================================================================ */
.course-tag {
  display: inline-block;
  padding: .125rem .5rem;
  border-radius: 3px;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-left: 3px solid var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary-hover);
}

/* ================================================================
   NAV LINK avec soulignement glissé
   ================================================================ */
.nav-link-topo {
  position: relative;
  color: var(--color-text-muted);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color .2s;
  padding-bottom: 2px;
}
.dark .nav-link-topo { color: var(--color-text-muted-dark); }
.nav-link-topo:hover,
.nav-link-topo.active { color: var(--color-primary); }
.nav-link-topo::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .22s ease;
  border-radius: 1px;
}
.nav-link-topo:hover::after,
.nav-link-topo.active::after { transform: scaleX(1); }

/* ================================================================
   ANIMATIONS PAGE-LOAD — révélation staggerée
   ================================================================ */
@keyframes reveal-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.reveal   { animation: reveal-up .35s ease both; }
.reveal-1 { animation: reveal-up .35s  .06s ease both; }
.reveal-2 { animation: reveal-up .35s  .12s ease both; }
.reveal-3 { animation: reveal-up .35s  .18s ease both; }
.reveal-4 { animation: reveal-up .35s  .24s ease both; }
.reveal-5 { animation: reveal-up .35s  .30s ease both; }

@keyframes pulse-orange {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}
.pulse-orange { animation: pulse-orange 2s ease-in-out infinite; }

/* ================================================================
   HEADER STICKY TOPO
   ================================================================ */
.header-topo {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  background: rgba(255, 253, 248, .92);
  border-bottom: 1px solid var(--color-border-light);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-nav);
}
.dark .header-topo {
  background: rgba(26, 19, 10, .92);
  border-bottom-color: var(--color-border-dark);
}

/* ================================================================
   STAT CARD — affichage de métriques
   ================================================================ */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .75rem 1rem;
  border-radius: .5rem;
  border: 1px solid var(--color-border-light);
  background: var(--color-surface-light);
}
.dark .stat-card {
  background: var(--color-surface-dark);
  border-color: var(--color-border-dark);
}
.stat-card .stat-label {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.dark .stat-card .stat-label { color: var(--color-text-muted-dark); }
.stat-card .stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--color-text-primary);
}
.dark .stat-card .stat-value { color: var(--color-text-primary-dark); }
.stat-card.accent {
  border-color: rgba(var(--primary-rgb), .4);
  background: rgba(var(--primary-rgb), .06);
}
.stat-card.accent .stat-label { color: var(--color-primary-hover); }
.stat-card.accent .stat-value { color: var(--color-primary); }

/* ================================================================
   INDICATEUR BALISE (point orange vivant sur la carte)
   ================================================================ */
.beacon-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .25);
  flex-shrink: 0;
}

/* ================================================================
   FOCUS VISIBLE — accessibilité
   ================================================================ */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ================================================================
   SCROLLBAR WEBKIT — subtile
   ================================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border-light);
  border-radius: 3px;
}
.dark ::-webkit-scrollbar-thumb { background: var(--color-border-dark); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }
