/*
* Modern Blog Theme - Responsive Styles
* Premium responsive design for all devices
*/

/* ============================================
   TABLET & BELOW (< 1024px)
   ============================================ */
@media screen and (max-width: 1024px) {
    :root {
        --container-width: 100%;
        --header-height: 70px;
    }

    .container {
        padding: 0 var(--space-lg);
    }

    /* Header */
    .site-branding {
        flex-wrap: nowrap;
        gap: var(--space-md);
    }

    /* Category Navigation - Tablet: Collapsible (no carousel) */
    .category-nav {
        position: static;
        overflow: visible;
    }

    /* New Static Main Navigation - Tablet */
    .main-nav {
        position: static;
        overflow: visible;
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Main Nav List - Hidden by default on tablet */
    .main-nav-list {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--color-background);
        border-top: 1px solid var(--color-border);
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-md);
        z-index: 1000;
        padding: var(--space-md);
    }

    .main-nav-list.toggled {
        display: flex;
    }

    .main-nav-item {
        width: 100%;
    }

    .main-nav-link {
        width: 100%;
        padding: var(--space-md);
        justify-content: center;
        border-bottom: 1px solid var(--color-border);
        font-size: 1rem;
        border-radius: 0;
    }

    .main-nav-item:last-child .main-nav-link {
        border-bottom: none;
    }

    /* Hide carousel wrapper on mobile */
    .nav-carousel-wrapper {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-width: none;
        background: var(--color-background);
        border-top: 1px solid var(--color-border);
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-md);
        z-index: 1000;
    }

    .nav-carousel-wrapper.toggled {
        display: block;
    }

    .category-nav-list {
        display: flex;
        flex-direction: column;
        padding: var(--space-md);
        animation: none !important;
        /* Disable carousel on mobile */
    }

    .category-nav-list.toggled {
        display: flex;
    }

    .category-nav-item {
        width: 100%;
    }

    .category-nav-link {
        width: 100%;
        padding: var(--space-md);
        justify-content: center;
        border-bottom: 1px solid var(--color-border);
        font-size: 1rem;
    }

    .category-nav-item:last-child .category-nav-link {
        border-bottom: none;
    }

    /* Hide dropdown arrows on tablet/mobile (no hover) */
    .dropdown-arrow {
        display: none;
    }

    /* Disable hover dropdowns on touch devices */
    .category-dropdown {
        display: none !important;
    }

    /* Hide old menu toggle since we use nav-toggle now */
    .menu-toggle {
        display: none;
    }

    .main-navigation {
        display: none;
    }

    .main-navigation ul {
        flex-direction: column;
        gap: 0;
    }

    .main-navigation li {
        width: 100%;
        border-bottom: 1px solid var(--color-border);
    }

    .main-navigation li:last-child {
        border-bottom: none;
    }

    .main-navigation a {
        display: block;
        padding: var(--space-md);
        text-align: center;
    }

    /* Hero */
    .hero-section {
        min-height: 70vh;
    }

    .hero-title {
        font-size: clamp(2rem, 5vw, 3rem);
    }

    .hero-excerpt {
        font-size: 1.1rem;
    }

    /* Post Grid */
    .post-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-lg);
    }

    /* Footer */
    .footer-widgets {
        grid-template-columns: repeat(2, 1fr);
    }

    .site-info {
        flex-direction: column;
        text-align: center;
    }
}

/* ============================================
   MOBILE DEVICES (< 768px)
   ============================================ */
