@import url(https://cesium.com/downloads/cesiumjs/releases/1.116/Build/Cesium/Widgets/widgets.css);

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---- Cesium full screen ---- */
#cesiumContainer {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

.cesium-selection-wrapper { display: none !important; }

/* ---- North arrow ---- */
#northArrow {
    position: fixed;
    top: 50px;
    right: 75px;
    width: 50px;
    height: 50px;
    background-image: url('/static/images/north_white.png');
    background-size: contain;
    pointer-events: none;
    z-index: 10000;
}

/* ===================== TOP BAR BUTTONS ===================== */
#topBarButtons {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    display: flex;
    gap: 6px;
    align-items: center;
    width: 290px;
}

#toggleButton,
#backTo2DBtn {
    flex: 1;
    padding: 7px 0;
    text-align: center;
    background: rgba(11, 74, 83, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;

    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: pointer;
    text-decoration: none;

    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    transition: background 0.2s ease;
}

#toggleButton:hover,
#backTo2DBtn:hover {
    background: rgba(11, 74, 83, 1);
}

/* ===================== CARD WRAPPER (single scrollable column) ===================== */
#cardWrapper {
    position: fixed;
    top: 50px;
    left: 12px;
    z-index: 1000;
    width: 290px;
    max-height: calc(100vh - 65px);
    overflow-y: auto;
    scrollbar-width: none;
    display: none; /* JS-controlled */
}

#cardWrapper::-webkit-scrollbar { display: none; }

/* ===================== FLOATING GLASS SIDEBAR ===================== */
#controlContainer {
    padding: 10px 12px 12px;
    background: #ffffff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 18px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18), 0 2px 10px rgba(0, 0, 0, 0.08);
    cursor: default;
    font-size: 12px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #334155;
}

/* ===================== CARD 2: CVM & FILTERS ===================== */
#controlContainer2 {
    margin-top: 8px;
    padding: 10px 12px 12px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 18px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18), 0 2px 10px rgba(0, 0, 0, 0.08);
    cursor: default;
    font-size: 12px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #334155;
}

#controlContainer2 hr {
    border: none;
    border-top: 1px solid #f1f5f9;
    margin: 6px 0;
}

#controlContainer2 span {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

#controlContainer2 #data-file {
    width: 100%;
    margin-bottom: 6px;
}

#distanceDisplay {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

/* ── Panel title ── */
.panel-title {
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    text-align: center;
    margin-bottom: 6px;
}

/* ── 3D Accordion sections ── */
.acc-section {
    border: 1px solid #e8ecf0;
    border-radius: 10px;
    margin-bottom: 5px;
    overflow: hidden;
    background: #f8fafc;
}

.acc-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #334155;
    text-align: left;
    font-family: inherit;
}

.acc-header:hover {
    background: #f1f5f9;
}

.acc-arrow {
    font-size: 10px;
    color: #64748b;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.acc-section:not(.open) .acc-arrow {
    transform: rotate(-90deg);
}

.acc-label {
    flex: 1;
    white-space: nowrap;
}

.acc-body {
    padding: 4px 10px 8px;
}

.acc-section:not(.open) .acc-body {
    display: none;
}

.acc-hint {
    font-size: 10px;
    color: #64748b;
    margin-bottom: 6px;
    line-height: 1.4;
}

/* Scoped labels */
#controlContainer label,
#controlContainer2 label {
    font-size: 12px;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
}

#controlContainer2 b,
.cvm-slider-group b {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Checkbox grid — 2 columns, aligned */
#toggleCheckboxGrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 8px;
}

.eq-size-label {
    font-size: 11px !important;
    color: #64748b !important;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Loading overlay ── */
.viewer3d-loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.6);
    z-index: 2000;
    gap: 12px;
    transition: opacity 0.3s;
}

.viewer3d-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #0b4a53;
    border-radius: 50%;
    animation: v3dspin 0.8s linear infinite;
}

.viewer3d-loading-text {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    font-family: 'Inter', sans-serif;
}

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

#selectHighResFaults {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    padding: 4px;
    font-size: 11px;
    background: white;
    color: #334155;
}

#selectHighResFaults option:checked,
#select2dSurface option:checked {
    background: #e2eef0;
    color: #0b4a53;
}

#loadHighResBtn,
#resetHighResBtn {
    width: 100%;
    margin-top: 6px;
    padding: 6px;
    border-radius: 8px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

#loadHighResBtn {
    background: #0b4a53;
    color: white;
}
#loadHighResBtn:hover { background: #083b42; }

#resetHighResBtn {
    background: transparent;
    color: #475569;
    border: 1px solid #cbd5e1;
}
#resetHighResBtn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #334155;
}

#highResStatus {
    font-size: 11px;
    color: #0b4a53;
    font-weight: 600;
    margin-top: 6px;
}

