/*
 * Styles specific to the games page (games.php) will be placed here.
 */

/* Accordion Styles */
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out, padding-top 0.5s ease-out, padding-bottom 0.5s ease-out;
    padding-left: 1.5rem; /* Corresponds to p-6 */
    padding-right: 1.5rem; /* Corresponds to p-6 */
}
.accordion-content.active {
    max-height: 5000px; /* A large enough value to not clip content */
    padding-top: 1.5rem; /* Corresponds to p-6 */
    padding-bottom: 1.5rem; /* Corresponds to p-6 */
    border-top: 1px solid #4a5568; /* border-gray-700 */
}
.accordion-arrow.rotated {
    transform: rotate(180deg);
}

/* Make all game containers full-width to allow for responsive board centering */
.game-container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Tic-Tac-Toe specific styles */
.tic-tac-toe-game-board {
    display: grid;
    grid-template-columns: repeat(3, 100px); /* Fixed cell size for desktop */
    grid-template-rows: repeat(3, 100px);
    gap: 4px;
}

.tic-tac-toe-cell {
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem; /* Larger font for X/O */
    font-weight: bold;
    cursor: pointer;
    border: 2px solid #a0aec0; /* Tailwind gray-400 */
    transition: background-color 0.3s ease;
}

.tic-tac-toe-cell:hover {
    background-color: #f7fafc; /* Tailwind gray-50 */
}

.tic-tac-toe-cell.x-mark {
    color: #ef4444; /* Tailwind red-500 */
}

.tic-tac-toe-cell.o-mark {
    color: #3b82f6; /* Tailwind blue-500 */
}

/* New class for winning cells highlight */
.tic-tac-toe-cell.win-line {
    background-color: #fcd34d; /* Tailwind yellow-300 */
    animation: pulse 1s infinite alternate; /* Simple pulse animation */
}

