/* ================================================================
   Apparence du site : une vieille carte du Japon en relief.
   Mer turquoise passée, relief sépia, papier vieilli ; panneaux en
   parchemin cerclés d'un double filet d'encre ; rouge de cartographe
   pour les actions.
   ================================================================ */
:root {
  --papier: #efe4c8;        /* parchemin : panneaux, fiche */
  --papier-clair: #f6eedb;  /* papier neuf : anneau des blasons, texte sur le rouge */
  --papier-fonce: #e4d5b1;  /* champs, survol */
  --trait: #8a6b45;         /* filets d'encre des panneaux */
  --encre: #35251a;         /* encre sépia : texte principal */
  --encre-2: #5b432d;       /* texte secondaire */
  --encre-3: #6e533a;       /* texte discret (contraste ≥ 4,5 même sur --papier-fonce) */
  --rouge: #a8321f;         /* rouge de cartographe : les actions (texte papier dessus : contraste 5,8) */
  --rouge-survol: #8f2716;
  --sarcelle: #1d5652;      /* encre bleu-vert : focus, liens, nom anglais en japonais */
  --mer: #8fbab2;
  --ombre: 0 4px 14px rgba(52, 36, 18, 0.28);
  --filet: inset 0 0 0 3px var(--papier), inset 0 0 0 4px rgba(138, 107, 69, 0.5); /* double filet des cartouches */
  --rayon: 2px;
  /* Noto Sans d'abord : Noto Sans JP dessine mal ō / ū (trait décalé) ; le japonais passe à Noto Sans JP */
  --police: "Noto Sans", "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Zen Antique : caractères d'imprimerie japonaise de l'ère Meiji (latin et japonais) */
  --police-titre: "Zen Antique", "Noto Serif JP", Georgia, serif;
  /* IM Fell : les caractères des imprimeurs du XVIIe siècle, pour les écritures de la carte */
  --police-carte: "IM Fell English", "Zen Antique", Georgia, serif;
  --haut: max(12px, env(safe-area-inset-top));
  --bas: max(12px, env(safe-area-inset-bottom));
  --largeur-fiche: 400px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  /* Grain du papier (petit motif répété) et grandes taches de vieillissement */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .33 0 0 0 0 .22 0 0 0 0 .11 .6 0 0 0 -.26'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --taches: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900'%3E%3Cfilter id='t'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.005' numOctaves='4' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .3 0 0 0 0 .12 .8 0 0 0 -.34'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23t)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--mer);
  color: var(--encre);
  font-family: var(--police);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection { background: var(--sarcelle); color: var(--papier-clair); }
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--sarcelle); outline-offset: 2px; }

#carte { position: fixed; inset: 0; }

/* Papier vieilli posé sur toute la carte (app.js le glisse sous les lieux) : bords brunis, taches, grain.
   Une image fixe, sans flou ni mélange de couleurs : rien n'est recalculé quand la carte bouge. */
.papier {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 82% 78% at 50% 50%, rgba(92, 60, 28, 0) 56%, rgba(92, 60, 28, 0.34) 100%),
    var(--taches) center / cover,
    var(--grain) 0 0 / 240px 240px;
}

/* Panneau en parchemin : plein, sans flou (le flou coûte cher quand la carte bouge) */
.panneau {
  background: var(--grain) 0 0 / 240px 240px, var(--papier);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}

/* ---------- En-tête ---------- */
.entete {
  position: fixed; top: var(--haut); left: 12px; z-index: 5;
  display: flex; align-items: center;
  padding: 6px 14px 6px 6px;
  max-width: calc(100vw - 24px - 150px);
}
.marque { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.logo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; border: 1.5px solid var(--encre); background: var(--papier-fonce); }
.logo[src=""], .logo:not([src]) { display: none; }
.marque-textes { display: flex; flex-direction: column; min-width: 0; }
.titre { font-family: var(--police-titre); font-size: 19px; letter-spacing: 0.01em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sous-titre { font-size: 12px; color: var(--encre-2); line-height: 1.35; }
/* Compteur de visites, à droite du titre, séparé par un filet d'encre (ordinateur seulement) */
.visites {
  display: flex; flex-direction: column; align-items: center; flex: none;
  margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--trait); cursor: default;
}
.visites[hidden] { display: none; }
.visites-nombre {
  font-family: var(--police-titre); font-size: 19px; line-height: 1.15; color: var(--encre);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.visites-mot { font-size: 12px; line-height: 1.35; color: var(--encre-2); }
/* La visite en cours s'ajoute : le chiffre saute un peu */
.visites-nombre.plus-un { animation: plus-un .5s ease-out; }
@keyframes plus-un { 40% { transform: translateY(-3px) scale(1.08); } }

/* ---------- Langues ---------- */
.langues {
  position: fixed; top: var(--haut); right: 12px; z-index: 5;
  display: flex; padding: 3px; gap: 2px;
}
.langues button {
  border: 0; background: transparent; padding: 7px 10px; border-radius: 2px;
  font-size: 13px; font-weight: 500; color: var(--encre-2); transition: background .2s, color .2s;
}
.langues button:hover { color: var(--encre); background: var(--papier-fonce); }
.langues button[aria-pressed="true"] { background: var(--rouge); color: var(--papier-clair); }

/* ---------- Boutons Catégories / Au hasard ---------- */
.filtres { position: fixed; top: calc(var(--haut) + 64px); left: 12px; z-index: 6; max-width: calc(100vw - 24px); }
.filtres > .menu { width: min(340px, calc(100vw - 24px)); }
.bouton-categories {
  display: flex; align-items: center; gap: 8px; padding: 9px 13px;
  font-weight: 500; font-size: 14px; transition: background .2s;
}
.bouton-categories:hover { background-color: var(--papier-fonce); }
.bouton-categories > svg { width: 18px; height: 18px; }
.bouton-categories .chevron { transition: transform .25s var(--ease); opacity: .7; }
.bouton-categories[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.compteur { background: var(--papier-fonce); color: var(--encre-2); padding: 1px 7px; border-radius: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
/* Un menu ouvert passe devant la fiche (sur téléphone, elle occupe le bas de l'écran) */
.filtres:has(> .menu:not([hidden])) { z-index: 9; }
.filtres-boutons { display: flex; align-items: center; gap: 8px; }
.bouton-hasard .de { color: var(--rouge); }
.bouton-hasard[aria-expanded="true"], .bouton-categories[aria-expanded="true"] { border-color: var(--encre-2); background-color: var(--papier-fonce); }

/* ---------- Lieu au hasard (le dé) ---------- */
.hasard-titre { margin: 2px 2px 14px; font-family: var(--police-titre); font-size: 18px; line-height: 1.3; text-wrap: balance; }
.champ-hasard { display: block; margin-bottom: 12px; }
.champ-hasard > span { display: block; margin: 0 2px 6px; font-size: 13px; color: var(--encre-2); }
.champ-hasard select {
  width: 100%; appearance: none; -webkit-appearance: none; cursor: pointer;
  font: inherit; font-size: 15px; color: var(--encre);
  padding: 10px 40px 10px 12px; border: 1px solid var(--trait); border-radius: var(--rayon);
  background: var(--papier-clair) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%235b432d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
}
.champ-hasard select:focus-visible { outline: none; border-color: var(--sarcelle); box-shadow: 0 0 0 1px var(--sarcelle); }
.champ-hasard option, .champ-hasard optgroup { background: var(--papier); color: var(--encre); }
.btn-lancer {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px;
  padding: 13px; border: 0; border-radius: var(--rayon); background: var(--rouge); color: var(--papier-clair);
  font-weight: 700; font-size: 16px; letter-spacing: 0.02em; box-shadow: 0 3px 10px rgba(52, 36, 18, 0.3);
  transition: background .15s;
}
.btn-lancer:hover { background: var(--rouge-survol); }
.btn-lancer:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; background: var(--rouge); }
.btn-lancer .de { width: 22px; height: 22px; }
.hasard-info { margin: 10px 2px 2px; text-align: center; font-size: 13px; color: var(--encre-3); }
.de.roule { animation: roule .6s cubic-bezier(.3, .7, .4, 1); }
@keyframes roule { 40% { transform: rotate(200deg) scale(1.3); } 100% { transform: rotate(360deg); } }

.menu {
  margin-top: 8px; padding: 12px;
  max-height: calc(100dvh - var(--haut) - 140px); overflow: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--trait) transparent;
  box-shadow: var(--filet), var(--ombre);
  animation: apparait .2s var(--ease);
}
@keyframes apparait { from { opacity: 0; transform: translateY(-6px); } }
.recherche {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--papier-clair); border: 1px solid var(--trait); border-radius: var(--rayon);
}
.recherche svg { width: 17px; height: 17px; color: var(--encre-3); flex: none; }
.recherche input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--encre);
  font: inherit; padding: 10px 0; outline: none; caret-color: var(--rouge);
}
.recherche input::placeholder { color: var(--encre-3); }
.recherche:focus-within { border-color: var(--sarcelle); box-shadow: 0 0 0 1px var(--sarcelle); }

