/* ==========================================================================
   Mobile-only elements — hidden on desktop, shown via media queries below
   ========================================================================== */

.site-nav__close,
.menu-overlay {
    display: none;
}

/* ==========================================================================
   Responsive - Tablet (max 992px)
   ========================================================================== */

@media (max-width: 992px) {
    /* Layout */
    .content-area {
        grid-template-columns: 1fr;
    }

    /* Header */
    .menu-toggle {
        display: flex;
    }

    /*
     * Z-index hierarchy (within .site-header stacking context):
     *   var(--z-menu-panel)   3 — .site-nav     (menu panel)
     *   var(--z-menu-overlay) 2 — .menu-overlay  (dark backdrop)
     *   auto                     — header bar     (logo, hamburger)
     *
     * When menu is open, .site-header is elevated to --z-menu-open-header (10000)
     * so the entire menu system sits above all page content.
     */

    /* ---- Mobile nav panel ---- */
    .site-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 75%;
        max-width: 300px;
        height: 100vh;
        background-color: var(--color-white);
        z-index: var(--z-menu-panel);
        display: flex;
        flex-direction: column;
        box-shadow: var(--shadow-lg);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .site-nav.is-open {
        transform: translateX(0);
    }

    /* ---- Close button — top-right corner of panel ---- */
    .site-nav .site-nav__close {
        position: absolute;
        top: var(--space-2);
        right: var(--space-2);
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: none;
        color: var(--color-gray-600);
        cursor: pointer;
        border-radius: 2px;
        pointer-events: auto;
        transition: all var(--transition-fast);
        z-index: 1;
    }

    .site-nav .site-nav__close:hover {
        background-color: var(--color-gray-100);
        color: var(--color-primary);
    }

    /* ---- Menu items — only this area scrolls ---- */
    .nav-menu {
        display: flex;
        flex: 1;
        flex-direction: column;
        width: 100%;
        padding-top: 56px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-menu > li > a {
        height: auto;
        padding: var(--space-3) var(--space-6);
        border-bottom: 1px solid var(--color-gray-100);
    }

    .nav-menu > li > a::after {
        display: none;
    }

    .nav-menu .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        background-color: var(--color-gray-50);
    }

    .nav-menu .sub-menu a {
        padding-left: var(--space-10);
    }

    /* Mega menu: disable on mobile */
    .mega-menu {
        position: static;
        display: none;
    }

    /* ---- Menu open state ---- */
    body.menu-open {
        overflow: hidden;
    }

    body.menu-open .site-header {
        z-index: var(--z-menu-open-header);
    }

    /* ---- Menu overlay ---- */
    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: var(--z-menu-overlay);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    body.menu-open .menu-overlay {
        display: block;
    }

    /* Hero */
    .hero-grid {
        grid-template-columns: 1fr 1fr;
    }

    .hero-main {
        grid-column: 1 / -1;
    }

    .hero-main__title {
        font-size: var(--text-2xl);
    }

    /* Trending */
    .trending-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Cards grid */
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cards-grid--3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .card__title {
        -webkit-line-clamp: 3;
    }

    /* Opinion */
    .opinion-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Newsletter */
    .newsletter {
        flex-direction: column;
        text-align: center;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Archive */
    .archive-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Author */
    .author-profile {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* ==========================================================================
   Responsive - Mobile Large (max 768px)
   ========================================================================== */

@media (max-width: 768px) {
    /* Trending: 2 columns */
    .trending-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Cards: single column, horizontal layout */
    .cards-grid,
    .cards-grid--3 {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    /* Horizontal card: image left, content right */
    .card {
        border-radius: 4px;
    }

    .card__link {
        flex-direction: row;
        min-height: 120px;
    }

    .card__image {
        flex-shrink: 0;
        width: 160px;
        min-height: 120px;
        aspect-ratio: auto;
    }

    .card__image img {
        height: 100%;
        object-fit: cover;
    }

    .card__content {
        padding: var(--space-3) var(--space-4);
        justify-content: center;
        min-width: 0;
        gap: var(--space-2);
    }

    .card__title {
        font-size: var(--text-base);
        -webkit-line-clamp: 3;
        line-height: 1.4;
    }

    /* Category badge: full text, no truncation */
    .category-badge {
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
        max-width: none;
        font-size: 0.7rem;
    }

    /* Opinion grid to 2 columns */
    .opinion-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }
}

/* ==========================================================================
   Responsive - Mobile (max 640px)
   ========================================================================== */

@media (max-width: 640px) {
    :root {
        --header-height: 50px;
    }

    /* Typography */
    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); }

    /* Ticker */
    .ticker__label {
        font-size: 0.65rem;
        padding: 0 var(--space-2);
    }

    /* Trending: single column */
    .trending-grid {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .trending-item {
        padding: var(--space-3);
    }

    .trending-item__rank {
        font-size: var(--text-2xl);
        min-width: 30px;
    }

    .trending-item__title {
        -webkit-line-clamp: 2;
    }

    .trending-section {
        padding: var(--space-6) 0;
    }

    /* Indicators */
    .indicators {
        height: auto;
        padding: var(--space-2) 0;
    }

    .indicators__track {
        gap: var(--space-4);
    }

    .indicators__item {
        flex-direction: column;
        gap: 0;
        text-align: center;
    }

    /* Header */
    .site-logo-text {
        font-size: var(--text-xl);
    }

    .custom-logo {
        max-height: 35px;
    }

    /* Hero */
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .hero-main__content {
        padding: var(--space-4);
    }

    .hero-main__title {
        font-size: var(--text-xl);
    }

    .hero-main__excerpt {
        display: none;
    }

    .hero-side__title {
        font-size: var(--text-base);
    }

    /* Cards — refine horizontal layout for small screens */
    .cards-grid,
    .cards-grid--3 {
        gap: var(--space-3);
    }

    .card__link {
        min-height: 110px;
    }

    .card__image {
        width: 130px;
        min-height: 110px;
    }

    .card__title {
        font-size: var(--text-sm);
        -webkit-line-clamp: 3;
        line-height: 1.4;
    }

    .card__content {
        padding: var(--space-2) var(--space-3);
        gap: var(--space-1);
        min-width: 0;
    }

    .card .meta {
        font-size: var(--text-xs);
        gap: var(--space-2);
    }

    .category-badge {
        font-size: 0.625rem;
        padding: 2px var(--space-1);
    }

    /* Opinion */
    .opinion-grid {
        grid-template-columns: 1fr;
    }

    /* Single post */
    .single-post__title {
        font-size: var(--text-2xl);
    }

    .single-post__meta {
        flex-direction: column;
        gap: var(--space-3);
        align-items: flex-start;
    }

    .single-post__content {
        font-size: var(--text-base);
    }

    /* Author box */
    .author-box {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    /* Newsletter */
    .newsletter__input-group {
        flex-direction: column;
        gap: var(--space-2);
    }

    .newsletter__submit {
        width: 100%;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .site-footer__bottom-inner {
        flex-direction: column;
        gap: var(--space-2);
        text-align: center;
    }

    /* Archive */
    .archive-grid {
        grid-template-columns: 1fr;
    }

    .posts-grid {
        grid-template-columns: 1fr;
    }

    /* Search */
    .search-overlay .search-form {
        flex-direction: column;
    }

    /* Pagination */
    .nav-links {
        flex-wrap: wrap;
    }

    /* Sidebar */
    .sidebar {
        margin-top: var(--space-8);
        padding-top: var(--space-8);
        border-top: 3px solid var(--color-accent);
    }

    /* Widget popular posts */
    .widget-popular-posts__item {
        gap: var(--space-2);
    }

    .widget-popular-posts__number {
        font-size: var(--text-xl);
        min-width: 30px;
    }

    /* Bottom navigation bar */
    body {
        padding-bottom: 60px;
    }

    .back-to-top {
        bottom: 75px;
    }
}

/* ==========================================================================
   Bottom Navigation (mobile only)
   ========================================================================== */

.bottom-nav {
    display: none;
}

@media (max-width: 640px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background-color: var(--color-white);
        border-top: 1px solid var(--color-gray-200);
        z-index: var(--z-bottom-nav);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    /* When menu is open: shorten panel & overlay to leave bottom bar visible */
    body.menu-open .site-nav {
        height: calc(100vh - 60px);
    }

    body.menu-open .menu-overlay {
        bottom: 60px;
    }

    .bottom-nav__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--color-gray-500);
        font-size: 0.625rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        transition: color var(--transition-fast);
        background: none;
        border: none;
        cursor: pointer;
        font-family: inherit;
    }

    .bottom-nav__item:hover,
    .bottom-nav__item.is-active {
        color: var(--color-primary);
    }

    .bottom-nav__item.is-active svg {
        stroke: var(--color-accent);
    }
}

/* ==========================================================================
   Sticky Sidebar (desktop only)
   ========================================================================== */

@media (min-width: 993px) {
    .sidebar {
        position: sticky;
        top: calc(var(--header-height) + var(--space-4));
        align-self: start;
        max-height: calc(100vh - var(--header-height) - var(--space-8));
        overflow-y: auto;
        scrollbar-width: thin;
    }
}

/* ==========================================================================
   Widget Styles (shared across breakpoints)
   ========================================================================== */

.widget {
    margin-bottom: var(--space-6);
    padding: var(--space-5);
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
}

.widget-title {
    font-size: var(--text-base);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-4);
    border-bottom: 3px solid var(--color-accent);
}

/* Popular posts widget */
.widget-popular-posts {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.widget-popular-posts__item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-gray-100);
    color: inherit;
    transition: all var(--transition-fast);
}

