/* SVR.League.Telemetry.UI — shared stylesheet
 * Consumed by both the MAUI Blazor host and the WASM viewer via
 * <link href="_content/SVR.League.Telemetry.UI/css/ui.css" rel="stylesheet" />
 */

/* ── App backdrop ────────────────────────────────────────────────
 * Lighter down the middle, darker toward the edges. The gradient is
 * horizontal and viewport-wide, so any full-width element painting
 * --svr-app-bg lines up seamlessly with the page behind it: body, a
 * sticky header and a fixed inset:0 overlay all agree pixel-for-pixel.
 * Anything narrower (dialog interiors, cards, panels) must NOT use it —
 * it would show a squeezed copy. Those take the solid --svr-bg-center,
 * which is also what the MudBlazor Background palette entry is set to.
 */
:root {
    --svr-bg-center: #061319;
    --svr-bg-edge: #040a10;
    --svr-app-bg: linear-gradient(90deg, var(--svr-bg-edge) 0%, var(--svr-bg-center) 50%, var(--svr-bg-edge) 100%);

    /* Cards sit one step above the backdrop, in the same two-colour family. The light
     * pools a little below the middle — behind the car or circuit artwork — rather than
     * dead centre, and the card edge lands on the page's own centre colour, so a card
     * reads as a lift out of the page rather than a panel dropped onto it. */
    --svr-card-glow: #0a1e26;
    --svr-card-edge: #06131a;
    --svr-card-bg: radial-gradient(ellipse 130% 100% at 50% 68%, var(--svr-card-glow) 0%, var(--svr-card-edge) 70%);
}

html, body {
    /* Saira where the host declares it (the MAUI app); hosts that still ship Formula1 fall back to it. */
    font-family: 'Saira', 'Formula1', Roboto, Arial, sans-serif;
    background: var(--svr-app-bg);
}

/* Dialogs sit on the same backdrop rather than the surface colour. A full-screen
 * dialog spans the viewport and so lines up with the page behind it; a smaller,
 * centred one paints its own copy — lighter through its middle, darker at its own
 * edges. Loaded after MudBlazor.min.css in every host, so this wins on order. */
.mud-dialog {
    background: var(--svr-app-bg);
}

/* ── Car image loading placeholder ───────────────────────────────────
 * Put .svr-car-loading on the box that wraps a car photo and add the class
 * "loaded" once the photo has loaded (or failed). Until then the box shows a
 * wireframe car cycling through the spectrum, which reads as a progress hint
 * without needing a spinner on top of the artwork.
 */
.svr-car-loading {
    position: relative;
}

.svr-car-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('../img/car-loading.png') center / contain no-repeat;
    opacity: 0.5;
    pointer-events: none;
    animation: svr-car-loading-cycle 3.2s linear infinite;
}

.svr-car-loading.loaded::before {
    display: none;
}

