/* =========================================================
   STUDYSPIDER STUDY NOTES
   W3SCHOOLS-STYLE DOCUMENTATION UI
   ========================================================= */

:root {
    --white: #ffffff;
    --sidebar-bg: #ffffff;
    --text: #111827;
    --text-light: #4b5563;
    --text-muted: #6b7280;

    --border: #e5e7eb;
    --border-light: #eeeeee;

    --orange: #c65d0a;
    --orange-light: #fff0e0;
    --orange-soft: rgba(198, 93, 10, 0.08);

    --green: #04aa6d;

    --header-height: 70px;
    --sidebar-width: 250px;
    --toc-width: 230px;
}


/* =========================================================
   RESET
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 85px;
    max-width: 100vw;
    overflow-x: clip;
}

body {
    margin: 0;
    background: #ffffff;
    color: var(--text);

    /*
       W3Schools-like font
    */
    font-family:
        "Segoe UI",
        Arial,
        Helvetica,
        sans-serif;

    font-size: 16px;
    line-height: 1.6;

    -webkit-font-smoothing: antialiased;
    max-width: 100vw;
    overflow-x: clip;
}

button,
input {
    font-family: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}


/* =========================================================
   HEADER
   ========================================================= */

.study-header {
    position: sticky;
    top: 0;
    z-index: 1000;

    height: var(--header-height);

    background: #ffffff;

    border-bottom: 1px solid #e5e7eb;
}


.header-inner {
    width: 100%;
    height: 100%;

    padding: 0 24px;

    display: flex;
    align-items: center;

    gap: 20px;
}


/* =========================================================
   BRAND
   ========================================================= */

.brand {
    flex-shrink: 0;

    color: var(--orange);

    text-decoration: none;

    font-size: 1.45rem;
    font-weight: 700;

    letter-spacing: -0.5px;
}

.brand:hover {
    color: #a94e08;
}


/* =========================================================
   HEADER SEARCH
   ========================================================= */

.header-search {
    position: relative;

    width: 380px;

    margin-left: auto;
}

.search-icon {
    position: absolute;

    left: 13px;
    top: 50%;

    transform: translateY(-50%);

    color: #666;

    font-size: 18px;

    pointer-events: none;
}

