/* styles.css */

/* =========================================
   RESET & VARIABLES
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-gradient: linear-gradient(135deg, #f0fdf4 0%, #dbeafe 100%);
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --success: #22c55e;
    --danger: #ef4444;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =========================================
   STICKY HEADER & NAV
   ========================================= */
.sticky-header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.desktop-nav a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    margin-left: 25px;
    transition: color 0.2s;
}

.desktop-nav a:hover {
    color: var(--primary);
}

.hamburger-menu {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav.hidden {
    display: none;
}

.mobile-nav a {
    padding: 15px 20px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    border-top: 1px solid var(--border-color);
}

/* =========================================
   HUB PAGE (index.php)
   ========================================= */
.hub-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    flex: 1;
}

.hub-hero {
    text-align: center;
    margin-bottom: 50px;
}

.hub-hero h1 {
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 15px;
    color: var(--text-main);
}

.hub-hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Card Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
}

.game-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 0;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.game-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.game-card h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    padding: 0 20px;
}

.game-card p {
    color: var(--text-muted);
    margin-bottom: 25px;
    line-height: 1.6;
    padding: 0 20px;
    flex-grow: 1;
}

.play-btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
    margin: 0 20px 20px 20px;
}

.play-btn:hover {
    background: var(--primary-hover);
}

/* Accordion FAQ */
.faq-section {
    max-width: 800px;
    margin: 0 auto 60px auto;
}

.faq-section h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2rem;
}

.accordion {
    margin-bottom: 10px;
}

.accordion-header {
    background-color: var(--card-bg);
    color: var(--text-main);
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: left;
    outline: none;
    font-size: 1.1rem;
    font-weight: 600;
    transition: 0.4s;
    font-family: 'Inter', sans-serif;
}

.accordion-header.active, .accordion-header:hover {
    background-color: #f8fafc;
}

.accordion-header:after {
    content: '\002B';
    color: var(--text-muted);
    font-weight: bold;
    float: right;
    margin-left: 5px;
}

.accordion-header.active:after {
    content: "\2212";
}

.accordion-content {
    padding: 0 18px;
    background-color: white;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
    border-radius: 0 0 8px 8px;
}

.accordion-content p {
    padding: 15px 0;
    line-height: 1.6;
    color: var(--text-muted);
}

/* =========================================
   GAMES UI (layout.php)
   ========================================= */
#ui-container {
    max-width: 600px;
    margin: 40px auto 20px auto;
    padding: 0 20px;
    width: 100%;
    position: relative;
    z-index: 20;
}

.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -1px;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 5px;
    margin-bottom: 15px;
}

.reset-btn {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.reset-btn:hover {
    background: #e2e8f0;
}

/* Search Bar */
#search-container {
    margin-bottom: 30px;
}

.input-wrapper {
    position: relative;
    display: flex;
    gap: 10px;
    z-index: 1000; /* Extremely important for dropdown overlay */
}

#country-input {
    flex: 1;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    outline: none;
    box-shadow: var(--shadow-sm);
}

#country-input:focus {
    border-color: var(--primary);
}

#submit-btn {
    padding: 0 20px;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background 0.2s;
}

#submit-btn:hover {
    background: var(--primary-hover);
}

/* Autocomplete */
.autocomplete-items {
    position: absolute;
    top: 100%;
    left: 0;
    right: 90px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:hover {
    background-color: #f1f5f9;
}

/* Guesses */
#guesses-container {
    max-height: 300px;
    overflow-y: auto;
}

.guess-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    animation: popIn 0.3s ease-out;
}

.guess-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.guess-distance {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

.color-block {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

/* =========================================
   GAME SPECIFIC VISUALS
   ========================================= */
#game-visual-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin-bottom: 40px;
}

/* Worldle (Shape) */
#worldle-container {
    width: 100%;
    max-width: 500px;
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#country-shape-img {
    max-width: 100%;
    max-height: 100%;
    filter: brightness(0) drop-shadow(0 10px 15px rgba(0,0,0,0.2));
    transition: filter 1s ease;
}

/* Flagle (Flag with covers) */
#flagle-container {
    width: 100%;
    max-width: 400px;
}

#flag-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 3/2;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#flag-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flag-cover {
    position: absolute;
    background-color: #cbd5e1;
    border: 1px solid #94a3b8;
    transition: opacity 0.5s ease;
}
.block-1 { top: 0; left: 0; width: 33.33%; height: 50%; }
.block-2 { top: 0; left: 33.33%; width: 33.33%; height: 50%; }
.block-3 { top: 0; left: 66.66%; width: 33.33%; height: 50%; }
.block-4 { top: 50%; left: 0; width: 33.33%; height: 50%; }
.block-5 { top: 50%; left: 33.33%; width: 33.33%; height: 50%; }
.block-6 { top: 50%; left: 66.66%; width: 33.33%; height: 50%; }

/* GeoGuesser (Leaflet Map) */
#geoguesser-container {
    width: 100%;
    max-width: 800px;
    height: 500px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-color);
}

#map {
    width: 100%;
    height: 100%;
}

/* =========================================
   FOOTER
   ========================================= */
.site-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 30px 20px;
    text-align: center;
    margin-top: auto;
}

.footer-links {
    margin-bottom: 15px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 15px;
    font-weight: 600;
}

.footer-links a:hover {
    color: var(--primary);
}

.site-footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* =========================================
   MODAL
   ========================================= */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-md);
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--success);
}

.modal-content p {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.modal-btn {
    display: inline-block;
    padding: 10px 20px;
    margin-top: 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    color: white;
    background: var(--text-muted);
}

.green-btn {
    background: var(--primary);
    margin-left: 10px;
}

/* =========================================
   RESPONSIVE DESIGN (Media Queries)
   ========================================= */
@media (max-width: 768px) {
    .desktop-nav { display: none; }
    .hamburger-menu { display: block; }
    .hub-hero h1 { font-size: 2rem; }
    #country-input { font-size: 1rem; }
    #submit-btn { padding: 0 15px; font-size: 1rem; }
    #geoguesser-container { height: 350px; }
}
