/* ==========================================================================
   GLOBAL RESET & STYLING (Premium Dark Slate Theme)
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    /* Custom scroll behavior restored for portfolio narrative */
}

/* Scrollbar customizations */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #050A14;
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */
.app-container {
    display: flex;
    width: 100%;
    height: 720px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    background-color: #050A14;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

/* Sidebar Controls */
.sidebar {
    width: 380px;
    background: linear-gradient(180deg, #0f172a 0%, #090d16 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
    flex-shrink: 0;
    gap: 20px;
}

/* Main Dashboard Panel */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #0b0f19;
    height: 100%;
    overflow: hidden;
}

/* ==========================================================================
   SIDEBAR COMPONENTS
   ========================================================================== */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #334155;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.brand-logo-3d {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
    background: transparent;
    flex-shrink: 0;
}

.brand h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #f8fafc 30%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand .subtitle {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Cards & Panels */
.panel {
    background: rgba(30, 41, 59, 0.45); /* Glassmorphic Slate */
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
    border-color: rgba(56, 189, 248, 0.15);
    box-shadow: 0 8px 32px rgba(56, 189, 248, 0.05);
}

.panel h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 16px;
    letter-spacing: -0.2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

/* Form Controls */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    position: relative;
}

.control-group label {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group input[type="text"] {
    background-color: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 14px;
    color: #f8fafc;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.control-group input[type="text"]:focus {
    outline: none;
    border-color: #38bdf8;
    background-color: rgba(15, 23, 42, 0.85);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

/* Dropdown Results list */
.search-results-dropdown {
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 4px;
}

.search-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 8px;
    transition: all 0.2s ease;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.search-item:last-child {
    margin-bottom: 0;
}

.search-item:hover {
    background-color: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
}

.search-item .search-type {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.search-type.cns {
    background-color: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
}

.search-type.pub {
    background-color: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
}

/* Slider Controls */
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.2);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #1e293b;
    outline: none;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #38bdf8;
    cursor: pointer;
    border: 2px solid #0f172a;
    box-shadow: 0 0 0 0px rgba(56, 189, 248, 0);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease, background-color 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
    background: #56c8fc;
}

input[type="range"]::-moz-range-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #1e293b;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

input[type="range"]::-moz-range-thumb {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    background: #38bdf8;
    cursor: pointer;
    border: 2px solid #0f172a;
    box-shadow: 0 0 0 0px rgba(56, 189, 248, 0);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.3);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
    background: #56c8fc;
}

input[type="range"]::-moz-range-progress {
    background-color: #38bdf8;
    height: 4px;
    border-radius: 2px;
}

.control-help {
    font-size: 10.5px;
    color: #64748b;
    font-style: italic;
    margin-top: 4px;
}

/* Custom Switch Toggle styling */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 20px;
    flex-shrink: 0;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: #94a3b8;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.switch-toggle input:checked + .switch-slider {
    background-color: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.4);
}

.switch-toggle input:checked + .switch-slider:before {
    background-color: #38bdf8;
    transform: translateX(22px);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}

/* Mini Switch Variation */
.mini-switch {
    width: 32px;
    height: 16px;
}

.mini-switch .switch-slider {
    border-radius: 16px;
}

.mini-switch .switch-slider:before {
    height: 10px;
    width: 10px;
    left: 2px;
    bottom: 2px;
}

.mini-switch input:checked + .switch-slider:before {
    transform: translateX(16px);
}

/* Checkbox Toggle Group Layout */
.switch-group {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 4px 0;
}

.checkbox-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.btn-secondary {
    background: rgba(51, 65, 85, 0.3);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.4);
    color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

/* ==========================================================================
   INFO DYNAMIC PANEL
   ========================================================================== */
.info-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto;
    border-color: #334155;
}

.info-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    color: #64748b;
    gap: 12px;
}

.placeholder-icon {
    stroke: #475569;
}

.info-placeholder p {
    font-size: 12px;
    line-height: 1.6;
}

