@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --- UNIVERSAL VARIABLES --- */
:root {
    --primary: #3b82f6; 
    --border: #e2e8f0;
    --bg: #f8fafc;
    --text: #0f172a;
    --gray: #64748b;
}

body, html {
    margin: 0; padding: 0; height: 100%;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background: var(--bg);
}

.app-layout { 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh;
    overflow-x: hidden;
    /* Ensure no height: 100vh or overflow: hidden here */
}

/* --- HEADER (STATIC) --- */
.main-header {
    background: white; 
    padding: 15px 30px; 
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; 
    z-index: 1000;
    box-sizing: border-box;
}

.nav-content { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.025em; }

.view-toggle { background: #f1f5f9; padding: 4px; border-radius: 8px; display: flex; gap: 4px; }
.toggle-btn {
    text-decoration: none; color: var(--gray); padding: 6px 12px;
    border-radius: 6px; font-size: 13px; font-weight: 600; transition: 0.2s;
}
.toggle-btn.active { background: white; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

/* --- FILTERS (Desktop Default) --- */
.filter-bar { display: flex; gap: 15px; flex-wrap: wrap; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--gray); }
input, select {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 14px; background: white; color: var(--text); outline: none;
}

.reset-btn {
    background: white;
    border: 1px solid var(--primary);
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
    height: 35px;
}
.reset-btn:hover { background: #eff6ff; box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1); }

.dropdown-check-list { position: relative; display: inline-block; }
.dropdown-check-list .anchor {
    position: relative; cursor: pointer; display: inline-block; padding: 8px 12px;
    border: 1px solid var(--border); border-radius: 6px; background: white; width: 140px;
}
.dropdown-check-list .items {
    padding: 10px; display: none; margin: 0; border: 1px solid var(--border);
    position: absolute; width: 220px; background: #fff; z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); border-radius: 8px;
    max-height: 400px; overflow-y: auto; list-style: none;
}
.dropdown-check-list.visible .items { display: block; }

/* --- MOBILE TOGGLE BUTTON (Hidden on Desktop) --- */
.mobile-toggle-btn {
    display: none; /* Hidden by default */
    width: 100%; padding: 12px; background: white;
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--primary); font-size: 14px; font-weight: 700;
    cursor: pointer; margin-bottom: 10px; text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: background 0.2s;
}
.mobile-toggle-btn:hover { background: #f8fafc; }

/* --- CLOSE BUTTON (Hidden on Desktop) --- */
.close-filters-btn {
    display: none; /* Hidden by default */
    background: var(--text); border: 1px solid var(--text); color: white;
    font-size: 13px; font-weight: 700; cursor: pointer; padding: 8px 16px;
    border-radius: 6px; transition: all 0.2s; height: 35px;
}

/* --- BACK TO TOP BUTTON --- */
#back-to-top {
    position: fixed; bottom: 25px; right: 25px; width: 50px; height: 50px;
    background-color: var(--primary); color: white; border: none; border-radius: 50%;
    cursor: pointer; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    display: none; align-items: center; justify-content: center;
    font-size: 24px; z-index: 2000; transition: transform 0.2s, background-color 0.2s;
}
#back-to-top.visible { display: flex; animation: popIn 0.3s ease-out; }
#back-to-top:hover { background-color: #2563eb; transform: translateY(-3px); }
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- INDEX PAGE: SIDEBAR & MAP --- */
#main-container { 
    display: flex; 
    flex-shrink: 0;
    
    /* CHANGED: Increased from 110px to 150px */
    /* This ensures the Header + Map fits exactly in the viewport, */
    /* pushing the footer just below the fold. */
    height: calc(100vh - 150px); 
    
    width: 100%;
    overflow: hidden; 
}
#sidebar { width: 350px; background: white; border-right: 1px solid var(--border); overflow-y: auto; }
#map { flex: 1; }

