/* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 *
 *  Theming contract for OpenBench.
 *
 *  DARK is the original OpenBench skin, restored value for value. Every
 *  literal that used to be hard-coded in a rule below now lives in a custom
 *  property whose dark value is that exact literal, so the dark page renders
 *  as it always did. The variables exist purely so a second palette can be
 *  swapped in; they are not an invitation to re-tune the dark colours.
 *
 *  LIGHT follows fishtest (tests.stockfishchess.org), which is Bootstrap 5.3
 *  with a green link colour. Sampled from the live site:
 *
 *      body            #ffffff / #212529      --bs-body-bg / --bs-body-color
 *      sidebar         #dee2e6               .mainnavbar = --bs-gray-300
 *      sidebar hover   #f8f9fa               .links-link:hover = --bs-light
 *      headings/links  #008002 -> #5f9960    --bs-link-color / -hover-color
 *      borders         #dee2e6               --bs-border-color
 *      muted text      #6c757d               --bs-secondary-color
 *      table stripe    rgba(0,0,0,.05)       --bs-table-striped-bg
 *      table hover     rgba(0,0,0,.075)      --bs-table-hover-bg
 *      stat box        #f5f5f5               .elo-results
 *      green/red/...   #d1e7dd #f8d7da       --bs-*-bg-subtle
 *                      #fff3cd #cff4fc
 *
 * # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # */

:root {
    color-scheme: dark;

    /* The three surfaces and three inks the templates have always used. */
    --color1: #222222;
    --color2: #2D2D2D;
    --color3: #3B3B3B;

    --color-font1: #DBDEE1;
    --color-font2: #949BA4;
    --color-font3: #008F11;

    /* Chrome */
    --link: #8BBAD6;
    --link-hover: #8BBAD6;
    --sidebar-bg: var(--color1);
    --sidebar-hover: #303030;
    --sidebar-rule: var(--color2);

    /* Tables */
    --stripes-th-bg: black;
    --table-header-bg: #171717;
    --row-hover: #323232;
    --td-border: #444444;

    /* Index capacity cards */
    --card-bg: var(--color2);
    --card-title-bg: var(--table-header-bg);
    --card-border: var(--color3);

    /* Buttons */
    --button-border: transparent;
    --button-ink: var(--color-font1);
    --button-blue: #1C2D40;
    --button-blue-hover: #2E3F57;
    --button-start: #384A5F;
    --button-start-hover: #2E3F57;
    --button-preset: #046c52;
    --button-preset-hover: #11a983;
    --button-yellow: #7A4E09;
    --button-yellow-hover: #9B6B0F;
    --button-red: #74261E;
    --button-red-hover: #8E3D28;

    /* Result blocks */
    --statblock-bg: #CCCCCC;
    --statblock-ink: black;
    --statblock-green: #76D576;
    --statblock-blue: #60F0FF;
    --statblock-yellow: #EFF891;
    --statblock-red: #FA9696;
    --statblock-hover: rgba(0, 0, 0, 0.10);
    --long-statblock-bg: var(--color3);
    --long-statblock-ink: var(--color-font2);

    /* Live Elo dials */
    --gauge-track: #4A4A4A;
    --gauge-bad: #C0392B;
    --gauge-warn: #D9891F;
    --gauge-good: #3D9A4E;
    --gauge-needle: #FF5A4B;
    --gauge-tick: #6E7681;
    --gauge-ink: #949BA4;
    --gauge-value-ink: #DBDEE1;

    /* Semantic inks (these were literal keywords in the original rules and in
       the inline styles that the markers/icons replaced). */
    --error-ink: red;
    --warning-ink: yellow;
    --success-ink: green;
    --redlink: #FF4D4D;
    --marker-thread-odds: orange;
    --was-default-network: #EFF891;
    --icon-muted: grey;
    --icon-destructive: #A03030;
    --atomicdb-link-ink: #e8a33d;

    /* Forms (form.css) */
    --input-bg: var(--color2);
    --input-ink: var(--color-font2);
    --input-border: var(--color3);
    --input-focus-border: var(--color3);
    --input-focus-shadow: 0 0 0 2px rgba(77, 144, 254, 0.75);
    --file-button-bg: var(--color3);
    --file-button-border: var(--color2);
    --file-button-hover-bg: rgba(77, 144, 254, 0.8);
    --file-button-hover-border: var(--color2);

    /* The theme switch itself */
    --toggle-ink: var(--color-font2);
    --toggle-ink-hover: var(--color-font3);
    --toggle-focus-ring: var(--color-font3);
}

