/*
 * Historical Events Globe - Styles
 *
 * This file controls how everything looks.
 * CSS uses selectors (like .class-name or #id-name) to target HTML elements.
 * Properties inside {} define the appearance.
 */

/* ============================================
   CSS VARIABLES (Custom Properties)
   ============================================
   Variables start with -- and let us reuse values.
   We define them in :root so they're available everywhere.
*/
:root {
    /* Colors - Dark theme palette */
    --bg-primary: #0a0a0f;           /* Main background - very dark blue-black */
    --bg-secondary: #12121a;          /* Secondary background - slightly lighter */
    --bg-overlay: rgba(10, 10, 15, 0.85);  /* Semi-transparent for overlays */
    --bg-panel: rgba(18, 18, 26, 0.95);    /* Panel background */

    --text-primary: #ffffff;          /* Main text - white */
    --text-secondary: #a0a0b0;        /* Secondary text - gray */
    --text-muted: #606070;            /* Muted text - darker gray */

    --accent-primary: #4a9eff;        /* Primary accent - bright blue */
    --accent-secondary: #7c3aed;      /* Secondary accent - purple */

    --border-color: rgba(255, 255, 255, 0.1);  /* Subtle borders */
    --hover-color: rgba(255, 255, 255, 0.05);  /* Hover state background */

    /* Category Colors - Muted, dark-theme friendly, legible over satellite imagery */
    --category-war: #b45550;          /* Muted rust for War & Conflict */
    --category-politics: #4a72a8;     /* Deep blue for Politics & Law */
    --category-science: #4a9e9e;      /* Cool teal for Science & Technology */
    --category-culture: #c49a3c;      /* Warm amber for Culture & Society */
    --category-disaster: #b87840;     /* Desaturated sienna for Disaster & Accident */
    --category-exploration: #5a9e6e;  /* Soft green for Exploration & Discovery */
    --category-other: #808894;        /* Neutral gray for Other */

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Panel Width */
    --panel-width: 420px;
}

/* ============================================
   RESET & BASE STYLES
   ============================================
   Remove default browser styling for consistency.
*/
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;  /* Makes width/height include padding and border */
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;  /* Prevent scrollbars - globe handles its own scrolling */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

/* Remove focus outline but add custom one for accessibility */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ============================================
   UTILITY CLASSES
   ============================================
   Small, reusable classes for common patterns.
*/
.hidden {
    display: none !important;  /* !important ensures this always works */
}

/* ============================================
   LOADING SCREEN
   ============================================
   Shown while the globe initializes.
*/
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;  /* Above everything else */
    opacity: 1;
    transition: opacity 0.6s ease-out;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: var(--text-primary);
}

/* Spinning animation for the loader */
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto var(--spacing-md);
    animation: spin 1s linear infinite;
}

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

/* ============================================
   ERROR SCREEN
   ============================================
   Shown if the globe fails to load.
*/
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.error-content {
    text-align: center;
    padding: var(--spacing-xl);
    max-width: 400px;
}

.error-content h2 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.error-content button {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    transition: background-color var(--transition-fast);
}

.error-content button:hover {
    background-color: #3a8eef;
}

/* ============================================
   APP CONTAINER
   ============================================
   Main wrapper for the entire application.
*/
.app-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ============================================
   CESIUM CONTAINER
   ============================================
   Where the 3D globe renders.
*/
.cesium-container {
    width: 100%;
    height: 100%;
}

/*
   Override some Cesium default styles to match our dark theme.
   Cesium adds its own UI elements that we need to style.
*/
.cesium-viewer {
    background-color: var(--bg-primary);
}

/* Hide Cesium's default credit/logo (we'll add attribution elsewhere if needed) */
.cesium-viewer-bottom {
    display: none !important;
}

/* Style Cesium's navigation help popup */
.cesium-navigation-help {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-color) !important;
}

/* ============================================
   UI OVERLAY
   ============================================
   Container for our custom controls.
   Positioned over the globe.
*/
.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    padding: var(--spacing-md);
    pointer-events: none;  /* Let clicks pass through to the globe */
    z-index: 100;
}

/* Re-enable pointer events on interactive children */
.ui-overlay > * {
    pointer-events: auto;
}

/* ============================================
   HEADER
   ============================================
   App title and search box.
*/
.ui-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ============================================
   FILTER PANEL
   ============================================
   Contains category toggles and date range.