.location-item {
    padding: 0; border-bottom: 1px solid var(--border);
    cursor: pointer; background: white;
    display: flex; flex-direction: column; overflow: hidden;
}
.location-item:hover { background: #fcfdfe; }
.location-item.active { background: #f0f7ff; border-left: 4px solid var(--primary); }

.sidebar-content-top { padding: 15px 15px 10px 15px; }
.sidebar-title { margin: 0 0 4px 0; font-size: 16px; font-weight: 700; color: var(--text); }
.sidebar-meta { font-size: 12px; color: var(--gray); margin-bottom: 8px; }

/* --- FIX FOR SIDEBAR "ZOOMED" IMAGES --- */
.sidebar-image-full {
    width: 100%; 
    height: 88px;        /* Matches the 4:1 Python aspect ratio precisely */
    background: #f1f5f9; 
    display: block;      
    overflow: hidden;
    border-top: 1px solid var(--border);
}

.sidebar-image-full img { 
    width: 100%; 
    height: 100%; 
    /* 'contain' ensures the whole chart is visible without cropping */
    object-fit: contain; 
    /* Add a little padding so the line doesn't touch the very edges */
    padding: 5px 0;
    box-sizing: border-box;
    opacity: 0.9;
    display: block;
}

/* --- SITE BLURB (Desktop Default) --- */
.site-blurb {
    padding: 20px 15px; background: #eff6ff; border-bottom: 1px solid var(--border);
}
.site-blurb h2 { margin: 0 0 10px 0; font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.site-blurb p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--gray); }
.site-blurb strong { color: var(--primary); font-weight: 700; }
#location-list { flex: 1; overflow-y: auto; }
.mobile-only { display: none; } /* Hidden on desktop */

/* --- LIST PAGE --- */
#full-list-container {
    max-width: 1000px; margin: 0 auto; padding: 30px; width: 100%; box-sizing: border-box;
}
.list-row {
    background: white; border: 1px solid var(--border); border-radius: 12px;
    padding: 20px; margin-bottom: 15px; display: flex; align-items: center;
    cursor: pointer; transition: 0.2s; justify-content: space-between;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.list-row:hover {
    border-color: var(--primary); transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.row-info { flex: 1; min-width: 200px; }
.row-chart { 
    width: 300px; height: 80px; margin-left: 40px; flex-shrink: 0; 
    display: flex; align-items: center; justify-content: flex-end; 
}
.row-chart img { height: 100%; width: 100%; object-fit: contain; opacity: 0.8; }

/* --- COURSE PAGE --- */
.course-container {
    max-width: 900px; margin: 40px auto; background: white; border-radius: 16px; overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); display: block; 
}
.course-header { padding: 30px; border-bottom: 1px solid #f1f5f9; }
.title-area { margin-bottom: 20px; }
.back-link { 
    text-decoration: none; color: var(--gray); font-size: 11px; font-weight: 800; 
    text-transform: uppercase; letter-spacing: 0.05em; display: block; 
    margin-bottom: 10px; transition: color 0.2s;
}
.back-link:hover { color: var(--primary); }
.course-header h1 { font-size: 32px; margin: 5px 0 0 0; }
.stats-grid { display: flex; gap: 40px; margin-top: 20px; }
.stat-tile { display: flex; flex-direction: column; }
.stat-tile .label { font-size: 11px; font-weight: 700; color: var(--gray); letter-spacing: 0.05em; margin-bottom: 4px; }
.stat-tile .value { font-size: 24px; font-weight: 800; color: var(--text); }
.chart-container { padding: 20px; height: 300px; width: 100%; box-sizing: border-box; display: block; }
#elevationChart { width: 100%; height: 100%; }
#course-map { height: 400px; width: 100%; position: relative; }

/* --- BADGES & PINS --- */
.badge-container { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.small-badges { margin-top: 5px; gap: 4px; }
.category-badge, .stat-badge {
    padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 800;
    text-transform: uppercase; display: inline-block; letter-spacing: 0.02em;
}
.stat-badge { background: #f1f5f9; color: var(--gray); border: 1px solid var(--border); }
.category-badge { color: white; }
.very-flat { background: #eab308; }
.flat { background: #10b981; }
.undulating { background: #3b82f6; }
.hilly { background: #f59e0b; }
.very-hilly { background: #ef4444; }
.marker-pin {
    cursor: pointer; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3)); transition: transform 0.2s;
}
.marker-pin:hover { transform: scale(1.15); z-index: 1000; }
.chart-tracker {
    width: 14px; height: 14px; background-color: #3b82f6; border: 2px solid white;
    border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.3); pointer-events: none;
}

/* --- HEADER ACTIONS --- */
.header-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.website-link {
    font-size: 13px; font-weight: 600; color: var(--primary); text-decoration: none;
    padding: 8px 12px; border-radius: 6px; transition: background-color 0.2s;
    white-space: nowrap; display: inline-flex; align-items: center;
}
.website-link:hover { background-color: #eff6ff; text-decoration: underline; }
#share-btn {
    display: flex; align-items: center; gap: 8px; padding: 10px 18px;
    background-color: var(--primary); color: white; border: none; border-radius: 50px;
    font-size: 13px; font-weight: 700; cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3), 0 2px 4px -1px rgba(59, 130, 246, 0.1);
}
#share-btn:hover { background-color: #2563eb; transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4); }
#share-btn:active { transform: translateY(0); }
#share-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* --- MAP RECENTER BUTTON --- */
#recenter-map-btn {
    position: absolute; 
    
    /* 1. Clear the zoom controls (approx 100px tall) */
    top: 120px; 
    
    /* 2. Move to the right side */
    right: 10px;       /* Matches MapLibre's default margin */
    left: auto;        /* crucial: overrides the previous 'left' setting */
    
    z-index: 10;
    width: 29px; height: 29px; background: white; border: 1px solid #ccc;
    border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text); box-shadow: 0 0 0 2px rgba(0,0,0,.1); transition: background 0.2s, color 0.2s;
}
#recenter-map-btn:hover { background: #f4f4f4; color: var(--primary); }

/* --- MAP POPUP STYLING --- */
.mapboxgl-popup-content, .maplibregl-popup-content {
    padding: 15px; border-radius: 12px; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); border: none;
}
.popup-content { display: flex; flex-direction: column; gap: 10px; min-width: 140px; }
.popup-title { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.2; }
.popup-btn {
    display: inline-block; text-align: center; background-color: var(--primary); color: white !important;
    text-decoration: none; font-size: 11px; font-weight: 800; padding: 8px 12px;
    border-radius: 6px; text-transform: uppercase; letter-spacing: 0.05em;
    transition: background-color 0.2s, transform 0.1s;
}
.popup-btn:hover { background-color: #2563eb; transform: translateY(-1px); }

/* --- HEADER TITLE & SUBTITLE --- */
.title-wrapper { display: flex; flex-direction: column; justify-content: center; }
.header-subtitle {
    font-size: 11px; font-weight: 600; color: var(--gray);
    text-transform: uppercase; letter-spacing: 0.05em; margin-top: -2px;
}
.mobile-break { display: none; }

/* --- FOOTER SECTION (REORGANIZED & ENHANCED) --- */
.main-footer {
    background: white; padding: 30px 20px; border-top: 1px solid var(--border);
    margin-top: auto; flex-shrink: 0;
}
.footer-grid {
    max-width: 1100px; margin: 0 auto; display: grid;
    grid-template-columns: 220px 1fr 220px; align-items: center; gap: 20px;
}
.footer-column { display: flex; flex-direction: column; gap: 10px; }
.footer-column.center { text-align: center; }
.footer-column.side:last-child { align-items: flex-end; }
.footer-column.side:first-child { align-items: flex-start; }
.footer-logo { font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 5px; display: block; }
.footer-disclaimer { font-size: 12px; color: var(--gray); line-height: 1.5; margin: 0 auto; }
.footer-legal { margin-top: 5px; }
.footer-legal a { font-size: 11px; color: var(--gray); text-decoration: underline; transition: color 0.2s; }
.footer-legal a:hover { color: var(--primary); }

.support-btn {
    display: inline-flex !important; align-items: center !important; gap: 8px !important;
    background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%) !important;
    color: white !important; padding: 12px 20px !important; border-radius: 8px !important;
    text-decoration: none !important; font-weight: 700 !important; font-size: 14px !important;
    letter-spacing: 0.01em !important; border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3), 0 2px 4px -1px rgba(59, 130, 246, 0.1) !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.support-btn:hover {
    transform: translateY(-2px) !important; filter: brightness(1.1) !important;
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4) !important;
}
.support-btn svg { width: 16px !important; height: 16px !important; fill: currentColor; transition: transform 0.2s ease !important; }
.support-btn:hover svg { transform: scale(1.15); }

.correction-btn {
    color: var(--gray); font-size: 13px; font-weight: 600; text-decoration: none;
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
    transition: all 0.2s; display: inline-block;
}
.correction-btn:hover { background: #fff1f2; color: #e11d48; border-color: #e11d48; }


/* =================================================================
   MASTER MOBILE OPTIMIZATION (768px and below)
   ================================================================= */
@media (max-width: 768px) {
    /* --- 1. GENERAL LAYOUT ADJUSTMENTS --- */
    .mobile-break { display: block !important; }
    .header-top-row { flex-direction: column; align-items: flex-start; gap: 15px; }
    .header-actions { width: 100%; justify-content: space-between; }
    
    #main-container { flex-direction: column !important; height: auto !important; overflow: visible !important; }
    #map { width: 100% !important; height: 450px !important; flex: none !important; }

    /* --- 2. REQUIREMENT 1: HIDE SIDEBAR LIST ON MAP (MOBILE) --- */
    /* Only hide sidebar on the map page, if you want it on other pages, remove .map-view-page */
    body.map-view-page #sidebar { display: none !important; }

    /* --- 3. REQUIREMENT 2 & 3: MAP PAGE FILTERS (COLLAPSIBLE + BLURB) --- */
    /* Show the Toggle Button on Map Page */
    body.map-view-page .mobile-toggle-btn { display: block !important; }

    /* Hide the Filter Bar by default on Map Page */
    body.map-view-page .filter-bar { 
        display: none; 
    }

    .correction-box {
        padding: 20px;
        border: none; /* Optional: cleaner look on mobile */
        box-shadow: none;
        background: transparent;
    }

    /* Style the Filter Bar when OPEN (Map Page) */
    body.map-view-page .filter-bar.open {
        display: flex !important;
        flex-direction: column !important;
        background: white !important;
        padding: 0 0 20px 0 !important; /* Padding for bottom content */
        margin: 10px !important;
        border: 1px solid var(--border) !important;
        border-radius: 12px !important;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
        gap: 6px !important;
        width: auto !important;
        align-items: flex-start !important;
        overflow: hidden !important; /* Clip content for rounded corners */
    }

    body.map-view-page .filter-group:has(#sortOrder) {
        display: none !important;
    }

    /* REQ 3: SHOW BLUE BLURB ON MAP MOBILE (Inside Filter Menu) */
    body.map-view-page .filter-bar.open .mobile-only {
        display: block !important;
        width: 100% !important;
        padding: 20px !important;
        background: #eff6ff !important;
        border-bottom: 1px solid var(--border) !important;
        box-sizing: border-box !important;
        margin-bottom: 5px !important;
        text-align: left !important;
    }
    
    /* Ensure internal inputs have padding since bar has 0 padding */
    body.map-view-page .filter-bar.open .filter-group,
    body.map-view-page .filter-bar.open .mobile-filter-actions {
        padding-left: 20px !important;
        padding-right: 20px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* --- 4. REQUIREMENT 4: LIST PAGE FILTERS (PERSISTENT / NOT FOLDING) --- */
    /* Force filters to display flex on list page */
    body.list-view-page .filter-bar {
        display: flex !important;
        flex-direction: column !important;
        background: white !important;
        padding: 15px !important;
        border-bottom: 1px solid var(--border) !important;
        gap: 12px !important;
        margin: 0 !important;
        width: 100% !important;
    }

    /* Hide the toggle button on List Page (since it's always open) */
    body.list-view-page .mobile-toggle-btn { display: none !important; }

    /* Hide the Blurb on List Page mobile filters (optional, prevents duplication) */
    body.list-view-page .mobile-only { display: none !important; }

    /* --- 5. REQUIREMENT 5: LIST IMAGES STACKED BELOW TEXT --- */
    .list-row { 
        flex-direction: column !important; 
        align-items: stretch !important; 
        padding: 15px !important;
        overflow: hidden !important;
    }

    .row-info { width: 100% !important; margin-bottom: 15px !important; }

    .row-chart {
        width: calc(100% + 30px) !important; /* Spans full width */
        margin: 0 -15px -15px -15px !important; /* Pulls to edges */
        height: 120px !important; 
        display: block !important; 
        background: #f1f5f9 !important;
    }

    .row-chart img { 
        width: 100% !important; height: 100% !important; 
        object-fit: cover !important; display: block !important; opacity: 1 !important; 
    }

    /* --- SHARED MOBILE STYLES (Inputs & Footer) --- */
    
    /* 1. Tighten spacing between label and input */
    .filter-group { 
        width: 100% !important; 
        gap: 2px !important;
        margin-bottom: 5px !important;
    }

    /* 2. Generic Input Styling (Text & Selects) */
    input[type="text"], select {
        width: 100% !important; 
        height: 36px !important; 
        font-size: 14px !important; 
        padding: 0 10px !important;
    }

    /* 3. FIX: Checkbox Specific Styling (Stop them from being huge) */
    input[type="checkbox"] {
        width: 20px !important; 
        height: 20px !important; 
        margin-right: 10px !important;
        cursor: pointer !important;
        display: inline-block !important;
        vertical-align: middle !important;
    }
    
    /* Ensure list items inside the dropdown align nicely */
    .dropdown-check-list .items li {
        display: flex !important;
        align-items: center !important;
        padding: 8px 0 !important;
    }

    /* 4. FIX: Vertically Center 'All Ireland' Text */
    .dropdown-check-list .anchor {
        width: 100% !important; 
        height: 36px !important; 
        font-size: 14px !important;
        padding: 0 10px !important;
        display: flex !important;         /* Enables Flexbox */
        align-items: center !important;   /* Vertically Centers Text */
        color: var(--text) !important;
    }

    /* 5. FIX: Horizontally Center 'Find Near Me' Button */
    #gps-btn {
        width: auto !important;           /* Let text dictate width */
        min-width: 140px !important;      /* Ensure it's not too small */
        align-self: center !important;    /* Centers item in Flex Column */
        margin: 10px auto !important;     /* Centers item in Block layout */
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* Actions Container (Reset + Close) */
    .mobile-filter-actions {
        display: flex !important; gap: 10px !important; width: 100% !important; margin-top: 5px !important;
    }
    .mobile-filter-actions .reset-btn, 
    .close-filters-btn {
        flex: 1 !important; display: flex !important; justify-content: center !important; align-items: center !important;
        height: 36px !important; margin: 0 !important;
    }
    .close-filters-btn { display: flex !important; }

    /* Footer Stacking */
    .footer-grid {
        grid-template-columns: 1fr !important; text-align: center !important; gap: 25px !important;
    }
    .footer-column { align-items: center !important; }
    .footer-column.side:first-child { flex-direction: row; justify-content: center; flex-wrap: wrap; }
    .support-btn { width: 100%; max-width: 320px; justify-content: center; }
}

/* --- CORRECTION PAGE LAYOUT --- */
.correction-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Start below header */
    padding: 40px 20px;
    background: var(--bg);
}

.correction-box {
    background: white;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 500px; /* Keeps the form from getting too wide on desktop */
}

/* Specific textarea styling to match your inputs */
textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: var(--primary);
}

/* --- SHARE MODAL STYLES --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); z-index: 3000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white; padding: 25px; border-radius: 16px;
    width: 90%; max-width: 350px; text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: scaleIn 0.2s ease-out;
}

.modal-content h3 { margin: 0 0 10px 0; font-size: 18px; color: var(--text); }
.modal-content p { margin: 0 0 20px 0; font-size: 14px; color: var(--gray); }

.share-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.share-choice-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 12px; border: 1px solid var(--border);
    background: white; border-radius: 8px; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: 0.2s; color: var(--text);
}

.share-choice-btn:hover { background: #f8fafc; border-color: var(--primary); color: var(--primary); }
.share-choice-btn .icon { font-size: 18px; }

.modal-cancel-btn {
    background: none; border: none; color: var(--gray); font-size: 13px;
    font-weight: 600; cursor: pointer; padding: 5px 10px;
}
.modal-cancel-btn:hover { color: var(--text); text-decoration: underline; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }


.map-legend {
    position: absolute;
    bottom: 25px;
    right: 25px;
    z-index: 50;
    
    background: white;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    
    font-family: 'Inter', sans-serif;
    min-width: 140px;
    width: auto;
}

.map-legend h4 {
    margin: 0 0 2px 0;
    line-height: 1;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--gray);
    letter-spacing: 0.05em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.2;
}
/* --- DOT STYLING (Global) --- */
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block; /* Essential for it to have size */
    border: 1px solid rgba(0,0,0,0.1); /* Subtle border for yellow/white contrast */
    flex-shrink: 0; /* Prevents it from disappearing if text is long */
}

