/* Mini-jeux (/jeux/). Cadre et classement suivent le thème du site ;
   la scène du canvas a sa propre palette, fixe, dessinée en JS. */

.jeux-content {
    display: grid;
    gap: clamp(1.4rem, 4vw, 2.6rem);
    align-content: start;
    padding: clamp(6.2rem, 9vw, 7.5rem) clamp(1.2rem, 6vw, 5rem) clamp(3rem, 7vw, 5rem);
}

.jeux-intro {
    max-width: 58rem;
}

.jeux-intro h1 {
    margin: 0 0 0.6rem;
    color: var(--blue);
    font-size: clamp(2.2rem, 7vw, 4.6rem);
    font-weight: 900;
    line-height: 0.95;
}

.jeux-intro p:last-child {
    max-width: 44rem;
    margin: 0;
}

.jeux-intro .eyebrow a {
    color: inherit;
}

/* Page d'accueil des jeux : cartes « borne d'arcade » */
.jeux-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    gap: clamp(1.2rem, 2.5vw, 1.8rem);
    max-width: 74rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.jeux-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 2px solid var(--blue);
    border-radius: 12px;
    color: var(--ink);
    background: var(--white);
    box-shadow: 0 6px 0 var(--blue);
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.jeux-card:hover,
.jeux-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 10px 0 var(--blue);
}

.jeux-card:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--blue);
}

.jeux-card__affiche {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 5 / 2;
    image-rendering: pixelated;
}

.jeux-card__record {
    align-self: flex-start;
    margin-bottom: 0.2rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    color: #ffd27a;
    background: var(--ink);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.jeux-card__corps {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.1rem 1.2rem 1.3rem;
}

.jeux-card__titre {
    color: var(--blue);
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 900;
    line-height: 1.1;
}

.jeux-card__accroche {
    flex: 1;
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.45;
}

.jeux-card__jouer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 3rem;
    border-radius: 999px;
    color: var(--on-blue);
    background: var(--blue);
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: background 0.15s ease, color 0.15s ease;
}

.jeux-card__jouer::before {
    content: "";
    border-style: solid;
    border-width: 0.5rem 0 0.5rem 0.85rem;
    border-color: transparent transparent transparent currentColor;
}

.jeux-card:hover .jeux-card__jouer,
.jeux-card:focus-visible .jeux-card__jouer {
    color: var(--blue);
    background: var(--pink);
}

@media (prefers-reduced-motion: reduce) {
    .jeux-card,
    .jeux-card__jouer {
        transition: none;
    }
}

@media (max-width: 40rem) {
    .jeux-content {
        padding-inline: 1rem;
    }

    .jeux-cards {
        grid-template-columns: 1fr;
        gap: 1.3rem;
    }
}

/* Page d'un jeu */
.jeux-stage {
    position: relative;
    display: grid;
    gap: 0.6rem;
    max-width: 100%;
}

.jeux-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 5 / 2;
    border: 2px solid var(--blue);
    border-radius: var(--radius);
    background: #1b1020;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    touch-action: none;
    outline-offset: 3px;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

.jeux-pad {
    display: none;
    gap: 0.8rem;
}

@media (pointer: coarse) {
    .jeux-pad {
        display: flex;
    }
}

.jeux-pad button {
    flex: 1;
    min-height: 4rem;
    border: 2px solid var(--blue);
    border-radius: var(--radius);
    color: var(--blue);
    background: var(--white);
    font: 900 1rem var(--font-display);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.jeux-pad button:active {
    color: var(--on-blue);
    background: var(--blue);
}

.jeux-tools {
    position: absolute;
    top: calc(2px + 0.5vw);
    right: calc(2px + 0.5vw);
    display: flex;
    gap: 0.4rem;
}

/* Boutons posés sur le jeu, en pixels : discrets, mais assez grands pour le doigt. */
.jeux-tools button {
    display: block;
    box-sizing: border-box;
    width: max(40px, calc(var(--jeux-w, 800px) * 0.05));
    aspect-ratio: 1;
    padding: 8px;
    border: 0;
    border-radius: 0;
    color: #fff;
    background: rgba(16, 8, 20, 0.55);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
    opacity: 0.8;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.jeux-tools button:hover,
.jeux-tools button:focus-visible {
    opacity: 1;
    background: rgba(16, 8, 20, 0.8);
}

.jeux-tools svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.jeux-rotate {
    display: none;
}

.jeux-hint {
    display: none;
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

@media (pointer: coarse) {
    .jeux-hint {
        display: block;
    }
}

/* Plein écran : API native quand elle existe, sinon (iPhone) simple habillage CSS. */
html.jeux-is-full,
html.jeux-is-full body {
    overflow: hidden;
    overscroll-behavior: none;
}

.jeux-is-full .jeux-stage {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: none;
    background: #000;
}

.jeux-is-full .jeux-canvas {
    width: min(100vw, 250vh);
    width: min(100vw, calc(100dvh * 2.5));
    border: 0;
    border-radius: 0;
}

.jeux-is-full .jeux-pad {
    position: absolute;
    right: max(0.8rem, env(safe-area-inset-right));
    bottom: max(0.8rem, env(safe-area-inset-bottom));
    left: max(0.8rem, env(safe-area-inset-left));
    justify-content: space-between;
    pointer-events: none;
}

.jeux-is-full .jeux-pad button {
    flex: 0 0 38%;
    min-height: 4.6rem;
    opacity: 0.55;
    pointer-events: auto;
}

.jeux-is-full .jeux-tools {
    top: max(0.5rem, env(safe-area-inset-top));
    right: max(0.5rem, env(safe-area-inset-right));
}

@media (pointer: coarse) and (orientation: portrait) {
    .jeux-is-full .jeux-rotate {
        position: absolute;
        top: 12%;
        left: 0;
        right: 0;
        display: block;
        color: #f2cf7a;
        font: 900 1.1rem var(--font-display);
        text-align: center;
        pointer-events: none;
    }
}
