/* Ruben T. en briques 3D : interface de la scène (les visuels sont dans le canvas WebGL) */
:root {
  --bg: #06080d;
  --ink: #eef1f7;
  --dim: rgba(238, 241, 247, .68);
  --glass: rgba(12, 16, 26, .56);
  --line: rgba(255, 255, 255, .15);
  --accent: #ffc82a;
  --accent-ink: #17130a;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, "Liberation Mono", monospace;
  --pad: clamp(12px, 2.4vmin, 22px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body { font-family: var(--sans); color: var(--ink); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.noscript { position: fixed; inset: 0; margin: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--bg); }

.stage { position: fixed; inset: 0; overflow: hidden; background:
  radial-gradient(120% 90% at 50% 60%, #121a2e 0%, #080b14 55%, #05070c 100%); }
.view, .poster-pic, .poster { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.view[hidden], .poster-pic[hidden] { display: none; }
.poster { object-fit: cover; object-position: 50% 52%; }
.poster-pic { transition: opacity .6s ease; }
.view { opacity: 0; transition: opacity .6s ease; touch-action: manipulation; }
.stage[data-ready="1"] .view { opacity: 1; }
.stage[data-ready="1"] .poster-pic { opacity: 0; pointer-events: none; }
.stage[data-fallback="1"] .poster-pic { display: none; }
/* textes de l'interface : masqués tant que la langue n'est pas appliquée (évite un éclair de français dans la version anglaise) */
html:not(.i18n) [data-i18n] { visibility: hidden; }

/* --- HUD : compteur de briques --- */
.hud { position: absolute; top: var(--pad); left: var(--pad); display: flex; gap: 10px; opacity: 0; transition: opacity .5s ease; pointer-events: none; }
.stage:not([data-state="idle"]) .hud, .is-still .hud { opacity: 1; }
.hud__count { display: inline-flex; align-items: baseline; gap: 8px; padding: 9px 13px 8px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  font: 600 clamp(10px, 1.5vmin, 12px)/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); font-variant-numeric: tabular-nums; }
.hud__count b { color: var(--ink); font-weight: 700; font-size: 1.35em; letter-spacing: .04em; }
.hud__sep { opacity: .5; }
#total { opacity: .75; }

/* --- légendes --- */
.caption, .credit { position: absolute; margin: 0; pointer-events: none; opacity: 0; transform: translateY(8px); transition: opacity .55s ease, transform .55s ease; text-wrap: balance; }
.caption { left: var(--pad); right: var(--pad); bottom: calc(var(--pad) + 62px + var(--safe-b)); max-width: 30em; font-size: clamp(13px, 2.1vmin, 17px); line-height: 1.42; font-weight: 500; letter-spacing: .005em; color: var(--ink);
  text-shadow: 0 1px 14px rgba(0, 0, 0, .8), 0 0 2px rgba(0, 0, 0, .6); }
.caption.is-in, .credit.is-in { opacity: 1; transform: none; }
.credit { left: var(--pad); bottom: calc(var(--pad) + 66px + var(--safe-b)); font: 600 clamp(12px, 1.9vmin, 15px)/1 var(--mono); letter-spacing: .24em; color: var(--ink); text-shadow: 0 0 22px rgba(255, 200, 42, .5), 0 1px 12px rgba(0, 0, 0, .8); }
.credit::before { content: ""; display: inline-block; width: 22px; height: 2px; margin-right: 12px; vertical-align: middle; background: var(--accent); box-shadow: 0 0 12px rgba(255, 200, 42, .7); }
.is-still .caption, .is-still .credit { bottom: var(--pad); }

/* --- écran de départ --- */
.start { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 14px; padding: var(--pad) var(--pad) calc(var(--pad) * 1.6 + var(--safe-b));
  background: linear-gradient(180deg, rgba(5, 7, 12, .5) 0%, rgba(5, 7, 12, 0) 30%, rgba(5, 7, 12, 0) 58%, rgba(5, 7, 12, .74) 100%);
  transition: opacity .45s ease, visibility .45s; }
.stage:not([data-state="idle"]) .start { opacity: 0; visibility: hidden; pointer-events: none; }
.start__eyebrow { position: absolute; top: var(--pad); left: var(--pad); right: 76px; margin: 0; font: 600 clamp(10px, 1.7vmin, 13px)/1.3 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); text-shadow: 0 1px 10px rgba(0, 0, 0, .8); }
.start__hint { margin: 0; font: 500 11px/1.3 var(--mono); letter-spacing: .1em; color: var(--dim); text-shadow: 0 1px 8px rgba(0, 0, 0, .8); }
.play { position: relative; display: inline-flex; align-items: center; gap: 14px; min-height: 64px; max-width: calc(100% - 20px); padding: 8px 28px 8px 8px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #ffd649 0%, #ffb800 100%); color: var(--accent-ink); font: 700 clamp(15px, 2.6vmin, 19px)/1.15 var(--sans); letter-spacing: -.005em; text-align: left;
  box-shadow: 0 14px 44px rgba(255, 184, 0, .34), 0 2px 0 rgba(255, 255, 255, .55) inset, 0 -3px 0 rgba(160, 100, 0, .35) inset;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s ease; }
.play__icon { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%; background: var(--accent-ink); color: var(--accent); padding-left: 3px; }
.play::after { content: ""; position: absolute; inset: -6px; border-radius: inherit; border: 2px solid rgba(255, 200, 42, .55); animation: ring 2.4s ease-out infinite; pointer-events: none; }
@keyframes ring { 0% { transform: scale(.96); opacity: .9; } 100% { transform: scale(1.14); opacity: 0; } }
@keyframes ring-s { 0% { transform: scale(.98); opacity: .9; } 100% { transform: scale(1.05); opacity: 0; } }
.play:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 18px 54px rgba(255, 184, 0, .45), 0 2px 0 rgba(255, 255, 255, .55) inset, 0 -3px 0 rgba(160, 100, 0, .35) inset; }
.play:active { transform: translateY(1px) scale(.99); }
.play[disabled] { opacity: .7; cursor: progress; }

/* focus visible partout */
button:focus-visible, .scrub:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* --- son --- */
.sound { position: absolute; top: var(--pad); right: var(--pad); width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); color: var(--ink);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); transition: transform .2s ease, background .2s ease; }
.sound:hover { background: rgba(28, 34, 50, .78); transform: scale(1.06); }
.sound[aria-pressed="true"] .sound__off, .sound[aria-pressed="false"] .sound__on { display: none; }
.sound[aria-pressed="false"] { color: var(--dim); }

