/**
 * Game Boy Interface - Estilos Principales
 * Estilos base para el controlador Game Boy
 * v1.1 - Fixed D-Pad animations
 */

:root {
    --gb-gray: #9ca3af;
    --gb-dark-gray: #6b7280;
    --gb-red: #dc2626;
    --gb-beige: #e8e4d9;
    --gb-shadow: rgba(0, 0, 0, 0.3);
    --gb-controller-size: 200px;
}

/* Contenedor principal del controlador */
.gameboy-controller {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: all;
}

/* Wrapper de controles */
.gameboy-controls {
    display: flex;
    align-items: center;
    gap: 60px;
    padding: 20px;
    border-radius: 15px;
    background: linear-gradient(135deg, #3f3f3f40 100%, #2a2a2a80 100%);
    
    
    backdrop-filter: blur(10px);
    box-shadow: inset 0px 0px 20px 10px #00000052;
    
    
    box-shadow:
        0 10px 30px var(--gb-shadow),
        inset 0 -2px 5px rgba(0, 0, 0, 0.1);
}

/* ========================================
   D-PAD (Cruceta)
   ======================================== */

.gameboy-dpad {
    position: relative;
    width: 100px;
    height: 100px;
}

.dpad-btn {
    position: absolute;
    background: var(--gb-dark-gray);
    border: none;
    cursor: pointer;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    box-shadow:
        0 3px 6px rgba(0, 0, 0, 0.3),
        inset 0 -1px 2px rgba(0, 0, 0, 0.3);
}

.dpad-btn:hover {
    background: var(--gb-gray);
    box-shadow:
        0 5px 10px rgba(0, 0, 0, 0.3),
        inset 0 -1px 2px rgba(0, 0, 0, 0.3);
}

.dpad-btn:active,
.dpad-btn.active {
    background: #4b5563;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.3),
        inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Preserve transforms on hover for up/down */
.dpad-up:hover,
.dpad-up:active,
.dpad-up.active {
    transform: translateX(-50%);
}

.dpad-down:hover,
.dpad-down:active,
.dpad-down.active {
    transform: translateX(-50%);
}

/* Preserve transforms on hover for left/right */
.dpad-left:hover,
.dpad-left:active,
.dpad-left.active {
    transform: translateY(-50%);
}

.dpad-right:hover,
.dpad-right:active,
.dpad-right.active {
    transform: translateY(-50%);
}

/* Posiciones específicas de cada botón del D-Pad */
.dpad-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 35px;
    border-radius: 4px 4px 2px 2px;
}

.dpad-right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 35px;
    height: 30px;
    border-radius: 2px 4px 4px 2px;
}

.dpad-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 35px;
    border-radius: 2px 2px 4px 4px;
}

.dpad-left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 35px;
    height: 30px;
    border-radius: 4px 2px 2px 4px;
}

/* Centro de la cruceta (estético) */
.dpad-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: var(--gb-dark-gray);
    border-radius: 3px;
    pointer-events: none;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
}

/* Flechas dentro de los botones */
.dpad-arrow {
    font-style: normal;
    font-size: 14px;
    line-height: 1;
}

/* ========================================
   BOTONES A y B
   ======================================== */

.gameboy-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
    transform: rotate(-15deg);
}

.game-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.1s ease;
    position: relative;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 -2px 3px rgba(0, 0, 0, 0.2);
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 12px rgba(0, 0, 0, 0.3),
        inset 0 -2px 3px rgba(0, 0, 0, 0.2);
}

