/* SITE10 — les strates de la montagne. En descendant la page on traverse la vraie roche du jeu, dans l'ordre du jeu
   (réglage ROCKS de ../Stonehive/data/reglages.json) : terre, grès, calcaire, ardoise, marbre, granite, basalte, puis
   l'obsidienne et le magma au fond. Les filons (ORES) et les poches de pierres (GEMS) sont posés dans les roches et aux
   profondeurs où le jeu les met. Les motifs (images/roches/, faits par outils/strates-images.py) ne sont demandés qu'en
   arrivant près de leur étage (js/strates.js pose .roche-ici) ; sans JavaScript, tous sont chargés.
   Dans index.html : <div class="roches" data-roche="…"> (la roche du haut de l'étage), puis des <i class="strate"
   data-roche="…" style="--haut:…"> (la roche suivante commence à cette hauteur), des <i class="filon" data-filon="…">
   et des <i class="poche" data-poche="…"> placés en % de l'étage (--x, --y). */

:root {
  --onde-a: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='960' height='80' viewBox='0 0 960 80' preserveAspectRatio='none'%3E%3Cpath d='M0 40 L48 30 L96 34 L144 20 L192 26 L240 44 L288 52 L336 48 L384 60 L432 50 L480 38 L528 42 L576 28 L624 18 L672 24 L720 36 L768 48 L816 56 L864 46 L912 34 L960 40 V80H0Z'/%3E%3C/svg%3E");
  --onde-a-trait: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='960' height='80' viewBox='0 0 960 80' preserveAspectRatio='none'%3E%3Cpath d='M0 40 L48 30 L96 34 L144 20 L192 26 L240 44 L288 52 L336 48 L384 60 L432 50 L480 38 L528 42 L576 28 L624 18 L672 24 L720 36 L768 48 L816 56 L864 46 L912 34 L960 40' fill='none' stroke='%23000' stroke-opacity='.5' stroke-width='16'/%3E%3Cpath d='M0 40 L48 30 L96 34 L144 20 L192 26 L240 44 L288 52 L336 48 L384 60 L432 50 L480 38 L528 42 L576 28 L624 18 L672 24 L720 36 L768 48 L816 56 L864 46 L912 34 L960 40' fill='none' stroke='%23000' stroke-opacity='.85' stroke-width='5'/%3E%3C/svg%3E");
  --onde-b: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='80' viewBox='0 0 1200 80' preserveAspectRatio='none'%3E%3Cpath d='M0 30 L48 44 L96 58 L144 62 L192 50 L240 54 L288 40 L336 22 L384 16 L432 28 L480 24 L528 36 L576 52 L624 48 L672 60 L720 44 L768 30 L816 34 L864 20 L912 26 L960 38 L1008 50 L1056 46 L1104 36 L1152 28 L1200 30 V80H0Z'/%3E%3C/svg%3E");
  --onde-b-trait: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='80' viewBox='0 0 1200 80' preserveAspectRatio='none'%3E%3Cpath d='M0 30 L48 44 L96 58 L144 62 L192 50 L240 54 L288 40 L336 22 L384 16 L432 28 L480 24 L528 36 L576 52 L624 48 L672 60 L720 44 L768 30 L816 34 L864 20 L912 26 L960 38 L1008 50 L1056 46 L1104 36 L1152 28 L1200 30' fill='none' stroke='%23000' stroke-opacity='.5' stroke-width='16'/%3E%3Cpath d='M0 30 L48 44 L96 58 L144 62 L192 50 L240 54 L288 40 L336 22 L384 16 L432 28 L480 24 L528 36 L576 52 L624 48 L672 60 L720 44 L768 30 L816 34 L864 20 L912 26 L960 38 L1008 50 L1056 46 L1104 36 L1152 28 L1200 30' fill='none' stroke='%23000' stroke-opacity='.85' stroke-width='5'/%3E%3C/svg%3E");
}
[data-roche="terre"] { --img: url('../images/roches/terre.webp'); --teinte: #2e2216; }
[data-roche="gres"] { --img: url('../images/roches/gres.webp'); --teinte: #4d3b26; }
[data-roche="calcaire"] { --img: url('../images/roches/calcaire.webp'); --teinte: #45433a; }
[data-roche="ardoise"] { --img: url('../images/roches/ardoise.webp'); --teinte: #2f3640; }
[data-roche="marbre"] { --img: url('../images/roches/marbre.webp'); --teinte: #565452; }
[data-roche="granite"] { --img: url('../images/roches/granite.webp'); --teinte: #453a3a; }
[data-roche="basalte"] { --img: url('../images/roches/basalte.webp'); --teinte: #26262a; }
[data-roche="obsidienne"] { --img: url('../images/roches/obsidienne.webp'); --teinte: #1a1326; }
[data-roche="magma"] { --img: url('../images/roches/magma.webp'); --teinte: #c8580f; }
[data-filon="cuivre"] { --img: url('../images/roches/filon-cuivre.webp'); }
[data-filon="etain"] { --img: url('../images/roches/filon-etain.webp'); }
[data-filon="houille"] { --img: url('../images/roches/filon-houille.webp'); }
[data-filon="fer"] { --img: url('../images/roches/filon-fer.webp'); }
[data-filon="argent"] { --img: url('../images/roches/filon-argent.webp'); }
[data-filon="or"] { --img: url('../images/roches/filon-or.webp'); }
[data-filon="platine"] { --img: url('../images/roches/filon-platine.webp'); }
[data-filon="adamantite"] { --img: url('../images/roches/filon-adamantite.webp'); --l: 288px; --h: 192px; }
[data-poche="topaze"] { --img: url('../images/roches/poche-topaze.webp'); }
[data-poche="emeraude"] { --img: url('../images/roches/poche-emeraude.webp'); }
[data-poche="saphir"] { --img: url('../images/roches/poche-saphir.webp'); }
[data-poche="rubis"] { --img: url('../images/roches/poche-rubis.webp'); }
[data-poche="diamant"] { --img: url('../images/roches/poche-diamant.webp'); }
[data-poche="etoile-abysses"] { --img: url('../images/roches/poche-etoile-abysses.webp'); }

/* ── La roche d'un étage : derrière tout le reste ── */
main .etage { background-color: #0d0b0a; }
.roches { position: absolute; inset: 0; z-index: -1; overflow: hidden; isolation: isolate; pointer-events: none;
  background-color: var(--teinte); background-size: 288px 288px; }
.strate { position: absolute; left: 0; right: 0; top: var(--haut); bottom: 0; background-color: var(--teinte); background-size: 288px 288px;
  -webkit-mask: var(--onde-a) var(--dx, 0px) 0 / 960px 80px repeat-x, linear-gradient(#000, #000) 0 79px / 100% 100% no-repeat;
  mask: var(--onde-a) var(--dx, 0px) 0 / 960px 80px repeat-x, linear-gradient(#000, #000) 0 79px / 100% 100% no-repeat; }
/* (l'ombre de la couche du dessus sur celle du dessous : le même tracé, en trait sombre) */
.strate::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 80px; background: var(--onde-a-trait) var(--dx, 0px) 0 / 960px 80px repeat-x; }
.strate.b { -webkit-mask-image: var(--onde-b), linear-gradient(#000, #000); mask-image: var(--onde-b), linear-gradient(#000, #000);
  -webkit-mask-size: 1200px 80px, 100% 100%; mask-size: 1200px 80px, 100% 100%; }
.strate.b::before { background-image: var(--onde-b-trait); background-size: 1200px 80px; }

/* les filons de minerai et les poches de pierres précieuses : les dessins du jeu, posés sur la roche */
.filon, .poche { position: absolute; left: var(--x); top: var(--y); background-repeat: no-repeat; background-size: 100% 100%; }
.filon { width: var(--l, 384px); height: var(--h, 288px); margin: calc(var(--h, 288px) / -2) 0 0 calc(var(--l, 384px) / -2); z-index: 1; }
.filon.retourne { transform: scaleX(-1); }
.poche { width: 192px; height: 96px; margin: -48px 0 0 -96px; z-index: 3; filter: drop-shadow(0 0 10px #000); }
/* (l'éclat du jeu, gemShine : une étoile par poche) */
.poche::after { content: ''; position: absolute; left: var(--ex, 34%); top: var(--ey, -8%); width: 64px; height: 64px; background-size: 192px 64px; background-position: var(--e, 0) 0; opacity: 0.8; }
.poche:nth-of-type(2n)::after { --e: -64px; --ex: 52%; --ey: 4%; }
.poche:nth-of-type(3n)::after { --e: -128px; --ex: 8%; --ey: 0%; }

/* le voile : la roche se voit sur les côtés, elle s'assombrit sous la colonne des textes */
.roches::after { content: ''; position: absolute; inset: 0; z-index: 2;
  background: var(--lumiere, linear-gradient(transparent, transparent)),
    linear-gradient(90deg, #0a080759, #0a0807cc 21%, #0a0807d6 50%, #0a0807cc 79%, #0a080759); }
.ateliers .roches { --lumiere: radial-gradient(40% 18% at 12% 20%, #e0662a1c, transparent 70%), radial-gradient(40% 18% at 88% 55%, #e0662a1c, transparent 70%); }
.tresor .roches { --lumiere: radial-gradient(60% 45% at 50% 50%, #f0c36a33, #e0a04010 55%, transparent 75%); }

/* les motifs ne sont demandés qu'en approchant (.roche-ici) ; sans JavaScript, tout de suite */
html:not(.js-strates) :is(.roches, .strate, .filon, .poche), .roche-ici :is(.roches, .strate, .filon, .poche) { background-image: var(--img); }
html:not(.js-strates) .magma::before, .roche-ici .magma::before { background-image: var(--img); }
html:not(.js-strates) .poche::after, .roche-ici .poche::after { background-image: url('../images/roches/eclat.webp'); }

/* ── Les galeries passent dans la roche de leur profondeur (assombrie : les nains d'abord) ── */
html:not(.js-strates) .galerie[data-roche], .galerie[data-roche].roche-ici {
  background: linear-gradient(#0a0807f2, #0a0807a6 30%, #0a08078c 62%, #0a0807e6), var(--img) 0 0 / 288px 288px, var(--teinte); }

/* ── Le fond : le magma autour du trésor (deux lacs sur les côtés, une mer sous la corniche des nains) ── */
.tresor { padding-bottom: 150px !important; }
.magma { position: absolute; z-index: 3; overflow: hidden; background-color: var(--teinte); }
.magma::before { content: ''; position: absolute; inset: 0 -288px -288px 0; background-size: 288px 288px; }
/* (un peu assombri : le bouton Steam et le trésor doivent rester ce qui brille le plus) */
.magma::after { content: ''; position: absolute; inset: 0; background: linear-gradient(#2a08005c, #2a080038); }
.magma.mer { left: 0; right: 0; bottom: 0; height: 190px;
  -webkit-mask: var(--onde-b) -300px 0 / 1200px 80px repeat-x, linear-gradient(#000, #000) 0 79px / 100% 100% no-repeat;
  mask: var(--onde-b) -300px 0 / 1200px 80px repeat-x, linear-gradient(#000, #000) 0 79px / 100% 100% no-repeat; }
.magma.lac { left: 0; top: 44%; bottom: 350px; width: clamp(54px, 19vw, 400px);
  -webkit-mask: var(--rive) 0 0 / 100% 100% no-repeat; mask: var(--rive) 0 0 / 100% 100% no-repeat;
  --rive: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M0 9L10 3L22 0L30 8L44 11L52 24L50 33L62 41L70 40L78 52L74 61L88 68L100 80L94 90L100 100H0Z'/%3E%3C/svg%3E"); }
.magma.lac.droite { left: auto; right: 0; transform: scaleX(-1); top: 50%; }
/* la lueur orange qui monte du magma */
.lueur-magma { position: absolute; left: 0; right: 0; bottom: 0; height: 72%; z-index: 4; mix-blend-mode: screen; opacity: 0.6;
  background: radial-gradient(34% 62% at 0% 78%, #ff6a1a8c, transparent 72%), radial-gradient(34% 62% at 100% 80%, #ff6a1a8c, transparent 72%),
    linear-gradient(0deg, #ff7a1a8c, #ff5a1a26 34%, transparent 62%); }
/* la corniche d'obsidienne où se tient la foule, au-dessus de la mer */
canvas.foule { width: calc(100% + 32px); margin-left: -16px; margin-right: -16px; border-top: 3px solid #000; border-bottom: 4px solid #000;
  background: linear-gradient(#000000b0, #14101ce0 16px, #0a0807c4); box-shadow: 0 10px 18px #000000d0, 0 -8px 16px #00000090; }

/* le nom de la roche traversée, sous le compteur de la jauge (js/strates.js) */
.roche-nom { display: block; margin-top: 7px; padding-top: 6px; border-top: 1px solid #ffffff1a; font: 700 12px/1 var(--police-titres); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.roche-nom:empty { display: none; }
.roche-nom::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 7px; vertical-align: -2px; border: 1px solid #000; outline: 1px solid #ffffff26;
  background: var(--teinte) var(--img) 0 0 / 48px 48px; }
/* le rail de la jauge : les couches traversées, de la neige au magma (un cinquième du rail par étage) */
.jauge-rail { width: 8px; background: linear-gradient(#8fa0b8, #5d6f8a 12%, #2e2216 17%, #2e2216 21%, #6b5233 22%, #6b5233 33%, #6a665a 34%, #6a665a 51%, #3d4756 52%, #3d4756 66%,
  #8a8784 67%, #8a8784 73%, #6b5858 74%, #6b5858 90%, #34343a 91%, #34343a 96%, #1a1326 96.5%, #1a1326 98%, #e0662a 98.5%); }

@media (max-width: 820px) {
  /* téléphone : pas de marges où montrer la roche → un voile égal partout, des filons et des poches plus petits */
  .roches::after { background: var(--lumiere, linear-gradient(transparent, transparent)), linear-gradient(#0a0807c2, #0a0807c2); }
  .filon { --l: 230px; --h: 173px; opacity: 0.7; }
  .filon[data-filon="adamantite"] { --l: 173px; --h: 115px; }
  /* (une seule pierre par poche, collée au bord : elle ne passe pas sous les textes) */
  .poche { left: clamp(10px, var(--x), calc(100% - 10px)); width: 56px; height: 56px; margin: -28px 0 0 -28px; background-size: 112px 56px; background-position: 0 0; opacity: 0.85; }
  .poche::after { left: 10%; top: -30%; width: 40px; height: 40px; background-size: 120px 40px; }
  .poche:nth-of-type(2n)::after { --e: -40px; }
  .poche:nth-of-type(3n)::after { --e: -80px; }
  .tresor { padding-bottom: 120px !important; }
  .magma.mer { height: 160px; }
  .magma.lac { top: 56%; bottom: 320px; }
  .magma.lac.droite { top: 60%; }
}

/* ── Ce qui bouge : le scintillement des pierres, la coulée et le souffle du magma ── */
@media (prefers-reduced-motion: no-preference) {
  .roche-ici .poche::after { animation: scintiller 3.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
  @keyframes scintiller { 0%, 58%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); } 72% { opacity: 1; transform: scale(1) rotate(20deg); } 86% { opacity: 0.25; transform: scale(0.7) rotate(40deg); } }
  .roche-ici .magma.mer::before { animation: couler 46s linear infinite; }
  .roche-ici .magma.lac::before { animation: descendre 64s linear infinite; }
  @keyframes couler { to { transform: translateX(-288px); } }
  @keyframes descendre { to { transform: translateY(-288px); } }
  .roche-ici .lueur-magma { animation: souffler 5.5s ease-in-out infinite; }
  @keyframes souffler { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.8; } }
}
