/* Retro Bide Collec : styles du site (themes clair et sombre, version telephone) */
[x-cloak] { display: none !important; }

/* ========================================
   THEMES : sombre par defaut, clair avec html.light (voir /theme.js)
   Couleurs en "R G B" pour l'opacite Tailwind (bg-retro-500/50...)
   ======================================== */
:root {
    --retro-800: 10 10 26;  --retro-700: 26 26 46;  --retro-600: 42 30 92;  --retro-500: 58 46 108;
    --retro-400: 74 62 124; --retro-300: 107 47 143; --retro-200: 139 63 160; --retro-100: 199 125 255;
    --snes-purple: 107 47 143; --snes-pink: 255 110 199; --snes-cyan: 0 229 255; --snes-orange: 255 154 0;
    --snes-green: 46 213 115; --snes-yellow: 255 215 0; --snes-red: 255 71 87;
    --fg: 255 255 255; --gray-200: 229 231 235; --gray-300: 209 213 219; --gray-500: 107 114 128;

    --page-bg: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 50%, #2a1e5c 100%);
    --grid-line: rgba(106, 47, 143, 0.03);
    --grid-line-2: rgba(57, 255, 20, 0.015);
    --panel-bg: linear-gradient(145deg, #1a1a2e, #2a1e5c);
    --panel-frame: linear-gradient(145deg, #3f3f5f, #1a1a2e);
    --panel-border: #2a2a3a;
    --screw: radial-gradient(circle, #4a4a6a 0%, #2a2a3a 100%);
    --screw-ring: #1a1a2e;
    --input-bg: #0a0a14; --input-border: #3f3f5f; --input-fg: #e0e0e0;
    --media-bg: #000;
    --info-bg: rgba(26, 26, 46, 0.85);
    --bevel-light: rgba(255, 255, 255, 0.2); --bevel-dark: rgba(0, 0, 0, 0.4);
    --card-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    --scroll-track: #0a0a1a;
    --glow: 0.8;
}
html.light {
    --retro-800: 241 238 248; --retro-700: 250 248 255; --retro-600: 233 227 246; --retro-500: 224 216 241;
    --retro-400: 184 168 220; --retro-300: 107 47 143;  --retro-200: 120 50 150;  --retro-100: 88 40 130;
    --snes-purple: 107 47 143; --snes-pink: 186 24 118; --snes-cyan: 0 113 140; --snes-orange: 170 84 0;
    --snes-green: 18 124 66; --snes-yellow: 140 100 0; --snes-red: 196 28 44;
    --fg: 30 22 51; --gray-200: 55 50 75; --gray-300: 72 66 94; --gray-500: 112 106 130;

    --page-bg: linear-gradient(135deg, #f6f3fc 0%, #ece6f7 50%, #e2d9f3 100%);
    --grid-line: rgba(106, 47, 143, 0.05);
    --grid-line-2: rgba(0, 113, 140, 0.03);
    --panel-bg: linear-gradient(145deg, #ffffff, #f1ecfa);
    --panel-frame: linear-gradient(145deg, #d9d0ec, #bfb2dd);
    --panel-border: #cfc4e6;
    --screw: radial-gradient(circle, #f4f1fa 0%, #b8a8dc 100%);
    --screw-ring: #e2d9f3;
    --input-bg: #ffffff; --input-border: #b8a8dc; --input-fg: #1e1633;
    --media-bg: #e6e0f2;
    --info-bg: rgba(250, 248, 255, 0.9);
    --bevel-light: rgba(255, 255, 255, 0.9); --bevel-dark: rgba(80, 50, 130, 0.25);
    --card-shadow: 0 6px 14px rgba(60, 30, 110, 0.12);
    --scroll-track: #ece6f7;
    --glow: 0;
}
/* Cadres d'images : noirs en sombre, gris clair en clair (les voiles de modale restent sombres) */
html.light .bg-black:not([class*="bg-opacity"]) { background-color: var(--media-bg); }
/* Textes des boutons : toujours lisibles sur leur couleur, quel que soit le theme */
.retro-btn.retro-btn-primary, .retro-btn.retro-btn-danger, .retro-btn.retro-btn-secondary { color: #fff; }
.retro-btn.retro-btn-success, .retro-btn.retro-btn-warning, .retro-btn.retro-btn-info { color: #000; }
html.light .retro-btn .text-snes-yellow { color: #5a3d00; }
/* Degrades "marque" (bandeau, logo) : couleurs vives dans les deux themes */
html.light .from-snes-pink {
    --tw-gradient-from: #ff6ec7 var(--tw-gradient-from-position);
    --tw-gradient-to: rgb(255 110 199 / 0) var(--tw-gradient-to-position);
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
html.light .to-snes-cyan { --tw-gradient-to: #00e5ff var(--tw-gradient-to-position); }

/* ========================================
   NOUVEAU DESIGN RETRO CONSOLE
   ======================================== */

/* ------------------------------
   ARRIERE-PLAN : Circuit imprimé
   ------------------------------ */
body {
    background-color: rgb(var(--retro-800));
    background-attachment: fixed;

    /* Motif circuit imprimé très subtil, sur le degrade du theme */
    background-image: 
        /* Lignes horizontales fines */
        repeating-linear-gradient(0deg, 
            var(--grid-line) 0 1px, 
            transparent 1px 48px
        ),
        /* Lignes verticales fines */
        repeating-linear-gradient(90deg, 
            var(--grid-line) 0 1px, 
            transparent 1px 48px
        ),
        /* Grille plus large */
        repeating-linear-gradient(0deg, 
            var(--grid-line-2) 0 1px, 
            transparent 1px 96px
        ),
        repeating-linear-gradient(90deg, 
            var(--grid-line-2) 0 1px, 
            transparent 1px 96px
        ),
        var(--page-bg);
    
    min-height: 100vh;
    image-rendering: pixelated;
}

/* ------------------------------
   EFFETS DE LUMIERE 128-BIT
   ------------------------------ */

/* Lueur ambiante subtile */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 80%, rgba(106, 47, 143, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 229, 255, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(46, 213, 115, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* ------------------------------
   BORDURES STYLE CONSOLE
   ------------------------------ */

/* Effet "boîtier de console" avec vis */
.console-border {
    position: relative;
    border: 4px solid var(--panel-border);
    border-radius: 12px;
    background: var(--panel-bg);
}

.console-border::before {
    content: "";
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    background: var(--panel-frame);
    border-radius: 16px;
    z-index: -1;
}

/* Vis de coin */
.console-border::after {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--screw);
    border-radius: 50%;
    top: -12px;
    left: -12px;
    box-shadow: 
        0 0 0 4px var(--screw-ring),
        2px 2px 0 rgba(0,0,0,0.5);
}

/* Vis en bas à droite */
.console-border::first-line {
    /* Ne fonctionne pas, utiliser un pseudo-element supplémentaire */
}

/* ------------------------------
   BOUTONS STYLE MANETTE
   ------------------------------ */

.retro-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    
    /* Effet 3D */
    border: 3px solid;
    border-top-color: rgba(255,255,255,0.4);
    border-left-color: rgba(255,255,255,0.4);
    border-right-color: rgba(0,0,0,0.4);
    border-bottom-color: rgba(0,0,0,0.4);
    
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(0,0,0,0.1));
    
    /* Ombre portée style NES */
    box-shadow: 
        -4px -4px 0 rgba(0,0,0,0.3),
        4px 4px 0 rgba(0,0,0,0.5);
    
    transition: all 0.1s ease;
    cursor: pointer;
    user-select: none;
}

.retro-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 
        -2px -2px 0 rgba(0,0,0,0.3),
        2px 2px 0 rgba(0,0,0,0.5);
}

.retro-btn:active {
    transform: translate(3px, 3px);
    box-shadow: 
        -1px -1px 0 rgba(0,0,0,0.3),
        1px 1px 0 rgba(0,0,0,0.5);
    
    border-top-color: rgba(0,0,0,0.4);
    border-left-color: rgba(0,0,0,0.4);
    border-right-color: rgba(255,255,255,0.4);
    border-bottom-color: rgba(255,255,255,0.4);
}

/* Variantes de couleur */
.retro-btn-primary { background: linear-gradient(135deg, #6b2f8f, #4a1e5c); border-color: #4a1e5c; color: #fff; }
.retro-btn-success { background: linear-gradient(135deg, #2ed573, #1a7d3a); border-color: #1a7d3a; color: #000; }
.retro-btn-danger { background: linear-gradient(135deg, #ff4757, #8b0000); border-color: #8b0000; color: #fff; }
.retro-btn-warning { background: linear-gradient(135deg, #ffa502, #8b5a00); border-color: #8b5a00; color: #000; }
.retro-btn-info { background: linear-gradient(135deg, #00e5ff, #008ba3); border-color: #008ba3; color: #000; }
.retro-btn-secondary { background: linear-gradient(135deg, #3f3f5f, #2a2a3a); border-color: #2a2a3a; color: #fff; }

/* ------------------------------
   CARTES STYLE CARTOUCHE
   ------------------------------ */

.game-card {
    background: var(--panel-bg);
    border: 4px solid;
    border-top-color: var(--bevel-light);
    border-left-color: var(--bevel-light);
    border-right-color: var(--bevel-dark);
    border-bottom-color: var(--bevel-dark);
    border-radius: 12px;
    
    /* Effet de lumière sur le dessus */
    box-shadow: 
        inset -4px -4px 0 rgba(0,0,0,0.3),
        inset 4px 4px 0 rgba(255,255,255,0.1),
        var(--card-shadow);
    
    transition: all 0.2s ease;
    overflow: hidden;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 
        inset -4px -4px 0 rgba(0,0,0,0.3),
        inset 4px 4px 0 rgba(255,255,255,0.15),
        0 12px 24px rgba(0,0,0,0.4);
}

/* Image de couverture avec effet CRT */
.game-cover {
    position: relative;
    overflow: hidden;
}

.game-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain;   /* pochette entiere, sans recadrage */
    filter: saturate(1.2) contrast(1.1);
}

/* Effet de verre dépoli pour les infos */
.game-info {
    background: var(--info-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ------------------------------
   TEXTE & TYPOGRAPHIE
   ------------------------------ */

.text-glow-green { text-shadow: 0 0 8px rgba(46, 213, 115, var(--glow)); }
.text-glow-pink { text-shadow: 0 0 8px rgba(255, 42, 136, var(--glow)); }
.text-glow-cyan { text-shadow: 0 0 8px rgba(0, 229, 255, var(--glow)); }
.text-glow-purple { text-shadow: 0 0 8px rgba(106, 47, 143, var(--glow)); }
.text-glow-gold { text-shadow: 0 0 8px rgba(255, 215, 0, var(--glow)); }

/* Clignotement style néon */
@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.3; }
}
.blink { animation: blink 1.5s infinite; }

/* Défilement style marquee */
@keyframes marquee {
    from { transform: translateX(100%); }
    to { transform: translateX(-100%); }
}
.marquee span {
    display: inline-block;
    animation: marquee 30s linear infinite;
}

/* ------------------------------
   ELEMENTS DE NAVIGATION
   ------------------------------ */

.nav-link {
    position: relative;
    padding: 8px 16px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.nav-link:hover {
    border-color: rgb(var(--fg) / 0.3);
    background: rgb(var(--fg) / 0.05);
}

.nav-link.active {
    border-color: rgb(var(--snes-cyan));
    background: rgb(var(--snes-cyan) / 0.1);
}

/* ------------------------------
   EFFETS SPECIAUX
   ------------------------------ */

/* Bordure "niche" façon UI 8-bit */
.notch {
    clip-path: polygon(
        0 8px, 4px 8px, 4px 4px, 8px 4px, 8px 0,
        calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px,
        100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px), calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%,
        8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px)
    );
}

/* Input style terminal */
.terminal-input {
    font-family: 'VT323', monospace;
    font-size: 1.25rem;
    line-height: 1.4;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    color: var(--input-fg);
    padding: 8px 12px;
}

.terminal-input:focus {
    outline: none;
    border-color: rgb(var(--snes-cyan));
    box-shadow: 0 0 0 2px rgb(var(--snes-cyan) / 0.25);
}

/* Scrollbar personnalisée */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb { 
    background: linear-gradient(180deg, #4a1e5c, #6b2f8f);
    border: 2px solid var(--scroll-track);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover { 
    background: linear-gradient(180deg, #6b2f8f, #8b3fa0);
}

/* Animation pour les badges */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.badge-pulse {
    animation: pulse 2s infinite;
}

/* Effet de surbrillance pour les cartes */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 3s infinite;
}

img { image-rendering: pixelated; }

/* Pastille "demandes d'ami en attente" (menu AMIS) */
/* Avatar des membres (image ronde, ou avatar pixel art par defaut sur sa couleur) */
.rbc-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 9999px;
    overflow: hidden;
    border: 2px solid rgb(var(--retro-400));
    font-family: "Press Start 2P", monospace;
    color: #fff;
    line-height: 1;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    background: #000;
}
.rbc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rbc-avatar img.rbc-avatar-pixel { image-rendering: pixelated; }

.friend-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    border: 2px solid rgb(var(--retro-600));
    background: rgb(var(--snes-pink));
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    line-height: 14px;
    text-align: center;
    box-shadow: 0 0 6px rgba(255, 110, 199, 0.8);
    animation: friend-badge-pop 1.6s ease-in-out infinite;
    pointer-events: none;
}
.friend-badge-inline {
    position: static;
    display: inline-block;
    margin-left: 6px;
    vertical-align: middle;
}
@keyframes friend-badge-pop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
    .friend-badge { animation: none; }
}

/* ------------------------------
   TELEPHONE
   ------------------------------ */
/* Le cadre decoratif (::before) deborde : pas de barre de defilement horizontale */
.console-border.overflow-y-auto, .console-border.overflow-auto { overflow-x: hidden; }
@media (max-width: 639px) {
    .console-border.p-8, .console-border.p-6 { padding: 1.25rem; }
    .rbc-filters > select, .rbc-filters > input { flex: 1 1 100%; min-width: 0; }
    /* Champs a 16 px minimum : evite le zoom automatique d'iOS a la saisie */
    .terminal-input { font-size: 1.125rem; }
    input, select, textarea { font-size: max(16px, 1em); }
    .retro-btn:hover { transform: none; }
    /* Rangees de boutons (Annuler / Enregistrer...) : passent a la ligne */
    .flex.justify-end, .flex.justify-between[class*="space-x-"] { flex-wrap: wrap; gap: 0.5rem; }
    .flex.justify-end[class*="space-x-"] > *, .flex.justify-between[class*="space-x-"] > * { margin-left: 0 !important; margin-right: 0 !important; }
    .retro-btn.px-6 { padding-left: 0.75rem; padding-right: 0.75rem; }
}

/* Jeu Casse-Bide : terrain 480 x 640 mis a l'echelle de l'ecran, pixels nets */
.cb-stage {
    width: min(480px, calc(100vw - 16px), calc((100dvh - 64px) * 0.75));
    aspect-ratio: 3 / 4;
    border: 4px solid #4a3e7c;
    border-radius: 8px;
    overflow: hidden;
}
.cb-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    touch-action: none;
    cursor: none;
}
