/* =================================================================
   GALLATIN CONTINUITY — Stylesheet
   Gallatin Watershed Council branded interactive map
   ================================================================= */

/* --- CSS Variables (GWC Palette) --- */
:root {
    /* Primary: River blues */
    --water-deep:       #1a5276;
    --water-mid:        #2980b9;
    --water-light:      #5dade2;
    --water-pale:       #d4effc;
    --water-tint:       #eaf6fd;

    /* Secondary: Forest greens */
    --forest-deep:      #1e4d2b;
    --forest-mid:       #2d6a4f;
    --forest-light:     #52b788;
    --forest-pale:      #d8f3dc;

    /* Earth tones */
    --earth-brown:      #6b4226;
    --earth-tan:        #c9a96e;
    --earth-sand:       #f0e6d3;

    /* Neutrals */
    --gray-900:         #1a1d21;
    --gray-800:         #2d3239;
    --gray-700:         #3d444d;
    --gray-600:         #555e68;
    --gray-500:         #7a8490;
    --gray-400:         #9ca6b0;
    --gray-300:         #c5cdd6;
    --gray-200:         #e2e7ec;
    --gray-100:         #f2f4f6;
    --gray-50:          #f8f9fa;
    --white:            #ffffff;

    /* Transect zone colors */
    --zone-natural:     #1e4d2b;
    --zone-rural:       #52b788;
    --zone-suburban:    #95d5b2;
    --zone-general:     #e9c46a;
    --zone-center:      #f4a261;
    --zone-core:        #e76f51;

    /* Functional */
    --accent:           #2980b9;
    --accent-hover:     #1a5276;
    --danger:           #c0392b;
    --success:          #27ae60;
    --warning:          #f39c12;

    /* Typography */
    --font-display:     'DM Serif Display', Georgia, serif;
    --font-body:        'Source Sans 3', -apple-system, sans-serif;

    /* Spacing */
    --panel-width:      260px;
    --header-height:    56px;
    --radius-sm:        4px;
    --radius-md:        8px;
    --radius-lg:        12px;
    --radius-xl:        16px;

    /* Shadows */
    --shadow-sm:        0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:        0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg:        0 8px 30px rgba(0,0,0,0.12);
    --shadow-xl:        0 16px 50px rgba(0,0,0,0.15);

    /* Transitions */
    --ease-out:         cubic-bezier(0.23, 1, 0.32, 1);
    --duration-fast:    150ms;
    --duration-normal:  250ms;
    --duration-slow:    400ms;
}


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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    color: var(--gray-800);
    background: var(--gray-100);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* =================================================================
   WELCOME OVERLAY
   ================================================================= */
.welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 30% 80%, rgba(45,106,79,0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 20%, rgba(41,128,185,0.12) 0%, transparent 50%),
        linear-gradient(165deg, var(--gray-50) 0%, var(--water-tint) 50%, var(--forest-pale) 100%);
    backdrop-filter: blur(2px);
    opacity: 1;
    transition: opacity var(--duration-slow) var(--ease-out);
}

.welcome-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.welcome-card {
    text-align: center;
    max-width: 480px;
    padding: 48px 40px;
    animation: welcomeIn 0.8s var(--ease-out) both;
}

@keyframes welcomeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-logo {
    width: 160px;
    height: auto;
    margin-bottom: 32px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.08));
}

.welcome-card h1 {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 400;
    line-height: 1.2;
    color: var(--water-deep);
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.welcome-tagline {
    font-size: 1.05rem;
    font-weight: 300;
    color: var(--gray-600);
    line-height: 1.6;
    margin-bottom: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-meta {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--forest-mid);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 32px;
}

.welcome-dot {
    margin: 0 8px;
    opacity: 0.5;
}

.welcome-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    background: var(--water-deep);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow: var(--shadow-md);
}

