/* ==========================================================================
   theme.css: light mode + theme switching, for every page.
   1. light-mode variables          4. light-mode overrides: home labels
   2. light sky (clouds)            5. colour transitions for the theme switch
   3. light-mode overrides: home    6. sun/moon spin + light-mode sidebar
   Shared colour tokens (ink, violet, hairlines...) live in tokens.css.
   ========================================================================== */

/* 1. light-mode variables ------------------------------------------------- */
html.theme-light {
    color-scheme: light;
    background: #f4f2f6 !important;
    scrollbar-color: #aaa3af #e4e1e7;
}

/* light values for the shared colours live in tokens.css; these are page/component ones */
body.is-light-mode {
    --sidebar-surface: #f8f7fa;
    --sidebar-surface-raised: #e8e4ec;
    --sidebar-outline: #aaa3af;
    --sidebar-divider: #d3ced8;
    --star-bright: #26212d;
    --star-dim: #4f4658;
    --star-near: #40364a;
    min-height: 100vh;
    background: #f4f2f6 !important;
    color: #18151c;
}

/* 2. light sky: clouds replace the stars ---------------------------------- */
body.is-light-mode .sky {
    opacity: .65;
    filter: none;
}

.cloud-field {
    position: absolute;
    inset: 0;
    display: block;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity .55s ease;
}

.star-layer {
    transition: opacity .55s ease;
}

body.is-light-mode .star-layer {
    opacity: 0 !important;
    animation: none !important;
}

body.is-light-mode .star-particle {
    --particle-color: #000;
    box-shadow: 0 0 .3rem rgba(0, 0, 0, .3), 0 0 .7rem rgba(0, 0, 0, .42);
}

.cloud {
    position: absolute;
    display: block;
    width: clamp(12rem, 23vw, 26rem);
    height: 1.7rem;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(62, 45, 76, .24), rgba(62, 45, 76, .11));
    filter: blur(.2px);
    opacity: .8;
    animation: cloud-drift 42s ease-in-out infinite;
}

.cloud::before,
.cloud::after {
    position: absolute;
    bottom: .35rem;
    content: "";
    border-radius: 50%;
    background: inherit;
}

.cloud::before {
    left: 13%;
    width: 28%;
    height: 2.4rem;
}

.cloud::after {
    right: 17%;
    width: 37%;
    height: 3rem;
}

.cloud-one {
    top: 10%;
    left: 42%;
    scale: 1.05;
    rotate: -2deg;
    animation-delay: -17s;
}

.cloud-two {
    top: 30%;
    left: 78%;
    scale: .75;
    rotate: 2deg;
    animation-duration: 50s;
    animation-delay: -31s;
}

.cloud-three {
    top: 58%;
    left: 3%;
    scale: .8;
    rotate: -1deg;
    animation-duration: 46s;
    animation-delay: -9s;
}

.cloud-four {
    top: 84%;
    left: 68%;
    scale: 1.16;
    rotate: 1deg;
    animation-duration: 56s;
    animation-delay: -42s;
}

.cloud-five {
    top: 17%;
    left: 73%;
    width: clamp(8rem, 15vw, 18rem);
    height: 1.1rem;
    scale: .62;
    rotate: -2deg;
    opacity: .46;
    animation-duration: 38s;
    animation-delay: -5s;
}

.cloud-six {
    top: 72%;
    left: 19%;
    width: clamp(15rem, 28vw, 32rem);
    height: 2.25rem;
    scale: .86;
    rotate: 1deg;
    opacity: .56;
    animation-duration: 62s;
    animation-delay: -27s;
}

.cloud-seven {
    top: 45%;
    left: 46%;
    width: clamp(9rem, 18vw, 21rem);
    height: 1.35rem;
    scale: .7;
    rotate: -1deg;
    opacity: .4;
    animation-duration: 44s;
    animation-delay: -36s;
}

body.is-light-mode .cloud-field {
    opacity: 1;
}

/* the clouds are invisible in dark mode, so don't make the browser re-style them every
   frame there (with the blur filter that cost ~20ms a frame on a large window) */
body:not(.is-light-mode) .cloud {
    animation-play-state: paused;
}