.game-btn:active,
.game-btn.active {
    transform: translateY(2px);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-b {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-b:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.btn-b:active,
.btn-b.active {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

.btn-a {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-a:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.btn-a:active,
.btn-a.active {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}



/* Prevenir arrastre de imágenes/texto */
.gameboy-controller * {
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

/* ========================================
   ANIMACIONES
   ======================================== */

/* Animación para botones A/B */
@keyframes pulse-button {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
}

/* Animaciones específicas para D-Pad que preservan posicionamiento */
@keyframes pulse-dpad-up {
    0%, 100% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(0.95);
    }
}

@keyframes pulse-dpad-down {
    0%, 100% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(0.95);
    }
}

@keyframes pulse-dpad-left {
    0%, 100% {
        transform: translateY(-50%) scale(1);
    }
    50% {
        transform: translateY(-50%) scale(0.95);
    }
}

@keyframes pulse-dpad-right {
    0%, 100% {
        transform: translateY(-50%) scale(1);
    }
    50% {
        transform: translateY(-50%) scale(0.95);
    }
}

/* Aplicar animaciones específicas */
.game-btn.active {
    animation: pulse-button 0.15s ease;
}

.dpad-up.active {
    animation: pulse-dpad-up 0.15s ease;
}

.dpad-down.active {
    animation: pulse-dpad-down 0.15s ease;
}

.dpad-left.active {
    animation: pulse-dpad-left 0.15s ease;
}

.dpad-right.active {
    animation: pulse-dpad-right 0.15s ease;
}

/* ========================================
   MENU ITEMS (Navegación Game Boy)
   ======================================== */

.gb-menu-item {
    transition: all 0.2s ease;
}

.gb-menu-item.gb-focused {
    border-color: #ffffff !important;
}

.gb-menu-item.gb-focused p {
    color: #ffffff !important;
}

/* Indicador de selección (flecha) */
.gb-menu-item.gb-focused p::before {
    content: '▶ ';
    opacity: 1;
    transition: opacity 0.2s ease;
}

.gb-menu-item:not(.gb-focused) p::before {
    content: '';
    opacity: 0;
}

/* ========================================
   GLITCH OVERLAY
   ======================================== */

#gb-glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    pointer-events: none;
    display: none;
}

#gb-glitch-canvas {
    width: 100%;
    height: 100%;
}

/* Animación de glitch para items cuando se seleccionan */
.gb-menu-item.gb-glitch-selected {
    animation: glitch-select 0.15s ease;
}

@keyframes glitch-select {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(-2px, 2px);
    }
    50% {
        transform: translate(2px, -2px);
    }
    75% {
        transform: translate(-2px, -2px);
    }
}

/* ========================================
   TOGGLE BUTTON (Solo móvil)
   ======================================== */

.gameboy-toggle-btn {
    display: none; /* Oculto por defecto en desktop */
}

