@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #2a3554 var(--inst-ink);
}

body {
    margin: 0;
    padding-top: var(--nav-h);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-base);
    color: var(--text-primary);
    background: var(--bg);
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, li {
    overflow-wrap: break-word;
}

img {
    max-width: 100%;
    height: auto;
}

::selection {
    background: rgba(91, 124, 255, 0.35);
    color: #fff;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--inst-ink);
}

::-webkit-scrollbar-thumb {
    background: #232c4a;
    border: 2px solid var(--inst-ink);
    border-radius: var(--radius-pill);
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--inst-blue-600);
    }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}

a:focus-visible, button:focus-visible {
    border-radius: 4px;
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1003;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 16px var(--section-pad-x);
    background: var(--bg);
    border-bottom: 1px solid #222;
    transition: background 0.25s ease, border-color 0.25s ease;
}

    .navbar.scrolled {
        background: rgba(11, 15, 26, 0.85);
        backdrop-filter: blur(10px);
        border-bottom-color: #333;
    }

.logo {
    font-weight: 700;
}

.logo-block {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
}

.logo a {
    text-decoration: none;
    color: var(--text-primary);
}

/*
 * Brand mark pair: the dark-theme asset and the light-theme asset
 * (logo-black.svg). Visibility is driven purely by the theme attribute
 * on <html>, so the swap happens before first paint and without JS.
 * Specificity (0,2,1) keeps the rule authoritative inside the footer,
 * where .ft-logo img also targets the images.
 */
.logo-mark {
    display: block;
    height: 36px;
    width: auto;
}

html:not([data-theme="light"]) .logo-mark--light,
html[data-theme="light"] .logo-mark--dark {
    display: none;
}

.navbar nav {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

    .navbar nav a {
        margin: 0;
        padding: 8px 12px;
        white-space: nowrap;
        text-decoration: none;
        font-size: var(--text-sm);
        font-weight: 500;
        color: var(--text-muted);
        border-radius: var(--radius-sm);
        transition: color 0.2s ease, background 0.2s ease;
    }

        .navbar nav a:hover {
            color: var(--text-primary);
            background: rgba(255, 255, 255, 0.04);
        }

        .navbar nav a.is-current {
            color: var(--text-primary);
            background: rgba(91, 124, 255, 0.1);
            box-shadow: inset 0 -2px 0 var(--brand);
        }

/*
 * Theme switch: borderless segmented pill, last item of the primary nav.
 * The thumb rests on the active mode; the covered icon turns white,
 * the idle icon stays faint. No borders by design decision.
 */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex: none;
    margin-left: 6px;
    padding: 6px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

    .theme-toggle:hover {
        color: var(--text-primary);
    }

        .theme-toggle:hover .theme-toggle__track {
            background: var(--overlay);
        }

.theme-toggle__track {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    flex: none;
    width: 58px;
    height: 30px;
    padding: 0 7px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    transition: background 0.2s ease;
}

.theme-toggle__icon {
    position: relative;
    z-index: 1;
    width: 15px;
    height: 15px;
    color: var(--text-faint);
    transition: color 0.25s ease;
}

.theme-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--grad-brand);
    box-shadow: 0 2px 8px rgba(91, 124, 255, 0.35);
    transform: translateX(28px);
    transition: transform 0.3s var(--ease-out);
}

.theme-toggle__icon--moon {
    color: #fff;
}

.theme-toggle__state {
    display: none;
    color: var(--text-primary);
}

.burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    z-index: 1001;
    padding: 8px;
}

    .burger span {
        width: 25px;
        height: 3px;
        background: var(--text-primary);
        border-radius: 2px;
        transition: 0.3s;
    }

    .burger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 6px);
    }

    .burger.active span:nth-child(2) {
        opacity: 0;
    }

    .burger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -7px);
    }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    z-index: 1000;
}

    .overlay.active {
        opacity: 1;
        pointer-events: all;
    }