.welcome-btn:hover {
    background: var(--forest-deep);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.welcome-credits {
    margin-top: 32px;
    font-size: 0.78rem;
    color: var(--gray-400);
}

.welcome-credits a {
    color: var(--gray-500);
    text-decoration: underline;
    text-decoration-color: var(--gray-300);
    text-underline-offset: 2px;
}

.welcome-credits a:hover {
    color: var(--water-mid);
}


/* =================================================================
   HEADER
   ================================================================= */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px) saturate(1.2);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

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

.header-logo {
    width: 36px;
    height: auto;
}

.header-title h1 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--water-deep);
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

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

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--gray-600);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration-fast);
    text-decoration: none;
}

.header-btn:hover {
    color: var(--water-deep);
    background: var(--gray-100);
}


/* =================================================================
   APP LAYOUT
   ================================================================= */
.app-layout {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
}


/* =================================================================
   LEFT PANEL
   ================================================================= */
.panel {
    position: relative;
    width: var(--panel-width);
    min-width: var(--panel-width);
    height: 100%;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    transition: width var(--duration-normal) var(--ease-out),
                min-width var(--duration-normal) var(--ease-out),
                margin-left var(--duration-normal) var(--ease-out);
    z-index: 10;
}

.panel.collapsed {
    width: 0;
    min-width: 0;
    margin-left: 0;
    border-right: none;
}

.panel.collapsed .panel-scroll {
    display: none;
}

.panel.collapsed .panel-toggle {
    left: 0;
    right: auto;
    border-left: 1px solid var(--gray-200);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
}

/* Scrollbar styling */
.panel-scroll::-webkit-scrollbar {
    width: 6px;
}
.panel-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.panel-scroll::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}
.panel-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Search */
.panel-search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    transition: border-color var(--duration-fast);
}

.panel-search:focus-within {
    border-color: var(--water-mid);
}

.panel-search svg {
    flex-shrink: 0;
    color: var(--gray-400);
}

.panel-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--gray-800);
}

.panel-search input::placeholder {
    color: var(--gray-400);
}


/* --- Layer Categories --- */
.layer-category {
    margin-bottom: 8px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
    transition: background var(--duration-fast);
}

.category-header:hover {
    background: var(--gray-50);
}

.category-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 14px;
    flex-shrink: 0;
}

/* Category icon colors */
.category-icon.water   { background: var(--water-pale);  color: var(--water-deep); }
.category-icon.land    { background: var(--earth-sand);   color: var(--earth-brown); }
.category-icon.govern  { background: #e8daef;             color: #6c3483; }
.category-icon.zoning  { background: #fdebd0;             color: #b9770e; }
.category-icon.project { background: var(--forest-pale);  color: var(--forest-deep); }
.category-icon.data    { background: #d5f5e3;             color: #1e8449; }

.category-label {
    flex: 1;
}

.category-name {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--gray-800);
    line-height: 1.3;
}

.category-count {
    display: block;
    font-size: 0.73rem;
    color: var(--gray-500);
}

.category-chevron {
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    transition: transform var(--duration-fast) var(--ease-out);
    flex-shrink: 0;
}

.category-header.expanded .category-chevron {
    transform: rotate(90deg);
}

/* Layer list inside category */
.category-layers {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--duration-normal) var(--ease-out);
}

.category-layers.open {
    max-height: 800px;
}

.layer-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 12px 8px 50px;
    cursor: pointer;
    transition: background var(--duration-fast);
    border-radius: var(--radius-sm);
}

.layer-item:hover {
    background: var(--gray-50);
}

/* Custom toggle switch */
.layer-toggle {
    position: relative;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.layer-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.layer-toggle .toggle-track {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 9px;
    transition: background var(--duration-fast);
}

.layer-toggle input:checked + .toggle-track {
    background: var(--water-mid);
}

.layer-toggle .toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform var(--duration-fast) var(--ease-out);
}

.layer-toggle input:checked ~ .toggle-thumb {
    transform: translateX(14px);
}

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    line-height: 1.3;
}

.layer-desc {
    font-size: 0.75rem;
    color: var(--gray-500);
    line-height: 1.4;
    margin-top: 2px;
}