.search {
    width: 100%;

    height: 40px;

    padding: 8px 12px 8px 38px;

    border: 1px solid #cccccc;

    border-radius: 22px;

    background: #ffffff;

    color: #111827;

    outline: none;

    font-size: 15px;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.search::placeholder {
    color: #777;
}

.search:hover {
    border-color: #999;
}

.search:focus {
    border-color: var(--orange);

    box-shadow:
        0 0 0 2px rgba(198, 93, 10, 0.10);
}


/* =========================================================
   MOBILE MENU
   ========================================================= */

.icon-button {
    display: none;

    width: 40px;
    height: 40px;

    border: 1px solid #dddddd;
    border-radius: 5px;

    background: #ffffff;

    color: #111827;

    cursor: pointer;
}

.icon-button:hover {
    background: #f5f5f5;
}


/* =========================================================
   MAIN LAYOUT
   ========================================================= */

.study-layout {
    width: 100%;

    display: grid;

    /*
       IMPORTANT:
       No empty middle gap.
       Main column gets ALL remaining width.
    */

    grid-template-columns:
        var(--sidebar-width) minmax(0, 1fr) var(--toc-width);

    min-height:
        calc(100vh - var(--header-height));

    background: #ffffff;
}


/* =========================================================
   LEFT SIDEBAR
   ========================================================= */

.study-sidebar {
    position: sticky;

    top: var(--header-height);

    height:
        calc(100vh - var(--header-height));

    overflow-y: auto;

    background: #ffffff;

    border-right:
        1px solid #dddddd;

    padding-bottom: 30px;

    scrollbar-width: thin;
}


/* =========================================================
   SIDEBAR SCROLLBAR
   ========================================================= */

.study-sidebar::-webkit-scrollbar {
    width: 6px;
}

.study-sidebar::-webkit-scrollbar-track {
    background: #ffffff;
}

.study-sidebar::-webkit-scrollbar-thumb {
    background: #cccccc;
}

.study-sidebar::-webkit-scrollbar-thumb:hover {
    background: #aaaaaa;
}


/* =========================================================
   SIDEBAR TOP
   ========================================================= */

.sidebar-top {
    position: sticky;

    top: 0;

    z-index: 5;

    height: 55px;

    padding: 0 15px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    background: #ffffff;

    border-bottom:
        1px solid #eeeeee;
}


.sidebar-heading {
    color: #555555;

    font-size: 13px;

    font-weight: 700;

    letter-spacing: 0.6px;

    text-transform: uppercase;
}


.sidebar-close {
    display: none;

    border: 0;

    background: transparent;

    font-size: 24px;

    cursor: pointer;
}


/* =========================================================
   SIDEBAR NAV
   ========================================================= */

.sidebar-nav {
    padding: 8px 0 25px;
}


/* =========================================================
   STREAM TITLE
   ========================================================= */

.sidebar-stream-title {
    padding:
        14px 16px 7px;

    color: #777777;

    font-size: 12px;

    font-weight: 700;

    text-transform: uppercase;

    letter-spacing: 0.7px;
}


/* =========================================================
   SUBJECT GROUP
   ========================================================= */

.sidebar-group {
    margin: 0;
}


/* =========================================================
   SUBJECT BUTTON
   ========================================================= */

.sidebar-group-button {
    width: 100%;

    min-height: 42px;

    padding:
        9px 15px;

    display: flex;

    align-items: center;

    gap: 7px;

    border: 0;

    border-left:
        3px solid transparent;

    background: #ffffff;

    color: #222222;

    text-align: left;

    cursor: pointer;

    font-size: 15px;

    font-weight: 500;

    line-height: 1.4;

    transition:
        background 0.12s ease,
        color 0.12s ease;
}


.sidebar-group-button:hover {
    background: #f5f5f5;

    color: #111111;
}


/* =========================================================
   OPEN SUBJECT
   ========================================================= */

.sidebar-group-button.open {
    color: var(--orange);

    background:
        #fff7ef;

    font-weight: 600;

    border-left-color:
        var(--orange);
}


/* =========================================================
   ARROW
   ========================================================= */

.sidebar-arrow {
    width: 16px;

    flex: 0 0 16px;

    color: #777777;

    font-size: 12px;

    transition:
        transform 0.15s ease;
}


.sidebar-group-button.open .sidebar-arrow {
    color: var(--orange);

    transform:
        rotate(90deg);
}


/* =========================================================
   SUBJECT NAME
   ========================================================= */

.sidebar-group-name {
    min-width: 0;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}


/* =========================================================
   TOPICS
   ========================================================= */

.sidebar-topics {
    padding:
        2px 0 5px 18px;

    border-left:
        1px solid #eeeeee;

    margin-left:
        17px;

    animation:
        topicOpen 0.15s ease;
}


@keyframes topicOpen {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


/* =========================================================
   TOPIC BUTTON
   ========================================================= */

.sidebar-link {
    position: relative;

    width: 100%;

    min-height: 37px;

    padding:
        8px 12px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    border: 0;

    border-left:
        3px solid transparent;

    background: #ffffff;

    color: #444444;

    text-align: left;

    cursor: pointer;

    font-size: 14px;

    font-weight: 400;

    line-height: 1.4;

    transition:
        background 0.12s ease,
        color 0.12s ease;
}


.sidebar-link:hover {
    background:
        #f5f5f5;

    color:
        #111111;
}


/* =========================================================
   ACTIVE TOPIC
   ========================================================= */

.sidebar-link.active {
    background:
        #fff0e0;

    color:
        var(--orange);

    border-left-color:
        var(--orange);

    font-weight:
        600;
}


/* =========================================================
   TOPIC TIME
   ========================================================= */

.topic-time {
    flex-shrink: 0;

    margin-left: 7px;

    color: #999999;

    font-size: 11px;
}


/* =========================================================
   MAIN ARTICLE AREA
   ========================================================= */

.study-main {
    min-width: 0;

    /*
       NO MAX-WIDTH HERE
       NO CENTERING
       NO EMPTY SIDE SPACE
    */

    padding:
        24px 32px 60px;

    background:
        #ffffff;
}


/* =========================================================
   BREADCRUMB
   ========================================================= */

.breadcrumbs {
    width: 100%;

    margin:
        0 0 15px;

    display: flex;

    align-items: center;

    gap: 7px;

    color: #777777;

    font-size: 14px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


.breadcrumbs span {
    overflow: hidden;

    text-overflow: ellipsis;
}


.breadcrumbs span:first-child {
    color: var(--orange);

    font-weight: 600;
}


/* =========================================================
   ARTICLE TOOLBAR
   ========================================================= */

.article-toolbar {
    width: 100%;

    margin-bottom: 8px;

    display: flex;

    align-items: center;

    justify-content: space-between;
}


.article-subject {
    display: inline-block;

    padding:
        4px 8px;

    background:
        #f1f1f1;

    border-radius:
        3px;

    color:
        #555555;

    font-size:
        12px;

    font-weight:
        600;

    text-transform:
        uppercase;
}


/* =========================================================
   ARTICLE
   ========================================================= */

.article {

    /*
       THIS IS THE IMPORTANT CHANGE.

       Earlier:
       max-width: 920px;
       margin: auto;

       That created empty space.

       Now article uses entire middle column.
    */

    width: 100%;

    max-width: none;

    margin: 0;

    padding:
        18px 0 55px;

    background:
        #ffffff;

    border: 0;

    border-radius: 0;

    box-shadow: none;
}


/* =========================================================
   ARTICLE H1
   ========================================================= */

.article h1 {
    margin:
        0 0 20px;

    color:
        #111111;

    font-size:
        clamp(2rem, 3vw, 3rem);

    font-weight:
        400;

    line-height:
        1.2;

    letter-spacing:
        -0.5px;
}


/* =========================================================
   ARTICLE H2
   ========================================================= */

.article h2 {
    margin:
        42px 0 15px;

    padding:
        0 0 10px;

    color:
        #111111;

    font-size:
        28px;

    font-weight:
        600;

    line-height:
        1.3;

    border-bottom:
        1px solid #eeeeee;
}


.article h2::after {
    display: none;
}


/* =========================================================
   ARTICLE H3
   ========================================================= */

.article h3 {
    margin:
        30px 0 12px;

    color:
        #222222;

    font-size:
        22px;

    font-weight:
        600;

    line-height:
        1.35;
}


/* =========================================================
   ARTICLE H4
   ========================================================= */

.article h4 {
    margin:
        24px 0 10px;

    color:
        #222222;

    font-size:
        18px;

    font-weight:
        600;
}


/* =========================================================
   PARAGRAPH
   ========================================================= */

.article p {
    margin:
        0 0 18px;

    color:
        #222222;

    font-size:
        16px;

    line-height:
        1.75;

    text-align: justify;
}


/* =========================================================
   LISTS
   ========================================================= */

.article ul,
.article ol {
    margin:
        0 0 20px;

    padding-left:
        28px;
}


.article li {
    margin-bottom:
        7px;

    color:
        #222222;

    font-size:
        16px;

    line-height:
        1.7;

    text-align: justify;
}


/* =========================================================
   STRONG
   ========================================================= */

.article strong {
    color:
        #111111;

    font-weight:
        700;
}


/* =========================================================
   ARTICLE LINKS
   ========================================================= */

.article a {
    color:
        #0563c1;

    text-decoration:
        underline;

    border: 0;
}


.article a:hover {
    color:
        #003d80;
}


/* =========================================================
   NOTE / BLOCKQUOTE
   ========================================================= */

.article blockquote {
    margin:
        25px 0;

    padding:
        16px 20px;

    background:
        #fff9f2;

    border-left:
        4px solid var(--orange);

    color:
        #444444;
}


.article blockquote p:last-child {
    margin-bottom:
        0;
}


/* =========================================================
   INLINE CODE
   ========================================================= */

.article code {
    padding:
        2px 6px;

    border-radius:
        3px;

    background:
        #f4f4f4;

    color:
        #c7254e;

    font-family:
        Consolas,
        "Courier New",
        monospace;

    font-size:
        14px;
}


/* =========================================================
   CODE BLOCK
   ========================================================= */

.article pre {
    margin:
        25px 0;

    padding:
        18px;

    overflow-x:
        auto;

    background:
        #282a35;

    color:
        #ffffff;

    border-radius:
        4px;

    line-height:
        1.6;
}


.article pre code {
    padding:
        0;

    background:
        transparent;

    color:
        inherit;

    font-size:
        14px;
}


/* =========================================================
   TABLE
   ========================================================= */

.article table {
    width:
        100%;

    margin:
        25px 0;

    border-collapse:
        collapse;

    background:
        #ffffff;

    border:
        1px solid #dddddd;
}


.article th,
.article td {
    padding:
        11px 13px;

    border:
        1px solid #dddddd;

    text-align:
        left;

    color:
        #222222;
}


.article th {
    background:
        #f1f1f1;

    color:
        #111111;

    font-weight:
        600;
}


/* =========================================================
   IMAGES
   ========================================================= */

.article img {
    display:
        block;

    max-width:
        100%;

    height:
        auto;

    margin:
        25px auto;

    border:
        1px solid #dddddd;

    border-radius:
        4px;
}


/* =========================================================
   HR
   ========================================================= */

.article hr {
    height:
        1px;

    margin:
        35px 0;

    border:
        0;

    background:
        #dddddd;
}


/* =========================================================
   RIGHT TOC
   ========================================================= */

.study-toc {
    position:
        sticky;

    top:
        var(--header-height);

    height:
        calc(100vh - var(--header-height));

    overflow-y:
        auto;

    padding:
        28px 18px;

    background:
        #ffffff;

    border-left:
        1px solid #dddddd;

    scrollbar-width:
        thin;
}


.study-toc::-webkit-scrollbar {
    width:
        5px;
}

.study-toc::-webkit-scrollbar-thumb {
    background:
        #cccccc;
}


/* =========================================================
   TOC HEADING
   ========================================================= */

.toc-heading {
    margin-bottom:
        14px;

    color:
        #555555;

    font-size:
        13px;

    font-weight:
        700;

    letter-spacing:
        0.5px;
}


/* =========================================================
   TOC LINKS
   ========================================================= */

#toc a {
    display:
        block;

    padding:
        5px 0;

    color:
        #555555;

    font-size:
        14px;

    line-height:
        1.45;

    text-decoration:
        none;

    border: 0;
}


#toc a:hover {
    color:
        var(--orange);
}


#toc .toc-h3 {
    padding-left:
        13px;

    color:
        #777777;

    font-size:
        13px;
}