/* --- MOBILE LEGEND (Bar Below Map) --- */
@media (max-width: 768px) {
    .map-legend {
        /* Reset positioning to sit in normal flow below map */
        position: relative;
        bottom: auto;
        right: auto;
        left: auto;
        top: auto;
        
        /* Bar Styling */
        width: 100%;
        box-sizing: border-box; /* Ensures padding doesn't widen the screen */
        border-radius: 0;       /* Square edges for a "bar" look */
        border: none;
        border-bottom: 1px solid var(--border); /* Divider line */
        box-shadow: none;
        background: #f8fafc;    /* Slightly grey background to distinguish from map */
        
        /* Horizontal Layout */
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px 15px;          /* Good spacing between items */
        padding: 10px;
    }

    /* Hide Title */
    .map-legend h4 { display: none; }
    
    /* Horizontal Item Styling */
    .legend-item {
        margin: 0;
        font-size: 11px;
        white-space: nowrap;
    }
}


/* --- ENHANCED SECTION LABELS --- */
.section-label {
    display: flex;
    align-items: center;
    gap: 10px;
    
    margin: 30px 20px 15px 20px; /* Spacing around the headers */
    padding-left: 12px;
    border-left: 4px solid var(--primary); /* Blue accent line */
    
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray);
}

.section-label svg {
    color: var(--primary); /* Makes the icon pop */
    opacity: 0.8;
}

