/* Route replay */

/* Layout */
.route-page {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    grid-template-areas:
        "head     stats"
        "map      map"
        "results  results";
    column-gap: 20px;
}

.route-head {
    grid-area: head;
}

#route-stats {
    grid-area: stats;
    align-self: end;
    justify-self: end;
}

#route-map {
    grid-area: map;
}

#route-results {
    grid-area: results;
}

/* Controls */
#route-controls {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 10px 0 0 0;
}

.route-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.route-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    color: white;
}

.route-btn-play {
    border: 1px solid #0d6efd;
    background: #0d6efd;
    font-weight: 600;
}

.route-btn-reset {
    border: 1px solid #6c757d;
    background: #6c757d;
}

.speed-btn {
    height: 32px;
    min-width: 36px;
    padding: 4px 8px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.speed-btn:hover {
    background: #f8f9fa;
    border-color: #0d6efd;
}

.speed-btn.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
    font-weight: bold;
}

/* Scrubber, which is also the progress bar. Chrome and Safari get their fill
   from a gradient in updateProgressBar(). */
#progressScrubber {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    cursor: pointer;
    background: #dee2e6;
    border-radius: 4px;
}

#progressScrubber::-webkit-slider-runnable-track {
    height: 8px;
    background: transparent;
    border-radius: 4px;
}

#progressScrubber::-moz-range-track {
    height: 8px;
    background: #dee2e6;
    border-radius: 4px;
}

#progressScrubber::-moz-range-progress {
    height: 8px;
    background: #0d6efd;
    border-radius: 4px;
}

#progressScrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid #999;
    border-radius: 2px;
    cursor: pointer;
    margin-top: -6px;
}

#progressScrubber::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid #999;
    border-radius: 2px;
    cursor: pointer;
}

/* Live panel, written by updateStats() */
#route-stats {
    margin-top: 10px;
    margin-bottom: 2px;
}

#route-stats table {
    margin-bottom: 0;
}

#route-stats td {
    padding: 2px 10px;
    font-family: monospace;
    font-size: 14px;
    white-space: nowrap;
    line-height: 1.2;
}

#route-stats .rs-label {
    padding: 2px 15px 2px 8px;
}

#route-stats .rs-time      { color: #0d6efd; }
#route-stats .rs-distance  { color: #198754; }
#route-stats .rs-pace      { color: #fd7e14; }
#route-stats .rs-hr        { color: #dc3545; }
#route-stats .rs-direction { color: #6f42c1; font-weight: bold; padding: 2px 8px 2px 10px; }

#route-stats .runner-badge {
    color: #ffffff;
    display: inline-block;
    min-width: 60px;
    padding: 2px 8px;
    border-radius: 3px;
    border: 2px solid white;
    font-weight: bold;
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
}

#route-map {
    z-index: 1;
    height: 600px;
    width: 100%;
    margin-top: 30px;
}

/* Results */
#route-results {
    margin-top: 30px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
        "heading  heading"
        "note     note"
        "table    chart";
    column-gap: 40px;
    align-items: start;
}

#route-results h2 {
    grid-area: heading;
    margin-top: 0;
}

.route-results-note {
    grid-area: note;
    color: #666;
    font-style: italic;
    margin-bottom: 15px;
}

.route-results-table {
    grid-area: table;
    border-collapse: collapse;
    width: auto;
    min-width: 320px;
}

.route-results-table th {
    text-align: left;
    border-bottom: 1px #aaaaff solid;
    padding: 4px 14px 4px 0;
    font-size: 13px;
    font-weight: normal;
    color: #aaa;
    white-space: nowrap;
}