/* =========================================================
   READING PROGRESS
   ========================================================= */

.reading-progress {
    margin-top:
        25px;

    padding:
        14px;

    border:
        1px solid #dddddd;

    background:
        #ffffff;
}


.progress-header {
    display:
        flex;

    justify-content:
        space-between;

    margin-bottom:
        8px;

    color:
        #555555;

    font-size:
        12px;
}


.progress-header strong {
    color:
        var(--orange);
}


.progress-bar {
    width:
        100%;

    height:
        5px;

    margin-bottom:
        12px;

    background:
        #e5e5e5;

    overflow:
        hidden;
}


.progress-fill {
    height:
        100%;

    background:
        var(--orange);

    transition:
        width 0.2s ease;
}


.complete-button {
    width:
        100%;

    padding:
        8px;

    border:
        1px solid #cccccc;

    background:
        #ffffff;

    color:
        #333333;

    font-size:
        12px;

    cursor:
        pointer;
}


.complete-button:hover {
    background:
        #f5f5f5;
}


.complete-button.completed {
    color:
        var(--orange);

    border-color:
        var(--orange);

    background:
        #fff7ef;
}


/* =========================================================
   PREVIOUS / NEXT
   ========================================================= */

.article-navigation {
    width:
        100%;

    margin:
        0;

    display:
        grid;

    grid-template-columns:
        1fr 1fr;

    gap:
        15px;
}


