/* ========================================
   ENHANCED NPC PAGE STYLES (FINAL REV.)
   ======================================== */

/* --- CRITICAL FIXES & DEFAULTS --- */
body {
    color: #e0e0e0; /* Default light text color for the entire page */
}

.page-title, .section-title, .subsection-title, .npc-name, #modal-name {
    color: #ffffff !important; /* Ensure all titles are bright white */
}

.npc-role, .npc-location, .detail-label, .key-label, .stat-badge, .city-btn, .collapse-all-btn, .count {
    color: #a0a0a0 !important; /* Consistent light grey for secondary text */
}

.city-btn.active, .city-btn:hover, .collapse-all-btn:hover {
    color: #ffffff !important;
}


/* --- STICKY HEADER FIX --- */
/* This makes the main navigation bar stick to the top */
.main-nav {
    position: sticky !important;
    top: 0;
    z-index: 101; /* Higher z-index to stay on top */
}

/* This makes the city filter bar stick right below the main nav */
.city-nav {
    position: sticky !important;
    top: 60px; /* Adjust this value if your main-nav height is different */
    z-index: 100;
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
    padding: 20px;
    background: #1a1a1a;
    border-top: 1px solid #404040;
    border-bottom: 1px solid #404040;
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.npc-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.stat-badge {
    padding: 8px 20px;
    background: #2d2d2d;
    border: 1px solid #404040;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-badge.major { border-color: #c41e3a; color: #c41e3a !important; }
.stat-badge.secondary { border-color: #4a9eff; color: #4a9eff !important; }


/* City Filter Buttons */
.city-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 25px;
    background: #2d2d2d;
    border: 1px solid #404040;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: background 0.3s, color 0.3s, transform 0.2s;
}

.city-btn:hover {
    background: #404040;
    transform: translateY(-2px);
}

.city-btn.active {
    background: #c41e3a;
    border-color: #c41e3a;
}

.btn-icon { font-size: 1.2rem; }

/* City Sections */
.city-section {
    margin-bottom: 50px;
    background: rgba(26, 26, 26, 0.5);
    border: 1px solid #404040;
    transition: opacity 0.3s;
}

.city-section.hidden { display: none; }

/* --- REFINED SMOOTH COLLAPSIBLE SECTIONS --- */
.section-header {
    display: flex;
    align-items: center;
    padding: 20px;
    background: #2d2d2d;
    cursor: pointer;
    user-select: none;
    position: relative;
    border-bottom: 1px solid #404040;
    transition: background-color 0.3s;
}

.section-header:hover { background: #353535; }

.collapse-icon {
    font-size: 1.2rem;
    margin-right: 15px;
    color: #c41e3a !important;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Icon rotation for collapsed/expanded states */
.section-header.collapsed .collapse-icon { transform: rotate(-90deg); }
.section-header.expanded .collapse-icon { transform: rotate(0deg); }

.section-title {
    flex-grow: 1; /* Allow title to take up remaining space */
    display: flex;
    align-items: center;
    gap: 15px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    margin: 0;
    text-transform: uppercase;
}

.title-icon { color: #c41e3a; font-size: 1.8rem; }

.collapse-all-btn {
    margin-left: auto;
    padding: 8px 20px;
    background: #404040;
    border: 1px solid #606060;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s;
}

.collapse-all-btn:hover {
    background: #c41e3a;
    border-color: #c41e3a;
}

/* The core of the smooth collapse fix */
.section-content {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transition: max-height 0.7s ease, padding 0.5s ease, opacity 0.5s ease;
}

.section-header.expanded + .section-content {
    max-height: 5000px; /* Large enough to fit any content */
    opacity: 1;
    padding-top: 30px;
    padding-bottom: 30px;
}

.section-content-inner { /* A wrapper div inside section-content */
    padding-left: 30px;
    padding-right: 30px;
}

/* Subsections & NPC Cards */
.subsection { margin-bottom: 40px; }
.subsection:last-child { margin-bottom: 0; }

.subsection-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #404040;
}

.sub-icon { color: #808080; font-size: 1.3rem; }

.npc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.npc-card {
    background: #252525;
    border: 1px solid #404040;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    overflow: hidden;
}

.npc-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(196, 30, 58, 0.3);
    border-color: #c41e3a;
}

.npc-portrait {
    height: 180px;
    position: relative;
    background: #1a1a1a;
}

.npc-portrait img { width: 100%; height: 100%; object-fit: cover; }

.portrait-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    color: #404040;
}

.npc-importance {
    position: absolute; top: 5px; right: 5px; width: 15px; height: 15px;
    border-radius: 50%; border: 2px solid #1a1a1a;
}
.npc-importance.major { background-color: #c41e3a; }
.npc-importance.secondary { background-color: #4a9eff; }

.npc-info { padding: 15px; text-align: center; }
.npc-name { font-weight: bold; }
.npc-role { font-size: 0.85rem; margin-top: 5px; }
.npc-location { font-size: 0.75rem; margin-top: 5px; text-transform: uppercase; }

/* --- SMOOTH MODAL ANIMATION --- */
.npc-modal {
    display: flex; /* Use flex for centering */
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    
    /* Animation state: HIDDEN */
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: opacity 0.3s ease, visibility 0.3s, transform 0.3s ease;
}

.npc-modal.active {
    /* Animation state: VISIBLE */
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.modal-content {
    position: relative;
    background: #1e1e1e;
    border: 1px solid #404040;
    width: 90%;
    max-width: 900px;
}

.modal-close {
    position: absolute; top: 15px; right: 25px; color: #aaa;
    font-size: 28px; font-weight: bold; cursor: pointer;
}
.modal-close:hover { color: #fff; }

.modal-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    padding: 40px;
}

.modal-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border: 1px solid #404040;
}

#modal-name { font-size: 2rem; font-family: 'Orbitron', sans-serif; margin-bottom: 15px; }
.modal-keywords { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.keyword-badge { padding: 5px 10px; font-size: 0.8rem; border: 1px solid; }
.keyword-badge.primary { border-color: #c41e3a; }
.keyword-badge.secondary { border-color: #4a9eff; }
.key-value { color: #e0e0e0; }
.modal-details { margin-bottom: 20px; }
.detail-item { display: flex; padding: 8px 0; border-bottom: 1px solid #333; }
.detail-item:last-child { border-bottom: none; }
.detail-label { width: 100px; font-weight: bold; }
.detail-value { flex: 1; }
.modal-description p { line-height: 1.6; color: #c0c0c0; }

/* Responsive */
@media (max-width: 768px) {
    .city-nav { flex-wrap: wrap; }
    .city-btn { flex-basis: 45%; }
    .modal-grid { grid-template-columns: 1fr; text-align: center; }
    .modal-image { max-width: 250px; margin: 0 auto 20px; }
    .detail-item { flex-direction: column; align-items: center; }
    .detail-label { width: auto; margin-bottom: 5px; }
}