/* Dark theme. The "dark" class on <html> is set by assets/js/theme.js from the
   visitor's saved choice, or else the OS setting (prefers-color-scheme).
   Load this after every other stylesheet and inline <style> so it wins.
   :where(.dark) adds no specificity, so each rule competes as if it were unprefixed. */

:root {
    color-scheme: light;
    --yanna-blue: rgb(37, 160, 244);
}

:root.dark {
    color-scheme: dark;
    --bg: #121417;
    --surface: #1c1f24;
    --border: #3a3f47;
    --text: #e4e6eb;
    --text-muted: #a3a9b3;
    --link: #6cc0f8;
}

html:where(.dark),
:where(.dark) body {
    background-color: var(--bg);
    color: var(--text);
}

/* Landing page */
:where(.dark) .section,
:where(.dark) .section-white,
:where(.dark) .section-gray,
:where(.dark) .section .text-area {
    background-color: var(--bg);
}

:where(.dark) .text-gray {
    color: var(--text-muted);
}

:where(.dark) a,
:where(.dark) .text-gray a {
    color: var(--link);
}

:where(.dark) a:hover,
:where(.dark) a:focus {
    color: #9bd4fb;
}

/* Keep buttons and the footer/navbar links white on their coloured backgrounds */
:where(.dark) .btn-login,
:where(.dark) .btn-login:hover,
:where(.dark) .btn-login:focus,
:where(.dark) .signup-button,
:where(.dark) .signup-button:hover,
:where(.dark) .footer a,
:where(.dark) .footer .copyright,
:where(.dark) .navbar-transparent .navbar-nav > li > a:not(.btn) {
    color: #fff;
}

:where(.dark) .navbar-default:not(.navbar-transparent) {
    background-color: var(--surface);
}

:where(.dark) .navbar-default:not(.navbar-transparent) .navbar-nav > li > a:not(.btn) {
    color: var(--text);
}

/* Mobile slide-out menu */
:where(.dark) body > .navbar-collapse {
    background-color: var(--surface);
    border-left-color: var(--border);
}

/* the menu's white panel is drawn by this pseudo-element, not the background */
:where(.dark) body > .navbar-collapse::after {
    background-color: var(--surface);
}

:where(.dark) body > .navbar-collapse .nav > li {
    border-bottom-color: var(--border);
}

:where(.dark) body > .navbar-collapse .nav > li > a {
    color: var(--text);
}

:where(.dark) .footer {
    border-top-color: var(--border);
}

/* Waitlist / beta signup forms */
:where(.dark) .form-container {
    background: var(--surface);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

/* The beta form keeps its blue input borders; only soften the light grey ones */
:where(.dark) #WaitingList input,
:where(.dark) select {
    border-color: var(--border);
    background-color: transparent;
}

:where(.dark) select option {
    background-color: var(--surface);
    color: var(--text);
}

:where(.dark) .content-style,
:where(.dark) .head-content,
:where(.dark) .success-content {
    color: var(--text);
}

/* Light / dark switch, at the top right: in the navbar on the landing page
   (in the slide-out menu on small screens), in the page corner on the signup pages */
.navbar > .container {
    position: relative;
}

.theme-toggle {
    position: absolute;
    right: 15px;
    top: 15px;
    z-index: 1031;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .2s, background-color .2s;
}

.theme-toggle:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.theme-toggle:focus {
    outline: none;
}

.theme-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform .4s ease;
}

.theme-toggle:hover svg {
    transform: rotate(-20deg);
}

/* moon in light mode (switch to dark), sun in dark mode */
.theme-toggle .icon-sun,
.dark .theme-toggle .icon-moon {
    display: none;
}

.dark .theme-toggle .icon-sun {
    display: block;
}

/* Solid white navbar (after scrolling) and the white signup pages need a blue switch */
:root:not(.dark) .navbar-default:not(.navbar-transparent) .theme-toggle,
:root:not(.dark) .theme-toggle-corner {
    color: var(--yanna-blue);
    border-color: rgba(37, 160, 244, 0.45);
    background: transparent;
}

:root:not(.dark) .navbar-default:not(.navbar-transparent) .theme-toggle:hover,
:root:not(.dark) .theme-toggle-corner:hover {
    border-color: var(--yanna-blue);
    background: rgba(37, 160, 244, 0.08);
}

:root:not(.dark) .theme-toggle-corner:focus-visible {
    outline-color: var(--yanna-blue);
}

.theme-toggle-corner {
    top: 20px;
    right: 20px;
}

/* The copy inside the menu list is only for the slide-out menu on small screens */
.navbar .theme-item {
    display: none !important;
}

@media screen and (max-width: 767px) {
    .theme-toggle-corner {
        top: 16px;
        right: 16px;
    }
}

/* Below 992px the menu becomes a slide-out (built by yanna.js from a copy of the navbar list),
   so the switch moves from the top bar to the bottom of that menu */
@media screen and (max-width: 991px) {
    .navbar .theme-toggle {
        display: none;
    }
}

body > .navbar-collapse .nav > li.theme-item {
    position: absolute;
    left: 0;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    border-bottom: 0;
}

body > .navbar-collapse .theme-item .theme-toggle {
    position: static;
    transform: none;
    display: flex;
    margin: 0;
}

:root:not(.dark) body > .navbar-collapse .theme-toggle {
    color: var(--yanna-blue);
    border-color: rgba(37, 160, 244, 0.45);
    background: transparent;
}

:root:not(.dark) body > .navbar-collapse .theme-toggle:hover {
    border-color: var(--yanna-blue);
    background: rgba(37, 160, 244, 0.08);
}

:root:not(.dark) body > .navbar-collapse .theme-toggle:focus-visible {
    outline-color: var(--yanna-blue);
}

/* Landing page splash image: daytime in light mode, moonlit in dark mode */
#splashscreen {
    background-image: url('../../splashscreen.jpg');
}

:where(.dark) #splashscreen {
    background-image: url('../../splashscreen_moonlight.png');
}