.nav-card {
    min-height:
        78px;

    padding:
        15px 18px;

    border:
        1px solid #dddddd;

    background:
        #ffffff;

    color:
        #333333;

    text-align:
        left;

    cursor:
        pointer;
}


.nav-card:hover:not(:disabled) {
    background:
        #f5f5f5;

    border-color:
        #bbbbbb;
}


.nav-card:disabled {
    opacity:
        0.45;

    cursor:
        not-allowed;
}


.nav-label {
    display:
        block;

    margin-bottom:
        4px;

    color:
        #777777;

    font-size:
        12px;
}


.nav-card strong {
    display:
        block;

    overflow:
        hidden;

    color:
        #222222;

    font-size:
        15px;

    font-weight:
        600;

    text-overflow:
        ellipsis;

    white-space:
        nowrap;
}


/* =========================================================
   EMPTY / LOADING / ERROR
   ========================================================= */

.article-empty,
.article-loading,
.article-error {
    padding:
        80px 20px;

    text-align:
        center;
}


.empty-icon,
.error-icon {
    font-size:
        40px;

    margin-bottom:
        12px;
}


/* =========================================================
   FOCUS MODE
   ========================================================= */

body.focus-mode .study-sidebar,
body.focus-mode .study-toc {
    display:
        none;
}


