/**
 * Shared layout primitives — used by blog-single.php, blog.php (sidebar parts),
 * calendar.php, writer-apply.php, speed-test.php.
 *
 * Sections:
 *   1. Blog list / single shell  (.blog-single-layout, .blog-sidebar, .blog-main)
 *   2. Sidebar menu chrome       (.sidebar-menu-link etc.)
 *   3. 3-column inner layout     (.article-layout, .article-side-rail)
 *   4. Toolbar + search          (.blog-toolbar-widget, .blog-toolbar, .blog-search)
 *   5. Speed-test scoped overrides (.st-shell ...)
 */

/* ============== 1. Outer shell ============== */
.blog-single-layout {
    display: flex;
    gap: 16px;
    width: 100%;
    align-items: flex-start;
    padding-top: 30px;
    margin: 0;
}

.blog-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 86px;
    max-height: calc(100vh - 86px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
    display: flex;
    flex-direction: column;
}
.blog-sidebar::-webkit-scrollbar { width: 4px; }
.blog-sidebar::-webkit-scrollbar-track { background: transparent; }
.blog-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.blog-main {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 0;
    overflow-x: hidden;
}

/* ============== 2. Sidebar menu chrome ============== */
.blog-sidebar .sidebar-card {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
}
.blog-sidebar .sidebar-menu { list-style: none; padding: 4px 0; margin: 0; }
.blog-sidebar .sidebar-menu-item { margin-bottom: 1px; }

