/* La carte de l'expédition (section Territoire) : cadre, calques animés, panneau d'information, légende.
   Piloté par carte-expedition.js. */

.carte-exp { position: relative; margin-top: 2.5rem; }
.carte-frame {
  position: relative; border-radius: var(--radius-card); overflow: hidden; background: #1B0F2C;
  box-shadow: 0 24px 70px rgba(42, 15, 69, 0.32), 0 0 0 1px rgba(69, 22, 111, 0.35);
}
.carte-scroll { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: rgba(167,200,115,0.5) transparent; -webkit-overflow-scrolling: touch; }
.carte-stage { position: relative; aspect-ratio: 2400 / 1350; width: 100%; }
@media (max-width: 820px) { .carte-stage { width: 920px; max-width: none; } }
.carte-poster, .carte-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.carte-poster { object-fit: cover; transition: opacity 700ms ease; }
.carte-svg { opacity: 0; transition: opacity 700ms ease; }
.carte-exp.is-ready .carte-svg { opacity: 1; }
.carte-exp.is-ready .carte-poster { opacity: 0; pointer-events: none; }

/* Le cadre ne se remplit pas d'un coup : lueur d'attente tant que les calques chargent */
.carte-exp:not(.is-ready) .carte-frame::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 60% at 50% 50%, rgba(167,200,115,0.12), transparent 70%); animation: pano-breathe 3s ease-in-out infinite;
}

/* ----- Calques ----- */
.carte-svg .lieu.is-light { opacity: 0; transform: scale(0.55); transition: opacity 350ms ease, transform 650ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.carte-svg .lieu.is-light.on { opacity: 1; transform: none; }
.carte-svg .nom.is-light { opacity: 0; transition: opacity 600ms ease; }
.carte-svg .nom.is-light.on { opacity: 1; }
.carte-svg .beam { opacity: 0; transform: rotate(-43deg); transition: opacity 400ms ease, transform 900ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.carte-svg .beam.on { opacity: 1; transform: none; animation: beam-breathe 4.4s ease-in-out 1.2s infinite; }
@keyframes beam-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.72; } }
.carte-svg .head .lamp-flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker 1.6s ease-in-out infinite; }
.carte-svg .mono-rows { animation: mono-scroll 17.3s linear infinite; }
@keyframes mono-scroll { to { transform: translateY(-190px); } }

/* Drapeaux : le pied tombe, le tissu se déploie et ondule, la plaque du département apparaît */
.carte-svg .flag { opacity: 0; }
.carte-svg .flag.on { opacity: 1; }
.carte-svg .flag.on .flag-in { animation: flag-drop 650ms cubic-bezier(0.3, 1.45, 0.5, 1) both; }
.carte-svg .flag .plaque { transform: scale(0); }
.carte-svg .flag.on .plaque { animation: flag-plaque 420ms cubic-bezier(0.34, 1.56, 0.64, 1) 260ms both; }
.carte-svg .flag .cloth { transform-box: view-box; animation: flag-wave 2.6s ease-in-out infinite alternate; }
.carte-svg .flag-ring { opacity: 0; transform-box: fill-box; transform-origin: center; }
.carte-svg .flag.pulse .flag-ring { animation: flag-ring 1.1s ease-out infinite; }
@keyframes flag-drop { from { transform: translateY(-54px); } to { transform: none; } }
@keyframes flag-plaque { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes flag-wave { from { transform: skewY(-2.2deg) scaleX(1); } to { transform: skewY(2.2deg) scaleX(0.97); } }
@keyframes flag-ring { 0% { opacity: 0.9; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.5); } }

/* Éclats, feux follets, paillettes */
.carte-svg .spark { animation: spark var(--d) ease-in-out var(--delay) infinite; opacity: 0; }
@keyframes spark { 0% { opacity: 0; transform: translate(0, 0) scale(0.6); } 40% { opacity: 1; transform: translate(var(--sx), calc(var(--rise) * 0.5)) scale(1.15); } 100% { opacity: 0; transform: translate(calc(var(--sx) * -1), var(--rise)) scale(0.7); } }

/* Zones tactiles : un anneau discret au survol, au focus et à la sélection */
.carte-svg .hits .hit { cursor: pointer; outline: none; pointer-events: none; }
.carte-svg .hits .hit.ok { pointer-events: all; }
.carte-svg .hit-ring { fill: rgba(167, 200, 115, 0); stroke: rgba(234, 245, 200, 0); stroke-width: 3; stroke-dasharray: 10 9; transition: fill 250ms ease, stroke 250ms ease; }
.carte-svg .hit.ok:hover .hit-ring, .carte-svg .hit:focus-visible .hit-ring { fill: rgba(167, 200, 115, 0.1); stroke: rgba(234, 245, 200, 0.9); }
.carte-svg .hit.sel .hit-ring { fill: rgba(167, 200, 115, 0.08); stroke: rgba(234, 245, 200, 0.55); animation: hit-march 1.6s linear infinite; }
@keyframes hit-march { to { stroke-dashoffset: -38; } }

