@font-face { font-family: 'Indie Flower'; src: url(fonts/IndieFlower-Regular.ttf); font-display: swap; }
@font-face { font-family: 'Patrick Hand'; src: url(fonts/PatrickHand-Regular.ttf); font-display: swap; }

:root {
  --ink: #2638ba;
  --navy: #182280;
  --paper: #ffffff;
  --wash: #eef0fc;
  --hand: 'Indie Flower', 'Comic Sans MS', cursive;
  --text: 'Patrick Hand', 'Comic Sans MS', cursive;
  /* hand-drawn box: uneven corner radii */
  --sketch: 255px 18px 225px 18px / 18px 225px 18px 255px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--navy); font-family: var(--text); }
.marge { fill: var(--paper); }
#map { position: fixed; inset: 0; background: var(--paper); }
.leaflet-container { background: var(--paper); font-family: var(--text); }
.leaflet-control-zoom a { font-family: var(--text); color: var(--ink) !important; border-color: var(--ink) !important; }
.leaflet-bar { border: 2px solid var(--ink) !important; border-radius: var(--sketch) !important; overflow: hidden; }
.leaflet-control-attribution { font-family: var(--text); font-size: 12px; color: var(--ink); background: rgba(255,255,255,.85) !important; }
.leaflet-control-attribution a { color: var(--ink); }

.son button {
  display: block; width: 30px; height: 30px; padding: 0; border: 0; background: #fff; cursor: pointer;
  font-size: 16px; line-height: 30px; text-align: center;
}
.son button:hover { background: var(--wash); }
.son button:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }

/* clickable place names: invisible until hovered */
.lieu { cursor: pointer; transition: fill-opacity .15s; }
.lieu:hover, .lieu.active { fill-opacity: .12 !important; }

/* header + search */
.top {
  position: fixed; top: 12px; left: 12px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 24px));
}
.top h1 {
  margin: 0; padding: 6px 14px; font: 30px/1.1 var(--hand); color: var(--navy);
  background: rgba(255,255,255,.92); border: 2px solid var(--ink); border-radius: var(--sketch);
  box-shadow: 3px 3px 0 var(--navy);
}
.top h1 span { display: block; font-size: 16px; color: var(--ink); }
.search { position: relative; }
#q {
  width: 100%; padding: 9px 14px; font: 19px var(--text); color: var(--navy);
  background: #fff; border: 2px solid var(--ink); border-radius: var(--sketch); outline: none;
  box-shadow: 3px 3px 0 var(--navy);
}
#q:focus { box-shadow: 3px 3px 0 var(--ink), 0 0 0 3px rgba(38,56,186,.18); }
#results {
  list-style: none; margin: 6px 0 0; padding: 4px; max-height: 50vh; overflow: auto;
  background: #fff; border: 2px solid var(--ink); border-radius: 14px 4px 14px 4px;
}
#results li { padding: 6px 10px; font-size: 18px; cursor: pointer; border-radius: 8px; display: flex; justify-content: space-between; gap: 8px; }
#results li small { color: var(--ink); opacity: .7; }
#results li[aria-selected="true"], #results li:hover { background: var(--wash); }

#hint {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 900; margin: 0;
  padding: 6px 16px; font: 19px var(--hand); color: var(--navy); background: rgba(255,255,255,.92);
  border: 2px dashed var(--ink); border-radius: var(--sketch); transition: opacity .6s; pointer-events: none;
  white-space: nowrap;
}
#hint.gone { opacity: 0; }

