/* Eyeverse Map — body UI. Chrome: /assets/shared brand-header. View modes: shared `.page-tabs` under title. */

@import url("/assets/shared/css/brand-tokens.css");
@import url("/assets/shared/css/brand-font.css");
@import url("/assets/shared/css/page-intro.css");

:root {
  --primary-color: var(--accent);
  --primary-dark: var(--accent-dim);
  --primary-light: var(--link);

  --bg-primary: var(--bg);
  --bg-secondary: var(--bg);
  --bg-tertiary: var(--bg-elevated);

  --surface-primary: rgba(255, 255, 255, 0.08);
  --surface-secondary: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.12);
  --surface-nav: color-mix(in srgb, var(--bg) 88%, transparent);

  --text-primary: var(--text);
  --text-secondary: color-mix(in srgb, var(--text) 80%, transparent);
  --text-dark: #2d3748;
  --text-dark-secondary: #4a5568;

  --border-primary: var(--border);
  --border-secondary: color-mix(in srgb, var(--border) 60%, transparent);
  --border-accent: var(--accent);

  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-xxl: 48px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.3);

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

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

/* Base Styles */
* {
    box-sizing: border-box;
}

html {
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgb(201 162 39 / 8%), transparent 55%),
        var(--bg);
    overflow-x: clip;
    max-width: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    background: transparent;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 16px;
    overflow-x: clip;
    max-width: 100%;
}

/* Content layout — same shell as brand `.site-shell` */
.content {
    width: min(100%, var(--max-width, 72rem));
    margin-inline: auto;
    padding: 1.25rem clamp(1rem, 4vw, 1.5rem) 2.5rem;
    box-sizing: border-box;
    min-width: 0;
}

.container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Page intro: shared `.page-intro`; map h1 resets */
.page-intro {
    margin: 0 0 var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-primary);
    text-align: left;
}

.page-intro:has(+ .page-tabs) {
    margin-bottom: 0;
    padding-bottom: 0.85rem;
    border-bottom: none;
}

.page-intro h1 {
    background: none;
    -webkit-text-fill-color: unset;
    text-shadow: none;
    font-weight: 400;
    letter-spacing: 0.03em;
    text-align: left;
    margin: 0 0 0.75rem;
    font-size: var(--page-title-size);
}

.page-intro .lede {
    text-align: left;
    margin: 0;
}

/* Map view switcher — button-like tabs (2D / 3D / Data) */
.map-2d-view .page-tabs,
.data-explorer-view .page-tabs,
.terrain-3d-view .page-tabs {
    gap: 0.5rem;
    margin: 0 0 1.25rem;
    padding: 0;
    border-bottom: none;
}

.map-2d-view .page-tabs-link,
.data-explorer-view .page-tabs-link,
.terrain-3d-view .page-tabs-link {
    min-height: var(--tap-min, 2.75rem);
    padding: 0.45rem 1.15rem;
    border: 1px solid var(--border, var(--border-primary));
    border-radius: var(--radius-sm, 4px);
    background: var(--bg-elevated, var(--bg-tertiary));
    color: var(--text, var(--text-primary));
    font-size: 1rem;
    letter-spacing: 0.05em;
    line-height: 1.1;
    box-sizing: border-box;
}