*/
.filter-panel {
    background-color: var(--bg-overlay);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    width: 280px;
    backdrop-filter: blur(10px);  /* Frosted glass effect */
    -webkit-backdrop-filter: blur(10px);
}

.filter-section {
    margin-bottom: var(--spacing-md);
}

.filter-section:last-of-type {
    margin-bottom: var(--spacing-sm);
}

.filter-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-sm);
}

/* ============================================
   CATEGORY FILTERS
   ============================================
   Checkboxes for each event category.
*/
.category-filters {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.category-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.category-checkbox:hover {
    background-color: var(--hover-color);
}

/* Hide the default checkbox, we'll style our own */
.category-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Custom checkbox appearance */
.category-checkbox .checkbox-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

/* Checkmark icon (hidden by default) */
.category-checkbox .checkbox-custom::after {
    content: '✓';
    font-size: 10px;
    color: white;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

/* When checkbox is checked */
.category-checkbox input:checked + .checkbox-custom {
    background-color: var(--checkbox-color, var(--accent-primary));
    border-color: var(--checkbox-color, var(--accent-primary));
}

.category-checkbox input:checked + .checkbox-custom::after {
    opacity: 1;
}

/* Category color indicator dot */
.category-checkbox .category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-checkbox .category-label {
    font-size: 13px;
    color: var(--text-primary);
}

/* ============================================
   DATE RANGE FILTER
   ============================================
*/
.date-range-container {
    display: flex;
    gap: var(--spacing-md);
}

.date-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.date-input-group label {
    font-size: 12px;
    color: var(--text-secondary);
}

.year-input {
    width: 100%;
    padding: var(--spacing-sm);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--transition-fast);
}

.year-input:focus {
    border-color: var(--accent-primary);
}

/* Hide number input spinners */
.year-input::-webkit-outer-spin-button,
.year-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.year-input[type=number] {
    -moz-appearance: textfield;
}

/* ============================================
   EVENT COUNTER
   ============================================
   Shows how many events are currently visible.
*/
.event-counter {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
}

.event-counter span {
    color: var(--accent-primary);
    font-weight: 600;
}

/* ============================================
   EXPLORE HINT
   ============================================
   Tells users they can zoom to find more events.
*/
.explore-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: var(--spacing-sm);
    font-style: italic;
}

/* ============================================
   LOADING INDICATOR
   ============================================
   Shows when fetching data from Wikidata.
   Enhanced for high-density loading with counts.
*/
.loading-indicator {
    position: absolute;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-overlay);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 13px;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 150;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    max-width: 90%;
    white-space: nowrap;
}

.loading-indicator::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

/* ============================================
   DETAIL PANEL - READER LAYOUT
   ============================================
   Fixed panel with sticky header/footer and scrollable body.
   Designed as a clean reading surface.
*/
.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--panel-width);
    max-width: 100vw;
    height: 100dvh;
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.detail-panel:not(.hidden) {
    transform: translateX(0);
}

/* ============================================
   PANEL HEADER (Sticky)
   ============================================ */
.panel-header {
    flex-shrink: 0;
    position: relative;
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
}

.panel-header-content {
    padding-right: 40px;
}

.panel-category {
    display: inline-block;
    padding: 3px 8px;
    background-color: var(--category-color, var(--accent-primary));
    color: white;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 3px;
    margin-bottom: var(--spacing-xs);
}

.panel-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: var(--spacing-xs);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.panel-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    font-size: 12px;
}

.panel-date {
    color: var(--accent-primary);
    font-weight: 500;
}

.panel-location {
    color: var(--text-muted);
}

.panel-location::before {
    content: '';
}

/* Close button */
.panel-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 36px;
    height: 36px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 1;
}

.panel-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.panel-close svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   MODE SWITCH (Sticky)
   ============================================ */
.panel-mode-switch {
    flex-shrink: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
}

.panel-view-toggle {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    padding: 3px;
}