.layer-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Panel toggle button */
.panel-toggle {
    position: absolute;
    top: 50%;
    right: -32px;
    transform: translateY(-50%);
    width: 32px;
    height: 48px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-left: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    box-shadow: 2px 0 6px rgba(0,0,0,0.05);
    transition: color var(--duration-fast);
    z-index: 10;
}

.panel-toggle:hover {
    color: var(--gray-800);
}

.panel.collapsed .panel-toggle svg {
    transform: rotate(180deg);
}


/* =================================================================
   MAP
   ================================================================= */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.map {
    width: 100%;
    height: 100%;
}

/* Custom map controls */
.map-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 5;
}

.map-ctrl-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--duration-fast);
}

.map-ctrl-btn:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.map-ctrl-btn:last-child  { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.map-ctrl-btn:only-child  { border-radius: var(--radius-md); }

.map-ctrl-btn:hover {
    background: var(--gray-50);
    color: var(--water-deep);
}

/* Hide default Mapbox controls */
.mapboxgl-ctrl-top-right,
.mapboxgl-ctrl-top-left {
    display: none;
}


/* =================================================================
   QUERY PANEL (appears on map click)
   ================================================================= */
.query-panel {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 320px;
    max-height: 400px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 5;
    animation: slideUp var(--duration-normal) var(--ease-out);
}

.query-panel.hidden {
    display: none;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.query-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
}

.query-header h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--water-deep);
}

.query-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.query-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.query-content {
    padding: 16px;
    overflow-y: auto;
    max-height: 340px;
    font-size: 0.88rem;
}

.query-section {
    margin-bottom: 14px;
}

.query-section:last-child {
    margin-bottom: 0;
}

.query-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
    margin-bottom: 6px;
}

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

.query-item-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.query-item-label {
    color: var(--gray-700);
    font-size: 0.85rem;
}

.query-coords {
    font-size: 0.78rem;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 6px;
}

.query-coords svg {
    color: var(--gray-400);
}

/* --- Detail Panel Sections --- */
.detail-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-100);
}

.detail-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.detail-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.detail-layer-name {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.92rem;
}

.detail-category {
    font-size: 0.72rem;
    color: var(--gray-400);
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-feature {
    padding: 8px 0;
}

.detail-feature-border {
    border-top: 1px dashed var(--gray-200);
    margin-top: 8px;
    padding-top: 12px;
}

.detail-feature-title {
    font-weight: 600;
    color: var(--water-deep);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.detail-feature-props {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-prop {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
}

.detail-prop-label {
    color: var(--gray-500);
}

.detail-prop-value {
    color: var(--gray-700);
    font-weight: 500;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.detail-context {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-top: 10px;
}

.detail-context-desc {
    font-size: 0.82rem;
    color: var(--gray-600);
    line-height: 1.5;
    margin-bottom: 10px;
}

.detail-context-desc:last-child {
    margin-bottom: 0;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-action-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--water-mid);
    text-decoration: none;
    padding: 4px 8px;
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    transition: all var(--duration-fast) ease;
}

.detail-action-link:hover {
    background: var(--water-tint);
    border-color: var(--water-light);
    color: var(--water-deep);
}

.detail-action-link svg {
    opacity: 0.7;
}

/* --- Layer Info Panel --- */
.layer-info-panel {
    padding: 4px 0;
}

.layer-info-desc {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin: 10px 0;
}

.layer-info-fields {
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

.layer-info-label {
    font-weight: 600;
    margin-right: 4px;
}

/* --- Category Info Panel --- */
.category-info-panel {
    padding: 4px 0;
}

.category-info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.category-info-header .category-icon {
    font-size: 1.5rem;
}

.category-info-name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--water-deep);
}

.category-info-desc {
    font-size: 0.88rem;
    color: var(--gray-600);
    line-height: 1.55;
    margin-bottom: 14px;
}

.category-resources {
    margin-bottom: 14px;
}

.category-resources-label,
.category-layers-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.category-layers-list ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-layers-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.layer-swatch-small {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* --- Layer Info Button in Panel --- */
.layer-info-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all var(--duration-fast) ease;
    flex-shrink: 0;
}

.layer-item:hover .layer-info-btn {
    opacity: 1;
}

.layer-info-btn:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.layer-info-btn svg {
    width: 14px;
    height: 14px;
}

/* --- Category Info Button --- */
.category-info-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius-sm);
    margin-left: auto;
    margin-right: 8px;
    opacity: 0.6;
    transition: all var(--duration-fast) ease;
}

