/* Blitzboard dark mode: only loaded with the default theme, active when <html data-bb-mode="dark">.
   The mode is set in the head (fragments/layout.html) and switched with the toggle in the navbar (js/color_mode.js).
   Contrast (WCAG AA, >= 4.5:1): text on bg 14.9, muted on bg 8.0, accent green on bg 7.8, accent green on surface 7.1. */
html[data-bb-mode="dark"] {
    --bb-dark-bg: #101814;
    --bb-dark-surface: #18231D;
    --bb-dark-surface-raised: #1F2D25;
    --bb-dark-border: #2C3A31;
    --bb-dark-text: #E6EAE4;
    --bb-dark-muted: #A3B0A6;
    --bb-dark-accent: #5FBF85;
    --bb-dark-accent-hover: #7FD3A0;

    --bs-body-bg: var(--bb-dark-bg);
    color-scheme: dark;
}

html[data-bb-mode="dark"] body {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-bg);
}

html[data-bb-mode="dark"] a {
    color: var(--bb-dark-accent);
}

html[data-bb-mode="dark"] a:hover {
    color: var(--bb-dark-accent-hover);
}

html[data-bb-mode="dark"] hr {
    border-top-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] code {
    color: #F49AC2;
}

html[data-bb-mode="dark"] pre {
    color: var(--bb-dark-text);
}

/* text and backgrounds */
html[data-bb-mode="dark"] .text-primary {
    color: var(--bb-dark-accent) !important;
}

html[data-bb-mode="dark"] .text-muted {
    color: var(--bb-dark-muted) !important;
}

/* dark text stays dark on gold (warning) badges */
html[data-bb-mode="dark"] .text-dark:not(.bg-warning) {
    color: var(--bb-dark-text) !important;
}

html[data-bb-mode="dark"] .bg-light,
html[data-bb-mode="dark"] .bg-white {
    background-color: var(--bb-dark-surface-raised) !important;
}

html[data-bb-mode="dark"] .border,
html[data-bb-mode="dark"] .border-top,
html[data-bb-mode="dark"] .border-bottom,
html[data-bb-mode="dark"] .border-left,
html[data-bb-mode="dark"] .border-right {
    border-color: var(--bb-dark-border) !important;
}

/* custom highlights from bloodbowl.css have a bright background: keep dark text on them */
html[data-bb-mode="dark"] .score,
html[data-bb-mode="dark"] .telegram {
    color: var(--bb-ink);
}

/* navbar */
html[data-bb-mode="dark"] .navbar.blitzboard-navbar {
    background-color: var(--bb-green-dark);
}

html[data-bb-mode="dark"] .navbar.blitzboard-navbar .nav-link {
    color: rgba(255, 255, 255, .85);
}

html[data-bb-mode="dark"] .navbar.blitzboard-navbar .nav-link:hover,
html[data-bb-mode="dark"] .navbar.blitzboard-navbar .nav-link:focus {
    color: #fff;
}

html[data-bb-mode="dark"] .navbar.blitzboard-navbar .navbar-toggler {
    border-color: rgba(255, 255, 255, .2);
}

html[data-bb-mode="dark"] .navbar.blitzboard-navbar .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.7%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* the wide logo has a transparent variant with light text for dark backgrounds
   (blitzboard-logo-dark.svg has its own dark box, it is meant for the bright headers of the other themes);
   below 600px the <picture> in the navbar shows the square icon, that one works on both backgrounds */
@media (min-width: 600px) {
    html[data-bb-mode="dark"] .blitzboard-logo {
        content: url("/blitzboard-logo-on-dark.svg");
    }
}

html[data-bb-mode="dark"] .blitzboard-hero-logo {
    content: url("/blitzboard-logo-on-dark.svg");
}

/* colour mode toggle: the sun replaces the moon */
html[data-bb-mode="dark"] .bb-mode-toggle {
    color: var(--bb-gold);
}

html[data-bb-mode="dark"] .bb-mode-toggle:hover {
    color: var(--bb-gold);
    background-color: rgba(242, 183, 5, .15);
}

html[data-bb-mode="dark"] .bb-mode-toggle:focus-visible {
    box-shadow: 0 0 0 .2rem rgba(242, 183, 5, .5);
}

html[data-bb-mode="dark"] .bb-mode-toggle .bb-icon-moon {
    opacity: 0;
    transform: rotate(90deg) scale(.5);
}

html[data-bb-mode="dark"] .bb-mode-toggle .bb-icon-sun {
    opacity: 1;
    transform: none;
}

/* breadcrumb */
html[data-bb-mode="dark"] .breadcrumb {
    background-color: var(--bb-dark-surface);
}

html[data-bb-mode="dark"] .breadcrumb-item + .breadcrumb-item::before,
html[data-bb-mode="dark"] .breadcrumb-item.active {
    color: var(--bb-dark-muted);
}

