/*
 * Accursus base styles. Mobile first: plain rules target phones, media queries adjust for larger screens.
 * Rules: no horizontal page scroll; tables scroll inside .table-responsive or collapse with .table-stack;
 * touch targets at least ~44 px.
 */

:root {
    --accursus-touch-target: 2.75rem;
}

/*
 * Sport group colours (Features/Activities/Display/SportGroups.cs): one fixed categorical slot per group, so a sport
 * has the same colour on every page and in every filter. Validated palette (dataviz reference): adjacent slots stay
 * apart for colour-blind readers in both modes. Dark mode uses the same hues stepped for the dark surface.
 * Colour never carries meaning alone: legends, labels and tables name every group.
 */
:root,
[data-bs-theme="light"] {
    --sport-running: #2a78d6;
    --sport-cycling: #eb6834;
    --sport-swimming: #1baf7a;
    --sport-walking: #eda100;
    --sport-training: #e87ba4;
    --sport-xc-skiing: #008300;
    --sport-alpine: #6250d6;
    --sport-paddling: #e34948;
    --sport-other: #898781;
}

[data-bs-theme="dark"] {
    --sport-running: #3987e5;
    --sport-cycling: #d95926;
    --sport-swimming: #199e70;
    --sport-walking: #c98500;
    --sport-training: #d55181;
    --sport-xc-skiing: #008300;
    --sport-alpine: #9085e9;
    --sport-paddling: #e66767;
    --sport-other: #898781;
}

/* A small key in a sport's colour next to its name (identity is never colour alone). */
.sport-swatch {
    display: inline-block;
    flex: none;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 2px;
    background: var(--swatch);
}

.sport-swatch-line {
    height: 0.25rem;
    width: 1rem;
}

/* One class per sport group (SportGroups keys), instead of inline style attributes: the CSP allows no inline styles. */
.sport-running { --swatch: var(--sport-running); }
.sport-cycling { --swatch: var(--sport-cycling); }
.sport-swimming { --swatch: var(--sport-swimming); }
.sport-walking { --swatch: var(--sport-walking); }
.sport-training { --swatch: var(--sport-training); }
.sport-xc-skiing { --swatch: var(--sport-xc-skiing); }
.sport-alpine { --swatch: var(--sport-alpine); }
.sport-paddling { --swatch: var(--sport-paddling); }
.sport-other { --swatch: var(--sport-other); }

/* Media never forces the page wider than the viewport. */
img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

/* Comfortable touch targets. */
.btn,
.navbar-toggler,
.navbar-nav .nav-link {
    min-height: var(--accursus-touch-target);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Server-side validation errors (no client-side validation library). */
.input-validation-error {
    border-color: var(--bs-form-invalid-border-color);
}

/* Activity list: the link is the touch target for the whole activity. */
.activity-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--accursus-touch-target);
}

/* Route map: full width, tall enough on phones without filling the screen. */
.activity-map {
    width: 100%;
    height: 55vh;
    min-height: 18rem;
    max-height: 36rem;
}

/* Beside the charts on large screens, the map stays in view while they move its marker. */
@media (min-width: 992px) {
    .activity-map-sticky {
        position: sticky;
        top: 1rem;
    }
}

/* The marker the activity charts move along the route (activity-map.js): the activity's sport colour, ringed. */
.activity-map-cursor {
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 50%;
    background: var(--swatch, var(--bs-primary));
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

/*
 * Activity charts (activity-charts.js): stacked, full width, one per channel. The readout above them stays in view
 * while scrolling past them on a phone.
 */
.activity-chart-readout {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 0 0.5rem;
    padding: 0.375rem 0;
    min-height: var(--accursus-touch-target);
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color-translucent);
    color: var(--bs-secondary-color);
}

.activity-readout-item {
    display: inline-block;
    margin-right: 0.875rem;
    white-space: nowrap;
}

.activity-readout-value {
    color: var(--bs-body-color);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.activity-chart {
    margin: 0 0 0.75rem;
}

.activity-chart-title {
    margin: 0 0 0.125rem;
    font-size: 0.875rem;
    color: var(--bs-secondary-color);
}

.activity-chart-canvas {
    position: relative;
    height: 9rem;
}

/* A vertical swipe scrolls the page; a horizontal one moves the crosshair. */
.activity-chart-canvas canvas {
    touch-action: pan-y;
}

@media (min-width: 768px) {
    .activity-chart-canvas {
        height: 10rem;
    }
}

/* Statistics trend chart: full width, a fixed readable height (the canvas fills it). */
.statistics-chart {
    position: relative;
    height: 18rem;
}

@media (min-width: 768px) {
    .statistics-chart {
        height: 22rem;
    }
}

/* Label/value rows in the stat cards. */
.stat-list {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 1rem;
}

.stat-list dt {
    font-weight: normal;
    color: var(--bs-secondary-color);
}

.stat-list dd {
    margin: 0;
    text-align: end;
    font-variant-numeric: tabular-nums;
}

/* Phosphor icons sized and aligned with surrounding text. */
.ph {
    font-size: 1.25em;
    line-height: 1;
}

/*
 * .table-stack: on phones each row becomes a card with "label: value" lines.
 * Put the column name in data-label on every <td>.
 */
@media (max-width: 575.98px) {
    .table-stack thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .table-stack tr {
        display: block;
        padding: 0.5rem 0;
        border-bottom: var(--bs-border-width) solid var(--bs-border-color);
    }

    .table-stack td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.25rem 0.5rem;
        border: 0;
        text-align: end;
    }

    .table-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: start;
    }
}
