/*     Theme tokens     */
/*The stylesheets used to carry raw hex values, so a colour could only mean one thing.
  Every colour now goes through a named token here, and the dark block below is the only
  place that says what those names mean when the theme flips.

  The light values are exactly the hex values the site shipped with - light mode is meant
  to render pixel for pixel as before, so anything that looks different in light is a bug.

  The switch is Bootstrap's own data-bs-theme attribute on <html>, so Bootstrap's components
  (navbar, forms, tables, cards, dropdowns) flip on the same signal as our own CSS.*/

:root {
    color-scheme: light;

    /*Surfaces, from the page up to the thing sitting closest to the reader*/
    --page-bg: #eef1f4; /*only the Title page tints the page itself*/
    --surface: #fff; /*cards, inputs, chips, the navbar*/
    --surface-panel: #f8f9fa; /*toolbars, table headers, the grid footer*/
    --surface-muted: #f1f3f5; /*read-only and disabled fields, the series pill*/
    --surface-tag: #e9ecef; /*the field labels on Send It*/

    /*Lines, from hairline up to the borders that draw a control*/
    --line: #dee2e6;
    --line-soft: #e9ecef; /*row separators inside the media grid*/
    --line-legacy: #e5e5e5; /*the layout's own top and bottom rules*/
    --line-control: #ced4da; /*form controls*/
    --line-strong: #adb5bd; /*chips, toggles, pagination*/

    /*Text, from the strongest to the faintest*/
    --ink: #212529;
    --ink-body: #495057;
    --ink-muted: #6c757d;
    --ink-disabled: #656d75; /*read-only and disabled controls - quiet, but still meant to be read*/
    --ink-faint: #adb5bd;
    --badge-bg: #adb5bd; /*the little "?" disc next to the personal rating*/
    --ink-pager-off: #ced4da; /*a pagination arrow with nowhere to go*/

    /*Ink that must never flip. It sits on a fixed colour: the server writes the rating
      cells' hsl() background inline, and the two owner swatches carry their own colours,
      so those backgrounds stay vivid in dark mode and their text stays dark with them.*/
    --ink-on-swatch: #444;
    --ink-on-rating: #212529; /*the Title sidebar rating value, on that same inline hsl background*/
    --on-accent: #fff; /*text on a teal fill - the fill does not flip, so neither does this*/

    /*Teal is the site's accent. It is a fill in light mode and stays one in dark - white on
      #0f766e clears AA either way - but as text or a border on a dark ground it goes muddy,
      so those two roles lift to a brighter teal below.*/
    --accent: #0f766e; /*fills: active toggles, selected rows, multi-select tags*/
    --accent-deep: #115e59; /*the bar down the left of a watching row*/
    --accent-line: #0f766e; /*focus borders*/
    --accent-ink: #0f766e; /*teal as text*/
    --accent-soft-bg: #e6f2f1; /*the highlighted row in a dropdown*/
    --accent-ring: rgba(15, 118, 110, 0.15); /*focus glow*/
    --accent-ring-strong: rgba(15, 118, 110, 0.45);
    --accent-wash: #14867c4d; /*"watch next" - the same teal at a third strength, so it reads as
                               a weaker claim than the solid "watching" row above it*/

    /*Amber says "something folded away is filtered". Vivid enough to hold in both themes.*/
    --warn-bg: #fbbf24;
    --warn-line: #f59e0b;
    --warn-ink: #422006;
    --star: #fbbf24;
    --star-glow: rgba(251, 191, 36, 0.4);

    /*The blue chip for a selected network*/
    --chip-on-bg: #cfe2ff;
    --chip-on-line: #9ec5fe;
    --chip-on-ink: #084298;

    /*Links and buttons*/
    --link: #0077cc;
    --btn-primary-bg: #1b6ec2;
    --btn-primary-line: #1861ac;
    --btn-primary-ink: #fff;
    --focus-ring: #258cfb;
    --focus-halo: #fff; /*the inner ring that separates the glow from the control*/
    --input-focus-line: #0d6efd; /*Send It focuses its inputs in Bootstrap blue, not in teal*/
    --input-focus-ring: rgba(13, 110, 253, 0.25);

    /*Status*/
    --ok-ink: #155724;
    --ok-bg: #e6ffe6;
    --ok-line: #28a745;
    --ok-strong: green;
    --danger: red;
    --add-bg: #d1e7dd;
    --add-ink: #0f5132;

    /*Cells the games list flags: a missing field (red), worth a second look (yellow), released (green)*/
    --cell-missing-bg: #f8d7da;
    --cell-missing-ink: #842029;
    --cell-warn-bg: #fff3cd;
    --cell-warn-ink: #664d03;
    --cell-released-bg: #d1e7dd;
    --cell-released-ink: #0f5132;

    /*Shadows and the one divider drawn in plain black*/
    --shadow-card: rgba(0, 0, 0, 0.05);
    --shadow-pop: rgba(0, 0, 0, 0.15);
    --shadow-bar: rgba(0, 0, 0, 0.06);
    --divider-mobile: rgba(0, 0, 0, 0.3);

    /*The trailer pull's rows (YPEC-303): watch (green), check the search (yellow), short (half-grey), not a trailer
      or a folded duplicate (grey), and the two decisions*/
    --pull-green-bg: #dcf5e3;
    --pull-green-bar: #22a05a;
    --pull-yellow-bg: #fff3c4;
    --pull-yellow-bar: #e0a800;
    --pull-half-bg: #f4f5f6;
    --pull-half-ink: #7d848b;
    --pull-grey-bg: #eceef0;
    --pull-grey-ink: #8f969d;
    --pull-trailer: #1b6ec2;
    --pull-bad: #b02a37;

    /*The Power page (MAIN-9): the hour bars - cheap, normal, expensive - and work's line*/
    --power-cheap: #0f766e;
    --power-bar: #aab4be;
    --power-dear: #e8590c;
    /*Games: markers after a name - no Steam link (red), not found on HowLongToBeat (orange). Standalone icon colours
      on the row, at least 3:1 against it (red 4.5, orange 3.6); the cell-ink colours were made for text on a tinted cell*/
    --mark-missing: #dc3545;
    --mark-warn: #e8590c;
    --power-work: #212529; /*Work's line and bar: dark, so it shows on teal, grey and orange alike*/
}