.category-header:hover .category-info-btn {
    opacity: 1;
}

.category-info-btn:hover {
    background: var(--white);
    color: var(--water-mid);
}

.category-info-btn svg {
    width: 16px;
    height: 16px;
}


/* =================================================================
   LEGEND
   ================================================================= */
.legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 220px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    z-index: 5;
}

.legend.hidden {
    display: none;
}

.legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
}

.legend-header h4 {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--water-deep);
}

.legend-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 16px;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.legend-content {
    padding: 12px 14px;
    font-size: 0.8rem;
}

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

.legend-swatch {
    width: 16px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-swatch.line {
    height: 3px;
}

.legend-swatch.fill {
    height: 12px;
    width: 12px;
    border-radius: 2px;
    opacity: 0.7;
}

.legend-label {
    color: var(--gray-600);
}


/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 768px) {
    :root {
        --panel-width: 300px;
    }

    .panel {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        box-shadow: var(--shadow-lg);
    }

    .panel.collapsed {
        transform: translateX(-100%);
    }

    .welcome-card {
        padding: 32px 24px;
    }

    .welcome-card h1 {
        font-size: 1.8rem;
    }

    .query-panel {
        left: 16px;
        right: 16px;
        width: auto;
    }
}

@media (max-width: 480px) {
    .header-title h1 {
        font-size: 1rem;
    }

    .header-subtitle {
        display: none;
    }

    .welcome-card h1 {
        font-size: 1.5rem;
    }
}


/* =================================================================
   MAPBOX POPUP OVERRIDES
   ================================================================= */
.mapboxgl-popup-content {
    font-family: var(--font-body);
    font-size: 0.88rem;
    padding: 16px;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    max-width: 280px;
}

.mapboxgl-popup-close-button {
    font-size: 18px;
    padding: 4px 8px;
    color: var(--gray-500);
}

.popup-title {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--water-deep);
    margin-bottom: 6px;
}

.popup-meta {
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.popup-body {
    color: var(--gray-700);
    line-height: 1.5;
}

.popup-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--water-mid);
    text-decoration: none;
}

.popup-link:hover {
    color: var(--water-deep);
    text-decoration: underline;
}


/* =================================================================
   LOADING STATE
   ================================================================= */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 5;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--water-mid);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 0.85rem;
    color: var(--gray-500);
}


/* =================================================================
   ENHANCED WELCOME OVERLAY (Narrative Version)
   ================================================================= */
.welcome-card-large {
    max-width: 640px;
    padding: 48px 56px;
}

.welcome-subtitle {
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--forest-mid);
    margin-bottom: 24px;
    font-style: italic;
}

.welcome-narrative {
    text-align: left;
    margin-bottom: 32px;
    padding: 0 8px;
}

.welcome-narrative p {
    font-size: 1rem;
    color: var(--gray-600);
    line-height: 1.65;
    margin-bottom: 12px;
}

.welcome-narrative p:last-child {
    margin-bottom: 0;
}

.welcome-narrative strong {
    color: var(--water-deep);
    font-weight: 600;
}

/* --- Transect Visualization --- */
.welcome-transect {
    margin-bottom: 32px;
}

.transect-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.transect-bar {
    display: flex;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    height: 48px;
}

.transect-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: all var(--duration-normal) var(--ease-out);
    cursor: pointer;
    position: relative;
}

.transect-zone:hover {
    flex: 1.5;
}

