/* Pages d'erreur : effets interactifs + mini-jeu « Mini 12h » (autonome, sans Vite) */

/* ---------- Ambiance ---------- */

.eg-ripples {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.eg-spotlight {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 35%), rgba(255, 255, 255, 0.08), transparent 45%);
}

.error-code {
    cursor: pointer;
    transition: transform 0.25s ease-out;
    transform-style: preserve-3d;
}

.eg-digit {
    display: inline-block;
    animation: eg-bob 2.6s ease-in-out infinite;
}

.error-code.eg-splash {
    animation: code-glow 3s ease-in-out infinite, eg-squash 0.55s ease;
}

@keyframes eg-bob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-10px) rotate(-2deg); }
}

@keyframes eg-squash {
    0%   { scale: 1; }
    25%  { scale: 1.18 0.82; }
    55%  { scale: 0.92 1.1; }
    80%  { scale: 1.04 0.97; }
    100% { scale: 1; }
}

/* Sur ordinateur, la page d'erreur tient dans la hauteur de l'écran (le reste est ajusté par zoom en JS) */
@media (min-width: 768px) {
    .eg-content {
        padding-top: clamp(1rem, 3vh, 3rem);
        padding-bottom: clamp(2.5rem, 9vh, 10rem);
    }

    .eg-content .mb-10 { margin-bottom: clamp(1.25rem, 3.5vh, 2.5rem); }
    .eg-content .mb-8  { margin-bottom: clamp(1rem, 3vh, 2rem); }
    .eg-content .mt-12 { margin-top: clamp(1rem, 3vh, 3rem); }
    .eg-content .eg-launcher { margin-top: clamp(1rem, 3vh, 2.5rem); }
}

/* ---------- Sélecteur de langue ---------- */

.eg-lang {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 20;
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(6px);
}

.eg-lang a,
.eg-lang button {
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.eg-lang a:hover,
.eg-lang a:focus-visible,
.eg-lang button:hover,
.eg-lang button:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    outline: none;
}

.eg-lang a.is-active,
.eg-lang button.is-active {
    color: #0f172a;
    background: var(--eg-accent);
}

/* ---------- Bouton d'ouverture ---------- */

.eg-launcher {
    margin-top: 2.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1.3rem;
    border-radius: 9999px;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    border-color: color-mix(in srgb, var(--eg-accent) 65%, transparent);
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.eg-launcher:hover,
.eg-launcher:focus-visible {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 32px color-mix(in srgb, var(--eg-accent) 40%, transparent);
    outline: none;
}

.eg-launcher i {
    color: var(--eg-accent);
    font-size: 1.1rem;
    animation: eg-paddle 1.6s ease-in-out infinite;
}

@keyframes eg-paddle {
    0%, 100% { transform: translateX(-3px) rotate(-8deg); }
    50%      { transform: translateX(3px) rotate(8deg); }
}

/* ---------- Modale ---------- */

.eg-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.eg-modal[hidden] { display: none; }
.eg-modal.is-open { opacity: 1; }

.eg-modal.is-inline {
    --eg-accent: #22d3ee;
    position: relative;
    inset: auto;
    z-index: auto;
    padding: 0;
    transition: none;
}

.eg-modal.is-inline .eg-panel {
    margin: 0 auto;
    max-height: none;
    overflow: visible;
}

.eg-modal.is-inline .eg-help { display: none; }

.eg-modal.is-inline .eg-stage {
    width: min(400px, calc(100vw - 4rem), calc((100vh - 12rem) * 2 / 3));
    width: min(400px, calc(100vw - 4rem), calc((100dvh - 12rem) * 2 / 3));
}

.eg-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.75);
    backdrop-filter: blur(8px);
}

.eg-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 100%;
    max-height: 100%;
    overflow-y: auto;
    padding: 0.9rem;
    border-radius: 1.25rem;
    color: #fff;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55), 0 0 60px color-mix(in srgb, var(--eg-accent) 18%, transparent);
    transform: translateY(18px) scale(0.96);
    transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.eg-modal.is-open .eg-panel { transform: none; }

.eg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.eg-title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 800;
}

.eg-title i { color: var(--eg-accent); }

.eg-subtitle {
    margin: 0.1rem 0 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.eg-actions { display: flex; gap: 0.4rem; }

.eg-icon-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
}

.eg-icon-btn:hover,
.eg-icon-btn:focus-visible { background: rgba(255, 255, 255, 0.16); outline: none; }

.eg-hud {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.eg-stat {
    padding: 0.35rem 0.5rem;
    border-radius: 0.75rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.06);
}

.eg-stat-label {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}

.eg-stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.eg-stat-value.is-accent { color: var(--eg-accent); }

.eg-stage {
    position: relative;
    margin: 0 auto;
    width: min(360px, calc(100vw - 3rem), calc((100vh - 15rem) * 2 / 3));
    width: min(360px, calc(100vw - 3rem), calc((100dvh - 15rem) * 2 / 3));
    min-width: 220px;
    aspect-ratio: 2 / 3;
    border-radius: 0.9rem;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 30px rgba(0, 0, 0, 0.35);
}

.eg-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: pointer;
    outline: none;
}

.eg-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    background: radial-gradient(circle at 50% 40%, rgba(15, 23, 42, 0.45), rgba(15, 23, 42, 0.85));
    backdrop-filter: blur(2px);
    animation: eg-fade-in 0.3s ease;
}

.eg-overlay[hidden] { display: none; }

.eg-ov-title {
    margin: 0;
    font-size: 2.1rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    text-shadow: 0 0 28px var(--eg-accent);
}

.eg-ov-text {
    margin: 0;
    max-width: 17rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.78);
}

.eg-ov-text:empty { display: none; }

.eg-ov-record {
    margin: 0;
    font-weight: 900;
    color: #fde047;
    animation: eg-pop 0.6s ease-in-out infinite alternate;
}

.eg-ov-record[hidden] { display: none; }

.eg-play {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.6rem;
    border: 0;
    border-radius: 9999px;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
    background: var(--eg-accent);
    cursor: pointer;
    box-shadow: 0 0 26px color-mix(in srgb, var(--eg-accent) 60%, transparent);
    transition: transform 0.15s ease;
}

.eg-play:hover,
.eg-play:focus-visible { transform: scale(1.06); outline: 2px solid #fff; outline-offset: 3px; }

.eg-help {
    margin: 0;
    max-width: 360px;
    font-size: 0.7rem;
    line-height: 1.4;
    text-align: center;
    color: rgba(255, 255, 255, 0.45);
}

@keyframes eg-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes eg-pop {
    from { transform: scale(1); }
    to   { transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
    .eg-digit,
    .eg-launcher i,
    .eg-ov-record { animation: none; }
    .error-code { transition: none; }
}