[data-bs-theme="dark"] {
    color-scheme: dark;

    /*The surfaces climb as they get closer to the reader: page, then card, then panel.
      Bootstrap's own dark greys are retuned to this same ramp further down, so a native
      card and one of ours land on the same colour instead of two neighbouring greys.*/
    --page-bg: #15181c;
    --surface: #1d2126;
    --surface-panel: #23282e;
    --surface-muted: #2a3037;
    --surface-tag: #2f353d;

    --line: #363d45;
    --line-soft: #2f353d;
    --line-legacy: #363d45;
    --line-control: #444c56;
    --line-strong: #525b66;

    --ink: #e5e9ed;
    --ink-body: #b7c0c9;
    --ink-muted: #949ea8; /*lifted from #8d97a1 so muted text clears AA on the muted surface too*/
    --ink-disabled: #949ea8;
    --ink-faint: #6b7580;
    --badge-bg: #5a636d;
    --ink-pager-off: #4f5862;

    /*unchanged on purpose - see the light block*/
    --ink-on-swatch: #444;
    --on-accent: #fff; /*text on a teal fill - the fill does not flip, so neither does this*/

    --accent: #0f766e;
    --accent-deep: #115e59;
    --accent-line: #2dd4bf;
    --accent-ink: #5eead4;
    --accent-soft-bg: #143430;
    --accent-ring: rgba(45, 212, 191, 0.25);
    --accent-ring-strong: rgba(45, 212, 191, 0.5);
    --accent-wash: #14867c66;

    --warn-bg: #fbbf24;
    --warn-line: #f59e0b;
    --warn-ink: #422006;
    --star: #fbbf24;
    --star-glow: rgba(251, 191, 36, 0.4);

    --chip-on-bg: #1c3a5e;
    --chip-on-line: #2f5c8f;
    --chip-on-ink: #b9d3f2;

    --link: #6cb6ff;
    --btn-primary-bg: #1b6ec2;
    --btn-primary-line: #1861ac;
    --btn-primary-ink: #fff;
    --focus-ring: #258cfb;
    --focus-halo: #15181c;
    --input-focus-line: #6cb6ff;
    --input-focus-ring: rgba(108, 182, 255, 0.3);

    --ok-ink: #a7d9bd;
    --ok-bg: #12301c;
    --ok-line: #28a745;
    --ok-strong: #4ade80;
    --danger: #f87171;
    --add-bg: #14331f;
    --add-ink: #a7d9bd;

    --cell-missing-bg: #4c1d24;
    --cell-missing-ink: #f8c4ca;
    --cell-warn-bg: #4a3a0c;
    --cell-warn-ink: #f6e1a1;
    --cell-released-bg: #163a2a;
    --cell-released-ink: #a7d9bd;

    /*A shadow is the absence of light and cannot darken a dark ground, so the card shadows
      go to near nothing and depth is carried by the surface ramp instead.*/
    --shadow-card: rgba(0, 0, 0, 0.4);
    --shadow-pop: rgba(0, 0, 0, 0.6);
    --shadow-bar: rgba(0, 0, 0, 0.45);
    --divider-mobile: rgba(255, 255, 255, 0.16);

    /*The trailer pull's rows: tinted surfaces dark enough for the light body text, the bars kept bright*/
    --pull-green-bg: #16301f;
    --pull-green-bar: #34c274;
    --pull-yellow-bg: #332a0c;
    --pull-yellow-bar: #f0b90b;
    --pull-half-bg: #23282e;
    --pull-half-ink: #9aa3ad;
    --pull-grey-bg: #1a1e22;
    --pull-grey-ink: #7f8993;
    --pull-trailer: #6cb6ff;
    --pull-bad: #f1828d;

    /*The Power page: brighter bars so they stand off the dark card*/
    --power-cheap: #14b8a6;
    --power-bar: #5f6b77;
    --power-dear: #f76707;
    --mark-missing: #f87171; /*6.4:1 on the dark row*/
    --mark-warn: #fb923c; /*7.9:1*/
    --power-work: #e5e9ed;

    /*Bootstrap's dark defaults sit on a different grey ramp than ours. Pointing them at our
      tokens keeps native components (cards on Network, Recipe's lists, Send It's inputs)
      on the same surfaces as the pages we have restyled.*/
    --bs-body-bg: #15181c;
    --bs-body-bg-rgb: 21, 24, 28;
    --bs-body-color: #e5e9ed;
    --bs-body-color-rgb: 229, 233, 237;
    --bs-secondary-bg: #2a3037;
    --bs-secondary-bg-rgb: 42, 48, 55;
    --bs-tertiary-bg: #23282e;
    --bs-tertiary-bg-rgb: 35, 40, 46;
    --bs-border-color: #363d45;
    --bs-link-color: #6cb6ff;
    --bs-link-color-rgb: 108, 182, 255;
    --bs-link-hover-color: #8ec7ff;
    --bs-link-hover-color-rgb: 142, 199, 255;
    --bs-card-bg: #1d2126;
    --bs-card-border-color: #363d45;
}