.transect-zone span {
    opacity: 0.9;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.transect-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding: 0 4px;
    font-size: 0.72rem;
    color: var(--gray-500);
}

/* --- Statistics Row --- */
.welcome-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 32px;
    padding: 20px 0;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--water-deep);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}


/* =================================================================
   NARRATIVE PANEL HEADER
   ================================================================= */
.panel-narrative {
    background: linear-gradient(135deg, var(--water-tint) 0%, var(--forest-pale) 100%);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(41, 128, 185, 0.15);
}

.narrative-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--water-mid);
    background: rgba(255,255,255,0.7);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.narrative-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--water-deep);
    margin-bottom: 8px;
}

.narrative-desc {
    font-size: 0.85rem;
    color: var(--gray-600);
    line-height: 1.5;
}


/* =================================================================
   HEADER STORY BUTTON
   ================================================================= */
.header-btn-text {
    width: auto;
    padding: 0 12px;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
}


/* =================================================================
   STORY PANEL (Slides from right)
   ================================================================= */
.story-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 380px;
    max-height: calc(100% - 32px);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    z-index: 15;
    animation: slideInRight var(--duration-normal) var(--ease-out);
}

.story-panel.hidden {
    display: none;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.story-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    background: linear-gradient(135deg, var(--water-tint) 0%, var(--white) 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.story-header h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--water-deep);
}

.story-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--duration-fast);
}

.story-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.story-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    font-size: 0.92rem;
    color: var(--gray-700);
    line-height: 1.6;
}

.story-content h4 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--water-deep);
    margin-bottom: 12px;
}

.story-content p {
    margin-bottom: 14px;
}

.story-content p:last-child {
    margin-bottom: 0;
}

.story-content .highlight-box {
    background: var(--water-tint);
    border-left: 3px solid var(--water-mid);
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.story-content .setback-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

.story-content .setback-item {
    background: var(--gray-50);
    padding: 12px;
    border-radius: var(--radius-md);
    text-align: center;
}

.story-content .setback-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--water-deep);
}

.story-content .setback-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.story-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.story-nav-btn {
    padding: 8px 16px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--water-deep);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast);
}

.story-nav-btn:hover:not(:disabled) {
    background: var(--water-tint);
    border-color: var(--water-light);
}

.story-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#story-progress {
    font-size: 0.78rem;
    color: var(--gray-500);
}


/* =================================================================
   TRANSECT SLIDER (Bottom of map)
   ================================================================= */
.transect-slider {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    padding: 12px 20px 10px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 5;
    width: 420px;
    max-width: calc(100% - 32px);
}

.transect-slider-track {
    display: flex;
    height: 36px;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.transect-zone-segment {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: all var(--duration-fast);
    position: relative;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

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

.transect-zone-segment .zone-label {
    opacity: 0.85;
    pointer-events: none;
}

.transect-zone-segment.active {
    flex: 1.4;
}

.transect-zone-segment.active .zone-label {
    opacity: 1;
    font-weight: 700;
}

.transect-slider-thumb {
    position: absolute;
    top: -4px;
    width: 6px;
    height: 44px;
    background: var(--white);
    border: 2px solid var(--gray-800);
    border-radius: 3px;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    transition: left var(--duration-normal) var(--ease-out);
    left: 0;
}

.transect-endpoints {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--gray-500);
}

.transect-endpoints span:first-child,
.transect-endpoints span:last-child {
    font-weight: 500;
    white-space: nowrap;
}

.transect-current-label {
    font-weight: 600;
    color: var(--water-deep);
    text-align: center;
    flex: 1;
    padding: 0 8px;
}

/* Story layer legend in content */
.story-layer-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--gray-600);
}

.layer-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}


/* =================================================================
   STORY CONTENT ZONES (visual styling)
   ================================================================= */
