/* ==========================================
   1. BASE VARIABLES & RESETS
   ========================================== */
:root {
    --bg-dark: #121212;
    --panel-bg: #1e1e1e;
    --text-main: #e0e0e0;
    --text-muted: #9e9e9e;
    --accent-color: #ff5722;
    --border-color: #333;
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevents whole-page scroll, keeps dashboard fixed */
}

/* Custom Webkit Scrollbars (Applied universally to scrollable panels) */
.summary-brief::-webkit-scrollbar,
.context-panel::-webkit-scrollbar,
#modal-list::-webkit-scrollbar {
    width: 6px;
}

.summary-brief::-webkit-scrollbar-track,
.context-panel::-webkit-scrollbar-track,
#modal-list::-webkit-scrollbar-track {
    background: transparent;
}

.summary-brief::-webkit-scrollbar-thumb,
.context-panel::-webkit-scrollbar-thumb,
#modal-list::-webkit-scrollbar-thumb {
    background: #444c56;
    border-radius: 3px;
}

.summary-brief::-webkit-scrollbar-thumb:hover,
.context-panel::-webkit-scrollbar-thumb:hover,
#modal-list::-webkit-scrollbar-thumb:hover {
    background: #74b9ff;
}

/* ==========================================
   2. MAIN DASHBOARD SKELETON
   ========================================== */
/* The 2x2 Grid Layout */
.dash-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 20px;
    padding: 20px;
    flex: 1;
    height: calc(100vh - 60px);
}

/* Reusable Panel Base */
.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
}

/* Structural Overrides */
.quadrant-wrapper {
    position: relative;
    overflow: hidden;
    padding: 0; /* Overrides .panel padding so inner absolute containers span edge-to-edge */
}

.panels-wrapper {
    position: relative;
    overflow: hidden; 
    height: 100%;
    width: 100%;
}

/* Individual context views inside the quadrants */
.context-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow scrolling on smaller screens */
}

.context-panel h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

/* ==========================================
   3. HEADER & NAVIGATION CONTROLS
   ========================================== */
.dash-header {
    height: 60px;
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.dash-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0; 
    flex: 1; 
}

.dash-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Segmented Control Toggle */
.view-toggle {
    display: flex;
    justify-content: center;
    background-color: #191c24; 
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    padding: 2px;
}

.view-toggle input[type="radio"] {
    display: none;
}

.view-toggle label {
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 18px;
    transition: all 0.2s ease-in-out;
}

.view-toggle input[type="radio"]:checked + label {
    background-color: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

#toggle-volcano:checked + label {
    background-color: #ff4757; 
}

#toggle-earthquake:checked + label {
    background-color: #74b9ff; 
}

/* Date & Filter Controls Container */
#date-controls {
    flex: 1; 
    display: flex;
    align-items: center;
    justify-content: flex-end; 
    height: 100%; 
    min-width: 350px; 
}

.control-group {
    display: flex;
    align-items: center;
    justify-content: flex-end; 
    gap: 12px;
    margin: 0; 
    width: 100%; 
}

