/* ── Brand typeface: Zed Display (ONE Architecture standard sans), self-hosted ── */
@font-face { font-family:"Zed Display"; src:url("fonts/zed/ZedDisplay-Regular.woff2") format("woff2"); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:"Zed Display"; src:url("fonts/zed/ZedDisplay-Bold.woff2") format("woff2"); font-weight:700; font-style:normal; font-display:swap; }
@font-face { font-family:"Zed Display SC"; src:url("fonts/zed/ZedDisplaySemiCondensed-Heavy.woff2") format("woff2"); font-weight:800; font-style:normal; font-display:swap; }

/* ── Design tokens ──────────────────────────────────────────────
   Neo-brutalist editorial theme on ONE Architecture brand: cream paper
   (--primary-cream), near-black ink, hard 2px borders + offset shadows,
   Zed Display (brand sans) + Space Mono for data. */
:root {
    /* Tonal hierarchy from ONE's neutrals so surfaces read with depth:
       white floating panels/buttons (lifted) > cream header bands >
       off-white sidebar (recessed). */
    --paper:   #FFFFFF;   /* white — floating panels, buttons (lift) */
    --cream:   #FBF5E0;   /* ONE brand cream — header bands          */
    --sidebar: #FFFFFF;   /* white — sidebar content (under LAYERS)   */
    --cream-2: #E2DECF;   /* deeper warm tone — wells / data tracks  */
    --ink:    #121212;
    --muted:  #6c6a5e;
    --amber:  #ffb462;   /* ONE rust                          */
    --coral:  #962205;   /* ONE dark rust (accents)           */
    --line:   #121212;   /* hard borders are full black      */
    --hairline: rgba(18,18,18,0.12);
    --shadow:   4px 4px 0 var(--ink);
    --shadow-sm: 2px 2px 0 var(--ink);
    --grotesk: "Zed Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --display: "Zed Display SC", "Zed Display", sans-serif;
    --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

body {
    font-family: var(--grotesk);
    color: var(--ink);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Shared section micro-label (sans, matches home-page title face) */
.eyebrow, .layer-group h3, .stats-panel h3, .legend h4 {
    font-family: var(--grotesk);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ── Header ────────────────────────────────────────────────────── */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--cream);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    border-bottom: 2px solid var(--ink);
}

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

#header h1 {
    font-family: var(--display);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex: none;
}

.subtitle {
    /* Place name = same display face/weight/case as the "DEPAVE" wordmark,
       just grey instead of black — reads as one two-tone title. */
    font-family: var(--display);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
}

.header-btn {
    background: var(--paper);
    border: 2px solid var(--ink);
    color: var(--ink);
    width: 28px;
    height: 28px;
    border-radius: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.header-btn:hover {
    background: var(--amber);
}

.header-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 var(--ink);
}

/* Text variant of the header button (e.g. Methodology, Detailed links) */
.header-btn-text {
    width: auto;
    height: 28px;
    padding: 0 12px;
    border-radius: 0;
    font-family: var(--grotesk);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
}

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

/* ── Info icons + popover ─────────────────────────────────────── */
.info-icon {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1.5px solid #5a5a5a;
    background: var(--paper);
    color: #5a5a5a;
    font-size: 10px;
    font-style: normal;
    font-weight: 700;
    font-family: var(--mono);
    line-height: 12px;
    text-align: center;
    padding: 0;
    cursor: pointer;
    margin-left: 4px;
    flex-shrink: 0;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.info-icon:hover,
.info-icon:focus {
    background: var(--amber);
    color: var(--ink);
    border-color: var(--ink);
    outline: none;
}

.info-popover {
    position: fixed;
    display: none;
    max-width: 220px;
    background: var(--paper);
    color: var(--ink);
    border: 2px solid var(--ink);
    border-radius: 0;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.45;
    box-shadow: var(--shadow);
    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: var(--sidebar);
    z-index: 500;
    display: flex;
    flex-direction: column;
    border-right: 2px solid var(--ink);
    transition: transform 0.25s ease;
}

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

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--cream);
    border-bottom: 2px solid var(--ink);
}

.sidebar-header h2 {
    font-family: var(--grotesk);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--ink);
    padding: 0 4px;
    line-height: 1;
}

.sidebar-open-btn {
    position: fixed;
    top: 60px;
    left: 8px;
    z-index: 499;
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0;
    width: 30px;
    height: 42px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: var(--shadow-sm);
}

.sidebar-open-btn:hover { background: var(--amber); }

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

/* ── Layer Groups ──────────────────────────────────────────────── */
.layer-group {
    padding: 10px 16px;
    border-bottom: 1px solid var(--hairline);
}

.layer-group h3 {
    font-size: 10px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 7px;
}

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

.toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid var(--ink);
    border-radius: 0;
    background: var(--paper);
    cursor: pointer;
    position: relative;
    transition: background 0.1s ease;
}
.toggle input[type="checkbox"]:checked {
    background: var(--ink);
}
.toggle input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 0;
    width: 4px;
    height: 8px;
    border: solid var(--paper);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.toggle input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--coral);
    outline-offset: 1px;
}

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

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

.radio-group input[type="radio"] { accent-color: var(--ink); }

/* ── Color Dots ────────────────────────────────────────────────── */
.dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1px solid var(--ink);
}

.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: 2px solid var(--ink);
    background: var(--cream-2);
    max-height: 200px;
    overflow-y: auto;
}

.stats-panel h3 {
    font-size: 10px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.stats-placeholder {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 3px 0;
    border-bottom: 1px solid var(--hairline);
}

.stat-row .label {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
}

.stat-row .value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
}

/* ── Info Panel (top-left, shifts with sidebar) ───────────────── */
.info-panel {
    position: fixed;
    top: 60px;
    left: 296px;
    width: 320px;
    max-height: 400px;
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0;
    box-shadow: var(--shadow);
    z-index: 600;
    overflow: hidden;
    transition: left 0.25s ease;
}
.sidebar.collapsed ~ .info-panel,
body:has(.sidebar.collapsed) .info-panel {
    left: 12px;
}

.info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--ink);
    color: var(--cream);
}

.info-header h3 {
    font-family: var(--grotesk);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.info-close {
    background: none;
    border: none;
    color: var(--cream);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

#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: 4px 0;
    border-bottom: 1px solid var(--hairline);
}

#info-content td:first-child {
    color: var(--muted);
    width: 45%;
    font-family: var(--mono);
    font-size: 11px;
}

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

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

.score-bar-track {
    flex: 1;
    height: 8px;
    background: var(--cream-2);
    border: 1px solid var(--ink);
    border-radius: 0;
    overflow: hidden;
}

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

.score-value {
    font-size: 11px;
    font-weight: 700;
    font-family: var(--mono);
    width: 36px;
    text-align: right;
}

/* ── Legend ─────────────────────────────────────────────────────── */
.legend {
    position: fixed;
    top: 60px;
    left: 296px;
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0;
    padding: 11px 14px;
    box-shadow: var(--shadow);
    z-index: 400;
    font-size: 12px;
    max-width: 220px;
    transition: left 0.25s ease;
}

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

.legend h4 {
    font-size: 10px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 7px;
}

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

/* ── Donut Chart ───────────────────────────────────────────────── */
.donut-panel {
    position: fixed;
    bottom: 16px;
    left: 296px;
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0;
    box-shadow: var(--shadow);
    z-index: 600;
    padding: 14px 16px 12px;
    text-align: center;
    width: 260px;
    transition: left 0.25s ease;
}
.sidebar.collapsed ~ .donut-panel {
    left: 16px;
}
#donut-canvas {
    display: block;
    margin: 0 auto;
}
#donut-legend {
    margin-top: 10px;
    font-size: 11px;
    line-height: 1.6;
    text-align: left;
}
#donut-legend .dl-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
#donut-legend .dl-swatch {
    width: 11px;
    height: 11px;
    border-radius: 0;
    border: 1px solid var(--ink);
    flex-shrink: 0;
}
#donut-legend .dl-label {
    flex: 1;
    color: var(--ink);
}
#donut-legend .dl-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
    color: var(--ink);
}

.legend-swatch {
    width: 16px;
    height: 12px;
    border-radius: 0;
    border: 1px solid var(--ink);
}

/* ── QA additions ──────────────────────────────────────────────── */
.opacity-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 4px;
    font-family: var(--grotesk);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.opacity-row input[type=range] {
    flex: 1;
    accent-color: var(--coral);
}
.feat-source {
    margin-top: 10px;
    font-size: 10px;
    color: var(--muted);
    font-family: var(--mono);
}
.feat-source code {
    background: var(--cream-2);
    border: 1px solid var(--hairline);
    padding: 1px 4px;
    border-radius: 0;
}
table.attrs {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}
table.attrs td {
    padding: 3px 4px;
    border-bottom: 1px solid var(--hairline);
    word-break: break-word;
}
table.attrs td:first-child {
    color: var(--muted);
    white-space: nowrap;
    width: 40%;
    font-family: var(--mono);
}

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

.modal-content {
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0;
    box-shadow: var(--shadow);
    padding: 28px 32px;
    max-width: 540px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-content h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

.modal-content h3 {
    font-family: var(--grotesk);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 18px;
    margin-bottom: 8px;
}

.modal-content p, .modal-content li {
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
}

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

.modal-content a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 2px solid var(--amber);
}
.modal-content a:hover { background: var(--amber); }

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: var(--paper);
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-sm);
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    color: var(--ink);
    line-height: 1;
}
.modal-close:hover { background: var(--coral); color: #fff; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
