/* ==========================================================================
   Questionnaire : descente océan → terre → volcan, et ligne de profondeur.
   Logique et dessins : js/components/journey.js et js/components/lures.js.
   Les animations n’utilisent que transform et opacity (fluides sur iPhone)
   et s’arrêtent si l’appareil demande moins de mouvement.
   ========================================================================== */

body[data-page="questionnaire"] main { position: relative; z-index: 0; padding-bottom: 56px; }
body[data-page="questionnaire"] .ftr { margin-top: 0; }

/* Le titre de la page est posé sur la surface de l’eau */
body[data-page="questionnaire"] .q-intro { position: relative; }

.world-bg {
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  margin-left: -50vw;
  overflow: hidden;
  pointer-events: none;
}
.zone { position: absolute; left: 0; right: 0; }
.zone-fx, .zone-seams, .zone-parts { position: absolute; inset: 0; }
.seam { position: absolute; left: 0; width: 100%; height: 40px; }

/* Questions centrées, avec une colonne de chaque côté (la ligne est dans celle de droite) */
#sections { position: relative; padding: 0 34px; }
@media (max-width: 520px) {
  #sections { margin: 0 calc(var(--gutter) * -1); padding: 0 25px; }
}

/* ---------- Océan ---------- */

/* Rayons de lumière qui ondulent près de la surface */
.zone-ocean .zone-fx::before {
  content: "";
  position: absolute;
  top: 0;
  left: -10%;
  width: 120%;
  height: 34%;
  background: repeating-linear-gradient(102deg, rgba(255, 255, 255, .2) 0 44px, transparent 44px 150px, rgba(255, 255, 255, .1) 150px 186px, transparent 186px 290px);
  -webkit-mask-image: linear-gradient(#000, transparent);
  mask-image: linear-gradient(#000, transparent);
  transform-origin: 50% 0;
  animation: rays 9s ease-in-out infinite alternate;
}
@keyframes rays { from { transform: skewX(-3deg); } to { transform: skewX(3deg); } }

/* Reflets (caustiques) près de la surface, neige marine en profondeur */
.zone-ocean .zone-fx::after {
  content: "";
  position: absolute;
  top: 0;
  left: -200px;
  right: -200px;
  height: 30%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='140' viewBox='0 0 200 140' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M0 30c22-14 40 10 62-2s34-22 58-6 46 6 80-4M10 80c18-10 30 8 52 0s32-18 54-4 40 10 84-2M0 120c26-8 44 6 70-4s40-14 62 0 38 6 68-6'/%3E%3C/svg%3E") 0 0 / 200px 140px;
  opacity: .22;
  -webkit-mask-image: linear-gradient(#000 20%, transparent);
  mask-image: linear-gradient(#000 20%, transparent);
  animation: caustics 14s linear infinite;
}
@keyframes caustics { to { transform: translateX(200px); } }

.zone-ocean .zone-parts::after {
  content: "";
  position: absolute;
  inset: 40% 0 0;
  background-image:
    radial-gradient(1.4px 1.4px at 20px 30px, rgba(225, 242, 255, .55), transparent),
    radial-gradient(1px 1px at 90px 120px, rgba(225, 242, 255, .5), transparent),
    radial-gradient(1.6px 1.6px at 150px 60px, rgba(225, 242, 255, .4), transparent),
    radial-gradient(1px 1px at 60px 190px, rgba(225, 242, 255, .5), transparent);
  background-size: 190px 220px;
  -webkit-mask-image: linear-gradient(transparent, #000 40%);
  mask-image: linear-gradient(transparent, #000 40%);
}
.bubble {
  position: absolute;
  width: var(--s);
  height: var(--s);
  border: 1px solid rgba(225, 245, 255, .75);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .7), rgba(255, 255, 255, .06) 60%);
  animation: rise linear infinite;
}
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(6px, -280px); opacity: 0; }
}
.zone-ocean .wd { color: rgba(10, 52, 98, .4); }
.zone-ocean .wd.whale { color: rgba(6, 30, 66, .45); }
.zone-ocean .wd.jelly { color: #A6ECFF; filter: drop-shadow(0 0 6px rgba(140, 230, 255, .7)); }
.zone-ocean .wd.kelp { color: rgba(30, 90, 70, .7); transform: translateY(-100%); }

/* ---------- Terre ---------- */

.seabed { filter: drop-shadow(0 -2px 0 rgba(255, 255, 255, .25)); }
.zone-terre .zone-fx::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2.5px 2px at 30px 40px, rgba(0, 0, 0, .18), transparent),
    radial-gradient(1.5px 1.5px at 110px 20px, rgba(255, 255, 255, .14), transparent),
    radial-gradient(3px 2.2px at 160px 110px, rgba(0, 0, 0, .14), transparent),
    radial-gradient(1.5px 1.5px at 70px 150px, rgba(255, 255, 255, .12), transparent),
    radial-gradient(2px 1.6px at 200px 80px, rgba(0, 0, 0, .16), transparent);
  background-size: 230px 180px;
}
/* Lueur du magma au fond de la terre */
.zone-terre .zone-fx::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 9%;
  background: radial-gradient(60% 100% at 50% 100%, rgba(255, 210, 120, .55), transparent);
  animation: glow 4s ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: .6; } to { opacity: 1; } }
