html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

.app-shell {
    min-height: 100vh;
    padding-bottom: 0;
}

.page-title {
    margin: 0.75rem 0 0.25rem;
    text-align: center;
}

.page-subtitle {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0 auto 0.75rem;
    max-width: min(96ch, 100%);
    text-align: center;
}

.map-panel-unavailable {
    align-items: center;
    background-color: #f8f9fa;
    border: 1px dashed #ced4da;
    color: #6c757d;
    display: flex;
    font-size: 0.9rem;
    justify-content: center;
    padding: 1rem;
    text-align: center;
}

.page-updated {
    color: #6c757d;
    font-size: 0.8rem;
    margin: 0 auto 0.5rem;
    text-align: center;
}

.emergency-notice {
    background-color: #fff4f4;
    border: 1px solid #f1c2c2;
    border-radius: 0.375rem;
    color: #713b3b;
    font-size: 0.85rem;
    line-height: 1.45;
    margin: 0.75rem auto;
    max-width: min(104ch, 100%);
    padding: 0.6rem 0.9rem;
    text-align: center;
}

.emergency-notice strong {
    color: #a12626;
}

.map-wrapper {
    position: relative;
}

.map-panel {
    width: 100%;
    height: min(72vh, 52rem);
    min-height: 24rem;
    border-radius: 0.5rem;
}

.map-loading {
    align-items: center;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 0.5rem;
    bottom: 0;
    display: flex;
    justify-content: center;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 1000;
}

.map-loading-inner {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.incident-table-panel {
    margin-top: 0.5rem;
}

.incident-table-toggle {
    color: #6c757d;
    cursor: pointer;
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-wrap: wrap;
}

.incident-table-toggle-hint {
    color: #6c757d;
}

.incident-table-wrapper {
    max-height: clamp(16rem, 34vh, 30rem);
    background-color: #fff;
    border-radius: 0.5rem;
    overflow: auto;
}

.incident-table {
    margin-bottom: 0;
}

.incident-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: #f8f9fa;
}

.incident-row-fire {
    border-left: 4px solid #dc3545;
}

.incident-row-medical {
    border-left: 4px solid #0d6efd;
}

.incident-row-other {
    border-left: 4px solid #6c757d;
}

.incident-badge {
    font-weight: 600;
}

.incident-badge-fire {
    background-color: #dc3545;
}

.incident-badge-medical {
    background-color: #0d6efd;
}

.incident-badge-other {
    background-color: #6c757d;
}

.incident-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.incident-chip {
    border-radius: 1rem;
    color: #fff;
    display: inline-block;
    font-size: 0.85rem;
    padding: 0.25rem 0.65rem;
}

.filter-btn {
    border: none;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.15s;
}

.filter-btn.filter-btn-active {
    opacity: 1;
}

.incident-row-selected {
    outline: 2px solid #ffc107;
    outline-offset: -2px;
}

.refresh-badge {
    color: #6c757d;
    font-size: 0.8rem;
    margin-left: auto;
    padding: 0.25rem 0;
}

.site-footer {
    border-top: 1px solid #dee2e6;
    color: #6c757d;
    font-size: 0.85rem;
    margin-top: 1rem;
    padding: 0.75rem 0;
    text-align: center;
}

.site-footer a {
    color: #6c757d;
}

.site-footer-sep {
    margin: 0 0.4rem;
}

.incident-chip-fire {
    background-color: #dc3545;
}

.incident-chip-medical {
    background-color: #0d6efd;
}

.incident-chip-other {
    background-color: #6c757d;
}

.incident-chip-closed {
    background-color: #495057;
    border: 1px dashed #adb5bd;
}

/* ---- Closed / recently-resolved incidents ---- */

.incident-badge-closed {
    background-color: #495057;
    font-weight: 600;
}

.incident-status-active {
    color: #198754;
    font-weight: 600;
}

.incident-row-closed td {
    opacity: 0.7;
}

.incident-row-closed td:has(.incident-badge-closed) {
    opacity: 1;
}

.incident-hidden {
    display: none !important;
}

html.dark-mode .incident-status-active {
    color: #4ade80;
}

/*
 * Always set the map height explicitly to define the size of the div element
 * that contains the map.
 */
#map {
    width: 100%;
}

/* ---- Settings panel ---- */

.map-settings-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1001;
}

.map-settings-btn {
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 7px;
    transition: background 0.15s;
}

.map-settings-btn:hover {
    background: #f4f4f4;
}

.map-settings-panel {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    min-width: 230px;
    padding: 0.6rem 0.75rem;
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
}

