/* Arkéonoïd Web · css/arkeonoid.css · lot 9 · v1.3 · 2026-12-02
   Page responsive : scène 4:3 la plus grande possible, barre d'outils à côté (paysage)
   ou dessous (portrait), jamais par-dessus le jeu. */

@font-face {
  font-family: "Grand9K Pixel";
  src: url("../fonts/grand9k-pixel.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bar: 48px;
  --red: #6b0000;
  --gold: #ffcc00;
  --sand: #f3e7d6;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--sand);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#stage {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  box-shadow: 0 0 0 1px #222;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* Paysage (écran plus large que 4:3) : barre verticale à droite */
@media (min-aspect-ratio: 4/3) {
  #app { flex-direction: row; }
  #stage {
    height: min(100vh, (100vw - var(--bar) - 12px) * 3 / 4);
    height: min(100dvh, (100vw - var(--bar) - 12px) * 3 / 4);
  }
  #toolbar { flex-direction: column; }
}

/* Portrait (ou carré) : barre horizontale en dessous */
@media (max-aspect-ratio: 4/3) {
  #app { flex-direction: column; }
  #stage {
    width: min(100vw, (100vh - var(--bar) - 12px) * 4 / 3);
    width: min(100vw, (100dvh - var(--bar) - 12px) * 4 / 3);
  }
  #toolbar { flex-direction: row; }
}

#app:fullscreen { background: #000; }

#toolbar {
  display: flex;
  gap: 6px;
}

#toolbar button {
  width: var(--bar);
  height: var(--bar);
  border: 1px solid #333;
  border-radius: 10px;
  background: #111;
  color: var(--sand);
  cursor: pointer;
  padding: 10px;
}

#toolbar button:hover, #toolbar button:focus-visible { border-color: var(--gold); color: var(--gold); }
#toolbar button[hidden] { display: none; }
#toolbar svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
#toolbar .i-speaker { fill: currentColor; }
#btn-mute[data-on="1"] .i-off, #btn-mute[data-on="0"] .i-on { display: none; }

/* Écran de chargement / « Cliquer pour jouer » */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
  cursor: pointer;
}

#overlay[data-state="hidden"] { display: none; }
#overlay .panel {
  text-align: center;
  background: rgba(0, 0, 0, .78);
  border: 2px solid var(--red);
  border-radius: 14px;
  padding: 4% 6%;
  max-width: 86%;
}

#overlay .logo {
  margin: 0 0 .6em;
  font: 700 clamp(22px, 6vw, 42px)/1 "Grand9K Pixel", system-ui, sans-serif;
  color: #fff;
  text-shadow: 3px 3px 0 var(--red);
}

#overlay .when-loading, #overlay .when-ready, #overlay .when-error { display: none; }
#overlay[data-state="loading"] .when-loading { display: block; }
#overlay[data-state="ready"] .when-ready { display: inline-block; }
#overlay[data-state="error"] .when-error { display: block; color: #ff8a8a; }

#overlay progress { width: min(320px, 60vw); accent-color: var(--gold); }

#overlay button {
  font: clamp(14px, 3vw, 20px) "Grand9K Pixel", system-ui, sans-serif;
  color: #000;
  background: var(--gold);
  border: 0;
  border-radius: 8px;
  padding: .7em 1.2em;
  cursor: pointer;
  box-shadow: 4px 4px 0 #555;
}

#overlay button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.noscript { max-width: 640px; padding: 16px; text-align: center; }

/* Boîtes de dialogue par-dessus le jeu : nom du Hall of Fame (lot 6), code (lot 7) */
.dialog {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
}
.dialog[hidden], .dialog [hidden] { display: none !important; }
.dialog .panel {
  width: min(92%, 440px);
  text-align: center;
  background: rgba(0, 0, 0, .86);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 1.1em 1.3em;
  font: clamp(12px, 2.4vw, 16px)/1.45 "Grand9K Pixel", system-ui, sans-serif;
  color: #fff;
}
.dialog .panel p { margin: 0 0 .8em; }
.dialog .hs-name { display: inline-flex; align-items: center; gap: .6em; margin-bottom: .8em; }
.dialog input[name="name"] {
  width: 4.2em;
  font: clamp(22px, 5vw, 34px) "Grand9K Pixel", monospace;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--gold);
  background: #000;
  border: 2px solid #777;
  border-radius: 8px;
  padding: .1em .2em;
}
.dialog input[name="name"]:focus { outline: none; border-color: var(--gold); }
.dialog .hs-human { margin: 0 0 .8em; }
.dialog .hs-human input { width: 1.2em; height: 1.2em; vertical-align: middle; accent-color: var(--gold); }
.dialog .hs-human a { color: var(--gold); }
.dialog .hs-human .hs-ok { color: #8be28b; font-weight: 700; }
.dialog .hs-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.dialog .hs-error { color: #ff8a8a; }
.dialog .hs-buttons { display: flex; gap: .8em; justify-content: center; margin: 0; }
.dialog button {
  font: inherit;
  color: #000;
  background: var(--gold);
  border: 0;
  border-radius: 8px;
  padding: .5em 1em;
  cursor: pointer;
  box-shadow: 3px 3px 0 #555;
}
.dialog button[data-role="skip"] { background: #bbb; }
.dialog button:disabled { opacity: .5; cursor: wait; }
.dialog button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* Code d'un niveau (lot 7) : champ plus large, texte en minuscules */
.dialog input[name="code"] {
  width: min(16em, 70vw);
  font: clamp(14px, 3.2vw, 20px) "Grand9K Pixel", monospace;
  text-align: center;
  color: var(--gold);
  background: #000;
  border: 2px solid #777;
  border-radius: 8px;
  padding: .3em .5em;
  margin-bottom: .8em;
}
.dialog input[name="code"]:focus { outline: none; border-color: var(--gold); }

/* Réglage du volume (lot 7) */
#volume-pop {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #111;
  border: 1px solid var(--gold);
  border-radius: 10px;
}
#volume-pop[hidden] { display: none; }
#volume-pop input { width: 120px; accent-color: var(--gold); }
#volume-pop output { min-width: 3ch; font: 13px "Grand9K Pixel", system-ui, sans-serif; color: var(--sand); }
@media (min-aspect-ratio: 4/3) {
  #volume-pop { flex-direction: column; padding: 10px 6px; }
  #volume-pop input { writing-mode: vertical-lr; direction: rtl; width: auto; height: 120px; }
}
#btn-pause[data-on="1"] .i-pause, #btn-pause[data-on="0"] .i-play { display: none; }

/* Conseil « tournez l'appareil » : écran tactile en portrait (lot 7) */
#rotate-hint { display: none; margin: 0; text-align: center; font-size: 14px; color: var(--gold); }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate-hint { display: block; }
}

/* Liens de bas de page (lot 9) : sous le jeu, visibles en faisant défiler */
.site-links {
  padding: 10px 12px 14px;
  text-align: center;
  font: 12px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #9a8f86;
}
.site-links a { color: #d8c8b8; text-decoration: none; padding: 4px 2px; }
.site-links a:hover, .site-links a:focus-visible { color: var(--gold); text-decoration: underline; }
:fullscreen .site-links, .standalone .site-links { display: none; }
@media (display-mode: fullscreen), (display-mode: standalone) { .site-links { display: none; } }