.zone-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.zone-tag.natural { background: #1e4d2b; color: white; }
.zone-tag.rural { background: #2d6a4f; color: white; }
.zone-tag.suburban { background: #52b788; color: white; }
.zone-tag.general { background: #95d5b2; color: var(--gray-800); }
.zone-tag.center { background: #f4a261; color: white; }
.zone-tag.core { background: #e76f51; color: white; }

.zone-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.zone-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.zone-icon.natural { background: rgba(30, 77, 43, 0.15); }
.zone-icon.rural { background: rgba(45, 106, 79, 0.15); }
.zone-icon.suburban { background: rgba(82, 183, 136, 0.15); }
.zone-icon.general { background: rgba(149, 213, 178, 0.2); }
.zone-icon.center { background: rgba(244, 162, 97, 0.15); }
.zone-icon.core { background: rgba(231, 111, 81, 0.15); }


/* =================================================================
   RESPONSIVE UPDATES FOR NARRATIVE
   ================================================================= */
@media (max-width: 768px) {
    .welcome-card-large {
        max-width: 100%;
        padding: 32px 24px;
        margin: 16px;
    }

    .welcome-stats {
        gap: 16px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .story-panel {
        left: 16px;
        right: 16px;
        width: auto;
        max-height: 50%;
        bottom: 80px;
        top: auto;
    }

    .transect-slider {
        width: auto;
        left: 16px;
        right: 16px;
        transform: none;
    }

    .transect-zone-segment .zone-label {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .welcome-stats {
        flex-direction: column;
        gap: 12px;
    }

    .stat {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }

    .transect-zone-segment .zone-label {
        font-size: 0.55rem;
    }

    .transect-endpoints {
        font-size: 0.65rem;
    }

    .transect-slider-track {
        height: 28px;
    }
}


/* =================================================================
   COMPACT PANEL MODE
   ================================================================= */
.panel.panel-compact {
    --panel-width: 260px;
    width: var(--panel-width);
    min-width: var(--panel-width);
}

.panel.panel-compact .panel-scroll {
    padding: 12px;
}

.panel.panel-compact .category-header {
    padding: 8px 10px;
}

.panel.panel-compact .category-icon {
    width: 24px;
    height: 24px;
    font-size: 12px;
}

.panel.panel-compact .category-name {
    font-size: 0.82rem;
}

.panel.panel-compact .category-count {
    font-size: 0.68rem;
}

.panel.panel-compact .layer-item {
    padding: 6px 10px 6px 40px;
}

.panel.panel-compact .layer-toggle {
    width: 28px;
    height: 16px;
}

.panel.panel-compact .layer-toggle .toggle-thumb {
    width: 12px;
    height: 12px;
}

.panel.panel-compact .layer-toggle input:checked ~ .toggle-thumb {
    transform: translateX(12px);
}

.panel.panel-compact .layer-name {
    font-size: 0.78rem;
}

.panel.panel-compact .layer-desc {
    font-size: 0.7rem;
    display: none;
}

.panel.panel-compact .layer-swatch {
    width: 10px;
    height: 10px;
}


/* =================================================================
   IMPROVED STORY PANEL (Always Visible Right Side)
   ================================================================= */
.story-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 340px;
    max-height: calc(100% - 100px);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    z-index: 15;
    overflow: hidden;
}

.story-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    background: linear-gradient(135deg, var(--water-tint) 0%, var(--white) 100%);
}

.story-logo {
    width: 32px;
    height: auto;
}

.story-header-text {
    flex: 1;
}

#story-title {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--water-deep);
    line-height: 1.2;
}

.story-tagline {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.story-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 0.88rem;
    color: var(--gray-700);
    line-height: 1.55;
}

.story-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

.story-nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--gray-600);
    transition: all var(--duration-fast);
}

.story-nav-btn:hover:not(:disabled) {
    background: var(--water-tint);
    border-color: var(--water-light);
    color: var(--water-deep);
}

.story-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#story-progress {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
}


/* =================================================================
   ABOUT INFO PANEL
   ================================================================= */
.about-info-panel {
    padding: 8px 0;
}

.about-logo-row {
    text-align: center;
    margin-bottom: 16px;
}

.about-logo {
    width: 80px;
    height: auto;
}

.about-info-panel h4 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--water-deep);
    margin-bottom: 8px;
}

