/* ============================================================
   GeoFreak — Main Stylesheet
   ============================================================ */

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --blue-500: #1a73e8;
    --blue-600: #1557b0;
    --blue-700: #0d47a1;
    --blue-900: #0a2540;
    --green-400: #66bb6a;
    --green-500: #4caf50;
    --green-600: #2e7d32;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* ─── Top Bar (language switcher) ──────────────────────────── */
.top-bar {
    background: var(--gray-900);
    height: 32px;
}
.top-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}
.top-bar .nav-lang-wrap { position: relative; }
.top-bar .nav-lang {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    cursor: pointer;
    transition: color 0.2s;
}
.top-bar .nav-lang svg { width: 14px; height: 14px; flex-shrink: 0; stroke: var(--gray-400); }
.top-bar .nav-lang:hover { color: var(--white); }
.top-bar .nav-lang:hover svg { stroke: var(--white); }
.top-bar .lang-dropdown {
    top: calc(100% + 4px);
    right: 0;
}

/* ─── Navbar ───────────────────────────────────────────────── */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--gray-200);
    transition: top 0.25s ease, background 0.3s ease;
}
/* Landing page: navbar starts below the top-bar */
.has-topbar .navbar { top: 32px; }

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-logo {
    width: 36px !important;
    height: 36px !important;
    display: inline-block !important;
}

.nav-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--blue-700);
}

.nav-title .accent {
    color: var(--green-500);
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--gray-600);
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--blue-600);
}

/* ─── Language switcher ────────────────────────────────────── */
.nav-lang {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--gray-100);
    border: 1.5px solid var(--gray-300);
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    transition: all 0.2s;
    cursor: pointer;
}
.nav-lang svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-lang:hover {
    background: var(--blue-500);
    color: white;
    border-color: var(--blue-500);
}
.nav-lang:hover svg { stroke: white; }
.nav-lang-wrap {
    position: relative;
}
.lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 1100;
    overflow: hidden;
}
.lang-dropdown.open { display: block; }
.lang-opt {
    display: block;
    padding: 10px 16px;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s;
}
.lang-opt:hover { background: var(--gray-100); }
.lang-opt.active {
    background: var(--blue-500);
    color: white;
    font-weight: 600;
}

/* ─── Logout button (red) ──────────────────────────── */
.nav-logout {
    color: #ef4444 !important;
    font-weight: 600;
}
.nav-logout:hover {
    background: #fef2f2 !important;
    color: #dc2626 !important;
}

/* ─── Nav badge (pending friend requests) ──────────── */
.nav-badge {
    display: inline-block;
    background: #ef4444;
    color: white;
    border-radius: 50px;
    font-size: 0.68rem;
    padding: 1px 6px;
    margin-left: 4px;
    font-weight: 700;
    line-height: 1.4;
    vertical-align: top;
}

/* ─── Hamburger toggle (mobile) ────────────────────────────── */
.nav-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    z-index: 1010;
}
.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: all 0.3s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── Footer ───────────────────────────────────────────────── */
.footer {
    background: var(--gray-900);
    color: var(--gray-400);
    padding: 36px 24px 20px;
    font-size: 0.9rem;
}
.footer-container { max-width: 960px; margin: 0 auto; }
.footer-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 32px;
    flex-wrap: wrap;
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 6px;
}
.footer-brand img {
    width: 28px !important;
    height: 28px !important;
    display: inline-block !important;
}
.footer-slogan {
    color: var(--gray-400);
    font-size: 0.85rem;
    margin-top: 4px;
}
.footer-links {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.footer-links a {
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--white); }
.footer-bottom {
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 20px;
    padding-top: 16px;
    color: var(--gray-500);
    font-size: 0.8rem;
}

/* ─── Landing Page ─────────────────────────────────────────── */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--blue-900) 0%, #0c2d5a 40%, #0a3d6b 100%);
}

.hero-bg-globe {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 700px;
    height: 700px;
    opacity: 0.06;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 40px 24px;
    max-width: 800px;
}

.hero-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 24px;
    filter: drop-shadow(0 4px 20px rgba(26,115,232,0.4));
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 800;
    color: var(--white);
    margin-bottom: 16px;
    letter-spacing: -1px;
    line-height: 1.1;
}

.hero-title .accent {
    background: linear-gradient(135deg, var(--green-400), var(--green-500));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.35rem);
    color: rgba(255,255,255,0.7);
    margin-bottom: 40px;
    font-weight: 300;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: all 0.25s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
    color: white;
    box-shadow: 0 4px 15px rgba(26,115,232,0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(26,115,232,0.5);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
}

.btn-outline:hover {
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.08);
    transform: translateY(-2px);
}

/* ─── Features Section ─────────────────────────────────────── */
.features-section {
    padding: 100px 24px;
    background: var(--white);
}

