/* Global Styles */
body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: black;
    font-family: 'Courier New', monospace;
}

/* Content Wrapper (Fullscreen Iframe) */
#content-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#art-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* UI Overlay (Top Left Buttons) */
#ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Let clicks pass through outside buttons */
}

#buttons-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
    align-items: flex-start;
}

/* Retro Button Style - All buttons consistent dark marble look */
.retro-btn {
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 14px;
    color: lightgrey;
    background-color: black;
    border-top: 3px solid #ff69b4;
    border-left: 3px solid #ff69b4;
    border-right: 3px solid #8b3a62;
    border-bottom: 3px solid #8b3a62;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    text-transform: uppercase;
    outline: none;
    user-select: none;
    text-align: center;
    width: 200px;
    box-sizing: border-box;
    display: block;
    margin-bottom: 5px;
    text-decoration: none;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

/* Canvas Background (WebGL Shader) */
.btn-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
    mix-blend-mode: overlay;
}

/* Default marble canvas state */
.btn-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    opacity: 0.9;
    mix-blend-mode: screen;
    filter: brightness(1.2);
}

/* Active/Pressed State - Green becomes black, white becomes red */
.retro-btn.active .btn-canvas,
.retro-btn:active .btn-canvas {
    opacity: 1.0;
    mix-blend-mode: screen;
    /* Shift hue from green (~120deg) to red (~0deg), increase saturation, adjust brightness */
    filter: hue-rotate(-120deg) saturate(2) brightness(0.8) contrast(1.3);
}

/* Ensure pattern is visible and looks unique on black backgrounds if any */
.black-bg .btn-canvas {
    mix-blend-mode: screen;
    filter: brightness(1.2);
}

/* Gold Embossed Text Effect */
.retro-btn span {
    position: relative;
    z-index: 2;
    pointer-events: none;

    /* Gold gradient text */
    background: linear-gradient(180deg,
            #f5e6a3 0%,
            /* Light gold top */
            #d4af37 25%,
            /* Classic gold */
            #b8860b 50%,
            /* Dark goldenrod */
            #d4af37 75%,
            /* Classic gold */
            #f5e6a3 100%
            /* Light gold bottom */
        );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;

    /* Embossed shadow effect - black blurry shadow */
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.9)) drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.7)) drop-shadow(-0.5px -0.5px 0px rgba(255, 235, 180, 0.3));

    /* Slightly bolder for more presence */
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* The .retro-btn rule itself still needs position: relative for z-index to work on its children */
.retro-btn {
    position: relative;
}

@media (max-width: 600px) {
    .retro-btn {
        padding: 12px 16px;
        font-size: 16px;
        min-width: 140px;
    }
}

/* Mailto button - grayscale marble with pink border */
#mailto-btn {
    pointer-events: auto;
    margin-bottom: 10px;
}

#mailto-btn .btn-canvas {
    filter: grayscale(1) brightness(1.2);
}

/* Pressed/Active state - dark top/left, pink bottom/right */
.retro-btn:active,
.retro-btn.active {
    border-top: 3px solid #000000;
    border-left: 3px solid #000000;
    border-right: 3px solid #ff69b4;
    border-bottom: 3px solid #ff69b4;
    box-shadow: inset 2px 2px 0px #000000;
}

/* Settings Modal (Overlay) */
#settings-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hidden {
    display: none !important;
}

/* Orientation/Rotate Prompt Overlay (iPhone Only) */
#rotate-overlay {
    position: fixed;
    inset: 0;
    /* Shorthand for top, bottom, left, right: 0 */
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: #fff;
    z-index: 100000;
    display: none;
    flex-direction: column;
    justify-content: center;
    /* Perfect vertical centering */
    align-items: center;
    /* Perfect horizontal centering */
    text-align: center;
    font-family: 'Courier New', monospace;
    padding: 30px;
    box-sizing: border-box;
    text-transform: uppercase;
}

