/* ═══════════════════════════════════════════════════════
   CentralUniversity.in — Mobile-First Responsive CSS
   Optimized for: 320px, 360px, 375px, 414px, 768px, 1024px
   ═══════════════════════════════════════════════════════ */

/* ═══ Base Mobile Reset ═══ */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: hidden; }
body { overflow-x: hidden; -webkit-font-smoothing: antialiased; }
img, video, iframe, embed, object { max-width: 100%; height: auto; }
table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* Touch-Friendly Targets */
a, button, .btn, input[type="submit"], .nav-link, .card { min-height: 44px; }
input, select, textarea { font-size: 16px !important; border-radius: 8px; }

/* ═══ TABLET: 768px - 1024px ═══ */
@media (max-width: 1024px) {
    .container, .site-container { max-width: 100%; padding: 0 20px; }
    .hero-section { padding: 50px 20px; }
    .hero-section h1 { font-size: 2rem; }
    .university-grid, .card-grid, .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .content-sidebar-wrap { flex-direction: column; }
    .content-area, .sidebar { width: 100%; }
    .sidebar { margin-top: 30px; }
}

/* ═══ MOBILE: 768px and below ═══ */
@media (max-width: 768px) {
    /* Layout */
    .container, .site-container { padding: 0 15px; }
    section { padding: 30px 0; }

    /* Typography */
    h1, .h1 { font-size: 1.6rem; line-height: 1.3; }
    h2, .h2 { font-size: 1.3rem; line-height: 1.3; }
    h3, .h3 { font-size: 1.15rem; }
    p, li, td, th { font-size: 0.95rem; line-height: 1.65; }

    /* Sticky Header */
    .site-header { position: sticky; top: 0; z-index: 1000; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
    .header-inner { padding: 10px 15px; display: flex; align-items: center; justify-content: space-between; }
    .site-logo img { max-height: 36px; width: auto; }
    .site-title { font-size: 1.1rem; }

    /* Hamburger Menu */
    .menu-toggle { display: flex !important; flex-direction: column; gap: 5px; padding: 8px; background: none; border: none; cursor: pointer; z-index: 1001; }
    .menu-toggle span { width: 24px; height: 2.5px; background: #333; border-radius: 2px; transition: 0.3s ease; }
    .menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
    .menu-toggle.active span:nth-child(2) { opacity: 0; }
    .menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

    /* Fullscreen Mobile Nav */
    .main-navigation, .primary-menu, .nav-menu { display: none; position: fixed; top: 56px; left: 0; right: 0; bottom: 0; background: #fff; z-index: 999; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; }
    .main-navigation.active, .nav-menu.active { display: block; }
    .main-navigation ul, .nav-menu ul { flex-direction: column; gap: 0; }
    .main-navigation li { border-bottom: 1px solid #f0f0f0; }
    .main-navigation a, .nav-menu a { display: block; padding: 14px 16px; font-size: 1rem; color: #333; text-decoration: none; }
    .main-navigation a:hover { background: #f8f9fa; color: #1565c0; }
    .sub-menu, .dropdown-menu { position: static; box-shadow: none; background: #f8f9fa; padding-left: 20px; }
    .desktop-only, .hide-mobile { display: none !important; }
    .mobile-only, .show-mobile { display: block !important; }

    /* Hero */
    .hero-section { padding: 35px 15px; min-height: auto; text-align: center; }
    .hero-section h1 { font-size: 1.5rem; margin-bottom: 10px; }
    .hero-section p { font-size: 0.9rem; margin-bottom: 15px; }
    .hero-search { flex-direction: column; gap: 10px; }
    .hero-search input, .hero-search button { width: 100%; padding: 14px; border-radius: 8px; }
    .hero-stats { flex-wrap: wrap; gap: 10px; justify-content: center; }
    .hero-stats .stat-item { flex: 0 0 calc(50% - 10px); text-align: center; padding: 10px; }
    .hero-stats .stat-number { font-size: 1.4rem; }
    .hero-stats .stat-label { font-size: 0.75rem; }

    /* Cards & Grids */
    .university-grid, .card-grid { grid-template-columns: 1fr; gap: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .university-card .card-image { height: 160px; object-fit: cover; }
    .university-card .card-body { padding: 14px; }
    .university-card .card-title { font-size: 1rem; line-height: 1.3; }
    .university-card .card-meta { font-size: 0.8rem; display: flex; flex-wrap: wrap; gap: 6px; }
    .university-card .card-meta span { background: #f0f4f8; padding: 3px 8px; border-radius: 4px; font-size: 0.75rem; }
    .badge, .tag, .nirf-badge, .naac-badge { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; }

    /* University Single Page */
    .uni-header { padding: 20px 15px; text-align: center; }
    .uni-header .uni-logo { width: 60px; height: 60px; margin: 0 auto 12px; }
    .uni-header h1 { font-size: 1.3rem; }
    .uni-quick-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 15px 0; }
    .uni-quick-facts .fact { background: #f8f9fa; padding: 10px; border-radius: 8px; text-align: center; }
    .uni-quick-facts .fact-value { font-size: 1.1rem; font-weight: 700; color: #1565c0; display: block; }
    .uni-quick-facts .fact-label { font-size: 0.7rem; color: #666; text-transform: uppercase; letter-spacing: 0.5px; }

    /* Scrollable Tabs */
    .uni-tabs, .tab-navigation { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; border-bottom: 2px solid #e0e0e0; margin: 0 -15px; padding: 0 15px; }
    .uni-tabs::-webkit-scrollbar, .tab-navigation::-webkit-scrollbar { display: none; }
    .uni-tabs .tab, .tab-navigation .tab-link { flex: 0 0 auto; padding: 12px 16px; font-size: 0.85rem; white-space: nowrap; border-bottom: 2px solid transparent; color: #666; text-decoration: none; }
    .uni-tabs .tab.active, .tab-navigation .tab-link.active { color: #1565c0; border-bottom-color: #1565c0; font-weight: 600; }

    /* Ranking Table */
    .ranking-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -15px; padding: 0 15px; }
    .ranking-table { min-width: 600px; font-size: 0.85rem; }

    /* Mobile Ranking Cards */
    .ranking-cards-mobile { display: flex; flex-direction: column; gap: 10px; }
    .ranking-card-mobile { background: #fff; border: 1px solid #e8e8e8; border-radius: 10px; padding: 14px; display: flex; align-items: center; gap: 12px; }
    .ranking-card-mobile .rank-num { flex: 0 0 40px; height: 40px; background: #1565c0; color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }
    .ranking-card-mobile .rank-info { flex: 1; min-width: 0; }
    .ranking-card-mobile .rank-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .ranking-card-mobile .rank-meta { font-size: 0.75rem; color: #888; margin-top: 2px; }

    /* Filter Chips (horizontal scroll) */
    .filter-bar { flex-direction: column; gap: 10px; }
    .filter-bar select, .filter-bar input { width: 100%; padding: 12px; }
    .filter-chips { display: flex; overflow-x: auto; gap: 8px; padding: 10px 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .filter-chips::-webkit-scrollbar { display: none; }
    .filter-chip { flex: 0 0 auto; padding: 8px 16px; border-radius: 20px; background: #f0f0f0; font-size: 0.8rem; white-space: nowrap; border: 1px solid #ddd; cursor: pointer; }
    .filter-chip.active { background: #1565c0; color: #fff; border-color: #1565c0; }

    /* Compare (swipeable) */
    .compare-cards { display: flex; overflow-x: auto; gap: 12px; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; }
    .compare-card { flex: 0 0 280px; scroll-snap-align: start; }

    /* Course Cards */
    .course-grid { grid-template-columns: 1fr; gap: 10px; }
    .course-card { padding: 14px; border-radius: 10px; }
    .course-card .course-details { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
    .course-card .course-tag { font-size: 0.72rem; padding: 3px 8px; background: #e3f2fd; border-radius: 4px; }

    /* Footer */
    .site-footer { padding: 30px 15px 20px; }
    .footer-grid { grid-template-columns: 1fr; gap: 25px; }
    .footer-col ul { columns: 2; column-gap: 15px; }
    .footer-col a { font-size: 0.85rem; padding: 5px 0; display: block; }
    .footer-bottom { flex-direction: column; gap: 10px; text-align: center; font-size: 0.8rem; }

    /* Breadcrumbs */
    .breadcrumb, .breadcrumbs { font-size: 0.75rem; padding: 10px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Pagination */
    .pagination, .nav-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
    .pagination a, .pagination span, .page-numbers { min-width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }

    /* FAQ/Accordion */
    .faq-question, .accordion-header { padding: 14px 16px; font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
    .faq-answer, .accordion-body { padding: 0 16px 14px; font-size: 0.88rem; }

    /* CTA */
    .cta-section { padding: 25px 15px; border-radius: 12px; text-align: center; }
    .cta-buttons { flex-direction: column; gap: 10px; }
    .cta-buttons .btn { width: 100%; }

    /* Reviews */
    .review-card { padding: 14px; }
    .review-stars { font-size: 1rem; }
    .review-meta { font-size: 0.8rem; }

    /* Sticky Bottom Bar */
    .mobile-bottom-bar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; box-shadow: 0 -2px 10px rgba(0,0,0,0.1); z-index: 998; display: flex; justify-content: space-around; padding: 6px 0; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
    .mobile-bottom-bar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.65rem; color: #666; text-decoration: none; padding: 4px 8px; }
    .mobile-bottom-bar a.active { color: #1565c0; }
    body.has-bottom-bar { padding-bottom: 60px; }

    /* Back to top */
    .back-to-top { position: fixed; bottom: 70px; right: 15px; width: 40px; height: 40px; background: #1565c0; color: #fff; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.2); z-index: 997; opacity: 0; transform: translateY(10px); transition: 0.3s; cursor: pointer; }
    .back-to-top.visible { opacity: 1; transform: translateY(0); }
}

/* ═══ SMALL MOBILE: 480px ═══ */
@media (max-width: 480px) {
    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.15rem; }
    .hero-section h1 { font-size: 1.3rem; }
    .stats-grid .stat-number { font-size: 1.2rem; }
    .footer-col ul { columns: 1; }
}

/* ═══ EXTRA SMALL: 360px ═══ */
@media (max-width: 360px) {
    .container, .site-container { padding: 0 12px; }
    h1 { font-size: 1.2rem; } h2 { font-size: 1.05rem; } p { font-size: 0.9rem; }
    .hero-section { padding: 25px 12px; }
    .university-card .card-body { padding: 10px; }
    .uni-tabs .tab { padding: 10px 12px; font-size: 0.8rem; }
}

/* ═══ MINIMUM: 320px ═══ */
@media (max-width: 320px) {
    .container { padding: 0 10px; }
    h1 { font-size: 1.1rem; } h2 { font-size: 1rem; }
    .hero-stats .stat-number { font-size: 1.1rem; }
    .btn, button { padding: 10px 16px; font-size: 0.85rem; }
}

/* ═══ Landscape Mobile ═══ */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section { padding: 25px 20px; min-height: auto; }
    .university-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

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

/* ═══ Print ═══ */
@media print {
    .site-header, .site-footer, .mobile-bottom-bar, .back-to-top, .menu-toggle, .filter-bar, .cta-section { display: none !important; }
    body { font-size: 12pt; color: #000; }
    a { color: #000; text-decoration: underline; }
}