/* cards, list groups, dropdowns, modals, toasts */
html[data-bb-mode="dark"] .card,
html[data-bb-mode="dark"] .list-group-item,
html[data-bb-mode="dark"] .dropdown-menu,
html[data-bb-mode="dark"] .modal-content,
html[data-bb-mode="dark"] .popover {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-surface);
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .card-header,
html[data-bb-mode="dark"] .card-footer {
    background-color: rgba(255, 255, 255, .04);
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .list-group-item-action {
    color: var(--bb-dark-text);
}

html[data-bb-mode="dark"] .list-group-item-action:hover,
html[data-bb-mode="dark"] .list-group-item-action:focus {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-surface-raised);
}

html[data-bb-mode="dark"] .list-group-item.active {
    color: #fff;
    background-color: var(--bb-green);
    border-color: var(--bb-green);
}

html[data-bb-mode="dark"] .list-group-item.disabled,
html[data-bb-mode="dark"] .list-group-item:disabled {
    color: var(--bb-dark-muted);
    background-color: var(--bb-dark-surface);
}

html[data-bb-mode="dark"] .dropdown-item {
    color: var(--bb-dark-text);
}

html[data-bb-mode="dark"] .dropdown-item:hover,
html[data-bb-mode="dark"] .dropdown-item:focus {
    color: #fff;
    background-color: var(--bb-dark-surface-raised);
}

html[data-bb-mode="dark"] .dropdown-divider {
    border-top-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .modal-header,
html[data-bb-mode="dark"] .modal-footer {
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .close {
    color: #fff;
    text-shadow: none;
}

html[data-bb-mode="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

html[data-bb-mode="dark"] .toast {
    background-color: var(--bb-dark-surface);
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .toast-header {
    color: var(--bb-dark-muted);
    background-color: var(--bb-dark-surface-raised);
    border-bottom-color: var(--bb-dark-border);
}

/* tables */
html[data-bb-mode="dark"] .table {
    color: var(--bb-dark-text);
}

html[data-bb-mode="dark"] .table th,
html[data-bb-mode="dark"] .table td,
html[data-bb-mode="dark"] .table thead th,
html[data-bb-mode="dark"] .table tbody + tbody,
html[data-bb-mode="dark"] .table-bordered,
html[data-bb-mode="dark"] .table-bordered th,
html[data-bb-mode="dark"] .table-bordered td {
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, .04);
}

html[data-bb-mode="dark"] .table-hover tbody tr:hover {
    color: var(--bb-dark-text);
    background-color: rgba(255, 255, 255, .08);
}

html[data-bb-mode="dark"] .table-light,
html[data-bb-mode="dark"] .table-light > th,
html[data-bb-mode="dark"] .table-light > td,
html[data-bb-mode="dark"] .table .thead-light th {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-surface-raised);
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .table-secondary,
html[data-bb-mode="dark"] .table-secondary > th,
html[data-bb-mode="dark"] .table-secondary > td {
    color: var(--bb-dark-text);
    background-color: #2A352E;
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .table-dark,
html[data-bb-mode="dark"] .table-dark > th,
html[data-bb-mode="dark"] .table-dark > td {
    color: #fff;
    background-color: var(--bb-green-dark);
    border-color: var(--bb-green);
}

/* forms */
html[data-bb-mode="dark"] .form-control,
html[data-bb-mode="dark"] .form-select,
html[data-bb-mode="dark"] .custom-select {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-surface);
    border-color: #3D4D43;
}

html[data-bb-mode="dark"] .form-control:focus,
html[data-bb-mode="dark"] .form-select:focus,
html[data-bb-mode="dark"] .custom-select:focus {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-surface);
    border-color: var(--bb-dark-accent);
    box-shadow: 0 0 0 .2rem rgba(95, 191, 133, .35);
}

html[data-bb-mode="dark"] .form-control::placeholder {
    color: #7D8A80;
}

html[data-bb-mode="dark"] .form-control:disabled,
html[data-bb-mode="dark"] .form-control[readonly],
html[data-bb-mode="dark"] .form-select:disabled,
html[data-bb-mode="dark"] .custom-select:disabled {
    color: var(--bb-dark-muted);
    background-color: #131C17;
}

html[data-bb-mode="dark"] .form-select,
html[data-bb-mode="dark"] .custom-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%23ced4da' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e");
}

html[data-bb-mode="dark"] .input-group-text {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-surface-raised);
    border-color: #3D4D43;
}

html[data-bb-mode="dark"] .form-text,
html[data-bb-mode="dark"] .custom-control-label {
    color: inherit;
}

html[data-bb-mode="dark"] .form-switch .form-check-input {
    background-color: var(--bb-dark-surface);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255,255,255,.45%29'/%3e%3c/svg%3e");
    border-color: rgba(255, 255, 255, .3);
}

