/* =========================================================
   Discrete English
   ========================================================= */

:root {
    --header-height: 64px;

    --sidebar-width: 250px;
    --toc-width: 220px;

    --content-max-width: 850px;

    --bg: #ffffff;
    --bg-secondary: #f6f7f9;
    --bg-sidebar: #f8f9fb;
    --bg-code: #f1f3f5;

    --text: #24292f;
    --text-secondary: #57606a;
    --text-muted: #6e7781;

    --border: #d8dee4;

    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-soft: #f3e8ff;

    --success: #15803d;
    --warning: #b45309;
    --danger: #dc2626;
}


/* =========================================================
   Dark Mode
   ========================================================= */

body.dark {
    --bg: #111113;
    --bg-secondary: #1a1a1e;
    --bg-sidebar: #151518;
    --bg-code: #1d1d21;

    --text: #eeeeef;
    --text-secondary: #b5b5bc;
    --text-muted: #85858e;

    --border: #303036;

    --accent: #a78bfa;
    --accent-hover: #c4b5fd;
    --accent-soft: #29213d;

    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
}


/* =========================================================
   Reset
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    margin: 0;

    min-width: 0;
    width: 100%;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    font-size: 16px;
    line-height: 1.7;

    overflow-x: hidden;

    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}


/* =========================================================
   Links
   ========================================================= */

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}


/* =========================================================
   Top Bar
   ========================================================= */

.topbar {
    position: fixed;

    top: 0;
    left: 0;
    right: 0;

    height: var(--header-height);

    background: rgba(17, 17, 19, 0.92);

    border-bottom: 1px solid var(--border);

    backdrop-filter: blur(12px);

    z-index: 1000;
}

body:not(.dark) .topbar {
    background: rgba(255, 255, 255, 0.92);
}


.topbar-inner {
    width: 100%;
    height: 100%;

    display: flex;
    align-items: center;

    padding: 0 24px;
}


/* =========================================================
   Brand
   ========================================================= */

.brand {
    display: flex;
    align-items: center;
    gap: 10px;

    min-width: var(--sidebar-width);

    color: var(--text);

    font-size: 17px;
    font-weight: 700;

    white-space: nowrap;
}

.brand:hover {
    color: var(--text);
}


.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 30px;
    height: 30px;

    background: var(--accent);
    color: white;

    border-radius: 7px;

    font-size: 15px;
    font-weight: 800;
}


/* =========================================================
   Top Navigation
   ========================================================= */

.top-nav {
    display: flex;
    align-items: center;

    gap: 24px;

    margin-left: auto;
}

.top-nav a {
    color: var(--text-secondary);

    font-size: 14px;
    font-weight: 500;
}

.top-nav a:hover {
    color: var(--text);
}

.top-nav a.active {
    color: var(--accent);
}


/* =========================================================
   Theme Button
   ========================================================= */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 36px;
    height: 36px;

    margin-left: 20px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: var(--bg-secondary);
    color: var(--text);

    cursor: pointer;

    font-size: 16px;

    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--accent);
}


/* =========================================================
   Main Layout
   ========================================================= */

.layout {
    display: grid;

    grid-template-columns:
        var(--sidebar-width)
        minmax(0, 1fr);

    min-height: 100vh;

    padding-top: var(--header-height);
}


/* =========================================================
   Sidebar
   ========================================================= */

.sidebar {
    position: sticky;

    top: var(--header-height);

    height: calc(100vh - var(--header-height));

    overflow-y: auto;

    padding: 32px 18px;

    background: var(--bg-sidebar);

    border-right: 1px solid var(--border);
}


.sidebar-section {
    margin-bottom: 28px;
}


.sidebar-title {
    margin-bottom: 9px;

    padding: 0 10px;

    color: var(--text-muted);

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.08em;
}


.sidebar-link {
    display: block;

    padding: 8px 10px;

    margin: 2px 0;

    border-radius: 6px;

    color: var(--text-secondary);

    font-size: 14px;
}


.sidebar-link:hover {
    background: var(--bg-secondary);

    color: var(--text);
}


.sidebar-link.selected {
    background: var(--accent-soft);

    color: var(--accent);

    font-weight: 600;
}


/* =========================================================
   Content Area
   ========================================================= */

.content {
    position: relative;

    display: grid;

    grid-template-columns:
        minmax(0, var(--content-max-width))
        var(--toc-width);

    justify-content: center;

    column-gap: 48px;

    width: 100%;
    max-width: 1280px;

    margin: 0 auto;

    padding: 48px 32px 80px;
}


/* =========================================================
   Article
   ========================================================= */

.content article {
    min-width: 0;
    width: 100%;
}


/* =========================================================
   Breadcrumb
   ========================================================= */

.breadcrumb {
    margin-bottom: 28px;

    color: var(--text-muted);

    font-size: 13px;
}

.breadcrumb span {
    margin: 0 8px;
}


/* =========================================================
   Headings
   ========================================================= */

h1,
h2,
h3 {
    color: var(--text);

    line-height: 1.25;
}

h1 {
    margin: 0 0 16px;

    font-size: clamp(2rem, 4vw, 2.75rem);

    font-weight: 800;

    letter-spacing: -0.035em;
}

h2 {
    margin-top: 52px;
    margin-bottom: 18px;

    font-size: 1.65rem;

    letter-spacing: -0.02em;
}

h3 {
    margin: 0 0 8px;

    font-size: 1.05rem;
}

p {
    margin: 0 0 18px;
}


/* =========================================================
   Lead
   ========================================================= */

.lead {
    max-width: 700px;

    margin-bottom: 36px;

    color: var(--text-secondary);

    font-size: 1.15rem;
    line-height: 1.7;
}