/* 3. light-mode overrides: home + sidebar toggles ------------------------ */
body.is-light-mode .transition-star {
    background: #f4f2f6;
    box-shadow: 0 0 2rem 1rem rgba(79, 40, 107, .2);
}

body.is-light-mode .moon {
    opacity: 0;
    scale: .72;
    filter: none;
}

body.is-light-mode .sun {
    opacity: 1;
    scale: 1;
}

body.is-light-mode .moon-glint {
    opacity: 0;
}

body.is-light-mode .moon-wrap::before {
    background: radial-gradient(circle, rgba(111, 54, 150, .2) 0, rgba(79, 40, 107, .09) 38%, transparent 70%);
}

body.is-light-mode .identity h1 {
    left: 50%;
    color: #18151c;
    text-shadow: 0 2px 1rem rgba(255, 255, 255, .55);
}

body.is-light-mode .star {
    background: #26212d;
    box-shadow: 0 0 .35rem .08rem rgba(38, 33, 45, .35), 0 0 .8rem .14rem rgba(79, 40, 107, .14);
}

body.is-light-mode .site-sidebar-control[data-theme-toggle].is-light .site-sidebar-control-icon-sun {
    color: #63337f;
}

body.is-light-mode .site-sidebar-control[data-theme-toggle] .site-sidebar-control-icon-moon {
    opacity: 0;
    scale: .72;
}

body.is-light-mode .site-sidebar-control[data-theme-toggle] .site-sidebar-control-icon-sun {
    opacity: 1;
    scale: 1;
}

body.is-light-mode .site-sidebar-control[data-theme-toggle] .site-sidebar-theme-label-dark {
    opacity: 0;
}

body.is-light-mode .site-sidebar-control[data-theme-toggle] .site-sidebar-theme-label-light {
    opacity: 1;
}

body.animations-disabled .site-sidebar-control[data-animation-toggle] .site-sidebar-control-icon-motion-on {
    opacity: 0;
    scale: .72;
}

body.animations-disabled .site-sidebar-control[data-animation-toggle] .site-sidebar-control-icon-motion-off {
    opacity: 1;
    scale: 1;
}

body.is-light-mode .return-link,
body.is-light-mode .link-label {
    color: var(--violet);
}

/* 5. colour transitions so switching theme fades instead of snapping ---- */
html,
body {
    transition: background-color .55s ease;
}

/* text colour is inherited by the whole page, so fading it restyles everything every frame;
   only the theme switch fades it (pages swap their colours while the content is faded out) */
html:has(> body.theme-color-fading),
body.theme-color-fading {
    transition: background-color .55s ease, color var(--theme-color-duration) var(--theme-color-timing);
}

.site-sidebar-shell,
.site-sidebar-toggle,
.site-sidebar-toggle::before {
    transition: border-color .55s ease, background-color .55s ease, color var(--theme-color-duration) var(--theme-color-timing), box-shadow .55s ease;
}

.site-sidebar-brand,
.site-sidebar-control,
.site-sidebar-link,
.site-sidebar-nav-icon,
.identity h1,
.about,
.about a,
.projects-view,
.projects-heading > p:last-child,
.destination-overview > p:not(.kicker),
.destination .prototype-note,
.star-line,
.link-label {
    transition: color var(--theme-color-duration) var(--theme-color-timing);
}

.site-sidebar-brand-label,
.site-sidebar-control-label,
.site-sidebar-link-label {
    transition: max-width .34s cubic-bezier(.3, .5, .25, 1), opacity .2s ease, color var(--theme-color-duration) var(--theme-color-timing);
}

.site-sidebar-control {
    transition: border-color .55s ease, background-color .55s ease, color var(--theme-color-duration) var(--theme-color-timing);
}

.site-sidebar-link {
    transition: border-color .55s ease, background-color .55s ease, color var(--theme-color-duration) var(--theme-color-timing), translate .25s ease;
}

.site-sidebar-nav-icon {
    transition: color var(--theme-color-duration) var(--theme-color-timing), translate .25s ease;
}

.site-sidebar-control-icon-stack .site-sidebar-control-icon {
    transition: opacity .35s ease, scale .35s cubic-bezier(.3, .5, .25, 1), color var(--theme-color-duration) var(--theme-color-timing);
}