html[data-bb-mode="dark"] .form-switch .form-check-input:checked {
    background-color: var(--bb-green-light);
    border-color: var(--bb-green-light);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* tabs and pagination */
html[data-bb-mode="dark"] .nav-tabs {
    border-bottom-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .nav-tabs .nav-link:hover,
html[data-bb-mode="dark"] .nav-tabs .nav-link:focus {
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .nav-tabs .nav-link.active,
html[data-bb-mode="dark"] .nav-tabs .nav-item.show .nav-link {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-bg);
    border-color: var(--bb-dark-border) var(--bb-dark-border) var(--bb-dark-bg);
}

html[data-bb-mode="dark"] .nav-tabs .nav-link.disabled {
    color: var(--bb-dark-muted);
}

html[data-bb-mode="dark"] .page-link {
    color: var(--bb-dark-accent);
    background-color: var(--bb-dark-surface);
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .page-link:hover {
    color: var(--bb-dark-accent-hover);
    background-color: var(--bb-dark-surface-raised);
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .page-item.active .page-link {
    color: #fff;
    background-color: var(--bb-green);
    border-color: var(--bb-green);
}

html[data-bb-mode="dark"] .page-item.disabled .page-link {
    color: var(--bb-dark-muted);
    background-color: var(--bb-dark-surface);
    border-color: var(--bb-dark-border);
}

/* buttons: the green fill stays, outlines and light buttons need lighter colours on the dark background */
html[data-bb-mode="dark"] .btn-outline-primary {
    color: var(--bb-dark-accent);
    border-color: var(--bb-dark-accent);
}

html[data-bb-mode="dark"] .btn-outline-primary:hover,
html[data-bb-mode="dark"] .btn-outline-primary:not(:disabled):not(.disabled):active,
html[data-bb-mode="dark"] .btn-outline-primary:not(:disabled):not(.disabled).active {
    color: #fff;
    background-color: var(--bb-green-light);
    border-color: var(--bb-green-light);
}

html[data-bb-mode="dark"] .btn-outline-secondary {
    color: var(--bb-dark-muted);
    border-color: var(--bb-dark-muted);
}

html[data-bb-mode="dark"] .btn-outline-secondary:hover,
html[data-bb-mode="dark"] .btn-outline-secondary:focus,
html[data-bb-mode="dark"] .btn-outline-secondary.active,
html[data-bb-mode="dark"] .show > .btn-outline-secondary.dropdown-toggle {
    color: var(--bb-ink);
    background-color: var(--bb-dark-muted);
    border-color: var(--bb-dark-muted);
}

html[data-bb-mode="dark"] .btn-outline-dark {
    color: var(--bb-dark-text);
    border-color: var(--bb-dark-text);
}

html[data-bb-mode="dark"] .btn-outline-dark:hover {
    color: var(--bb-ink);
    background-color: var(--bb-dark-text);
}

html[data-bb-mode="dark"] .btn-outline-warning {
    color: var(--bb-gold);
}

html[data-bb-mode="dark"] .btn-outline-warning:hover,
html[data-bb-mode="dark"] .btn-outline-warning:focus {
    color: var(--bb-ink);
}

html[data-bb-mode="dark"] .btn-light {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-surface-raised);
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .btn-link {
    color: var(--bb-dark-accent);
}

/* alerts: opaque colours, the roster summary is a sticky alert that scrolls over the content */
html[data-bb-mode="dark"] .alert .alert-link {
    color: inherit;
}

html[data-bb-mode="dark"] .alert-primary {
    color: #BFE6CD;
    background-color: #17311F;
    border-color: #24533A;
}

html[data-bb-mode="dark"] .alert-secondary {
    color: #D3DAD4;
    background-color: #252B27;
    border-color: #3A433D;
}

html[data-bb-mode="dark"] .alert-success {
    color: #B5E5C4;
    background-color: #133020;
    border-color: #23573A;
}

html[data-bb-mode="dark"] .alert-info {
    color: #A6DDEB;
    background-color: #0F2A33;
    border-color: #1D4C5A;
}

html[data-bb-mode="dark"] .alert-warning {
    color: #F6D97A;
    background-color: #3A2F0A;
    border-color: #6B5510;
}

html[data-bb-mode="dark"] .alert-danger {
    color: #F3B5BA;
    background-color: #3A1518;
    border-color: #6A262C;
}

html[data-bb-mode="dark"] .alert-light {
    color: var(--bb-dark-text);
    background-color: var(--bb-dark-surface);
    border-color: var(--bb-dark-border);
}

html[data-bb-mode="dark"] .alert-dark {
    color: var(--bb-dark-text);
    background-color: #0B100D;
    border-color: var(--bb-dark-border);
}

/* a short fade when switching, not on the first paint */
html[data-bb-mode-switching] body,
html[data-bb-mode-switching] .card,
html[data-bb-mode-switching] .navbar {
    transition: background-color .25s ease, color .25s ease;
}

@media (prefers-reduced-motion: reduce) {
    html[data-bb-mode-switching] body,
    html[data-bb-mode-switching] .card,
    html[data-bb-mode-switching] .navbar {
        transition: none;
    }
}
