/* MODERN INSTITUTIONAL REPOSITORY STYLE V3 STABLE - MOBILE FIRST */
:root {
    /* Color Palette - Deeper and more professional (Recovered from V2) */
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-gradient: radial-gradient(circle at top right, #1e293b 0%, #0f172a 100%);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.4);
    --accent-subtle: rgba(56, 189, 248, 0.1);

    --border-light: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(56, 189, 248, 0.2);

    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-heavy: rgba(15, 23, 42, 0.85);

    --container: 1280px;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 20px 50px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    outline: none;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-dark);
    /* Fallback */
    background-image: var(--bg-gradient);
    /* Richer V2 background */
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
}

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

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

/* LAYOUT & CONTAINER */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* SECTION HEADERS (Restored from V2) */
.section-header {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 50px;
    position: relative;
}

.section-header h2 {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 16px;
}

.section-accent {
    width: 60px;
    height: 4px;
    background: var(--accent);
    margin: 0 auto 20px;
    border-radius: 4px;
    box-shadow: 0 0 15px var(--accent-glow);
}

/* HEADER NAVIGATION */
header {
    border-bottom: 1px solid var(--border-light);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.logo {
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    display: flex;
    align-items: center;
}

.badge {
    background: var(--accent-subtle);
    color: var(--accent);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-left: 10px;
    font-weight: 600;
    border: 1px solid var(--border-accent);
}

nav a {
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: 25px;
    font-weight: 500;
}

nav a:hover {
    color: #fff;
}

.logo-area {
    display: flex;
    align-items: center;
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background: #fff;
    margin: 5px 0;
}

@media (max-width: 768px) {
    nav {
        display: none;
        position: fixed;
        top: 70px;
        left: 0;
        width: 100%;
        height: calc(100vh - 70px);
        background: var(--bg-dark);
        flex-direction: column;
        padding: 20px;
        border-top: 1px solid var(--border-light);
    }

    nav.active {
        display: flex;
    }

    nav a {
        margin: 0 0 20px 0;
        font-size: 18px;
    }

    .menu-toggle {
        display: block;
    }
}

/* --- HERO & HOMEPAGE STYLES (Enriched V2) --- */
.hero {
    text-align: center;
    padding: 80px 0 60px;
}

.hero h1 {
    font-size: clamp(36px, 5vw, 56px);
    font-weight: 800;
    letter-spacing: -2px;
    margin-bottom: 20px;
    line-height: 1.1;
}

.hero p {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto 40px;
    line-height: 1.6;
}

.text-gradient {
    background: linear-gradient(to right, #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* STATS - GRID LAYOUT (Restored from V2 for stability) */
.stat-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 60px;
}

@media (min-width: 600px) {
    .stat-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1024px) {
    .stat-container {
        grid-template-columns: repeat(4, 1fr);
        margin-bottom: 80px;
    }
}

.stat-item {
    padding: 25px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px solid var(--border-light);
    text-align: center;
    transition: var(--transition);
}

.stat-item:hover {
    background: var(--glass-bg);
    border-color: var(--accent-subtle);
    transform: scale(1.02);
}

.stat-item .value {
    font-size: clamp(32px, 6vw, 40px);
    font-weight: 800;
    color: #fff;
    line-height: 1;
    margin-bottom: 8px;
}

.stat-item .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* FEATURED GRID (Restored from V2) */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 80px;
}

@media (min-width: 600px) {
    .featured-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

@media (min-width: 900px) {
    .featured-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.country-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 25px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.country-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(56, 189, 248, 0.15);
}

.country-card .flag {
    font-size: 32px;
    margin-bottom: 15px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.country-card h4 {
    font-size: 16px;
    color: #fff;
    margin: 0 0 5px;
    font-weight: 600;
}

.country-card .meta {
    font-size: 10px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    opacity: 0.8;
}

/* --- SEARCH COMPONENT (Restored V2 + Fixes) --- */
.search-wrapper {
    position: relative;
    max-width: 650px;
    margin: 0 auto;
    z-index: 1100;
}

.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-group input {
    width: 100%;
    padding: 16px 20px;
    padding-left: 52px;
    background: var(--glass-heavy);
    /* Restored V2 heavy glass */
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    color: #fff;
    font-size: 16px;
    transition: var(--transition);
    outline: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.search-input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.2), 0 15px 45px rgba(0, 0, 0, 0.4);
    background: var(--bg-card);
}

.search-icon {
    position: absolute;
    left: 20px;
    color: var(--accent);
    pointer-events: none;
    font-size: 18px;
    opacity: 0.8;
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-premium);
    display: none;
    z-index: 9999;
    /* CRITICAL FIX */
    backdrop-filter: blur(20px);
}

.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    text-decoration: none;
    color: #fff;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border-light);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--accent-subtle);
    padding-left: 25px;
}

.suggestion-item .main-text {
    font-size: 14px;
    font-weight: 600;
}

.suggestion-item .sub-text {
    font-size: 12px;
    color: var(--text-muted);
}

.suggestion-item .type-tag {
    font-size: 10px;
    text-transform: uppercase;
    background: var(--accent-subtle);
    padding: 3px 8px;
    border-radius: 20px;
    color: var(--accent);
    font-weight: 700;
    border: 1px solid var(--border-accent);
}

.search-how-to {
    margin-top: 15px;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.search-how-to b {
    color: var(--accent);
    font-weight: 600;
}


/* --- COUNTRY PAGE & CARDS --- */

/* SINGLE COLUMN LAYOUT OVERRIDE (For User Preference) */
.layout-main {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 30px;
}

.column-a,
.column-b {
    width: 100%;
}

.section-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: clamp(20px, 4vw, 30px);
    margin-bottom: 30px;
    box-shadow: var(--shadow-premium);
}

