/* =============================================================================
   Track Map Page
   Prefix: .tm-
   ============================================================================= */

.tm-page {
    padding: 28px 0 48px;
}

/* ─── Breadcrumb / back link ─────────────────────────────────────────────────── */
.tm-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--lm-text-gray);
    text-decoration: none;
    margin-bottom: 16px;
    transition: color var(--lm-t);
}
.tm-back:hover { color: var(--lm-red); text-decoration: none; }
.tm-back .material-symbols-outlined { font-size: 16px; }

/* ─── Page title ─────────────────────────────────────────────────────────────── */
.tm-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--lm-text);
    margin: 0 0 20px;
    line-height: 1.25;
}

/* ─── Meta strip ─────────────────────────────────────────────────────────────── */
.tm-meta-card {
    background: var(--lm-card-bg);
    border: 1px solid var(--lm-border);
    border-radius: var(--lm-r-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px 24px;
}

@media (max-width: 767px) {
    .tm-meta-card {
        grid-template-columns: repeat(2, 1fr);
        padding: 16px;
        gap: 14px 16px;
    }
}

@media (max-width: 480px) {
    .tm-meta-card {
        grid-template-columns: 1fr;
    }
}

.tm-meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tm-meta-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--lm-r-sm);
    background: var(--lm-red-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tm-meta-icon .material-symbols-outlined {
    font-size: 16px;
    color: var(--lm-red);
}

.tm-meta-text {
    min-width: 0;
}

.tm-meta-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--lm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
    white-space: nowrap;
}

.tm-meta-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--lm-text);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tm-meta-value a {
    color: var(--lm-text);
    text-decoration: none;
}
.tm-meta-value a:hover { color: var(--lm-red); }

/* ─── Map card ───────────────────────────────────────────────────────────────── */
.tm-map-card {
    background: var(--lm-card-bg);
    border: 1px solid var(--lm-border);
    border-radius: var(--lm-r-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.tm-map-img-link {
    display: block;
}

.tm-map-img {
    width: 100%;
    /* Track maps are ~square (background-size:contain in a wide box), so the
       rendered map is height-constrained — its size is driven by this box
       height, not the 100% width. 672px = 480 × 1.4 makes the map ~40% larger
       while the wider render still fits the container width. */
    min-height: 672px;
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    background-color: var(--lm-card-bg);
    transition: opacity var(--lm-t);
}
.tm-map-img-link:hover .tm-map-img { opacity: 0.9; }

/* Dark mode: prefer a baked dark export when available, else invert the light
   map — mirrors the lap screen's .ls-track-map (has-dark-map / invert-on-dark).
   The image background must be transparent so invert() flips only the map SVG
   (dark lines -> white) and the dark card surface shows through, rather than
   inverting --lm-card-bg into a light grey. */
html[data-theme="dark"] .tm-map-img.has-dark-map { background-image: var(--tm-map-dark) !important; }
html[data-theme="dark"] .tm-map-img.invert-on-dark {
    filter: invert(1) grayscale(1);
    background-color: transparent;
}

@media (max-width: 767px) {
    .tm-map-img { min-height: 392px; } /* 280 × 1.4 — keep the +40% on mobile */
}

.tm-map-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--lm-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.tm-map-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--lm-red);
    text-decoration: none;
    transition: color var(--lm-t);
}
.tm-map-link:hover { color: var(--lm-red-hover); text-decoration: none; }
.tm-map-link .material-symbols-outlined { font-size: 16px; }

/* ─── Elevation profile card ─────────────────────────────────────────────────── */
.tm-elev-card {
    background: var(--lm-card-bg);
    border: 1px solid var(--lm-border);
    border-radius: var(--lm-r-lg);
    padding: 16px 20px 20px;
    margin-bottom: 16px;
}

.tm-elev-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--lm-text-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

/* Baked 1600×380 PNG; aspect-ratio keeps the box matched to the image so
   background-size:contain never letterboxes. Dark mode swaps to the baked
   dark export via the same CSS-var pattern as .tm-map-img. */
.tm-elev-img {
    width: 100%;
    aspect-ratio: 1600 / 380;
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
}
html[data-theme="dark"] .tm-elev-img.has-dark-map { background-image: var(--tm-map-dark) !important; }

/* ─── Notes card ─────────────────────────────────────────────────────────────── */
.tm-notes-card {
    background: var(--lm-card-bg);
    border: 1px solid var(--lm-border);
    border-radius: var(--lm-r-lg);
    padding: 20px 24px;
}

.tm-notes-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--lm-text-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.tm-notes-body {
    font-size: 14px;
    color: var(--lm-text-mid);
    line-height: 1.7;
}

/* ─── Dark mode ──────────────────────────────────────────────────────────────── */
/* The track SVG is transparent — var(--lm-card-bg) shows through as the dark
   background, giving black track + white labels on dark naturally. No filter
   needed; just let the background-color on the parent card do the work. */