/* Dynamic Details Content */
.info-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-content h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.3px;
}

.tag-row {
    display: flex;
    gap: 8px;
    margin-top: -8px;
}

.badge-type {
    background-color: #334155;
    text-transform: uppercase;
}

.badge-jesuit {
    background-color: #f59e0b; /* Amber 500 */
    color: #0f172a;
    text-transform: uppercase;
}

.info-section {
    border-top: 1px solid #334155;
    padding-top: 12px;
}

.info-section h4 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.heading-icon {
    flex-shrink: 0;
    color: #38bdf8;
    opacity: 0.8;
}

.info-section p {
    font-size: 12.5px;
    color: #cbd5e1; /* Slate 300 */
    line-height: 1.5;
}

.gnd-link {
    font-size: 12.5px;
    color: #38bdf8;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.gnd-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   NAVIGATION TAB BAR (Segmented Pill Controller)
   ========================================================================== */
.tabs-bar {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 30px;
    margin: 16px 24px;
    width: fit-content;
    gap: 4px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.tab-button {
    background: none;
    border: none;
    color: #94a3b8;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 25px;
    position: relative;
}

.tab-button:hover {
    color: #f1f5f9;
    background-color: rgba(255, 255, 255, 0.03);
}

.tab-button.active {
    color: #38bdf8;
    background-color: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

.tabs-nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding-right: 24px;
}

/* Tab display toggles */
.tab-container {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

.tab-content {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.tab-content.active {
    display: block;
}

/* ==========================================================================
   TAB 1: D3 INTERACTIVE NETWORK GRAPH
   ========================================================================== */
.viz-container {
    width: 100%;
    height: 100%;
    position: relative;
    outline: none;
}

#network-svg {
    display: block;
    cursor: grab;
}

#network-svg:active {
    cursor: grabbing;
}

/* Network Legend overlay styling */
.network-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(30, 41, 59, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
    gap: 10px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.color-censor {
    background-color: #38bdf8;
}

.color-jesuit {
    background-color: #fbbf24;
    border: 1.5px solid #ffffff;
}

.color-pub {
    background-color: #f43f5e;
}

.legend-line {
    width: 20px;
    height: 2px;
    background-color: rgba(248, 250, 252, 0.3);
    display: inline-block;
}

/* D3 Graph elements */
.node {
    stroke-width: 0.5px;
    stroke: #0f172a;
    cursor: pointer;
    transition: stroke-width 0.15s ease, filter 0.15s ease;
}

.node:hover {
    stroke-width: 2px;
    stroke: #ffffff;
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.4));
}

.node.selected {
    stroke-width: 2.5px;
    stroke: #ffffff;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.6));
}

.link {
    stroke: #334155;
    stroke-opacity: 0.35;
    pointer-events: none;
    transition: stroke 0.15s ease, stroke-opacity 0.15s ease;
}

.link.highlighted {
    stroke-opacity: 0.95;
    stroke-dasharray: 6, 8;
    stroke-dashoffset: 0;
    animation: flow-dash 1.5s linear infinite;
}

.node-label {
    fill: #f8fafc;
    font-size: 7.5px;
    font-family: inherit;
    font-weight: bold;
    pointer-events: none;
}

/* ==========================================================================
   TAB 2: LEAFLET SPATIAL MAP
   ========================================================================== */
#map-container {
    background-color: #0b0f19;
}

/* Custom dark theme adjustments for Leaflet container */
.leaflet-container {
    background-color: #0f172a !important;
}

