/* ============================================
   Custom Styles for Crypto CJ Blog
   ============================================ */

/* ---- Heading Styles ---- */

.single .content > h2 > .header-mark::before,
.single .content > h3 > .header-mark::before,
.single .content > h4 > .header-mark::before,
.single .content > h5 > .header-mark::before,
.single .content > h6 > .header-mark::before {
    content: "" !important;
    margin-right: 0 !important;
}

.single .content > h1 {
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.single .content > h2 {
    color: #34495e;
    border-left: 4px solid #e74c3c;
    padding-left: 1rem;
    margin-left: -1rem;
    background: linear-gradient(90deg, rgba(231, 76, 60, 0.08), transparent);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.single .content > h3 {
    color: #16a085;
    border-bottom: 2px solid #1abc9c;
    padding-bottom: 0.3rem;
    display: inline-block;
    margin-bottom: 1rem;
}

.single .content > h4 {
    color: #8e44ad;
    font-weight: 600;
}

.single .content > h5 {
    color: #d35400;
    font-weight: 500;
}

.single .content > h6 {
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

[theme=dark] .single .content > h1 { color: #ecf0f1; border-bottom-color: #3498db; }
[theme=dark] .single .content > h2 { color: #bdc3c7; border-left-color: #e74c3c; background: linear-gradient(90deg, rgba(231, 76, 60, 0.15), transparent); }
[theme=dark] .single .content > h3 { color: #1abc9c; border-bottom-color: #16a085; }
[theme=dark] .single .content > h4 { color: #9b59b6; }
[theme=dark] .single .content > h5 { color: #e67e22; }
[theme=dark] .single .content > h6 { color: #95a5a6; }

.single .content h1,
.single .content h2,
.single .content h3,
.single .content h4,
.single .content h5,
.single .content h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

/* ============================================
   2-Column Layout: Sidebar + Content
   ============================================ */

/* Override theme wrapper to support sidebar */
.layout-with-sidebar {
    display: flex;
    flex: 1 0 auto;
    width: 100%;
    max-width: 100%;
}

/* Page fills available space */
.layout-with-sidebar .main .page {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

/* Single post pages: leave room for TOC on the right */
.layout-with-sidebar .main .page.single {
    width: calc(100% - 280px) !important;
    max-width: calc(100% - 280px) !important;
}

/* Content container */
.layout-with-sidebar .main .container {
    padding: 0 2rem;
}

/* Main content area */
.layout-with-sidebar .main {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    width: 272px;
    min-width: 272px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.sidebar.collapsed .sidebar-nav,
.sidebar.collapsed .sidebar-header {
    opacity: 0;
    pointer-events: none;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 272px;
}

/* Toggle */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 14px;
    height: 48px;
    min-height: 48px;
    cursor: pointer;
    color: #868e96;
    transition: color 0.15s;
    border-bottom: 1px solid #e9ecef;
}

.sidebar-toggle:hover {
    color: #495057;
}

.sidebar-toggle i {
    font-size: 1rem;
}

/* Header */
.sidebar-header {
    padding: 20px 20px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    transition: opacity 0.15s;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 20px;
    transition: opacity 0.2s;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #ced4da;
}

/* Category */
.sidebar-category {
    margin: 0;
}

.sidebar-category-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-category-title:hover {
    background: #e9ecef;
    color: #212529;
}

.sidebar-category-title i {
    font-size: 0.7rem;
    color: #adb5bd;
    width: 14px;
    text-align: center;
    transition: transform 0.2s;
}

.sidebar-category.collapsed .sidebar-category-title i {
    transform: rotate(-90deg);
}

.sidebar-category-title span:first-of-type {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-count {
    font-size: 0.65rem;
    font-weight: 500;
    color: #868e96;
    background: #e9ecef;
    padding: 1px 7px;
    border-radius: 10px;
    line-height: 1.5;
}

/* Post links */
.sidebar-posts {
    list-style: none;
    margin: 0;
    padding: 0 0 6px 0;
    overflow: hidden;
    max-height: 1000px;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.sidebar-category.collapsed .sidebar-posts {
    max-height: 0;
    padding: 0;
}

.sidebar-post-item {
    margin: 0;
    padding: 0;
}

.sidebar-post-item a {
    display: block;
    padding: 5px 20px 5px 42px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #6c757d;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-post-item a:hover {
    color: #228be6;
    background: #f1f3f5;
    border-left-color: #dee2e6;
}

.sidebar-post-item.active a {
    color: #1971c2;
    background: #d0ebff;
    font-weight: 600;
    border-left-color: #228be6;
}

/* ============================================
   Dark Theme Sidebar
   ============================================ */

[theme=dark] .sidebar {
    background: #1a1b1e;
    border-right-color: #2c2e33;
}

[theme=dark] .sidebar-toggle {
    color: #5c5f66;
    border-bottom-color: #2c2e33;
}

[theme=dark] .sidebar-toggle:hover {
    color: #909296;
}

[theme=dark] .sidebar-header {
    color: #5c5f66;
}

[theme=dark] .sidebar-category-title {
    color: #909296;
}

[theme=dark] .sidebar-category-title:hover {
    background: #25262b;
    color: #c1c2c5;
}

[theme=dark] .sidebar-category-title i {
    color: #5c5f66;
}

[theme=dark] .sidebar-count {
    background: #25262b;
    color: #5c5f66;
}

[theme=dark] .sidebar-post-item a {
    color: #868e96;
}

[theme=dark] .sidebar-post-item a:hover {
    background: #25262b;
    color: #4dabf7;
    border-left-color: #373a40;
}

[theme=dark] .sidebar-post-item.active a {
    background: #1b2838;
    color: #4dabf7;
    border-left-color: #339af0;
}

[theme=dark] .sidebar-nav::-webkit-scrollbar-thumb {
    background: #373a40;
}

/* ============================================
   Responsive
   ============================================ */

/* Tablet: narrower sidebar */
@media screen and (max-width: 1280px) {
    .sidebar {
        width: 240px;
        min-width: 240px;
    }

    .sidebar-inner {
        min-width: 240px;
    }

    .layout-with-sidebar .main .container {
        padding: 0 1.5rem;
    }
}

/* Mobile: overlay sidebar */
@media screen and (max-width: 680px) {
    .layout-with-sidebar {
        position: relative;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 280px;
        min-width: 280px;
        height: 100vh;
        z-index: 200;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        border-right: none;
    }

    .sidebar-inner {
        min-width: 280px;
    }

    .sidebar:not(.collapsed) {
        left: 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    }

    /* Override desktop collapsed styles for mobile */
    .sidebar.collapsed {
        width: 280px;
        min-width: 280px;
        border-right: none;
    }

    .sidebar.collapsed .sidebar-nav,
    .sidebar.collapsed .sidebar-header {
        opacity: 1;
        pointer-events: auto;
    }

    /* Floating toggle button — always visible on mobile */
    .sidebar-toggle {
        position: fixed;
        left: 12px;
        bottom: 80px;
        top: auto;
        width: 44px;
        height: 44px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
        background: #228be6;
        color: #fff !important;
        border: none;
        box-shadow: 0 2px 12px rgba(34, 139, 230, 0.4);
        z-index: 201;
    }

    .sidebar-toggle:hover {
        color: #fff;
        background: #1c7ed6;
    }

    .sidebar-toggle i {
        color: #fff;
    }

    [theme=dark] .sidebar-toggle {
        background: #339af0;
        box-shadow: 0 2px 12px rgba(51, 154, 240, 0.4);
    }

    [theme=dark] .sidebar-toggle:hover {
        background: #228be6;
    }

    /* When sidebar open, toggle returns to header position */
    .sidebar:not(.collapsed) .sidebar-toggle {
        position: static;
        width: auto;
        height: 48px;
        border-radius: 0;
        background: transparent;
        color: #868e96 !important;
        border: none;
        border-bottom: 1px solid #e9ecef;
        box-shadow: none;
    }

    .sidebar:not(.collapsed) .sidebar-toggle i {
        color: #868e96;
    }

    [theme=dark] .sidebar:not(.collapsed) .sidebar-toggle {
        background: transparent;
        color: #5c5f66 !important;
        border-bottom-color: #2c2e33;
    }

    .layout-with-sidebar .main .container {
        padding: 0 1rem;
    }

    .layout-with-sidebar .main .page {
        width: 100% !important;
    }
}

/* Overlay when sidebar open on mobile */
@media screen and (max-width: 680px) {
    .sidebar:not(.collapsed)::after {
        content: '';
        position: fixed;
        top: 0;
        left: 280px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 199;
    }
}
