/**
 * The lap-time leaderboard (P-CDA-150). Tables ported from
 * mockups/ecosystem/ecosystem.css, which copies SimGrid's results table:
 * rows as rounded bars on #322F4C, monospace numbers. The head copies the
 * setups pages' "Browse setups" bar: Narrow 800 title, muted count, the
 * shared filter dropdowns. No letter-spaced uppercase.
 *
 * Loaded only on /laptimes/ pages. Elementor prints a custom font's
 * @font-face only when a widget uses it, and these pages have none, so the
 * faces are declared here from the font-loading module's WOFF2 files.
 */

@font-face {
    font-family: "Blackbird Narrow";
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url("../../../font-loading/fonts/Blackbird-NarrowExtraBold.woff2") format("woff2");
}

@font-face {
    font-family: "Blackbird Regular";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../../../font-loading/fonts/Blackbird-Regular.woff2") format("woff2");
}

@font-face {
    font-family: "Blackbird Regular";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../../../font-loading/fonts/Blackbird-Bold.woff2") format("woff2");
}

.cda-lt {
    --lt-bg: var(--e-global-color-f246ce3, #100f1a); /* Grey 900 */
    --lt-panel: var(--e-global-color-3433412, #222032); /* Grey 800 */
    --lt-line: var(--e-global-color-e30960e, #322f4c); /* Grey 700 */
    --lt-text: var(--e-global-color-a311b85, #d0d0d0);
    --lt-soft: var(--e-global-color-89b7035, #cdd2d7); /* Grey 300 */
    --lt-muted: var(--e-global-color-94bcddc, #868f98); /* Grey 400 */
    --lt-red: var(--e-global-color-primary, #ff2614);
    --lt-red-hover: var(--e-global-color-secondary, #ff4131);
    --lt-red-soft: #ff261429; /* secondary buttons: kit red at 16% */
    --lt-heading: "Blackbird Narrow", arial, sans-serif;
    --lt-body: "Blackbird Regular", arial, sans-serif;
    --sg-row: #322f4c;
    --sg-row-alt: #2a2740;
    --sg-head: #222032;
    --sg-well: #100f1a;
    --sg-text: #eceff1;
    --sg-sub: #cdd2d7;
    --sg-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    display: block;
    /* The kit's boxed width (1140px content) plus the 20px side padding every
       Elementor section uses, so the page lines up with the header. */
    max-width: calc(var(--container-max-width, 1140px) + 40px);
    margin: 0 auto;
    padding: 0 20px 40px;
    box-sizing: border-box;
    color: var(--lt-text);
    font-family: var(--lt-body);
    font-size: 15px;
    line-height: 1.5;
}

body.cda-lt-page {
    background-color: var(--e-global-color-f246ce3, #100f1a);
}

.cda-lt *,
.cda-lt *::before,
.cda-lt *::after {
    box-sizing: border-box;
}

.cda-lt a {
    color: var(--lt-red);
    text-decoration: none;
}

.cda-lt a:hover {
    color: var(--lt-red-hover);
}

.cda-lt .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Head: title and driver count on the left, the filter dropdowns
   (core/class-cda-dropdown.php) on the right, as on the setups pages;
   they wrap under the title when there isn't room. */
.cda-lt__board {
    padding: 48px 0 32px;
}

.cda-lt__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
    margin: 0 0 16px;
}

.cda-lt__heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
}

.cda-lt .cda-lt__title {
    margin: 0;
    font: 800 28px/1.1 var(--lt-heading);
    letter-spacing: normal;
    text-transform: uppercase;
    color: #fff;
}

.cda-lt__count {
    margin: 0;
    font: 14px/20px var(--lt-body);
    color: var(--lt-muted);
}

.cda-lt__bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* SimGrid table: wrapper well, header bar, rows as rounded bars */
.cda-lt .sg-table {
    overflow: hidden;
    border-radius: 8px;
    background: var(--sg-well);
}

.cda-lt .sg-head,
.cda-lt .sg-row {
    display: grid;
    align-items: center;
}

/* Header row and position cells on Grey 900, as on SimGrid */
.cda-lt .sg-head {
    background: var(--lt-bg);
    font: 700 10px/15px var(--lt-body);
    text-transform: uppercase;
    color: #fff;
}

.cda-lt .sg-head > * {
    padding: 10px;
}

.cda-lt .sg-row {
    border-bottom: 1px solid var(--sg-head);
    font: 14px/21px var(--lt-body);
    color: var(--sg-text);
}

.cda-lt .sg-row > * {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-self: stretch;
    min-width: 0;
    padding: 10px;
    background: var(--sg-row);
}

.cda-lt .sg-row:nth-child(even) > * {
    background: var(--sg-row-alt);
}

.cda-lt .sg-row > :first-child {
    border-radius: 4px 0 0 4px;
}

.cda-lt .sg-row > :last-child {
    border-radius: 0 4px 4px 0;
}

.cda-lt .sg-r {
    align-items: flex-end;
    text-align: right;
}

.cda-lt .sg-car-txt a,
.cda-lt .sg-car-txt b {
    display: block;
    overflow: hidden;
    font: 600 13px/18px var(--lt-body);
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--sg-text);
}

/* A car with setups: the product's image beside its name */
.cda-lt .sg-row > .cda-lt__car {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

/* The product image is square with the car across its middle, so a wide
   frame with cover crops to the car. */
.cda-lt .cda-lt__car-img {
    flex: none;
    width: 80px;
    height: 44px;
    max-width: none;
    border-radius: 4px;
    object-fit: cover;
}

.cda-lt .cda-lt__car-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* A car with setups: its name links to them */
.cda-lt .sg-car-txt > a {
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.25);
    text-underline-offset: 3px;
}

.cda-lt .sg-car-txt > a:hover {
    color: #fff;
    text-decoration-color: var(--lt-red);
}

.cda-lt .cda-lt__none {
    font: 13px/18px var(--lt-body);
    color: var(--lt-muted);
    white-space: nowrap;
}

/* "Show more" under a class table (laptimes.js) */
.cda-lt .cda-lt__more {
    display: block;
    width: 100%;
    margin: 8px 0 0;
    padding: 10px 16px;
    border: 1px solid var(--lt-line);
    border-radius: 4px;
    background: transparent;
    font: 800 14px/1 var(--lt-heading);
    letter-spacing: normal;
    text-transform: uppercase;
    color: #fff;
    cursor: pointer;
}

.cda-lt .cda-lt__more:hover {
    border-color: #5d6486;
}

.cda-lt .cda-lt__more[hidden],
.cda-lt .sg-row[hidden],
.cda-lt .cda-lt__group[hidden] {
    display: none;
}

/* On a game page, inside the page's own container */
.cda-lt.cda-lt--embed {
    max-width: none;
    margin: 0;
    padding: 0;
    scroll-margin-top: 96px;
}

.cda-lt .sg-car-txt small {
    display: block;
    overflow: hidden;
    font-size: 11px;
    line-height: 15px;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--sg-sub);
}

.cda-lt .sg-num {
    font: 12px/18px var(--sg-mono);
    font-variant-numeric: tabular-nums;
    color: var(--sg-sub);
}

.cda-lt .sg-delta {
    font: 10px/15px var(--sg-mono);
    color: rgba(255, 255, 255, 0.6);
}

/* Pace tables (mockups/ecosystem: podium position cells, purple pill for
   the class's fastest lap) */
.cda-lt__meta {
    margin: 0 0 14px;
    font: 14px/21px var(--lt-body);
    color: var(--lt-muted);
}

.cda-lt .cda-lt__class {
    margin: 20px 0 8px;
    font: 800 16px/20px var(--lt-heading);
    letter-spacing: normal;
    text-transform: uppercase;
    color: var(--lt-soft);
}

.cda-lt__pace-grid {
    grid-template-columns: 44px minmax(0, 1fr) 140px;
}

/* Car pages: in the product description, set apart from the text around it */
.cda-lt.cda-lt--car {
    margin: 32px 0;
}

/* iRacing car pages: one table under each series heading */
.cda-lt.cda-lt--series {
    margin: 12px 0 32px;
}

.cda-lt--car .cda-lt__heading {
    margin: 0 0 16px;
}

/* Car pages: track, Pro lap (with the gap to the class's fastest car) */
.cda-lt__car-grid {
    grid-template-columns: minmax(0, 1fr) 140px;
}

.cda-lt .sg-delta[title] {
    cursor: help;
}

.cda-lt .sg-c {
    align-items: center;
    text-align: center;
}

.cda-lt .sg-row > .sg-pos {
    align-items: center;
    background: var(--lt-bg);
    font-weight: 700;
}

.cda-lt .sg-row > .sg-pos[data-p="1"] {
    background: #ffdb5a;
    color: var(--sg-well);
}

.cda-lt .sg-row > .sg-pos[data-p="2"] {
    background: #adb5bd;
    color: var(--sg-well);
}

.cda-lt .sg-row > .sg-pos[data-p="3"] {
    background: #c99355;
    color: var(--sg-well);
}

.cda-lt .sg-best {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    background: #9b51e0;
    font: 12px/12px var(--sg-mono);
    color: #fff;
}

/* The Pro who set the car's lap, under its name */
.cda-lt .sg-car-txt .cda-lt__pro {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    font: 12px/16px var(--lt-body);
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--lt-soft);
}

/* While laptimes.js fetches the next board */
.cda-lt[aria-busy="true"],
.cda-lt [aria-busy="true"] {
    opacity: 0.6;
    transition: opacity 0.15s;
}

/* The source line under the tables */
.cda-lt .cda-lt__note {
    margin: 16px 0 0;
}

.cda-lt .cda-lt__note a {
    color: var(--lt-soft);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cda-lt .cda-lt__note a:hover {
    color: #fff;
}

/* Setups buttons (kit: Narrow 800 16px uppercase, 4px corners) */
.cda-lt__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 24px 0 0;
}

.cda-lt .cda-lt__btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 4px;
    font: 800 16px/1 var(--lt-heading);
    letter-spacing: normal;
    text-transform: uppercase;
    transition: background-color 0.3s, color 0.3s;
}

.cda-lt .cda-lt__btn--primary {
    background: var(--lt-red);
    color: #fff;
}

.cda-lt .cda-lt__btn--primary:hover {
    background: var(--lt-red-hover);
    color: #fff;
}

.cda-lt .cda-lt__btn--secondary {
    background: var(--lt-red-soft);
    color: var(--lt-red);
}

.cda-lt .cda-lt__btn--secondary:hover {
    background: var(--lt-red);
    color: #fff;
}

@media (max-width: 767px) {
    .cda-lt__board {
        padding: 32px 0 24px;
    }

    .cda-lt .cda-lt__title {
        font-size: 22px;
        overflow-wrap: break-word;
    }

    .cda-lt .sg-row > *,
    .cda-lt .sg-head > * {
        padding: 8px 6px;
    }

    /* Phones: the same three columns, narrower. */
    .cda-lt__pace-grid {
        grid-template-columns: 30px minmax(0, 1fr) 92px;
    }

    .cda-lt__car-grid {
        grid-template-columns: minmax(0, 1fr) 100px;
    }

    .cda-lt .sg-row > .cda-lt__car {
        gap: 8px;
    }

    .cda-lt .cda-lt__car-img {
        width: 56px;
        height: 32px;
    }

    .cda-lt .sg-car-txt a,
    .cda-lt .sg-car-txt b,
    .cda-lt .sg-car-txt small {
        white-space: normal;
    }
}
