/**
 * Hagstone Article Sidebar
 * TL;DR box, related posts, and media for article layouts
 *
 * @package Hagstone
 * @since 1.0
 */

/* ============================================
   Layout: Article with Sidebar
   ============================================ */

.single-post-main.layout-article.has-sidebar {
    display: flex;
    gap: 3rem;
}

.single-post-main.layout-article.has-sidebar .single-container {
    flex: 1;
    min-width: 0;
}

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

.article-sidebar {
    flex: 0 0 auto;
    position: sticky;
    top: calc(var(--header-height, 80px) + 2rem);
    align-self: flex-start;
    max-height: calc(100vh - var(--header-height, 80px) - 4rem);
    overflow-y: auto;
    padding-bottom: 2rem;

    /* Two-column layout: media left, text boxes right */
    display: flex;
    gap: 1.5rem;

    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Media on the left */
.article-sidebar > .media-box {
    flex: 0 0 200px;
    max-width: 200px;
    margin-bottom: 0;
    align-self: flex-start;
}

/* Text boxes container on the right */
.sidebar-text-boxes {
    flex: 0 0 360px;
    width: 360px;
}

.article-sidebar::-webkit-scrollbar {
    width: 4px;
}

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

.article-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

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

.sidebar-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.sidebar-box:last-child {
    margin-bottom: 0;
}

.sidebar-box-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.65);
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-box-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-box-content p {
    margin: 0 0 0.75rem 0;
}

.sidebar-box-content p:last-child {
    margin-bottom: 0;
}

/* ============================================
   TL;DR Box
   ============================================ */

.tldr-box {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.tldr-box .sidebar-box-title {
    color: rgba(255, 255, 255, 0.75);
}

.tldr-box .sidebar-box-content {
    color: rgba(255, 255, 255, 0.9);
}

/* Code in TL;DR */
.tldr-box code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15em 0.4em;
    font-size: 0.85em;
    border-radius: 3px;
}

/* ============================================
   Related Posts Box
   ============================================ */

.related-posts-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.related-posts-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.related-posts-list li:last-child {
    border-bottom: none;
}

.related-posts-list a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.related-posts-list a:hover {
    color: #fff;
}

.related-posts-list li.current {
    opacity: 1;
}

.related-posts-list .current-post {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
}

.related-posts-list time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.65);
    flex-shrink: 0;
}

.view-all-link {
    display: inline-block;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
}

.view-all-link:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   Media Box
   ============================================ */

.media-box {
    padding: 0;
    overflow: hidden;
}

.sidebar-media {
    position: relative;
    overflow: hidden;
}

.sidebar-media img,
.sidebar-media video {
    display: block;
    width: 100%;
    height: auto;
}

.media-count {
    margin: 0;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.65);
    background: rgba(0, 0, 0, 0.2);
}

/* ============================================
   Entrance Animation
   ============================================ */

@keyframes sidebarSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.article-sidebar {
    animation: sidebarSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.1s;
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .article-sidebar {
        animation: none;
        opacity: 1;
    }
}

/* ============================================
   Mobile: Stacked Layout
   ============================================ */

@media (max-width: 1200px) {
    .single-post-main.layout-article.has-sidebar {
        flex-direction: column;
        gap: 2rem;
    }

    .single-post-main.layout-article.has-sidebar .single-container {
        max-width: 100%;
    }

    .article-sidebar {
        flex: none;
        position: static;
        max-height: none;
        overflow: visible;
        animation: none;
        opacity: 1;
        padding-bottom: 0;
    }

    .sidebar-text-boxes {
        flex: 1;
        width: auto;
    }
}

/* Small mobile - stack vertically */
@media (max-width: 599px) {
    .article-sidebar {
        flex-direction: column;
    }

    .article-sidebar > .media-box {
        flex: none;
        max-width: 100%;
    }

    .sidebar-text-boxes {
        flex: none;
        width: 100%;
    }

    .sidebar-box {
        margin-bottom: 1rem;
    }
}