.panel-view-toggle .toggle-btn {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.panel-view-toggle .toggle-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.panel-view-toggle .toggle-btn.active {
    background: rgba(74, 158, 255, 0.15);
    color: var(--accent-primary);
}

/* ============================================
   PANEL BODY (Scrollable)
   ============================================ */
.panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.panel-body::-webkit-scrollbar {
    width: 6px;
}

.panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.panel-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   MEDIA SECTION
   ============================================ */
.panel-media {
    padding: var(--spacing-md);
    padding-bottom: 0;
}

.panel-image-container {
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 220px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: var(--bg-secondary);
    position: relative;
}

.panel-image-container.loading {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        rgba(255, 255, 255, 0.04) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.panel-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.panel-image.loaded {
    opacity: 1;
}

.panel-image-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.3;
}

.panel-image-caption:empty {
    display: none;
}

/* Gallery strip */
.panel-gallery {
    margin-top: var(--spacing-sm);
}

.panel-gallery-strip {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.panel-gallery-strip::-webkit-scrollbar {
    display: none;
}

.gallery-thumb {
    width: 52px;
    height: 52px;
    border-radius: 4px;
    object-fit: cover;
    cursor: pointer;
    opacity: 0.6;
    border: 2px solid transparent;
    flex-shrink: 0;
    scroll-snap-align: start;
    transition: all var(--transition-fast);
}

.gallery-thumb:hover {
    opacity: 1;
}

.gallery-thumb.active {
    opacity: 1;
    border-color: var(--accent-primary);
}

/* ============================================
   CONTENT SECTION
   ============================================ */
.panel-content {
    padding: var(--spacing-md);
}

.panel-view {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Loading skeleton */
.panel-skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        rgba(255, 255, 255, 0.04) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
    height: 80px;
}

/* Description */
.panel-description {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.7;
}

.panel-description.loading {
    color: var(--text-muted);
    font-style: italic;
}

/* Facts section */
.panel-facts {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md) 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.panel-fact-row {
    display: flex;
    gap: var(--spacing-sm);
    padding: 4px 0;
    font-size: 13px;
}

.panel-fact-label {
    color: var(--text-muted);
    min-width: 80px;
    flex-shrink: 0;
}

.panel-fact-value {
    color: var(--text-primary);
    line-height: 1.4;
}

/* Topic chips */
.panel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--spacing-md);
}

.panel-chip {
    display: inline-flex;
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: default;
    transition: border-color var(--transition-fast);
}

.panel-chip:hover {
    border-color: var(--text-muted);
}

/* ============================================
   FULL ARTICLE - WIKI ARTICLE STYLES
   ============================================ */
.wiki-article {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.75;
}

.wiki-article h2,
.wiki-article h3,
.wiki-article h4,
.wiki-article h5 {
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}

.wiki-article h2 { font-size: 1.25em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.wiki-article h3 { font-size: 1.1em; }
.wiki-article h4 { font-size: 1em; }

.wiki-article p {
    margin-bottom: 1em;
}

.wiki-article p:last-child {
    margin-bottom: 0;
}

.wiki-article ul,
.wiki-article ol {
    margin: 0.5em 0 1em 1.5em;
    padding: 0;
}

.wiki-article li {
    margin-bottom: 0.3em;
}

.wiki-article a {
    color: var(--accent-primary);
    text-decoration: none;
}

.wiki-article a:hover {
    text-decoration: underline;
}

.wiki-article blockquote {
    margin: 1em 0;
    padding: 0.5em 1em;
    border-left: 3px solid var(--accent-primary);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-style: italic;
}

.wiki-article img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 0.5em 0;
}

.wiki-article figure {
    margin: 1em 0;
    padding: 0;
}

.wiki-article figcaption {
    font-size: 0.85em;
    color: var(--text-muted);
    padding: 0.5em 0;
}

.wiki-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.9em;
}

.wiki-article th,
.wiki-article td {
    padding: 0.5em;
    border: 1px solid var(--border-color);
    text-align: left;
}

.wiki-article th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
}

/* Hide problematic wiki elements */
.wiki-article .mw-empty-elt,
.wiki-article .noprint,
.wiki-article .mw-editsection,
.wiki-article .sistersitebox,
.wiki-article .portalbox {
    display: none !important;
}

/* Truncation notice */
.wiki-article .read-more-link {
    display: inline-block;
    margin-top: 1em;
    color: var(--accent-primary);
}

/* ============================================
   PANEL FOOTER (Sticky)
   ============================================ */
.panel-footer {
    flex-shrink: 0;
    padding: var(--spacing-md);
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
}

.panel-wiki-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: 10px var(--spacing-md);
    background: var(--accent-primary);
    border: none;
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.panel-wiki-btn:hover {
    background: #3a8eef;
    transform: translateY(-1px);
}

.panel-wiki-btn svg {
    flex-shrink: 0;
}

