/* ============================================
   MENU POPUPS STYLES
   HTML implementation of menu system
   ============================================ */

.menu-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002; /* Above restoration popup */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    touch-action: manipulation;
    overscroll-behavior: none;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.menu-popup.hidden {
    opacity: 0;
    pointer-events: none;
}

.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

/* Menu Modal */
.menu-modal {
    position: relative;
    background: linear-gradient(145deg, #303030, #252525);
    border-radius: 20px;
    padding: 35px 12px;
    min-width: 200px;
    max-width: 250px;
    width: 70%;
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.8),
        0 15px 40px rgba(0, 0, 0, 0.6),
        0 5px 15px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: menuPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-areas:
        "close close close close"
        "title title title title"
        ". sound music ."
        "howtoplay howtoplay howtoplay howtoplay"
        "home home home home";
    gap: 20px;
    align-items: center;
    justify-items: center;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    transform-origin: center center;
    transition: transform 0.2s ease-out;
}

.menu-close {
    grid-area: close;
    justify-self: end;
    align-self: flex-start;
    margin-left: auto;
}

.menu-title {
    grid-area: title;
    width: 100%;
}

#sound-toggle {
    grid-area: sound;
}

#music-toggle {
    grid-area: music;
}

#how-to-play-btn {
    grid-area: howtoplay;
}

#home-btn {
    grid-area: home;
}

.menu-modal-large {
    max-width: 500px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
    padding: 35px 20px;
    min-width: 280px;
    width: 85%;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-origin: center center;
    transition: transform 0.2s ease-out;
}

.menu-modal-large .menu-close {
    align-self: flex-end;
}

.menu-modal-large .menu-btn {
    min-width: 200px;
    padding: 16px 20px;
}

@keyframes menuPopIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Close Button */
.menu-close {
    min-width: 34px;
    max-width: 34px;
    width: 34px;
    min-height: 34px;
    max-height: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: rgba(102, 102, 102, 0.8);
    border: none;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: Arial, sans-serif;
    line-height: 1;
    margin: -20px -10px 0 0;
    flex-shrink: 0;
    padding: 0;
}

.menu-close:hover {
    background-color: rgba(102, 102, 102, 1);
    transform: scale(1.1);
}

.menu-close:active {
    transform: scale(0.95);
}

/* Title */
.menu-title {
    font-family: 'Coiny', cursive;
    font-size: 42px;
    color: white;
    margin: -15px 0 0 0;
    text-align: center;
}

/* Toggle Switches */
.menu-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(251, 203, 19, 0.3);
}

.toggle-icon-container {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #d3d3d3;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.menu-toggle:active .toggle-icon-container {
    transform: scale(0.95);
    background-color: #c0c0c0;
}

.toggle-icon {
    width: 30px;
    height: 30px;
}

.toggle-label {
    font-family: 'Coiny', cursive;
    font-size: 18px;
    color: white;
    text-align: center;
}

.toggle-switch {
    position: relative;
}

.toggle-track {
    width: 54px;
    height: 28px;
    border-radius: 20px;
    background-color: #a0a0a0;
    border: 2px solid black;
    position: relative;
    transition: background-color 0.3s ease;
}

.toggle-track.active {
    background-color: #4CAF50;
}

.toggle-thumb {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: white;
    border: 2px solid black;
    transition: left 0.3s ease;
}

.toggle-track.active .toggle-thumb {
    left: 26px;
}

/* Buttons */
.menu-btn {
    font-family: 'Coiny', cursive;
    font-size: 24px;
    padding: 16px 12px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    white-space: nowrap;
    position: relative;
}

.menu-btn-primary {
    background-color: #fbcb13;
    color: #000000;
    box-shadow: 0 5px 0 #ff7200;
}

.menu-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #ff7200;
}

.menu-btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 3px 0 #ff7200;
}

.menu-btn-secondary {
    background-color: #d3d3d3;
    color: #333333;
    box-shadow: 0 5px 0 #a0a0a0;
}

.menu-btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #a0a0a0;
}