/* ----- Panneau d'information + légende ----- */
.carte-panel { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1.25rem; margin-top: 1.25rem; align-items: stretch; }
.carte-info {
  position: relative; overflow: hidden; min-height: 168px; padding: 1.4rem 1.6rem 1.5rem;
  background: var(--night-sky); color: var(--white); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); border: 1px solid rgba(167,200,115,0.22);
  transition: opacity 160ms ease, transform 200ms var(--ease-out);
}
.carte-info.swap { opacity: 0; transform: translateY(6px); }
.carte-info::after {
  content: ''; position: absolute; top: -90px; right: -90px; width: 280px; height: 280px; opacity: 0.1; pointer-events: none;
  background: var(--green-hero);
  -webkit-mask: url(images/motifs/courbes-niveau.svg) center / contain no-repeat; mask: url(images/motifs/courbes-niveau.svg) center / contain no-repeat;
}
.ci-tag { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--green-hero); }
.ci-tag::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--green-hero); box-shadow: 0 0 12px rgba(167,200,115,0.8); }
.carte-info[data-mode="ombre"] .ci-tag { color: #CDBEE3; }
.carte-info[data-mode="ombre"] .ci-tag::before { background: #8F6BC9; box-shadow: 0 0 12px rgba(143,107,201,0.8); }
.ci-title { font-family: 'Marcellus', Georgia, serif; font-weight: 400; font-size: clamp(1.35rem, 2.4vw, 1.75rem); line-height: 1.2; margin: 0.55rem 0 0.5rem; color: var(--white); }
.ci-text { font-size: 0.97rem; color: rgba(255,255,255,0.86); max-width: 56ch; margin: 0; }
.ci-dep { display: inline-block; margin-top: 0.8rem; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.06em; color: var(--purple-dark); background: var(--green-hero); padding: 0.28rem 0.75rem; border-radius: 999px; }
.ci-dep[hidden] { display: none; }

.carte-side { display: flex; flex-direction: column; gap: 1rem; justify-content: space-between; }
.carte-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem 1rem; font-size: 0.84rem; font-weight: 600; color: var(--text); padding: 1rem 1.2rem; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.carte-legend span { display: inline-flex; align-items: center; gap: 0.55rem; }
.lg-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.lg-dot.ombre { background: #45166F; }
.lg-dot.lumiere { background: #A7C873; box-shadow: 0 0 0 2px rgba(78,107,47,0.35); }
.lg-flag { width: 14px; height: 14px; flex-shrink: 0; color: var(--purple); }
.lg-path { width: 22px; height: 0; border-top: 3px dashed var(--purple); opacity: 0.8; flex-shrink: 0; }
.carte-replay { align-self: flex-start; }
.carte-replay[disabled] { opacity: 0.55; cursor: default; transform: none; }
.carte-hint { display: none; font-size: 0.78rem; color: var(--text-light); margin-top: 0.6rem; text-align: center; }
@media (max-width: 820px) { .carte-hint { display: block; } .carte-panel { grid-template-columns: 1fr; } }

/* ----- Pied de section : départements cliquables + appel ----- */
.zones-foot { margin-top: 2rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.25rem 2rem; }
.zones-chips { display: flex; flex-wrap: wrap; gap: 0.6rem; list-style: none; }
.zone-chip {
  display: inline-flex; align-items: center; gap: 0.5rem; font: inherit; font-size: 0.92rem; font-weight: 700; color: var(--text); cursor: pointer;
  padding: 0.5rem 1rem 0.5rem 0.6rem; border-radius: 999px; background: var(--white); border: 1px solid var(--border);
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.zone-chip:hover, .zone-chip:focus-visible { background: var(--tint); border-color: var(--purple); transform: translateY(-2px); box-shadow: var(--shadow-card); }
.zone-chip:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.zone-chip .num { min-width: 2.1rem; text-align: center; font-size: 0.78rem; font-weight: 800; color: #F3F8E4; background: var(--purple); padding: 0.18rem 0.5rem; border-radius: 6px; }
.zone-chip.plain { cursor: default; color: var(--text-light); font-weight: 600; }
.zone-chip.plain:hover { background: var(--white); border-color: var(--border); transform: none; box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  .carte-svg .lieu.is-light, .carte-svg .nom.is-light, .carte-svg .beam, .carte-poster, .carte-svg, .carte-info { transition: none; }
  .carte-svg .mono-rows, .carte-svg .spark, .carte-svg .flag .cloth, .carte-svg .flag.on .flag-in, .carte-svg .flag.on .plaque, .carte-svg .head .lamp-flame, .carte-svg .beam.on, .carte-svg .hit.sel .hit-ring { animation: none; }
  .carte-svg .flag .plaque { transform: none; }
  .carte-svg .spark { opacity: 0.8; }
  .carte-exp:not(.is-ready) .carte-frame::after { animation: none; }
}
@media (max-width: 600px) { .zones-foot { justify-content: center; } .zones-chips { justify-content: center; } }

/* Pastilles de départements : libellés d'origine, avec le repère de lieu */
.zone-chip { padding-left: 0.8rem; }
.zone-chip .icon { width: 18px; height: 18px; color: var(--green); }

/* Hors écran : on suspend les animations de la carte */
.carte-exp.is-off .carte-svg * { animation-play-state: paused; }
/* Mode léger : décors fixes, pas d'animation continue */
html.lite .carte-svg .mono-rows, html.lite .carte-svg .flag .cloth, html.lite .carte-svg .beam.on, html.lite .carte-svg .head .lamp-flame { animation: none; }
html.lite .carte-frame { box-shadow: 0 10px 28px rgba(42, 15, 69, 0.3); }