/* Map Header controls overlays */
.map-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    background: rgba(30, 41, 59, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px 20px;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.map-controls .slider-container {
    flex-grow: 2;
}

.slider-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-title {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.map-play-btn {
    background-color: #38bdf8;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 24px;
}

.map-play-btn:hover {
    background-color: #0ea5e9;
    transform: translateY(-1px);
}

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

.map-play-btn.playing {
    background-color: #f43f5e;
    color: #ffffff;
}

.map-volume-container {
    flex-grow: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 9px;
    color: #64748b;
}

.map-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    border-left: 1px solid #334155;
    padding-left: 16px;
}

.legend-title {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-filters {
    display: flex;
    gap: 12px;
}

.filter-label {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #94a3b8;
    transition: color 0.15s ease;
}

.filter-label:hover {
    color: #cbd5e1;
}

.filter-label input[type="checkbox"] {
    accent-color: #38bdf8;
    width: 13px;
    height: 13px;
    cursor: pointer;
}

.color-catholic-hub {
    background-color: #d4af37;
}

.color-protestant-hub {
    background-color: #5b21b6;
}

.color-mixed-hub {
    background-color: #94a3b8;
}

/* Pulsing markers animation for large hubs */
@keyframes marker-pulse {
    0% {
        stroke-width: 1px;
        stroke-opacity: 0.7;
    }
    50% {
        stroke-width: 3.5px;
        stroke-opacity: 1;
        stroke: #ffffff;
    }
    100% {
        stroke-width: 1px;
        stroke-opacity: 0.7;
    }
}

.pulse-marker {
    animation: marker-pulse 2s infinite ease-in-out;
}

/* Custom leaflet tooltip styling */
.leaflet-tooltip {
    background-color: #1e293b !important;
    border: 1px solid #475569 !important;
    color: #f8fafc !important;
    font-family: inherit;
    font-size: 11px;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    padding: 6px 10px !important;
}

/* ==========================================================================
   TAB 3: TREND TIMELINES
   ========================================================================== */
#timeline-tab {
    overflow-y: auto;
    padding: 24px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

@media(min-width: 900px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }
    .chart-card:first-child {
        grid-column: span 2;
    }
}

.chart-card {
    background: rgba(30, 41, 59, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.chart-card:hover {
    border-color: rgba(56, 189, 248, 0.15);
    box-shadow: 0 8px 32px rgba(56, 189, 248, 0.05);
}

.chart-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 4px;
}

.chart-desc {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 20px;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
}

/* ==========================================================================
   LOADING SPINNERS & SYSTEM ELEMENTS
   ========================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background-color: #0b0f19;
    background-image: url('assets/branding/grey_parchment.jpg');
    background-size: cover;
    background-blend-mode: multiply;
    opacity: 0.98;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.loading-title {
    font-family: 'UnifrakturMaguntia', serif;
    font-size: 32px;
    color: #e2e8f0;
    margin: 8px 0 4px 0;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
    letter-spacing: 1px;
    text-align: center;
}

.loading-desc {
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    color: #94a3b8;
    font-style: italic;
    margin: 0;
    text-align: center;
}

.loading-ink-splatter {
    position: absolute;
    width: 180px;
    height: 180px;
    background-image: url('assets/UI/ink_splatter.jpg');
    background-size: contain;
    background-repeat: no-repeat;
    mix-blend-mode: multiply;
    opacity: 0.35;
    pointer-events: none;
    z-index: 101;
}

.loading-ink-splatter.top-left {
    top: -10px;
    left: -10px;
}

.loading-ink-splatter.bottom-right {
    bottom: -10px;
    right: -10px;
    transform: rotate(180deg);
}

.loader-3d-model {
    z-index: 102;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
}

.spinner {
    width: 48px;
    height: 48px;
    background-image: url('assets/UI/loading_spinner.jpg');
    background-size: cover;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.6)) grayscale(0.5);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Geographic flow polylines animation */
@keyframes flow-dash {
    to {
        stroke-dashoffset: -40;
    }
}

.flow-polyline {
    stroke-dashoffset: 0;
    animation: flow-dash 2s linear infinite;
    filter: drop-shadow(0 0 3px rgba(0,0,0,0.5));
}

/* Neon glow classes for active city markers (Option 1) */
.glow-growth {
    filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.85));
}

.glow-decline {
    filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.85));
}

.glow-neutral {
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.45));
}