.menu-actions { display: flex; gap: 6px; margin: 10px 0 6px; }
.menu-actions button {
  flex: 1; border: 1px solid var(--trait); background: transparent;
  padding: 7px; border-radius: var(--rayon); font-size: 13px; color: var(--encre-2);
}
.menu-actions button:hover { color: var(--encre); background: var(--papier-fonce); }

.liste-categories, .resultats { list-style: none; margin: 0; padding: 0; }
.lien-liste {
  display: block; margin: 8px 0 2px; padding: 8px 8px 2px; border-top: 1px solid rgba(138, 107, 69, 0.4);
  font: italic 15px var(--police-carte); color: var(--sarcelle); text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.lien-liste:hover { color: var(--encre); }
.deplier, .resultats button {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 7px 8px; border-radius: var(--rayon); cursor: pointer; text-align: left;
  border: 0; background: transparent;
}
.resultats button:hover, .resultats button:focus-visible { background: var(--papier-fonce); }
.ligne-tete { display: flex; align-items: center; border-radius: var(--rayon); }
.ligne-tete:hover { background: var(--papier-fonce); }
.ligne-categorie .case { align-self: stretch; display: grid; place-items: center; padding: 0 3px 0 8px; cursor: pointer; }
.ligne-categorie .deplier { flex: 1; min-width: 0; padding-left: 8px; }
.ligne-categorie .deplier:focus-visible { outline: 2px solid var(--sarcelle); outline-offset: -2px; }
.ligne-categorie input { position: absolute; opacity: 0; pointer-events: none; }
.ligne-categorie .nom-cat { flex: 1; min-width: 0; font-size: 14px; }
.ligne-categorie .nb { color: var(--encre-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.chevron-cat { width: 16px; height: 16px; flex: none; color: var(--encre-3); transition: transform .2s var(--ease); }
.deplier[aria-expanded="true"] .chevron-cat { transform: rotate(180deg); }
.ligne-categorie.masquee .pastille, .ligne-categorie.masquee .nom-cat { opacity: .45; }

/* Liste des lieux d'une catégorie (dépliée) */
.sous-liste {
  list-style: none; margin: 2px 0 8px 52px; padding: 0 0 0 12px;
  border-left: 1px solid color-mix(in srgb, var(--c) 70%, transparent);
}
.sous-liste button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  color: var(--encre-2); font-size: 13.5px; line-height: 1.3; padding: 7px 10px; border-radius: var(--rayon);
}
.sous-liste button:hover, .sous-liste button:focus-visible { background: var(--papier-fonce); color: var(--encre); outline: none; }
.sous-liste button.actif { background: color-mix(in srgb, var(--c) 22%, var(--papier)); color: var(--encre); font-weight: 600; }
.ligne-categorie .coche {
  width: 20px; height: 20px; border-radius: 2px; border: 1.5px solid var(--encre-3); flex: none;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.ligne-categorie .coche svg { width: 14px; height: 14px; opacity: 0; color: var(--papier-clair); }
.ligne-categorie input:checked ~ .coche { background: var(--rouge); border-color: var(--rouge); }
.ligne-categorie input:checked ~ .coche svg { opacity: 1; }
.ligne-categorie input:focus-visible ~ .coche { outline: 2px solid var(--sarcelle); outline-offset: 2px; }

/* Blason d'une catégorie : sa couleur du tableau, vieillie vers le sépia, cerclée de papier et d'encre */
.pastille {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: color-mix(in oklab, var(--c, #888) 78%, #4a3521); color: var(--papier-clair);
  box-shadow: inset 0 0 0 1.5px var(--papier-clair), 0 0 0 1px rgba(53, 37, 26, 0.6);
}
.pastille svg { width: 16px; height: 16px; }
.pastille .emoji { font-size: 15px; line-height: 1; }
.resultats { margin-top: 6px; }
.resultats .nom-res { flex: 1; font-size: 14px; }
.resultats .cat-res { color: var(--encre-3); font-size: 12px; }
.resultats .vide { padding: 12px 8px; color: var(--encre-3); font-size: 14px; }

/* ---------- Boutons de la carte ---------- */
.controles {
  position: fixed; right: 12px; bottom: calc(var(--bas) + 24px); z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.controles .panneau { width: 42px; height: 42px; display: grid; place-items: center; transition: background .2s; }
.controles .panneau svg { width: 20px; height: 20px; }
.controles .panneau:hover { background-color: var(--papier-fonce); }

/* Rose des vents : elle tourne avec la carte ; la toucher remet le nord en haut */
.btn-rose {
  width: 58px; height: 58px; padding: 0; margin-bottom: 4px; border: 0; border-radius: 50%;
  background: none; box-shadow: var(--ombre);
}
.rose { width: 100%; height: 100%; will-change: transform; }
.btn-rose:hover .rose circle:first-child { fill: var(--papier-clair); }

/* Bandeau en rouleau « Japan · 日本 · Japon », en bas à gauche, comme le titre des vieilles cartes */
.bandeau {
  position: fixed; left: 8px; bottom: calc(var(--bas) + 2px); z-index: 3; width: 240px; height: 72px;
  pointer-events: none; filter: drop-shadow(0 3px 5px rgba(52, 36, 18, 0.3));
  transform-origin: left bottom;
}
.bandeau-fond { position: absolute; inset: 0; width: 100%; height: 100%; }
.bandeau-texte {
  position: absolute; inset: 0 34px; margin: 0; display: flex; align-items: center; justify-content: center; gap: 11px;
  color: var(--encre); white-space: nowrap;
}
.bandeau-texte span { font-family: var(--police-carte); font-style: italic; font-size: 19px; line-height: 1; }
.bandeau-texte [lang="ja"] { font-family: var(--police-titre); font-style: normal; font-size: 24px; letter-spacing: 0.08em; color: var(--rouge); }
.maplibregl-ctrl-bottom-left { left: 250px; }

/* Noms des mers : italique d'imprimeur, couchés sur l'eau, visibles seulement de loin */
.nom-mer {
  font-family: var(--police-carte); font-style: italic; font-size: 22px; letter-spacing: 0.2em;
  color: #1c4744; white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 3px rgba(173, 208, 199, 0.9), 0 0 8px rgba(173, 208, 199, 0.7);
  opacity: 0.85; transition: opacity .5s;
}
.nom-mer.petit { font-size: 16px; letter-spacing: 0.16em; }
.nom-mer:lang(ja) { font-family: var(--police-titre); font-style: normal; writing-mode: vertical-rl; letter-spacing: 0.4em; font-size: 19px; }
.nom-mer.petit:lang(ja) { font-size: 15px; }
#carte:not(.loin) .nom-mer { opacity: 0; }

/* Noms des grandes régions (capitales espacées) puis des préfectures (italique), écrits sur la terre quand on
   zoome (noms-regions.js). Ils sont sous le papier vieilli, comme imprimés sur la feuille. */
.nom-terre { pointer-events: none; }
.nom-region, .nom-prefecture {
  display: block; white-space: nowrap; color: var(--encre);
  text-shadow: 0 0 2px var(--papier-clair), 0 0 3px var(--papier-clair), 0 0 9px rgba(246, 238, 219, 0.85);
  opacity: 0; visibility: hidden; transition: opacity .6s, visibility 0s .6s;
}
.nom-region { font-family: var(--police-titre); font-size: 26px; letter-spacing: 0.36em; text-transform: uppercase; margin-right: -0.36em; }
.nom-region:lang(ja) { font-size: 26px; letter-spacing: 0.6em; margin-right: -0.6em; }
.nom-prefecture { font-family: var(--police-carte); font-style: italic; font-size: 18px; letter-spacing: 0.06em; }
.nom-prefecture:lang(ja) { font-family: var(--police-titre); font-style: normal; font-size: 16px; letter-spacing: 0.2em; }
#carte.noms-regions .nom-region, #carte.noms-prefectures .nom-prefecture { opacity: 0.92; visibility: visible; transition: opacity .6s; }

/* ---------- La mer vivante (mer.js) : la baleine et le serpent de mer, vus de loin ---------- */
.vie-marine { pointer-events: none; }
.vie-marine svg { display: block; overflow: visible; }
#carte.mer-calme .vie-marine { display: none; }

/* La baleine et le serpent de mer : cachés, ils jouent leur petite scène quand mer.js leur ajoute .joue */
.baleine, .monstre { visibility: hidden; }
.baleine.joue, .monstre.joue { visibility: visible; animation: scene var(--duree-scene) linear; }
.baleine { --duree-scene: 9s; }
.monstre { --duree-scene: 11s; }
@keyframes scene { from { opacity: 1; } to { opacity: 1; } }
.baleine svg { width: 60px; height: 38px; }
.monstre svg { width: 78px; height: 41px; }
.baleine.miroir svg, .monstre.miroir svg { scale: -1 1; }
.vie-marine .remous { fill: none; stroke: #3d6b64; stroke-width: 0.9; stroke-linecap: round; opacity: 0; }
.joue .remous { animation: remous var(--duree-scene) ease-in-out both; }
@keyframes remous { 0% { opacity: 0; } 10%, 85% { opacity: 0.85; } 100% { opacity: 0; } }

.b-corps { fill: #4d6266; stroke: #263537; stroke-width: 0.9; stroke-linejoin: round; }
.b-reflet { fill: none; stroke: #9db4b2; stroke-width: 0.8; stroke-linecap: round; }
.b-jet .jet-fond { fill: none; stroke: #3d6b64; stroke-width: 2.6; stroke-linecap: round; }
.b-jet .jet { fill: none; stroke: #f6eedb; stroke-width: 1.3; stroke-linecap: round; }
.b-jet .goutte { fill: #f6eedb; stroke: #3d6b64; stroke-width: 0.5; }
.b-dos { transform: translateY(15px); }
.b-queue { transform: translateY(20px); }
.b-jet { opacity: 0; transform-origin: 17px 24px; }
.joue .b-dos { animation: baleine-dos 9s ease-in-out both; }
.joue .b-jet { animation: baleine-jet 9s ease-out both; }
.joue .b-queue { animation: baleine-queue 9s ease-in-out both; }
@keyframes baleine-dos {
  0% { transform: translateY(15px); }
  14%, 48% { transform: translateY(0); }
  31% { transform: translateY(-0.8px); }
  62%, 100% { transform: translateY(15px); }
}
@keyframes baleine-jet {
  0%, 16% { opacity: 0; transform: scale(0.2, 0.1); }
  22% { opacity: 1; transform: scale(1, 1); }
  36% { opacity: 0.9; transform: translateY(-2px) scale(1.12, 1.08); }
  46%, 100% { opacity: 0; transform: translateY(-4px) scale(1.2, 1.1); }
}
@keyframes baleine-queue {
  0%, 56% { transform: translateY(20px) rotate(0deg); }
  70% { transform: translateY(0) rotate(-5deg); }
  78% { transform: translateY(1px) rotate(3deg); }
  92%, 100% { transform: translateY(20px) rotate(0deg); }
}
.b-queue { transform-origin: 53px 34px; }

.m-fond { fill: none; stroke: #24352a; stroke-width: 6.2; }
.m-corps { fill: none; stroke: #5f8358; stroke-width: 4.2; }
.m-ecailles { fill: none; stroke: #b3c796; stroke-width: 1; stroke-dasharray: 1.2 2.4; }
.m-crete { fill: #a8321f; stroke: #4a1a10; stroke-width: 0.6; stroke-linejoin: round; }
.m-crane { fill: #5f8358; stroke: #24352a; stroke-width: 0.9; stroke-linejoin: round; }
.m-oeil { fill: #f6eedb; stroke: #24352a; stroke-width: 0.5; }
.m-pupille { fill: #24352a; }
.m-a1 { transform: translateY(12px); }
.m-a2 { transform: translateY(16px); }
.m-tete { transform: translateY(32px); transform-origin: 51px 39px; }
.joue .m-a1 { animation: monstre-a1 11s ease-in-out both; }
.joue .m-a2 { animation: monstre-a2 11s ease-in-out both; }
.joue .m-tete { animation: monstre-tete 11s ease-in-out both; }
@keyframes monstre-a1 {
  0%, 4% { transform: translateY(12px); }
  16% { transform: translateY(0); }
  30% { transform: translateY(1.6px); }
  44% { transform: translateY(-0.6px); }
  58% { transform: translateY(1.6px); }
  70% { transform: translateY(0); }
  84%, 100% { transform: translateY(12px); }
}
@keyframes monstre-a2 {
  0%, 9% { transform: translateY(16px); }
  21% { transform: translateY(0); }
  35% { transform: translateY(1.8px); }
  49% { transform: translateY(-0.6px); }
  63% { transform: translateY(1.8px); }
  74% { transform: translateY(0); }
  88%, 100% { transform: translateY(16px); }
}
@keyframes monstre-tete {
  0%, 14% { transform: translateY(32px) rotate(0deg); }
  28% { transform: translateY(0) rotate(-4deg); }
  42% { transform: translateY(-1px) rotate(5deg); }
  56% { transform: translateY(0) rotate(-3deg); }
  70% { transform: translateY(0) rotate(2deg); }
  92%, 100% { transform: translateY(32px) rotate(0deg); }
}

/* Petit mot d'accueil : un cartouche de papier, affiché à la première visite */
.aide {
  position: fixed; left: 50%; bottom: calc(var(--bas) + 10px); transform: translateX(-50%);
  margin: 0; z-index: 4; font-size: 13px; font-weight: 500; color: var(--encre); white-space: nowrap;
  background: var(--papier-clair); padding: 7px 14px; border-radius: 2px; border: 1px solid var(--trait); box-shadow: var(--ombre);
  pointer-events: none; transition: opacity .8s;
}
.aide.cachee { opacity: 0; }

/* ---------- Repères : blasons ronds cerclés d'encre, petits points quand on voit tout le Japon ---------- */
#carte { --t: 1; --leve: 0px; }
.repere {
  position: relative; width: 0; height: 0; border: 0; padding: 0; background: none; cursor: pointer;
  /* De près, le repère flotte juste au-dessus du modèle 3D de son lieu (couche3d.js règle --leve, et --h par lieu) */
  --lift: calc(var(--leve) * var(--h, 1));
}
.repere-tete {
  position: absolute; left: 0; bottom: calc(8px * var(--t) + var(--lift));
  width: calc(32px * var(--t)); height: calc(32px * var(--t));
  transform: translateX(-50%);
  display: grid; place-items: center; border-radius: 50%;
  background: color-mix(in oklab, var(--c, #a8321f) 78%, #4a3521);
  border: 2px solid var(--papier-clair);
  box-shadow: 0 0 0 1px rgba(53, 37, 26, 0.75), 0 3px 7px rgba(40, 26, 12, 0.4);
  color: var(--papier-clair);
  transition: transform .15s;
}
/* La petite pointe d'encre sous le blason, posée sur le lieu */
.repere-tete::before {
  content: ""; position: absolute; left: 50%; top: calc(100% + 1px); transform: translateX(-50%);
  border: 5px solid transparent; border-top: 7px solid var(--encre); border-bottom: 0;
}
.repere-tete > * { position: relative; }
.repere-tete svg { width: 58%; height: 58%; }
.repere-tete .emoji { font-size: calc(16px * var(--t)); line-height: 1; }
.repere-nom {
  position: absolute; left: 0; bottom: calc(44px * var(--t) + 2px + var(--lift)); transform: translateX(-50%);
  white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--encre);
  background: var(--papier-clair); padding: 4px 9px; border-radius: 2px; border: 1px solid var(--trait);
  box-shadow: 0 2px 6px rgba(52, 36, 18, 0.3);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.repere:hover, .repere:focus-visible, .repere.actif { z-index: 3; }
.repere:hover .repere-nom, .repere:focus-visible .repere-nom, .repere.actif .repere-nom { opacity: 1; }
.repere:hover .repere-tete { transform: translateX(-50%) scale(1.1); }
.repere.actif .repere-tete { box-shadow: 0 0 0 2.5px var(--rouge), 0 0 0 6px rgba(168, 50, 31, 0.28), 0 3px 10px rgba(40, 26, 12, 0.45); }
.repere.actif .repere-tete::before { border-top-color: var(--rouge); }
.repere:focus-visible { outline: none; }
.repere:focus-visible .repere-tete { box-shadow: 0 0 0 1px var(--encre), 0 0 0 4px var(--sarcelle); }

/* Vue lointaine : chaque lieu devient un petit point de la couleur de sa catégorie, pour laisser voir le relief */
#carte.loin .repere-tete { width: 11px; height: 11px; bottom: -5.5px; border-width: 1.5px; box-shadow: 0 0 0 1px rgba(53, 37, 26, 0.8), 0 1px 3px rgba(40, 26, 12, 0.45); }
#carte.loin .repere-tete > *, #carte.loin .repere-tete::before { display: none; }
/* zone à toucher plus grande que le point, pour le doigt */
#carte.loin .repere-tete::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; }
#carte.loin .repere-nom { bottom: 12px; }
#carte.loin .repere.actif .repere-tete { width: 15px; height: 15px; bottom: -7.5px; }

/* ---------- Fiche d'un lieu ---------- */
.fiche {
  /* commence sous les boutons de langue, pour pouvoir changer de langue fiche ouverte */
  position: fixed; z-index: 8; top: calc(var(--haut) + 52px); right: 12px; bottom: 12px; width: var(--largeur-fiche);
  background: var(--grain) 0 0 / 240px 240px, var(--papier); border: 1px solid var(--trait); border-radius: 3px;
  box-shadow: var(--filet), 0 16px 44px rgba(52, 36, 18, 0.4);
  transform: translateX(calc(100% + 24px)); transition: transform .4s var(--ease);
  display: flex; flex-direction: column; overflow: hidden;
}
.fiche.ouverte { transform: none; }
.fiche-defil { overflow: auto; overscroll-behavior: contain; flex: 1; scrollbar-width: thin; scrollbar-color: var(--trait) transparent; margin: 5px; }
.fiche-poignee { display: none; }
.fiche-fermer, .fiche-partager {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px;
  border: 1px solid var(--trait); border-radius: var(--rayon); background: rgba(246, 238, 219, 0.92); color: var(--encre);
  display: grid; place-items: center; transition: background .2s; box-shadow: 0 2px 6px rgba(40, 26, 12, 0.3);
}
.fiche-fermer { top: 15px; right: 15px; }
.fiche-partager { top: 15px; right: 57px; }
.fiche-fermer svg, .fiche-partager svg { width: 18px; height: 18px; }
.fiche-fermer:hover, .fiche-partager:hover { background: var(--papier-clair); }
/* « Un autre ! » : relancer le dé, en haut à gauche de la photo */
.fiche-autre {
  position: absolute; top: 15px; left: 15px; z-index: 4; height: 36px; padding: 0 13px 0 10px;
  display: flex; align-items: center; gap: 7px; border: 0; border-radius: var(--rayon);
  background: var(--rouge); color: var(--papier-clair); font-weight: 700; font-size: 14px;
  box-shadow: 0 3px 10px rgba(40, 26, 12, 0.4);
}
.fiche-autre:hover { background: var(--rouge-survol); }
.fiche-autre .de { width: 18px; height: 18px; }

/* La photo, collée sur la feuille avec un fin filet d'encre */
.fiche-media { position: relative; background: var(--papier-fonce); outline: 1px solid rgba(53, 37, 26, 0.55); }
.fiche-media .vignette {
  position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; border: 0; padding: 0;
  background: var(--papier-fonce) center / cover no-repeat;
}
.fiche-media .lecture {
  position: absolute; z-index: 1; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 8px; padding: 11px 18px 11px 14px; border-radius: var(--rayon);
  background: rgba(53, 37, 26, 0.82); font-weight: 600; font-size: 14px; color: var(--papier-clair);
  border: 1px solid rgba(246, 238, 219, 0.4); transition: background .2s, transform .2s;
}
.fiche-media .lecture svg { width: 20px; height: 20px; }
.fiche-media .vignette:hover .lecture { background: var(--rouge); border-color: var(--rouge); transform: translate(-50%, -50%) scale(1.04); }
.fiche-media .video {
  display: block; width: 100%; aspect-ratio: 9 / 16; max-height: 78vh; border: 0; background: #000;
}
.fiche-media .video-cadre { display: flex; justify-content: center; background: #000; }

/* Cartouche du titre : papier, encre, nom japonais écrit de haut en bas.
   Il se déroule vers le bas à l'ouverture de la fiche. */
.cartouche {
  position: absolute; z-index: 1; top: 60px; right: 14px;
  writing-mode: vertical-rl; text-orientation: upright;
  font-family: var(--police-titre); font-size: 20px; line-height: 1; letter-spacing: 0.14em;
  color: var(--encre); background: var(--papier-clair);
  padding: 12px 8px 10px; max-height: calc(100% - 70px); overflow: hidden;
  outline: 1px solid var(--encre); outline-offset: -4px;
  box-shadow: 0 4px 12px rgba(40, 26, 12, 0.4);
  pointer-events: none; /* un appui dessus lance quand même la vidéo */
  animation: deroule .6s var(--ease) .15s both;
}
@keyframes deroule { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }

.fiche-corps { padding: 6px 18px 20px; }
.fiche-nom { font-family: var(--police-titre); font-weight: 400; font-size: 27px; line-height: 1.2; margin: 8px 0 4px; text-wrap: balance; }
.fiche-nom-jp { margin: 0 0 4px; color: var(--sarcelle); font-size: 14px; }
.fiche-nom-jp:empty { display: none; }
.fiche-categorie { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; font-size: 13.5px; color: var(--encre-2); }
.fiche-categorie .pastille { width: 22px; height: 22px; }
.fiche-categorie .pastille svg { width: 13px; height: 13px; }
.fiche-boutons { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 18px; }
.fiche-boutons a, .fiche-boutons button {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: var(--rayon);
  border: 1px solid var(--trait); background: var(--papier-clair); color: var(--encre);
  text-decoration: none; font-size: 13.5px; font-weight: 500; transition: background .2s, border-color .2s;
}
.fiche-boutons a:hover, .fiche-boutons button:hover { border-color: var(--encre-2); background: var(--papier-fonce); }
.fiche-boutons .principal { background: var(--rouge); border-color: var(--rouge); color: var(--papier-clair); font-weight: 600; }
.fiche-boutons .principal:hover { background: var(--rouge-survol); border-color: var(--rouge-survol); }
.fiche-boutons svg { width: 16px; height: 16px; }
.fiche-description { color: var(--encre); line-height: 1.7; font-size: 15px; margin: 0; max-width: 65ch; padding-top: 16px; border-top: 1px solid rgba(138, 107, 69, 0.5); }
.fiche-plus { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; }
.fiche-plus:empty { display: none; }
.fiche-plus a { display: inline-flex; align-items: center; gap: 6px; color: var(--sarcelle); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.fiche-plus a:hover { color: var(--encre); }
.fiche-plus svg { width: 15px; height: 15px; }

/* ---------- Chargement & message ---------- */
/* Vagues seigaiha (le motif des mers sur les vieilles cartes japonaises), très discrètes, sur l'écran de chargement */
.chargement {
  position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 16px;
  --f: var(--papier); --v: #e3d4ae;
  background-color: var(--f);
  background-image:
    radial-gradient(circle at 100% 150%, var(--f) 24%, var(--v) 25%, var(--v) 28%, var(--f) 29%, var(--f) 36%, var(--v) 36%, var(--v) 40%, transparent 40%, transparent),
    radial-gradient(circle at 0 150%, var(--f) 24%, var(--v) 25%, var(--v) 28%, var(--f) 29%, var(--f) 36%, var(--v) 36%, var(--v) 40%, transparent 40%, transparent),
    radial-gradient(circle at 50% 100%, var(--v) 10%, var(--f) 11%, var(--f) 23%, var(--v) 24%, var(--v) 30%, var(--f) 31%, var(--f) 43%, var(--v) 44%, var(--v) 50%, var(--f) 51%, var(--f) 63%, var(--v) 64%, var(--v) 71%, transparent 71%, transparent),
    radial-gradient(circle at 100% 50%, var(--v) 5%, var(--f) 6%, var(--f) 15%, var(--v) 16%, var(--v) 20%, var(--f) 21%, var(--f) 30%, var(--v) 31%, var(--v) 35%, var(--f) 36%, var(--f) 45%, var(--v) 46%, var(--v) 49%, transparent 50%, transparent),
    radial-gradient(circle at 0 50%, var(--v) 5%, var(--f) 6%, var(--f) 15%, var(--v) 16%, var(--v) 20%, var(--f) 21%, var(--f) 30%, var(--v) 31%, var(--v) 35%, var(--f) 36%, var(--f) 45%, var(--v) 46%, var(--v) 49%, transparent 50%, transparent);
  background-size: 80px 40px;
  transition: opacity .8s; color: var(--encre-2);
}
.chargement.fini { opacity: 0; pointer-events: none; }
.chargement-logo {
  width: 124px; height: 124px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--encre); box-shadow: 0 0 0 5px var(--papier), 0 0 0 6px var(--trait), 0 10px 30px rgba(52, 36, 18, 0.35);
  animation: flotte 1.8s ease-in-out infinite;
}
.chargement p { margin: 0; font-size: 14px; background: var(--papier); padding: 4px 12px; }
@keyframes flotte { 50% { transform: translateY(-6px); } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bas) + 40px); z-index: 30; transform: translate(-50%, 20px);
  background: var(--encre); color: var(--papier-clair); padding: 9px 16px; border-radius: 2px; font-size: 14px; font-weight: 600;
  box-shadow: var(--ombre); opacity: 0; transition: opacity .25s, transform .25s var(--ease); pointer-events: none;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- MapLibre ---------- */
.maplibregl-ctrl-attrib { background: rgba(246, 238, 219, 0.92) !important; color: var(--encre-3) !important; font-size: 10.5px; }
.maplibregl-ctrl-attrib.maplibregl-compact, .maplibregl-ctrl-attrib-button { border-radius: 2px !important; }
.maplibregl-ctrl-attrib.maplibregl-compact-show { border: 1px solid var(--trait); }
.maplibregl-ctrl-attrib a { color: var(--encre-2) !important; }
.maplibregl-ctrl-bottom-left { bottom: var(--bas); }

/* ---------- Nouveautés : étiquette « Nouveau » (encre bleu-vert ; le rouge reste aux actions et aux choix) ---------- */
.etiquette-nouveau {
  display: inline-block; vertical-align: 1px; margin-right: 7px; padding: 0 6px; border-radius: 2px;
  background: var(--sarcelle); color: var(--papier-clair);
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 17px;
}
.sous-liste .etiquette-nouveau { margin: 0 0 0 4px; font-size: 9.5px; line-height: 15px; }
.date-courte { margin-left: 4px; font-size: 12px; color: var(--encre-3); }
.ligne-nouveaux { --c: var(--sarcelle); }
.ligne-nouveaux .case { visibility: hidden; cursor: default; }
.ligne-nouveaux .nom-cat { font-weight: 600; }
.fiche-date { margin: 6px 0 0; font-size: 13px; color: var(--encre-3); }
.fiche-date:empty { display: none; }

/* Sur le blason : un petit cœur rouge (favori) et l'étiquette « Nouveau » */
.repere-tete > .repere-coeur, .repere-tete > .repere-nouveau { position: absolute; display: none; }
.repere.favori .repere-coeur {
  display: grid; place-items: center; top: -5px; left: -6px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--papier-clair); color: var(--rouge); box-shadow: 0 0 0 1px var(--encre);
}
.repere-tete .repere-coeur svg { width: 10px; height: 10px; }
.repere.nouveau .repere-nouveau {
  display: block; top: -11px; left: 52%; white-space: nowrap; padding: 0 4px;
  border: 1px solid var(--papier-clair); border-radius: 2px; background: var(--sarcelle); color: var(--papier-clair);
  font-size: 8.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; line-height: 13px;
  box-shadow: 0 1px 3px rgba(40, 26, 12, 0.4);
}
/* De loin : les nouveaux lieux battent doucement, les favoris ont un anneau rouge */
#carte.loin .repere.favori .repere-tete { box-shadow: 0 0 0 1.5px var(--rouge), 0 1px 3px rgba(40, 26, 12, 0.45); }
#carte.loin .repere.nouveau .repere-tete { animation: pouls-nouveau 2.4s ease-out infinite; }
@keyframes pouls-nouveau {
  0% { box-shadow: 0 0 0 1px rgba(53, 37, 26, 0.8), 0 0 0 3px #1d5652, 0 0 0 3px rgba(29, 86, 82, 0.8); }
  70%, 100% { box-shadow: 0 0 0 1px rgba(53, 37, 26, 0.8), 0 0 0 3px #1d5652, 0 0 0 14px rgba(29, 86, 82, 0); }
}

/* ---------- Favoris ---------- */
.fiche-favori { right: 99px; }
.fiche-favori svg { width: 19px; height: 19px; overflow: visible; }
.fiche-favori path { fill: transparent; stroke: var(--encre); }
.fiche-favori[aria-pressed="true"] path { fill: var(--rouge); stroke: var(--rouge); }
.fiche-favori[aria-pressed="true"] svg { animation: bat .45s var(--ease); }
@keyframes bat { 40% { transform: scale(1.3); } }
.bouton-favoris .coeur, .bouton-visite .camera { color: var(--rouge); }
.bouton-favoris.nouvelle { animation: tampon .7s var(--ease); }
.panneau-info { margin: -6px 2px 12px; font-size: 13px; color: var(--encre-2); line-height: 1.45; }
.liste-favoris { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 2px; }
.liste-favoris li { display: flex; align-items: center; gap: 2px; }
.favori-ligne {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 5px 6px;
  border: 0; border-radius: var(--rayon); background: none; text-align: left; cursor: pointer;
}
.favori-ligne:hover { background: var(--papier-fonce); }
.favori-num { flex: none; width: 18px; text-align: right; font: 400 15px var(--police-titre); color: var(--encre-3); }
.favori-textes { min-width: 0; }
.favori-textes b { display: block; font-weight: 600; font-size: 14px; line-height: 1.3; }
.favori-textes small { display: block; font-size: 12.5px; color: var(--encre-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.favori-retirer {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: var(--rayon); background: none; color: var(--encre-3);
}
.favori-retirer:hover { background: var(--papier-fonce); color: var(--rouge); }
.favori-retirer svg { width: 16px; height: 16px; }
.favoris-actions { display: grid; gap: 8px; }
.btn-itineraire { margin: 0; text-decoration: none; font-size: 15px; }
.btn-itineraire svg { width: 19px; height: 19px; }
.btn-secondaire {
  display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; padding: 11px;
  border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--papier-clair);
  font-weight: 600; font-size: 14.5px; transition: background .15s;
}
.btn-secondaire:hover { background: var(--papier-fonce); }
.btn-secondaire svg { width: 19px; height: 19px; color: var(--rouge); }

/* ---------- Visite guidée (visite.js) ---------- */
.case-option { display: flex; align-items: center; gap: 9px; margin: 2px 2px 14px; font-size: 14px; cursor: pointer; }
.case-option input { width: 17px; height: 17px; margin: 0; flex: none; accent-color: var(--rouge); cursor: pointer; }
.btn-lancer > svg { width: 20px; height: 20px; }
/* La barre de commandes, en bas au centre */
.visite-barre {
  position: fixed; left: 50%; bottom: calc(var(--bas) + 14px); z-index: 12; transform: translateX(-50%);
  display: none; align-items: center; gap: 4px; padding: 5px; transition: opacity .4s;
}
body.en-visite .visite-barre { display: flex; }
.visite-barre button {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: var(--rayon); background: none; color: var(--encre); transition: background .15s;
}
.visite-barre button:hover { background: var(--papier-fonce); }
.visite-barre button:disabled { opacity: .35; cursor: default; background: none; }
.visite-barre svg { width: 20px; height: 20px; }
.visite-barre .visite-pause { background: var(--rouge); color: var(--papier-clair); }
.visite-barre .visite-pause:hover { background: var(--rouge-survol); }
.visite-progres { min-width: 58px; text-align: center; font: 400 15px var(--police-titre); font-variant-numeric: tabular-nums; color: var(--encre-2); }
.visite-arreter { margin-left: 4px; }
/* Le nom du lieu, comme le carton d'un documentaire */
.visite-titre {
  position: fixed; left: 50%; bottom: calc(var(--bas) + 76px); z-index: 11;
  display: flex; align-items: stretch; gap: 14px; max-width: min(640px, calc(100vw - 32px));
  padding: 12px 22px 12px 12px;
  background: var(--grain) 0 0 / 240px 240px, var(--papier); border: 1px solid var(--trait); border-radius: 3px;
  box-shadow: var(--filet), 0 10px 30px rgba(52, 36, 18, 0.4);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.visite-titre.visible { opacity: 1; transform: translate(-50%, 0); }
.visite-titre-ja {
  flex: none; writing-mode: vertical-rl; text-orientation: upright; white-space: nowrap;
  padding: 9px 6px 7px; background: var(--papier-clair); outline: 1px solid var(--encre); outline-offset: -3px;
  font: 400 17px/1 var(--police-titre); letter-spacing: .12em;
}
.visite-titre-textes { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding-left: 4px; }
.visite-titre-textes b { font: 400 28px/1.15 var(--police-titre); text-wrap: balance; }
.visite-titre-textes small { margin-top: 5px; font: italic 16px/1.3 var(--police-carte); color: var(--encre-2); }
html:lang(ja) .visite-titre-textes small { font: 400 14px/1.3 var(--police-titre); }
/* Pendant la visite, la fiche reste fermée et le rouleau du titre laisse la place à la barre */
body.en-visite .bandeau { display: none; }
body.en-visite .maplibregl-ctrl-bottom-left { left: 8px; }
/* Pendant la visite, toucher l'écran fait juste revenir la barre : les repères et les légendes ne s'ouvrent pas */
body.en-visite .repere, body.en-visite .legende { pointer-events: none; }
/* Mode film : la carte, le nom du lieu et les sources ; la barre revient quand on bouge la souris ou touche l'écran */
body.mode-film .entete, body.mode-film .filtres, body.mode-film .langues, body.mode-film .controles,
body.mode-film .aide, body.mode-film .toast, body.mode-film .repere-nom { display: none !important; }
body.mode-film .visite-titre { bottom: calc(var(--bas) + 40px); }
body.mode-film .visite-barre { top: calc(var(--haut) + 6px); bottom: auto; }
body.visite-calme .visite-barre { opacity: 0; pointer-events: none; }
.case-option.sous-option { margin: -8px 2px 14px 26px; }
.case-option:has(input:disabled) { opacity: .45; cursor: default; }
/* La vidéo TikTok du lieu, dans un cadre de papier à double filet (à droite ; en haut sur téléphone).
   Le cadre reste posé, invisible : visite.js lit sa place pour décaler le lieu à côté. */
.visite-video {
  position: fixed; z-index: 11; right: 76px; top: 50%;
  padding: 7px; border: 1px solid var(--trait); border-radius: 3px;
  background: var(--grain) 0 0 / 240px 240px, var(--papier);
  box-shadow: var(--filet), 0 14px 40px rgba(52, 36, 18, 0.45);
  visibility: hidden; opacity: 0; transform: translate(18px, -50%);
  transition: opacity .6s var(--ease), transform .6s var(--ease), visibility 0s linear .6s;
}
.visite-video.visible { visibility: visible; opacity: 1; transform: translate(0, -50%); transition-delay: 0s; }
body.mode-film .visite-video { right: 36px; }
.visite-video-ecran {
  position: relative; height: min(66vh, 600px); aspect-ratio: 9 / 16; overflow: hidden;
  background: #241a10 center / cover no-repeat; outline: 1px solid var(--encre);
}
.visite-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity .5s; }
.visite-video.joue iframe { opacity: 1; }
.visite-video iframe.reserve { opacity: 0 !important; pointer-events: none; } /* la vidéo suivante, qui se charge */
@media (min-width: 721px) {
  /* le nom du lieu se centre dans la place laissée à gauche de la vidéo */
  body.video-visible .visite-titre { left: calc((100vw - var(--video-place, 0px)) / 2); max-width: calc(100vw - var(--video-place, 0px) - 32px); }
}
body.visite-calme, body.visite-calme * { cursor: none !important; }

/* ---------- Téléphone ---------- */
@media (max-width: 720px) {
  /* En-tête sur une seule ligne, pour laisser la place à la carte */
  .entete { padding: 4px 10px 4px 4px; max-width: calc(100vw - 24px - 136px); }
  .logo { width: 30px; height: 30px; border-width: 1.5px; }
  .marque { gap: 8px; }
  .titre { font-size: 15px; }
  .sous-titre, .visites { display: none; }
  .langues { padding: 2px; }
  .langues button { padding: 7px 8px; font-size: 12px; }
  .filtres { top: calc(var(--haut) + 48px); }
  .bouton-categories { padding: 7px 11px; font-size: 13.5px; gap: 7px; }
  .bouton-categories > svg { width: 16px; height: 16px; }
  /* Visite et Favoris : juste l'icône (et le nombre), pour garder la rangée de boutons courte */
  .bouton-visite .texte-bouton, .bouton-favoris .texte-bouton { display: none; }
  .filtres-boutons { gap: 6px; }
  .bouton-visite, .bouton-favoris { padding: 7px 9px; }
  /* les sources sur une seule ligne pendant la visite, sous le nom du lieu */
  body.en-visite .maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib.maplibregl-compact { max-width: calc(100vw - 24px); }
  .visite-barre { gap: 2px; padding: 4px; }
  .visite-barre button { width: 38px; height: 38px; }
  .visite-progres { min-width: 50px; font-size: 14px; }
  .visite-titre { bottom: calc(var(--bas) + 66px); gap: 11px; padding: 10px 16px 10px 10px; width: max-content; }
  .visite-titre-ja { font-size: 15px; padding: 8px 5px 6px; }
  .visite-titre-textes b { font-size: 22px; }
  .visite-titre-textes small { font-size: 14.5px; }
  body.mode-film .visite-titre { bottom: calc(var(--bas) + 56px); }
  /* La vidéo en haut, le lieu dessous ; le titre et les boutons de la carte s'effacent derrière */
  .visite-video { left: 50%; top: var(--haut); padding: 5px; transform: translate(-50%, -14px); }
  .visite-video, body.mode-film .visite-video { right: auto; }
  .visite-video.visible { transform: translate(-50%, 0); }
  .visite-video-ecran { height: min(54dvh, 112vw); }
  body.video-visible .entete, body.video-visible .filtres, body.video-visible .langues { visibility: hidden; }
  .aide { bottom: calc(var(--bas) + 64px); }
  .controles { bottom: calc(var(--bas) + 16px); }
  .btn-rose { width: 50px; height: 50px; }
  .bandeau { transform: scale(0.76); left: 6px; }
  .maplibregl-ctrl-bottom-left { left: 186px; }
  /* le texte des sources passe sur 2 lignes plutôt que sous le bouton Recentrer */
  .maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib.maplibregl-compact { box-sizing: border-box; max-width: calc(100vw - 186px - 72px); }
  .nom-mer { font-size: 15px; letter-spacing: 0.12em; }
  .nom-mer.petit, .nom-mer.petit:lang(ja) { font-size: 12.5px; }
  .nom-mer:lang(ja) { font-size: 16px; }
  .nom-region { font-size: 19px; letter-spacing: 0.3em; margin-right: -0.3em; }
  .nom-region:lang(ja) { font-size: 19px; }
  .nom-prefecture { font-size: 15px; }
  .nom-prefecture:lang(ja) { font-size: 14px; }
  .baleine svg { width: 48px; height: 30px; }
  .monstre svg { width: 62px; height: 33px; }
  .controles #btn-plus, .controles #btn-moins { display: none; }

  /* Tiroir en bas de l'écran : hauteur normale, ou agrandie en tirant la barre vers le haut */
  .fiche {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 64dvh;
    border-radius: 8px 8px 0 0; border-bottom: 0;
    transform: translateY(105%);
    transition: transform .4s var(--ease), height .3s var(--ease);
  }
  .fiche.ouverte { transform: none; }
  .fiche.agrandie { height: calc(100dvh - 60px); }
  .fiche.glisse { transition: none; }
  /* Zone à attraper large (pour le doigt), la petite barre est dessinée au milieu */
  .fiche-poignee {
    display: block; position: absolute; top: 0; left: 22%; right: 22%; height: 34px; z-index: 3;
    touch-action: none; cursor: grab;
  }
  .fiche-poignee::before {
    content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 44px; height: 4px; border-radius: 2px; background: var(--encre);
    box-shadow: 0 0 0 2px rgba(246, 238, 219, 0.8);
  }
  .fiche-media .vignette { aspect-ratio: 16 / 10; }
  .fiche-media .video { max-height: 70dvh; }
  .cartouche { top: 58px; right: 12px; }
  .fiche-nom { font-size: 24px; }
  .fiche-corps { padding: 2px 18px calc(var(--bas) + 12px); }
  .fiche-boutons { gap: 6px; }
  .fiche-boutons a, .fiche-boutons button { padding: 8px 11px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #carte.loin .repere.nouveau .repere-tete { box-shadow: 0 0 0 1px rgba(53, 37, 26, 0.8), 0 0 0 3px #1d5652; }
}