@keyframes pulse {
    from { background-color: #fcd34d; }
    to { background-color: #f59e0b; }
}

/* Responsive adjustments for smaller screens */
@media (max-width: 640px) {
    .tic-tac-toe-game-board {
        grid-template-columns: repeat(3, 80px); /* Smaller cell size for mobile */
        grid-template-rows: repeat(3, 80px);
    }
    .tic-tac-toe-cell {
        width: 80px;
        height: 80px;
        font-size: 2.5rem;
    }
}

/* Rock-Paper-Scissors specific styles */
.rps-choice-button {
    display: inline-flex; /* Use flexbox to center content */
    align-items: center; /* Vertically center content */
    justify-content: center; /* Horizontally center content */
    color: #000000; /* Black for visibility against white background */
    font-weight: bold;
    padding: 0.25rem; /* Retained padding */
    border-radius: 9999px; /* rounded-full */
    transform: translateY(0); /* For hover effect */
    transition: all 0.3s ease; /* Smooth transition for hover */
    font-size: 4.5rem; /* 75% of 6rem */
    cursor: pointer; /* Indicate interactivity */
    line-height: 1; /* Remove extra line height from emoji */
    background-color: transparent; /* Ensure no background by default */
}
.rps-choice-button:hover {
    background-color: #f0f0f0; /* Light gray on hover for visual feedback */
    transform: translateY(-0.25rem); /* hover:-translate-y-1 */
}
.rps-player-choice, .rps-computer-choice {
    font-size: 4.5rem; /* 75% of 6rem */
    line-height: 1; /* Match line height for consistent sizing */
}

/* Minesweeper specific styles */
#minesweeper_boardContainer {
    /* Dynamic width and height will be set by JS */
    display: grid;
    border: 2px solid #a0aec0; /* Tailwind gray-400 */
    border-radius: 8px; /* Rounded corners for the board */
    overflow: hidden; /* Ensures borders are rounded within container */
    padding: 2px; /* Add padding to show the container's border evenly */
}

.minesweeper-cell {
    width: 30px; /* Base cell size */
    height: 30px;
    background-color: #d1d5db; /* Tailwind gray-300 */
    border: 1px solid #9ca3af; /* Tailwind gray-400 */
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    user-select: none; /* Prevent text selection */
    transition: background-color 0.1s ease-out;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

.minesweeper-cell:hover:not(.revealed):not(.flagged) {
    background-color: #e5e7eb; /* Tailwind gray-200 */
}

.minesweeper-cell.revealed {
    background-color: #f3f4f6; /* Tailwind gray-100 */
    border: 1px solid #e5e7eb; /* Lighter border when revealed */
    cursor: default;
}

.minesweeper-cell.mine {
    background-color: #f87171; /* Tailwind red-400 */
    color: #fff;
}

.minesweeper-cell.mine-exploded {
    background-color: #ef4444; /* Tailwind red-500 - more intense */
    color: #fff;
    animation: pulse-mine 0.5s 3; /* A quick pulse */
}

@keyframes pulse-mine {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.minesweeper-cell.flagged {
    background-color: #fcd34d; /* Tailwind yellow-300 */
    color: #000;
}

/* Colors for numbers */
.minesweeper-cell[data-value="1"] { color: #2563eb; /* blue-700 */ }
.minesweeper-cell[data-value="2"] { color: #16a34a; /* green-700 */ }
.minesweeper-cell[data-value="3"] { color: #dc2626; /* red-700 */ }
.minesweeper-cell[data-value="4"] { color: #7c3aed; /* violet-700 */ }
.minesweeper-cell[data-value="5"] { color: #ef4444; /* red-500 */ }
.minesweeper-cell[data-value="6"] { color: #0891b2; /* cyan-700 */ }
.minesweeper-cell[data-value="7"] { color: #f97316; /* orange-500 */ }
.minesweeper-cell[data-value="8"] { color: #9ca3af; /* gray-400 */ }

/* Responsive adjustments for Minesweeper cell size on smaller screens */
@media (max-width: 640px) {
    .minesweeper-cell {
        width: 25px; /* Slightly smaller cells on mobile */
        height: 25px;
        font-size: 1rem;
    }
}

/* Connect Four specific styles */
#connect4_boardContainer {
    display: grid;
    grid-template-columns: repeat(7, 60px); /* 7 columns, fixed size for desktop */
    grid-template-rows: repeat(6, 60px); /* 6 rows, fixed size */
    gap: 4px;
    background-color: #3b82f6; /* Tailwind blue-500 for the board */
    border-radius: 12px;
    padding: 10px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    margin: 20px auto;
}

.connect4-cell {
    width: 60px;
    height: 60px;
    background-color: #1a1a1a; /* Dark background for empty holes */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative; /* For the dropped piece animation */
    overflow: hidden; /* Ensure pieces stay within bounds during animation */
}

.connect4-cell.player1::after {
    content: '';
    display: block;
    width: 50px; /* Slightly smaller than cell to show border */
    height: 50px;
    background-color: #ef4444; /* Tailwind red-500 */
    border-radius: 50%;
    position: absolute;
    animation: dropPiece 0.5s ease-out forwards;
    box-shadow: 0 0 8px rgba(0,0,0,0.7);
}

.connect4-cell.player2::after {
    content: '';
    display: block;
    width: 50px;
    height: 50px;
    background-color: #fcd34d; /* Tailwind yellow-300 */
    border-radius: 50%;
    position: absolute;
    animation: dropPiece 0.5s ease-out forwards;
    box-shadow: 0 0 8px rgba(0,0,0,0.7);
}

/* New style for clickable top cells */
.connect4-cell.clickable-top-cell {
    cursor: pointer;
    outline: 2px solid transparent; /* default transparent outline */
    transition: outline-color 0.2s ease-in-out;
}

.connect4-cell.clickable-top-cell:hover {
    outline-color: #ffffff; /* White outline on hover */
    outline-offset: 2px; /* Small offset for the outline */
}


/* Animation for dropping piece */
@keyframes dropPiece {
    0% { transform: translateY(-300px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Responsive adjustments for Connect Four */
@media (max-width: 640px) {
    #connect4_boardContainer {
        grid-template-columns: repeat(7, 45px); /* Smaller cells for mobile */
        grid-template-rows: repeat(6, 45px);
        gap: 2px; /* Smaller gap */
        padding: 5px;
        margin: 10px auto;
    }

    .connect4-cell {
        width: 45px;
        height: 45px;
    }

    .connect4-cell.player1::after,
    .connect4-cell.player2::after {
        width: 38px; /* Adjusted piece size */
        height: 38px;
    }
}

/* Memory Game specific styles */
#memory_boardContainer {
    display: grid;
    background-color: #3b82f6; /* Tailwind blue-500 */
    border-radius: 12px;
    padding: 10px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    margin: 20px auto;
}

.memory-game-card {
    width: 80px;
    height: 80px;
    background-color: #1a1a1a; /* Dark background for card back */
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem; /* For emoji/icon */
    color: #ffffff;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    position: relative;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.memory-game-card.flipped {
    transform: rotateY(180deg);
}

.memory-game-card.matched {
    cursor: default;
    pointer-events: none; /* Disable clicks on matched cards */
    /* The card remains flipped, but we change the front face style to indicate a match */
    /* Opacity is removed to keep the icon fully visible */
}

.memory-game-card .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
}

.memory-game-card .card-front {
    background-color: #fcd34d; /* Tailwind yellow-300 */
    color: #000;
    transform: rotateY(180deg);
}

/* New style for the front of a card that has been successfully matched */
.memory-game-card.matched .card-front {
    background-color: #4ade80; /* Tailwind green-400 */
    color: #1f2937; /* Tailwind gray-800 for better contrast */
}

.memory-game-card .card-back {
    background-color: #3b82f6; /* Tailwind blue-500 */
    color: #fff;
}

/* Responsive adjustments for Memory Game */
@media (max-width: 640px) {
    .memory-game-card {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
}