.zone-terre .wd.shell { color: rgba(250, 236, 210, .75); }
.zone-terre .wd.pebble { color: rgba(60, 38, 22, .45); }
.zone-terre .wd.pebble.deep { color: rgba(30, 26, 24, .45); }
.zone-terre .wd.fossil { color: rgba(245, 228, 196, .62); }
.zone-terre .wd.gem { filter: drop-shadow(0 0 8px rgba(160, 120, 255, .45)); }

/* ---------- Volcan ---------- */

/* Roche du Nether : grain sombre */
.zone-volcan .zone-fx::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(3px 2px at 40px 30px, rgba(0, 0, 0, .22), transparent),
    radial-gradient(2px 2px at 130px 90px, rgba(255, 140, 60, .12), transparent),
    radial-gradient(3px 2.4px at 80px 150px, rgba(0, 0, 0, .2), transparent);
  background-size: 170px 190px;
}
.zone-volcan .zone-fx::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 26%;
  background:
    radial-gradient(40% 60% at 20% 100%, rgba(255, 190, 80, .5), transparent),
    radial-gradient(50% 70% at 80% 100%, rgba(255, 150, 40, .45), transparent);
  animation: glow 3s ease-in-out infinite alternate;
}
.ember {
  position: absolute;
  width: calc(var(--s) * .6);
  height: calc(var(--s) * .6);
  border-radius: 50%;
  background: #FFB347;
  box-shadow: 0 0 6px 2px rgba(255, 120, 30, .75);
  animation: rise-far linear infinite;
}
@keyframes rise-far {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(18px, -420px); opacity: 0; }
}
.zone-volcan .wd.rock { color: rgba(14, 4, 3, .6); }
.zone-volcan .wd.flap { color: rgba(14, 4, 3, .7); }
.crack { stroke: #FF8A2A; filter: drop-shadow(0 0 4px #FF5A0A); animation: glow 2.6s ease-in-out infinite alternate; }
.wd.lava.late .crack { animation-delay: -1.3s; }
.wd.hang { transform: none; }
.flap.late { animation-delay: -3s; }

/* ---------- Décors (marges des grands écrans) ---------- */

.wd {
  position: absolute;
  width: min(var(--w), calc(50vw - 420px));
  transform: translateY(-50%);
}
.wd svg { display: block; width: 100%; height: auto; overflow: visible; }
.wd-left { right: calc(50% + 384px); }
.wd-right { left: calc(50% + 384px); }
.wd.mirror svg { transform: scaleX(-1); }
/* Téléphone : plus petits, au bord de l’écran, un peu cachés sous les questions */
@media (max-width: 1000px) {
  .wd { width: calc(var(--w) * .34); }
  .wd-left { right: auto; left: -10px; }
  .wd-right { left: auto; right: -10px; }
}

.swim { animation: swim 9s ease-in-out infinite alternate; }
.swim.slow { animation-duration: 21s; }
.swim-rev { animation-direction: alternate-reverse; }
@keyframes swim { from { transform: translate(-10px, -50%); } to { transform: translate(10px, calc(-50% - 4px)); } }
.jelly { animation: float 7s ease-in-out infinite; }
.jelly.late { animation-delay: -3.5s; }
@keyframes float { 0%, 100% { transform: translateY(-50%); } 50% { transform: translateY(calc(-50% - 16px)); } }
.jelly-bell { transform-origin: 30px 30px; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scaleY(1); } 50% { transform: scale(1.06, .9); } }
.sway { transform-origin: 50% 100%; animation: sway 5s ease-in-out infinite alternate; }
.sway.late { animation-delay: -2.5s; }
@keyframes sway { from { transform: skewX(-4deg); } to { transform: skewX(4deg); } }
.glint { animation: glint 3.4s ease-in-out infinite; }
@keyframes glint { 0%, 70%, 100% { opacity: 0; } 80% { opacity: 1; } }
.flap { animation: float 6s ease-in-out infinite; }
.bat { transform-origin: 80px 24px; animation: flap .35s ease-in-out infinite alternate; }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(.55); } }

/* ==========================================================================
   Ligne de profondeur
   ========================================================================== */