/* Light: fishtest. */

html[data-theme="light"] {
    color-scheme: light;

    --color1: #ffffff;
    --color2: #f2f2f2;
    --color3: #e9ecef;

    --color-font1: #212529;
    --color-font2: #343a40;
    --color-font3: #008002;

    --link: #008002;
    --link-hover: #5f9960;
    --sidebar-bg: #dee2e6;
    --sidebar-hover: #f8f9fa;
    --sidebar-rule: #cbd2d9;

    --stripes-th-bg: #e9ecef;
    --table-header-bg: #e9ecef;
    --row-hover: #ececec;
    --td-border: #dee2e6;

    --card-bg: #ffffff;
    --card-title-bg: #f7f7f8;
    --card-border: #dee2e6;

    --button-border: #ced4da;
    --button-ink: #212529;
    --button-blue: #cfe2ff;
    --button-blue-hover: #b6d4fe;
    --button-start: #cfe2ff;
    --button-start-hover: #b6d4fe;
    --button-preset: #d1e7dd;
    --button-preset-hover: #a3cfbb;
    --button-yellow: #fff3cd;
    --button-yellow-hover: #ffe69c;
    --button-red: #f8d7da;
    --button-red-hover: #f1aeb5;

    --statblock-bg: #f5f5f5;
    --statblock-ink: #212529;
    --statblock-green: #44EB44;
    --statblock-blue: #66CCFF;
    --statblock-yellow: #FFFF00;
    --statblock-red: #FF6A6A;
    --statblock-hover: rgba(0, 0, 0, 0.075);
    --long-statblock-bg: #f5f5f5;
    --long-statblock-ink: #212529;

    --gauge-track: #dee2e6;
    --gauge-bad: #dc3545;
    --gauge-warn: #fd7e14;
    --gauge-good: #198754;
    --gauge-needle: #dc3545;
    --gauge-tick: #adb5bd;
    --gauge-ink: #6c757d;
    --gauge-value-ink: #212529;

    --error-ink: #b02a37;
    --warning-ink: #997404;
    --success-ink: #198754;
    --redlink: #dc3545;
    --marker-thread-odds: #b45309;
    --was-default-network: #997404;
    --icon-muted: #6c757d;
    --icon-destructive: #b02a37;
    --atomicdb-link-ink: #9a5b08;

    --input-bg: #ffffff;
    --input-ink: #212529;
    --input-border: #ced4da;
    --input-focus-border: #86b7fe;
    --input-focus-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
    --file-button-bg: #e9ecef;
    --file-button-border: #ced4da;
    --file-button-hover-bg: #dde2e6;
    --file-button-hover-border: #adb5bd;

    --toggle-ink: #6c757d;
    --toggle-ink-hover: #212529;
    --toggle-focus-ring: #5f9960;
}

/* Same palette for a client that never runs the bootstrap script (the script
   stamps data-theme before the stylesheets load, so this only fires with JS
   disabled). */

