/*
 * iGPFun - modern theme
 *
 * Loaded after style.css and scoped under body.theme-modern, so the retro
 * ascii theme is never touched by anything in here. Where a rule looks
 * over specific or uses !important it is beating an inline style written
 * by the php, not being clever.
 */

body.theme-modern {

    --bg: #05170F;
    --bg-2: #082018;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-solid: #0B241A;
    --surface-hi: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.09);
    --border-hi: rgba(255, 255, 255, 0.16);

    --text: #E9F1EC;
    --muted: #8CA79A;
    --faint: #61796E;

    --accent: #0AD68F;
    --accent-dim: #05764E;
    --accent-glow: rgba(10, 214, 143, 0.13);

    --gold: #FFD166;
    --silver: #CBD7DE;
    --bronze: #D08B48;
    --danger: #FF6B6B;

    --radius: 14px;
    --radius-sm: 9px;

    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 620px at 50% -10%, #0C3A28 0%, transparent 60%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/*
 * Layout. style.css lays the page out with display:table so the ascii art
 * can be centred as one lump, this needs ordinary flow.
 */
.theme-modern .content {
    display: block;
    width: auto;
}

/*
 * Centred on the horizontal to match the retro layout. The blocks centre,
 * the table cells stay left aligned where they belong.
 */
.theme-modern .eddiebot {
    display: block;
    white-space: normal;
    text-align: center;
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 18px 64px;
}

.theme-modern .data-table td {
    text-align: left;
}

.theme-modern .ui-dialog {
    text-align: left;
}

.theme-modern p {
    margin: 0;
}

/* ---------------------------------------------------------------- header */

.theme-modern h3#season-drop-down {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 6px 0 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.theme-modern h3#season-drop-down::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    transform: translateY(-3px) rotate(45deg);
    transition: transform 0.15s ease;
}

.theme-modern h3#season-drop-down:hover::after {
    transform: translateY(-1px) rotate(45deg);
}

.theme-modern h4 {
    font-size: 0.95rem;
    margin: 0;
}

/* ----------------------------------------------------------- button bars */

.theme-modern .ui-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 0 10px;
}

.theme-modern .ui-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/*
 * A dialog title and its close button are one group, so the group has to fill
 * the bar for the close button to sit hard right
 */
.theme-modern .ui-bar .ui-group:has(> .dialog-close) {
    flex: 1;
}

/*
 * A group of choices is drawn as one segmented control. Groups that are not
 * choices, the dialog title bars, are left as plain text.
 */
.theme-modern .ui-group:has(> .display_selected),
.theme-modern .ui-group:has(> .display_not_selected),
.theme-modern .ui-group:has(> .display-selected),
.theme-modern .ui-group:has(> .display-not-selected) {
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.2);
}

.theme-modern .ui-bar-text {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0 2px;
}

/*
 * The php writes both spellings of these classes, and inline styles for the
 * underline and the bold. Pills have to win all of it.
 */
.theme-modern .ui-bar .display_selected,
.theme-modern .ui-bar .display-selected,
.theme-modern .ui-bar .display_not_selected,
.theme-modern .ui-bar .display-not-selected {
    display: inline-block;
    padding: 5px 14px;
    border: 0;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 600 !important;
    line-height: 1.3;
    text-decoration: none !important;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: background 0.14s ease, color 0.14s ease;
    cursor: pointer;
}

.theme-modern .ui-bar .display_not_selected,
.theme-modern .ui-bar .display-not-selected {
    color: var(--muted) !important;
    background: transparent;
}

.theme-modern .ui-bar .display_not_selected:hover,
.theme-modern .ui-bar .display-not-selected:hover {
    color: var(--text) !important;
    background: var(--surface-hi);
}

.theme-modern .ui-bar .display_selected,
.theme-modern .ui-bar .display-selected {
    color: #04150E !important;
    background: var(--accent);
    box-shadow: 0 1px 8px var(--accent-glow);
}

/* ----------------------------------------------------------------- cards */

.theme-modern .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0 auto 16px;
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset,
                0 10px 30px rgba(0, 0, 0, 0.25);
}

.theme-modern .card-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    padding: 13px 16px;
    margin: 0;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.16);
}

.theme-modern .card-title .copy-table-link:hover {
    color: var(--accent);
}

/* ---------------------------------------------------------------- tables */

.theme-modern .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.theme-modern .table-wrap::-webkit-scrollbar {
    height: 9px;
    width: 9px;
}

.theme-modern .table-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.theme-modern .table-wrap::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
}

.theme-modern .table-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.28);
}

