/* Platformer Game Styles */

/* Disable body scroll when popup is open */
html.popup-open {
    overflow: hidden;
    height: 100%;
}

/* Back Control Button - matches other controls style */
.back-control {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 999px;
    background: var(--theme-switcher-bg);
    border: 1px solid var(--theme-switcher-border);
    box-shadow: var(--theme-switcher-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: opacity 220ms ease, transform 220ms ease, background 180ms ease, border-color 180ms ease;
    box-sizing: border-box;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.back-control:hover {
    background: color-mix(in srgb, var(--accent-1) 20%, transparent);
    border-color: var(--accent-1);
}

.back-control-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-primary);
    transition: color 180ms ease, transform 180ms ease;
}

.back-control-icon {
    width: 20px;
    height: 20px;
    transition: transform 180ms ease;
}

.back-control:hover .back-control-icon {
    transform: translateX(-2px);
}

/* Platformer Game Section */
.platformer-game-section {
    width: 100%;
    margin: 0 auto;
}

.platformer-game-card {
    padding: 20px 15px;
    margin-bottom: 30px;
}


.platformer-game-title {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.platformer-game-subtitle {
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

/* Game iframe Container */
.platformer-canvas-container {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 10px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    overflow: hidden;
}

#platformerFrame {
    display: block;
    width: 850px;
    max-width: 100%;
    height: 620px;
    max-height: 100%;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: #000;
    overflow: hidden;
    box-sizing: border-box;
}

/* Responsive: let iframe scale down on smaller screens */
@media (max-width: 900px) {
    #platformerFrame {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 850 / 620;
        max-height: calc(100vh - 300px);
    }
}

/* Controls Wrapper - contains controls and toggle button */
.platformer-controls-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0;
    width: 100%;
    padding-top: 5px;
    box-sizing: border-box;
}

/* Mobile Controls - D-pad on left, action buttons on right */
/* Hidden on desktop by default, can be shown via toggle button */
.platformer-mobile-controls {
    display: none; /* Hidden by default, shown via JavaScript toggle */
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    gap: 20px;
    margin-top: 0;
}

/* Hide controls on desktop (non-touch devices) by default */
/* JavaScript can override this with inline styles when user toggles */
@media (pointer: fine) and (min-width: 769px) {
    .platformer-mobile-controls:not([style*="flex"]) {
        display: none !important;
    }
}

.platformer-controls-left-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.platformer-controls-right-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.platformer-controls-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
    padding: 5px 0;
    box-sizing: border-box;
}

.platformer-controls-row-up {
    justify-content: center;
    margin-bottom: 0;
}

.platformer-controls-row-top {
    justify-content: center;
    gap: 40px;
}

.platformer-controls-row-crouch {
    justify-content: center;
    margin-top: 0;
}

.platformer-controls-row-actions {
    justify-content: center;
}