#rotate-overlay.visible {
    display: flex;
}

.rotate-window {
    background: #000000;
    border-top: 3px solid #ff69b4;
    border-left: 3px solid #ff69b4;
    border-right: 3px solid #8b3a62;
    border-bottom: 3px solid #8b3a62;
    padding: 0;
    box-shadow: 10px 10px 0px rgba(0, 0, 0, 0.5);
    max-width: 320px;
    position: relative;
    overflow: hidden;
}

/* Marble canvas for rotate window */
.rotate-marble {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0.9;
    mix-blend-mode: screen;
    pointer-events: none;
}

.rotate-content {
    padding: 30px 40px;
    position: relative;
    z-index: 2;
}

.rotate-msg {
    font-size: 14px;
    line-height: 1.8;
    letter-spacing: 1px;
    text-align: center;
}

/* Gold embossed text for rotate message */
.rotate-msg span {
    font-weight: bold;
    background: linear-gradient(180deg,
            #f5e6a3 0%,
            #d4af37 25%,
            #b8860b 50%,
            #d4af37 75%,
            #f5e6a3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.9)) drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.7));
}

/* Mobile Detection Overlay */
#mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: black;
    color: white;
    z-index: 99999;
    /* Top level blocking */
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    padding: 20px;
    box-sizing: border-box;
    text-transform: uppercase;
    line-height: 1.5;
}

#mobile-overlay.hidden {
    display: none !important;
}

.mobile-msg-container {
    /* Border removed for cleaner mobile layout */
    padding: 20px;
    width: 100%;
    /* No height constraint, just centered */
    background: black;
    box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.retro-link {
    color: #ffff00;
    text-decoration: underline;
    cursor: pointer;
}

.retro-link:hover {
    background-color: #ffff00;
    color: black;
    text-decoration: none;
}

.retro-window {
    background-color: #c0c0c0;
    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #404040;
    border-bottom: 2px solid #404040;
    padding: 4px;
    width: 400px;
    box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.8);
}

.retro-header {
    background: linear-gradient(90deg, #000080, #1084d0);
    color: white;
    padding: 4px 8px;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.retro-content {
    padding: 10px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: bold;
}

.input-group input {
    width: 100%;
    padding: 5px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    border: 2px solid #808080;
    border-right-color: white;
    border-bottom-color: white;
    background: black;
    color: #00ff00;
    /* Hacker green */
    box-sizing: border-box;
}

.button-row {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.button-row .retro-btn {
    min-width: 100px;
    margin: 0;
}

#status-msg {
    margin-top: 10px;
    font-size: 11px;
    color: green;
    text-align: center;
    height: 15px;
}

/* Mobile Navigation Tweaks (Chapter Button System) */
@media (max-width: 950px) {
    #ui-overlay {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    #static-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        /* Exact same gap as artworks */
        order: -1 !important;
        pointer-events: auto !important;
        margin-bottom: 10px !important;
    }

    #mailto-btn {
        display: block !important;
        pointer-events: auto !important;
    }

    /* CHAPTERS button is visible on mobile (both portrait and landscape) */
    #chapters-btn {
        display: block !important;
        pointer-events: auto !important;
    }

    /* Hidden by default until CHAPTERS is pressed */
    #buttons-container {
        display: none !important;
        gap: 10px !important;
    }

    #buttons-container.mobile-visible {
        display: flex !important;
    }

    /* Hide individual chapter button when list is open */
    #chapters-btn.mobile-hidden {
        display: none !important;
    }

    /* Global Mobile/Tablet Tweaks to hide F button */
    #fullscreenBtn,
    .fullscreen-btn,
    [id*="fullscreen"] {
        display: none !important;
    }
}

/* Ensure F button is hidden on all tablets (iPad Pro landscape is 1366px) */
@media (max-width: 1500px),
(hover: none) {

    #fullscreenBtn,
    .fullscreen-btn,
    [id*="fullscreen"] {
        display: none !important;
    }
}