/*
 * min-width rather than width, or a wide table like the grid gets squeezed
 * into the card instead of growing and letting the wrapper scroll
 */
.theme-modern .data-table {
    width: auto;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

/*
 * No sticky top here. table-wrap scrolls sideways, which makes it the scroll
 * container, and a sticky header inside it can never follow the page. It is
 * only put back for the dialog further down, where the wrap does scroll
 * vertically and it actually does something.
 */
.theme-modern .data-table th {
    background: #0A2119;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: left;
    white-space: nowrap;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.theme-modern .data-table td {
    padding: 9px 12px;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
    color: var(--text);
}

.theme-modern .data-table tbody tr:last-child td {
    border-bottom: 0;
}

.theme-modern .data-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.017);
}

.theme-modern .data-table tbody tr:hover td {
    background: var(--accent-glow);
    color: var(--text);
    font-weight: inherit;
}

.theme-modern .data-table th.ta-r,
.theme-modern .data-table td.ta-r {
    text-align: right;
}

/*
 * The summary standings are a handful of narrow columns. Left to fill the
 * page they read as a sparse mess, so the card is capped at a width the eye
 * can track across. The full and teams versions carry more columns.
 */
.theme-modern .card:has(table.standings-narrow) {
    max-width: 560px;
}

.theme-modern .card:has(table.standings-teams) {
    max-width: 840px;
}

/* standings: quietly badge the podium */

.theme-modern .data-table.standings tbody tr td:first-child {
    font-weight: 700;
    color: var(--faint);
}

.theme-modern .data-table.standings tbody tr:nth-child(1) td:first-child {
    color: var(--gold);
}

.theme-modern .data-table.standings tbody tr:nth-child(2) td:first-child {
    color: var(--silver);
}

.theme-modern .data-table.standings tbody tr:nth-child(3) td:first-child {
    color: var(--bronze);
}

/* points column reads as the headline number */

.theme-modern .data-table.standings tbody td:nth-child(3) {
    font-weight: 700;
    font-size: 0.98rem;
}

/*
 * grid: a column per week, so it scrolls sideways with the position and the
 * driver pinned. The first column is given a fixed width so the second one
 * knows where to sit.
 */
.theme-modern .data-table.grid th:nth-child(1),
.theme-modern .data-table.grid td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 2;
    box-sizing: border-box;
    width: 52px;
    min-width: 52px;
    max-width: 52px;
    background: var(--surface-solid);
}

.theme-modern .data-table.grid th:nth-child(2),
.theme-modern .data-table.grid td:nth-child(2) {
    position: sticky;
    left: 52px;
    z-index: 2;
    background: var(--surface-solid);
    box-shadow: 1px 0 0 var(--border);
}

.theme-modern .data-table.grid th:nth-child(1),
.theme-modern .data-table.grid th:nth-child(2) {
    z-index: 4;
    background: #0A2119;
}

.theme-modern .data-table.grid tbody tr:hover td:nth-child(1),
.theme-modern .data-table.grid tbody tr:hover td:nth-child(2) {
    background: #103526;
}

/* ------------------------------------------------------------ cell bits  */

.theme-modern .points-strike {
    color: var(--danger);
    opacity: 0.75;
}

.theme-modern .dialog-open {
    text-decoration: none !important;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.28);
    cursor: pointer;
    transition: color 0.14s ease, border-color 0.14s ease;
}

.theme-modern .dialog-open:hover,
.theme-modern .driver-hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: none;
}

.theme-modern .driver-select {
    color: var(--accent) !important;
    background: none !important;
    border-bottom-color: var(--accent);
}

.theme-modern .track-link {
    color: var(--text) !important;
    text-decoration: none !important;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.28);
}

.theme-modern .track-link:hover {
    color: var(--accent) !important;
    border-bottom-color: var(--accent);
}

.theme-modern span:has(> .track-select) {
    background: none;
    font-weight: 400;
}

.theme-modern .track-select {
    color: var(--accent) !important;
    background: var(--accent-glow);
    border: 1px solid var(--accent-dim);
    border-radius: 999px;
    padding: 2px 10px;
    text-decoration: none !important;
}

/* the watch replay dot */

.theme-modern .data-table td a[href^="race_watch"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1;
    transition: background 0.14s ease, color 0.14s ease;
}

.theme-modern .data-table td a[href^="race_watch"]:hover {
    background: var(--accent);
    color: #04150E;
}

.theme-modern .tt {
    border-bottom: 1px dotted rgba(255, 255, 255, 0.25);
}

