/* ===== Chalk theme tokens (mirrors static/css/edu-theme.css :root) =====
   This page is a standalone map app (doesn't extend base.html), so the
   tokens are re-declared here rather than pulled in, exactly matching
   edu-theme.css's values/names so a future retheme is a one-line change.
   Map tile colors are third-party content and are NOT touched anywhere
   in this file -- only sidebar/controls/chrome are retheme'd. */
:root {
    --primary-dark: #F6F4F1;      /* page background ("paper") */
    --secondary-dark: #FFFFFF;    /* surface (sidebar, panels) */
    --tertiary-dark: #EFEAE6;     /* elevated surface / hover */
    --accent-blue: #96305F;       /* "plum" -- primary accent */
    --accent-purple: #D9A441;     /* "gold" -- sparing highlight (AI-named badge) */
    --accent-green: #2F7A6B;      /* "teal" -- sparing secondary accent */
    --accent-deep: #7A2650;       /* darker plum, for text-on-white */
    --text-primary: #1B1720;      /* ink */
    --text-secondary: #565160;    /* ink-soft */
    --text-muted: #8B8494;        /* ink-faint */
    --hairline: #E3DFD9;
}

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--primary-dark);
    color: var(--text-primary);
}

/* ===== Back Button (legacy class, currently unused in markup -- themed
   for consistency in case it's reintroduced) ===== */
.back-btn {
    position: fixed;
    top: 12px;
    right: 16px;
    left: auto;
    z-index: 1100;
    background: var(--secondary-dark);
    color: var(--accent-deep);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    backdrop-filter: blur(6px);
    border: 1px solid var(--hairline);
    transition: background 0.2s, color 0.2s;
}
.back-btn:hover {
    background: var(--tertiary-dark);
    color: var(--accent-blue);
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--secondary-dark);
    border-right: 1px solid var(--hairline);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--hairline);
    position: relative;
    flex-shrink: 0;
}

.sidebar-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.sidebar-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.sidebar-toggle {
    display: none;
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: 1px solid var(--hairline);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--hairline);
    border-radius: 2px;
}

.sidebar-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== Category Tree (group -> type, collapsible) =====
   --cat-color is set per-category by JS (poi_taxonomy.js) -- that's
   informational category color-coding, not brand decoration, so it's
   left alone; only the neutral chrome around it is retheme'd. */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.group-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.group-btn, .category-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--cat-color, var(--hairline));
    border-radius: 8px;
    padding: 9px 12px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    transition: background 0.15s;
    width: 100%;
    background: color-mix(in srgb, var(--cat-color, transparent) 10%, var(--tertiary-dark));
}

.group-btn:hover, .category-btn:hover {
    background: color-mix(in srgb, var(--cat-color, transparent) 22%, var(--tertiary-dark));
}

.group-btn {
    font-weight: 700;
}

.type-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 6px;
    padding-left: 14px;
}

.type-list .category-btn {
    font-weight: 500;
    font-size: 0.8rem;
    padding: 7px 8px;
    gap: 6px;
    /* Grid items default to min-width:auto (won't shrink below content's
       min-content size) -- with a nowrap label inside, that min-content
       size is the label's FULL unwrapped width, which silently defeated
       the 1fr column tracks and the label's own min-width:0/ellipsis
       below. Confirmed live: without this, each button rendered ~187px
       wide (its natural content width) inside a ~120px column instead of
       being clamped to it. */
    min-width: 0;
}

/* Two narrow columns instead of one wide row -- label needs to truncate
   rather than wrap or push the count/chevron out, and min-width:0 is
   required for a flex child to actually shrink below its content size. */
.type-list .cat-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.type-list .cat-count {
    padding: 1px 5px;
}

.group-chevron {
    color: var(--text-muted);
    font-size: 0.75rem;
    width: 12px;
    flex-shrink: 0;
    text-align: center;
}

.cat-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cat-color, var(--text-muted));
}
.cat-icon svg {
    width: 100%;
    height: 100%;
    /* fill comes from the fill="currentColor" attribute set in JS on the
       <svg> element itself, NOT here -- a CSS fill rule would win over a
       child path's own explicit fill (e.g. the hospital glyph's cutout),
       since CSS always beats SVG presentation attributes. */
}

.cat-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--tertiary-dark);
    padding: 1px 7px;
    border-radius: 10px;
    flex-shrink: 0;
    margin-left: auto;
}
.group-btn .cat-count {
    margin-left: 0;
}

/* "AI-named" badge -- the one sparing use of the gold accent (anticipation/
   highlight moment), per the theme's "used sparingly" guidance for gold. */
.ai-tag {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--accent-purple) 65%, black);
    background: color-mix(in srgb, var(--accent-purple) 20%, white);
    border-radius: 6px;
    padding: 1px 5px;
    vertical-align: middle;
}