@media (prefers-color-scheme: light) {
    html:not([data-theme]) {
        color-scheme: light;

        --color1: #ffffff;
        --color2: #f2f2f2;
        --color3: #e9ecef;

        --color-font1: #212529;
        --color-font2: #343a40;
        --color-font3: #008002;

        --link: #008002;
        --link-hover: #5f9960;
        --sidebar-bg: #dee2e6;
        --sidebar-hover: #f8f9fa;
        --sidebar-rule: #cbd2d9;

        --stripes-th-bg: #e9ecef;
        --table-header-bg: #e9ecef;
        --row-hover: #ececec;
        --td-border: #dee2e6;

        --card-bg: #ffffff;
        --card-title-bg: #f7f7f8;
        --card-border: #dee2e6;

        --button-border: #ced4da;
        --button-ink: #212529;
        --button-blue: #cfe2ff;
        --button-blue-hover: #b6d4fe;
        --button-start: #cfe2ff;
        --button-start-hover: #b6d4fe;
        --button-preset: #d1e7dd;
        --button-preset-hover: #a3cfbb;
        --button-yellow: #fff3cd;
        --button-yellow-hover: #ffe69c;
        --button-red: #f8d7da;
        --button-red-hover: #f1aeb5;

        --statblock-bg: #f5f5f5;
        --statblock-ink: #212529;
        --statblock-green: #44EB44;
        --statblock-blue: #66CCFF;
        --statblock-yellow: #FFFF00;
        --statblock-red: #FF6A6A;
        --statblock-hover: rgba(0, 0, 0, 0.075);
        --long-statblock-bg: #f5f5f5;
        --long-statblock-ink: #212529;

        --gauge-track: #dee2e6;
        --gauge-bad: #dc3545;
        --gauge-warn: #fd7e14;
        --gauge-good: #198754;
        --gauge-needle: #dc3545;
        --gauge-tick: #adb5bd;
        --gauge-ink: #6c757d;
        --gauge-value-ink: #212529;

        --error-ink: #b02a37;
        --warning-ink: #997404;
        --success-ink: #198754;
        --redlink: #dc3545;
        --marker-thread-odds: #b45309;
        --was-default-network: #997404;
        --icon-muted: #6c757d;
        --icon-destructive: #b02a37;
        --atomicdb-link-ink: #9a5b08;

        --input-bg: #ffffff;
        --input-ink: #212529;
        --input-border: #ced4da;
        --input-focus-border: #86b7fe;
        --input-focus-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
        --file-button-bg: #e9ecef;
        --file-button-border: #ced4da;
        --file-button-hover-bg: #dde2e6;
        --file-button-hover-border: #adb5bd;

        --toggle-ink: #6c757d;
        --toggle-ink-hover: #212529;
        --toggle-focus-ring: #5f9960;
    }
}

html {
    background-color: var(--color1);
}

a:link, a:visited, a:active {
    text-decoration: none;
    color: var(--link);
}

a:hover {
    text-decoration: none;
    color: var(--link-hover);
}

body {
    background-color: var(--color1);

    font-size: 16px;
    font-family: "Courier Prime", serif;
    display:flex;

    /* So the sidebar column reaches the bottom of a short page. Invisible in
       dark, where the sidebar is the same colour as the canvas. */
    min-height: 100vh;
}

body, html, main{
    padding: 0;
    margin: 0;
    min-width: 100%;
    max-width: 100%;
    white-space: nowrap;
}

#sidebar {
    padding: 60px 16px 16px 16px;
    flex-basis: calc(min(300px, max(200px, 10%)));
    background-color: var(--sidebar-bg);
}

#sidebar-toggle {
    display: none;
}

#content-parent{
    flex-grow: 1;
    justify-content: left;
    height: 100%;

    box-sizing: border-box;
    padding-left: 2rem;
    padding-right: 2rem;
}

#content {
    max-width: calc(min(100%,1000px));
    width: 100%;
    white-space: nowrap;
    display: inline-block;

    /* Text with no rule of its own used to fall back to the initial colour,
       which is black -- readable on the light palette and all but invisible
       on the dark one (the /regression/ heading and lede were black on
       #222222). Anchor it to the page's own ink instead. */
    color: var(--color-font1);
}

/* Light / dark switch.

   Top-right corner of the viewport, which is where fishtest keeps its
   sun/moon (far right of the top bar, ~28px in from the edge). On desktop it
   is taken out of flow entirely, so #content-header lays out exactly as it
   did before any of the theme work, and the switch can neither be pushed
   off-screen by a wide table nor land on top of the index capacity cards.

   It is a bare icon rather than a bordered button, again following fishtest.
   The icon shows the theme a click would switch *to*, and the control stays
   hidden until the bootstrap script marks the document as script-capable, so
   a JS-less client never sees a dead switch. */

.theme-toggle {
    display: none;
    position: fixed;
    top: 10px;
    right: 16px;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 4px;
    background-color: transparent;
    color: var(--toggle-ink);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 180ms ease;
}

html.theme-js .theme-toggle {
    display: inline-flex;
}

.theme-toggle svg {
    display: block;
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.9;
}

.theme-toggle .theme-toggle-moon,
html[data-theme="light"] .theme-toggle .theme-toggle-sun {
    display: none;
}

html[data-theme="light"] .theme-toggle .theme-toggle-moon {
    display: block;
}