.site-sidebar-control-label,
.site-sidebar-theme-label > span {
    color: var(--ink);
}

.site-sidebar-theme-label > span {
    transition: opacity .28s linear, color var(--theme-color-duration) var(--theme-color-timing);
}

.identity h1 {
    transition: color var(--theme-color-duration) var(--theme-color-timing), text-shadow var(--theme-color-duration) var(--theme-color-timing), left .55s cubic-bezier(.2,.8,.2,1);
}

.star-line {
    transition: opacity .3s ease, box-shadow .3s ease, background-color .55s ease;
}

.link-label {
    transition: color var(--theme-color-duration) var(--theme-color-timing), border-color var(--theme-color-duration) var(--theme-color-timing), translate .3s ease;
}

body.theme-spin-to-light .moon,
/* 6. sun/moon spin during the switch, then the light-mode sidebar -------- */
body.theme-spin-to-light .site-sidebar-moon {
    animation: theme-moon-to-light .72s cubic-bezier(.2,.8,.2,1) both;
}

body.theme-spin-to-light .sun,
body.theme-spin-to-light .site-sidebar-sun {
    animation: theme-sun-to-light .72s cubic-bezier(.2,.8,.2,1) both;
}

body.theme-spin-to-dark .moon,
body.theme-spin-to-dark .site-sidebar-moon {
    animation: theme-moon-to-dark .72s cubic-bezier(.2,.8,.2,1) both;
}