.map-2d-view .page-tabs-link:hover,
.data-explorer-view .page-tabs-link:hover,
.terrain-3d-view .page-tabs-link:hover {
    border-color: var(--accent, var(--primary-color));
    color: var(--accent, var(--primary-color));
    background: color-mix(in srgb, var(--bg-elevated, #242424) 88%, var(--accent, #c9a227));
}

.map-2d-view .page-tabs-link.active,
.map-2d-view .page-tabs-link[aria-current="page"],
.data-explorer-view .page-tabs-link.active,
.data-explorer-view .page-tabs-link[aria-current="page"],
.terrain-3d-view .page-tabs-link.active,
.terrain-3d-view .page-tabs-link[aria-current="page"] {
    border-color: var(--accent, var(--primary-color));
    background: color-mix(in srgb, var(--accent, #c9a227) 28%, var(--bg-elevated, #242424));
    color: #fff;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent, #c9a227) 55%, transparent);
}

/* Typography — avoid fighting `.page-intro h1` */
h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: var(--spacing-lg);
    text-align: left;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #ffffff, #e2e8f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

h3 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

h4 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.subtitle {
    font-size: 1.3rem;
    margin-bottom: var(--spacing-xxl);
    opacity: 0.9;
    text-align: center;
    font-weight: 400;
}

/* Cards and Surfaces */
.card {
    background: var(--surface-primary);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-primary);
    transition: all var(--transition-normal);
}

.card:hover {
    background: var(--surface-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-xl);
    margin-top: var(--spacing-xxl);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--surface-primary);
    color: var(--text-primary);
    border: 1px solid var(--primary-color);
    box-shadow: none;
}

.btn-primary:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: none;
}

.btn-secondary {
    background: var(--surface-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    transform: translateY(-1px);
}

/* Form Controls */
.control-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

.control-group label {
    font-weight: 600;
    min-width: 120px;
    color: var(--text-primary);
}

select, input[type="range"], input[type="number"], input[type="text"], input:not([type]) {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    background: var(--surface-primary);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.875rem;
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
}

select:focus, input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Viz Buttons */
.viz-buttons {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.viz-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.55rem;
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    transition: all var(--transition-normal);
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.viz-btn:hover {
    background: var(--surface-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.viz-btn.active {
    background: var(--surface-primary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: none;
}

.viz-btn .icon {
    font-size: 0.95rem;
    line-height: 1;
}

@media (min-width: 1100px) {
    .map-2d-view .viz-buttons {
        flex-wrap: nowrap;
    }
}

/* Legend */
.legend {
    background: var(--surface-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-sm);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.legend-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    align-items: flex-start;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    white-space: nowrap;
    flex-shrink: 0;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.legend-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Canvas Container */
.canvas-container {
    background: var(--surface-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg);
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
}

canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    box-sizing: border-box;
}

/* Status Messages */
.status {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    font-weight: 500;
}

.status.success {
    background: rgba(76, 175, 80, 0.2);
    border-left: 4px solid #4CAF50;
    color: #4CAF50;
}

.status.error {
    background: rgba(244, 67, 54, 0.2);
    border-left: 4px solid #f44336;
    color: #f44336;
}

.status.info {
    background: rgba(33, 150, 243, 0.2);
    border-left: 4px solid #2196F3;
    color: #2196F3;
}

/* File List */
.file-list {
    background: var(--surface-secondary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-lg);
    border: 1px solid var(--border-secondary);
}

.file-item {
    padding: var(--spacing-xs) 0;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-secondary);
}

/* Tooltips */
.settlement-tooltip, .polygon-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: 14px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-primary);
}

/* Above stage chrome when mounted inside fullscreen #mapStage */
.map-stage.is-fullscreen .settlement-tooltip,
.map-stage.is-fullscreen .polygon-tooltip,
.map-stage.is-fullscreen .tooltip,
.map-stage.is-fullscreen .line-tooltip {
    z-index: 5000;
}

.tooltip-name {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.tooltip-details {
    font-size: 12px;
    opacity: 0.8;
}

.capital-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-right: var(--spacing-sm);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .viz-buttons {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: var(--spacing-sm);
    }
    
    .control-group {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
    
    .control-group label {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .content {
        padding: var(--spacing-md);
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .card {
        padding: var(--spacing-lg);
    }
}

/* Loading States */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--surface-primary);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
button:focus-visible, .btn:focus-visible, .viz-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-primary: rgba(255, 255, 255, 0.5);
        --text-secondary: rgba(255, 255, 255, 0.9);
    }
}

/* ===== Shared map overlay chrome (2D + 3D) ===== */
.map-overlay-panel {
    background: rgba(8, 8, 10, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg);
    color: rgba(255, 255, 255, 0.92);
}

.map-fullscreen-btn {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(8, 8, 10, 0.92);
    color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
}

.map-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.96);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.28);
}

.map-fullscreen-btn__exit {
    display: none;
}

.map-viewport.is-fullscreen .map-fullscreen-btn__enter,
.map-stage.is-fullscreen .map-fullscreen-btn__enter {
    display: none;
}

.map-viewport.is-fullscreen .map-fullscreen-btn__exit,
.map-stage.is-fullscreen .map-fullscreen-btn__exit {
    display: inline;
}

.map-fullscreen-btn--top-right {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 120;
}