/* Ensure mobile spacing remains tight */
@media (max-width: 768px) {
    .section-label {
        margin: 25px 15px 12px 15px;
        font-size: 12px;
    }
}

#course-map {
    height: 400px;
    width: 100%;
    position: relative;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.chart-container {
    padding: 20px;
    height: 300px;
    width: 100%;
    box-sizing: border-box;
    background: linear-gradient(to bottom, #ffffff, #f8fafc); /* Subtle fade */
}

/* --- MOBILE ONLY: Top-Left --- */
@media (max-width: 768px) {
    #recenter-map-btn {
        /* Move to Top-Left */
        top: 10px;
        left: 10px;
        
        /* Reset the 'Right' positioning from desktop */
        right: auto;
    }
}

/* --- INSTRUCTION HINTS (Desktop vs Mobile) --- */
.mobile-hint {
    display: none; /* Hidden by default (for desktop) */
}

@media (max-width: 768px) {
    .desktop-hint {
        display: none; /* Hide 'Hover' text on mobile */
    }
    .mobile-hint {
        display: inline; /* Show 'Touch' text on mobile */
    }
}

/* --- STYLED COURSE MARKER POPUPS --- */

/* 1. Override default popup container to be smaller/tighter */
.minimal-popup .maplibregl-popup-content {
    padding: 6px 10px !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1) !important;
    min-width: auto !important; /* Allow it to shrink to text size */
}

/* 2. Style the text inside */
.popup-label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    line-height: 1;
}

/* 3. Color matching */
.popup-label.start { color: #10b981; } /* Green */
.popup-label.finish { color: #ef4444; } /* Red */
.popup-label.loop { color: #f97316; }   /* Orange */

/* Optional: Hide the little triangle tip for a cleaner "floating" look */
/* .minimal-popup .maplibregl-popup-tip { display: none; } */