.depth {
  position: absolute;
  top: 0;
  right: 0;
  bottom: -30px;
  width: 34px;
  pointer-events: none;
  clip-path: inset(0 -120px -60px -120px); /* le fil attaché au leurre s’arrête au début des questions */
}
@media (max-width: 520px) { .depth { width: 25px; } }

/* Pointillés : la partie encore à descendre */
.guide {
  position: absolute;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: repeating-linear-gradient(to bottom, var(--g) 0 5px, transparent 5px 11px);
}
.guide-ocean { --g: rgba(235, 248, 255, .55); }
.guide-terre { --g: rgba(255, 236, 200, .45); }
.guide-volcan { --g: rgba(255, 190, 130, .45); }

/* Le leurre : position sticky, déplacé par le navigateur lui-même (aucun à-coup).
   Son fil fait partie du leurre : ils bougent ensemble, sans jamais se détacher. */
.depth-track { position: absolute; inset: 0 0 30px; }
.depth-lure {
  position: sticky;
  top: 40vh;
  width: 26px;
  height: 50px;
  margin: 0 auto;
}
.lure {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateY(-6px) scale(.8);
  transform-origin: 50% 0;
  transition: opacity .35s ease, transform .35s ease;
}
.lure svg { position: relative; display: block; width: 26px; height: 50px; overflow: visible; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.lure-line { position: absolute; left: 50%; bottom: calc(100% - 2px); height: 6000px; }
/* Eau : fil de pêche clair */
.lure-ocean .lure-line { width: 2px; margin-left: -1px; background: linear-gradient(transparent, rgba(255, 255, 255, .95) 70%); box-shadow: 0 0 4px rgba(255, 255, 255, .5); }
/* Terre : corde ronde (ombre et reflet), torsadée, qui entre dans la tête de la foreuse */
.lure-terre .lure-line {
  bottom: calc(100% - 6px);
  width: 6px;
  margin-left: -3px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(155deg, rgba(60, 34, 12, .32) 0 2px, transparent 2px 5px),
    linear-gradient(90deg, #6A4520, #C99A5E 30%, #F4D9A8 48%, #D3A86E 62%, #7A5226);
  box-shadow: 1px 0 1px rgba(0, 0, 0, .3);
}
/* Volcan : chaîne en fer, maillons ombrés */
.lure-volcan .lure-line {
  width: 5px;
  margin-left: -2.5px;
  background:
    repeating-linear-gradient(to bottom, #2A1C19 0 1px, transparent 1px 7px),
    linear-gradient(90deg, #3A2E2B, #A8968E 45%, #5A4A45);
  box-shadow: 0 0 6px rgba(255, 120, 40, .55);
}
.is-ocean .lure-ocean, .is-terre .lure-terre, .is-volcan .lure-volcan { opacity: 1; transform: none; }
.is-ocean .lure-ocean svg { transform-origin: 50% 0; animation: bob 2.8s ease-in-out infinite; }
.is-terre .lure-terre svg { animation: drill .12s linear infinite alternate; }
.is-volcan .lure-volcan svg { transform-origin: 50% 0; animation: swing 3.2s ease-in-out infinite; }
.lure-glow { animation: glow 1.6s ease-in-out infinite alternate; }
@keyframes bob { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg) translateY(2px); } }
@keyframes drill { from { transform: translateX(-.5px); } to { transform: translateX(.5px); } }
@keyframes swing { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@media (max-width: 520px) {
  .depth-lure, .lure svg { width: 22px; height: 42px; }
}

/* Repères n/total : se remplissent de gauche à droite une fois dépassés */
.depth-mark {
  position: absolute;
  z-index: 1;
  right: 2px;
  overflow: hidden;
  transform: translateY(-50%);
  padding: 2px 7px;
  border: 1px solid var(--mk-line);
  border-radius: 10px;
  background: var(--mk-bg);
  color: var(--mk-ink);
  font: 700 11px/1.35 var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color .45s ease, border-color .45s ease;
}
.depth-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--mk-on);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform .5s cubic-bezier(.3, .7, .3, 1);
}
.depth-mark b { position: relative; font-weight: 700; }
.depth-mark.is-passed { color: var(--mk-on-ink); border-color: transparent; }
.depth-mark.is-passed::before { transform: scaleX(1); }
.m-ocean { --mk-bg: rgba(255, 255, 255, .92); --mk-ink: #1F5F92; --mk-line: rgba(31, 95, 146, .35); --mk-on: linear-gradient(90deg, #1854D8, #7134B4); --mk-on-ink: #fff; }
.m-terre { --mk-bg: #FFF6E6; --mk-ink: #5B3B1E; --mk-line: rgba(91, 59, 30, .35); --mk-on: linear-gradient(90deg, #E3A33B, #C77A22); --mk-on-ink: #2B1A0C; }
.m-volcan { --mk-bg: rgba(30, 10, 8, .85); --mk-ink: #FFC08A; --mk-line: rgba(255, 138, 42, .45); --mk-on: linear-gradient(90deg, #FF8A2A, #E52F40); --mk-on-ink: #fff; }

@media (prefers-reduced-motion: reduce) {
  .zone-parts i { display: none; }
  .depth-mark::before, .lure { transition: none; }
}

/* Le titre du questionnaire est posé sur la surface claire de l’eau, quel que soit le thème */
body[data-page="questionnaire"] .page-title,
body[data-page="questionnaire"] .page-lede { color: var(--ink); text-shadow: none; }

/* Plus d’espace entre les catégories : des créatures y passent */
body[data-page="questionnaire"] .cat { margin-top: 46px; }
.zone-cross { position: absolute; inset: 0; }
.cross { position: absolute; left: 0; right: 0; height: 0; }
.cr { position: absolute; top: 0; width: var(--w); transform: translateY(-50%); }
.cr svg { display: block; width: 100%; height: auto; overflow: visible; }
.cr-go { left: 0; animation: cross linear infinite; }
.cr-back { animation-direction: reverse; }
.cr-flip svg { transform: scaleX(-1); }
@keyframes cross {
  from { transform: translate(-30vw, -50%); }
  to { transform: translate(115vw, calc(-50% + var(--dy, 0px))); }
}
.cross-ocean .cr { color: rgba(8, 44, 88, .5); }
.cross-terre .cr-still { color: rgba(245, 228, 196, .7); }
.cross-volcan .cr { color: rgba(14, 4, 3, .8); top: -6px; }

/* Changement de leurre immédiat, dès que le repère est franchi */
.lure { transition: none; }

/* Encadré « Progression retrouvée » : même fenêtre rétro, en plus compact */
.resume-win { margin-top: 14px; }
.resume-win .trial-bar { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }
.resume-win .trial-body { padding: 9px 11px 11px; }
.resume-win .trial-text { margin-bottom: 8px; font-size: 14px; }
.resume-win .trial-actions { flex-wrap: nowrap; gap: 6px; }
.resume-win .trial-actions .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; }

/* Teinte des blocs (calculée par journey.js d’après le décor juste derrière) */
body[data-page="questionnaire"] .q,
body[data-page="questionnaire"] .submit { background: var(--qb, var(--block)); }
body[data-page="questionnaire"] .q.is-missing { background: var(--red-soft); }
body[data-page="questionnaire"] .q select,
body[data-page="questionnaire"] .q .txt,
body[data-page="questionnaire"] .q .opt-img { background-color: var(--qf, var(--paper)); }
body[data-page="questionnaire"] .q .chip:not([aria-checked="true"]) { background: linear-gradient(var(--qf, #fff), var(--qb2, #ECF0F0)); }
body[data-page="questionnaire"] .trial { background: var(--qf, var(--paper)); }
body[data-page="questionnaire"] .trial-bar { background: var(--qb2, var(--block-2)); }
body[data-page="questionnaire"] .sym { background: var(--qb, var(--block)); }

/* Haut du questionnaire : dernier résultat (petit) et bouton discret de réinitialisation */
.q-tools { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; margin-top: 12px; }
.last-mini { padding: 5px 10px; border-left-width: 3px; }
.last-mini .lr-k { font-size: 10.5px; }
.last-mini .lr-v { font-size: 13px; }
.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(13, 79, 134, .28);
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
  color: #0D4F86;
  font: 700 13.5px/1 var(--sans);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.reset-btn svg { width: 15px; height: 15px; }
.reset-btn:hover { background: rgba(255, 255, 255, .4); }
.reset-btn:active { transform: translateY(1px); }

/* Fenêtre de confirmation (même style rétro que les épreuves) */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 15, 30, .5); }
.modal-win { position: relative; width: min(100%, 360px); }
body .modal .modal-win { background: #FFFFFF; }
body .modal .modal-win .trial-bar { background: linear-gradient(#F4F7FD, #DCE5F6); }
.modal-win .trial-actions { flex-wrap: nowrap; }
.modal-win .trial-actions .btn { flex: 1 1 0; }

/* Le bouchon qui se balance au bord droit (téléphone) ne doit jamais élargir la page :
   coupe horizontale sur <main> (clip ne crée pas de zone de défilement, le leurre reste sticky).
   Seulement quand <main> prend toute la largeur de l’écran : sur ordinateur, il est plus étroit
   que l’écran et la coupe tranchait le décor à gauche et à droite des questions. */
@media (max-width: 728px) { body[data-page="questionnaire"] main { overflow-x: clip; } }
/* Corps transparent : derrière le décor, c’est le fond de secours de <html> (mêmes couleurs,
   posé par journey.js) qui apparaît si Safari n’a pas encore dessiné le décor, jamais du blanc. */
body[data-page="questionnaire"] { background: transparent; }