.theme-modern th .tt {
    border-bottom: 0;
}

.theme-modern a {
    color: var(--text);
}

/* --------------------------------------------------------------- dialogs */

.theme-modern .ui-dialog {
    background: var(--surface-solid);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    font-family: inherit;
    color: var(--text);
    overflow: hidden;
    box-sizing: border-box;
    max-width: calc(100vw - 16px);
}

.theme-modern .ui-dialog .ui-dialog-titlebar {
    background: rgba(0, 0, 0, 0.2);
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    /*
     * 16px across to line the title up with the rows beneath it, and enough
     * height that it is not squashed against the first one
     */
    padding: 20px 16px;
    font-family: inherit;
}

.theme-modern .ui-dialog .ui-dialog-title {
    float: none;
    width: auto;
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    white-space: normal;
}

.theme-modern .ui-dialog .ui-dialog-title .ui-bar {
    margin: 0;
}

.theme-modern .ui-dialog .ui-dialog-content {
    /*
     * No top padding, or the first row sits inset below the title bar and
     * reads as though it is a different width to the rest
     */
    padding: 0;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    min-width: 260px;
}

/*
 * jquery ui's theme paints a solid block behind every link inside a widget,
 * which made every season in the picker look like the selected one
 */
.theme-modern .ui-widget-content a {
    background: transparent;
}

.theme-modern .ui-dialog .ui-dialog-content .table-wrap {
    /*
     * Roomy enough that a season list does not scroll at all on an ordinary
     * window. It only scrolls on a short one, and the shadow below covers that
     */
    max-height: min(80vh, 640px);
    overflow-y: auto;
}

/*
 * A long dialog list gets cut off mid row, and on browsers with overlay
 * scrollbars there is nothing on screen to say it carries on. So the list
 * casts a shadow at whichever end has more content.
 *
 * The two 'local' layers scroll with the content and cover the shadows up,
 * so each shadow disappears once you reach that end of the list.
 */
.theme-modern .ui-dialog .table-wrap {
    /*
     * auto, not thin. On this platform thin gives an overlay scrollbar that
     * only appears while you are already scrolling, which is no use as a hint
     * that the list carries on. auto reserves the space and stays put.
     */
    scrollbar-width: auto;
    scrollbar-color: rgba(255, 255, 255, 0.38) rgba(0, 0, 0, 0.3);
    background:
        linear-gradient(#0B241A 40%, rgba(11, 36, 26, 0)) center top / 100% 34px no-repeat local,
        linear-gradient(rgba(11, 36, 26, 0), #0B241A 60%) center bottom / 100% 34px no-repeat local,
        linear-gradient(to bottom, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0)) center top / 100% 22px no-repeat scroll,
        linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0)) center bottom / 100% 22px no-repeat scroll;
}

.theme-modern .ui-dialog .table-wrap::-webkit-scrollbar {
    width: 10px;
}

.theme-modern .ui-dialog .table-wrap::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.theme-modern .ui-dialog .table-wrap::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.38);
    border-radius: 999px;
}

.theme-modern .ui-dialog .table-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.55);
}

.theme-modern .ui-dialog .data-table th {
    background: #0A2119;
    position: sticky;
    top: 0;
    z-index: 3;
}

/*
 * The season picker reads as a menu, not a one column table.
 * width rather than min-width, or the rows stop short of the dialog edge,
 * which is set by the wider title bar above them.
 */
.theme-modern .data-table.season-list {
    width: 100%;
    min-width: 260px;
}

.theme-modern .data-table.season-list td {
    padding: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.theme-modern .data-table.season-list tbody tr:nth-child(even) td {
    background: none;
}

.theme-modern .data-table.season-list td a,
.theme-modern .data-table.season-list td span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 16px;
    text-decoration: none !important;
}

/* the choices: muted, with a chevron so they read as clickable */

.theme-modern .data-table.season-list td a {
    color: var(--text) !important;
    font-weight: 500 !important;
}

.theme-modern .data-table.season-list td a::after {
    content: "\203A";
    color: var(--faint);
    font-size: 1.05rem;
    line-height: 1;
    transition: transform 0.14s ease, color 0.14s ease;
}

.theme-modern .data-table.season-list tbody tr:has(a):hover td {
    background: var(--accent-glow);
}

.theme-modern .data-table.season-list td a:hover {
    color: var(--accent) !important;
}

.theme-modern .data-table.season-list td a:hover::after {
    color: var(--accent);
    transform: translateX(3px);
}