.theme-toggle:hover {
    color: var(--toggle-ink-hover);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--toggle-focus-ring);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

#sidebar ul {
    list-style-type: none;
    padding: 0px 16px 0px 8px;
    line-height: 1.75;
}

#sidebar li {
    padding: 4px 16px 2px;
    font-size: 1.0rem;
    border-radius: 4px;
    transition: background-color 0.2s ease-in-out;
}

#sidebar li a {
    color: var(--color-font2);
    display: block;
    width: 100%;
}

#sidebar li:hover {
    background-color: var(--sidebar-hover);
}

#sidebar .header {
    color: var(--color-font3);
    font-size: 1.1rem;
    pointer-events: none;
}

#sidebar hr {
    border: 1px var(--sidebar-rule) solid;
}

#sidebar .atomicdb-link {
    color: var(--atomicdb-link-ink);
    font-weight: 600;
}

/* Table Striping, with overriding for the Table Header */

#content .stripes tr:nth-child(odd):not(.table-header) {
    background-color: var(--color1);
}

#content .stripes tr:nth-child(even):not(.table-header) {
    background-color: var(--color2);
}

#content .stripes th {
    background-color: var(--stripes-th-bg);
}

/* Tables that have hoverable table rows */

#content .hoverable tr:nth-child(odd):hover:not(.table-header) {
    background-color: var(--row-hover);
}

#content .hoverable tr:nth-child(even):hover:not(.table-header) {
    background-color: var(--row-hover);
}

#content .hoverable tr:hover{
    background-color: var(--color1);
}

/* Tables that are too long can wrap words */

#content .wrappable td {
    white-space: pre-wrap;
    word-break: break-word;
    word-wrap: break-word;
}

/* Things which enable a Cursor Pointer event */

#content .cursor {
    cursor: pointer;
}

/* Table Headers in General */

#content .table-header th:first-child {
    border-top-left-radius: 12px;
}

#content .table-header th:last-child {
    border-top-right-radius: 12px;
}

#content .table-header th {
    color: var(--color-font3);
    font-weight: 400;
    background-color: var(--table-header-bg);
}

#content .table-small-header th {
    color: var(--color-font3);
    font-size: small;
    background-color: var(--table-header-bg);
}

/* Table Spacer for chaining Tables as a hack */

#content .table-spacer th, #content .table-spacer tr {
    background-color: var(--color1);
    height: 1rem;
}

#content .table-spacer-small th, #content .table-spacer-small tr {
    background-color: var(--table-header-bg);
    height: 0.4rem;
    padding: 0px;
}

/* Generic Table CSS for all Tables */

#content table {
    line-height: 96%;
    border-collapse: collapse;
}

#content td {
    color: var(--color-font2);
    border-bottom: 1px var(--td-border) solid;
}

#content th, #content td {
    padding: 10px 12px 6px 12px;
}

#content .anchor-container {
    display: flex;
    justify-content: space-between;
}

#content .anchor-container > .anchorbutton {
    flex: 1;
    margin-right: 4px;
}

#content .anchor-container > .anchorbutton:last-child {
    margin-right: 0px;
}

#content .anchorbutton {
    border-radius: 4px;
    padding: 8px 0px 6px;
    border-color: var(--button-border);
    color: var(--button-ink);
    display: inline-block;
    text-align: center;
    transition: background-color 0.3s ease;
    font-family: "Courier Prime", serif;
    font-size: 13px;
    cursor: pointer;
}

#content .btn-blue {
    background-color: var(--button-blue);
}

#content .btn-start {
    background-color: var(--button-start);
    width: 100%;
}

#content .btn-preset {
    background-color: var(--button-preset);
}

#content .btn-yellow {
    background-color: var(--button-yellow);
}

#content .btn-red {
    background-color: var(--button-red);
}

#content .btn-disabled {
    background-color: var(--color3);
}

#content .btn-blue:hover {
    background-color: var(--button-blue-hover);
}

#content .btn-start:hover {
    background-color: var(--button-start-hover);
}

#content .btn-preset:hover {
    background-color: var(--button-preset-hover);
}

#content .btn-yellow:hover {
    background-color: var(--button-yellow-hover);
}

#content .btn-red:hover {
    background-color: var(--button-red-hover);
}

#content .btn-disabled:hover {
    background-color: var(--color3);
    cursor: not-allowed;
    transform: none;
}

