/* ===== ARBRE DE PANACHAGE DES TRACES (éditions 2027) =====
   Départ → choix J1 → camp → choix J2 → arrivée, reliés par un sentier en
   pointillés (SVG tracé par /js/trace-mix.js).
   Couleurs des traces 2027 : bleu Directe, rouge Grande, noir Intégrale. */

.trace-mix {
  container-type: inline-size;
  margin-top: 1.5rem;
}

.tt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ----- Mise en page : arbre puis bilan ----- */
.tt-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* ----- Arbre ----- */
.trail-tree {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.9rem;
  width: 100%;
}

/* Sentier */
.tt-paths {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: visible;
  pointer-events: none;
}
.tt-path {
  fill: none;
  stroke: rgba(52, 52, 52, 0.2);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 0.1 9;
  transition: stroke 0.25s ease;
}
.tt-path--on {
  stroke-width: 4.5;
  stroke-dasharray: 0.1 11;
  animation: tt-march 0.9s linear infinite;
}
.tt-path--on.tt-path--blue { stroke: #4a90e2; }
.tt-path--on.tt-path--red  { stroke: var(--gold); }
.tt-path--on.tt-path--black { stroke: #343434; }
@keyframes tt-march { to { stroke-dashoffset: -11.1; } }

.tt-node,
.tt-fork { position: relative; z-index: 1; }

/* Étapes (départ, camp, arrivée) : pastilles compactes */
.tt-node {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.3rem 0.45rem;
  max-width: 100%;
  padding: 0.3rem 0.35rem 0.3rem 0.7rem;
  border-radius: 100px;
  background: var(--dark);
  border: 1px solid rgba(52, 52, 52, 0.14);
  text-align: center;
}
.tt-node--finish { padding-right: 0.85rem; }
.tt-node-ico {
  font-size: 0.95rem;
  line-height: 1;
}
.tt-node-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  line-height: 1.1;
  color: var(--cream);
}

/* Jour qui commence à cette étape */
.tt-node-day {
  padding: 0.12rem 0.5rem;
  border-radius: 100px;
  background: #343434;
  color: #fff;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

/* Embranchements */
.tt-fork {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  min-width: 0;
}
.tt-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(0.8rem, 5cqi, 2.2rem);
  max-width: 28.6rem;
  margin: 0 auto;
}
/* Jour à trace unique : une carte centrée, de la largeur d'une colonne */
.tt-cards--single {
  grid-template-columns: minmax(0, 13.2rem);
  justify-content: center;
}
.tt-cards--single .tt-card { cursor: default; }

/* Cartes : photo encadrée façon tirage, chiffres en avant */
.tt-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.4rem;
  border-radius: 13px;
  background: #fff;
  border: 2px solid rgba(52, 52, 52, 0.1);
  box-shadow: 0 2px 10px rgba(52, 52, 52, 0.06);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.tt-card:hover { opacity: 0.9; }
.tt-card:active { transform: scale(0.98); }
.tt-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.tt-card:has(input:focus-visible) {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.tt-card:has(input:checked) {
  opacity: 1;
  transform: translateY(-3px) rotate(-0.6deg);
  box-shadow: 0 10px 26px rgba(52, 52, 52, 0.14);
}
.tt-cards .tt-card:nth-child(2):has(input:checked) { transform: translateY(-3px) rotate(0.6deg); }
.tt-card--blue:has(input:checked) { border-color: #7ab8ff; }
.tt-card--red:has(input:checked)  { border-color: #ff7a7a; }
.tt-card--black:has(input:checked) { border-color: #343434; }

/* Coche « choisie » sur la photo */
.tt-card::after {
  content: "";
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2l2 2 4-4.4' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 70% no-repeat;
  transform: scale(0);
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.tt-card:has(input:checked)::after { transform: scale(1); }
.tt-card--blue:has(input:checked)::after { background-color: #2f6dc0; }
.tt-card--red:has(input:checked)::after  { background-color: #d64b4b; }
.tt-card--black:has(input:checked)::after { background-color: #343434; }

.tt-photo {
  position: relative;
  display: block;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  border: 1px solid rgba(52, 52, 52, 0.15);
  background: var(--sage);
  overflow: hidden;
}
.tt-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.5);
  transition: filter 0.3s ease, transform 0.5s ease;
}
.tt-card:has(input:checked) .tt-photo img { filter: none; transform: scale(1.04); }

/* Repli tant que la photo n'existe pas : montagnes stylisées + mention */
.tt-photo--empty {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 60' preserveAspectRatio='none'%3E%3Cpath d='M0 60 L28 22 L42 38 L64 12 L88 40 L102 28 L120 46 L120 60 Z' fill='%23343434' fill-opacity='0.12'/%3E%3Cpath d='M0 60 L20 42 L38 52 L60 34 L84 54 L104 44 L120 56 L120 60 Z' fill='%23343434' fill-opacity='0.12'/%3E%3C/svg%3E") bottom / 100% 70% no-repeat,
    var(--sage);
}
.tt-card--red .tt-photo--empty { background-color: #f6d9d2; }
.tt-photo--empty::after {
  content: "Photo à venir";
  position: absolute;
  bottom: 0.5rem;
  right: 0.6rem;
  font-size: 0.64rem;
  font-style: italic;
  color: rgba(52, 52, 52, 0.45);
}

/* Nom de la trace posé sur la photo */
.tt-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1;
  padding: 0.18rem 0.6rem;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.8rem;
  font-weight: 600;
}
.tt-card--blue .tt-badge { color: #2f6dc0; }
.tt-card--red .tt-badge  { color: #d64b4b; }
.tt-card--black .tt-badge { color: #343434; }

.tt-card-body {
  padding: 0.5rem 0.35rem 0.25rem;
}
.tt-fig {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.55rem;
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(1.4rem, 4.4cqi, 1.65rem);
  letter-spacing: 0.02em;
  line-height: 1.05;
}
.tt-km { color: var(--cream); }
.tt-card--blue .tt-elev { color: #2f6dc0; }
.tt-card--red .tt-elev  { color: #d64b4b; }
.tt-card--black .tt-elev { color: #343434; }

/* ----- Bilan : même habillage que les pastilles d'étape ----- */
.tt-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  padding: 0.7rem 1.6rem 0.8rem;
  border-radius: 18px;
  background: var(--dark);
  border: 1px solid rgba(52, 52, 52, 0.14);
  color: var(--cream);
  text-align: center;
}
.trace-mix:not(.is-ready) .tt-result { display: none; }
.tt-result-kicker {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(52, 52, 52, 0.55);
}
.tt-result-figs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 1rem;
}
.tt-result-big {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.2rem, 7vw, 2.7rem);
  letter-spacing: 0.03em;
  line-height: 1;
  white-space: nowrap;
}
.tt-result-big--elev { color: var(--gold); }

/* ----- Avertissement en fin de section ----- */
.tt-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  width: fit-content;
  max-width: 100%;
  margin: 1.5rem auto 0;
  padding: 0.6rem 0.95rem;
  border-radius: 10px;
  background: var(--dark-2);
  border-left: 3px solid var(--gold);
}
.tt-notice-ico {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 0.12rem;
  color: var(--gold);
}
.tt-notice p {
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--cream);
}

@media (max-width: 480px) {
  .trail-tree { gap: 1.6rem; }
  .tt-node-pre { display: none; }
  .tt-badge, .tt-card::after { top: 0.6rem; }
  .tt-badge { left: 0.6rem; }
  .tt-card::after { right: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tt-path--on { animation: none; }
  .tt-card, .tt-card::after, .tt-photo img { transition: none; }
}