/* The photo fades in over the placeholder rather than replacing it abruptly. */
.svr-car-loading img {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.svr-car-loading.loaded img {
    opacity: 1;
}

/* The artwork is blue, so a full hue rotation walks it through every colour. */
@keyframes svr-car-loading-cycle {
    from { filter: hue-rotate(0deg); }
    to   { filter: hue-rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .svr-car-loading::before {
        animation: none;
    }
}

/* ── Lap-time badge (best lap highlight) ─────────────────────────── */
.best-lap-badge {
    background-color: #7B1FA2;
    color: white;
    padding: 1px 8px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}

/* ── Clickable card base ─────────────────────────────────────────── */
.svr-card-clickable {
    cursor: pointer;
    transition: background-color 0.15s;
}

.svr-card-clickable:hover {
    background-color: var(--mud-palette-action-default-hover);
}

/* ── Track map corner labels (HTML overlay from trackMap3D.js) ───── */
/* Under the WebGL canvas (z-index 2); placement keeps labels off the track ribbon. */
.track-map-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.track-corner-label {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    color: rgba(236, 240, 241, 0.8);
    font: 600 12px/1.15 Roboto, Arial, sans-serif;
    text-align: center;
    padding: 2px 5px;
    border-radius: 3px;
    background: rgba(11, 11, 22, 0.55);
    text-shadow: 0 0 2px #0b0b16, 0 1px 1px #0b0b16;
    white-space: nowrap;
    box-sizing: border-box;
}

.track-corner-label-num {
    display: block;
    line-height: 1.15;
    font-size: 12px;
}

.track-corner-label-name {
    display: block;
    line-height: 1.15;
    font-size: 10px;
    font-weight: 500;
    opacity: 0.85;
}

.track-corner-anchor {
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 3px;
    margin: -1.5px 0 0 -1.5px;
    border-radius: 50%;
    background: rgba(236, 240, 241, 0.55);
    opacity: 0.7;
    box-shadow: 0 0 2px #0b0b16;
}

.track-corner-leader {
    position: absolute;
    left: 0;
    top: 0;
    height: 1px;
    transform-origin: 0 50%;
    background: rgba(236, 240, 241, 0.28);
}

/* ── History list layout (day groups + card grid) ─────────────────── */
.history-day-header {
    margin-top: 0.5rem;
    margin-bottom: 0.15rem;
}

.history-day-header:first-child {
    margin-top: 0;
}

.history-date-heading {
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.history-day-summary {
    margin-top: 2px;
    line-height: 1.3;
}

/* Session/history cards — same lift-from-page gradient as the Cars page cards.
 * Lives here (not scoped CSS) because HistoryCard's root is a MudPaper: Blazor
 * isolation + ::deep cannot attach a background to that host element reliably. */
.mud-paper.history-card--clean {
    background: var(--svr-card-bg);
    position: relative;
    /* Clip the car reflection so it cannot bleed past the card edge. */
    overflow: hidden;
    border-left: 3px solid var(--mud-palette-secondary);
    cursor: pointer;
    padding: 8px 12px;
    height: 100%;
    box-sizing: border-box;
}

/* The card fill is a gradient, so a hover background-color would sit behind it
   and never show. Fade a tint over the top instead. The car visual sits at
   z-index 0 and the card body at 1, so the tint lands between them. */
.mud-paper.history-card--clean::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: var(--mud-palette-action-default-hover);
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 0;
}

.mud-paper.history-card--clean:hover::after {
    opacity: 1;
}

.mud-paper.history-card--clean.history-card-static {
    cursor: default;
}

.mud-paper.history-card--clean.history-card-static:hover::after {
    opacity: 0;
}

/* Photo cards (HistoryCard with a circuit photo): the photo and its fades sit under
   the hover tint; a light shadow keeps the title and stats crisp over busy scenery. */
.mud-paper.history-card--photo .hc-title,
.mud-paper.history-card--photo .hc-best,
.mud-paper.history-card--photo .hc-stats {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.history-card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
}

.history-card-grid > * {
    min-width: 0;
}

/* Offset each card's placeholder cycle so a list of sessions drifts through the
   spectrum instead of pulsing in unison. Negative delays start mid-cycle. */
.history-card-grid > *:nth-child(3n+2) .svr-car-loading::before { animation-delay: -1.1s; }
.history-card-grid > *:nth-child(3n+3) .svr-car-loading::before { animation-delay: -2.2s; }

.history-card-grid > .history-card-wrapper {
    display: flex;
}

.history-card-grid > .history-card-wrapper > * {
    flex: 1 1 auto;
    width: 100%;
}

.history-card-grid > .history-card,
.history-card-grid > .history-card-wrapper > .history-card,
.history-card-grid > .history-card-wrapper > .mud-paper {
    height: 100%;
}

@media (min-width: 900px) {
    .history-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .history-card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ── iOS-style bottom sheets (shared with MAUI host) ─────────────── */
.mud-dialog-container.mud-dialog-bottomcenter {
    align-items: flex-end !important;
    /* MudBlazor defaults to 32px bottom + centred layout; sheets should be flush. */
    justify-content: stretch !important;
    padding: 0 !important;
}

.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog,
.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-full,
.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-false,
.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-xs,
.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-sm,
.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-md {
    /* Override MudBlazor's calc(100% - 64px) full-width gutter. */
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: min(85dvh, 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    /* No bottom inset here: the MAUI host puts the bottom and side insets on the title, content
       and actions (MainLayout.razor), so a padding on the sheet too doubled the home-indicator
       gap. The web hosts have no viewport-fit=cover, so env() is 0 there anyway. */
    animation: sheet-slide-up 280ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog .mud-dialog-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog .mud-dialog-actions {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 8px;
}

.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog .mud-dialog-actions > .mud-button-root {
    width: 100%;
    margin: 0 !important;
    justify-content: center;
}

.sheet-handle {
    display: none;
    justify-content: center;
    padding: 10px 0 4px;
    flex: 0 0 auto;
    touch-action: none;
    cursor: grab;
}

.mud-dialog-container.mud-dialog-bottomcenter .sheet-handle {
    display: flex;
}

.sheet-handle-pill {
    width: 36px;
    height: 5px;
    border-radius: 3px;
    background: var(--mud-palette-text-disabled);
    opacity: 0.85;
}

/* Bottom-sheet dialog titles need vertical room for the close control.
   position:relative is required so MudBlazor's absolute .mud-button-close
   (top:50%) anchors to the title row. Without it, the sheet's
   backdrop-filter (and slide-up transform) become the containing block
   and the X lands mid-dialog — especially visible on iOS WKWebView. */
.mud-dialog-container.mud-dialog-bottomcenter .mud-dialog-title {
    position: relative;
    min-height: 52px;
    padding-top: 14px;
    padding-bottom: 14px;
    display: flex;
    align-items: center;
}

.mud-dialog-container.mud-dialog-bottomcenter .mud-dialog-title .mud-typography-h6,
.mud-dialog-container.mud-dialog-bottomcenter .mud-dialog-title.mud-typography-h6 {
    font-size: 1.05rem !important;
    font-weight: 600;
    line-height: 1.3;
}

.mud-dialog-container.mud-dialog-bottomcenter .sheet-title {
    font-weight: 600;
    width: 100%;
    padding: 0 8px 4px;
}

/* Close / icon control — soft circular fill always visible
   (MudBlazor only paints hover fill on fine pointers; mobile never gets it).
   Sized for a comfortable touch target inside the sheet title row. */
.sheet-close,
.mud-dialog-container.mud-dialog-bottomcenter .mud-dialog-title .mud-button-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 6px !important;
    border-radius: 50%;
    background-color: var(--mud-palette-action-default-hover);
}

.mud-dialog-container.mud-dialog-bottomcenter .mud-dialog-title .mud-button-close {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
}

.sheet-close .mud-icon-root,
.mud-dialog-container.mud-dialog-bottomcenter .mud-dialog-title .mud-button-close .mud-icon-root {
    font-size: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
}

.mud-dialog-container.mud-dialog-bottomcenter .mud-dialog-title:has(.mud-button-close) {
    padding-inline-end: 56px;
}

@media (hover: hover) and (pointer: fine) {
    .sheet-close:hover,
    .mud-dialog-container.mud-dialog-bottomcenter .mud-dialog-title .mud-button-close:hover {
        background-color: color-mix(in srgb, var(--mud-palette-action-default-hover) 70%, var(--mud-palette-text-primary) 30%);
    }
}

/* Picker drawer header — match MudDialog sheet title chrome */
.sheet-picker-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 4px 52px 12px;
}

.sheet-picker-header .sheet-title {
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.3;
    width: 100%;
    text-align: center;
}

.sheet-picker-header .sheet-close:not(.sheet-back) {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.sheet-picker-header .sheet-back {
    position: absolute;
    left: 8px;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
}

.sheet-picker-row {
    background: transparent !important;
    border-radius: 12px;
    box-shadow: none !important;
}

.sheet-picker-row:active {
    background: var(--mud-palette-action-default-hover) !important;
}

/* Drag-to-dismiss (bottomSheetDismiss.js in MAUI host) */
.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.sheet-dragging {
    animation: none !important;
    transition: none !important;
    touch-action: none;
    user-select: none;
    cursor: grabbing;
}

.mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.sheet-dismissing {
    pointer-events: none;
    animation: none !important;
}

@keyframes sheet-slide-up {
    from {
        transform: translateY(100%);
        opacity: 0.6;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Long picker lists (track, car). One column, except in a wide landscape sheet below. */
.sheet-picker-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── Landscape phone: centred sheets ──────────────────────────────────
 * A full-width sheet puts its edges under the notch / Dynamic Island and the
 * side navigation bar, and 85% of a landscape phone is very little height.
 * Like iOS's own sheets, cap the width and centre it, and let it rise almost
 * to the top. Centred sheets clear the side insets, so the side margins and
 * padding that the MAUI host (MainLayout.razor, the picker drawer hosts) adds
 * for full-width sheets are dropped. Long pickers (.sheet-wide) get more width
 * and lay their rows in two columns.
 *
 * This block must stay in ui.css, below the base sheet rules above, and ui.css
 * must stay the last stylesheet a host loads: the base rules set the sheet's
 * width, margin and the container's justify-content with !important, and a
 * media query adds no specificity, so the same overrides placed in a host's
 * app.css (loaded earlier) lose to them. App 2.0.3-2.0.6 shipped exactly that
 * and kept their landscape dialogs full width, under the Dynamic Island.
 */
@media (orientation: landscape) and (max-height: 500px) {
    .mud-dialog-container.mud-dialog-bottomcenter {
        justify-content: center !important;
    }

    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog,
    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-full,
    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-false,
    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-xs,
    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-sm,
    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.mud-dialog-width-md {
        width: min(540px, 100%) !important;
        margin: 0 auto !important;
        max-height: calc(100% - 10px);
    }

    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog.sheet-fixed-height {
        height: calc(100% - 10px);
    }

    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog > .mud-dialog-title,
    .mud-dialog-container.mud-dialog-bottomcenter > .mud-dialog > .mud-focus-trap > .mud-focus-trap-child-container > * {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* .mud-drawer-temporary is in the selector to beat MudBlazor's
       .mud-drawer.mud-drawer-temporary { margin: 0 !important } whatever the load order: an equally
       specific !important would lose to it when it loads later, and the sheet sits at the left edge. */
    .mud-drawer.mud-drawer-temporary.ios-bottom-sheet,
    .mud-drawer.mud-drawer-temporary.bottom-sheet {
        /* MudDrawer writes its Height as an inline height. */
        --mud-drawer-height: calc(100dvh - 10px) !important;
        height: calc(100dvh - 10px) !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
        width: min(540px, 100%) !important;
    }

    /* Two columns need the extra width, but never so much that the edge reaches the side insets. */
    .mud-drawer.mud-drawer-temporary.ios-bottom-sheet.sheet-wide,
    .mud-drawer.mud-drawer-temporary.bottom-sheet.sheet-wide {
        width: min(720px, 100% - 2 * max(var(--svr-safe-left, 0px), var(--svr-safe-right, 0px)) - 16px) !important;
    }

    .mud-drawer.ios-bottom-sheet .mud-drawer-content > .sheet-host-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .mud-drawer.ios-bottom-sheet.sheet-wide .sheet-picker-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px 8px;
    }
}

/* ───────────── social ─────────────
   Global rather than scoped: the feed, profile, friends and rail are several components sharing
   one set of rows, avatars and cards, and scoped ::deep cannot paint a MudPaper root. */

.mud-paper.social-card {
    background: var(--svr-card-bg);
    position: relative;
    overflow: hidden;
    border-left: 3px solid var(--mud-palette-secondary);
    padding: 10px 12px;
    box-sizing: border-box;
}

/* The accent rail carries the entry type, so a feed scans by colour before it is read. */
.mud-paper.social-card.social-card--best { border-left-color: var(--mud-palette-warning); }
.mud-paper.social-card.social-card--session { border-left-color: var(--mud-palette-primary); }
.mud-paper.social-card.social-card--quiet { border-left-color: var(--mud-palette-lines-default); }
.mud-paper.social-card.social-card--live { border-left-color: var(--mud-palette-success); }
.mud-paper.social-card.social-card--invites { border-left-color: var(--mud-palette-error); }

.social-flag {
    width: 18px;
    height: auto;
    border-radius: 2px;
    margin-right: 5px;
    vertical-align: -1px;
}

/* ── avatar ── */

.social-avatar {
    --social-avatar-size: 36px;
    --social-avatar-ring: rgba(255, 255, 255, 0.12);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: var(--social-avatar-size);
    height: var(--social-avatar-size);
    border-radius: 50%;
    background: #1d1a2e;
    box-shadow: 0 0 0 2px var(--social-avatar-ring);
    color: var(--mud-palette-text-primary);
    font-weight: 700;
    font-size: calc(var(--social-avatar-size) * 0.36);
    letter-spacing: -0.02em;
}

.social-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.social-avatar--sm { --social-avatar-size: 28px; }
.social-avatar--feed { --social-avatar-size: 48px; }
.social-avatar--lg { --social-avatar-size: 72px; }
.social-avatar--live { --social-avatar-ring: var(--mud-palette-error); }

.social-avatar-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 30%;
    height: 30%;
    min-width: 8px;
    min-height: 8px;
    border-radius: 50%;
    background: var(--mud-palette-error);
    box-shadow: 0 0 0 2px var(--mud-palette-background);
}

.social-avatar--more {
    background: rgba(255, 255, 255, 0.06);
    color: var(--mud-palette-text-secondary);
    font-size: 0.7rem;
}

.social-avatar-stack {
    display: inline-flex;
    align-items: center;
}

.social-avatar-stack > * + * {
    margin-left: -8px;
}

.social-avatar-stack .social-avatar {
    box-shadow: 0 0 0 2px var(--mud-palette-background);
}

/* ── tyres ── */

.tyre-dots {
    display: inline-flex;
    gap: 3px;
}

.tyre-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--tyre-dot-color);
    background: #111;
    color: var(--tyre-dot-color);
    font-size: 0.6rem;
    font-weight: 800;
    line-height: 1;
}

/* ── hub and rail ── */

.social-hub {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.social-hub-rail {
    display: none;
}

@media (min-width: 1100px) {
    .social-hub {
        grid-template-columns: minmax(0, 1fr) 340px;
    }

    .social-hub-rail {
        display: block;
        position: sticky;
        top: 72px;
    }

    /* The rail already shows who is on track. */
    .social-hub-main .social-feed > .presence-card {
        display: none;
    }
}

.social-rail {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rail-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 0;
    position: relative;
    z-index: 1;
}

.rail-row + .rail-row {
    border-top: 1px solid rgba(255, 255, 255, 0.045);
}

.rail-row > a {
    line-height: 0;
}

.rail-row-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.rail-row-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.rail-row-sub {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.social-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 2px 2px;
}

.social-section-rule,
.social-feed-day-rule,
.driver-profile-divider-rule {
    flex: 1 1 auto;
    height: 1px;
    background: var(--mud-palette-lines-default);
    opacity: 0.6;
}

.social-section-count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: rgba(229, 57, 53, 0.18);
    color: var(--mud-palette-error);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

/* ── feed ── */

.social-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.social-feed-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.social-feed-day {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 2px 0;
}

.social-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.social-card-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.social-card-head > a,
.social-card-connection a {
    line-height: 0;
}

.social-card-title {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.social-card-title-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.social-card-actor,
.friend-row-name {
    color: var(--mud-palette-text-primary);
    font-weight: 700;
    text-decoration: none;
}

.social-card-actor:hover,
.friend-row-name:hover {
    text-decoration: underline;
}

.social-card-verb {
    color: var(--mud-palette-text-secondary);
}

.social-card-verb b.social-card-track {
    color: #b39dff;
    font-weight: 600;
}

.social-card-position {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    border: 1px solid rgba(253, 216, 53, 0.55);
    color: #fdd835;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.social-card-time {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* A card's middle: circuit, what happened, the car. Three columns so the width is used rather
   than leaving the right half of the card empty. */
.social-card-link {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
}

.social-card-link:disabled {
    cursor: default;
}

.social-card-link:not(:disabled):hover {
    background: var(--mud-palette-action-default-hover);
}

.social-card-grid {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(120px, 30%);
    align-items: center;
    gap: 14px;
    padding: 4px;
}

.social-card-circuit {
    display: flex;
    align-items: center;
}

.social-card-stats {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-items: flex-start;
}

.social-card-car {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
    text-align: center;
}

.social-card-car-img {
    width: 100%;
    max-width: 200px;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.social-card-car-name {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.social-card-car-class {
    font-size: 0.7rem;
    color: var(--mud-palette-text-secondary);
}

.social-card-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.social-card-fact {
    padding: 1px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--mud-palette-text-secondary);
    font-size: 0.74rem;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .social-card-grid {
        grid-template-columns: minmax(0, 1fr) 38%;
        gap: 10px;
    }

    .social-card-circuit {
        display: none;
    }
}

.social-card-lap-row {
    display: flex;
    align-items: baseline;
    gap: 9px;
}

/* Matches the history card's lap readout so a time looks the same everywhere in the app. */
.social-card-lap {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #c4b5fd;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.social-card-note {
    font-size: 0.78rem;
    color: var(--mud-palette-text-secondary);
}

.social-card-delta {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.social-card-fact.social-card-fact--best { color: var(--mud-palette-warning); }

.social-card-delta.gain { color: var(--mud-palette-success); }
.social-card-delta.loss { color: var(--mud-palette-error); }

.social-card-sectors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 4px;
    width: 100%;
    max-width: 420px;
}

.social-card-sector {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(179, 157, 255, 0.12);
}

.social-card-sector-label {
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    color: var(--mud-palette-text-secondary);
}

.social-card-sector-time {
    font-weight: 700;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.social-card-tyres,
.social-card-lobby {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
}

.social-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.045);
}

.social-card-actions-spacer {
    flex: 1 1 auto;
}

.social-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 12px;
    border: 1px solid var(--mud-palette-lines-default);
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.social-count.mine {
    border-color: var(--mud-palette-primary);
    background: rgba(124, 77, 255, 0.16);
    color: var(--mud-palette-text-primary);
}

.social-count:disabled {
    opacity: 0.6;
    cursor: default;
}

.social-count:hover {
    border-color: var(--mud-palette-primary);
    color: var(--mud-palette-text-primary);
}

.social-card-connection {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 4px;
}

.social-card-connection-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ── a session several friends drove: one row per driver ── */

.social-participants {
    display: flex;
    flex-direction: column;
}

.social-participant {
    display: grid;
    grid-template-columns: 42px auto minmax(0, 1fr) auto minmax(96px, 26%);
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
}

.social-participants > .social-participant + .social-participant {
    border-top: 1px solid rgba(255, 255, 255, 0.045);
}

.social-participant-who {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.social-participant-name {
    font-weight: 700;
    font-size: 0.9rem;
}

.social-participant-sub {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.social-participant-lap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.social-card-lap.social-card-lap--sm {
    font-size: 1rem;
}

.social-participant-car {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    text-align: center;
}

.social-participant-car .social-card-car-img {
    max-width: 120px;
}

@media (max-width: 520px) {
    .social-participant {
        grid-template-columns: 36px auto minmax(0, 1fr) auto;
    }

    .social-participant-car {
        display: none;
    }
}

/* ── on track strip ── */

.presence-head {
    display: flex;
    align-items: center;
    gap: 7px;
    position: relative;
    z-index: 1;
}

.presence-spacer {
    flex: 1 1 auto;
}

.presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mud-palette-error);
    flex: 0 0 auto;
    animation: presence-pulse 2s ease-in-out infinite;
}

.presence-dot--idle {
    background: var(--mud-palette-text-disabled);
    animation: none;
}

.presence-empty {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 8px;
    position: relative;
    z-index: 1;
}

.presence-dot--inline {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 5px;
}

@keyframes presence-pulse {
    50% { opacity: 0.35; }
}

.presence-strip {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 0 4px;
    position: relative;
    z-index: 1;
}

.presence-driver {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    /* Fixed width that never shrinks: the strip scrolls sideways instead, and long names or
       track names are clipped inside the tile rather than spilling over the neighbours. */
    flex: 0 0 auto;
    width: 96px;
    min-width: 0;
    padding: 6px 4px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.presence-driver.selected {
    border-color: rgba(229, 57, 53, 0.45);
    background: rgba(229, 57, 53, 0.08);
}

.presence-name {
    font-size: 0.78rem;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presence-where {
    font-size: 0.68rem;
    line-height: 1.25;
    color: var(--mud-palette-text-secondary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presence-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 6px;
    position: relative;
    z-index: 1;
}

/* ── friends ── */

.friends-panel,
.discover-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.friends-panel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.friends-panel-filter {
    flex: 1 1 auto;
}

.friends-panel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.mud-paper.social-card.friends-panel-list {
    padding: 2px 12px;
}

.friend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    position: relative;
    z-index: 1;
}

.friend-row + .friend-row {
    border-top: 1px solid rgba(255, 255, 255, 0.045);
}

.friend-row > a {
    line-height: 0;
}

.friend-row--muted {
    opacity: 0.7;
}

.friend-row-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.friend-row-status {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-row-status.live,
.driver-profile-status.live {
    color: #ef9a9a;
}

/* ── discover ── */

.discover-heading {
    padding: 8px 2px 0;
}

.discover-row {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.discover-row > a {
    line-height: 0;
}

.discover-row-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.discover-number {
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--mud-palette-text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
}

/* ── driver profile ── */

.driver-profile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.driver-profile-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 2px 4px;
}

.driver-profile-identity {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.driver-profile-name {
    display: flex;
    align-items: center;
}

.driver-profile-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

/* The racing number, sized like a car door. */
.driver-profile-number {
    flex: 0 0 auto;
    align-self: flex-start;
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--mud-palette-error);
    font-variant-numeric: tabular-nums;
}

.driver-profile-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.driver-profile-actions-spacer {
    flex: 1 1 auto;
}

.driver-profile-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.driver-profile-about,
.driver-profile-gear {
    position: relative;
    z-index: 1;
}

.driver-profile-gear {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.driver-profile-scope {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 9px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.driver-profile-scope .mud-icon-root {
    font-size: 0.9rem;
}

.driver-profile-scope.public {
    border: 1px solid rgba(66, 165, 245, 0.5);
    color: #90caf9;
}

.driver-profile-scope.friends {
    border: 1px solid rgba(179, 157, 255, 0.5);
    color: #b39dff;
}

.driver-profile-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 2px 0;
}

.driver-profile-tab {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
}

.driver-profile-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 1px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--mud-palette-lines-default);
    border: 1px solid var(--mud-palette-lines-default);
}

.driver-profile-total {
    text-align: center;
    padding: 10px 4px;
    background: var(--svr-card-bg, var(--mud-palette-surface));
}

.driver-profile-total-value {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.driver-profile-total-label {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
    margin-top: 2px;
}

.driver-profile-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    position: relative;
    z-index: 1;
}

.driver-profile-row + .driver-profile-row {
    border-top: 1px solid rgba(255, 255, 255, 0.045);
}

.driver-profile-row.clickable {
    cursor: pointer;
}

.driver-profile-row.clickable:hover:not(:disabled) {
    background: var(--mud-palette-action-default-hover);
}

.driver-profile-row-text {
    flex: 1 1 auto;
    min-width: 0;
}

.driver-profile-row-end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.driver-profile-row-lap {
    font-weight: 700;
    color: #c4b5fd;
    font-variant-numeric: tabular-nums;
}

.driver-profile-car {
    width: 72px;
    height: 36px;
    object-fit: contain;
}

.driver-profile-recent {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    position: relative;
    z-index: 1;
}

.driver-profile-recent + .driver-profile-recent {
    border-top: 1px solid rgba(255, 255, 255, 0.045);
}

.driver-profile-recent-badge {
    min-width: 34px;
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid var(--mud-palette-lines-default);
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
}

.driver-profile-recent-text {
    flex: 1 1 auto;
    min-width: 0;
}

.driver-profile-locked {
    min-height: 150px;
}

/* Blurred bars hint at what a friend would see. The real data is never sent to a stranger, so
   this is decoration, not a gate. */
.driver-profile-locked-ghost {
    position: absolute;
    inset: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    filter: blur(5px);
    opacity: 0.35;
}

.driver-profile-locked-ghost > div {
    height: 26px;
    border-radius: 6px;
    background: linear-gradient(90deg, #6d5bd0 0%, #e53935 70%, transparent 100%);
}

.driver-profile-locked-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    text-align: center;
}

/* ── home card ── */

/* Covers the card so its two parts can be placed: faces on the right of the title bar, the rest
   in a bar along the bottom. */
.social-home-summary {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

/* Vertically centred in the 48px title bar (h6 line + 8px padding either side). */
.social-home-faces {
    position: absolute;
    top: 0;
    right: 12px;
    height: 48px;
}

.social-home-footer {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: rgba(0, 0, 0, 0.6);
}

.social-home-live {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    border: 1px solid rgba(229, 57, 53, 0.5);
    background: rgba(0, 0, 0, 0.35);
    font-size: 0.75rem;
    font-weight: 600;
}

.social-home-counts {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 600;
}

/* A driver's name that leads to their profile, wherever it appears in a table or list. */
a.social-driver-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
}

a.social-driver-link:hover {
    color: var(--mud-palette-primary-lighten);
    border-bottom-style: solid;
}