#content .copy-button {
    color: var(--color-font2);
    transition: color 0.2s ease-in-out;

}

#content .copy-button:hover {
    color: var(--color-font3);
    cursor: pointer;
}

/* Short StatBlock to show SPRT and Test Results */

#content .statblock {
    font-size: 13px;
    color: var(--statblock-ink);
    line-height: 92%;
    background-color: var(--statblock-bg);
    font-family: "Courier New";
    border-radius: 4px;
    padding: 7px 10px 4px;
}

#content .statblock-green {
    background-color: var(--statblock-green);
}

#content .statblock-blue {
    background-color: var(--statblock-blue);
}

#content .statblock-yellow {
    background-color: var(--statblock-yellow);
}

#content .statblock-red {
    background-color: var(--statblock-red);
}

/* The whole result box is the link to its test. The padding moves onto the
   anchor so the click target is the box a visitor is aiming at, and not just
   the glyphs inside it. */

#content td.statblock {
    padding: 0;
}

#content .statblock-link {
    display: block;
    padding: 7px 10px 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

#content .statblock-link:link,
#content .statblock-link:visited,
#content .statblock-link:active,
#content .statblock-link:hover {
    color: inherit;
}

#content .statblock-link:hover {
    background-color: var(--statblock-hover);
}

#content .redlink {
    color: var(--redlink);
}

/* Long StatBlock which we can copy */

#content .long-statblock {
    background-color: var(--long-statblock-bg);
    color: var(--long-statblock-ink);
    border-radius: 4px;
    padding: 0.50rem 0.75rem;
}

/* Live Elo dials: LLR, LOS and Elo on top of a gameplay workload.
   Drawn by live_elo.js; the design follows Fishtest's live_elo page. The
   colours stay here so the theme switch repaints the needles for free. */

#content .live-elo {
    float: left;
}

#content .live-elo-dials {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: flex-end;
}

#content .live-elo-dial {
    flex: 1 1 190px;
    min-width: 0;
    max-width: 260px;
}

#content .live-elo-svg {
    display: block;
    width: 100%;
    height: auto;
}

#content .live-elo-band {
    fill: none;
    stroke-linecap: butt;
}

#content .live-elo-band-track {
    stroke: var(--gauge-track);
}

#content .live-elo-band-bad {
    stroke: var(--gauge-bad);
}

#content .live-elo-band-warn {
    stroke: var(--gauge-warn);
}

#content .live-elo-band-good {
    stroke: var(--gauge-good);
}

#content .live-elo-tick {
    stroke: var(--gauge-tick);
    stroke-width: 1.5;
}

#content .live-elo-tick-mark {
    stroke: var(--gauge-value-ink);
    stroke-width: 2.5;
}

#content .live-elo-needle,
#content .live-elo-hub {
    fill: var(--gauge-needle);
}

#content .live-elo-value {
    fill: var(--gauge-value-ink);
    font-family: "Courier Prime", monospace;
    font-size: 26px;
    font-weight: bold;
}

#content .live-elo-label {
    fill: var(--gauge-ink);
    font-family: "Courier Prime", monospace;
    font-size: 13px;
    letter-spacing: 1px;
}

#content .live-elo-bound {
    fill: var(--gauge-ink);
    font-family: "Courier Prime", monospace;
    font-size: 11px;
}

#content .live-elo-summary {
    margin: 0.5rem 0 0;
    padding: 0.50rem 0.75rem;
    background-color: var(--long-statblock-bg);
    color: var(--long-statblock-ink);
    border-radius: 4px;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Test Views */

#content #config {
    float: left;
}

#content #actions {
    float: left;
}

#content #results {
    display: inline-block;
    width: inherit;
}

#content .test-config {
    font-size: 1.0rem;
}

#content .test-config .td-label {
    color: var(--color-font1);
    white-space: nowrap;
    vertical-align: top;
}

#content .test-config code {
    display: block;
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    font-family: "Courier Prime", monospace;
}

/* ??? */

td pre {
    margin: 0px;
    padding: 0px;
}

#content .error-message {
    color: var(--error-ink);
}

#content .warning-message {
    color: var(--warning-ink);
}

#content .status-message {
    color: var(--success-ink);
}

#content .site-title {
    color: var(--color-font3);
}