/* --- barre de lecture --- */
.controls { position: absolute; left: var(--pad); right: var(--pad); bottom: calc(var(--pad) + var(--safe-b)); height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 6px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  transition: opacity .4s ease, transform .4s ease; }
.stage[data-state="idle"] .controls { opacity: 0; visibility: hidden; pointer-events: none; }
.stage.ui-hidden[data-state="playing"] .controls:not(:focus-within) { opacity: 0; transform: translateY(8px); pointer-events: none; }
.ctl { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--ink); transition: background .2s ease; }
.ctl:hover { background: rgba(255, 255, 255, .1); }
.ctl svg { display: none; }
.stage[data-state="playing"] .ic-pause, .stage[data-state="paused"] .ic-play, .stage[data-state="ended"] .ic-replay, .stage[data-state="idle"] .ic-play { display: block; }
.time { flex: 0 0 auto; min-width: 2.6em; font: 600 12px/1 var(--mono); color: var(--dim); font-variant-numeric: tabular-nums; text-align: right; }
.scrub { flex: 1 1 auto; min-width: 0; height: 24px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; --p: 0%; }
.scrub::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: linear-gradient(90deg, var(--accent) var(--p), rgba(255, 255, 255, .22) var(--p)); }
.scrub::-moz-range-track { height: 4px; border-radius: 99px; background: rgba(255, 255, 255, .22); }
.scrub::-moz-range-progress { height: 4px; border-radius: 99px; background: var(--accent); }
.scrub::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(255, 200, 42, .28); }
.scrub::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(255, 200, 42, .28); }

/* --- rejouer --- */
.replay { position: absolute; left: 50%; bottom: calc(var(--pad) + 66px + var(--safe-b)); transform: translate(-50%, 8px); display: inline-flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 20px 0 16px; border-radius: 999px;
  border: 1px solid rgba(255, 200, 42, .55); background: rgba(255, 200, 42, .14); color: var(--ink); font: 700 14px/1 var(--sans); letter-spacing: .02em; opacity: 0; visibility: hidden; transition: opacity .5s ease, transform .5s ease, background .2s ease;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.replay:hover { background: rgba(255, 200, 42, .28); }
.stage[data-state="ended"] .replay { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: .6s, .6s, 0s, 0s; }

/* --- fondu au noir au lancement --- */

/* --- image fixe (?t=) : aucune interface, aucune transition (l'image est capturable dès le drapeau data-rendered) --- */
.is-still *, .is-still *::before, .is-still *::after { transition: none !important; animation: none !important; }
.is-still .view { opacity: 1; }
.is-still .start, .is-still .controls, .is-still .sound, .is-still .replay, .is-still .poster-pic { display: none !important; }

@media (max-width: 520px) {
  .controls { gap: 8px; padding-right: 12px; }
  .caption { max-width: none; }
  .play { padding-right: 22px; }
  .start__hint { display: none; }
}
@media (max-width: 420px) {
  .play { gap: 10px; padding-right: 18px; }
  .play::after { inset: -4px; animation-name: ring-s; }
}
@media (max-height: 420px) {
  .start__hint { display: none; }
  .play { min-height: 52px; }
  .play__icon { width: 38px; height: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  .play::after { animation: none; opacity: 0; }
  .caption, .credit, .view, .poster-pic, .start, .controls, .replay { transition-duration: .01s; }
  .caption, .credit { transform: none; }
}

/* --- variante sans texte (affiche / vignette) --- */
.is-clean .hud, .is-clean .caption, .is-clean .credit { display: none !important; }

@media (max-width: 560px) {
  .credit { left: 0; right: 0; text-align: center; bottom: calc(var(--pad) + 122px + var(--safe-b)); }
  .credit::before { display: none; }
  .is-still .credit { bottom: calc(var(--pad) + 30px); }
}

/* affiches : 3 cadrages (large, carré, haut) choisis par <picture> selon le rapport d'aspect : une seule est téléchargée */
