/* ===================================================
   FINAL MOBILE OPTIMIZATION AND AUDIT FIXES
=================================================== */

html {
    overflow-x: clip;
}

body {
    max-width: 100%;
    overflow-x: clip;
}

main {
    position: relative;
    overflow: clip;
}

.site-banner,
.header,
.navbar,
.hero,
.about-hero,
.academics-hero,
.admissions-hero,
.student-life-hero,
.contact-hero {
    max-width: 100vw;
}

img,
svg,
video,
iframe {
    max-width: 100%;
}

[id] {
    scroll-margin-top: calc(var(--banner-offset, 0px) + 7rem);
}

[class*="-grid"] > *,
[class*="-layout"] > *,
.hero-content,
.section-header,
.banner-copy,
.banner-actions,
.pathway-content,
.leader-content,
.contact-form-panel,
.contact-support-panel {
    min-width: 0;
}

.gallery-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.gallery-filter .filter-btn {
    flex: 0 1 auto;
}

.mobile-menu {
    width: min(100%, 360px);
}

@media (max-width: 1100px) {
    .hero-grid,
    .academics-grid,
    .about-hero-grid,
    .student-hero-grid,
    .admissions-hero-grid,
    .contact-hero-grid,
    .contact-hub-grid,
    .application-layout,
    .requirements-layout,
    .learning-journey-grid,
    .leadership-card,
    .leadership-card.reverse {
        grid-template-columns: 1fr !important;
        gap: 1.75rem !important;
    }

    .hero-grid {
        min-height: auto !important;
        padding-bottom: 4.5rem !important;
    }

    .hero-image,
    .leader-image,
    .about-hero-visual,
    .student-hero-cards,
    .contact-hero-panel {
        order: -1;
    }

    .journey-timeline,
    #academic-journey .journey-timeline {
        overflow-x: auto;
        padding-bottom: 0.85rem;
        scroll-snap-type: x proximity;
    }

    .journey-timeline::-webkit-scrollbar,
    #academic-journey .journey-timeline::-webkit-scrollbar {
        height: 6px;
    }

    .journey-timeline > *,
    #academic-journey .journey-timeline > * {
        scroll-snap-align: start;
    }
}

