/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1a1a2e;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ── Header ────────────────────────────────────────────────────── */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

#header h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 13px;
    opacity: 0.7;
}

.header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.header-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Text variant of the header button (e.g. Methodology, Detailed links) */
.header-btn-text {
    width: auto;
    height: 28px;
    padding: 0 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* ── Info icons + popover ─────────────────────────────────────── */
.info-icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: none;
    background: #d0d0d6;
    color: #444;
    font-size: 10px;
    font-style: italic;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 14px;
    text-align: center;
    padding: 0;
    cursor: pointer;
    margin-left: 4px;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.info-icon:hover,
.info-icon:focus {
    background: #1a1a2e;
    color: #fff;
    outline: none;
}

.info-popover {
    position: fixed;
    display: none;
    max-width: 220px;
    background: #fff;
    color: #1a1a2e;
    border: 1px solid #d0d0d6;
    border-radius: 8px;
    padding: 10px;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 3000;
    pointer-events: auto;
}

/* ── Map ───────────────────────────────────────────────────────── */
#map {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 0;
    width: 280px;
    background: #fff;
    z-index: 500;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    transition: transform 0.25s ease;
}

.sidebar.collapsed {
    transform: translateX(-280px);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e8e8ec;
}

.sidebar-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
}

.sidebar-open-btn {
    position: fixed;
    top: 60px;
    left: 8px;
    z-index: 499;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 28px;
    height: 40px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* ── Layer Groups ──────────────────────────────────────────────── */
.layer-group {
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f4;
}

.layer-group h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #888;
    margin-bottom: 6px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
}

.toggle input[type="checkbox"] {
    accent-color: #1a1a2e;
}

.radio-group {
    display: flex;
    gap: 16px;
}

.radio-group label {
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Color Dots ────────────────────────────────────────────────── */
.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-heat { background: #e63946; }
.dot-flood { background: #457b9d; }
.dot-canopy { background: #2d6a4f; }
.dot-pave { background: #7b2d8e; }

/* ── Stats Panel ───────────────────────────────────────────────── */
.stats-panel {
    padding: 12px 16px;
    border-top: 1px solid #e8e8ec;
    background: #fafafa;
    max-height: 200px;
    overflow-y: auto;
}

.stats-panel h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #888;
    margin-bottom: 8px;
}

.stats-placeholder {
    font-size: 12px;
    color: #aaa;
    font-style: italic;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 2px 0;
}

.stat-row .label {
    color: #666;
}

.stat-row .value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Info Panel ────────────────────────────────────────────────── */
.info-panel {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 320px;
    max-height: 400px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 600;
    overflow: hidden;
}

.info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #1a1a2e;
    color: #fff;
}

.info-header h3 {
    font-size: 13px;
    font-weight: 600;
}

.info-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

#info-content {
    padding: 12px 14px;
    overflow-y: auto;
    max-height: 340px;
    font-size: 13px;
}

#info-content table {
    width: 100%;
    border-collapse: collapse;
}

#info-content td {
    padding: 3px 0;
    border-bottom: 1px solid #f0f0f4;
}

#info-content td:first-child {
    color: #888;
    width: 45%;
}

#info-content td:last-child {
    font-weight: 500;
    text-align: right;
}

/* Score bars */
.score-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-bar-track {
    flex: 1;
    height: 6px;
    background: #e8e8ec;
    border-radius: 3px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.score-value {
    font-size: 11px;
    font-weight: 600;
    width: 36px;
    text-align: right;
}

/* ── Legend ─────────────────────────────────────────────────────── */
.legend {
    position: fixed;
    bottom: 16px;
    left: 296px;
    background: #fff;
    border-radius: 6px;
    padding: 10px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 400;
    font-size: 12px;
    max-width: 200px;
    transition: left 0.25s ease;
}

.sidebar.collapsed ~ .legend {
    left: 16px;
}

.legend h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

.legend-swatch {
    width: 16px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.1);
}

/* ── QA additions ──────────────────────────────────────────────── */
.opacity-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 4px;
    font-size: 11px;
    color: #888;
}
.opacity-row input[type=range] {
    flex: 1;
    accent-color: #457b9d;
}
.feat-source {
    margin-top: 10px;
    font-size: 10px;
    color: #999;
}
.feat-source code {
    background: #eee;
    padding: 1px 4px;
    border-radius: 3px;
}
table.attrs {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}
table.attrs td {
    padding: 2px 4px;
    border-bottom: 1px solid #eee;
    word-break: break-word;
}
table.attrs td:first-child {
    color: #666;
    white-space: nowrap;
    width: 40%;
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 540px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-content h2 {
    font-size: 20px;
    margin-bottom: 12px;
}

.modal-content h3 {
    font-size: 14px;
    margin-top: 16px;
    margin-bottom: 8px;
}

.modal-content p, .modal-content li {
    font-size: 14px;
    line-height: 1.5;
    color: #444;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content a {
    color: #457b9d;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #888;
}