#content .default-network {
    color: var(--color-font3);
    transform: scale(1.10);
}

#content .was-default-network {
    color: var(--was-default-network);
    transform: scale(0.90);
}

#content .non-default-network {
    color: var(--color-font1);
    transform: scale(0.70);
}

/* Icons and markers that used to carry inline colours */

#content .icon-muted {
    color: var(--icon-muted);
}

#content .icon-destructive {
    color: var(--icon-destructive);
}

#content .marker-error,
#content .marker-fischer,
#content .marker-time-odds,
#content .marker-thread-odds {
    cursor: pointer;
}

#content .marker-error {
    color: var(--error-ink);
}

#content .marker-fischer {
    color: var(--success-ink);
}

#content .marker-time-odds {
    color: var(--warning-ink);
}

#content .marker-thread-odds {
    color: var(--marker-thread-odds);
}

#content .numeric {
    text-align: right;
}

#content .branch_name {
    font-style: italic;
}

#content .active-highlight {
    border-left: 4px solid var(--color-font3);
}

/* Fishtest-style capacity summary on the main index */

#content .index-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0 0 1rem;
    white-space: normal;
}

#content .index-metric {
    min-width: 0;
    overflow: hidden;
    color: var(--color-font1);
    text-align: center;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    cursor: help;
}

#content .index-metric-title {
    padding: 0.45rem 0.25rem;
    color: var(--color-font2);
    font-size: 0.85rem;
    background-color: var(--card-title-bg);
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

#content .index-metric-value {
    padding: 0.75rem 0.25rem;
    color: var(--color-font1);
    font-size: clamp(1.35rem, 2.5vw, 2rem);
    font-weight: bold;
    line-height: 1;
    white-space: nowrap;
}

/* Cross-fade the palette when the switch is used. Added a frame after load so
   the initial paint is never animated. */

html.theme-ready body,
html.theme-ready #sidebar,
html.theme-ready #content-header,
html.theme-ready #content td,
html.theme-ready #content th,
html.theme-ready #content .anchorbutton,
html.theme-ready #content .statblock,
html.theme-ready #content .long-statblock,
html.theme-ready #content .index-metric,
html.theme-ready #content .index-metric-title,
html.theme-ready .page,
html.theme-ready input,
html.theme-ready select,
html.theme-ready textarea {
    transition:
        background-color 180ms ease,
        border-color 180ms ease,
        color 180ms ease;
}

/* Styles for laptop-class widths. A 1920x1200 panel at 150% Windows scaling
   is 1280x800 CSS pixels, and the page used to answer that with a horizontal
   scrollbar on the body: a 200px sidebar, 2rem of gutter and a 1000px cap on
   the content leave the index table without the width it needs. Nothing here
   fires above 1366px, so the wide-screen layout is exactly as it was. */

@media (max-width: 1366px) {

    /* A flex item is min-width:auto by default, so the nowrap table inside
       could push this column -- and the page with it -- past the viewport. */
    #content-parent {
        min-width: 0;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* The 1000px cap costs width this page no longer has to spare. */
    #content {
        max-width: 100%;
    }

    /* A flex item will not shrink below its own min-content width, and the
       engine list carries names like Fairy-Stockfish-Atomic-Baseline: without
       min-width, one entry in the navigation decided how much of the viewport
       the sidebar took. */
    #sidebar {
        flex-basis: 168px;
        flex-shrink: 0;
        min-width: 0;
        padding: 52px 6px 12px 6px;
    }

    #sidebar ul {
        padding: 0px 4px;
        line-height: 1.6;
    }

    #sidebar li {
        padding: 3px 6px 1px;
        font-size: 0.75rem;
    }

    #sidebar li a {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #sidebar .header {
        font-size: 0.85rem;
    }

    /* The capacity cards keep a readable width and take a second row when
       they need one, instead of clipping their own values. */
    #content .index-metrics {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }

    #content th, #content td {
        padding: 8px 8px 5px 8px;
    }

    /* "Active: N Machines / N Threads / N MNPS" takes a second line rather
       than running off the end of its header row. */
    #content .table-header th {
        white-space: normal;
    }

    /* Branch names are the one column with no natural bound. The full name
       stays in the link's title, and on its own test page. */
    #content .branch-link {
        display: inline-block;
        max-width: 20ch;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: bottom;
    }

    /* Three dials still fit a 1280 viewport; below that they wrap cleanly. */
    #content .live-elo-dial {
        max-width: 240px;
    }

    /* Last resort for a table that still will not fit: the container scrolls
       sideways, never the body. Only inside this query -- above it the wide
       layout lets a long table spill past the content column, which is what
       it has always done. */
    #content .table-scroll {
        max-width: 100%;
        overflow-x: auto;
    }
}

