/* Dark theme, the hand-tuned part, and its switch (layout/theme_toggle.html, js/site-theme.js).
   Loads after site-dark.css, which maps every stylesheet's colours (manage.py build_dark_css);
   this file sets the page itself, the large brand bands and what the mapping cannot know. */

:root {
    --dk-page: #111723;
    --dk-raised: #171e2b;
    --dk-line: #273142;
    --dk-ink: #eaeff7;
    --dk-text: #c6cbd3;
    --dk-muted: #9aa5b4;
    --dk-link: #35aff6;
    /* the brand blue, deepened for the large areas, so it glows on the buttons only */
    --dk-band: linear-gradient(135deg, #0a5f8e 0%, #08496e 50%, #06334f 100%);
    --dk-band-flat: #0a4a70;
    --dk-foot: #0b1d2e;
}

/* ---------- Switch ---------- */

.tt {
    --tt-size: 48px;
    position: relative;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: var(--tt-size);
    height: var(--tt-size);
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    background: #fff;
    color: #0987c2;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease,
        box-shadow 200ms ease, transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.tt:hover { border-color: #0096db; }
.tt:active { transform: scale(.94); }

.tt:focus-visible {
    outline: 3px solid #0096db;
    outline-offset: 3px;
}

.tt__icon { display: block; overflow: visible; }

/* sun → moon: the disc grows, a second disc slides over it from the corner, the rays fold away */
.tt__core, .tt__cut, .tt__rays {
    transition: transform 500ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms ease;
}

.tt__core { transform-origin: 12px 12px; }
.tt__rays { transform-origin: 12px 12px; }

html[data-theme="dark"] .tt__core { transform: scale(1.75); }
html[data-theme="dark"] .tt__cut { transform: translate(-13px, 2px); }
html[data-theme="dark"] .tt__rays { opacity: 0; transform: rotate(-60deg) scale(.4); }

/* wide screens: always at hand in the bottom left corner (the assistant stands in the right one) */
.tt--float {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1029; /* under the header and its panels */
    box-shadow: 0 1px 2px rgba(2, 74, 110, .08), 0 10px 28px -10px rgba(2, 74, 110, .45);
}

.tt--float:hover { box-shadow: 0 1px 2px rgba(2, 74, 110, .08), 0 14px 32px -10px rgba(2, 74, 110, .55); }

.tt__tip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    padding: 7px 12px;
    border-radius: 8px;
    background: #1e293b;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(-4px, -50%);
    transition: opacity 150ms ease, transform 200ms cubic-bezier(0.23, 1, 0.32, 1);
}

.tt__tip-off, html[data-theme="dark"] .tt__tip-on { display: none; }
html[data-theme="dark"] .tt__tip-off { display: inline; }

.tt--float:focus-visible .tt__tip { opacity: 1; transform: translate(0, -50%); }

@media (hover: hover) and (pointer: fine) {
    .tt--float:hover .tt__tip { opacity: 1; transform: translate(0, -50%); transition-delay: 300ms; }
}

/* in the header row it only lives in the drawer: the floating one serves wide screens */
.tt--menu { display: none; }

@media (max-width: 1199px) {
    .tt--float { display: none; }
    .tt--menu { display: grid; --tt-size: 44px; }
}

/* where the container's gutter is narrower than the switch, the copyright line steps aside for it */
@media (min-width: 1200px) and (max-width: 1289px), (min-width: 1400px) and (max-width: 1469px) {
    .ft .ft-bottom p { padding-left: 48px; }
}

/* the drawer covers the page: the switch stays reachable inside it */
html.sh-locked .tt--float { display: none; }

/* ---------- The circle that spreads from the switch ---------- */

html.theme-vt::view-transition-old(root),
html.theme-vt::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

html.theme-vt::view-transition-new(root) { z-index: 9999; }

/* ---------- Dark theme ---------- */

html[data-theme="dark"] {
    color-scheme: dark;
    background-color: var(--dk-page);
}

html[data-theme="dark"] body {
    background-color: var(--dk-page);
    color: var(--dk-text);
}

html[data-theme="dark"] ::selection { background: rgba(53, 175, 246, .35); color: #fff; }

html[data-theme="dark"] .tt {
    border-color: var(--dk-line);
    background: var(--dk-raised);
    color: #ffd166;
}

html[data-theme="dark"] .tt:hover { border-color: #35aff6; }
html[data-theme="dark"] .tt__tip { background: #eaeff7; color: #111723; }

/* Bootstrap's colour utilities are !important and built from rgb variables the mapping cannot read */
html[data-theme="dark"] .bg-white, html[data-theme="dark"] .bg-body { background-color: var(--dk-page) !important; }
html[data-theme="dark"] .bg-light { background-color: var(--dk-raised) !important; }
html[data-theme="dark"] .text-dark, html[data-theme="dark"] .text-black, html[data-theme="dark"] .text-body { color: var(--dk-text) !important; }
html[data-theme="dark"] .text-muted, html[data-theme="dark"] .text-secondary { color: var(--dk-muted) !important; }
html[data-theme="dark"] .border, html[data-theme="dark"] .border-top, html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start, html[data-theme="dark"] .border-end { border-color: var(--dk-line) !important; }

/* a light marker in CMS text keeps dark text on it (js/site-theme.js) */
html[data-theme="dark"] [data-dk-light] { color: #1e293b; }

/* ---------- Large brand bands: deepened ---------- */

html[data-theme="dark"] .sh-util {
    background:
        url("../img/header-lines.595e4e9c7ea2.svg") repeat-x left center / auto 100%,
        linear-gradient(90deg, #0a5f8e 0%, #084a70 100%);
}

/* every page hero shares the gradient of the University pages; on the dark page it deepens with them */
html[data-theme="dark"] .page-hero,
html[data-theme="dark"] .sh-panel__lead,
html[data-theme="dark"] :is(.ab-hero, .ia-hero, .dt-hero, .qa-hero, .sf-hero, .pr-hero, .sdd-hero, .ssc-hero, .ra-hero, .sv-hero, .gdcau-hero) {
    background:
        radial-gradient(120% 120% at 85% 0%, rgba(255, 255, 255, .08), transparent 55%),
        var(--dk-band);
}

html[data-theme="dark"] .sh__mutil {
    background:
        url("../img/header-lines.595e4e9c7ea2.svg") repeat left top / auto 40px,
        var(--dk-band);
}

html[data-theme="dark"] .ft {
    background: var(--dk-foot);
    border-top: 1px solid var(--dk-line);
}

html[data-theme="dark"] .ft .ft-card::before { background: linear-gradient(90deg, #0096db, #0a5f8e); }

/* ---------- Media ---------- */

/* photos lose a little glare on the dark page */
html[data-theme="dark"] img:not([src$=".svg"]) { filter: brightness(.94); }

/* fewer, gentler: the icon swaps without moving */
@media (prefers-reduced-motion: reduce) {
    .tt__core, .tt__cut, .tt__rays, .tt__tip { transition: none; }
}

/* the home page's blue sections (Bootstrap's .bg-primary, set !important) */
html[data-theme="dark"] section.bg-primary {
    background-color: var(--dk-band-flat) !important;
    background-image: var(--dk-band);
}

/* partner logos are drawn for a white page: they keep a light tile */
html[data-theme="dark"] body .partners-list__item {
    background: #e8edf4;
    border-radius: 12px;
}

/* the header's floating cards stand a step above the page */
html[data-theme="dark"] :is(.sh-panel__card, .sh-search__form, .sh-util__drop),
html[data-theme="dark"] :is(.sh-panel__card, .sh-search__form)::before {
    background: var(--dk-raised);
}

html[data-theme="dark"] :is(.sh-panel__card, .sh-search__form, .sh-util__drop) {
    box-shadow: 0 0 0 1px var(--dk-line), 0 24px 60px -20px rgba(0, 0, 0, .7);
}

html[data-theme="dark"] :is(.sh-panel__card, .sh-search__form)::before { box-shadow: -1px -1px 0 var(--dk-line); }

/* ---------- Light on the dark page ---------- */

/* soft brand-blue light from the corners of the screen, drifting slowly; it sits under the header,
   the switch and the assistant, and never takes a click */
html[data-theme="dark"] body::after {
    content: "";
    position: fixed;
    inset: -15%;
    z-index: 1028;
    pointer-events: none;
    background:
        radial-gradient(38% 34% at 8% 10%, rgba(53, 175, 246, .16), transparent 70%),
        radial-gradient(34% 30% at 94% 22%, rgba(90, 140, 255, .11), transparent 70%),
        radial-gradient(40% 36% at 88% 92%, rgba(53, 175, 246, .14), transparent 70%),
        radial-gradient(30% 28% at 12% 85%, rgba(0, 200, 220, .08), transparent 70%);
    animation: dk-drift 40s ease-in-out infinite alternate;
}

@keyframes dk-drift {
    from { transform: translate3d(-2%, -1%, 0); }
    to { transform: translate3d(2%, 2%, 0); }
}

/* a line of light along the header's lower edge */
html[data-theme="dark"] .sh { border-bottom-color: transparent; }

html[data-theme="dark"] .sh::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(53, 175, 246, .6) 50%, transparent);
    box-shadow: 0 0 14px 1px rgba(53, 175, 246, .35);
}

/* the main buttons glow a little */
html[data-theme="dark"] :is(.sh__cta, .btn-primary, .ft-btn--primary, .hero-slider .hero-slide__btn--primary, .sh-search__form button) {
    box-shadow: 0 0 0 1px rgba(53, 175, 246, .25), 0 6px 22px -4px rgba(0, 150, 219, .55);
}

html[data-theme="dark"] :is(.sh__cta, .btn-primary, .ft-btn--primary, .hero-slider .hero-slide__btn--primary, .sh-search__form button):hover {
    box-shadow: 0 0 0 1px rgba(53, 175, 246, .4), 0 8px 30px -4px rgba(0, 150, 219, .75);
}

/* the footer card catches the light on its top edge */
html[data-theme="dark"] .ft .ft-card {
    box-shadow: 0 -8px 30px -12px rgba(53, 175, 246, .35), 0 16px 40px -16px rgba(0, 0, 0, .8);
}

/* the moon shines */
html[data-theme="dark"] .tt { box-shadow: 0 0 0 1px rgba(255, 209, 102, .08), 0 0 22px -4px rgba(255, 209, 102, .35); }
html[data-theme="dark"] .tt--float { box-shadow: 0 0 0 1px rgba(255, 209, 102, .1), 0 0 26px -2px rgba(255, 209, 102, .35), 0 10px 28px -10px rgba(0, 0, 0, .8); }
html[data-theme="dark"] .tt__icon { filter: drop-shadow(0 0 4px rgba(255, 209, 102, .6)); }

/* coloured lines give off a little light of their own colour */
html[data-theme="dark"] { --dk-glow: rgba(53, 175, 246, .55); }

/* the gradient bars on top of the cards; inside the card the light falls downwards */
html[data-theme="dark"] :is(.ab-card, .dt-area, .qa-area, .sdd-area, .sf-track, .pr-activity)::after,
html[data-theme="dark"] .ft .ft-card::before,
html[data-theme="dark"] .rankings__eyebrow::before {
    box-shadow: 0 1px 16px 1px var(--dk-glow);
}

html[data-theme="dark"] .sc-card::before { box-shadow: 1px 0 16px 1px var(--dk-glow); }

/* the active menu item's line */
html[data-theme="dark"] .sh__glide { box-shadow: 0 0 12px 1px var(--dk-glow); }

/* the faculties' own colours, lifted a little for the dark page */
html[data-theme="dark"] .bp-school::before {
    --dk-fac: color-mix(in oklab, var(--bp-faculty, #0096db) 72%, #fff);
    background: var(--dk-fac);
    box-shadow: 0 1px 18px 1px color-mix(in srgb, var(--dk-fac) 55%, transparent);
}

/* panels with a line on the left: the light spills from the line into the panel */
html[data-theme="dark"] :is(.ab-highlight, .ab-letter__quote, .ia-intake__card, .dt-mission, .pr-mission,
    .qa-mission, .sdd-mission, .sf-panel, .ssc-motto, .pr-priority, .about-info-bottom) {
    box-shadow: inset 12px 0 20px -14px var(--dk-glow), -3px 0 14px -6px var(--dk-glow);
}

/* and from a line on top */
html[data-theme="dark"] .ab-step { box-shadow: inset 0 12px 20px -14px var(--dk-glow), 0 -3px 14px -6px var(--dk-glow); }

@media (prefers-reduced-motion: reduce) {
    html[data-theme="dark"] body::after { animation: none; }
}