@media (max-width: 768px) {
    .gameboy-toggle-btn {
        display: block;
        position: absolute;
        top: 15px;
        left: 50%;
        transform: translateX(-50%);
        border: none;
        border-radius: 12px 12px 0 0;
        padding: 8px 20px;
        cursor: pointer;
        z-index: 10000;
        transition: all 0.3s ease;
        background: transparent;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        outline: none;
        border: none;
    }

    .gameboy-toggle-btn:active {
        box-shadow:
            0 -1px 5px rgba(0, 0, 0, 0.2),
            inset 0 1px 3px rgba(0, 0, 0, 0.2);
        outline: none;
        border: none;

    }

    .toggle-icon {
        display: block;
        font-size: 16px;
        color: var(--gb-dark-gray);
        line-height: 1;
        transition: transform 0.3s ease;
    }

    /* Cuando el controlador está oculto */
    .gameboy-controller.gb-hidden .toggle-icon {
        transform: rotate(180deg);
    }

    /* Animación de ocultar/mostrar controles */
    .gameboy-controller {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* Dejar franja de 45px visible cuando está oculto */
    .gameboy-controller.gb-hidden {
        transform: translateX(-50%) translateY(calc(100% - 45px)) !important;
    }

    /* Deshabilitar interacción con controles ocultos */
    .gameboy-controller.gb-hidden .gameboy-controls {
        pointer-events: none;
    }

    /* Mantener toggle clickeable y expandir área */
    .gameboy-controller.gb-hidden .gameboy-toggle-btn {
        pointer-events: all;
        padding: 12px 20px;
        
    }
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Controlador centrado y elevado 100px */
    .gameboy-controller {
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    /* Controles más espaciados y centrados */
    .gameboy-controls {
        gap: 70px !important;
        padding: 38px 22px 80px 22px !important;
        justify-content: space-evenly !important;
    }

    /* Cruceta 130px */
    .gameboy-dpad {
        width: 130px !important;
        height: 130px !important;
    }

    /* Botones del D-Pad proporcionalmente ajustados */
    .dpad-up,
    .dpad-down {
        width: 39px !important;
        height: 46px !important;
        font-size: 19px !important;
    }

    .dpad-left,
    .dpad-right {
        width: 46px !important;
        height: 39px !important;
        font-size: 19px !important;
    }

    /* Centro de la cruceta proporcional */
    .dpad-center {
        width: 39px !important;
        height: 39px !important;
    }

    /* Flechas proporcionales */
    .dpad-arrow {
        font-size: 17px !important;
    }

    /* Botones A y B proporcionalmente ajustados */
    .game-btn {
        width: 58px !important;
        height: 58px !important;
        font-size: 17px !important;
    }

    /* Ajustar gap de botones */
    .gameboy-buttons {
        gap: 16px !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    /* Controlador centrado y elevado */
    .gameboy-controller {
    }

    .gameboy-controls {
        gap: 55px !important;
        padding: 38px 22px 80px 22px !important;
    }

    /* Cruceta proporcional para pantallas pequeñas */
    .gameboy-dpad {
        width: 115px !important;
        height: 115px !important;
    }

    .dpad-up,
    .dpad-down {
        width: 35px !important;
        height: 41px !important;
        font-size: 17px !important;
    }

    .dpad-left,
    .dpad-right {
        width: 41px !important;
        height: 35px !important;
        font-size: 17px !important;
    }

    .dpad-center {
        width: 35px !important;
        height: 35px !important;
    }

    .dpad-arrow {
        font-size: 15px !important;
    }

    /* Botones A y B proporcionales */
    .game-btn {
        width: 52px !important;
        height: 52px !important;
        font-size: 15px !important;
    }

    .gameboy-buttons {
        gap: 14px !important;
    }
}

/* ========================================
   CONTENT ADJUSTMENTS FOR MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Espacio inferior para que el contenido no quede oculto por el controlador */
    .gameboy-section {
        padding-bottom: 320px !important;
        min-height: 100vh;
    }

    /* Ajustar padding del contenido para mejor visualización */
    .gameboy-section .et_pb_row {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }

    /* Títulos más pequeños en móvil */
    .gameboy-section h1 {
        font-size: 48px !important;
        line-height: 1.2em !important;
    }

    .gameboy-section h2 {
        font-size: 28px !important;
        line-height: 1.3em !important;
    }

    .gameboy-section h3 {
        font-size: 18px !important;
        line-height: 1.6em !important;
    }

    /* Items de menú adaptados para móvil */
    .gb-menu-item {
        font-size: 24px !important;
        padding: 15px 30px !important;
        margin-bottom: 15px !important;
    }

    .gb-menu-item p {
        font-size: 24px !important;
        margin: 0 !important;
    }

    /* Botones más grandes para móvil */
    .gameboy-section .et_pb_button {
        font-size: 16px !important;
        padding: 12px 30px !important;
    }
}

@media (max-width: 480px) {
    /* Más espacio en pantallas muy pequeñas */
    .gameboy-section {
        padding-bottom: 300px !important;
    }

    .gameboy-section .et_pb_row {
        padding-top: 30px !important;
        padding-bottom: 30px !important;
    }

    /* Títulos aún más pequeños */
    .gameboy-section h1 {
        font-size: 36px !important;
    }

    .gameboy-section h2 {
        font-size: 24px !important;
    }

    .gameboy-section h3 {
        font-size: 16px !important;
    }

    /* Items de menú más compactos */
    .gb-menu-item {
        font-size: 20px !important;
        padding: 12px 25px !important;
        margin-bottom: 12px !important;
    }

    .gb-menu-item p {
        font-size: 20px !important;
    }

    /* Botones compactos */
    .gameboy-section .et_pb_button {
        font-size: 14px !important;
        padding: 10px 25px !important;
    }

    /* Imágenes con margen inferior */
    .gameboy-section .et_pb_image {
        margin-bottom: 20px !important;
    }
}

/* Asegurar que el scroll llegue al final de cada sección */
@media (max-width: 768px) {
    body {
        scroll-padding-bottom: 320px;
    }

    /* Ajustar columnas de Divi para móvil */
    .gameboy-section .et_pb_column {
        margin-bottom: 20px !important;
    }

    /* Centrar contenido en móvil */
    .gameboy-section .et_pb_row_2col,
    .gameboy-section .et_pb_row_1-2_1-2 {
        flex-direction: column !important;
    }

    /* Textos centrados en móvil para mejor legibilidad */
    .gameboy-section .et_pb_text {
        text-align: center !important;
    }
}