@media screen and (max-width: 768px) {
    :root {
        --header-height: 64px;
    }

    .container {
        padding: 0 var(--space-md);
    }

    /* Typography */
    h1 {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    h2 {
        font-size: clamp(1.5rem, 6vw, 2rem);
    }

    h3 {
        font-size: clamp(1.25rem, 4vw, 1.5rem);
    }

    /* Header */
    .site-header {
        padding: var(--space-sm) 0;
    }

    .site-title {
        font-size: 1.25rem;
    }

    .header-actions {
        gap: var(--space-sm);
    }

    #search-toggle {
        width: 40px;
        height: 40px;
    }

    /* Hero */
    .hero-section {
        min-height: 80vh;
        margin-bottom: var(--space-2xl);
    }

    .hero-content {
        padding: var(--space-md);
    }

    .hero-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .hero-read-time::before {
        display: none;
    }

    .hero-title {
        font-size: clamp(1.75rem, 7vw, 2.5rem);
    }

    .hero-excerpt {
        font-size: 1rem;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    /* Post Grid */
    .post-grid {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    /* Post Card */
    .post-card .entry-header,
    .post-card .entry-excerpt {
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }

    .post-card .entry-footer {
        padding: var(--space-md);
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }

    .post-meta-items {
        flex-wrap: wrap;
    }

    /* Comments Carousel */
    .comments-carousel-section {
        padding: var(--space-2xl) 0;
        margin: var(--space-2xl) 0;
    }

    .comment-card {
        padding: var(--space-lg);
    }

    .comment-content {
        font-size: 1.1rem;
    }

    /* Single Post */
    .single .entry-header {
        padding-top: var(--space-2xl);
        text-align: left;
    }

    .single .entry-header .post-categories {
        justify-content: flex-start;
    }

    .single .entry-title {
        font-size: clamp(1.75rem, 6vw, 2.5rem);
    }

    .single .entry-meta {
        justify-content: flex-start;
        gap: var(--space-md);
    }

    .single .author-meta {
        flex-direction: row;
    }

    .single .entry-content {
        font-size: 1rem;
    }

    .single .entry-content blockquote {
        padding: var(--space-lg);
        padding-left: var(--space-lg);
    }

    .single .entry-content blockquote p {
        font-size: 1.1rem;
    }

    .post-thumbnail {
        border-radius: var(--radius-sm);
        max-width: 100%;
        max-height: 200px;
    }

    .post-thumbnail img {
        max-height: 200px;
    }

    /* Article Content Images - Mobile: Full visibility, no cropping */
    .single .entry-content img,
    .entry-content img,
    .page .entry-content img,
    .wp-block-image img,
    figure img,
    .entry-content [class*="wp-image-"] {
        max-width: calc(100vw - 2rem) !important;
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        object-fit: contain !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .single .entry-content .alignleft,
    .single .entry-content .alignright,
    .entry-content .alignleft,
    .entry-content .alignright,
    .wp-block-image.alignleft,
    .wp-block-image.alignright {
        float: none !important;
        max-width: calc(100vw - 2rem) !important;
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        margin: var(--space-md) auto !important;
    }

    .single .entry-content figure,
    .entry-content figure,
    .wp-block-image,
    .alignwide,
    .alignfull,
    figure.wp-block-image {
        max-width: calc(100vw - 2rem) !important;
        width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        overflow: visible !important;
    }

    /* Logo Mobile */
    .site-logo {
        max-height: 40px;
    }

    /* Author Bio */
    .author-bio {
        flex-direction: column;
        text-align: center;
        padding: var(--space-xl);
    }

    .author-bio-content {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Post Actions */
    .post-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .like-button {
        justify-content: center;
    }

    .share-buttons {
        justify-content: center;
    }

    /* Footer */
    .footer-widgets {
        grid-template-columns: 1fr;
        gap: var(--space-2xl);
        text-align: center;
    }

    .footer-column a:hover {
        padding-left: 0;
    }

    .site-info {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }

    .footer-social ul {
        justify-content: center;
    }

    /* Comments - Mobile: Better proportions */
    .comments-area {
        width: calc(100vw - 2rem) !important;
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding: var(--space-md) !important;
    }

    .children {
        margin-left: var(--space-sm);
        padding-left: var(--space-sm);
    }

    .comment-body {
        padding: var(--space-md);
        margin-bottom: var(--space-md);
    }

    .comment-author {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .comment-author img {
        width: 36px !important;
        height: 36px !important;
    }

    .comment-content {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .comment-respond {
        padding: var(--space-md);
        width: 100%;
    }

    .comment-form-modern input,
    .comment-form-modern textarea {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Search Overlay */
    .search-overlay-content {
        padding: var(--space-md);
    }

    .search-overlay input[type="search"] {
        font-size: 1.1rem;
    }

    #search-close {
        top: -50px;
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    /* Pagination */
    .nav-links a,
    .nav-links span {
        min-width: 38px;
        height: 38px;
        padding: 0 var(--space-sm);
        font-size: 0.9rem;
    }

    /* Widgets */
    .widget {
        padding: var(--space-lg);
    }

    /* Related Posts - Mobile: Centered properly */
    .related-posts {
        padding: var(--space-xl) var(--space-md) !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    .related-posts-header {
        padding: 0 !important;
        text-align: center;
    }

    .related-posts-grid {
        padding: 0 !important;
        gap: var(--space-md) !important;
    }

    .related-posts .post-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
        padding: 0 !important;
    }

    .related-post-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    /* Post Thumbnail Mobile */
    .post-thumbnail {
        max-height: 180px;
    }

    .post-thumbnail img {
        height: 180px;
    }
}

/* ============================================
   SMALL MOBILE (< 480px)
   ============================================ */
@media screen and (max-width: 480px) {
    :root {
        --header-height: 60px;
    }

    .container {
        padding: 0 var(--space-sm);
    }

    /* Header */
    .site-title {
        font-size: 1.1rem;
    }

    .menu-toggle {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.85rem;
    }

    /* Hero */
    .hero-section {
        min-height: auto;
        padding: var(--space-3xl) 0;
    }

    .hero-category {
        font-size: 0.7rem;
    }

    .hero-title {
        font-size: clamp(1.5rem, 8vw, 2rem);
    }

    .hero-excerpt {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    /* Post Card */
    .post-card .entry-title {
        font-size: 1.1rem;
    }

    .post-card .entry-excerpt {
        font-size: 0.9rem;
    }

    .category-badge {
        font-size: 0.7rem;
        padding: 2px var(--space-xs);
    }

    /* Single Post */
    .single .entry-title {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }

    .tags-links a {
        font-size: 0.8rem;
        padding: var(--space-2xs) var(--space-sm);
    }

    /* Author Bio */
    .author-bio-avatar img {
        width: 64px;
        height: 64px;
    }

    /* Comments */
    .comment-author-info {
        flex-direction: column;
    }

    /* 404 */
    .error-404 h1 {
        font-size: 6rem;
    }

    /* Landing Page Mobile */
    .featured-post {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    .featured-post-image {
        aspect-ratio: 16 / 9;
    }
}

/* ============================================
   DESKTOP LARGE (> 1280px)
   ============================================ */
@media screen and (min-width: 1281px) {
    .post-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .hero-section {
        min-height: 60vh;
    }
}

/* ============================================
   ULTRA-WIDE (> 1600px)
   ============================================ */
@media screen and (min-width: 1601px) {
    :root {
        --container-width: 1400px;
    }

    body {
        font-size: 1.1rem;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --color-border: #333333;
        --color-text-secondary: #111111;
        --color-text-muted: #333333;
    }

    .btn-primary {
        border: 2px solid #000000;
    }
}

/* ============================================
   DARK MODE PREFERENCE (Already dark by default)
   ============================================ */
@media (prefers-color-scheme: light) {
    /* Optional: Add light mode overrides if needed */
    /* The theme is dark by default for premium feel */
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .site-header,
    .site-footer,
    .header-actions,
    .main-navigation,
    .post-actions,
    .share-buttons,
    .comments-area,
    .related-posts {
        display: none !important;
    }

    body {
        background: white;
        color: var(--color-primary);
    }

    a {
        color: var(--color-primary);
        text-decoration: underline;
    }

    .entry-content {
        max-width: 100%;
    }
}