.section-card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-card h2 svg,
.section-card h2 i {
    color: var(--accent);
}


/* Region Grid Sortable */
.subdivision-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.subdivision-item {
    background: var(--glass-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    text-decoration: none;
    transition: all 0.2s ease;
}

.subdivision-item:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    transform: translateX(5px);
}

.subdivision-item span:first-child {
    font-weight: 600;
    font-size: 14px;
}

.subdivision-item .count {
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Sort Controls */
.sort-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.sort-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: var(--transition);
}

.sort-btn.active,
.sort-btn:hover {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}

/* Buttons */
.btn-dl-premium,
.btn-dl-outline,
.btn-dl {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 15px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    cursor: pointer;
    gap: 8px;
}

.btn-dl-premium,
.btn-dl {
    background: var(--accent);
    color: #000;
    border: none;
}

.btn-dl-premium:hover,
.btn-dl:hover {
    box-shadow: 0 5px 15px rgba(56, 189, 248, 0.4);
    transform: translateY(-2px);
}

.btn-dl-outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: #fff;
}

.btn-dl-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #fff;
}

/* FAQS */
.faq-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.faq-item {
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    transition: var(--transition);
}

.faq-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--accent-subtle);
}

.faq-item h3 {
    font-size: 15px;
    margin-bottom: 10px;
    color: #fff;
    font-weight: 600;
}

.faq-item p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.faq-item a {
    color: var(--accent);
    border-bottom: 1px dotted var(--accent);
}

.faq-item a:hover {
    border-bottom-style: solid;
}

/* UTILS - V2 had dividers and specific classes */
.divider {
    height: 1px;
    background: var(--border-light);
    margin: 25px 0;
}

/* --- FOOTER --- */
footer {
    border-top: 1px solid var(--border-light);
    padding: 80px 0 40px;
    margin-top: 80px;
    background: rgba(5, 5, 5, 0.3);
}

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

.footer-grid h4 {
    color: #fff;
    margin-bottom: 25px;
    font-size: 16px;
    font-weight: 700;
}

.footer-grid a {
    display: block;
    margin-bottom: 12px;
    color: var(--text-secondary);
    transition: color 0.2s;
    font-size: 14px;
}

.footer-grid a:hover {
    color: var(--accent);
}

.footer-bottom {
    text-align: center;
    border-top: 1px solid var(--border-light);
    padding-top: 30px;
    color: var(--text-muted);
    font-size: 13px;
}

.footer-country-switcher {
    border-top: 1px solid var(--border-light);
    padding-top: 32px;
    margin-bottom: 30px;
}

.footer-country-switcher-head {
    text-align: center;
    margin-bottom: 18px;
}

.footer-country-switcher-head h4 {
    color: #fff;
    font-size: 17px;
    margin-bottom: 8px;
}

.footer-country-switcher-head p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

.footer-country-flags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.country-flag-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
    font-size: 12px;
}

.country-flag-pill:hover {
    color: #fff;
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.08);
    transform: translateY(-1px);
}

.country-flag-pill.is-active {
    color: #fff;
    border-color: rgba(56, 189, 248, 0.55);
    background: rgba(56, 189, 248, 0.12);
    box-shadow: 0 8px 20px rgba(56, 189, 248, 0.14);
}

.country-flag-pill-emoji {
    font-size: 17px;
    line-height: 1;
}

.country-flag-pill-text {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.language-switcher {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.language-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.language-pill:hover {
    color: #fff;
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.08);
    transform: translateY(-1px);
}

.language-pill.is-active {
    color: #fff;
    border-color: rgba(56, 189, 248, 0.55);
    background: rgba(56, 189, 248, 0.12);
    box-shadow: 0 10px 24px rgba(56, 189, 248, 0.14);
}

.language-pill-emoji {
    font-size: 18px;
    line-height: 1;
}

.language-pill-text {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ORBS & DECORATION (Restored) */
.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.3;
}

.orb-1 {
    top: -150px;
    left: -150px;
    width: 600px;
    height: 600px;
    background: var(--accent);
}

.orb-2 {
    bottom: -150px;
    right: -150px;
    width: 700px;
    height: 700px;
    background: #4f46e5;
}

/* Mission Block Special */
.registry-card {
    border-radius: 24px;
    border: 1px solid var(--border-light);
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.05) 0%, transparent 70%), var(--bg-card);
}

/* MODAL SYSTEM (Restored) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-container {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    width: 100%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-premium);
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
}

.modal-body {
    overflow-y: auto;
    padding: 20px;
}

.spec-table {
    width: 100%;
    border-collapse: collapse;
}

.spec-table th,
.spec-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

.spec-table th {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.btn-full-preview {
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 15px;
    cursor: pointer;
    font-weight: 600;
}

/* --- HORIZONTAL TOC & NAVIGATION --- */
.nav-toc {
    position: sticky;
    top: 71px;
    /* Just below header */
    background: var(--glass-heavy);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-light);
    z-index: 900;
    margin: 30px -20px;
    /* Space above and below */
    padding: 10px 0;
}

.nav-toc-inner {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 20px;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
}

.nav-toc-inner::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.nav-toc-item {
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: var(--transition);
}

.nav-toc-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.nav-toc-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--border-accent);
}

/* --- REFINED SUBDIVISION CARDS (The "Beautiful Windows") --- */
.subdivision-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    text-decoration: none;
    color: var(--text-primary);
}

.subdivision-card:hover {
    background: var(--glass-bg);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.subdivision-card span:first-child {
    font-weight: 600;
    font-size: 15px;
}

.subdivision-card .badge-count {
    font-size: 11px;
    color: var(--accent);
    background: var(--accent-subtle);
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    border: 1px solid var(--border-accent);
}

.subdivision-card code {
    color: var(--accent);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}
