/* ClickPrix — dark telemetry dashboard. */

:root {
    --bg-top: #0a0d13;
    --bg-bottom: #080a0f;
    --ink: #e7ecf3;
    --ink-soft: #aeb7c6;
    --ink-mute: #7a8598;
    --red: #ff444f;
    --red-hover: #ff6a72;
    --card: rgba(255, 255, 255, 0.025);
    --edge: rgba(255, 255, 255, 0.08);
    --sans: 'Space Grotesk', 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    font-family: var(--sans);
    background-color: var(--bg-bottom);
    background-image:
        radial-gradient(52rem 34rem at 88% -6%, rgba(255, 68, 79, 0.10), transparent 65%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(var(--bg-top), var(--bg-bottom));
    background-size: auto, 44px 44px, 44px 44px, auto;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

button {
    font: inherit;
}

h1:focus {
    outline: none;
}

/* ---- Blazor boilerplate (loading + error UI), restyled dark ---- */

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: rgba(255, 255, 255, 0.08);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #ff444f;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-family: var(--mono);
    color: #7a8598;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

#blazor-error-ui {
    background: #1a1114;
    color: #e7ecf3;
    border-top: 1px solid rgba(255, 68, 79, 0.5);
    bottom: 0;
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.5);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui a {
        color: #ff6a72;
    }

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 9px;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

/* ---- Page shell ---- */

.cp {
    max-width: 1080px;
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 3.5vw, 2rem) 3rem;
}

/* ---- Header ---- */

.cp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--edge);
}

.cp-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.cp-mark {
    width: 17px;
    height: 17px;
    border-radius: 4px;
    background: linear-gradient(135deg, #ff4f59, #e8323d);
    transform: skewX(-12deg);
    box-shadow: 0 0 14px rgba(255, 68, 79, 0.5);
}

.cp-wordmark {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.14em;
}

    .cp-wordmark em {
        font-style: normal;
        color: var(--red);
    }

.cp-caption {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    color: var(--ink-mute);
    text-align: right;
}

/* ---- Hero ---- */

.cp-hero {
    padding: clamp(2rem, 6vw, 3.5rem) 0 clamp(1.5rem, 4vw, 2.25rem);
}

.cp-eyebrow {
    font-family: var(--mono);
    color: var(--red);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    margin: 0 0 0.9rem;
}

.cp-headline {
    font-size: clamp(2.1rem, 5.5vw, 3.5rem);
    font-weight: 600;
    line-height: 1.04;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
}

.cp-lede {
    color: var(--ink-soft);
    max-width: 46rem;
    line-height: 1.55;
    margin: 0;
    font-size: clamp(0.95rem, 1.6vw, 1.05rem);
}

/* ---- Controls row ---- */

.cp-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.9rem;
    margin: 0 0 1.1rem;
}

.cp-modes {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: 12px;
    padding: 0.4rem;
}

.cp-mode {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s ease-out, border-color 0.15s ease-out, background-color 0.15s ease-out;
}

    .cp-mode:hover:not(:disabled) {
        color: var(--ink);
        border-color: var(--edge);
    }

    .cp-mode:disabled {
        opacity: 0.4;
        cursor: default;
    }

    .cp-mode.active {
        color: var(--red-hover);
        border-color: rgba(255, 68, 79, 0.55);
        background: rgba(255, 68, 79, 0.10);
    }

.cp-play {
    font-family: var(--sans);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.2em;
    text-indent: 0.2em;
    color: #fff;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.9rem 2rem;
    min-width: 9.5rem;
    cursor: pointer;
    background: linear-gradient(160deg, #ff4f59, #e8323d);
    box-shadow: 0 6px 26px rgba(255, 68, 79, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: filter 0.15s ease-out, box-shadow 0.2s ease-out;
}

    .cp-play:hover {
        filter: brightness(1.07);
    }

    .cp-play.playing {
        background: rgba(255, 255, 255, 0.07);
        border-color: var(--edge);
        box-shadow: none;
        color: var(--ink);
        filter: none;
    }

.cp-readout {
    flex: 1 1 15rem;
    min-width: 14rem;
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: 12px;
    padding: 0.7rem 0.95rem 0.8rem;
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 0.75rem;
    align-items: end;
}

.cp-readout-label {
    grid-column: 1 / -1;
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.15em;
    color: var(--ink-mute);
    margin-bottom: 0.35rem;
}

.cp-readout-pos {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--ink-soft);
    padding-bottom: 0.15rem;
}

.cp-readout-gap {
    font-family: var(--mono);
    font-weight: 600;
    font-size: clamp(1.4rem, 2.4vw, 1.8rem);
    color: var(--red);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.cp-progress {
    grid-column: 1 / -1;
    margin-top: 0.55rem;
    height: 3px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.cp-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--red);
    border-radius: 99px;
}

/* ---- Gap chart ---- */

.cp-chart {
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: 16px;
    padding: 1rem 1.1rem 1.15rem;
}

.cp-chart-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    color: var(--ink-mute);
    padding: 0 0.2rem 0.8rem;
    border-bottom: 1px solid var(--edge);
    margin-bottom: 0.6rem;
}

.cp-syncing {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    color: var(--ink-mute);
    text-align: center;
    padding: 2.5rem 0;
    margin: 0;
    animation: cp-sync 1.2s ease-in-out infinite alternate;
}

