
@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Map Custom Controls */
.map-controls {
    position: absolute;
    bottom: 20px;
    left: 20px; /* Moved to left */
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10000; /* High z-index */
    pointer-events: auto; /* Ensure clickable */
}

.map-control-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 1.4rem; /* Slightly larger text */
    padding: 0;
    line-height: 1;
}

.map-control-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--primary-blue);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.map-control-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .map-control-btn {
    background: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .map-control-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--primary-blue-dark);
}

/* Global Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    /* Primitives */
    --primary-blue: #0b63c7;
    --primary-blue-dark: #3b82f6; /* Lighter blue for dark mode visibility */
    --dark-blue: #0a2a57;
    --light-blue-bg: #e6eef8;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --black: #000000;

    /* Semantic Variables (Light Mode Default) */
    --bg-body: var(--light-blue-bg);
    --bg-surface: var(--white);
    --bg-surface-hover: var(--gray-50);
    --bg-surface-alt: var(--gray-100);
    
    --text-main: #1f2a37; /* Keeping legacy name for now, mapping to gray-800 */
    --text-primary: #1f2a37;
    --text-secondary: #4b5563; /* gray-600 */
    --text-tertiary: #9ca3af; /* gray-400 */
    --text-muted: #4b5563; /* Alias for secondary */
    
    --heading-color: var(--dark-blue);
    --accent-color: var(--primary-blue);
    --border-default: #e0e0e0;
    --border-color: #e0e0e0; /* Alias */

    /* Semantic Status Colors */
    --text-success: #16a34a; /* green-600 */
    --text-error: #dc2626; /* red-600 */
    --bg-success-soft: #dcfce7; /* green-100 */
    --bg-error-soft: #fee2e2; /* red-100 */

    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.02);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.04);
    
    /* Map Colors */
    --map-fill-default: #e9edf3;
    --map-fill-0: #86efac; /* Darkened from dcfce7 (lightest green) to 20% step */
    --map-fill-20: #4ade80; /* Shifted up */
    --map-fill-40: #22c55e; /* Shifted up */
    --map-fill-60: #16a34a; /* Darker */
    --map-fill-80: #14532d; /* Darkest green */
    --map-stroke: #ffffff;

    /* Synergy Map Status Colors */
    --status-vf: #20a95a;
    --status-voa: #ffd84d;
    --status-evisa: #f59f1a;
    --status-vr: #e05d4d;
    --status-ar: #000000;
    --status-passports: #9c27b0;
    --status-default: #e9edf3;

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-md: 11px;
    --radius-lg: 14px;
    --transition-speed: 0.25s;
    --row-h: 34px;
    --header-h: 50px;
}

[data-theme="dark"] {
    /* Dark Mode Overrides */
    --bg-body: #0f172a; /* Slate 900 */
    --bg-surface: #1e293b; /* Slate 800 */
    --bg-surface-hover: #334155; /* Slate 700 */
    --bg-surface-alt: #1e293b;

    --text-main: #f1f5f9; /* Slate 100 */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8; /* Slate 400 */
    --text-tertiary: #64748b; /* Slate 500 */
    --text-muted: #94a3b8;

    --heading-color: #f8fafc; /* Slate 50 */
    --accent-color: var(--primary-blue-dark);
    --border-default: #334155; /* Slate 700 */
    --border-color: #334155;

    --btn-primary-bg: var(--primary-blue-dark);
    --btn-primary-hover: var(--primary-blue);
    --text-inverse: #ffffff;

    --bg-row-stripe: #1e293b; /* Slate 800 (same as surface) or slightly different? Maybe surface-hover */
    --bg-row-stripe: rgba(255,255,255,0.02);
    --bg-row-hover: rgba(255,255,255,0.05);

    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.3);

    /* Map Colors Dark - Commented out to match light mode gradation as requested
    --map-fill-default: #334155;
    --map-fill-0: #14532d;
    --map-fill-20: #166534;
    --map-fill-40: #15803d;
    --map-fill-60: #16a34a;
    --map-fill-80: #22c55e;
    --map-stroke: #1e293b; 
    */
    /* Using Light Mode Map Colors for consistency */
    --map-fill-default: #e9edf3;
    --map-fill-0: #dcfce7;
    --map-fill-20: #86efac;
    --map-fill-40: #4ade80;
    --map-fill-60: #22c55e;
    --map-fill-80: #15803d;
    --map-stroke: #1e293b;

    /* Synergy Map Status Colors Dark */
    --status-vf: #22c55e;
    --status-voa: #facc15;
    --status-evisa: #fb923c;
    --status-vr: #f87171;
    --status-ar: #4b5563;
    --status-passports: #c084fc;
    --status-default: #334155;

    --light-blue-bg: rgba(59, 130, 246, 0.15);
}

html {
    font-size: 14px; /* Restore smaller desktop font size as per production */
}