.section-header {
    text-align: center;
    margin-bottom: 64px;
}

.section-badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--blue-500);
    color: white;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 12px;
}

.section-desc {
    font-size: 1.1rem;
    color: var(--gray-500);
    max-width: 600px;
    margin: 0 auto;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 28px;
    max-width: 1200px;
    margin: 0 auto;
}

.feature-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 36px 28px;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--blue-500);
}

.feature-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 20px;
}

.feature-icon.blue { background: rgba(26,115,232,0.1); }
.feature-icon.green { background: rgba(76,175,80,0.1); }
.feature-icon.orange { background: rgba(255,152,0,0.1); }
.feature-icon.purple { background: rgba(156,39,176,0.1); }
.feature-icon.red { background: rgba(244,67,54,0.1); }
.feature-icon.teal { background: rgba(0,150,136,0.1); }

.feature-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.feature-desc {
    color: var(--gray-500);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ─── Stats Bar ────────────────────────────────────────────── */
.stats-section {
    padding: 60px 24px;
    background: linear-gradient(135deg, var(--blue-700), var(--blue-900));
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 32px;
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.stat-item .stat-number {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--white);
}

.stat-item .stat-label {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.6);
    margin-top: 4px;
}

/* ─── CTA Section ──────────────────────────────────────────── */
.cta-section {
    padding: 80px 24px;
    text-align: center;
    background: var(--gray-50);
}

.cta-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
}

.cta-desc {
    color: var(--gray-500);
    margin-bottom: 32px;
    font-size: 1.05rem;
}

/* ─── Map Page ─────────────────────────────────────────────── */
.map-page {
    padding-top: 64px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#map {
    flex: 1;
    z-index: 1;
}

/* Leaflet custom tooltip */
.country-tooltip {
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
}

.country-tooltip .tooltip-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.country-tooltip .tooltip-capital {
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
}

/* ─── Country Modal ────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 28px 32px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 1;
}

.modal-flag {
    width: 72px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
}

.modal-country-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.modal-country-official {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.modal-close {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.modal-body {
    padding: 24px 32px 32px;
}

.modal-section {
    margin-bottom: 24px;
}

.modal-section-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--blue-500);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 24px;
}

.modal-item {
    display: flex;
    flex-direction: column;
    padding: 6px 0;
}

.modal-item-label {
    font-size: 0.75rem;
    color: var(--gray-400);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-item-value {
    font-size: 0.95rem;
    color: var(--gray-800);
    font-weight: 500;
}

/* Map markers */
.capital-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d4a017;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
    line-height: 1;
    text-align: center;
}

.city-marker {
    background: rgba(30, 64, 120, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.city-marker-large {
    background: rgba(220, 50, 50, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.city-tooltip-content {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    line-height: 1.4;
}

.city-tooltip-content .ct-name {
    font-weight: 600;
    font-size: 0.88rem;
}

.city-tooltip-content .ct-country {
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem;
}

.city-tooltip-content .ct-pop {
    color: rgba(255,255,255,0.8);
    font-size: 0.75rem;
    margin-top: 2px;
}

.city-tooltip-content .ct-badge {
    display: inline-block;
    background: rgba(212, 160, 23, 0.25);
    color: #ffd54f;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ─── Loading ──────────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gray-50);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 500;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--blue-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 16px;
    color: var(--gray-500);
    font-size: 0.95rem;
}

/* ─── Responsive ───────────────────────────────────────────── */

/* Tablet (≤ 900px) */
@media (max-width: 900px) {
    .features-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 20px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    .modal { width: 95%; max-height: 90vh; }
}

/* Phone (≤ 640px) */
@media (max-width: 640px) {
    /* Hamburger visible */
    .nav-hamburger { display: flex; }

    .nav-links {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(255,255,255,0.97);
        backdrop-filter: blur(12px);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 18px;
        z-index: 1005;
    }
    .nav-links.open {
        display: flex;
    }
    .nav-links .nav-link {
        font-size: 1.2rem;
        padding: 12px 28px;
    }

    .nav-container { height: 56px; }

    /* Modal */
    .modal-grid {
        grid-template-columns: 1fr;
    }
    .modal-header {
        padding: 20px;
    }
    .modal-body {
        padding: 16px 20px 24px;
    }

    /* Hero */
    .hero-content {
        padding: 32px 16px;
    }
    .hero-logo { width: 90px; height: 90px; }

    /* Features */
    .features-section { padding: 60px 16px; }
    .features-grid { grid-template-columns: 1fr; gap: 16px; }

    /* Stats */
    .stats-section { padding: 40px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .stat-item .stat-number { font-size: 2rem; }

    /* CTA */
    .cta-section { padding: 50px 16px; }
}
