/* ============================================
   RESPONSIVE.CSS - Comprehensive Mobile-First Responsive Overrides
   oieaw.cn Photography Blog
   ============================================ */

/* ---- GLOBAL RESPONSIVE UTILITIES ---- */
* {
    -webkit-tap-highlight-color: transparent;
}

img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* ---- HAMBURGER / MOBILE MENU TOGGLE ---- */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
}

/* ============================================
   TABLET LANDSCAPE - max-width: 1200px
   ============================================ */
@media (max-width: 1200px) {
    .container,
    .header-inner,
    .main-content,
    .footer-inner {
        padding-left: 16px;
        padding-right: 16px;
    }

    .hero-section {
        grid-template-columns: 1fr 280px !important;
        gap: 16px !important;
    }

    .editor-picks-list {
        gap: 12px;
    }

    .featured-grid,
    .works-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .content-with-sidebar {
        grid-template-columns: 1fr 280px;
        gap: 20px;
    }
}

/* ============================================
   TABLET PORTRAIT - max-width: 992px
   ============================================ */
@media (max-width: 992px) {
    .hero-section {
        grid-template-columns: 1fr !important;
        min-height: auto !important;
        max-height: none !important;
    }

    .editor-picks {
        display: none;
    }

    .carousel {
        height: auto !important;
        max-height: 400px !important;
        aspect-ratio: 16/9;
    }

    .carousel-slide,
    .carousel-slide img {
        height: auto !important;
        aspect-ratio: 16/9;
    }

    .content-with-sidebar,
    .content-layout {
        grid-template-columns: 1fr !important;
        display: grid;
    }

    .content-sidebar,
    .sidebar {
        order: 2;
        width: 100%;
    }

    .content-main {
        order: 1;
        width: 100%;
        min-width: 0;
    }

    .featured-grid,
    .works-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .article-grid,
    .list-article-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

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

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

    .section-title {
        font-size: 22px;
    }

    .prev-next-nav {
        grid-template-columns: 1fr;
        gap: 12px;
    }

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


/* ============================================
   MOBILE - max-width: 768px
   ============================================ */
@media (max-width: 768px) {
    /* -- Header & Navigation -- */
    .site-header {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .header-inner {
        padding: 0 12px;
        gap: 8px;
        height: var(--header-height, 56px);
    }

    .site-logo {
        font-size: 16px;
    }

    .site-logo svg {
        width: 22px;
        height: 22px;
    }

    .main-nav {
        display: none;
    }

    .header-search {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile nav overlay when active */
    .main-nav.active {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: var(--header-height, 56px);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--primary-dark, #003366);
        padding: 16px;
        z-index: 999;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
    }

    .main-nav.active a {
        padding: 14px 16px;
        width: 100%;
        font-size: 16px;
        border-radius: 8px;
    }

    /* Mobile search bar inside nav */
    .mobile-search {
        display: block;
        padding: 12px 0;
    }

    .mobile-search .search-form {
        display: flex;
        width: 100%;
    }

    .mobile-search .search-form input {
        flex: 1;
        padding: 10px 14px;
        border-radius: 8px 0 0 8px;
        border: 1px solid rgba(255,255,255,0.2);
        background: rgba(255,255,255,0.1);
        color: #fff;
        font-size: 15px;
    }

    .mobile-search .search-form button {
        padding: 10px 16px;
        border-radius: 0 8px 8px 0;
        background: var(--primary, #0066cc);
        border: none;
        color: #fff;
    }

    /* -- User dropdown -- */
    .user-dropdown-wrapper {
        order: -1;
    }

    .user-name-text {
        display: none;
    }

    /* -- Hero / Carousel -- */
    .hero-section {
        grid-template-columns: 1fr !important;
        margin-bottom: 24px !important;
        min-height: auto !important;
        max-height: none !important;
    }

    .carousel {
        aspect-ratio: 16/9;
        height: auto !important;
        max-height: 300px !important;
        border-radius: 8px !important;
    }

    .carousel-slide,
    .carousel-slide img {
        height: auto !important;
        min-height: 0 !important;
        aspect-ratio: 16/9;
        object-fit: cover;
    }

    .carousel-overlay {
        padding: 16px 16px 12px;
    }

    .carousel-slide .carousel-overlay .carousel-title,
    .carousel-title {
        font-size: 18px !important;
        line-height: 1.3;
    }

    .carousel-overlay p {
        font-size: 13px !important;
        display: none;
    }

    .carousel-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
    }

    .carousel-btn.prev {
        left: 8px !important;
    }

    .carousel-btn.next {
        right: 8px !important;
    }

    .carousel-dots {
        bottom: 8px !important;
        gap: 4px !important;
    }

    /* -- Editor Picks (hide on mobile or stack) -- */
    .editor-picks {
        display: none !important;
    }

    /* -- Content Layout -- */
    .main-content {
        padding: 12px;
    }

    .content-layout {
        display: flex !important;
        flex-direction: column;
        gap: 24px;
    }

    .content-with-sidebar {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column;
    }

    .content-main {
        order: 1;
        width: 100% !important;
        min-width: 0;
    }

    .content-sidebar {
        order: 2;
        width: 100% !important;
    }

    .sidebar-sticky {
        position: static !important;
    }

    /* -- Article Grids -- */
    .featured-grid,
    .works-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .article-grid,
    .list-article-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .related-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    /* -- Article Cards -- */
    .card-body {
        padding: 10px !important;
    }

    .card-title {
        font-size: 14px;
        line-height: 1.4;
    }

    .card-title a {
        font-size: 14px;
    }

    .card-excerpt {
        font-size: 13px;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .card-meta {
        font-size: 12px;
    }

    .card-stats {
        font-size: 12px;
        gap: 8px;
    }

    .card-tags {
        display: none;
    }

    .category-badge {
        font-size: 11px !important;
        padding: 2px 6px !important;
    }

    /* -- Section Headings -- */
    .section-title {
        font-size: 20px;
        margin-bottom: 16px;
    }

    .section-heading {
        margin-bottom: 16px;
        font-size: 20px;
    }

    /* -- Article Detail Page -- */
    .article-detail {
        padding: 16px !important;
    }

    .article-detail h1 {
        font-size: 22px !important;
        line-height: 1.3;
    }

    .article-detail h2 {
        font-size: 19px;
    }

    .article-detail h3 {
        font-size: 17px;
    }

    .article-content {
        font-size: 15px;
        line-height: 1.7;
    }

    .article-content img {
        max-width: 100%;
        height: auto;
        border-radius: 6px;
    }

    .article-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        font-size: 13px;
    }

    .article-content pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 13px;
        padding: 12px;
    }

    .article-content blockquote {
        padding: 12px 16px;
        margin: 16px 0;
        font-size: 15px;
    }

    .article-actions {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 0;
        margin: 16px 0;
    }

    .action-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* -- Prev/Next Navigation -- */
    .prev-next-nav {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .prev-next-link {
        padding: 14px;
    }

    /* -- Sidebar -- */
    .sidebar {
        width: 100% !important;
    }

    .sidebar-card {
        margin-bottom: 16px !important;
    }

    .sidebar-title {
        font-size: 15px;
    }

    .hot-list li {
        padding: 8px 0;
    }

    .hot-item-title {
        font-size: 13px;
    }

    /* -- Footer -- */
    .site-footer {
        padding: 24px 0 16px;
    }

    .footer-inner {
        padding: 0 12px;
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 24px;
    }

    .footer-col {
        text-align: center;
    }

    .footer-logo {
        justify-content: center;
    }

    .footer-desc {
        text-align: center;
    }

    .footer-links ul {
        text-align: center;
    }

    .footer-title {
        font-size: 15px;
    }

    .footer-bottom {
        padding-top: 16px;
        font-size: 12px;
    }

    /* -- Pagination -- */
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }

    .pagination a,
    .pagination span {
        min-width: 36px;
        height: 36px;
        font-size: 14px;
    }

    /* -- Comments -- */
    .comment-avatar {
        width: 36px;
        height: 36px;
    }

    .comment-author {
        font-size: 13px;
    }

    .comment-text {
        font-size: 14px;
    }

    /* -- Auth Pages -- */
    .auth-container {
        max-width: 100%;
        padding: 0 16px;
    }

    .auth-card {
        padding: 20px;
    }

    /* -- Search Form (standalone page) -- */
    .search-form input[type="text"] {
        width: 100% !important;
        font-size: 15px !important;
    }

    /* -- Tag Cloud -- */
    .tag-cloud {
        justify-content: center;
    }

    .tag-cloud a,
    .tag-cloud .tag-item {
        font-size: 12px !important;
        padding: 4px 10px !important;
    }

    /* -- Admin (if viewed on tablet) -- */
    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        padding: 12px;
    }

    .admin-sidebar nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .admin-sidebar nav a {
        padding: 8px 12px;
    }

    .admin-main {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}


/* ============================================
   SMALL MOBILE - max-width: 480px
   ============================================ */
@media (max-width: 480px) {
    /* Typography scaling */
    body {
        font-size: 14px;
    }

    .header-inner {
        padding: 0 10px;
    }

    .site-logo {
        font-size: 14px;
        gap: 6px;
    }

    .site-logo svg {
        width: 20px;
        height: 20px;
    }

    /* Carousel */
    .carousel {
        max-height: 200px !important;
        border-radius: 6px !important;
    }

    .carousel-slide .carousel-overlay .carousel-title,
    .carousel-title {
        font-size: 15px !important;
    }

    .carousel-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 14px !important;
    }

    /* Grids to single column */
    .featured-grid,
    .works-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .article-grid,
    .list-article-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .related-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Cards - horizontal layout on small screens */
    .card {
        display: flex;
        flex-direction: row;
        align-items: stretch;
    }

    .card .card-image {
        width: 120px;
        min-width: 120px;
        flex-shrink: 0;
    }

    .card .card-image img {
        height: 100%;
        object-fit: cover;
        border-radius: var(--radius, 8px) 0 0 var(--radius, 8px);
    }

    .card .card-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 10px 12px !important;
    }

    .card-excerpt {
        display: none;
    }

    .card-title {
        font-size: 14px;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Article Detail */
    .article-detail {
        padding: 12px !important;
    }

    .article-detail h1 {
        font-size: 20px !important;
    }

    .article-detail h2 {
        font-size: 17px;
    }

    .article-content {
        font-size: 14px;
        line-height: 1.7;
    }

    .article-content th,
    .article-content td {
        padding: 8px 10px;
        font-size: 12px;
    }

    .article-actions {
        gap: 6px;
    }

    .action-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .action-btn svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* Section titles */
    .section-title {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .section-heading {
        font-size: 18px;
    }

    /* Sidebar */
    .sidebar-card {
        padding: 14px !important;
    }

    .sidebar-card-header {
        font-size: 14px;
    }

    /* Footer */
    .footer-bottom p {
        font-size: 11px;
    }

    /* Pagination */
    .pagination a,
    .pagination span {
        min-width: 32px;
        height: 32px;
        font-size: 13px;
    }

    /* Auth */
    .auth-card {
        padding: 16px;
    }

    /* Stats grid single column */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Prev/Next compact */
    .prev-next-link {
        padding: 12px;
        font-size: 13px;
    }

    /* Comments */
    .comment-item {
        padding: 12px 0;
    }

    .comment-avatar {
        width: 32px;
        height: 32px;
    }
}

/* ============================================
   EXTRA SMALL - max-width: 360px
   ============================================ */
@media (max-width: 360px) {
    .header-inner {
        padding: 0 8px;
    }

    .site-logo {
        font-size: 13px;
    }

    .main-content {
        padding: 8px;
    }

    .carousel {
        max-height: 180px !important;
    }

    .card .card-image {
        width: 100px;
        min-width: 100px;
    }

    .article-detail {
        padding: 10px !important;
    }

    .article-detail h1 {
        font-size: 18px !important;
    }

    .footer-inner {
        padding: 0 8px;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION FIX
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .carousel {
        max-height: 60vh !important;
    }

    .main-nav.active {
        padding: 8px 16px;
    }

    .main-nav.active a {
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .site-header,
    .site-footer,
    .sidebar,
    .content-sidebar,
    .carousel,
    .hero-section,
    .pagination,
    .article-actions,
    .prev-next-nav,
    .mobile-menu-toggle,
    .comment-form {
        display: none !important;
    }

    .content-layout,
    .content-with-sidebar {
        display: block !important;
    }

    .content-main {
        width: 100% !important;
    }

    .article-detail {
        padding: 0 !important;
    }

    .article-content {
        font-size: 12pt;
        line-height: 1.6;
    }

    .article-content img {
        max-width: 100%;
        page-break-inside: avoid;
    }
}


/* ============================================
   MOBILE NAV FIX - override all previous rules
   ============================================ */
@media (max-width: 768px) {
    /* Header layout */
    .site-header { position: sticky; top: 0; z-index: 1000; }
    .header-inner {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 8px 12px !important;
        flex-wrap: nowrap !important;
    }
    
    /* Logo - keep on one line */
    .logo {
        display: flex !important;
        align-items: center !important;
        white-space: nowrap !important;
        font-size: 16px !important;
        flex-shrink: 0 !important;
        gap: 6px !important;
    }
    .logo .logo-icon { width: 22px !important; height: 22px !important; }
    .logo span { display: inline !important; }

    /* Hide desktop nav */
    .main-nav {
        display: none !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0,0,0,0.95);
        z-index: 9999;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
        padding-top: 60px;
    }
    .main-nav.active {
        display: flex !important;
    }
    .main-nav a {
        color: #fff !important;
        font-size: 18px !important;
        padding: 16px 30px !important;
        display: block !important;
        width: 100%;
        text-align: center;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        text-decoration: none;
    }
    .main-nav a:hover,
    .main-nav a.active {
        background: rgba(255,255,255,0.1) !important;
        color: #f0c040 !important;
    }
    
    /* Hide search form on mobile */
    .header-right .search-form { display: none !important; }
    
    /* User toggle compact */
    .user-name-text { display: none !important; }
    .user-toggle { padding: 4px 8px !important; }
    .user-avatar { font-size: 12px !important; }
    
    /* Hamburger button always visible */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: none !important;
        border: none !important;
        color: #fff !important;
        cursor: pointer;
        padding: 6px !important;
        flex-shrink: 0;
        order: 10;
        width: 36px;
        height: 36px;
    }
    .mobile-menu-toggle svg { width: 24px; height: 24px; }
    
    /* X icon when menu active */
    .mobile-menu-toggle.active svg line:nth-child(1) {
        transform: rotate(45deg);
        transform-origin: center;
    }
    .mobile-menu-toggle.active svg line:nth-child(2) { opacity: 0; }
    .mobile-menu-toggle.active svg line:nth-child(3) {
        transform: rotate(-45deg);
        transform-origin: center;
    }
    
    /* Header right section */
    .header-right {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        margin-left: auto !important;
    }
}

/* Ensure hamburger hidden on desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle { display: none !important; }
    .main-nav { display: flex !important; }
}