.map-controls-hint {
    padding: 0.5rem 0.65rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.7rem;
    line-height: 1.55;
}

.map-controls-hint__title {
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.map-reset-btn {
    padding: 0.4rem 0.65rem !important;
    font-size: 0.75rem !important;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    background: rgba(0, 0, 0, 0.45) !important;
    color: rgba(255, 255, 255, 0.92) !important;
    cursor: pointer;
    font-family: var(--font-display);
}

.map-reset-btn:hover {
    transform: none !important;
    background: rgba(0, 0, 0, 0.65) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.28) !important;
}

/* ===== 3D TERRAIN PREVIEW SPECIFIC STYLES ===== */
.terrain-3d-view body {
    background: transparent;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

.terrain-3d-view .siteShell {
    flex: 1;
    min-height: 0;
}

.terrain-3d-view .content--map-3d {
    flex-shrink: 0;
    padding-bottom: 0;
}

.terrain-3d-view #container {
    position: relative;
    /* Above page footer when the layers panel overlaps; below sticky site chrome (500). */
    z-index: 40;
    flex: 1;
    min-height: 0;
    width: 100%;
}

.terrain-3d-view .map-stage-chrome {
    pointer-events: none;
}

.terrain-3d-view .map-stage-chrome .layers-panel,
.terrain-3d-view .map-stage-chrome .map-stage-actions {
    pointer-events: auto;
}

.terrain-3d-view .layers-panel .legend {
    margin-top: 0;
}

.terrain-3d-view .legend {
    margin-top: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.35);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: none;
}

.terrain-3d-view .loading-indicator {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

.terrain-3d-view .legend h3 {
    margin: 0 0 var(--spacing-sm) 0;
    font-size: var(--font-size-md);
    color: rgba(255, 255, 255, 0.92);
}

.terrain-3d-view .legend-item {
    display: flex;
    align-items: center;
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.75);
}

.terrain-3d-view .legend-color {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
    margin-right: var(--spacing-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
}


.terrain-3d-view #loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 200;
    background: var(--surface-primary);
    padding: var(--spacing-xl);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg);
}

.terrain-3d-view #error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    text-align: center;
    z-index: 200;
    display: none;
    border: 1px solid rgba(244, 67, 54, 0.3);
    backdrop-filter: blur(20px);
}

.terrain-3d-view #canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: grab;
    user-select: none;
}

/* ===== DATA EXPLORER SPECIFIC STYLES ===== */
.data-explorer-view body {
    background: transparent;
}

.data-explorer-view .data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    align-items: stretch;
}