/*     Chrome that the layout owns     */
/*The navbar used to be pinned white with bg-white. Bootstrap's default navbar is
  transparent, which would have let the Title page's grey body show through it, so the
  surface is stated here instead of borrowed from the page.*/
.navbar {
    background-color: var(--surface);
}

    .navbar .navbar-brand,
    .navbar .nav-link {
        color: var(--ink);
    }

        .navbar .nav-link:hover,
        .navbar .nav-link:focus {
            color: var(--accent-ink);
        }

/*     Nav menus     */
/*Media is both a page and a menu, so its word and its caret are two controls side by side.
  The nav never collapses, so its menu always opens as a popup and never needs a line of its own.*/
.navSplit {
    display: flex;
    align-items: center;
}

    /*The word and the caret sit as close as Other's do (4px), so the two read as one item*/
    .navbar-nav .navSplit > .nav-link:first-child {
        padding-right: 0.1rem;
    }

    .navbar-nav .navSplit > .dropdown-toggle-split {
        padding-left: 0.15rem;
        padding-right: 0.5rem;
    }

/*On a phone the caret is tapped, not clicked, and 17px is too narrow for a thumb*/
@media (max-width: 575.98px) {
    .navbar-nav .navSplit > .dropdown-toggle-split {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/*Between phone and tablet the whole row only fits on one line with the links a little closer together and the nav
  using the window's width rather than the 540px container*/
@media (min-width: 576px) and (max-width: 767.98px) {
    .navbar {
        --bs-navbar-nav-link-padding-x: 0.25rem;
    }

    .navbar > .container {
        max-width: none;
    }
}

/*On a phone the P stands in for the name and opens the menu with everything that is not Media or
  Send It. Only the image shows - no button chrome.*/
.navBrandMenu {
    display: block;
    padding: 0;
    margin-right: 0.5rem;
    border: 0;
    border-radius: 50%;
    background: none;
    line-height: 0;
}

    .navBrandMenu img {
        display: block;
        width: 30px;
        height: 30px;
    }

    .navBrandMenu:focus-visible {
        outline: 2px solid var(--accent-line);
        outline-offset: 2px;
    }

/*Bootstrap's dropdown highlights in its own blue; these point it at the site's surface, lines
  and teal, so the menus flip with the theme like everything else.*/
.navbar .dropdown-menu {
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-border-color: var(--line);
    --bs-dropdown-link-color: var(--ink);
    --bs-dropdown-link-hover-color: var(--ink);
    --bs-dropdown-link-hover-bg: var(--accent-soft-bg);
    --bs-dropdown-link-active-color: var(--on-accent);
    --bs-dropdown-link-active-bg: var(--accent);
    --bs-dropdown-header-color: var(--ink-muted); /*"Logged in as" in the phone menu; Bootstrap's grey doesn't flip*/
}

/*     Nav icons     */
/*Utilities, not features: admin, log out and the theme toggle sit at the end of the nav and
  keep the height of a nav link so they do not compete with the brand for the eye.*/
.navIcon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    color: var(--ink-muted);
    cursor: pointer;
}

    .navIcon:hover {
        border-color: var(--line);
        color: var(--ink);
    }

    .navIcon:focus-visible {
        outline: 2px solid var(--accent-line);
        outline-offset: 2px;
    }

    .navIcon svg {
        width: 17px;
        height: 17px;
        display: block;
    }

/*Who the browser is logged in as, as quiet as the icons beside it. One line: a long name is cut short (the title holds
  all of it), so it can't push the nav onto a second row*/
.navAccount {
    max-width: 10rem;
    margin-right: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    color: var(--ink-muted);
}

/*"Logged in as" heads the account menus. A long name wraps rather than widen the menu off a phone's screen (measured:
  a 50-character name made the menu 401px wide at 375px)*/
.navAccountHeader {
    max-width: min(18rem, calc(100vw - 2rem));
    white-space: normal;
    overflow-wrap: anywhere;
}

/*...and the menu holding it is as wide as it needs, up to that cap: Bootstrap's 10rem would wrap even "Logged in as
  AlexWork"*/
.dropdown-menu:has(.navAccountHeader) {
    width: max-content;
}

/*     Theme toggle     */
/*The icon shows what a click gets you, not the theme you are already in.*/
.themeToggle .themeIconSun {
    display: none;
}

[data-bs-theme="dark"] .themeToggle .themeIconMoon {
    display: none;
}

[data-bs-theme="dark"] .themeToggle .themeIconSun {
    display: block;
}

/*The theme is applied before paint, so there is no flash - but the very first frame of a
  transition would still show the old colours sweeping. Nothing animates on the flip.*/
@media (prefers-reduced-motion: reduce) {
    .themeToggle {
        transition: none;
    }
}

/*     Colours that carry data, not theme     */
/*These encode a value - a rating, whose row it is - rather than a mood, so they are defined
  once and are the same in both themes.

  The owner swatches carry the same two hues the desktop app uses - blue for Alex, berry for
  Ann - but as a fill rather than as text, so they are tinted light enough for --ink-on-swatch
  to sit on them: #444 measures 5.68 on the blue and 5.15 on the berry. The salmon that used to
  stand in for Ann only reached 3.76, which is why her pill read as washed out.

  Both are opaque, so the row behind them cannot lift or drag the colour and neither needs a
  dark-mode override. The old amber did: it was drawn at 80% alpha and relied on a white row
  showing through, which a dark row turned against it.*/
:root {
    --star-network: #e0a800;
    --rating-10: #1f7a4d;
    --rating-9: #3f8f68;
    --rating-8: #5f8fa3;
    --rating-7: #7d8790;
    --marker-ink: #fff; /*sits on the rating fills above, so it does not flip*/
    --swatch-alex: #9ecbf0;
    --swatch-ann: #f0a8c4;
}