@media (max-width: 900px) {
    .banner-inner {
        gap: 0.7rem !important;
    }

    .banner-copy p {
        max-width: none;
        line-height: 1.55;
    }

    .banner-link:not(.primary) {
        display: none;
    }

    .nav-actions {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        min-width: 52px;
    }

    .hamburger {
        display: flex !important;
        flex-direction: column;
        margin-left: auto;
    }

    .hero,
    .about-hero,
    .academics-hero,
    .admissions-hero,
    .student-life-hero,
    .contact-hero {
        padding-top: calc(var(--banner-offset, 0px) + 4.75rem) !important;
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 6.75rem;
    }

    section {
        padding: 72px 0 !important;
    }

    .site-banner .container,
    .header .container,
    .hero .container,
    .about-hero .container,
    .academics-hero .container,
    .admissions-hero .container,
    .student-life-hero .container,
    .contact-hero .container {
        width: calc(100vw - 1rem) !important;
    }

    .banner-inner {
        grid-template-columns: 1fr !important;
        padding: 0.7rem 0.8rem 0.8rem !important;
    }

    .banner-pill {
        font-size: 0.68rem;
        letter-spacing: 0.06em;
    }

    .banner-copy {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.45rem !important;
    }

    .banner-copy p {
        font-size: 0.78rem;
    }

    .banner-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.65rem !important;
    }

    .banner-socials {
        order: 0 !important;
        margin-right: 0 !important;
    }

    .banner-social-link {
        width: 36px;
        height: 36px;
    }

    .banner-link {
        width: 100%;
    }

    .navbar {
        grid-template-columns: auto minmax(0, 1fr) auto !important;
        gap: 0.65rem !important;
        padding: 0.55rem 0.65rem !important;
    }

    .nav-actions {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        min-width: 52px;
    }

    .hero-content h1,
    .about-hero-content h1,
    .academics-hero .hero-content h1,
    .admissions-hero .hero-content h1,
    .student-hero-content h1,
    .contact-hero-content h1,
    .gallery-section .section-header h1 {
        max-width: none !important;
        font-size: clamp(1.95rem, 8.8vw, 2.85rem) !important;
        line-height: 1.05 !important;
        letter-spacing: -0.03em;
        overflow-wrap: normal;
        word-break: normal;
        text-wrap: balance;
    }

    .hero .hero-content h1 {
        max-width: 8ch !important;
    }

    .hero .hero-content h1 span {
        display: block;
    }

    .about-hero-content h1 {
        max-width: 11ch !important;
    }

    .academics-hero .hero-content h1 {
        max-width: 10ch !important;
    }

    .admissions-hero .hero-content h1 {
        max-width: 9ch !important;
    }

    .contact-hero-content h1 {
        max-width: 11ch !important;
    }

    .hero-content p,
    .about-hero-content p,
    .academics-hero .hero-content p,
    .admissions-hero .hero-description,
    .student-hero-content p,
    .contact-hero-content p,
    .section-header p,
    .journey-description,
    .testimonial-card p {
        font-size: 0.96rem !important;
        line-height: 1.72 !important;
        overflow-wrap: anywhere;
    }

    .hero-badge,
    .section-tag {
        max-width: 100%;
        white-space: normal;
        line-height: 1.35;
    }

    .hero-buttons,
    .cta-buttons,
    .transport-actions {
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .hero-buttons .btn,
    .cta-buttons .btn,
    .transport-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .hero-stats,
    .academics-grid,
    .academics-hero .hero-stats,
    .admissions-hero-summary,
    .student-hero-cards,
    .contact-form-grid,
    .quick-contact-grid,
    .download-grid,
    .policy-grid,
    .fee-notes-grid,
    .values-grid,
    .vision-grid,
    .vm-grid,
    .gallery-grid,
    .features-grid,
    .programs-grid,
    .clubs-grid,
    .approach-grid,
    .stats-grid,
    .transport-highlights,
    .why-grid,
    .cbc-grid,
    .activities-grid,
    .csl-grid,
    .info-grid,
    .experience-grid,
    .environment-grid,
    .pathway-grid,
    .footer-grid {
        grid-template-columns: 1fr !important;
    }

    .hero-image,
    .leader-image,
    .about-hero-visual,
    .academics-hero .hero-image,
    .admissions-hero .hero-image,
    .student-hero-cards,
    .contact-hero-panel {
        order: initial !important;
    }

    .feature-card,
    .info-card,
    .cbc-card,
    .pathway-card,
    .policy-card,
    .download-card,
    .testimonial-card,
    .contact-form-panel,
    .contact-support-panel,
    .value-card,
    .values-story-card,
    .transport-shell,
    .journey-card,
    .leadership-card,
    .quick-card,
    .visit-card,
    .wellbeing-card,
    .support-card {
        padding: 1.35rem !important;
        border-radius: 24px !important;
    }

    .hero-stats .stat,
    .hero-stats .stat-card,
    .admissions-hero-summary .summary-item {
        min-width: 0 !important;
    }

    .about-floating-card,
    .floating-card,
    .academics-hero .floating-card,
    .cbe-philosophy .floating-card,
    .admissions-hero-note,
    .admissions-hero-aside {
        position: static !important;
        inset: auto !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        margin-top: 1rem !important;
    }

    .academics-hero .hero-image,
    .admissions-hero .hero-image {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .academics-hero .floating-card,
    .admissions-hero-note,
    .admissions-hero-aside {
        display: none !important;
    }

    .contact-hero-card li {
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: start !important;
        justify-content: flex-start !important;
    }

    .about-image-main img,
    .leader-image img,
    .hero-image img,
    .admissions-hero .hero-image img,
    #student-life-journey .journey-image img,
    .transport-photo-card,
    .gallery-item img,
    .activity-card img,
    .image-card img {
        min-height: 0 !important;
        height: clamp(220px, 62vw, 360px) !important;
    }

    .gallery-masonry {
        columns: 1 !important;
        gap: 1rem !important;
    }

    .quick-action-rail {
        width: calc(100vw - 1.5rem) !important;
        max-width: calc(100vw - 1.5rem) !important;
        left: 0.75rem !important;
        right: auto !important;
        top: auto !important;
        bottom: 0.75rem !important;
        grid-auto-flow: row !important;
        transform: none !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.45rem !important;
    }

    .quick-action-btn {
        width: 100%;
        min-height: 50px !important;
        min-width: 0 !important;
        padding: 0.75rem 0.35rem !important;
        font-size: 0.68rem !important;
        letter-spacing: 0.05em !important;
    }

    .command-toggle {
        display: none !important;
    }

    .back-to-top {
        right: 0.75rem !important;
        bottom: 7.25rem !important;
        transform: none !important;
    }
}

@media (max-width: 576px) {
    body {
        padding-bottom: 9rem;
    }

    .banner-inner {
        padding: 0.65rem 0.7rem 0.75rem !important;
        border-radius: 0 0 20px 20px !important;
    }

    .banner-actions {
        width: 100%;
        justify-content: flex-start !important;
    }

    .hero,
    .about-hero,
    .academics-hero,
    .admissions-hero,
    .student-life-hero,
    .contact-hero {
        padding-top: calc(var(--banner-offset, 0px) + 4rem) !important;
    }

    .logo {
        width: 58px !important;
        min-width: 58px !important;
    }

    .logo img {
        width: 48px !important;
        height: 48px !important;
    }

    .navbar {
        min-height: 64px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    .hero-content h1,
    .about-hero-content h1,
    .academics-hero .hero-content h1,
    .admissions-hero .hero-content h1,
    .student-hero-content h1,
    .contact-hero-content h1,
    .gallery-section .section-header h1 {
        font-size: clamp(1.5rem, 7.8vw, 2.1rem) !important;
    }

    .hero .hero-content h1 {
        font-size: clamp(1.68rem, 8.2vw, 2.2rem) !important;
    }

    .academics-hero .hero-image,
    .admissions-hero .hero-image {
        display: none !important;
    }

    .hamburger {
        min-width: 88px !important;
        padding-inline: 0.9rem !important;
    }

    .hamburger span {
        display: none !important;
    }

    .hamburger::after {
        content: 'Menu';
        color: #fff;
        font-size: 0.8rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .mobile-menu {
        width: 100% !important;
        padding: 1.25rem !important;
    }

    .mobile-menu a {
        padding: 0.9rem 1rem;
        font-size: 1rem !important;
    }

    .quick-action-rail {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .back-to-top {
        width: 48px;
        height: 48px;
        bottom: 9.4rem !important;
    }
}