/* Faint neon glow for previous decade comparison rings */
.prev-marker-glow-growth {
    filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.7));
}

.prev-marker-glow-decline {
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.7));
}

/* Sidebar city and actor timeline chart styling */
.city-chart-wrapper,
.actor-chart-wrapper {
    position: relative;
    height: 130px;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 5px;
    background-color: rgba(15, 23, 42, 0.4);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px;
}

/* Custom Leaflet divIcon Map Marker (Circular Images) */
.custom-map-marker {
    background: transparent !important;
    border: none !important;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                margin-left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                margin-top 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.4s ease;
}

.custom-map-marker-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

.marker-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1.5px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    overflow: hidden; /* crop image to circle */
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease, border-color 0.2s ease;
}

/* Connect the neon glows to the custom wrapper */
.glow-growth .marker-image-wrapper {
    filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.85));
    border-color: #10b981;
}

.glow-decline .marker-image-wrapper {
    filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.85));
    border-color: #ef4444;
}

.glow-neutral .marker-image-wrapper {
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.45));
    border-color: #ffffff;
}

/* Hover effects for custom markers */
.custom-map-marker-wrapper:hover .marker-image-wrapper {
    transform: scale(1.22);
}
.glow-growth:hover .marker-image-wrapper {
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 1.0));
    border-width: 2px;
}
.glow-decline:hover .marker-image-wrapper {
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 1.0));
    border-width: 2px;
}
.glow-neutral:hover .marker-image-wrapper {
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.8));
    border-width: 1.5px;
}

/* Dynamic Sidebar City woodcut visual blending */
.sidebar-city-image {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    filter: grayscale(1) contrast(1.1) brightness(0.85);
    mix-blend-mode: screen;
    opacity: 0.95;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: border-color 0.3s ease;
}
.sidebar-city-image:hover {
    border-color: rgba(56, 189, 248, 0.3);
}

/* Custom prev decade HTML marker ring */
.custom-prev-ring {
    background: transparent !important;
    border: none !important;
    pointer-events: none;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                margin-left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                margin-top 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.4s ease;
}

#section-3d {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.sidebar-3d-model {
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
}

.prev-decade-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: transparent;
    box-sizing: border-box;
    pointer-events: none;
}

.prev-ring-growth {
    border: 2px dashed #10b981;
    filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.8));
}

.prev-ring-decline {
    border: 2px dashed #ef4444;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.8));
}

/* Floating HTML tooltip for Bipartite Network */
.network-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 11.5px;
    color: #cbd5e1;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 2000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* SVG Node glow filter styling using SVG url filters */