@media (max-width: 768px) {
    html {
        font-size: 16px; /* Keep 16px on mobile for readability and to prevent input zoom */
    }
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-size: 1rem;
    line-height: 1.4;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-speed), transform var(--transition-speed);
}

.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Header */
.site-header {
    background: var(--bg-surface);
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 8px 0;
    height: 60px; /* Fixed height for CLS */
    contain: layout; /* Removed contain: size which might affect sticky behavior or fixed descendants if nested */
    box-sizing: border-box;
    transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
}

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

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--heading-color);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.logo-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.logo-text {
    letter-spacing: 0.08em;
}

.logo .highlight {
    color: var(--accent-color);
    background: rgba(11, 99, 199, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Desktop Navigation */
.desktop-nav {
    display: flex;
    align-items: center;
    gap: 18px; /* Reduced from 24px to prevent wrapping */
}

.nav-link {
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.05rem; /* Increased for better visibility */
    white-space: nowrap; /* Prevent text wrapping */
}

.nav-link:hover, .nav-link.active {
    color: var(--accent-color);
}

.nav-highlight {
    border: 1px solid var(--accent-color);
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--accent-color) !important;
    transition: all 0.2s;
}

.nav-highlight:hover {
    background: var(--bg-body);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 4px;
}

.arrow {
    font-size: 0.7em;
    transition: transform var(--transition-speed);
}

.nav-item-dropdown {
    position: relative;
}

.nav-item-dropdown:hover .arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-surface);
    min-width: 200px;
    box-shadow: var(--shadow-hover);
    border-radius: var(--radius-md);
    padding: 8px 0;
    margin-top: 10px;
    animation: fadeIn 0.2s ease-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    display: block;
    padding: 10px 20px;
    color: var(--text-primary);
    font-size: 1rem;
}

.dropdown-item:hover {
    background: var(--bg-body);
    color: var(--accent-color);
}

/* Language Switch */
.lang-switch {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.lang-switch .active {
    color: var(--heading-color);
}

/* Burger Button */
.burger-btn {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 102;
}

.burger-btn span {
    width: 100%;
    height: 2px;
    background-color: var(--heading-color);
    border-radius: 2px;
    transition: all 0.3s;
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    bottom: 0; /* Cover full height properly on mobile */
    background: var(--bg-surface);
    z-index: 101;
    display: none;
    padding-top: 80px;
    opacity: 0;
    transition: opacity 0.3s;
    overflow-y: auto; /* Allow scrolling if content is too long */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    box-sizing: border-box; /* Include padding in dimensions */
}

.mobile-menu.open {
    display: block;
    opacity: 1;
}

.mobile-menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-bottom: 120px; /* Large padding to ensure bottom content is accessible */
    min-height: 100%; /* Ensure content takes up at least full height */
    box-sizing: border-box;
}

.mobile-link {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--heading-color);
    padding: 10px;
}

.mobile-link-synergy {
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 10px 24px;
    margin: 5px 0;
    color: var(--accent-color);
    background-color: rgba(11, 99, 199, 0.05);
    display: inline-block;
}

.mobile-submenu {
    display: none;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-body);
    width: 100%;
    text-align: center;
    padding: 10px 0;
    margin-top: 5px;
}

.mobile-submenu.open {
    display: flex;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Visually hidden utility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Footer */
.site-footer {
    background: var(--bg-surface);
    color: var(--text-secondary);
    padding: 40px 0;
    margin-top: auto;
    border-top: 1px solid var(--border-default);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
}

.footer-col h4 {
    color: var(--heading-color);
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-col ul li {
    margin-bottom: 10px;
}

.footer-col ul li a {
    color: var(--text-secondary);
    transition: color 0.2s;
}

.footer-col ul li a:hover {
    color: var(--accent-color);
}

.footer-bottom {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-default);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

/* Tooltip (Global) */
.tip {
    position: relative;
    display: inline-flex;
    margin-left: 6px;
    vertical-align: middle;
}

.tip-icon {
    font-size: 0.9em;
    color: var(--text-tertiary);
    cursor: help;
    transition: color 0.2s;
}

.tip:hover .tip-icon {
    color: var(--accent-color);
}

.tip-content {
    position: absolute;
    bottom: auto; /* Default to auto to allow overrides */
    top: calc(100% + 10px); /* Default to below */
    left: 50%;
    transform: translateX(-50%) translateY(4px); /* Animate to 0 */
    background: var(--heading-color);
    color: var(--bg-surface);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 400;
    width: auto;
    min-width: 200px;
    max-width: 370px;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 10000;
    box-shadow: var(--shadow-hover);
    margin-bottom: 0;
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
    border: 1px solid rgba(0,0,0,0.1);
}

.tip-content {
}

@media (min-width: 1024px) {
    .tip-content {
        min-width: 240px;
        max-width: 370px;
    }
}

.tip:hover .tip-content {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.tip-content::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent var(--heading-color) transparent;
}

[data-theme="dark"] .tip-content {
    background-color: #1f2937;
    color: #f1f5f9;
    border: 1px solid #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .tip-content::after {
    border-color: transparent transparent #1f2937 transparent;
}

/* Ensure tooltips work on mobile with touch */
@media (max-width: 768px) {
    .tip:active .tip-content, 
    .tip:focus-within .tip-content {
        opacity: 1;
        visibility: visible;
        transform: translate(-50%, -50%); /* Centered fixed logic if used, or standard positioning */
        pointer-events: auto;
    }
    /* If using fixed centering from previous steps, ensure transform matches */
    .tip-content {
        /* On mobile, we might want fixed positioning for better UX */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80vw;
        max-width: 300px;
        margin: 0;
        z-index: 10001;
    }
    .tip:hover .tip-content {
         transform: translate(-50%, -50%); /* Override hover transform for fixed mobile */
    }
}
.mobile-scroll-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background-color: var(--bg-surface);
    color: var(--heading-color);
    border: 1px solid var(--border-default);
    border-radius: 50%;
    display: none; /* Hidden on desktop */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
}

.mobile-scroll-top-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
    width: 40px; /* Increased from 32px */
    height: 40px; /* Increased from 32px */
}

