/* --- General Styling & Variables --- */
:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --card-bg-color: #1e1e1e;
    --primary-color: #8A2BE2; /* BlueViolet */
    --secondary-color: #00BFFF; /* DeepSkyBlue */
    --text-color: #E0E0E0;
    --text-muted-color: #A0A0A0;
    --border-color: #333;
    --glow-color: rgba(138, 43, 226, 0.5);

    --font-en-title: sans-serif;
    --font-en-body: sans-serif;
    --font-ar-title: 'Tajawal', sans-serif;
    --font-ar-body: 'Tajawal', sans-serif;
}

/* Light Theme Variables */
.light-theme {
    --bg-color: #f0f2f5;
    --surface-color: #ffffff;
    --card-bg-color: #ffffff;
    --text-color: #212529;
    --text-muted-color: #6c757d;
    --border-color: #e9ecef;
    --glow-color: rgba(138, 43, 226, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-en-body);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

html.rtl {
    direction: rtl;
}

html.rtl body {
    font-family: var(--font-ar-body);
}

.container {
    width: 90%;
    max-width: 1300px;
    margin: 0 auto;
}

img {
    max-width: 100%;
    display: block;
}

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

a:hover {
    color: var(--secondary-color);
}

/* --- Header --- */
.main-header {
    background-color: rgba(18, 18, 18, 0.8);
    backdrop-filter: blur(10px);
    padding: 1.5rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.light-theme .main-header {
    background-color: rgba(255, 255, 255, 0.8);
    border-color: #e9ecef;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.light-theme .logo {
    color: var(--text-color);
}

.logo i {
    color: var(--primary-color);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.language-selector, .theme-toggle-btn {
    position: relative;
}

.language-btn, .theme-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}
.theme-toggle-btn { padding: 0.5rem 1rem; }

.light-theme .language-btn, .light-theme .theme-toggle-btn {
    color: var(--text-color);
}

.language-btn:hover, .theme-toggle-btn:hover {
    background-color: var(--surface-color);
    border-color: var(--primary-color);
}

.language-dropdown {
    display: none;
    position: absolute;
    top: 120%;
    right: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    min-width: 150px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

html.rtl .language-dropdown {
    right: auto;
    left: 0;
}

.language-dropdown.show {
    display: block;
}

.language-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    border-radius: 6px;
}

.language-dropdown a:hover {
    background-color: var(--primary-color);
    color: #fff;
}

/* --- Main Content --- */
main {
    padding-top: 100px; /* Header height + margin */
}

/* --- Hero Section (Inspired by Themewagon) --- */
.hero-section {
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('images/hero_bg.jpg') no-repeat center center;
    background-size: cover;
    padding: 8rem 0;
    color: #fff;
    text-align: center;
}

.light-theme .hero-section {
    background: linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)), url('images/hero_bg.jpg') no-repeat center center;
    background-size: cover;
    color: #212529;
}

.hero-text {
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    font-family: var(--font-en-title);
    animation: neon-glow 2s ease-in-out infinite alternate;
}

.hero-description {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

/* New Neon Glow Animation for Title */
@keyframes neon-glow {
    from {
        text-shadow: 0 0 5px var(--primary-color), 0 0 10px var(--primary-color);
    }
    to {
        text-shadow: 0 0 20px var(--primary-color), 0 0 30px var(--primary-color), 0 0 40px var(--primary-color);
    }
}

html.rtl .hero-title {
    font-family: var(--font-ar-title);
}

html.rtl .hero-description {
    font-family: var(--font-ar-body);
}

/* --- Games Section --- */
.games-section {
    padding: 4rem 0;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 3rem;
    color: var(--text-color);
    position: relative;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-en-title);
}

html.rtl .section-title {
    font-family: var(--font-ar-title);
}