@keyframes cp-sync {
    from {
        opacity: 0.45;
    }

    to {
        opacity: 1;
    }
}

.cp-row {
    display: grid;
    grid-template-columns: 2.6ch 4px minmax(0, 10.5rem) 1fr 6.5ch;
    align-items: center;
    gap: 0.7rem;
    padding: 0.32rem 0.2rem;
    border-radius: 9px;
    transition: background-color 0.18s ease-out;
}

    .cp-row.flash {
        background: rgba(255, 68, 79, 0.14);
    }

/* Highlight view: no lanes, crossed rows stay lit instead */
.cp-chart.no-lanes .cp-lane {
    display: none;
}

.cp-chart.no-lanes .cp-row {
    grid-template-columns: 2.6ch 4px minmax(0, 1fr) 6.5ch;
}

.cp-chart.no-lanes .cp-row.lit {
    background: rgba(255, 68, 79, 0.08);
    box-shadow: inset 2px 0 0 var(--red);
}

.cp-chart.no-lanes .cp-row.flash {
    background: rgba(255, 68, 79, 0.2);
}

.cp-pos {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--ink-mute);
    text-align: right;
}

.cp-teambar {
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--team, #8b95a7);
}

.cp-driver {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    min-width: 0;
}

.cp-code {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    color: var(--ink);
}

.cp-teamname {
    font-size: 0.72rem;
    color: var(--ink-mute);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-lane {
    position: relative;
    height: 14px;
    border-radius: 99px;
    background: rgba(0, 0, 0, 0.36);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.cp-finish {
    position: absolute;
    left: 86%;
    top: 0;
    bottom: 0;
    width: 5px;
    transform: translateX(-50%);
    background: repeating-linear-gradient(45deg, #dfe5ee 0 2.5px, #10141b 2.5px 5px);
    opacity: 0.75;
}

.cp-pulse {
    position: absolute;
    left: 86%;
    top: 50%;
    width: 14px;
    height: 14px;
    transform: translate(-50%, -50%) scale(0.4);
    border-radius: 50%;
    background: radial-gradient(rgba(255, 68, 79, 0.85), transparent 70%);
    opacity: 0;
    pointer-events: none;
}

    .cp-pulse.pulsing {
        animation: cp-pulse 0.6s ease-out;
    }

@keyframes cp-pulse {
    0% {
        opacity: 0.95;
        transform: translate(-50%, -50%) scale(0.5);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2.6);
    }
}

.cp-marker {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 8px;
    border-radius: 99px;
    transform: translate(-50%, -50%);
    background: var(--team, #8b95a7);
    box-shadow: 0 0 9px 1px color-mix(in srgb, var(--team, #8b95a7) 75%, transparent);
}

    .cp-marker.crossed {
        animation: cp-hit 0.45s ease-out;
        box-shadow: 0 0 12px 2px var(--team, #8b95a7);
    }

@keyframes cp-hit {
    0% {
        filter: brightness(2.2);
    }

    100% {
        filter: brightness(1);
    }
}

.cp-gap {
    font-family: var(--mono);
    font-size: 0.78rem;
    text-align: right;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

    .cp-gap.pole {
        color: var(--red);
        font-weight: 600;
        letter-spacing: 0.08em;
    }

/* ---- Footer ---- */

.cp-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.4rem;
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.14em;
    color: var(--ink-mute);
}

.cp-footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    color: var(--ink-mute);
    text-decoration: none;
    transition: color 0.15s ease-out;
}

.cp-github-mark {
    width: 1.6em;
    height: 1.6em;
    flex: none;
}

    .cp-footer-link:hover {
        color: var(--red-hover);
    }

.cp-source {
    display: inline-flex;
    align-items: center;
    gap: 0.6em;
}

.cp-source-btn {
    font: inherit;
    letter-spacing: inherit;
    color: var(--ink-mute);
    background: transparent;
    border: 1px solid var(--edge);
    border-radius: 6px;
    padding: 0.25em 0.55em;
    cursor: pointer;
    transition: color 0.15s ease-out, border-color 0.15s ease-out, background-color 0.15s ease-out;
}

    .cp-source-btn:hover:not(:disabled) {
        color: var(--ink);
    }

    .cp-source-btn.active {
        color: var(--red-hover);
        border-color: rgba(255, 68, 79, 0.55);
        background: rgba(255, 68, 79, 0.10);
    }

    .cp-source-btn:disabled {
        opacity: 0.5;
        cursor: default;
    }

/* ---- Narrow screens ---- */

@media (max-width: 640px) {
    .cp-teamname {
        display: none;
    }

    .cp-row {
        grid-template-columns: 2.4ch 3px auto 1fr 5.8ch;
        gap: 0.5rem;
    }

    .cp-chart.no-lanes .cp-row {
        grid-template-columns: 2.4ch 3px 1fr 5.8ch;
    }

    .cp-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .cp-readout {
        flex-basis: auto;
    }

    .cp-modes {
        justify-content: center;
    }

    .cp-mode {
        flex: 1 1 auto;
        text-align: center;
    }

    .cp-header {
        flex-wrap: wrap;
    }

    .cp-chart {
        padding: 0.8rem 0.7rem 0.9rem;
    }
}