@keyframes sidebar-glow-pulse {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}
.blog-sidebar .sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.01em;
    background: transparent;
    position: relative;
    transition: color 0.25s ease;
}
.blog-sidebar .sidebar-menu-link::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: rgba(59, 138, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(59, 138, 255, 0.35), 0 0 10px rgba(59, 138, 255, 0.12);
    opacity: 0;
    transition: opacity 0.25s ease;
    -webkit-mask-image: linear-gradient(90deg, black 0%, black 40%, transparent 95%);
    mask-image: linear-gradient(90deg, black 0%, black 40%, transparent 95%);
    pointer-events: none;
}
.blog-sidebar .sidebar-menu-link:hover { color: #3b8aff; }
.blog-sidebar .sidebar-menu-link:hover::before {
    opacity: 1;
    animation: sidebar-glow-pulse 2s ease-in-out infinite;
}
.blog-sidebar .sidebar-menu-link.active { color: #3b8aff; font-weight: 500; }
.blog-sidebar .sidebar-menu-link.active::before {
    opacity: 0.7;
    box-shadow: inset 0 0 0 1px rgba(59, 138, 255, 0.28), 0 0 8px rgba(59, 138, 255, 0.1);
}
.blog-sidebar .sidebar-menu-link.active svg { color: #3b8aff; }
.blog-sidebar .sidebar-menu-link.all-posts-link::before { display: none; }

@keyframes sidebar-glow-pulse-gold {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}
.blog-sidebar .sidebar-menu-link.academy-link { color: rgba(255, 215, 0, 0.65); }
.blog-sidebar .sidebar-menu-link.academy-link svg { color: rgba(255, 215, 0, 0.45); }
.blog-sidebar .sidebar-menu-link.academy-link::before {
    background: rgba(255, 215, 0, 0.07);
    box-shadow: inset 0 0 0 1px rgba(255, 215, 0, 0.35), 0 0 10px rgba(255, 180, 0, 0.1);
}
.blog-sidebar .sidebar-menu-link.academy-link:hover { color: #FFD700; }
.blog-sidebar .sidebar-menu-link.academy-link:hover::before {
    animation: sidebar-glow-pulse-gold 2s ease-in-out infinite;
}
.blog-sidebar .sidebar-menu-link.academy-link:hover svg { color: #FFD700; }

.blog-sidebar .sidebar-menu-link svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.35);
    transition: color 0.2s ease;
    stroke-width: 1.8;
}
.blog-sidebar .sidebar-menu-link:hover svg { color: #3b8aff; }

.blog-sidebar .sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 6px 14px;
}
.blog-sidebar .sidebar-section-title {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.25);
    padding: 12px 14px 6px;
    margin: 0;
}
.blog-sidebar .category-count {
    margin-left: auto;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 7px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
}

/* ============== 3. Inner 3-column layout (main content + side rail) ============== */
.article-layout {
    position: relative;
    padding-right: 344px; /* 320 rail + 24 gap */
    margin-bottom: 14px;
}
.article-layout > .article-content { margin-bottom: 0; max-width: none; }

.article-side-rail {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 4;
}
.article-side-rail.is-fixed {
    position: fixed;
    top: 130px;
    right: var(--rail-right, 32px);
}

@media (max-width: 1100px) {
    .article-layout { padding-right: 0; }
    .article-side-rail { position: static; width: 100%; }
}

/* ============== 4. Toolbar + search (used by calendar.php, blog.php) ============== */
.blog-toolbar-widget {
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    margin-top: 20px;
    margin-bottom: 16px;
}
.blog-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.blog-search {
    flex: 1;
    min-width: 180px;
    max-width: 340px;
    position: relative;
    display: flex;
    align-items: center;
}
.blog-search svg {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}
.blog-search input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 38px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    transition: all 0.2s ease;
}
.blog-search input:focus {
    outline: none;
    border-color: #3b8aff;
    background: rgba(56, 132, 255, 0.05);
}
.blog-search input::placeholder { color: rgba(255, 255, 255, 0.4); }

/* ============== 5. Rail widget cards (used inside .article-side-rail) ============== */
.rail-widget {
    background: linear-gradient(180deg, #0f1828 0%, #0a1220 100%);
    border: 1px solid rgba(59, 138, 255, 0.14);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}
.rail-head {
    position: relative;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.rail-head-left {
    display: flex; align-items: center; gap: 8px;
    min-width: 0; flex: 1;
}
.rail-head-icon {
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, 0.55);
    flex-shrink: 0;
}
.rail-head-icon svg { width: 14px; height: 14px; flex-shrink: 0; stroke-width: 1.8; }
.rail-title {
    font-size: 13px; font-weight: 500;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-sub {
    font-size: 10.5px; color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.02em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 42%;
    flex-shrink: 0;
}
.rail-body { padding: 6px 14px 12px; }
.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rail-prices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rail-prices .rail-price { border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.rail-prices .rail-price:last-child { border-bottom: none; }
.rail-price-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 4px;
    text-decoration: none; border: none;
}
.rail-price-sym {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px; font-weight: 600;
    color: #fff;
    letter-spacing: 0.05em;
}
.rail-price-vals { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.rail-price-bid {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px; font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.rail-price-chg {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.rail-price-chg.is-up { color: #22c55e; }
.rail-price-chg.is-dn { color: #ef4444; }

/* Defensive: any stray SVG inside the side rail must be tame */
.article-side-rail svg:not([width]):not([height]) {
    max-width: 100%;
    max-height: 24px;
}

@media (max-width: 1280px) {
    .article-layout { padding-right: 0; }
    .article-side-rail,
    .article-side-rail.is-fixed,
    .article-side-rail.is-bottom {
        position: static;
        top: auto; bottom: auto; right: auto;
        width: auto;
        max-height: none;
        overflow: visible;
        margin-top: 16px;
    }
}

/* ============== 6. Speed-test scoped overrides ============== */
.st-shell .blog-single-layout {
    padding-top: 24px;
    align-items: flex-start;
    overflow-x: hidden;
    max-width: 100%;
}
.st-shell .blog-main {
    gap: 14px;
}
@media (max-width: 900px) {
    .st-shell .blog-single-layout { flex-direction: column; padding-top: 16px; }
    .st-shell .blog-sidebar { position: static; width: 100%; max-height: none; }
}