/* =========================================================
   Horizontal Rule
   ========================================================= */

hr {
    height: 1px;

    margin: 36px 0;

    border: 0;

    background: var(--border);
}


/* =========================================================
   Callouts
   ========================================================= */

.callout {
    display: flex;

    gap: 14px;

    margin: 28px 0;

    padding: 18px 20px;

    background: var(--accent-soft);

    border-left: 4px solid var(--accent);

    border-radius: 7px;
}

.callout-icon {
    flex-shrink: 0;

    font-size: 20px;
}

.callout strong {
    color: var(--accent);
}

.callout p {
    margin-top: 7px;
    margin-bottom: 0;
}

.joke-ending {
    color: var(--text-muted);

    font-style: italic;
}

.secondary-joke {
    opacity: 0.9;
}


/* =========================================================
   Documentation Cards
   ========================================================= */

.cards {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 16px;

    margin-top: 28px;
}


.card {
    position: relative;

    display: block;

    min-width: 0;

    padding: 20px;

    background: var(--bg-secondary);

    border: 1px solid var(--border);
    border-radius: 10px;

    color: var(--text);

    transition:
        border-color 0.15s ease,
        transform 0.15s ease,
        background-color 0.15s ease;
}


.card:hover {
    border-color: var(--accent);

    background: var(--bg-code);

    color: var(--text);

    transform: translateY(-2px);
}


.card-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;

    margin-bottom: 16px;

    background: var(--accent-soft);

    border-radius: 7px;

    color: var(--accent);

    font-weight: 700;
}


.card p {
    margin: 0;

    color: var(--text-secondary);

    font-size: 14px;

    line-height: 1.55;
}


.card-arrow {
    display: block;

    margin-top: 18px;

    color: var(--accent);

    font-size: 18px;
}


/* =========================================================
   Table of Contents
   ========================================================= */

.toc {
    position: sticky;

    top: calc(var(--header-height) + 48px);

    align-self: start;

    padding-top: 34px;

    min-width: 0;
}


.toc-title {
    margin-bottom: 12px;

    color: var(--text-muted);

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.08em;
}


.toc a {
    display: block;

    margin-bottom: 8px;

    color: var(--text-muted);

    font-size: 13px;

    line-height: 1.45;
}


.toc a:hover {
    color: var(--accent);
}


/* =========================================================
   Footer
   ========================================================= */

footer {
    border-top: 1px solid var(--border);

    background: var(--bg-sidebar);
}


.footer-inner {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 20px;

    width: 100%;

    padding: 24px 32px;

    color: var(--text-muted);

    font-size: 13px;
}


.footer-inner strong {
    margin-right: 8px;

    color: var(--text);
}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 1100px) {

    :root {
        --toc-width: 190px;
    }

    .content {
        column-gap: 28px;

        padding-left: 24px;
        padding-right: 24px;
    }

    .cards {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 850px) {

    .layout {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    .brand {
        min-width: 210px;
    }

    .content {
        display: block;

        max-width: 900px;

        padding: 40px 28px 70px;
    }

    .toc {
        display: none;
    }

}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 650px) {

    :root {
        --header-height: 58px;
    }


    .topbar-inner {
        padding: 0 14px;
    }


    .brand {
        min-width: 0;

        font-size: 15px;
    }


    .brand-mark {
        width: 28px;
        height: 28px;
    }


    .top-nav {
        display: none;
    }


    .theme-toggle {
        margin-left: auto;
    }


    .layout {
        display: block;
    }


    .sidebar {
        position: static;

        height: auto;

        padding: 16px 14px;

        border-right: none;
        border-bottom: 1px solid var(--border);
    }


    .sidebar-section {
        margin-bottom: 14px;
    }


    .sidebar-title {
        margin-bottom: 5px;
    }


    .sidebar-link {
        display: inline-block;

        margin: 2px 2px 2px 0;

        padding: 6px 9px;
    }


    .content {
        padding: 32px 18px 56px;
    }


    h1 {
        font-size: 2rem;
    }


    h2 {
        margin-top: 40px;

        font-size: 1.45rem;
    }


    .lead {
        font-size: 1.05rem;
    }


    .cards {
        grid-template-columns: 1fr;
    }


    .callout {
        padding: 16px;
    }


    .footer-inner {
        flex-direction: column;

        align-items: flex-start;

        padding: 22px 18px;
    }

}

/* =========================================================
   Source Attribution
   ========================================================= */

.source-note {
    margin-bottom: 28px;
    padding: 14px 16px;

    background: var(--bg-secondary);

    border: 1px solid var(--border);
    border-radius: 7px;

    color: var(--text-secondary);

    font-size: 13px;
    line-height: 1.6;
}

.source-note strong {
    color: var(--text);
}

.source-note a {
    font-weight: 500;
}


/* =========================================================
   Next Page
   ========================================================= */

.next-page {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-top: 60px;
    padding-top: 28px;

    border-top: 1px solid var(--border);
}

.next-page > div {
    display: flex;
    flex-direction: column;
}

.next-page span {
    color: var(--text-muted);

    font-size: 12px;
}

.next-page strong {
    color: var(--text);

    font-size: 15px;
}

.next-page a {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;

    border: 1px solid var(--border);
    border-radius: 8px;

    color: var(--accent);

    font-size: 20px;
}

.next-page a:hover {
    border-color: var(--accent);

    background: var(--accent-soft);
}


/* =========================================================
   Small Phones
   ========================================================= */

@media (max-width: 400px) {

    .content {
        padding-left: 14px;
        padding-right: 14px;
    }


    h1 {
        font-size: 1.75rem;
    }


    .brand span:last-child {
        overflow: hidden;

        text-overflow: ellipsis;
    }

}