:root {
    --mpl-font: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --color-primary: #0284c7;
    --color-primary-dark: #0369a1;
    --color-bg-subtle: #f8fafc;
    --color-border: #e2e8f0;
    --color-text-main: #0f172a;
    --color-text-muted: #64748b;
}

body {
    font-family: var(--mpl-font);
    color: var(--color-text-main);
    background: #ffffff;
    line-height: 1.7;
}

.article-header {
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    border-bottom: 1px solid var(--color-border);
    padding: 56px 0 40px;
}

.article-title {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: #0f172a;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.article-lead {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.article-body {
    font-size: 1.05rem;
    color: #334155;
    padding: 48px 0 80px;
}

.article-body h2 {
    font-size: 1.85rem;
    font-weight: 800;
    color: #0f172a;
    margin-top: 3.5rem;
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
}

.article-body h3 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1e293b;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.article-body p {
    margin-bottom: 1.4rem;
}

/* Interactive map containers */
.map-interactive-container {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.06);
    background: #ffffff;
    margin: 2rem 0;
}

.map-toolbar {
    background: #f8fafc;
    border-bottom: 1px solid var(--color-border);
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tile-count-summary {
    padding: 4px 10px;
    border: 1px solid #bae6fd;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.8rem;
    font-weight: 700;
}

.tile-grid-point-count {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 6px;
    background: #e0f2fe;
    color: #0369a1;
    white-space: nowrap;
}

#tileGridMap, #evaluationMap {
    height: 480px;
    width: 100%;
    background: #f1f5f9;
}

.evaluation-load-error {
    height: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #64748b;
    padding: 24px;
}

#tileGridMap .leaflet-tile,
#evaluationMap .leaflet-tile {
    mix-blend-mode: normal;
}

.leaflet-attribution-flag {
    display: none !important;
}

/* Desaturate and softly blur the OSM basemap so colored score overlays (markers, contours) stand out. */
.map-tiles-grayscale {
    filter: grayscale(1) brightness(1.12) contrast(0.92) blur(0.6px);
}

#evaluationMap .evaluation-amenity-marker,
#evaluationMap .selected-amenity-marker {
    transition: none;
}

#evaluationMap .evaluation-amenity-marker:focus {
    outline: none;
}

/* Calculation Card */
.calc-card {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 20px;
    margin: 1.5rem 0;
}

/* Nested inside .map-interactive-container so it reads as one panel with the map above it */
.calc-card-embedded {
    margin: 0;
    border: none;
    border-top: 1px solid var(--color-border);
    border-radius: 0;
}

.calc-formula {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 0.95rem;
    color: #0369a1;
    margin: 10px 0;
    overflow-x: auto;
}

/* Stacked Bars */
.bars-container {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 20px;
    margin: 1.5rem 0;
}

.bar-track {
    position: relative;
    height: 32px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    border: 1px solid #cbd5e1;
}

.bar-capacity {
    height: 100%;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--segment-color) 18%, white);
}

.bar-capacity + .bar-capacity {
    border-left: 1px solid rgba(255, 255, 255, 0.8);
}

.bar-segment {
    height: 100%;
    background: var(--segment-color);
    transition: width 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
    cursor: default;
}

.bar-segment:hover {
    filter: brightness(1.1);
}

/* Subgroup Table */
.subgroup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.subgroup-table th {
    background: #f8fafc;
    border-bottom: 2px solid var(--color-border);
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    color: #334155;
}

.subgroup-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.subgroup-table tr:hover {
    background: #f8fafc;
}

.winner-row-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: left;
}

.winner-row-btn:hover,
.winner-row-btn:focus-visible {
    text-decoration: underline;
}

.subgroup-table tfoot td {
    font-weight: 800;
    background: #f1f5f9;
    border-top: 2px solid #cbd5e1;
    border-bottom: none;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.notice-box {
    background: #f0fdf4;
    border-left: 4px solid #16a34a;
    padding: 16px 20px;
    border-radius: 0 8px 8px 0;
    margin: 1.75rem 0;
    font-size: 0.95rem;
    color: #14532d;
}

.overall-rating-layout {
    display: grid;
    grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.7fr);
    gap: 2rem;
    align-items: start;
    margin: 1.5rem 0 2.5rem;
}

.overall-rating-image {
    display: block;
    width: 100%;
    max-width: 290px;
    height: auto;
    margin: 0 auto;
}

.overall-rating-copy > :last-child {
    margin-bottom: 0;
}