.node.cns-glow {
    filter: url(#glow-censor);
}
.node.pub-glow {
    filter: url(#glow-publisher);
}
.node.jes-glow {
    filter: url(#glow-jesuit);
}

/* Connections List in Sidebar details */
.connections-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom Scrollbar for connections list */
.connections-list::-webkit-scrollbar {
    width: 4px;
}
.connections-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
.connections-list::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.3);
    border-radius: 2px;
}

.connection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    padding: 6px 8px;
    background: rgba(30, 41, 59, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    color: #e2e8f0;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.connection-item:hover {
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(56, 189, 248, 0.2);
}

.connection-partner {
    font-weight: 500;
}

.connection-city {
    color: #94a3b8;
    font-style: italic;
    margin-left: 4px;
}

.connection-weight {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.connection-item.low-weight-link {
    opacity: 0.55;
    background: rgba(15, 23, 42, 0.2);
}

.connection-item.low-weight-link .connection-weight {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

/* ==========================================================================
   TAB 4: ABOUT THE TEAM (COIN CABINET)
   ========================================================================== */
#info-tab {
    overflow-y: auto;
    padding: 24px;
}

.cabinet-header {
    text-align: center;
    max-width: 700px;
    margin: 0 auto 30px auto;
}

.cabinet-title {
    font-family: 'UnifrakturMaguntia', serif;
    font-size: 36px;
    color: #f8fafc;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
    letter-spacing: 0.5px;
}

.cabinet-desc {
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    color: #94a3b8;
    font-style: italic;
    line-height: 1.5;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 40px;
}

.team-card {
    background: rgba(30, 41, 59, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: visible; /* changed from hidden to allow 3D coin flip translation outside bounds */
    perspective: 1000px; /* added for 3D flip depth */
}

.team-card:hover {
    border-color: rgba(56, 189, 248, 0.25);
    box-shadow: 0 12px 40px rgba(56, 189, 248, 0.08);
    transform: translateY(-4px);
}

.coin-viewer-wrapper {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
    cursor: pointer;
    transform-style: preserve-3d;
}

.coin-viewer-wrapper:hover {
    transform: scale(1.05);
}

.coin-viewer-wrapper.flipping {
    animation: coin-flip-anim 1.0s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes coin-flip-anim {
    0% {
        transform: translateY(0) rotateX(0deg) scale(1);
        z-index: 1;
    }
    1% {
        z-index: 10;
    }
    40% {
        transform: translateY(-80px) scale(1.2) rotateX(360deg);
        box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8), 0 25px 35px rgba(56, 189, 248, 0.35);
        z-index: 10;
    }
    99% {
        z-index: 10;
    }
    100% {
        transform: translateY(0) scale(1) rotateX(720deg);
        z-index: 1;
    }
}

.team-card:hover .coin-viewer-wrapper {
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8), 0 0 12px rgba(56, 189, 248, 0.15);
}

.team-coin-model {
    width: 100%;
    height: 100%;
    background: transparent;
}

.team-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #f8fafc;
    margin: 0 0 4px 0;
}

.team-role {
    font-family: 'IM Fell English', serif;
    font-size: 12.5px;
    font-style: italic;
    color: #38bdf8;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.team-bio {
    font-family: 'Inter', sans-serif;
    font-size: 11.5px;
    line-height: 1.6;
    color: #94a3b8;
    margin: 0;
    text-align: left;
    height: 110px;
    overflow-y: auto;
    padding-right: 4px;
}

.team-bio::-webkit-scrollbar {
    width: 3px;
}
.team-bio::-webkit-scrollbar-track {
    background: transparent;
}
.team-bio::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}
.team-card:hover .team-bio::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.2);
}

/* ==========================================================================
   MOBILE RESPONSIVENESS & PROGRESSIVE DISCLOSURE
   ========================================================================== */