/* fiche */
#backdrop { position: fixed; inset: 0; z-index: 1100; background: rgba(24,34,128,.08); }
#fiche {
  position: fixed; z-index: 1200; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-.4deg);
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  padding: 22px 24px 18px; background: var(--paper);
  border: 2.5px solid var(--navy); border-radius: var(--sketch); box-shadow: 6px 6px 0 var(--navy);
  font-size: 18px; line-height: 1.35;
}
#close {
  position: absolute; top: 8px; right: 12px; width: 38px; height: 38px; border: 0; background: none;
  font: 34px/1 var(--hand); color: var(--navy); cursor: pointer;
}
#close:hover { color: var(--ink); }
#f-kind { margin: 0; font: 17px var(--hand); color: var(--ink); letter-spacing: .04em; }
#f-name { margin: 2px 40px 10px 0; font: 36px/1.1 var(--hand); color: var(--navy); }
#f-fig { margin: 0 0 12px; }
#f-img { display: block; width: 100%; max-height: 240px; object-fit: cover; border: 2px solid var(--navy); border-radius: 6px 14px 4px 12px; }
#f-fig figcaption { font-size: 13px; text-align: right; margin-top: 3px; }
#f-fig a, #f-more a, #f-share a { color: var(--ink); }
#f-text { margin: 0 0 8px; color: #1d2766; }
#f-more { margin: 0 0 10px; }
#f-coord, #f-share { margin: 6px 0 0; font-size: 16px; color: var(--ink); }
#f-copied { font-family: var(--hand); }
#f-license { margin: 10px 0 0; font-size: 13px; opacity: .75; }

@media (max-width: 640px) {
  .top h1 { font-size: 24px; }
  .top h1 span { display: inline; font-size: 14px; margin-left: 6px; }
  #fiche {
    top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 72vh;
    border-radius: 22px 22px 0 0; box-shadow: 0 -4px 0 var(--navy);
  }
  #hint { font-size: 16px; bottom: 14px; }
}
/* Ouverture : carton de titre, la plume trace côte et routes, puis le dessin apparaît dessous */
#ouverture {
  position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: var(--paper);
  transition: opacity .9s ease-in;
  pointer-events: none;
}
#ouverture.revele { opacity: 0; }
#ouverture svg { position: absolute; }
#ouverture path { fill: none; stroke: var(--navy); stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 2; stroke-dashoffset: 1;  /* trou > 1 : pas de point au bout avant le tracé */ }
#ouverture .route { stroke: var(--ink); opacity: .8; }
#ouverture.trace .cote { stroke-dashoffset: 0; transition: stroke-dashoffset 1.8s cubic-bezier(.4, 0, .3, 1); }
#ouverture.trace .route { stroke-dashoffset: 0; transition: stroke-dashoffset .9s ease-out 1.3s; }
#ouverture.trace p { transition: opacity .6s; opacity: 0; }
#ouverture p {
  margin: 0; text-align: center; font: clamp(44px, 9vw, 96px)/1 var(--hand); color: var(--navy);
  animation: encre .9s ease-out both;
}
#ouverture span { display: block; margin-top: 10px; font-size: .32em; color: var(--ink); letter-spacing: .08em; }
@keyframes encre { from { opacity: 0; transform: translateY(8px); filter: blur(3px); } }

/* Animation d'ambiance (dessins posés sur la carte, en coordonnées de l'image) */
.ambiance { pointer-events: none; }
.ambiance .trait { fill: none; stroke: var(--navy); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.ambiance .halo { fill: none; stroke: #fff; stroke-width: 22; stroke-linecap: round; stroke-linejoin: round; }
.ambiance .voile { fill: #fff; stroke: var(--navy); stroke-width: 7; stroke-linejoin: round; }
.vague { animation: vague 7s ease-in-out infinite both; opacity: 0; }
@keyframes vague { 0%, 100% { opacity: 0; transform: translateX(0); } 35%, 65% { opacity: 1; } 100% { transform: translateX(60px); } }
.tangage { animation: tangage 4s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes tangage { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
.aile .trait { stroke-width: 5; }
.aile .halo { stroke-width: 11; }
.aile { animation: aile .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes aile { to { transform: scaleY(-.5); } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } #ouverture { display: none; } }

/* Animation d'ambiance : la mer vivante (mer-vivante.js), sous les tuiles du reste du dessin */
.mer-vivante { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