.section-title::after {
    content: '';
    position: absolute;
    width: 70%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    bottom: -10px;
    left: 15%;
    border-radius: 2px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.game-card {
    background-color: var(--card-bg-color);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 0 25px var(--glow-color);
}

.game-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.game-card-content {
    padding: 1.5rem;
}

.game-card-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card-description {
    color: var(--text-muted-color);
    font-size: 0.9rem;
    height: 45px;
    overflow: hidden;
}

/* --- Game Detail View --- */
.game-detail-view {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    overflow-y: auto;
    padding: 2rem;
    backdrop-filter: blur(5px);
}

.light-theme .game-detail-view {
    background-color: rgba(240, 242, 245, 0.9);
}

.game-detail-content {
    background-color: var(--card-bg-color);
    max-width: 1100px;
    margin: 2rem auto;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: background-color 0.3s, border-color 0.3s;
}

.game-detail-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
}

.game-detail-info {
    display: flex;
    flex-direction: column;
}

.game-detail-title {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.game-detail-long-description {
    color: var(--text-muted-color);
    margin-bottom: 1.5rem;
}

.download-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: auto; /* Push buttons to the bottom */
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    color: #fff;
    transition: transform 0.2s ease;
}

.download-btn:hover {
    transform: scale(1.05);
}

.download-btn.google-play { background-color: #4CAF50; }
.download-btn.app-store { background-color: #007AFF; }
.download-btn img { height: 24px; }

/* --- Slideshow Container (Replaces old gallery) --- */
.slideshow-container {
    position: relative;
    width: 100%;
    height: 450px;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.slideshow-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ensures images fit without distortion */
    background-color: #000;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}
.slideshow-image.active {
    opacity: 1;
}

/* Motivational Phrase Box (The "red box") */
.motivational-box {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem; /* Reduced padding for smaller screens */
    background-color: var(--card-bg-color);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    min-height: 100px;
}

.motivational-text {
    font-size: 1.5rem; /* Reduced font size for smaller screens */
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--glow-color);
    line-height: 1.4;
    transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
    white-space: normal; /* Allow text to wrap */
    animation: none;
    max-width: 90%; /* Ensure text doesn't overflow container */
}

@media (min-width: 768px) {
    .motivational-text {
        font-size: 2rem; /* Restore larger font on bigger screens */
    }
}

.motivational-text.en { font-family: var(--font-en-body); }
.motivational-text.ar { font-family: var(--font-ar-body); }

/* New motivational phrase animations */
.animate-fade-in {
    animation: fadeIn 1.5s ease-in-out forwards;
}

.animate-slide-up {
    animation: slideUp 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.animate-scale-in {
    animation: scaleIn 1.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
}

.animate-typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 2s steps(40, end) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

.close-detail-view {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: var(--card-bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

html.rtl .close-detail-view {
    right: auto;
    left: 2rem;
}

/* --- Footer --- */
.main-footer {
    background-color: var(--card-bg-color);
    padding: 4rem 0 2rem 0;
    border-top: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-column {
    padding: 1rem;
}

.footer-logo {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.footer-description {
    color: var(--text-muted-color);
    margin-bottom: 1.5rem;
}

.footer-column h4 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.footer-column p {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    color: var(--text-muted-color);
    margin-bottom: 1rem;
}

.footer-column p i {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-top: 4px;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    font-size: 1.2rem;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.light-theme .social-icon {
    background-color: #f8f9fa;
}

.social-icon:hover {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.newsletter-form input {
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-color);
    width: 100%;
}

.newsletter-form button {
    padding: 0.75rem;
    border-radius: 8px;
    border: none;
    background-color: var(--primary-color);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.3s;
}

.newsletter-form button:hover {
    background-color: var(--secondary-color);
}

.footer-bottom {
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

.footer-bottom p {
    color: var(--text-muted-color);
    margin: 0;
}


/* --- Responsive Design --- */
@media (max-width: 992px) {
    .game-detail-main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .hero-title { font-size: 2.5rem; }
    .section-title { font-size: 2rem; }
    .header-content { flex-direction: column; gap: 1rem; }
    main { padding-top: 150px; }
    .slideshow-container { height: 300px; }
    .hero-section { padding: 5rem 0; }
}

@media (max-width: 576px) {
    .games-grid { grid-template-columns: 1fr; }
    .game-detail-view { padding: 1rem; }
    .game-detail-content { margin: 1rem auto; }
    .close-detail-view { top: 1rem; right: 1rem; }
    html.rtl .close-detail-view { right: auto; left: 1rem; }
}