@media (max-width: 768px) {
    body {
        overflow: auto !important;
        height: auto !important;
    }
    
    .app-container {
        flex-direction: column;
        width: 100% !important;
        height: auto !important;
        min-height: 100vh;
        position: relative;
    }
    
    /* Collapsible Sidebar as slide-up drawer */
    .sidebar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 70vh !important;
        z-index: 1000 !important;
        border-right: none !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6) !important;
        transform: translateY(100%) !important;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
        overflow-y: auto !important;
        padding: 24px 20px 80px 20px !important;
    }
    
    .sidebar.mobile-open {
        transform: translateY(0) !important;
    }
    
    /* Pull-bar indicator at top of mobile drawer */
    .sidebar::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
    }
    
    .main-content {
        width: 100% !important;
        height: auto !important;
        padding-bottom: 80px !important; /* space for floating button */
        overflow: visible !important;
    }
    
    /* Floating mobile action button */
    .mobile-filter-trigger {
        display: flex !important;
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: #0284c7;
        color: #f8fafc;
        border: 1px solid #38bdf8;
        border-radius: 30px;
        padding: 12px 20px;
        font-family: 'Outfit', sans-serif;
        font-size: 13.5px;
        font-weight: 600;
        align-items: center;
        gap: 8px;
        z-index: 1001;
        box-shadow: 0 4px 20px rgba(2, 132, 199, 0.4);
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .mobile-filter-trigger:active {
        transform: scale(0.95);
        background: #0369a1;
    }
    
    /* Backdrop overlay when mobile drawer is open */
    .mobile-drawer-backdrop {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .mobile-drawer-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Stacking grids */
    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .tabs-bar {
        margin: 12px !important;
        width: calc(100% - 24px) !important;
        justify-content: center;
    }
    
    .tab-button {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
    
    .viz-container {
        height: 350px !important; /* Limit height of visualizer canvas on phone screen */
    }
    
    .leaflet-container {
        height: 350px !important;
    }
    
    /* Fixed layout locked viewport dashboard */
    body.fixed-layout {
        overflow: hidden !important;
        height: 100vh !important;
        position: fixed !important;
        width: 100vw !important;
    }
    
    body.fixed-layout .app-container {
        height: 100vh !important;
        min-height: 100vh !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    body.fixed-layout .main-content {
        height: 100% !important;
        overflow: hidden !important;
        padding-bottom: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    body.fixed-layout .tab-container {
        flex-grow: 1 !important;
        position: relative !important;
        height: 100% !important;
        overflow: hidden !important;
    }
    
    body.fixed-layout .tab-content {
        height: 100% !important;
        width: 100% !important;
    }
    
    body.fixed-layout #network-tab.active {
        display: flex !important;
        flex-direction: column !important;
    }
    
    body.fixed-layout #network-container {
        height: 0 !important;
        flex-grow: 1 !important;
    }
    
    body.fixed-layout #map-tab.active {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
    }
    
    body.fixed-layout #map-container {
        height: 0 !important;
        flex-grow: 1 !important;
        width: 100% !important;
    }
    
    body.fixed-layout .leaflet-container {
        height: 100% !important;
    }
    
    body.fixed-layout #timeline-tab.active {
        display: block !important;
        overflow-y: auto !important;
        height: 100% !important;
        padding: 16px !important;
        padding-bottom: 80px !important;
    }

    /* Loading overlay fullscreen is already fixed, just ensure z-index overrides on mobile */
    .loading-overlay {
        z-index: 99999 !important;
    }
    
    .loading-title {
        font-size: 24px !important;
    }
    
    /* Tabs Navigation Row responsive stack */
    .tabs-nav-wrapper {
        flex-direction: column !important;
        align-items: center !important;
        padding-right: 0 !important;
        gap: 10px !important;
        margin-top: 12px !important;
        width: 100% !important;
    }
    
    .tabs-bar {
        margin: 0 !important;
        width: 100% !important;
        justify-content: center !important;
    }
    
    .nav-home-btn {
        width: auto !important;
        margin-bottom: 4px !important;
    }
    
    /* Map controls stacking */
    .map-controls {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        margin: 12px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px !important;
        padding: 14px !important;
        background: rgba(15, 23, 42, 0.85) !important;
        border-radius: 12px !important;
        z-index: 1000 !important;
    }
    
    .map-controls .slider-container, 
    .map-controls .map-volume-container, 
    .map-controls .map-legend {
        width: 100% !important;
    }
    
    .map-legend {
        border-left: none !important;
        padding-left: 0 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        padding-top: 12px !important;
    }
    
    .legend-filters {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 12px !important;
        justify-content: space-between !important;
    }
    
    /* Adjust text alignments for smaller widths */
    .brand {
        margin-bottom: 12px !important;
    }
    .brand h1 {
        font-size: 20px !important;
    }
    .brand .subtitle {
        font-size: 10px !important;
    }

    /* Mobile Numismatic Cabinet (Team Gallery) overrides */
    .team-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
        padding: 12px !important;
        max-width: 100% !important;
    }
    
    .team-card {
        padding: 16px 12px !important;
        border-radius: 10px !important;
    }
    
    .coin-viewer-wrapper {
        width: 100px !important;
        height: 100px !important;
        margin-bottom: 12px !important;
    }
    
    .team-card h3 {
        font-size: 14px !important;
    }
}

/* Default state for mobile components on desktop */
.mobile-filter-trigger, .mobile-drawer-backdrop {
    display: none;
}