/* Attribution */
.panel-attribution {
    margin-top: var(--spacing-sm);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 8px;
}

.panel-attribution a {
    color: var(--text-secondary);
    text-decoration: none;
}

.panel-attribution a:hover {
    color: var(--accent-primary);
}

.panel-attribution .attr-links {
    display: flex;
    gap: 8px;
}

.panel-attribution .attr-links a::before {
    content: '';
}

.panel-attribution .attr-links a:not(:first-child)::before {
    content: '\00B7\00A0';
    color: var(--text-muted);
}

/* ============================================
   PERFORMANCE HUD
   ============================================
   Always-visible instrumentation overlay.
   Shows FPS, loaded/rendered counts, clusters, labels, requests, load time.
*/
.perf-hud {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background-color: rgba(0, 0, 0, 0.75);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 11px;
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--text-secondary);
    z-index: 100;
    min-width: 130px;
    pointer-events: none;
}

.perf-row {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: 2px 0;
}

.perf-label {
    color: var(--text-muted);
}

.perf-value {
    color: var(--accent-primary);
    font-weight: 600;
}

/* ============================================
   SEARCH BAR (Upper Left)
   ============================================
   Collapsible search that expands on click.
*/
.search-container {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    display: flex;
    align-items: center;
    height: 36px;
    background-color: rgba(20, 20, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-md);
    z-index: 100;
    transition: border-color 0.15s ease;
}

.search-container:hover,
.search-container.expanded {
    border-color: rgba(255, 255, 255, 0.5);
}

.search-toggle {
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.search-container:hover .search-toggle,
.search-container.expanded .search-toggle {
    color: #ffffff;
}

.search-expanded {
    display: flex;
    align-items: center;
    width: 0;
    overflow: hidden;
    transition: width 0.2s ease-out;
}

.search-container.expanded .search-expanded {
    width: 210px;
}

.search-container.typing .search-expanded {
    transition: none;
}

.search-input {
    width: 100%;
    height: 34px;
    background: transparent;
    border: none;
    padding: 0 var(--spacing-sm) 0 0;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
}

/* ============================================
   MAILING LIST SIGNUP (Lower Left)
   ============================================
   Collapsible email signup - matches search bar style.
*/
.mailing-container {
    position: absolute;
    bottom: var(--spacing-md);
    left: var(--spacing-md);
    display: flex;
    align-items: center;
    height: 36px;
    background-color: rgba(20, 20, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-md);
    z-index: 100;
    transition: border-color 0.15s ease;
}

.mailing-container:hover,
.mailing-container.expanded {
    border-color: rgba(255, 255, 255, 0.5);
}

.mailing-toggle {
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mailing-container:hover .mailing-toggle,
.mailing-container.expanded .mailing-toggle {
    color: #ffffff;
}

.mailing-expanded {
    display: flex;
    align-items: center;
    width: 0;
    overflow: hidden;
    transition: width 0.2s ease-out;
}

.mailing-container.expanded .mailing-expanded {
    width: 170px;
}

.mailing-container.typing .mailing-expanded {
    transition: none;
}

.mailing-input {
    width: 100%;
    height: 34px;
    background: transparent;
    border: none;
    padding: 0 var(--spacing-sm) 0 0;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

.mailing-input::placeholder {
    color: var(--text-muted);
}

.mailing-input:focus {
    outline: none;
}

/* ============================================
   ESRI ATTRIBUTION
   ============================================
   Required disclosure for ESRI basemap data.
*/
.esri-attribution {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 50;
    white-space: nowrap;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================
   Adjust layout for smaller screens.
*/
@media (max-width: 768px) {
    .ui-overlay {
        padding: var(--spacing-sm);
    }

    .search-container,
    .filter-panel {
        width: 100%;
        max-width: 300px;
    }

    .app-title {
        font-size: 16px;
    }

    .detail-panel {
        width: 100%;
    }

    .panel-image-container {
        max-height: 180px;
    }
}

@media (max-width: 480px) {
    :root {
        --panel-width: 100vw;
    }

    .filter-panel {
        max-width: 260px;
    }

    .detail-panel {
        border-left: none;
    }

    .panel-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .panel-title {
        font-size: 15px;
    }

    .panel-image-container {
        max-height: 160px;
        border-radius: 0;
    }

    .panel-media {
        padding: 0;
    }

    .panel-content {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .date-range-container {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
}