/* ===== Detail View ===== */
.detail-back-btn {
    background: none;
    border: none;
    color: var(--accent-deep);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0 0 12px 0;
    display: block;
    transition: color 0.15s;
}
.detail-back-btn:hover {
    color: var(--accent-blue);
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 10px;
}

.detail-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.address-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.address-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--tertiary-dark);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    padding: 9px 12px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s;
}
.address-item:hover {
    background: color-mix(in srgb, var(--accent-blue) 8%, var(--tertiary-dark));
}

.address-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.address-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ===== Result Summary ===== */
.result-summary {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== Map ===== */
/* Leaflet tile colors are the mapping provider's content, not brand
   decoration -- intentionally untouched. Only layout is set here. */
#map {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* ===== POI marker badges =====
   --poi-color is the per-category marker color (informational, set by
   JS) -- left alone. White ring + dark shadow is kept so markers stay
   legible against any map tile color underneath them. */
.poi-marker { background: none; border: none; }
.poi-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--poi-color, var(--text-muted));
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    color: #fff;
    transition: transform 0.15s;
}
.poi-badge:hover { transform: scale(1.12); }
.poi-badge svg { width: 16px; height: 16px; } /* fill set via the svg's own fill="currentColor" attribute -- see .cat-icon svg comment above */

/* ===== Manual "Search This Area" trigger ===== */
.search-area-btn {
    position: fixed;
    top: 14px;
    left: calc(280px + 50%);
    transform: translateX(-50%);
    z-index: 1050;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 9px 18px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(27, 23, 32, 0.25);
    transition: background 0.15s, transform 0.1s;
}
.search-area-btn:hover { background: var(--accent-deep); }
.search-area-btn:active { transform: translateX(-50%) scale(0.96); }
.search-area-btn:disabled { opacity: 0.6; cursor: default; }

/* ===== Out-of-coverage notice ===== */
.coverage-notice {
    position: fixed;
    bottom: 28px;
    left: calc(280px + 50%);
    transform: translateX(-50%);
    z-index: 1050;
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    padding: 14px 18px;
    max-width: 360px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
    box-shadow: 0 6px 24px rgba(27, 23, 32, 0.18);
    display: none;
}
.coverage-notice.visible { display: block; }
.city-jumps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 10px;
}
.city-jump-btn {
    background: color-mix(in srgb, var(--accent-blue) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-blue) 35%, transparent);
    color: var(--accent-deep);
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s;
}
.city-jump-btn:hover { background: color-mix(in srgb, var(--accent-blue) 20%, transparent); }

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    background: rgba(246, 244, 241, 0.72);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.loading-overlay p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 3px solid var(--hairline);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ===== Leaflet popup theme ===== */
.leaflet-popup-content-wrapper {
    background: var(--secondary-dark);
    color: var(--text-primary);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(27, 23, 32, 0.2);
}
.leaflet-popup-tip {
    background: var(--secondary-dark);
}
.leaflet-popup-content {
    margin: 12px 16px;
    line-height: 1.5;
}
.popup-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
/* .popup-category's text color is set inline per-category by JS
   (informational category color-coding) -- left alone. */
.popup-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.popup-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.popup-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--accent-deep);
    text-decoration: none;
}
.popup-link:hover {
    text-decoration: underline;
}

/* ===== No results message ===== */
.no-results-msg {
    background: var(--tertiary-dark);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== Mobile ===== */
@media (max-width: 700px) {
    .sidebar {
        width: 100%;
        height: auto;
        bottom: 0;
        top: auto;
        border-right: none;
        border-top: 1px solid var(--hairline);
        max-height: 55vh;
        transform: translateY(calc(100% - 56px));
    }

    .sidebar.open {
        transform: translateY(0);
    }

    .sidebar-toggle {
        display: flex;
        /* The site-wide share FAB sits fixed at bottom:24px/right:24px
           (z-index 9000) -- on mobile the collapsed sidebar strip is the
           bottom 56px of the viewport, so a right-14px toggle here visually
           collides with it (confirmed live). Move to the left side instead
           of fighting the FAB's z-index -- see the matching header
           padding-left below so it doesn't overlap the title text. */
        left: 14px;
        right: auto;
    }

    .sidebar-header {
        padding-left: 52px;   /* room for the toggle button now on the left */
    }

    .back-btn {
        right: 12px;
        left: auto;
        top: 10px;
    }

    #map {
        left: 0;
        bottom: 56px;
    }

    .loading-overlay {
        left: 0;
        bottom: 56px;
    }

    .coverage-notice {
        left: 50%;
        bottom: calc(56px + 16px);
        transform: translateX(-50%);
    }

    .search-area-btn {
        left: 50%;
    }
}