/* Styles for screen widths less than 768px */
@media (max-width: 767px) {
    #sidebar {
        flex-basis: 100%;
        position: fixed;
        top: 0;
        bottom: 0;
        width: 100%;
        background-color: var(--sidebar-bg);
        overflow-y: auto;
        transition: transform cubic-bezier(0.82, 0.08, 0.1, 0.93) 0.3s;
        transform: translateX(-100%);
    }

    body.sidebar-open #sidebar {
        transform: none;
    }

    #sidebar-toggle {
        display: flex;
        padding: 10px;
        color: var(--color-font1);
        background-color: transparent;
        border: none;
        position: relative;
        z-index: 10;
        font-size: 2.2rem;
    }

    #content-parent {
        height: auto;
        flex-grow: 0;
        flex-basis: 100%;
        padding: 0 8px;
    }

    #content {
        overflow-x: hidden;
        margin-top: 70px;
    }

    #content-header {
        display: flex;
        align-items: center;
        background-color: var(--color1);
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;

        /* The bar has to span the viewport so the switch can sit against its
           right edge; it is the same colour as the canvas, so widening it
           changes nothing that can be seen. */
        box-sizing: border-box;
        width: 100%;
        padding-right: 6px;
    }

    #content-header h2 {
        /* Adjust the font size to the screen width, ensuring that the title
           doesn't overflow. Trimmed from 4.8vw to 4.4vw so the title still
           clears the switch on a 375px phone; above 509px the clamp ceiling
           applies and the size is unchanged. */
        font-size: clamp(1.0rem, 4.4vw, 1.4rem);
        margin: 8px 0;
        min-width: 0;
    }

    /* The hamburger, the title and the switch share one narrow row. On a
       phone too narrow even for the trimmed size, the title wraps instead of
       running under the icon. */
    #content-header .site-title {
        white-space: normal;
    }

    /* In the header row, flush to the right edge of the viewport. Fixed
       positioning is dropped here: the bar itself already reaches the edge,
       and staying in flow keeps the switch off the title. */
    #content-header .theme-toggle {
        position: static;
        flex: 0 0 auto;
        margin-left: auto;
    }

    body {
        flex-direction: column;
    }

    /* Disable vertical body scrolling when the sidebar is open */
    body.sidebar-open {
        position: fixed;
        overflow-y: hidden;
    }

    /* Horizontally scrollable table */
    table {
        display: block;
        overflow-x: auto;
    }

    /* Tables cannot break words to avoid issues such as single-letter lines */
    /* The only exception is the test config table */
    #content .wrappable:not(.workload-container .test-config) td {
        word-break: normal;
    }

    /* Test Views */
    .workload-container {
        display: flex;
        flex-direction: column;
    }

    #content #actions {
        order: -1;
        margin: 0 0 1rem 0;
    }

    /* The dials stay at the top of the page on a phone as well */
    #content .live-elo {
        order: -2;
        float: none;
    }

    #content #config {
        float: none;
    }

    #content .long-statblock {
        overflow-x: auto;
    }

    #content .index-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html.theme-ready body,
    html.theme-ready #sidebar,
    html.theme-ready #content-header,
    html.theme-ready #content td,
    html.theme-ready #content th,
    html.theme-ready #content .anchorbutton,
    html.theme-ready #content .statblock,
    html.theme-ready #content .long-statblock,
    html.theme-ready #content .index-metric,
    html.theme-ready #content .index-metric-title,
    html.theme-ready .page,
    html.theme-ready input,
    html.theme-ready select,
    html.theme-ready textarea,
    .theme-toggle {
        transition-duration: 0.01ms;
    }
}

@media (forced-colors: active) {
    .theme-toggle {
        forced-color-adjust: auto;
        border: 1px solid ButtonText;
        background: ButtonFace;
        color: ButtonText;
    }
}