.control-group label {
    font-weight: bold;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.control-group input[type="number"],
.control-group input[type="date"] {
    background-color: #2a2e39; 
    color: #ffffff;
    border: 1px solid #444c56;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.control-group input[type="number"]:focus,
.control-group input[type="date"]:focus {
    border-color: #74b9ff; 
}

.control-group input[type="number"] {
    width: 65px;
    text-align: center;
}

.control-group .suffix {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-left: -6px; 
}

/* ==========================================
   4. ACTIVE VIEWS & ANIMATION STATES
   ========================================== */
/* Applies to any panel or container swapping context */
.context-view, .context-panel {
    transition: transform 0.4s ease-in-out, opacity 0.4s ease-in-out; 
}

.active-view {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.hidden-view {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

/* Header inputs completely disappear rather than just turning invisible */
#date-controls .hidden-view {
    display: none;
}

/* ==========================================
   5. GLOBE VIEW (Q1)
   ========================================== */
.globe-panel {
    position: relative;
    padding: 0 !important; /* Canvas needs flush edges */
    overflow: hidden;
}

#threejs-canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000; 
}

.globe-overlay-stats {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Globe Legend Overlay */
.globe-overlay-legend {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(18, 18, 18, 0.85); 
    border: 1px solid var(--border-color);
    padding: 12px 15px;
    border-radius: var(--border-radius);
    color: var(--text-main);
    font-size: 0.85rem;
    backdrop-filter: blur(4px);
}

.globe-overlay-legend h4 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-list li {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Legend Icons */
.legend-icon { display: inline-block; }
.dot-red { width: 10px; height: 10px; background-color: #ff4757; border-radius: 50%; box-shadow: 0 0 4px rgba(255, 71, 87, 0.6); }
.dot-blue { width: 8px; height: 8px; background-color: #74b9ff; border-radius: 50%; }
.dot-purple { width: 12px; height: 12px; background-color: #BC13FE; border-radius: 50%; }
.line-blue { width: 14px; height: 2px; background-color: #99ccff; }
.line-green { width: 14px; height: 2px; background-color: #00ff00; }

.legend-interactive {
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
}

.legend-interactive input[type="checkbox"] {
    accent-color: #00ff00;
}

/* ==========================================
   6. METRICS & UNIVERSAL WIDGETS
   ========================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto 1fr;
    gap: 20px;
    height: 100%;
}

.feature-metrics-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-content: start;
}

.span-full {
    grid-column: 1 / -1;
}

/* Individual Data Cards */
.metric-card {
    background: #191c24; 
    border: 1px solid #2a2e39;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Typography Hierarchy */
.metric-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 4px; }
.metric-value-huge { font-size: 1.6rem; font-weight: 700; color: #ffffff; line-height: 1.1; }
.metric-value { font-size: 1.1rem; font-weight: 600; color: #dcdde1; }
.metric-sub-value { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.metric-value-highlight { font-size: 1.2rem; font-weight: bold; color: #ff4757; }

/* Status Pill */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255, 71, 87, 0.15);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    margin-top: auto;
    margin-bottom: auto;
}

/* Mini Inline Gauge */
.mini-gauge-track {
    width: 100%;
    height: 6px;
    background: #2a2e39;
    border-radius: 3px;
    overflow: hidden;
}

.mini-gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4757, #ff7e67);
    width: 0%; 
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Universal Widget Typography Helpers */
.widget-gauge { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.widget-detail { grid-column: 1 / -1; }
.placeholder-text { color: var(--text-muted); font-style: italic; }

table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 10px; border-bottom: 1px solid var(--border-color); }
th { background-color: #2a2a2a; }

/* ==========================================
   7. SPECIFIC CONTEXT PANELS & COMPONENTS
   ========================================== */
.feature-layout {
    display: flex;
    gap: 20px;
    height: 100%;
}

/* Images & Visuals (Q2) */
.feature-image-box {
    width: 250px;
    height: 150px;
    background-color: #191c24; 
    border-radius: 8px; 
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #2a2e39; 
    padding: 4px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.feature-image-box img {
    max-width: 100%;
    max-height: 100%; 
    object-fit: cover; 
    border-radius: 4px;
}

/* Placeholder Graphics */
#volcano-img-placeholder, #quake-img-placeholder {
    text-align: center;
}
#volcano-img-placeholder { color: #57606f; }
#quake-img-placeholder { color: #74b9ff; }
#volcano-img-placeholder svg, #quake-img-placeholder svg { display: block; margin: 0 auto 8px auto; opacity: 0.6; }
#quake-img-placeholder svg { opacity: 0.8; }
#volcano-img-placeholder span, #quake-img-placeholder span {
    display: block; font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
#quake-img-placeholder span { color: #dcdde1; }

/* Geological Categorical Styling (Q3) */
.tectonic-card { border-left: 4px solid #74b9ff; padding-left: 10px; }

.rock-tag-container { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.rock-tag {
    background: linear-gradient(145deg, rgba(116, 185, 255, 0.1), rgba(116, 185, 255, 0.05));
    color: #74b9ff; /* Changes the text to a clear interactive blue */
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(116, 185, 255, 0.3);
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* Adds a tactile 3D drop-shadow */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.rock-tag:hover {
    background: rgba(116, 185, 255, 0.25);
    border-color: #74b9ff;
    color: #ffffff; /* Brightens text on hover */
    transform: translateY(-2px); /* Physically 'lifts' the button */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Adds a push-down effect when clicked */
.rock-tag:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.evidence-card {
    background: rgba(46, 204, 113, 0.05); 
    border: 1px solid rgba(46, 204, 113, 0.2);
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
}

.evidence-badge {
    color: #2ecc71; 
    font-weight: 600;
    font-size: 1.05rem;
    text-transform: capitalize;
}

/* History, Narratives & Timelines (Q4) */
.summary-brief {
    background: linear-gradient(145deg, #1e222b, #15181f); /* Matches the modal's deep background */
    border: 1px solid #444c56;
    border-left: 4px solid #74b9ff; /* Adds a colored accent edge to tie into the UI */
    border-radius: 6px;
    padding: 18px 20px; /* Slightly increased padding for reading margins */
    flex: 1;
    overflow-y: auto;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), 0 4px 10px rgba(0,0,0,0.15);
}

/* Apply the Merriweather font to the summary text */
.summary-brief p {
    font-family: 'Merriweather', serif;
    font-size: 0.95rem; /* Bumped up slightly for better legibility */
    font-weight: 300;
    line-height: 1.7; /* Relaxed line height */
    color: #dcdde1;
    margin: 0;
}

/* Add the classic drop-cap to the summary */
.summary-brief p::first-letter {
    font-size: 1.6rem;
    font-weight: 700;
    color: #74b9ff;
    line-height: 1;
    margin-right: 2px;
}

.action-button-container {
    margin-top: auto; 
    border-top: 1px solid var(--border-color); 
    padding-top: 15px;
    text-align: center;
}

#quake-url a {
    display: inline-block;
    width: 100%;
    background: rgba(116, 185, 255, 0.1);
    color: #74b9ff !important; 
    border: 1px solid #74b9ff;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    text-decoration: none !important;
}

#quake-url a:hover {
    background: #74b9ff;
    color: #121212 !important;
    box-shadow: 0 4px 10px rgba(116, 185, 255, 0.3);
}

.timeline-chart-container {
    height: 50px; 
    display: flex;
    align-items: flex-end; 
    gap: 2px; 
    border-bottom: 1px solid #444c56;
    padding-bottom: 2px;
}

.timeline-bar {
    flex: 1; 
    min-width: 4px;
    border-radius: 2px 2px 0 0;
    transition: filter 0.2s ease;
    cursor: crosshair;
    position: relative;
}

.timeline-bar:hover {
    filter: brightness(1.4);
}

/* Zero-JS Hover Tooltips */
.timeline-bar:hover::after {
    content: attr(data-info); 
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 18, 0.95);
    border: 1px solid #444c56;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    margin-bottom: 6px;
    z-index: 10;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

@keyframes pulse-tsunami {
    0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.4); }
    70% { box-shadow: 0 0 0 12px rgba(255, 71, 87, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

.tsunami-active {
    background: rgba(255, 71, 87, 0.15) !important;
    border-color: rgba(255, 71, 87, 0.4) !important;
    animation: pulse-tsunami 2s infinite;
}

/* ==========================================
   8. MODALS & OVERLAYS
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.hidden-modal {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: linear-gradient(145deg, #1e222b, #15181f); 
    border: 1px solid #444c56;
    border-top: 4px solid #74b9ff; /* Adds a colored accent to the top edge */
    border-radius: 8px;
    width: 90%;
    max-width: 550px; /* Slightly wider for better reading flow */
    padding: 30px; /* Gives the text more breathing room */
    box-shadow: 0 15px 40px rgba(0,0,0,0.7); /* Deep drop shadow */
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.hidden-modal .modal-content {
    transform: translateY(20px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal-eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #74b9ff;
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover {
    color: #ff4757;
}

/* Give the title a printed encyclopedia feel */
.guide-title {
    font-family: 'Merriweather', serif;
    font-size: 1.9rem;
    font-weight: 700;
    color: #ffffff;
    margin: 5px 0 15px 0;
    border-bottom: 1px dashed #444c56; /* Subtle divider line */
    padding-bottom: 15px;
}

/* Improve reading legibility for the main text */
.guide-body p {
    font-family: 'Merriweather', serif;
    font-size: 1rem;
    font-weight: 300; /* Crisp and light weight */
    line-height: 1.8; /* Taller line height for reading comfort */
    color: #dcdde1;
    margin: 0;
}

/* Adds a classic drop-cap to the very first letter of the description */
.guide-body p::first-letter {
    font-size: 1.6rem;
    font-weight: 700;
    color: #74b9ff;
    line-height: 1;
    margin-right: 2px;
}

/* Interactive Text Links */
.interactive-morphology {
    cursor: pointer;
    color: #74b9ff;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 4px;
    transition: color 0.2s ease;
}

.interactive-morphology:hover {
    color: #ff4757;
    text-decoration-style: solid;
}

/* Critical Events Feed */
.events-feed-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feed-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feed-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(4px); /* Slight bump right to indicate interaction */
    border-color: rgba(255, 255, 255, 0.15);
}

.feed-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.9rem;
}

.feed-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.feed-title {
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-arrow {
    font-size: 0.8rem;
    color: #444c56;
    transition: color 0.2s ease;
}

.feed-item:hover .feed-arrow {
    color: #dcdde1;
}

/* Digital Flip-Clock Display */
.time-clock-card {
    background: linear-gradient(180deg, #191c24 0%, #12141a 100%);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
    border: 1px solid #2a2e39;
}

.clock-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin: 10px 0;
    background: #000000;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #444c56;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

.clock-number {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2.8rem;
    font-weight: bold;
    color: #ff4757; /* Volcano Red */
    text-shadow: 0 0 12px rgba(255, 71, 87, 0.4);
    line-height: 1;
}

#clock-quake-val {
    color: #feca57; /* Earthquake Yellow/Orange */
    text-shadow: 0 0 12px rgba(254, 202, 87, 0.4);
}

.clock-unit {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #7f8fa6;
    letter-spacing: 1px;
}