.map-settings-title {
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.map-settings-item {
    align-items: center;
    cursor: pointer;
    display: flex;
    font-size: 0.875rem;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    user-select: none;
}

.map-settings-item:last-child {
    margin-bottom: 0;
}

.map-settings-item input[type="checkbox"] {
    cursor: pointer;
}

/* ---- Dark mode ---- */

html.dark-mode body {
    background-color: #1e2124;
    color: #dee2e6;
}

html.dark-mode .page-subtitle {
    color: #adb5bd;
}

html.dark-mode .map-loading {
    background: rgba(20, 20, 25, 0.85);
    color: #dee2e6;
}

html.dark-mode .incident-table-panel summary {
    color: #adb5bd;
}

html.dark-mode .incident-table-toggle-hint {
    color: #6c757d;
}

html.dark-mode .incident-table-wrapper {
    background-color: #2c2f33;
}

html.dark-mode .incident-table {
    --bs-table-bg: #2c2f33;
    --bs-table-color: #dee2e6;
    --bs-table-border-color: #3d4045;
    --bs-table-hover-bg: #343a40;
    --bs-table-hover-color: #dee2e6;
}

html.dark-mode .incident-table thead th {
    background-color: #343a40;
    color: #dee2e6;
}

html.dark-mode .refresh-badge {
    color: #adb5bd;
}

html.dark-mode .site-footer {
    border-color: #3d4045;
    color: #6c757d;
}

html.dark-mode .site-footer a {
    color: #6c757d;
}

html.dark-mode .map-panel-unavailable {
    background-color: #2c2f33;
    border-color: #3d4045;
    color: #adb5bd;
}

html.dark-mode .page-updated {
    color: #adb5bd;
}

html.dark-mode .emergency-notice {
    background-color: #3a2626;
    border-color: #5c3a3a;
    color: #e8b4b4;
}

html.dark-mode .emergency-notice strong {
    color: #ff8080;
}

html.dark-mode .alert-warning {
    background-color: #3d3000;
    border-color: #5c4800;
    color: #ffe066;
}

html.dark-mode .map-settings-btn {
    background: #2c2f33;
    border-color: #555;
    color: #dee2e6;
}

html.dark-mode .map-settings-btn:hover {
    background: #343a40;
}

html.dark-mode .map-settings-panel {
    background: #2c2f33;
    border-color: #4a4d52;
    color: #dee2e6;
}

html.dark-mode .map-settings-title {
    color: #adb5bd;
}

@media (min-width: 1200px) {
    .map-panel {
        height: min(74vh, 56rem);
    }

    .map-loading {
        border-radius: 0.5rem;
    }

    .incident-table-wrapper {
        max-height: clamp(18rem, 28vh, 24rem);
    }
}

@media (max-width: 767.98px) {
    .incident-table-wrapper {
        max-height: none;
        overflow: visible;
    }

    .incident-table thead {
        display: none;
    }

    .incident-table,
    .incident-table tbody,
    .incident-table tr,
    .incident-table td {
        display: block;
        width: 100%;
    }

    .incident-table tr {
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        margin-bottom: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .incident-table td {
        border: 0;
        border-bottom: 1px solid #f1f3f5;
        display: flex;
        gap: 0.5rem;
        justify-content: space-between;
        padding: 0.45rem 0;
        text-align: right;
    }

    .incident-table td:last-child {
        border-bottom: 0;
    }

    .incident-table td::before {
        color: #495057;
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
    }
}


/* ---- Long-form prose (homepage notes and /about) ---- */

.page-notes,
.prose-page {
    color: #495057;
    font-size: 0.92rem;
    line-height: 1.6;
    margin: 1.5rem auto 0;
    max-width: min(104ch, 100%);
}

.prose-page {
    margin-top: 1rem;
    padding-bottom: 1rem;
}

.page-notes h2,
.prose-page h2 {
    font-size: 1.15rem;
    margin-top: 1.5rem;
}

.page-notes h3,
.prose-page h3 {
    font-size: 1rem;
    margin-top: 1.25rem;
}

.prose-lead {
    font-size: 1rem;
}

.page-notes code,
.prose-page code {
    background-color: #f1f3f5;
    border-radius: 0.2rem;
    font-size: 0.85em;
    padding: 0.1rem 0.3rem;
}

.page-notes-more,
.prose-back {
    margin-top: 1.25rem;
}

html.dark-mode .page-notes,
html.dark-mode .prose-page {
    color: #ced4da;
}

html.dark-mode .page-notes code,
html.dark-mode .prose-page code {
    background-color: #2c2f33;
}

/* ---- Collapsible "About this incident map" ---- */

.page-notes > summary {
    cursor: pointer;
    list-style: none;
}

.page-notes > summary::-webkit-details-marker {
    display: none;
}

.page-notes-toggle h2 {
    align-items: center;
    display: inline-flex;
    gap: 0.4rem;
    margin: 0;
}

/* Rotates to point down when the section is open. */
.page-notes-toggle h2::before {
    border-left: 0.4em solid currentColor;
    border-top: 0.3em solid transparent;
    border-bottom: 0.3em solid transparent;
    content: "";
    display: inline-block;
    transition: transform 0.15s ease;
}

.page-notes[open] > summary .page-notes-toggle h2::before,
.page-notes[open] > .page-notes-toggle h2::before {
    transform: rotate(90deg);
}

.page-notes > summary:hover h2 {
    color: #6c757d;
}

.page-about-link {
    font-size: 0.9rem;
    margin: 0 auto 0.75rem;
    text-align: center;
}

html.dark-mode .page-notes > summary:hover h2 {
    color: #adb5bd;
}

/* ---- Live summary ---- */

.live-summary {
    margin: 0 auto 0.5rem;
    max-width: min(104ch, 100%);
    text-align: center;
}

.live-summary-question {
    color: #6c757d;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin: 0 0 0.15rem;
}

.live-summary-answer {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

/*
 * Reads as a footnote to the answer above it, not a second answer. The amber is darker
 * than it looks like it needs to be: at this size it is normal-weight text as far as WCAG
 * is concerned, and the obvious #b06a00 lands at 4.3:1 on white, just under AA.
 */
.live-summary-dispatch {
    color: #9a5c00;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

html.dark-mode .live-summary-question {
    color: #adb5bd;
}

html.dark-mode .live-summary-dispatch {
    color: #f0ad4e;
}

/* ---- Install prompt ---- */

.install-bar {
    align-items: center;
    background-color: #eef4ff;
    border: 1px solid #c9dcff;
    border-radius: 0.375rem;
    display: flex;
    flex-wrap: wrap;
    font-size: 0.875rem;
    gap: 0.6rem;
    justify-content: center;
    margin: 0 auto 0.75rem;
    max-width: min(104ch, 100%);
    padding: 0.5rem 0.75rem;
}

.install-bar[hidden] {
    display: none;
}

.install-bar-text {
    color: #21426f;
}

.install-bar-btn {
    background-color: #0d6efd;
    border: 0;
    border-radius: 0.25rem;
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0.85rem;
}

.install-bar-btn:hover {
    background-color: #0b5ed7;
}

.install-bar-dismiss {
    background: none;
    border: 0;
    color: #21426f;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.6;
    padding: 0 0.25rem;
}

.install-bar-dismiss:hover {
    opacity: 1;
}

html.dark-mode .install-bar {
    background-color: #1c2a3f;
    border-color: #2f4569;
}

html.dark-mode .install-bar-text,
html.dark-mode .install-bar-dismiss {
    color: #b7cdf0;
}

/* ---- Newly arrived incidents ---- */
/*
 * A call that appeared on the last refresh is marked briefly, because the page no longer
 * reloads: without this, new rows would simply materialise with nothing to draw the eye.
 */

.incident-row-new {
    animation: incident-arrive 2.5s ease-out 3;
}

@keyframes incident-arrive {
    0%, 100% { background-color: transparent; }
    25% { background-color: rgba(255, 193, 7, 0.28); }
}

.marker-new {
    animation: marker-arrive 1.6s ease-out 6;
}

@keyframes marker-arrive {
    0%, 100% { stroke-width: 1; }
    50% { stroke-width: 6; }
}

html.dark-mode .incident-row-new {
    animation-name: incident-arrive-dark;
}

@keyframes incident-arrive-dark {
    0%, 100% { background-color: transparent; }
    25% { background-color: rgba(255, 193, 7, 0.22); }
}

/* ---- Keyboard focus ---- */
/* The rows respond to a click, so they have to be reachable and visible without a mouse. */

.incident-table tbody tr:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

.filter-btn:focus-visible,
.install-bar-btn:focus-visible,
.install-bar-dismiss:focus-visible,
.map-settings-btn:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .incident-row-new,
    .marker-new {
        animation: none;
    }

    .incident-row-new {
        background-color: rgba(255, 193, 7, 0.22);
    }
}