.data-explorer-view .data-card {
    background: var(--surface-primary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    min-height: 150px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
}

.data-explorer-view .data-card:hover {
    background: var(--surface-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.data-explorer-view .data-card h3 {
    margin: 0 0 0.75rem;
    color: #f0f0f0;
    font-size: 1.4rem;
    font-weight: 600;
}

.data-explorer-view .stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
}

.data-explorer-view .stat-item {
    background: var(--surface-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border-secondary);
}

.data-explorer-view .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.data-explorer-view .settlement-name {
    font-weight: 600;
    color: var(--text-primary);
}

.data-explorer-view .settlement-pop, 
.data-explorer-view .list-info {
    color: #f0f0f0;
    font-size: 12px;
}

.data-explorer-view .biome-list, 
.data-explorer-view .culture-list, 
.data-explorer-view .religion-list, 
.data-explorer-view .settlement-list, 
.data-explorer-view .region-list {
    overflow: visible;
    background: var(--surface-secondary);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-secondary);
    box-sizing: border-box;
}

.data-explorer-view .list-item,
.data-explorer-view .settlement-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.data-explorer-view .list-item:first-child,
.data-explorer-view .settlement-item:first-child {
    padding-top: 0;
}

.data-explorer-view .list-item:last-child,
.data-explorer-view .settlement-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.data-explorer-view .list-rank {
    color: var(--accent, var(--primary-color));
    margin-right: 8px;
}

.data-explorer-view .color-indicator {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-right: var(--spacing-sm);
    border: 1px solid var(--border-primary);
}

/* ===== 2D MAP SPECIFIC STYLES ===== */
.map-2d-view body {
    background: transparent;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

.map-2d-view .siteShell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.map-2d-view .content--map-2d {
    flex-shrink: 0;
    width: min(100%, var(--max-width, 72rem));
    margin-inline: auto;
    padding: 1.25rem clamp(1rem, 4vw, 1.5rem) 0;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .map-2d-view .content--map-2d {
        padding-top: 0.65rem;
        padding-bottom: 0;
    }

    .map-2d-view .content--map-2d .page-intro {
        margin-bottom: 0.35rem;
    }

    .map-2d-view .content--map-2d .page-intro h1 {
        font-size: 1.45rem;
        margin-bottom: 0.25rem;
    }

    .map-2d-view .content--map-2d .page-intro .lede {
        font-size: 0.875rem;
    }

    .map-2d-view .content--map-2d .page-intro:has(+ .page-tabs) {
        padding-bottom: 0.65rem;
    }

    .map-2d-view .content--map-2d .page-tabs {
        margin-bottom: 0.75rem;
        padding-bottom: 0;
    }

    .terrain-3d-view .content--map-3d {
        padding-top: 0.65rem;
        padding-bottom: 0;
    }

    .terrain-3d-view .content--map-3d .page-intro h1 {
        font-size: 1.45rem;
        margin-bottom: 0.25rem;
    }

    .terrain-3d-view .content--map-3d .page-intro .lede {
        font-size: 0.875rem;
    }

    .terrain-3d-view .content--map-3d .page-intro:has(+ .page-tabs) {
        padding-bottom: 0.65rem;
    }

    .terrain-3d-view .content--map-3d .page-tabs {
        margin-bottom: 0.75rem;
        padding-bottom: 0;
    }
}

.map-2d-view .map-stage {
    position: relative;
    /* Above page footer when the layers panel overlaps; below sticky site chrome (500). */
    z-index: 40;
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    background: #0a0a0c;
}

.map-stage-chrome {
    position: absolute;
    z-index: 120;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    pointer-events: none;
}

.map-stage-chrome--top {
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
}

.map-stage-chrome .layers-panel,
.map-stage-chrome .map-stage-actions {
    pointer-events: auto;
}

.map-stage-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.map-2d-view .tooltip a {
    color: #87CEEB !important;
    text-decoration: underline !important;
    pointer-events: auto !important;
}

.map-2d-view .tooltip a:hover {
    color: #ADD8E6 !important;
}

.layers-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 11.5rem;
    max-width: min(11.5rem, calc(100vw - 4.5rem));
    max-height: calc(100% - 1.5rem);
    margin: 0;
    box-sizing: border-box;
    background: rgba(8, 8, 10, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: width 0.2s ease;
}

.layers-panel[data-collapsed="true"] {
    width: 2.35rem;
    max-width: 2.35rem;
}

.layers-panel__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
    margin: 0;
    padding: 0.45rem 0.55rem;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.92);
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    box-sizing: border-box;
}

.layers-panel__toggle:hover {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    transform: none;
}

.layers-panel__toggle-label {
    flex: 1;
    text-align: left;
}

.layers-panel__chevron {
    flex-shrink: 0;
    font-size: 0.7rem;
    line-height: 1;
    opacity: 0.9;
}

.layers-panel__chevron--closed {
    display: none;
}

.layers-panel[data-collapsed="true"] .layers-panel__toggle {
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.55rem;
    min-height: 5.5rem;
    padding: 0.55rem 0.35rem;
    border-bottom: none;
}

.layers-panel[data-collapsed="true"] .layers-panel__toggle-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-align: center;
    flex: 0 0 auto;
}

.layers-panel[data-collapsed="true"] .layers-panel__chevron--open {
    display: none;
}

.layers-panel[data-collapsed="true"] .layers-panel__chevron--closed {
    display: inline;
}

.layers-panel__body {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.5rem;
    min-height: 0;
    overflow: auto;
}

.layers-panel[data-collapsed="true"] .layers-panel__body {
    display: none;
}

.layers-panel .viz-buttons {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    margin: 0;
    gap: 0.3rem;
}

.layers-panel .viz-btn {
    width: 100%;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.92);
}

.layers-panel .viz-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: none;
}

.layers-panel .viz-btn.active {
    background: rgba(177, 2, 2, 0.28);
    border-color: var(--primary-color);
    color: #fff;
}