.about-info-panel p {
    font-size: 0.88rem;
    color: var(--gray-600);
    margin-bottom: 12px;
    line-height: 1.55;
}

.about-info-panel a {
    color: var(--water-mid);
    text-decoration: none;
}

.about-info-panel a:hover {
    text-decoration: underline;
}


/* =================================================================
   ZONE LABELS ON MAP (Mapbox styling adjustments)
   ================================================================= */
.zone-labels {
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
}


/* =================================================================
   MAP CONTROLS POSITION ADJUSTMENT (for story panel)
   ================================================================= */
.map-controls {
    position: absolute;
    top: 16px;
    right: 376px;
    z-index: 5;
}

@media (max-width: 768px) {
    .map-controls {
        right: 16px;
        top: auto;
        bottom: 100px;
    }
}


/* =================================================================
   CREEK HIGHLIGHT VISUAL CUE
   ================================================================= */
.creek-legend-item {
    background: linear-gradient(90deg, transparent 0%, rgba(0, 229, 255, 0.2) 50%, transparent 100%);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.creek-legend-line {
    width: 24px;
    height: 4px;
    background: #00e5ff;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.creek-legend-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #00838f;
}


/* =================================================================
   CULVERT/UNDERGROUND INDICATOR
   ================================================================= */
.culvert-indicator {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border: 1px dashed #e65100;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin: 14px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.culvert-icon {
    background: #ff6d00;
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.culvert-indicator span {
    font-size: 0.82rem;
    color: var(--gray-700);
    line-height: 1.45;
}

.culvert-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--gray-200);
}

.culvert-dash {
    width: 20px;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #ff6d00 0,
        #ff6d00 4px,
        transparent 4px,
        transparent 8px
    );
    border-radius: 1px;
}


/* =================================================================
   POLICY BOX STYLES (Story Content)
   Visual indicators for different policy regulations
   ================================================================= */
.policy-box {
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin: 14px 0;
    border-left: 4px solid;
    font-size: 0.85rem;
    line-height: 1.5;
}

.policy-box strong {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

/* Natural zone - forest green */
.policy-box.natural {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-left-color: #4caf50;
}

.policy-box.natural strong {
    color: #2e7d32;
}

/* County regulations - orange */
.policy-box.county {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-left-color: #ff9800;
}

.policy-box.county strong {
    color: #e65100;
}

/* City regulations - pink/magenta */
.policy-box.city {
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%);
    border-left-color: #e91e63;
}

.policy-box.city strong {
    color: #ad1457;
}

/* Policy conflict - red/warning */
.policy-box.conflict {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border-left-color: #f44336;
}

.policy-box.conflict strong {
    color: #c62828;
}

/* Proposed policy - teal/blue-green */
.policy-box.proposed {
    background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
    border-left-color: #00bcd4;
}

.policy-box.proposed strong {
    color: #00838f;
}

/* Vision/Goal state - deep green */
.policy-box.vision {
    background: linear-gradient(135deg, #e8f5e9 0%, #a5d6a7 100%);
    border-left-color: #1e4d2b;
}

.policy-box.vision strong {
    color: #1e4d2b;
}

/* Setback comparison cards */
.setback-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 14px 0;
}

.setback-card {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    text-align: center;
    border-top: 3px solid;
}

.setback-card.city {
    border-top-color: #e91e63;
}

.setback-card.county {
    border-top-color: #ff9800;
}

.setback-card.proposed {
    border-top-color: #4caf50;
}

.setback-card .setback-distance {
    display: block;
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--water-deep);
    margin-bottom: 2px;
}

.setback-card .setback-jurisdiction {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
}

/* Layer toggle hint in story */
.layer-toggle-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--water-tint);
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--water-deep);
    margin-top: 12px;
}

.layer-toggle-hint svg {
    width: 14px;
    height: 14px;
}