.platformer-control-btn {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    border-radius: 50%;
    border: 2px solid var(--card-border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(var(--card-blur));
    -webkit-backdrop-filter: blur(var(--card-blur));
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
    box-sizing: border-box;
}

.platformer-control-btn:active,
.platformer-control-btn.active {
    transform: scale(0.95);
    background: color-mix(in srgb, var(--accent-1) 30%, var(--card-bg));
    border-color: var(--accent-1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.platformer-control-left,
.platformer-control-right {
    font-size: 24px;
}

.platformer-control-up {
    font-size: 24px;
}

.platformer-control-jump {
    font-size: 24px;
}

.platformer-control-run {
    font-size: 18px;
}

.platformer-control-attack {
    font-size: 18px;
}

.platformer-control-crouch {
    font-size: 20px;
}

/* Controls Toggle Button - Small circle icon, centered when hidden, right when visible */
.platformer-controls-toggle-btn {
    position: absolute;
    left: 50%;
    top: 5px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: 2px solid var(--card-border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(var(--card-blur));
    -webkit-backdrop-filter: blur(var(--card-blur));
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: inherit;
    z-index: 10;
}

/* When controls are visible, toggle button moves to top right */
.platformer-controls-wrapper.controls-visible {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
}

.platformer-controls-wrapper.controls-visible .platformer-mobile-controls {
    display: flex;
    flex: 1;
    align-items: center;
}

.platformer-controls-wrapper.controls-visible .platformer-controls-toggle-btn {
    position: absolute;
    right: 10px;
    top: 2px;
    left: auto;
    transform: none;
    margin: 0;
    flex-shrink: 0;
}

.platformer-controls-toggle-btn:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: var(--accent-1);
}

.platformer-controls-toggle-btn:active {
    transform: translateX(-50%) scale(0.95);
}

/* Adjust hover/active transforms when controls are visible */
.platformer-controls-wrapper.controls-visible .platformer-controls-toggle-btn:hover {
    transform: scale(1.1);
}

.platformer-controls-wrapper.controls-visible .platformer-controls-toggle-btn:active {
    transform: scale(0.95);
}

.platformer-controls-toggle-btn.active {
    background: color-mix(in srgb, var(--accent-1) 20%, var(--card-bg));
    border-color: var(--accent-1);
}

.platformer-controls-toggle-icon {
    font-size: 18px;
    line-height: 1;
}

.platformer-controls-toggle-text {
    display: none; /* Hide text, show only icon */
}

/* Instructions */
.platformer-instructions {
    margin-top: 45px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Remove padding-top and reduce margin-top when controls are visible */
.platformer-controls-wrapper.controls-visible ~ .platformer-instructions {
    padding-top: 0;
    margin-top: 5px;
}

.platformer-instructions p {
    margin: 5px 0;
}

.platformer-instructions strong {
    color: var(--text-primary);
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 768px) {
    .platformer-game-card {
        padding: 15px 10px;
    }
    
    .platformer-game-title {
        font-size: 2rem;
    }
    
    .platformer-game-subtitle {
        font-size: 0.9rem;
    }
    
    .platformer-canvas-container {
        padding: 5px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    #platformerFrame {
        width: 100% !important;
        height: auto !important;
        min-height: 200px;
        max-height: calc(100vh - 350px);
        aspect-ratio: 850 / 620;
        box-sizing: border-box;
    }
    
    /* Mobile controls display is controlled by JavaScript, not CSS */
    /* This media query is for styling only, not visibility */
    
    .platformer-control-btn {
        width: 45px;
        height: 45px;
        min-width: 45px;
        min-height: 45px;
        font-size: 18px;
        flex-shrink: 0;
    }
    
    .platformer-control-left,
    .platformer-control-right {
        font-size: 24px;
    }
    
    .platformer-control-up {
        font-size: 24px;
    }
    
    .platformer-control-jump {
        font-size: 20px;
        width: 55px;
        height: 55px;
        min-width: 55px;
        min-height: 55px;
    }
    
    .platformer-controls-row-up {
        margin-bottom: 0;
    }
    
    .platformer-controls-row-top {
        gap: 35px;
    }
    
    .platformer-controls-row-crouch {
        margin-top: 0;
    }
    
    .platformer-control-run {
        font-size: 16px;
    }
    
    .platformer-control-crouch {
        font-size: 18px;
    }
    
    .platformer-mobile-controls {
        gap: 30px;
        padding: 0 5px;
    }
    
    .platformer-controls-row {
        padding: 0 5px;
        justify-content: center;
    }
    
    .platformer-controls-row-crouch {
        margin-top: 3px;
    }
    
    
    .platformer-mobile-controls {
        gap: 15px;
    }
    
    .platformer-controls-toggle-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .platformer-controls-toggle-icon {
        font-size: 16px;
    }
    
    /* Adjust hover/active for mobile */
    .platformer-controls-toggle-btn:hover {
        transform: translateX(-50%) scale(1.05);
    }
    
    .platformer-controls-wrapper.controls-visible .platformer-controls-toggle-btn {
        right: 5px;
    }
    
    .platformer-controls-wrapper.controls-visible .platformer-controls-toggle-btn:hover {
        transform: scale(1.05);
    }
    
    .platformer-instructions {
        font-size: 12px;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .platformer-game-card {
        padding: 8px 5px;
    }
    
    #platformerFrame {
        max-height: calc(100vh - 280px);
        min-height: 180px;
    }
    
    .platformer-canvas-container {
        padding: 3px;
    }
    
    .platformer-control-left,
    .platformer-control-right,
    .platformer-control-up {
        font-size: 20px;
    }
    
    .platformer-control-jump {
        width: 50px;
        height: 50px;
        min-width: 50px;
        min-height: 50px;
        font-size: 18px;
    }
    
    .platformer-controls-row-top {
        gap: 30px;
    }
    
    .platformer-controls-row {
        padding: 0 5px;
        justify-content: space-around;
    }

	.platformer-controls-wrapper.controls-visible .platformer-controls-toggle-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
    }
}

@media (max-width: 360px) {
    .platformer-control-btn {
        width: 35px;
        height: 35px;
        min-width: 35px;
        min-height: 35px;
        font-size: 14px;
    }
    
    .platformer-control-left,
    .platformer-control-right,
    .platformer-control-up {
        font-size: 18px;
    }
    
    .platformer-control-jump {
        width: 45px;
        height: 45px;
        min-width: 45px;
        min-height: 45px;
        font-size: 16px;
    }
    
    .platformer-controls-row-top {
        gap: 25px;
    }
}

/* Theme-specific adjustments for iframe (optional) */
[data-theme="neon"] .platformer-canvas-container {
    box-shadow: inset 0 2px 12px rgba(34, 211, 238, 0.15);
}