/* Score-to-contour pipeline */
.contour-pipeline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr);
    align-items: center;
    margin: 2rem 0;
}

.contour-pipeline-step {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 8px 20px -12px rgba(15, 23, 42, 0.3);
}

.contour-pipeline-visual {
    padding: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--color-border);
}

.contour-pipeline svg {
    display: block;
    width: 100%;
    height: auto;
}

.contour-pipeline figcaption {
    min-height: 88px;
    padding: 14px 16px;
    line-height: 1.4;
}

.contour-pipeline figcaption strong,
.contour-pipeline figcaption span {
    display: block;
}

.contour-pipeline figcaption strong {
    color: #1e293b;
    font-size: 0.9rem;
}

.contour-pipeline figcaption span {
    margin-top: 4px;
    color: var(--color-text-muted);
    font-size: 0.78rem;
}

.contour-pipeline-arrow {
    color: var(--color-primary);
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
}

.score-grid-lines path {
    fill: none;
    stroke: #cbd5e1;
    stroke-width: 1;
}

.score-grid-values text {
    font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace;
    text-anchor: middle;
}

/* Circle fill intensity scales with the underlying score value: darker blue = higher score */
.score-cell-1 circle { fill: #e0f2fe; stroke: #7dd3fc; stroke-width: 1.5; }
.score-cell-2 circle { fill: #bae6fd; stroke: #38bdf8; stroke-width: 1.5; }
.score-cell-3 circle { fill: #7dd3fc; stroke: #0ea5e9; stroke-width: 1.5; }
.score-cell-4 circle { fill: #38bdf8; stroke: #0284c7; stroke-width: 1.5; }
.score-cell-5 circle { fill: #0284c7; stroke: #075985; stroke-width: 1.5; }
.score-cell-6 circle { fill: #075985; stroke: #0c4a6e; stroke-width: 1.5; }

.score-cell-1 text, .score-cell-2 text, .score-cell-3 text { fill: #075985; }
.score-cell-4 text, .score-cell-5 text, .score-cell-6 text { fill: #ffffff; }

.contour-source-points circle {
    fill: #cbd5e1;
}

.contour-line {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.contour-line-low { stroke: #3b82f6; }
.contour-line-mid { stroke: #eab308; }
.contour-line-high { stroke: #ef4444; fill: rgba(239, 68, 68, 0.12); }

.contour-crossings circle {
    fill: #ffffff;
    stroke: #0f172a;
    stroke-width: 1.5;
}

.contour-map-blocks rect {
    fill: #e2e8f0;
}

.contour-map-park {
    fill: #dcfce7;
}

.contour-map-roads path {
    fill: none;
    stroke: #ffffff;
    stroke-width: 5;
    stroke-linecap: round;
}

.contour-map-roads-outline path {
    fill: none;
    stroke: #cbd5e1;
    stroke-width: 7;
    stroke-linecap: round;
}

.contour-area {
    stroke-width: 2;
}

.contour-area-low { fill: rgba(59, 130, 246, 0.2); stroke: #3b82f6; }
.contour-area-mid { fill: rgba(234, 179, 8, 0.28); stroke: #eab308; }
.contour-area-high { fill: rgba(239, 68, 68, 0.3); stroke: #ef4444; }

@media (max-width: 767.98px) {
    #tileGridMap, #evaluationMap, .evaluation-load-error {
        height: 350px;
    }

    .overall-rating-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.25rem;
    }

    .overall-rating-image {
        max-width: 260px;
    }

    .contour-pipeline {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .contour-pipeline-arrow {
        line-height: 1;
        transform: rotate(90deg);
    }

    .contour-pipeline figcaption {
        min-height: 0;
    }
}

/* Geometry visualizer canvas */
.canvas-container {
    position: relative;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    margin: 2rem 0;
}

#geometryCanvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 900 / 440;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

/* Primitive Tags Card */
.text-bars-pubs {
    /* Darker than Bootstrap's default text-warning (#ffc107, ~1.6:1 on white) to meet WCAG AA (4.5:1) */
    color: #b45309;
}

.primitive-tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 1.5rem 0;
}

.primitive-tag-card {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
}

.primitive-tag-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}

.primitive-tag-list li {
    padding: 4px 0;
    font-size: 0.88rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed #e2e8f0;
}

.primitive-tag-list li:last-child {
    border-bottom: none;
}

.primitive-tag-list code {
    color: #0369a1;
    font-size: 0.82rem;
}