body.theme-spin-to-dark .sun,
body.theme-spin-to-dark .site-sidebar-sun {
    animation: theme-sun-to-dark .72s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes theme-moon-to-light {
    from { opacity: 1; scale: 1; rotate: 0deg; }
    to { opacity: 0; scale: .72; rotate: 180deg; }
}

@keyframes theme-sun-to-light {
    from { opacity: 0; scale: .72; rotate: 180deg; }
    to { opacity: 1; scale: 1; rotate: 360deg; }
}

@keyframes theme-moon-to-dark {
    from { opacity: 0; scale: .72; rotate: 180deg; }
    to { opacity: 1; scale: 1; rotate: 360deg; }
}

@keyframes theme-sun-to-dark {
    from { opacity: 1; scale: 1; rotate: 0deg; }
    to { opacity: 0; scale: .72; rotate: 180deg; }
}

@keyframes cloud-drift {
    0%, 100% { translate: -1.5rem 0; }
    50% { translate: 1.5rem .35rem; }
}

body.is-light-mode .site-sidebar-shell {
    background: var(--sidebar-surface);
    box-shadow: .75rem 0 2rem rgba(25, 18, 31, .12);
}

body.is-light-mode .site-sidebar-toggle {
    background: var(--sidebar-outline);
}

body.is-light-mode .site-sidebar-toggle::before {
    background: var(--sidebar-surface);
}

body.is-light-mode .site-sidebar-link,
body.is-light-mode .site-sidebar-control,
body.is-light-mode .site-sidebar-controls {
    color: #18151c;
}

body.is-light-mode .site-sidebar-controls {
    --sidebar-control-divider: rgba(79, 40, 107, .14);
}

body.is-light-mode .site-sidebar-nav::after {
    color: rgba(99, 51, 127, .06);
}

body.is-light-mode .site-sidebar-switch {
    border-color: rgba(75, 67, 82, .35);
    background: rgba(75, 67, 82, .08);
    color: rgba(75, 67, 82, .72);
}

body.is-light-mode .site-sidebar-control[aria-pressed="true"] .site-sidebar-switch {
    border-color: var(--violet);
    background: var(--violet);
    color: #fff;
}

body.is-light-mode .site-sidebar-nav-icon,
body.is-light-mode .site-sidebar-control-icon {
    color: #4b4352;
}

body.is-light-mode .site-sidebar-control:hover,
body.is-light-mode .site-sidebar-control:focus-visible,
body.is-light-mode .site-sidebar-control[data-theme-toggle][aria-pressed="true"],
body.is-light-mode .site-sidebar-control[data-animation-toggle][aria-pressed="false"] {
    background: var(--sidebar-surface-raised);
    color: #18151c;
}

body.is-light-mode .site-sidebar-link:hover .site-sidebar-nav-icon,
body.is-light-mode .site-sidebar-link:focus-visible .site-sidebar-nav-icon,
body.is-light-mode .site-sidebar-link.is-active .site-sidebar-nav-icon {
    color: #18151c;
}

body.is-light-mode .projects-view {
    color: #18151c;
}

body.is-light-mode .destination-overview > p:not(.kicker) {
    color: #3c3443;
}

body.is-light-mode .destination .prototype-note {
    color: #5c5264;
}

body.is-light-mode .projects-heading > p:last-child {
    color: #38323d;
}

body.is-light-mode .about {
    color: #38323d;
}

body.is-light-mode .star-line {
    background: #3e3745;
}

body.is-light-mode .link-label {
    border-bottom-color: rgba(24, 21, 28, .55);
}

body.is-light-mode .music-page {
    --music-border: rgba(79, 40, 107, .48);
    --music-panel: #fff;
    --music-panel-hover: #f1eef4;
    --music-line: rgba(79, 40, 107, .18);
    --music-line-strong: rgba(79, 40, 107, .48);
    color: #18151c;
}

body.is-light-mode .music-intro,
body.is-light-mode .music-results-heading p,
body.is-light-mode .music-results-heading span,
body.is-light-mode .music-page-jump,
body.is-light-mode .music-result-note {
    color: #5f5765;
}

body.is-light-mode .music-search,
body.is-light-mode .music-table-wrap,
body.is-light-mode .custom-table tbody tr {
    border-color: rgba(79, 40, 107, .48);
    background: #fff;
    color: #18151c;
}

body.is-light-mode .music-page .form-control,
body.is-light-mode .music-page select {
    border-color: rgba(75, 67, 82, .35) !important;
    background: #fff !important;
    color: #18151c !important;
}

body.is-light-mode .music-search-field label,
body.is-light-mode .custom-table thead th,
body.is-light-mode .music-section-heading span {
    color: #2a2530 !important;
}

body.is-light-mode .music-tag-control.is-enhanced .music-tag-options {
    background: #fff;
}

body.is-light-mode .music-tag-trigger {
    border-color: rgba(75, 67, 82, .35);
    background: #fff;
    color: #2a2530;
}

body.is-light-mode .music-tag-trigger:hover,
body.is-light-mode .music-tag-trigger:focus-visible {
    border-color: var(--violet);
    background: #f1eef4;
    color: #18151c;
    outline: none;
}

body.is-light-mode .music-tag-dropdown {
    border-color: rgba(79, 40, 107, .48);
    background: #fff;
    box-shadow: 0 1.5rem 4rem rgba(48, 29, 62, .16);
}

body.is-light-mode .music-tag-dropdown-footer {
    border-color: rgba(79, 40, 107, .18);
}

body.is-light-mode .music-tag-selection-count {
    color: #665d6d;
}

body.is-light-mode .music-tag-option {
    color: #2a2530;
}

body.is-light-mode .music-tag-option:hover,
body.is-light-mode .music-tag-option:focus-visible {
    background: #f1eef4;
    color: #18151c;
}

body.is-light-mode .music-tag-option.is-selected {
    border-color: rgba(79, 40, 107, .62);
    background: #f1eef4;
    color: #18151c;
}

body.is-light-mode .music-button,
body.is-light-mode .music-button-primary,
body.is-light-mode .music-button-secondary {
    border-color: rgba(75, 67, 82, .35);
    background: #fff;
    color: #2a2530;
}

body.is-light-mode .music-button:hover,
body.is-light-mode .music-button:focus-visible,
body.is-light-mode .music-button-primary:hover,
body.is-light-mode .music-button-primary:focus-visible,
body.is-light-mode .music-button-secondary:hover,
body.is-light-mode .music-button-secondary:focus-visible {
    border-color: var(--violet);
    background: #f1eef4;
    color: #18151c;
}

body.is-light-mode .custom-table {
    color: #2a2530;
}

body.is-light-mode .custom-table td:first-child,
body.is-light-mode .song-link {
    color: #18151c !important;
}

body.is-light-mode .song-link:hover,
body.is-light-mode .song-link:focus-visible {
    color: var(--violet) !important;
}
