/* ============================================================
   QreaLAB V01 — experiences.css
   ------------------------------------------------------------
   L'intérieur d'un module ouvert : le plateau de jeu, ses
   informations et les contrôles tactiles.

   ── Canvas à taille fixe, affichage fluide ─────────────────
   Les deux jeux dessinent dans un canvas de dimensions FIXES
   (800×300 pour 404 ESCAPE, 380×520 pour TETRIS). C'est un bon
   choix : la logique de jeu n'a pas à gérer le redimensionnement.
   On ne touche donc pas au JS — on laisse le CSS mettre le canvas
   à l'échelle, en préservant son rapport avec `aspect-ratio`.
   ============================================================ */

.stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    min-height: 0;
    padding: var(--space-md);
    border: 1px solid var(--line-subtle);
    border-radius: var(--radius-md);
    background: rgba(3, 5, 9, 0.48);
    box-shadow: inset 0 0 0 5px rgba(127, 149, 173, 0.025);
}

/* Bandeau d'instrument partagé par toutes les expériences. Il reprend le
   voyant, l'identifiant et la jauge des modules visibles dans le monde. */
.stage__module-band {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    width: 100%;
    min-height: 24px;
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--line-subtle);
}

.stage__module-lamp {
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--signal-dead);
}

.stage__module-id,
.stage__module-code {
    font-size: 9px;
    letter-spacing: var(--ls-wide);
    color: var(--text-muted);
}

.stage__module-code {
    margin-left: var(--space-sm);
}

.stage__module-signal {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 10px;
    margin-left: auto;
}

.stage__module-signal span {
    width: 4px;
    height: 100%;
    background: rgba(180, 205, 230, 0.12);
}

.stage[data-state="AVAILABLE"] .stage__module-lamp {
    background: var(--signal);
    box-shadow: 0 0 8px rgba(88, 210, 238, 0.75);
    animation: lamp-blink 2.6s var(--ease-in-out) infinite;
}

.stage[data-state="EXPLORED"] .stage__module-lamp,
.stage[data-state="COMPLETE"] .stage__module-lamp {
    background: var(--q-white);
    box-shadow: 0 0 10px rgba(95, 232, 255, 0.8);
}

.stage[data-state="AVAILABLE"] .stage__module-signal span:nth-child(-n+2),
.stage[data-state="EXPLORED"] .stage__module-signal span:nth-child(-n+3),
.stage[data-state="COMPLETE"] .stage__module-signal span:nth-child(-n+5) {
    background: var(--signal);
    box-shadow: 0 0 4px rgba(88, 210, 238, 0.55);
}

/* ══════════════════════════════════════════════════════════
   PLATEAU
   ══════════════════════════════════════════════════════════ */

.stage__board {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    padding: var(--space-sm);
    background: #02040a;
    border: 1px solid var(--line-subtle);
    border-radius: var(--radius-sm);
    /* Une lueur très faible : le module est alimenté, il n'est pas
       une fenêtre de navigateur. */
    box-shadow: inset 0 0 60px rgba(88, 210, 238, 0.05);
}

.stage__board canvas {
    /* Rendu net d'un canvas mis à l'échelle : sans cela le navigateur
       lisse les pixels et le rendu devient flou. */
    image-rendering: pixelated;
    width: auto;
    max-width: 100%;
    max-height: 100%;
    height: auto;
    border-radius: var(--radius-xs);
    /* Le canvas gère lui-même son focus clavier. */
    outline: none;
    touch-action: none;
}

/* ══════════════════════════════════════════════════════════
   BANDEAU D'INFORMATIONS
   ══════════════════════════════════════════════════════════ */

.stage__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-md);
    width: 100%;
}

.stage__stat {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
}

.stage__stat-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
    color: var(--text-dim);
}

.stage__stat-value {
    font-family: var(--font-mono);
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    color: var(--text-bright);
}

/* Le rappel des touches : discret, et masqué sur les postes
   tactiles où il n'a aucun sens. */
.stage__hint {
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    letter-spacing: var(--ls-label);
    color: var(--text-muted);
    text-align: center;
}

@media (hover: none) and (pointer: coarse) {
    .stage__hint {
        display: none;
    }
}

/* La compétence testée : c'est une expérience, pas un jeu. */
.stage__competency {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--signal-dim);
}

/* ══════════════════════════════════════════════════════════
   CONTRÔLES TACTILES
   ══════════════════════════════════════════════════════════
   Affichés uniquement sur un poste à pointeur grossier
   (voir experiences/shared/touch.js). Ils appartiennent au module :
   même matière que le reste de l'installation.
   ══════════════════════════════════════════════════════════ */

.touchpad {
    display: grid;
    gap: var(--space-xs);
    width: 100%;
    max-width: 380px;
    /* Toujours accessible au pouce, jamais sous le bord de l'écran. */
    padding-bottom: var(--safe-bottom);
}

.touchpad--runner {
    grid-template-columns: 1fr;
}

.touchpad--grid {
    grid-template-columns: repeat(4, 1fr);
}

.touchpad__btn {
    display: grid;
    place-items: center;
    /* 56px : au-dessus du minimum recommandé de 44px, car on joue
       dans l'urgence et l'on visera mal. */
    min-height: 56px;
    color: var(--text-secondary);
    background: linear-gradient(180deg, #1b2025 0%, #12161a 100%);
    border: 1px solid var(--line-subtle);
    border-radius: var(--radius-sm);
    /* Empêche la sélection et le menu contextuel sur appui long. */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: background var(--t-instant) var(--ease-out),
                border-color var(--t-instant) var(--ease-out);
}

.touchpad__btn--wide {
    min-height: 68px;
}

/* Retour d'appui immédiat : sur mobile, sans retour visuel on ne
   sait pas si l'appui a été pris en compte. */
.touchpad__btn:active {
    color: var(--text-bright);
    background: linear-gradient(180deg, #253038 0%, #182026 100%);
    border-color: var(--line-signal);
}

.touchpad__glyph {
    font-size: var(--fs-lg);
    line-height: 1;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
    .stage {
        gap: var(--space-sm);
        height: 100%;
        padding: var(--space-sm);
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .stage__board {
        flex: 1;
        padding: var(--space-2xs);
    }

    .stage__module-band {
        flex: none;
    }

    /* Le plateau prend la hauteur disponible ; le canvas s'y inscrit
       sans jamais déborder, quelle que soit l'orientation. */
    .stage__board canvas {
        max-height: 100%;
        max-width: 100%;
    }

    .stage__meta {
        gap: var(--space-sm);
    }

    .stage__competency {
        display: none;
    }
}

/* Paysage sur petit écran : la hauteur est la ressource rare.
   On rend au plateau tout ce qu'on peut. */
@media (max-height: 480px) and (orientation: landscape) {
    .stage__meta {
        display: none;
    }

    .touchpad__btn {
        min-height: 44px;
    }

    .touchpad__btn--wide {
        min-height: 48px;
    }
}