.route-results-table td {
    padding: 5px 14px 5px 0;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.route-results-table .rr-place {
    white-space: nowrap;
}

.route-results-table .rr-place-number {
    display: inline-block;
    min-width: 1.6em;
    font-weight: bold;
}

.route-results-table .rr-distance,
.route-results-table .rr-time,
.route-results-table .rr-gap {
    text-align: right;
    font-family: monospace;
}

.route-results-table th.rr-distance,
.route-results-table th.rr-time,
.route-results-table th.rr-gap {
    text-align: right;
}

.route-results-table .rr-best .rr-time {
    font-weight: bold;
}

.route-results-table .rr-gap-best {
    color: #198754;
    font-weight: bold;
    font-family: inherit;
}

/* Chart */
.route-chart {
    grid-area: chart;
    min-width: 0;
    max-width: 560px;
}

.route-chart-svg {
    display: block;
    width: 100%;
    height: auto;
}

.route-chart-badge {
    stroke: #fff;
    stroke-width: 1;
}

/* Route::resultsChartSVG() sizes the badge from this font size */
.route-chart-label {
    font-size: 12px;
    font-weight: bold;
    fill: #ffffff;
}

.route-chart a {
    cursor: pointer;
    text-decoration: none;
}

.route-chart a text {
    text-decoration: none;
}

.route-chart a:hover rect,
.route-chart a:hover circle {
    filter: brightness(1.12);
}

.route-chart-grid {
    stroke: #e0e0f0;
    stroke-width: 1;
}

.route-chart-tick {
    fill: #999;
    font-size: 11px;
}

.route-chart-line {
    fill: none;
    stroke: #bbb;
    stroke-width: 2;
}

.route-chart-dot {
    stroke: #fff;
    stroke-width: 1.5;
}

/* Indented to where the first figure on the axis starts */
.route-chart-caption {
    margin: 0 0 2px 0;
    padding-left: 4.2%;
    color: #999;
    font-size: 12px;
    font-style: italic;
}

/* Map markers */
.gps-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.3);
    position: absolute;
    left: 0;
    top: 0;
}

.label-badge {
    margin: 0;
    position: absolute;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid white;
    color: white;
    font-weight: bold;
    font-size: 9px;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    line-height: 1.2;
    transform: translate(-50%, -50%);
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 10px 14px;
    line-height: 1.4;
}

/* Route list */
.route-card {
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.route-card h2 {
    font-size: 1.5rem;
    margin: 0 0 8px 0;
}

.route-card h2 a {
    text-decoration: none;
}

.route-card h2 a:hover {
    text-decoration: underline;
}

.route-card-facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    margin: 8px 0 0 0;
    color: #666;
    font-size: 14px;
}

.route-card-best .fa {
    margin-right: 4px;
}

/* One column: the panel no longer fits beside the controls */
@media (max-width: 1199px) {
    .route-page {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "head"
            "map"
            "stats"
            "results";
        column-gap: 0;
    }

    #route-stats {
        justify-self: start;
        align-self: start;
        margin-top: 15px;
    }

    #route-results {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "heading"
            "note"
            "table"
            "chart";
        column-gap: 0;
    }

    .route-chart {
        margin-top: 20px;
    }
}

/* The panel drops one column at a time, least useful first */
@media (max-width: 530px) {
    #route-stats .rs-time {
        display: none;
    }
}

@media (max-width: 455px) {
    #route-stats .rs-direction {
        display: none;
    }
}

@media (max-width: 400px) {
    #route-stats .rs-hr {
        display: none;
    }
}

@media (max-width: 345px) {
    #route-stats .rs-pace {
        display: none;
    }
}

/* A phone */
@media (max-width: 768px) {
    #route-stats table {
        border-collapse: collapse;
    }

    #route-stats td {
        padding: 3px 8px 3px 0;
    }

    #route-stats .rs-label {
        padding-left: 0;
    }

    .route-buttons {
        flex-wrap: wrap;
    }

    #route-map {
        height: 400px;
        margin-top: 20px;
    }

    .route-results-table {
        min-width: 0;
        width: 100%;
    }

    .route-results-table .rr-distance {
        display: none;
    }

    .route-results-table th,
    .route-results-table td {
        padding-right: 8px;
    }

    .route-results-table .rr-place {
        white-space: normal;
    }

    #route-stats {
        max-width: 100%;
        overflow-x: auto;
    }
}

/* A phone held upright */
@media (max-width: 560px) {
    .route-results-table .rr-day {
        display: none;
    }

    /* Ticks only: PHP sizes the labels' badges from .route-chart-label */
    .route-chart-tick {
        font-size: 16px;
    }
}

@media (max-width: 400px) {
    .route-results-table th,
    .route-results-table td {
        padding-right: 6px;
    }

    .route-results-table .rr-place-number {
        min-width: 1.2em;
    }
}