body.focus-mode .study-layout {
    display:
        block;
}


body.focus-mode .study-main {
    width:
        100%;

    padding-left:
        8%;

    padding-right:
        8%;
}


/* =========================================================
   MOBILE OVERLAY
   ========================================================= */

.sidebar-overlay {
    display:
        none;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1100px) {

    .study-layout {
        grid-template-columns:
            240px minmax(0, 1fr);
    }

    .study-toc {
        display:
            none;
    }

    .study-main {
        padding-left:
            28px;

        padding-right:
            28px;
    }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 720px) {

    :root {
        --header-height: 64px;
    }


    /* Header */

    .header-inner {
        padding:
            0 12px;

        gap:
            10px;
    }


    .icon-button {
        display:
            inline-flex;

        align-items:
            center;

        justify-content:
            center;
    }


    .brand {
        font-size:
            1.15rem;
    }


    .header-search {
        flex:
            1;

        width:
            auto;
    }


    .search {
        height:
            38px;

        font-size:
            14px;
    }


    /* Layout */

    .study-layout {
        display:
            block;
    }


    /* Sidebar */

    .study-sidebar {
        position:
            fixed;

        top:
            64px;

        left:
            0;

        z-index:
            900;

        width:
            min(310px, 88vw);

        height:
            calc(100vh - 64px);

        transform:
            translateX(-105%);

        transition:
            transform 0.25s ease;

        box-shadow:
            5px 0 25px rgba(0, 0, 0, 0.12);
    }


    .study-sidebar.open {
        transform:
            translateX(0);
    }


    .sidebar-close {
        display:
            block;
    }


    /* Overlay */

    .sidebar-overlay {
        position:
            fixed;

        inset:
            64px 0 0 0;

        z-index:
            850;

        display:
            block;

        background:
            rgba(0, 0, 0, 0.25);

        opacity:
            0;

        visibility:
            hidden;

        pointer-events:
            none;

        transition:
            opacity 0.25s ease;
    }


    .sidebar-overlay.open {
        opacity:
            1;

        visibility:
            visible;

        pointer-events:
            auto;
    }


    /* Main */

    .study-main {
        padding:
            20px 16px 45px;
    }


    .article h1 {
        font-size:
            2rem;
    }


    .article h2 {
        font-size:
            24px;
    }


    .article h3 {
        font-size:
            20px;
    }


    .article p,
    .article li {
        font-size:
            16px;
    }


    .article-navigation {
        grid-template-columns:
            1fr;
    }


    .article table {
        display:
            block;

        overflow-x:
            auto;
    }
}


/* =========================================================
   ACCESSIBILITY
   ========================================================= */

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline:
        2px solid rgba(198, 93, 10, 0.35);

    outline-offset:
        2px;
}

/* =========================================================
   MATHJAX OVERFLOW FIX FOR MOBILE
   ========================================================= */

mjx-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: normal !important;
}

mjx-container[display="true"] {
    display: block !important;
    overflow-x: auto !important;
}

mjx-container>svg {
    max-width: 100%;
    height: auto;
}