.layers-panel .search-container {
    width: 100%;
    max-width: none;
    min-width: 0;
    position: relative;
    flex: 0 0 auto;
}

.layers-panel .search-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-height: calc(0.35rem * 2 + 0.8125rem * 1.2);
    padding: 0.35rem 0.55rem;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    box-sizing: border-box;
}

.layers-panel .search-icon {
    font-size: 0.8rem;
    line-height: 1;
    opacity: 0.75;
    flex-shrink: 0;
}

.layers-panel #globalSearch {
    width: 100%;
    min-width: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    border: none;
    outline: none;
    font-family: var(--font-display);
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1.2;
    padding: 0;
    min-height: 0;
}

.layers-panel #globalSearch::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

.layers-panel .search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.25rem);
    width: auto;
    z-index: 130;
    margin-top: 0;
    background: rgba(12, 12, 14, 0.96);
    border-color: rgba(255, 255, 255, 0.14);
}

.layers-panel__controls {
    margin-top: 0.15rem;
    flex-shrink: 0;
}

.map-2d-view select,
.map-2d-view input[type="range"],
.map-2d-view button:not(.viz-btn):not(.map-fullscreen-btn):not(.map-reset-btn):not(.layers-panel__toggle):not(.map-action-btn) {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    background: var(--surface-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.map-2d-view .legend-content {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.55rem;
    align-items: flex-start;
}

.map-2d-view .legend-panel {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    z-index: 110;
    width: min(36rem, calc(100% - 1.5rem));
    max-width: min(36rem, calc(100% - 1.5rem));
    max-height: min(42vh, 16rem);
    color: rgba(255, 255, 255, 0.92);
}

.map-2d-view .legend-panel[data-collapsed="true"] {
    width: 2.35rem;
    max-width: 2.35rem;
    max-height: none;
}

.map-2d-view .legend-panel .layers-panel__body {
    padding: 0.45rem 0.55rem 0.55rem;
}

.map-2d-view .legend-panel .legend-item {
    padding: 0.15rem 0.25rem;
    color: rgba(255, 255, 255, 0.9);
}

.map-2d-view .legend-panel .legend-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
    font-weight: 400;
}

.map-2d-view .legend-panel .legend-color {
    border-color: rgba(255, 255, 255, 0.28);
    width: 14px;
    height: 14px;
}

.map-2d-view .legend-panel .legend-title {
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
}

.map-2d-view button:not(.viz-btn):not(.map-fullscreen-btn):not(.layers-panel__toggle):not(.map-action-btn) {
    background: var(--surface-primary);
    border-color: var(--primary-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.map-2d-view button:not(.viz-btn):not(.map-fullscreen-btn):not(.layers-panel__toggle):not(.map-action-btn):hover {
    background: var(--surface-hover);
    color: var(--primary-color);
}

.map-2d-view button:disabled {
    background: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

.map-2d-view .canvas-container {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: #111;
    overflow: hidden;
    display: block;
}

.map-2d-view canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    box-sizing: border-box;
    border-radius: 0;
    box-shadow: none;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.map-2d-view .info-panel {
    background: var(--surface-primary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-lg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
}

.map-2d-view .stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.map-2d-view .stat-item {
    background: var(--surface-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border-secondary);
}

.map-2d-view .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.map-loading-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 200;
    background: var(--surface-primary);
    padding: var(--spacing-xl);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg);
    font-size: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: min(20rem, 90vw);
}

.map-loading-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--surface-primary);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

.search-container {
    flex: 1 1 12rem;
    min-width: 0;
    max-width: 360px;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
}

.search-icon {
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0.75;
}

#globalSearch {
    width: 100%;
    background: transparent;
    color: var(--text-primary);
    border: none;
    outline: none;
    font-family: var(--font-display);
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
    line-height: 1.3;
    padding: 0;
    min-height: 1.5rem;
}

.search-results {
    margin-top: 0.35rem;
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    font-family: var(--font-display);
}

.search-result-item {
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    font-size: 0.8125rem;
}

.search-result-item--status {
    opacity: 0.65;
    cursor: default;
    pointer-events: none;
}

.layers-panel .search-result-item {
    color: rgba(255,255,255,0.92);
}

.layers-panel .search-result-item:hover {
    background: rgba(255,255,255,0.08);
}

.search-result-item:hover {
    background: var(--surface-hover);
}