.widget-popular-posts__item:last-child {
    border-bottom: none;
}

.widget-popular-posts__item:hover {
    padding-left: var(--space-2);
}

.widget-popular-posts__number {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--color-gray-200);
    line-height: 1;
    min-width: 35px;
    flex-shrink: 0;
}

.widget-popular-posts__item:hover .widget-popular-posts__number {
    color: var(--color-accent);
}

.widget-popular-posts__title {
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-gray-800);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.widget-popular-posts__item:hover .widget-popular-posts__title {
    color: var(--color-primary);
}

.widget-popular-posts__date {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
}

/* ==========================================================================
   Recent Posts Widget
   ========================================================================== */

.widget-recent {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Featured first post (large card) */
.widget-recent__featured {
    display: block;
    position: relative;
    overflow: hidden;
    margin-bottom: var(--space-4);
    color: inherit;
}

.widget-recent__featured-img {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.widget-recent__featured-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.widget-recent__featured:hover .widget-recent__featured-img img {
    transform: scale(1.05);
}

.widget-recent__featured-img--placeholder {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gray-400);
}

.widget-recent__featured-content {
    padding: var(--space-3) 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.widget-recent__featured-content .category-badge {
    align-self: flex-start;
    font-size: 0.65rem;
}

.widget-recent__featured-title {
    font-size: var(--text-base);
    font-weight: 700;
    line-height: 1.35;
    color: var(--color-gray-900);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--transition-fast);
}

.widget-recent__featured:hover .widget-recent__featured-title {
    color: var(--color-primary);
}

/* Compact list items */
.widget-recent__item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-gray-100);
    color: inherit;
    transition: all var(--transition-fast);
}