.primary, .secondary {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.25s var(--ease-out), box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.primary {
    border: none;
    background: linear-gradient(135deg, #5b7cff 0%, #7a94ff 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(91, 124, 255, 0.25);
}

    .primary::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.5s ease;
    }

    .primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 26px rgba(91, 124, 255, 0.38);
    }

        .primary:hover::before {
            left: 100%;
        }

    .primary:active {
        transform: translateY(-1px);
    }

.secondary {
    background: transparent;
    border: 1px solid rgba(91, 124, 255, 0.6);
    color: #fff;
}

    .secondary:hover {
        transform: translateY(-2px);
        border-color: var(--brand);
        background: rgba(91, 124, 255, 0.1);
    }

    .primary span, .secondary span {
        position: relative;
        z-index: 1;
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .primary svg, .secondary svg {
        width: 18px;
        height: 18px;
        transition: transform 0.3s ease;
    }

    .primary:hover svg, .secondary:hover svg {
        transform: translateX(4px);
    }

/*
 * LIGHT THEME LAYER. Additive overrides only; the dark theme stays default.
 */
html[data-theme="light"] {
    scrollbar-color: #cbd5e1 #f4f6fa;
}

[data-theme="light"] ::selection {
    background: rgba(91, 124, 255, 0.2);
    color: #0f172a;
}

[data-theme="light"] ::-webkit-scrollbar-track {
    background: var(--bg);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-color: var(--bg);
}

    [data-theme="light"] ::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

[data-theme="light"] .navbar {
    border-bottom-color: var(--line);
}

    [data-theme="light"] .navbar.scrolled {
        background: rgba(255, 255, 255, 0.85);
        border-bottom-color: var(--line);
    }

    [data-theme="light"] .navbar nav a:hover {
        background: rgba(15, 23, 42, 0.04);
    }

    [data-theme="light"] .navbar nav a {
        border-bottom-color: var(--line);
    }

[data-theme="light"] .theme-toggle__thumb {
    transform: translateX(0);
}

[data-theme="light"] .theme-toggle__icon--sun {
    color: #fff;
}

[data-theme="light"] .theme-toggle__icon--moon {
    color: var(--text-faint);
}

[data-theme="light"] .overlay {
    background: rgba(15, 23, 42, 0.3);
}

[data-theme="light"] .primary {
    box-shadow: 0 4px 14px rgba(91, 124, 255, 0.18);
}

[data-theme="light"] .secondary {
    border-color: rgba(91, 124, 255, 0.4);
    color: var(--text-primary);
}

    [data-theme="light"] .secondary:hover {
        background: rgba(91, 124, 255, 0.08);
    }

@media (max-width: 900px) {
    .navbar {
        padding: 12px 20px;
    }

    .burger {
        display: flex;
    }

    .logo-mark {
        height: 30px;
    }

    .navbar nav {
        position: fixed;
        top: 0;
        right: -100%;
        height: 100vh;
        height: 100dvh;
        width: min(300px, 84vw);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding-top: 96px;
        background: var(--bg);
        border-left: 1px solid var(--line);
        transition: right 0.3s ease;
        z-index: 1002;
        overflow-y: auto;
    }

        .navbar nav.active {
            right: 0;
        }

        .navbar nav a {
            padding: 16px 24px;
            font-size: var(--text-base);
            border-bottom: 1px solid #1c2338;
            border-radius: 0;
        }

            .navbar nav a.is-current {
                box-shadow: inset 2px 0 0 var(--brand);
            }

    /* The switch becomes a full-width row at the end of the drawer. */
    .theme-toggle {
        width: 100%;
        flex-direction: row-reverse;
        justify-content: space-between;
        margin: 16px 0 0;
        padding: 16px 24px;
        border-radius: 0;
    }

    .theme-toggle__state {
        display: block;
    }
}

@media (max-width: 768px) {
    .primary, .secondary {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .primary, .secondary, .navbar, .burger span, .overlay, .navbar nav {
        transition: none !important;
    }

    .theme-toggle, .theme-toggle__track, .theme-toggle__thumb, .theme-toggle__icon {
        transition: none !important;
    }

    .primary::before {
        display: none;
    }

    .primary:hover, .secondary:hover {
        transform: none;
    }
}
