/* Global Variables - games.css */
:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --primary-color: #007aff;
    --accent-color: #007aff;
    --card-bg: #f5f5f7;
    --border-color: #eeeeee;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --header-height: 50px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --text-color: #f5f5f5;
        --primary-color: #007aff;
        --accent-color: #007aff;
        --card-bg: #1c1c1e;
        --border-color: #222222;
        --shadow-color: rgba(0, 0, 0, 0.2);
    }
}

[data-theme="light"] {
    --bg-color: #ffffff;
    --text-color: #000000;
    --primary-color: #007aff;
    --accent-color: #007aff;
    --card-bg: #f5f5f7;
    --border-color: #eeeeee;
    --shadow-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-color: #000000;
    --text-color: #f5f5f5;
    --primary-color: #007aff;
    --accent-color: #007aff;
    --card-bg: #1c1c1e;
    --border-color: #222222;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

/* Global Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.5;
    padding-top: var(--header-height);
    margin: 0;
    overflow-x: hidden;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Header Styles */
#main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-color);
    padding: 0 15px;
    margin: 0 0.5rem;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    height: var(--header-height);
    box-sizing: border-box;
}

#main-header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    margin: 0 auto;
    gap: 1.5rem;
    position: relative;
}

#main-header .header-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#main-header nav a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

#main-header nav a:hover,
#main-header nav a:focus {
    color: var(--accent-color);
    text-decoration: none;
    outline: none;
}

/* Theme toggle */
#main-header .theme-switch-wrapper {
    display: flex;
    align-items: center;
    padding: 0;
    background-color: transparent;
}

#main-header .theme-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px;
}

#main-header .theme-switch-wrapper i {
    font-size: 1.2rem;
    transition: opacity 0.3s ease;
    line-height: 1;
}

#main-header .theme-toggle:hover {
    opacity: 0.5;
}

#main-header .theme-toggle:focus {
    outline: none;
}

#main-header .theme-toggle .fa-sun {
    display: none;
}

#main-header .theme-toggle .fa-moon {
    display: inline-block;
    color: #007aff;
}

[data-theme="dark"] #main-header .theme-toggle .fa-sun {
    display: inline-block;
    color: #FFA500;
}

[data-theme="dark"] #main-header .theme-toggle .fa-moon {
    display: none;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Game Grid */
.games-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    max-width: 550px;
    width: 100%;
    margin: 0 auto;
}

.game-card {
    background-color: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-bottom: 1.5rem;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.game-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 2; /* Approximately 2:1 aspect ratio to show full screenshot */
    overflow: hidden;
}

.game-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
    padding-top: 0rem;
    box-sizing: border-box;
}

.game-info {
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.game-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0 0 0.5rem 0;
    text-align: center;
}

.game-description {
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
    flex-grow: 1;
}

.play-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.play-button:hover {
    background-color: var(--accent-color);
    opacity: 0.9;
}

/* App Store Button Styles */
.app-store-buttons {
    display: flex;
    gap: 1.5rem;
    margin: 3rem auto 0;
    justify-content: center;
}

.app-store-button img {
    height: 3rem;
    transition: opacity 0.2s ease;
}

.app-store-button:hover img {
    opacity: 0.9;
}

/* Footer */
footer {
    text-align: center;
    padding: 0rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-color);
}

footer a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover,
footer a:focus {
    color: var(--accent-color);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto;
}

.footer-text {
    font-size: 0.9rem;
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
}

.copyright-text {
    font-size: 0.9rem;
    display: flex;
    text-align: center;
}

/* Mobile Game Selector */
.game-selector {
    display: none;
    margin-bottom: 1rem;
    position: relative;
    width: 100%;
}

.game-selector-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    -ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
}

.game-selector-button {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: var(--text-color);
    flex: 0 0 auto;
}

.game-selector-button.active {
    background-color: var(--primary-color);
    color: white;
}

.game-counter {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 0.5rem;
}

.counter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--border-color);
}

.counter-dot.active {
    background-color: var(--primary-color);
}

/* Media Queries */
@media (max-width: 1200px) {
    .games-container {
        grid-template-columns: repeat(2, 1fr);
        row-gap: 3rem;
    }
}

/* Mobile View */
@media (max-width: 650px) {
    .game-selector {
        display: block;
        width: 100%;
    }

    .games-container {
        display: flex;
        flex-direction: column;
        position: relative;
        gap: 1rem;
    }

    .game-card {
        display: none;
    }

    .game-card.active {
        display: flex;
    }

    .game-image-container {
         aspect-ratio: 1 / 1; /* Preserve aspect ratio on mobile */
    }

    .game-image {
        padding-top: 1rem;
    }

    .game-title {
        margin-top: 0.5rem;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
        display: none;
    }

    .app-store-buttons {
        gap: 1rem;
        margin: 1rem auto;  
    }

    .app-store-button img {
        height: 2.5rem;
    }

    .footer-text {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Swipe animations */
    @keyframes slideOutLeft {
        from { transform: translateX(0); opacity: 1; }
        to { transform: translateX(-100%); opacity: 0; }
    }

    @keyframes slideInRight {
        from { transform: translateX(100%); opacity: 0; }
        to { transform: translateX(0); opacity: 1; }
    }

    @keyframes slideOutRight {
        from { transform: translateX(0); opacity: 1; }
        to { transform: translateX(100%); opacity: 0; }
    }

    @keyframes slideInLeft {
        from { transform: translateX(-100%); opacity: 0; }
        to { transform: translateX(0); opacity: 1; }
    }

    /* When a card is animating, pull it out of the flow so it doesn't reserve space */
.slide-out-left,
.slide-out-right {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

    .slide-out-left {
        animation: slideOutLeft 0.3s forwards;
    }

    .slide-in-right {
        animation: slideInRight 0.3s forwards;
    }

    .slide-out-right {
        animation: slideOutRight 0.3s forwards;
    }

    .slide-in-left {
        animation: slideInLeft 0.3s forwards;
    }
}

/* Small Mobile */
@media (max-width: 400px) {
    h1 {
        font-size: 1.5rem;
    }

    .game-title {
        font-size: 1.1rem;
    }

    .app-store-button img {
        height: 2rem;
    }
}