.widget-recent__item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.widget-recent__item:hover {
    padding-left: var(--space-1);
}

.widget-recent__thumb {
    flex-shrink: 0;
    width: 80px;
    height: 60px;
    overflow: hidden;
    border-radius: 2px;
}

.widget-recent__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.widget-recent__item:hover .widget-recent__thumb img {
    transform: scale(1.1);
}

.widget-recent__thumb-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--color-gray-200), var(--color-gray-300));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gray-400);
}

.widget-recent__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.widget-recent__cat {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-accent-dark);
}

.widget-recent__title {
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.35;
    color: var(--color-gray-800);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--transition-fast);
}

.widget-recent__item:hover .widget-recent__title {
    color: var(--color-primary);
}

.widget-recent__time {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
}

/* List-only style (no featured card) */
.widget-recent--list .widget-recent__featured {
    display: none;
}

/* Comments */
.comments-section {
    margin-top: var(--space-8);
    padding-top: var(--space-8);
    border-top: 3px solid var(--color-gray-200);
}

.comment-list {
    list-style: none;
}

.comment-list .comment {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-gray-100);
}

.comment-list .comment-body {
    display: flex;
    gap: var(--space-3);
}

.comment-list .comment-author img {
    border-radius: 50%;
}

.comment-list .comment-content p {
    font-size: var(--text-sm);
    margin-bottom: var(--space-2);
}

.comment-list .reply a {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-primary);
    text-transform: uppercase;
}

/* Comment form */
.comment-respond {
    margin-top: var(--space-6);
}

.comment-respond .comment-reply-title {
    font-size: var(--text-xl);
    margin-bottom: var(--space-4);
}

.comment-respond label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-1);
    color: var(--color-gray-700);
}

.comment-respond input[type="text"],
.comment-respond input[type="email"],
.comment-respond input[type="url"],
.comment-respond textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--color-gray-300);
    font-size: var(--text-base);
    margin-bottom: var(--space-3);
    outline: none;
    transition: border-color var(--transition-fast);
}

.comment-respond input:focus,
.comment-respond textarea:focus {
    border-color: var(--color-primary);
}

/* Print */
@media print {
    .ticker,
    .indicators,
    .site-header__actions,
    .search-overlay,
    .sidebar,
    .site-footer,
    .newsletter-section,
    .single-post__share,
    .related-posts,
    .comments-section {
        display: none !important;
    }

    .content-area {
        grid-template-columns: 1fr;
    }

    body {
        font-size: 12pt;
        color: #000;
    }
}