/*
 * The one without a link is the season already on screen. Marked with a bar
 * and a label so it reads as where you are, not as one more thing to pick.
 */
.theme-modern .data-table.season-list td span {
    /*
     * The marker is an inset shadow rather than a border, so this row has the
     * exact same box as every other one. A solid tint here reads as a block
     * that stops short of the title bar whenever the list is scrolling and
     * the scrollbar takes its 10px, so it is kept faint on purpose.
     */
    box-shadow: inset 3px 0 0 var(--accent);
    background: rgba(10, 214, 143, 0.06);
    color: var(--accent) !important;
    font-weight: 700 !important;
    cursor: default;
}

.theme-modern .data-table.season-list td span::after {
    content: "Viewing";
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    opacity: 0.75;
}

.theme-modern .dialog-close {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.66rem;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

.theme-modern .dialog-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #04150E;
}

/*
 * Tooltips are appended to the body, so inside a dialog they end up behind it
 * unless they are lifted above the dialog's stacking order
 */
.theme-modern .ui-tooltip,
.theme-modern .eddie-tooltip {
    z-index: 10000;
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-sm);
    background: var(--surface-solid);
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    line-height: 1.35;
    padding: 6px 10px;
    max-width: 260px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ------------------------------------------- admin, datatables, modals   */

.theme-modern .btn {
    border: 1px solid var(--border-hi);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    transition: background 0.14s ease, color 0.14s ease;
}

.theme-modern .btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #04150E;
}

.theme-modern .btn-lg {
    border-radius: var(--radius-sm);
    border-width: 1px;
    padding: 9px 18px;
    font-size: 0.9rem;
}

.theme-modern table.dataTable {
    border: 0;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.theme-modern table.dataTable > thead > tr > th {
    background: #0A2119;
    color: var(--muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border) !important;
    border-top: 0 !important;
}

.theme-modern table.dataTable.cell-border > tbody > tr > * {
    border-top: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045) !important;
}

.theme-modern div > table > tbody > tr.dtrg-group > th {
    background: rgba(0, 0, 0, 0.22);
    color: var(--accent);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-top: 0 !important;
    border-bottom: 1px solid var(--border);
}

/* datatables 2.x chrome */

.theme-modern .dt-container {
    padding: 0;
}

.theme-modern .dt-layout-row:first-child {
    padding: 12px 16px 4px;
}

/*
 * The card clips its corners with overflow hidden, so the table needs its own
 * scroller or the right hand columns are cut off with no way to reach them.
 * The min-width stops the description column being squeezed to a sliver.
 */
.theme-modern .dt-layout-table {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.theme-modern .dt-layout-table::-webkit-scrollbar {
    height: 9px;
}

.theme-modern .dt-layout-table::-webkit-scrollbar-track {
    background: transparent;
}

.theme-modern .dt-layout-table::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
}

.theme-modern table.dataTable {
    min-width: 820px;
}

/* the description carries the sentence, give it the room it needs */

.theme-modern #penalties_table th:nth-child(4),
.theme-modern #penalties_table td:nth-child(4) {
    min-width: 240px;
}

.theme-modern .dt-search {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.theme-modern .dt-search label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.theme-modern .dt-input,
.theme-modern .dataTables_wrapper input,
.theme-modern .dataTables_wrapper select {
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 13px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

.theme-modern .dt-input:focus {
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.theme-modern .dt-info,
.theme-modern .dt-length label {
    color: var(--muted);
    font-size: 0.8rem;
}

.theme-modern .alert {
    border-radius: var(--radius-sm);
}

.theme-modern .modal {
    border-radius: var(--radius);
}

/* ---------------------------------------------------------------- mobile */

@media only screen and (max-width: 760px) {

    body.theme-modern {
        font-size: 15px;
    }

    .theme-modern .eddiebot {
        padding: 12px 10px 56px;
    }

    .theme-modern h3#season-drop-down {
        font-size: 1.18rem;
    }

    .theme-modern .card {
        border-radius: var(--radius-sm);
    }

    .theme-modern .data-table {
        font-size: 0.84rem;
    }

    .theme-modern .data-table th {
        padding: 8px 9px;
    }

    .theme-modern .data-table td {
        padding: 8px 9px;
    }

    .theme-modern .ui-bar .display_selected,
    .theme-modern .ui-bar .display-selected,
    .theme-modern .ui-bar .display_not_selected,
    .theme-modern .ui-bar .display-not-selected {
        padding: 5px 11px;
        font-size: 0.8rem;
    }

    .theme-modern .ui-dialog {
        max-width: calc(100vw - 20px);
    }
}
