/* ========================================
   Bike Routes – Stylesheet
   Inspired by routes.cc
   ======================================== */

:root {
    --color-bg: #fafaf9;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-text-secondary: #6b7280;
    --color-accent: #d97706;
    --color-accent-hover: #b45309;
    --color-border: #e5e5e5;
    --color-route: #d97706;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-card-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --transition: 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--color-accent-hover);
}

img {
    max-width: 100%;
    display: block;
}

/* ---- Layout ---- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ---- Header ---- */
.site-header {
    padding: 4rem 0 2rem;
    text-align: center;
}

.site-title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.site-subtitle {
    font-size: 1.15rem;
    color: var(--color-text-secondary);
    font-weight: 400;
    max-width: 500px;
    margin: 0 auto;
}

/* ---- Filters ---- */
.filters {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

.filter-btn {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.45rem 1rem;
    border: 1.5px solid var(--color-border);
    border-radius: 100px;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.filter-btn.active {
    background: var(--color-text);
    color: var(--color-surface);
    border-color: var(--color-text);
}

/* ---- Range Sliders ---- */
.sliders {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 0 0.5rem;
}

.slider-group {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

.slider-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.slider-label span {
    font-weight: 500;
    color: var(--color-text);
    text-transform: none;
    letter-spacing: 0;
}

.range-wrap {
    position: relative;
    height: 32px;
}

.range-input {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    left: 0;
    top: 8px;
    width: 100%;
    height: 4px;
    margin: 0;
    pointer-events: none;
    background: none;
    outline: none;
    z-index: 2;
}

.range-min {
    background: var(--color-border);
    border-radius: 2px;
    z-index: 1;
}

.range-track {
    position: absolute;
    top: 8px;
    height: 4px;
    background: var(--color-accent);
    border-radius: 2px;
    z-index: 1;
    pointer-events: none;
}

/* Thumb styles */
.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2.5px solid var(--color-accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    cursor: pointer;
    pointer-events: all;
    position: relative;
    z-index: 3;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.range-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2.5px solid var(--color-accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    cursor: pointer;
    pointer-events: all;
}

.range-input::-moz-range-track {
    background: transparent;
    border: none;
    height: 4px;
}

/* ---- Route Count ---- */
.route-count {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* ---- Regions Grid ---- */
.regions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
    padding-bottom: 4rem;
}

.region-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.region-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
    color: inherit;
}

.region-card-map {
    height: 240px;
    background: #f0ede8;
}

.region-card-body {
    padding: 1.5rem;
}

.region-card-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.region-card-subtitle {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.region-card-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.back-home {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
}

.back-home:hover {
    color: var(--color-text);
}

/* ---- Routes Grid ---- */
.routes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
    padding-bottom: 4rem;
}

/* ---- Route Card ---- */
.route-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.route-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
    color: inherit;
}

.route-card-map {
    height: 220px;
    background: #f0ede8;
    position: relative;
}

.route-card-body {
    padding: 1.25rem 1.5rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.route-card-name {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    letter-spacing: -0.01em;
}

.route-card-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.route-card-stats span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.route-card-description {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.55;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.route-card-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.65rem;
    border-radius: 100px;
    background: #f5f0eb;
    color: #8b7355;
}

.tag--hills {
    background: #fef3c7;
    color: #92400e;
}

.tag--allhills {
    background: #fee2e2;
    color: #991b1b;
}

.tag--flat {
    background: #d1fae5;
    color: #065f46;
}

.tag--loop {
    background: #ede9fe;
    color: #5b21b6;
}

.tag--out-and-back {
    background: #dbeafe;
    color: #1e40af;
}

.tag--easy {
    background: #d1fae5;
    color: #065f46;
}

.tag--medium {
    background: #fef3c7;
    color: #92400e;
}

.tag--hard {
    background: #fee2e2;
    color: #991b1b;
}

/* ---- Route Detail Page ---- */
.route-header {
    padding: 1rem 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.back-link {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.back-link:hover {
    color: var(--color-text);
}

.route-hero {
    width: 100%;
    height: 50vh;
    min-height: 350px;
    max-height: 550px;
}

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

.route-detail {
    padding: 2.5rem 0 4rem;
    max-width: 720px;
}

.route-detail-name {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.route-detail-subtitle {
    font-size: 1.05rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.route-detail-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1.25rem 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

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

.route-detail-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.route-detail-tags .tag {
    font-size: 0.85rem;
    padding: 0.35rem 0.85rem;
}

.route-detail-description {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--color-text);
    margin-bottom: 2rem;
}

/* ---- Recommended Stops ---- */
.stops-section {
    margin-bottom: 2rem;
}

.stops-heading {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.stops-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stop-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.stop-icon {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
    padding-top: 0.1rem;
}

.stop-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stop-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
}

.stop-note {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    background: var(--color-text);
    color: var(--color-surface);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.download-btn:hover {
    background: #333;
    color: var(--color-surface);
    transform: translateY(-1px);
}

.download-btn svg {
    width: 18px;
    height: 18px;
}

/* ---- Elevation Sparkline (Cards) ---- */
.route-card-elevation {
    height: 48px;
    margin-bottom: 0.75rem;
    overflow: visible;
    position: relative;
    cursor: crosshair;
}

.sparkline-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.sparkline-cursor {
    stroke: var(--color-text);
    stroke-width: 1;
    stroke-dasharray: 3 2;
    opacity: 0.5;
    visibility: hidden;
}

.sparkline-tooltip {
    display: none;
    position: absolute;
    top: -24px;
    transform: translateX(-50%);
    background: var(--color-text);
    color: var(--color-surface);
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

/* ---- Elevation Chart (Detail Page — Leaflet-Elevation) ---- */
.elevation-chart {
    position: relative;
    width: 100%;
    min-height: 200px;
    margin-bottom: 2rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    overflow: hidden;
}

.elevation-chart .elevation-control .area {
    fill: var(--color-accent);
    fill-opacity: 0.15;
}

.elevation-chart .elevation-control .line {
    stroke: var(--color-accent);
    stroke-width: 2;
}

.elevation-chart .elevation-summary {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

/* ---- Footer ---- */
.site-footer {
    margin-top: auto;
    padding: 2rem 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    border-top: 1px solid var(--color-border);
}

.site-footer a {
    color: var(--color-text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.site-footer a:hover {
    color: var(--color-text);
}

/* ---- Leaflet Overrides ---- */
.leaflet-container {
    background: #f0ede8;
    font-family: var(--font-body);
}

.route-card .leaflet-control-container {
    display: none;
}

/* ---- Loading State ---- */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .routes-grid,
    .regions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .site-header {
        padding: 3rem 0 1.5rem;
    }

    .site-title {
        font-size: 2.25rem;
    }

    .site-subtitle {
        font-size: 1rem;
    }

    .sliders {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .slider-group {
        max-width: none;
    }

    .routes-grid,
    .regions-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .route-card-map {
        height: 180px;
    }

    .route-hero {
        height: 40vh;
        min-height: 280px;
    }

    .route-detail-name {
        font-size: 1.75rem;
    }

    .route-detail-stats {
        gap: 1.5rem;
    }

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

@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }

    .filters {
        gap: 0.35rem;
    }

    .filter-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }
}
