/* ============================================================
   AI TECH — Responsive Master
   Mobile-first adaptation + SEO compliance
   ============================================================ */

/* === GLOBAL RESETS === */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { overflow-x: hidden; }
img, video, svg { max-width: 100%; height: auto; display: block; }
pre { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* === MIN TOUCH TARGETS 44px === */
.btn-primary, .btn-outline, .mobile-toggle, .mobile-nav-close,
.nav-list li a, .mobile-nav-list li a, .tag-cloud-item,
.news-card a, .featured-post a, .post-item a, .post-item,
.pop-item, .cat-list li a, .widget-social-link,
.share-btn, .post-nav a, .pagination a, .pagination span,
.scroll-top, .tag-link, .comment-link, .section-more {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.nav-list li a { padding: 14px 18px; min-height: 44px; }
.mobile-nav-list li a { padding: 16px 0; min-height: 48px; font-size: 16px; }
.post-item { padding: 12px; }
.post-item a { min-height: auto; }
.pop-item { padding: 10px 0; min-height: 44px; align-items: center; }
.cat-list li a { padding: 12px 14px; min-height: 44px; }
.widget-social-link { padding: 12px 14px; min-height: 44px; }
.share-btn { padding: 10px 16px; min-height: 44px; }
.post-nav a { padding: 8px 0; min-height: 44px; }
.pagination a, .pagination span { min-width: 44px; min-height: 44px; }

/* === 1024px — Tablet landscape === */
@media (max-width: 1024px) {
    .container { padding: 0 16px; }
    .content-grid, .single-layout { grid-template-columns: 1fr; }
    .sidebar { order: 2; }
    .news-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .featured-post { grid-template-columns: 1fr; }
    .featured-post-img { min-height: 220px; }
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .hero-grid { grid-template-columns: 1fr; }
    .hero-visual { display: none; }
    .hero-title { font-size: 32px; }
    .hero-desc { font-size: 16px; }
}

/* === 768px — Tablet portrait === */
@media (max-width: 768px) {
    /* Header */
    .header-inner { flex-wrap: wrap; }
    .header-search { order: 3; max-width: 100%; flex-basis: 100%; margin-top: 12px; }
    .header-cta { display: none; }
    .mobile-toggle { display: flex; min-height: 44px; min-width: 44px; justify-content: center; align-items: center; }
    .site-logo { font-size: 18px; }

    /* Top bar */
    .top-bar { display: none; }
    .site-header { top: 0; }
    .main-nav { top: auto; }

    /* Navigation */
    .nav-list { display: none; }
    .nav-list.open { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 99; }
    .nav-list li a { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 15px; min-height: 48px; }

    /* Hero */
    .hero { padding: 40px 0 30px; }
    .hero-title { font-size: 28px; }
    .hero-desc { font-size: 15px; }
    .hero-buttons { flex-direction: column; }
    .hero-buttons .btn-primary, .hero-buttons .btn-outline { width: 100%; justify-content: center; }

    /* News */
    .news-grid-3, .news-grid-2 { grid-template-columns: 1fr; }
    .news-title { font-size: 16px; }
    .featured-post-title { font-size: 20px; }
    .featured-post-body { padding: 20px; }

    /* Post list */
    .post-item { flex-direction: column; }
    .post-item-img { width: 100%; height: 160px; }

    /* Single */
    .single-title { font-size: 24px; }
    .single-header { padding: 20px; }
    .single-thumb { padding: 0 20px; }
    .single-content { padding: 20px; font-size: 15px; }
    .single-tags { padding: 0 20px 20px; }
    .share-bar { padding: 14px 20px; flex-wrap: wrap; }
    .post-nav { padding: 14px 20px; }

    /* Sidebar */
    .sidebar { display: grid; grid-template-columns: 1fr; gap: 16px; }

    /* Footer */
    .footer-grid { grid-template-columns: 1fr; gap: 24px; }
    .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }

    /* Subscribe form */
    .subscribe-form { flex-direction: column; }
    .subscribe-form input { border-radius: var(--radius-sm); min-height: 44px; }
    .subscribe-form button { border-radius: var(--radius-sm); min-height: 44px; }
}

/* === 480px — Mobile portrait === */
@media (max-width: 480px) {
    .container { padding: 0 12px; }
    body { font-size: 16px; line-height: 1.5; }

    /* Hero */
    .hero { padding: 30px 0 20px; }
    .hero-title { font-size: 24px; }
    .hero-desc { font-size: 14px; }
    .hero-badge { font-size: 12px; padding: 5px 12px; }
    .btn-primary, .btn-outline { padding: 12px 16px; font-size: 14px; min-height: 48px; }

    /* News */
    .news-card-img { aspect-ratio: 16/9; }
    .news-title { font-size: 15px; }
    .news-meta { font-size: 11px; }
    .news-badge { font-size: 10px; padding: 3px 8px; }

    /* Section headers */
    .section-title { font-size: 18px; }

    /* Post list */
    .post-item-img { height: 140px; }
    .post-item-title { font-size: 14px; }

    /* Sidebar */
    .widget { border-radius: var(--radius-sm); }
    .widget-title { font-size: 14px; padding: 12px 14px; }
    .widget-body { padding: 12px 14px; }

    /* Single */
    .single-title { font-size: 20px; }
    .single-meta { font-size: 12px; gap: 10px; }
    .single-content { padding: 16px; font-size: 15px; line-height: 1.7; }
    .single-content pre { padding: 12px; font-size: 13px; }
    .share-btn { font-size: 11px; padding: 8px 12px; }

    /* Pagination */
    .pagination { gap: 4px; margin-top: 20px; }

    /* Footer */
    .footer-col-title { font-size: 14px; }
    .footer-about p, .footer-links ul li a { font-size: 12px; }
    .footer-socials a { width: 40px; height: 40px; }

    /* 404 */
    .error-code { font-size: 80px; }
    .error-msg { font-size: 18px; }

    /* Scroll to top */
    .scroll-top { width: 40px; height: 40px; bottom: 16px; right: 16px; font-size: 16px; }
}

/* === HORIZONTAL SCROLL PREVENTION === */
.content-grid, .single-layout, .news-grid-3, .news-grid-2,
.footer-grid, .hero-grid, .featured-post {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* === ACCESSIBILITY === */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* === REDUCE MOTION === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* === SAFE AREA (notch phones) === */
@supports (padding: env(safe-area-inset-top)) {
    .top-bar { padding-top: env(safe-area-inset-top); }
    .site-footer { padding-bottom: env(safe-area-inset-bottom); }
}

/* === PRINT === */
@media print {
    .top-bar, .site-header, .main-nav, .mobile-nav, .sidebar,
    .site-footer, .scroll-top, .share-bar, .post-nav,
    .hero-buttons, .hero-visual { display: none !important; }
    body { background: #fff; color: #000; }
    .content-grid, .single-layout { grid-template-columns: 1fr; }
    a { color: #000; text-decoration: underline; }
    .news-card, .featured-post, .post-item, .single-post { border: 1px solid #ccc; box-shadow: none; }
}