.menu-btn-secondary:active {
    transform: translateY(2px);
    box-shadow: 0 3px 0 #a0a0a0;
}

.btn-icon {
    display: none;
}

.menu-btn-secondary .btn-icon {
    display: none;
}

.btn-icon img {
    display: none;
}

.btn-text {
    flex: 1;
    text-align: center;
    font-size: 24px;
    width: 100%;
}

/* How to Play Content */
.howtoplay-content {
    max-width: 400px;
    padding: 20px;
    text-align: left;
}

.howtoplay-text {
    font-family: 'Coiny', cursive;
    font-size: 18px;
    color: white;
    line-height: 1.6;
    margin: 0;
    white-space: pre-line;
}

/* Rules Content */
.rules-content {
    max-width: 400px;
    padding: 20px;
    text-align: center;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    isolation: isolate;
    opacity: 1;
    transition: opacity 0.1s ease-in-out;
}

.rules-card-title {
    font-family: 'Coiny', cursive;
    font-size: 18px;
    color: white;
    font-weight: bold;
    margin: 0;
}

.rules-card-text {
    font-family: 'Coiny', cursive;
    font-size: 20px;
    color: white;
    line-height: 1.5;
    margin: 0;
    text-align: center;
    text-decoration: none;
    word-wrap: break-word;
    overflow-wrap: break-word;
    letter-spacing: 0.02em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Rules Navigation */
.rules-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 10px 0;
}

.rules-arrow {
    min-width: 50px;
    max-width: 50px;
    width: 50px;
    min-height: 50px;
    max-height: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #d3d3d3;
    border: none;
    color: #333333;
    font-size: 28px;
    font-family: 'Coiny', cursive;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.rules-arrow:hover {
    background-color: #c0c0c0;
    transform: scale(1.1);
}

.rules-arrow:active {
    transform: scale(0.95);
}

.rules-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.rules-page-indicator {
    font-family: 'Coiny', cursive;
    font-size: 20px;
    color: white;
    min-width: 60px;
    text-align: center;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .menu-modal {
        padding: 30px 20px;
        min-width: 280px;
        max-width: 90%;
    }

    .menu-modal-large {
        /* max-height removed - using JavaScript scale instead */
    }

    .menu-title {
        font-size: 28px;
    }

    .menu-btn {
        font-size: 20px;
        padding: 14px 25px;
        min-width: 200px;
    }

    .toggle-label {
        font-size: 16px;
    }

    .howtoplay-text {
        font-size: 16px;
    }

    .rules-card-title {
        font-size: 17px;
    }

    .rules-card-text {
        font-size: 17px;
    }

    .rules-arrow {
        min-width: 45px;
        max-width: 45px;
        width: 45px;
        min-height: 45px;
        max-height: 45px;
        height: 45px;
        font-size: 24px;
    }

    .rules-page-indicator {
        font-size: 18px;
    }
}

/* Long text adaptation */
.menu-btn .btn-text {
    font-size: inherit;
}

/* For very long button texts (like French translations) */
@media (max-width: 500px) {
    .menu-btn {
        min-width: 180px;
        font-size: 18px;
        padding: 14px 22px;
    }
}

/* Desktop adjustments */
@media (min-width: 601px) {
    .menu-modal {
        padding: 30px 15px;
        min-width: 280px;
        max-width: 320px;
        gap: 15px;
    }

    .menu-modal-large {
        max-width: 420px;
        min-width: 320px;
        max-height: 75vh;
        padding: 25px 15px;
        gap: 12px;
    }

    .menu-modal-large .menu-btn {
        min-width: 180px;
        padding: 14px 16px;
        font-size: 18px;
    }

    .menu-btn {
        font-size: 18px;
        padding: 14px 10px;
        min-width: 140px;
    }

    .btn-text {
        font-size: 18px;
    }

    .menu-title {
        font-size: 36px;
    }

    .toggle-label {
        font-size: 16px;
    }

    .howtoplay-text {
        font-size: 16px;
    }

    .rules-card-text {
        font-size: 18px;
    }

    .rules-content {
        padding: 10px 20px;
        gap: 10px;
        min-height: 250px;
    }
}