/* ---- 2D Surfaces section ---- */
#toggleSubductionInterface {
    margin-top: 4px;
    margin-bottom: 4px;
}

#toggleSubductionInterface .surf-label {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    margin: 6px 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: block;
}

#select2dSurface {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
    font-size: 11px;
    background: white;
    color: #334155;
    margin-top: 4px;
}

/* ---- EQ controls ---- */
#eqcontrols {
    margin-top: 6px;
    margin-bottom: 6px;
    background: transparent;
}

/* ---- Sliders ---- */
.sliderContainer {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sliderLabel {
    flex: 1;
    min-width: 0;
    font-size: 9px;
    color: #94a3b8;
    margin-right: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.sliderLabel input[type="range"] {
    flex: 1;
    min-width: 0;
    width: auto;
}

input[type="range"],
input[type="checkbox"] {
    accent-color: #0b4a53;
}

/* noUiSlider-style range inputs */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 3px;
    background: #0b4a53;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 3px;
    background: #0b4a53;
}

input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 3px;
    background: #0b4a53;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #0b4a53;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    margin-top: -5.5px;
}

input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #0b4a53;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

/* ---- Camera / view button row ---- */
#viewButtonsRow {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    margin-top: 4px;
}

#viewButtonsRow label {
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}

#centerViewButton,
#homeViewButton {
    padding: 4px 8px;
    border-radius: 7px;
    border: 1px solid rgba(11, 74, 83, 0.22);
    background: rgba(11, 74, 83, 0.07);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: #0b4a53;
    font-family: 'Inter', -apple-system, sans-serif;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

#centerViewButton:hover,
#homeViewButton:hover {
    background: #0b4a53;
    color: white;
    border-color: #0b4a53;
}

#centerCoordinates {
    flex: 1;
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 5px;
    font-size: 11px;
    color: #334155;
    background: white;
}


/* CVM dropdown */
#data-file {
    flex: 1;
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 11px;
    color: #334155;
    background: white;
}

/* Blue divider for CVM section */
#controlContainer hr[style*="0000FF"],
#controlContainer > div > hr {
    border-color: rgba(11, 74, 83, 0.3) !important;
}

/* ===================== 2D SURFACE LEGEND (bottom-right, above logo) ===================== */
#legend {
    position: fixed;
    bottom: 72px;     /* sits above the CRESCENT logo */
    right: 12px;
    z-index: 10000;

    min-width: 160px;
    max-width: 230px;
    width: auto;
    height: auto;

    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 8px 12px;

    color: #334155;
    font-size: 11px;
    line-height: 1.5;
}

/* Hide entirely when nothing selected */
#legend:empty {
    display: none;
}

/* ===================== BOTTOM COLOR LEGEND ===================== */
#mapControls {
    pointer-events: none;
}

/* Hide the "Color Legend:" text label */
#legendLabel {
    display: none;
}

#legendContainer {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    z-index: 500;

    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 3px 12px;

    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 100px;
    padding: 6px 16px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);

    max-width: 90vw;

    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

#legendContainer.is-closed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(16px);
}

#legendContainer.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* ===================== LEGEND TOGGLE BUTTON ===================== */
.btn-legend-toggle {
    position: fixed;
    right: 15px;
    bottom: 130px;
    z-index: 99999;
    pointer-events: auto;

    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 12px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: rgba(255, 255, 255, 0.92);
    color: #0b4a53;
    border: 1px solid rgba(11, 74, 83, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.btn-legend-toggle svg {
    width: 16px;
    height: 16px;
    display: block;
    fill: currentColor;
    pointer-events: none;
}

.btn-legend-toggle:hover {
    background: rgba(255, 255, 255, 0.98);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.btn-legend-toggle.is-active {
    background: linear-gradient(135deg, #0e7490 0%, #0b4a53 100%);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

/* Legend item row */
.legendItem {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: #475569;
    white-space: nowrap;
    /* override JS-injected inline margins */
    margin: 0 !important;
}

/* Color swatch */
.legendColor {
    width: 11px !important;
    height: 11px !important;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-block !important;
    margin-right: 0 !important;
}

/* Separator between primary and aux legend groups */
.legend-sep {
    width: 1px;
    height: 16px;
    background: #e2e8f0;
    flex-shrink: 0;
}

/* ===================== LOGO ===================== */
#logoContainer {
    position: fixed;
    bottom: 10px;
    right: 12px;
    z-index: 200;
    pointer-events: none;
}

#logoContainer img {
    width: 160px;
    opacity: 0.90;
}

/* distance measurement now lives inside card 2 */
#clearButton {
    margin-right: 6px;
}

/* ===================== MISC ===================== */
.checkboxRow {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}