[data-theme="dark"] .theme-toggle {
    color: var(--text-main);
}

[data-theme="dark"] .theme-toggle:hover {
    background-color: #374151;
}

[data-theme="dark"] .mobile-scroll-top-btn {
    background-color: #1f2937;
    color: #f1f5f9;
    border-color: #374151;
}

[data-theme="dark"] .mobile-scroll-top-btn:hover {
    background-color: #374151;
}

.theme-toggle:hover {
    color: var(--heading-color);
    background-color: var(--bg-body);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Responsive */
@media (max-width: 768px) {
    .desktop-nav {
        display: none;
    }
    
    .burger-btn {
        display: flex;
    }

    .container {
        padding: 0 16px;
    }

    .mobile-scroll-top-btn {
        display: flex; /* Visible in DOM on mobile, controlled by opacity */
    }
}

/* Desktop Header Centering */
@media (min-width: 769px) {
    /* 1. Standard Section Titles */
    .section-title {
        text-align: center;
        width: 100%;
    }

    /* 2. About Page Headers */
    .about-block h3 {
        text-align: center;
    }

    /* 3. Flex Container Headers (Regions, Compare) */
    .section-header-row,
    .compare-header-row {
        justify-content: center !important;
        position: relative;
    }

    /* 4. Absolute positioning for right-side elements (Badges, Buttons) */
    .section-header-row .region-stat-badge,
    .compare-header-row .share-btn {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        margin: 0;
    }

    /* 5. Ensure Titles inside Flex Containers are centered and don't overlap */
    .section-header-row .section-title,
    .compare-header-row .section-title {
        max-width: 70%;
        margin: 0 auto;
        text-align: center;
    }

    /* Exception: Synergy Partner Pages - Keep Left Aligned */
    .synergy-header-group .section-title {
        text-align: left;
    }
}

/* =========================================
   Passport Tier Badges (Global)
   ========================================= */

/* Tier 1: Best (Rank 0-20% percentile) - Green */
.passport-tier-1 {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Tier 2: Good (20-40%) - Light Green */
.passport-tier-2 {
    background-color: #ecfccb;
    color: #3f6212;
    border: 1px solid #d9f99d;
}

/* Tier 3: Average (40-60%) - Yellow */
.passport-tier-3 {
    background-color: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde047;
}

/* Tier 4: Below Average (60-80%) - Orange */
.passport-tier-4 {
    background-color: #ffedd5;
    color: #9a3412;
    border: 1px solid #fdba74;
}

/* Tier 5: Worst (80-100%) - Red */
.passport-tier-5 {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Dark Mode Overrides for Tiers */
[data-theme="dark"] .passport-tier-1 {
    background-color: rgba(6, 78, 59, 0.4);
    color: #6ee7b7;
    border-color: #065f46;
}

[data-theme="dark"] .passport-tier-2 {
    background-color: rgba(54, 83, 20, 0.4);
    color: #bef264;
    border-color: #3f6212;
}

[data-theme="dark"] .passport-tier-3 {
    background-color: rgba(113, 63, 18, 0.4);
    color: #fde047;
    border-color: #854d0e;
}

[data-theme="dark"] .passport-tier-4 {
    background-color: rgba(124, 45, 18, 0.4);
    color: #fdba74;
    border-color: #9a3412;
}

[data-theme="dark"] .passport-tier-5 {
    background-color: rgba(127, 29, 29, 0.4);
    color: #fca5a5;
    border-color: #991b1b;
}

.passport-tier-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 4px; /* Consistent radius */
    font-weight: 600;
    font-size: 0.9rem; /* Slightly larger for readability in tables */
}
