/* ========== Responsive Design ========== */

/* Global: prevent accidental horizontal overflow on any breakpoint */
html, body { overflow-x: hidden; }

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .carousel-item:active {
        transform: scale(0.95);
    }

    .level-item:active {
        transform: scale(0.96) translateY(-4px);
    }

    .search-btn:active,
    .carousel-btn:active {
        transform: scale(0.92);
    }

    .nav-toggle:active {
        transform: scale(0.94);
    }

    /* Better touch targets */
    .carousel-item {
        min-height: 44px;
    }

    .level-item {
        min-height: 44px;
    }
}

/* Large Screens (Laptop/Desktop) */
@media (max-width: 1200px) {
    :root {
        --carousel-items-visible: 4;
    }

    .nav-container {
        padding: 0 1.8rem;
    }

    .levels-container {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 2rem;
    }

    .carousel-section {
        max-width: 580px;
    }

    .search-container {
        max-width: 580px;
    }
}

/* Medium Screens (Small Laptop/Tablet) */
@media (max-width: 900px) {
    :root {
        --carousel-items-visible: 4;
    }

    .nav-container {
        padding: 0 1rem;
        align-items: center;
        gap: 0.4rem;
    }

    .nav-toggle {
        display: inline-flex;
    }

    /* Compact top-nav: keep icons, hide labels; sidebar (if present) still opens via hamburger */
    .nav-right {
        gap: 0.55rem;
        margin-left: auto;
        flex-wrap: nowrap;
        overflow: visible;
    }

    .nav-right .nav-link {
        font-size: 0;
        padding: 0.4rem;
    }

    .nav-right .nav-link i:first-child {
        font-size: 1.2rem;
    }

    /* Mobile dropdown: full-width sheet below the navbar */
    .nav-right .dropdown-menu {
        position: fixed;
        left: 8px;
        right: 8px;
        top: calc(var(--nav-height, 50px) + 6px);
        min-width: 0;
        max-height: calc(100vh - var(--nav-height, 50px) - 24px);
        overflow-y: auto;
        transform: translateY(-8px) !important;
    }

    .nav-right .nav-dropdown:hover .dropdown-menu,
    .nav-right .nav-dropdown:focus-within .dropdown-menu,
    .nav-right .nav-dropdown.open .dropdown-menu {
        transform: translateY(0) !important;
    }

    .nav-right .dropdown-item {
        font-size: 0.95rem;
        padding: 0.7rem 0.85rem;
    }

    .carousel-section {
        max-width: 520px;
        gap: 1rem;
    }
}


/* Tablet Landscape */
@media (max-width: 1024px) and (orientation: landscape) {
    :root {
        --carousel-items-visible: 4;
    }

    .search-section {
        padding: 1.8rem 1.5rem;
        margin-top: 3.5rem;
    }

    .carousel-section {
        max-width: 650px;
    }

    .search-container {
        max-width: 650px;
    }

    .levels-container {
        grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
        gap: 1.8rem;
    }

    .level-icon {
        width: 70px;
        height: 70px;
    }

    .level-icon i {
        font-size: 1.75rem;
    }
}

/* Tablet (Large Tablet) */
@media (max-width: 768px) {
    :root {
        --carousel-items-visible: 4;
        --carousel-gap: 0.9rem;
    }

    .nav-container {
        padding: 0 1rem;
    }

    .brand-name {
        font-size: 1.25rem;
    }

    .logo-icon {
        font-size: 1.6rem;
    }

    .search-section {
        padding: 2rem 1.3rem 1.8rem;
        margin-top: 3.8rem;
    }

    .search-container {
        max-width: 520px;
        margin: 0.8rem auto 1.5rem;
        padding: 0.2rem 0.2rem 0.2rem 1rem;
    }

    .search-icon {
        font-size: 1.1rem;
        margin-right: 0.6rem;
    }

    .search-box {
        font-size: 0.9rem;
        padding: 0.7rem 0.35rem;
    }

    .search-btn {
        width: 40px;
        height: 40px;
        font-size: 0.88rem;
    }

    .voice-icon {
        font-size: 1rem;
        margin: 0 0.6rem;
    }

    .carousel-section {
        gap: 1rem;
        max-width: 520px;
        padding: 0.3rem 0;
    }

    .carousel-container {
        padding: 0.6rem 0;
    }

    .carousel-track {
        gap: var(--carousel-gap);
    }

    .carousel-item {
        padding: 0.4rem;
    }

    .carousel-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 0.45rem;
    }

    .carousel-icon i {
        font-size: 1.25rem;
    }

    .carousel-label {
        font-size: 0.78rem;
    }

    .carousel-btn {
        width: 32px;
        height: 32px;
    }

    .carousel-btn i {
        font-size: 0.85rem;
    }

    .section-title {
        font-size: 1.9rem;
    }

    .levels-container {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 1.8rem 1.2rem;
    }

    .level-item {
        padding: 0.6rem 0.35rem;
    }

    .level-icon {
        width: 66px;
        height: 66px;
    }

    .level-icon i {
        font-size: 1.65rem;
    }

    .level-name {
        font-size: 0.88rem;
    }

    .education-levels {
        margin: 0.8rem auto;
        padding: 2.4rem 1.8rem;
    }

    .levels-title {
        font-size: 1.5rem;
    }

    .levels-subtitle {
        font-size: 1rem;
    }

    .levels-back-btn {
        font-size: 0.88rem;
        width: 40px;
        height: 40px;
        padding: 0;
    }

    .levels-back-btn i {
        font-size: 0.92rem;
    }

    .footer-container {
        padding: 0 1.3rem;
    }

    .footer-left p {
        font-size: 0.85rem;
    }

    .footer-right a {
        font-size: 0.85rem;
    }
}

/* Medium Mobile (Small Tablet) */
@media (max-width: 600px) {
    :root {
        --carousel-items-visible: 4;
        --carousel-gap: 0.5rem;
    }

    .search-section {
        padding: 1.8rem 1.2rem 1.6rem;
        margin-top: 3.5rem;
    }

    .search-container {
        max-width: 100%;
        margin: 0.75rem auto 1.3rem;
        padding: 0.18rem 0.18rem 0.18rem 0.95rem;
    }

    .carousel-section {
        gap: 0.4rem;
        max-width: 100%;
        padding: 0.25rem 0.7rem;
        flex-direction: row;
        align-items: center;
    }

    .carousel-btn {
        display: flex;
        width: 30px;
        height: 30px;
        flex-shrink: 0;
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid rgba(37, 99, 235, 0.25);
        box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2);
        backdrop-filter: blur(8px);
    }

    .carousel-btn i {
        font-size: 0.8rem;
        color: var(--primary-color);
    }

    .carousel-container {
        flex: 1;
        overflow: hidden;
        position: relative;
    }

    .carousel-track {
        display: flex;
        gap: var(--carousel-gap);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .carousel-item {
        padding: 0.35rem 0.2rem;
        flex-shrink: 0;
    }

    .carousel-icon {
        width: 43px;
        height: 43px;
        margin-bottom: 0.38rem;
    }

    .carousel-icon i {
        font-size: 1.15rem;
    }

    .carousel-label {
        font-size: 0.72rem;
    }

    .levels-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.8rem 1rem;
        padding: 0.2rem 0.1rem;
    }

    .level-icon {
        width: 66px;
        height: 66px;
    }

    .level-icon i {
        font-size: 1.65rem;
    }

    .level-name {
        font-size: 0.88rem;
    }

    .education-levels {
        margin: 0.4rem 0.55rem;
        padding: 1.2rem 0.75rem 1rem;
    }

    .levels-heading {
        margin-bottom: 0.5rem;
        gap: 0.25rem;
    }

    .levels-title {
        font-size: 1.4rem;
        max-width: 100%;
        line-height: 1.25;
        word-break: break-word;
    }

    .levels-subtitle {
        font-size: 0.95rem;
    }

    .levels-toolbar {
        margin: 0;
    }

    .footer {
        display: none;
    }
}

/* Mobile (Standard Mobile - 450px) */
@media (max-width: 450px) {
    :root {
        --carousel-gap: 0.6rem;
        --carousel-items-visible: 4;
    }

    .carousel-section {
        gap: 0.4rem;
        padding: 0.2rem 0.8rem;
    }

    .carousel-btn {
        width: 32px;
        height: 32px;
    }

    .carousel-btn i {
        font-size: 0.8rem;
    }

    .carousel-container {
        overflow: hidden;
    }

    .carousel-track {
        display: flex;
        gap: var(--carousel-gap);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .carousel-item {
        padding: 0.4rem 0.25rem;
        flex-shrink: 0;
    }

    .carousel-icon {
        width: 46px;
        height: 46px;
        margin-bottom: 0.42rem;
    }

    .carousel-icon i {
        font-size: 1.22rem;
    }

    .carousel-label {
        font-size: 0.74rem;
        line-height: 1.25;
    }
}

/* Mobile (Standard Mobile) */
@media (max-width: 480px) {
    :root {
        --carousel-gap: 0.45rem;
        --carousel-items-visible: 4;
    }

    body {
        padding-bottom: 100px;
    }

    .nav-container {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    .nav-left {
        flex-direction: row;
        text-align: center;
        gap: 0.8rem;
    }

    .brand-name {
        font-size: 1.15rem;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    .nav-right {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    .nav-toggle {
        margin-left: auto;
        width: auto;
        height: auto;
    }

    .nav-toggle i {
        font-size: 1.25rem;
    }

    .dropdown-item {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .search-section {
        padding: 1.6rem 1rem 1.4rem;
        margin-top: 2.8rem;
    }

    .search-container {
        max-width: 100%;
        margin: 0.7rem auto 1.3rem;
        padding: 0.18rem 0.18rem 0.18rem 0.9rem;
        border-radius: 45px;
    }

    .search-icon {
        font-size: 1.05rem;
        margin-right: 0.55rem;
    }

    .search-box {
        font-size: 0.88rem;
        padding: 0.68rem 0.3rem;
    }

    .search-box::placeholder {
        font-size: 0.86rem;
    }

    .search-btn {
        width: 38px;
        height: 38px;
        font-size: 0.85rem;
    }

    .voice-icon {
        font-size: 0.98rem;
        margin: 0 0.52rem;
    }

    .carousel-section {
        flex-direction: row;
        gap: 0.35rem;
        max-width: 100%;
        padding: 0.2rem 0.6rem;
        align-items: center;
    }

    .carousel-btn {
        display: flex;
        flex-shrink: 0;
        width: 30px;
        height: 30px;
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid rgba(37, 99, 235, 0.25);
        box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2);
        z-index: 10;
        position: relative;
        backdrop-filter: blur(8px);
    }

    .carousel-btn i {
        font-size: 0.78rem;
        color: var(--primary-color);
    }

    .carousel-btn:active {
        transform: scale(0.9);
        background: var(--primary-color);
    }

    .carousel-btn:active i {
        color: white;
    }

    .carousel-btn.carousel-prev {
        animation: pulseLeft 2s ease-in-out infinite;
    }

    .carousel-btn.carousel-next {
        animation: pulseRight 2s ease-in-out infinite;
    }

    @keyframes pulseLeft {
        0%, 100% {
            box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2);
        }
        50% {
            box-shadow: -3px 3px 15px rgba(37, 99, 235, 0.4);
        }
    }

    @keyframes pulseRight {
        0%, 100% {
            box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2);
        }
        50% {
            box-shadow: 3px 3px 15px rgba(37, 99, 235, 0.4);
        }
    }

    .carousel-container {
        overflow: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: none;
        padding: 0.5rem 0 0.6rem;
        flex: 1;
        scroll-behavior: smooth;
        position: relative;
    }

    .carousel-track {
        gap: var(--carousel-gap);
        padding: 0;
        display: flex;
        justify-content: flex-start;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .carousel-item {
        padding: 0.32rem 0.15rem;
        border-radius: 12px;
        flex-shrink: 0;
    }

    .carousel-icon {
        width: 42px;
        height: 42px;
        margin-bottom: 0.38rem;
    }

    .carousel-icon i {
        font-size: 1.12rem;
    }

    .carousel-label {
        font-size: 0.7rem;
        line-height: 1.22;
    }

    .carousel-container::-webkit-scrollbar {
        display: none;
    }

    .section-title {
        font-size: 1.6rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .section-title i {
        font-size: 1.8rem;
    }

    .levels-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.6rem 0.9rem;
        padding: 0.2rem 0.15rem;
    }

    .level-item {
        padding: 0.7rem 0.25rem;
    }

    .level-icon {
        width: 62px;
        height: 62px;
        margin-bottom: 0.7rem;
    }

    .level-icon i {
        font-size: 1.55rem;
    }

    .level-name {
        font-size: 0.84rem;
        line-height: 1.25;
    }

    .education-levels {
        margin: 0.4rem 0.45rem;
        padding: 1.15rem 0.65rem 0.9rem;
        border-radius: 14px;
    }

    .levels-heading {
        margin-bottom: 0.45rem;
        gap: 0.2rem;
    }

    .levels-title {
        font-size: 1.35rem;
    }

    .levels-subtitle {
        font-size: 0.92rem;
    }

    .levels-divider {
        max-width: 320px;
    }

    .levels-toolbar {
        margin: 0;
    }

    .levels-back-btn {
        font-size: 0.82rem;
        width: 36px;
        height: 36px;
        padding: 0;
    }

    .levels-back-btn i {
        font-size: 0.86rem;
    }

    .lesson-details {
        padding: 1.4rem 1.3rem;
        border-radius: 14px;
    }

    .lesson-details-title {
        font-size: 1.2rem;
        margin-bottom: 0.7rem;
    }

    .lesson-details-text {
        font-size: 0.94rem;
        line-height: 1.5;
    }

    .footer {
        padding: 0.8rem 0;
    }

    .footer-container {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        padding: 0 1rem;
    }

    .footer-left {
        flex-direction: column;
        gap: 0.3rem;
    }

    .footer-left p {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .footer-right {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.8rem 1.2rem;
    }

    .footer-right a {
        font-size: 0.8rem;
    }
}

/* Extra Small Mobile (Small Phones) */
@media (max-width: 360px) {
    :root {
        --carousel-gap: 0.4rem;
        --carousel-items-visible: 4;
    }

    .nav-container {
        padding: 0.5rem 0.75rem;
    }

    .carousel-section {
        padding: 0.2rem 0.5rem;
        gap: 0.3rem;
        align-items: center;
    }

    .carousel-btn {
        width: 28px;
        height: 28px;
    }

    .carousel-btn i {
        font-size: 0.75rem;
    }

    .carousel-container {
        overflow: hidden;
    }

    .carousel-track {
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .carousel-item {
        padding: 0.3rem 0.14rem;
        flex-shrink: 0;
    }

    .carousel-icon {
        width: 38px;
        height: 38px;
        margin-bottom: 0.32rem;
    }

    .carousel-icon i {
        font-size: 1.05rem;
    }

    .carousel-label {
        font-size: 0.66rem;
        line-height: 1.18;
    }

    .brand-name {
        font-size: 1.08rem;
    }

    .logo-icon {
        font-size: 1.4rem;
    }

    .nav-toggle {
        width: auto;
        height: auto;
    }

    .nav-toggle i {
        font-size: 1.2rem;
    }

    .search-section {
        padding: 1.4rem 0.9rem 1.2rem;
        margin-top: 2.6rem;
    }

    .search-container {
        margin: 0.65rem auto 1.2rem;
        padding: 0.15rem 0.15rem 0.15rem 0.85rem;
        border-radius: 40px;
    }

    .search-icon {
        font-size: 1rem;
        margin-right: 0.5rem;
    }

    .search-box {
        font-size: 0.85rem;
        padding: 0.65rem 0.28rem;
    }

    .search-box::placeholder {
        font-size: 0.83rem;
    }

    .search-btn {
        width: 36px;
        height: 36px;
        font-size: 0.82rem;
    }

    .voice-icon {
        font-size: 0.92rem;
        margin: 0 0.48rem;
    }

    .carousel-container {
        padding: 0.45rem 0 0.55rem;
    }

    .carousel-track {
        gap: var(--carousel-gap);
        padding: 0 0.25rem;
    }

    .carousel-item {
        flex: 0 0 88px;
        min-width: 88px;
        max-width: 88px;
        padding: 0.4rem 0.3rem;
        border-radius: 12px;
    }

    .carousel-icon {
        width: 42px;
        height: 42px;
        margin-bottom: 0.4rem;
    }

    .carousel-icon i {
        font-size: 1.15rem;
    }

    .carousel-label {
        font-size: 0.72rem;
        line-height: 1.25;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .levels-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.3rem 0.7rem;
        padding: 0.2rem 0.1rem;
    }

    .level-item {
        padding: 0.6rem 0.2rem;
    }

    .level-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 0.6rem;
    }

    .level-icon i {
        font-size: 1.4rem;
    }

    .level-name {
        font-size: 0.78rem;
        line-height: 1.22;
    }

    .education-levels {
        margin: 0.35rem 0.35rem;
        padding: 1rem 0.55rem 0.85rem;
        border-radius: 12px;
    }

    .levels-heading {
        margin-bottom: 0.4rem;
        gap: 0.18rem;
    }

    .levels-title {
        font-size: 1.25rem;
    }

    .levels-subtitle {
        font-size: 0.88rem;
    }

    .levels-toolbar {
        margin: 0;
    }

    .levels-back-btn {
        font-size: 0.78rem;
        width: 34px;
        height: 34px;
        padding: 0;
    }

    .levels-back-btn i {
        font-size: 0.82rem;
    }

    .lesson-details {
        padding: 1.2rem 1.1rem;
        border-radius: 12px;
    }

    .lesson-details-title {
        font-size: 1.12rem;
        margin-bottom: 0.65rem;
    }

    .lesson-details-text {
        font-size: 0.9rem;
        line-height: 1.48;
    }

    .footer {
        padding: 0.75rem 0;
    }

    .footer-container {
        padding: 0 0.85rem;
        gap: 0.7rem;
    }

    .footer-left p {
        font-size: 0.76rem;
        line-height: 1.35;
    }

    .footer-right {
        gap: 0.7rem 1rem;
    }

    .footer-right a {
        font-size: 0.76rem;
    }
}

/* Very Small Mobile (320px and below) */
@media (max-width: 320px) {
    :root {
        --carousel-gap: 0.35rem;
        --carousel-items-visible: 4;
    }

    .nav-container {
        padding: 0.45rem 0.65rem;
    }

    .carousel-section {
        padding: 0.2rem 0.45rem;
        gap: 0.28rem;
        align-items: center;
    }

    .carousel-btn {
        width: 26px;
        height: 26px;
    }

    .carousel-btn i {
        font-size: 0.72rem;
    }

    .carousel-container {
        overflow: hidden;
    }

    .carousel-track {
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .carousel-item {
        padding: 0.28rem 0.12rem;
        flex-shrink: 0;
    }

    .carousel-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 0.3rem;
    }

    .carousel-icon i {
        font-size: 1rem;
    }

    .carousel-label {
        font-size: 0.63rem;
        line-height: 1.16;
    }

    .brand-name {
        font-size: 1.02rem;
    }

    .logo-icon {
        font-size: 1.3rem;
    }

    .nav-toggle {
        width: auto;
        height: auto;
    }

    .nav-toggle i {
        font-size: 1.15rem;
    }

    .search-section {
        padding: 1.3rem 0.8rem 1.1rem;
        margin-top: 2.4rem;
    }

    .search-container {
        margin: 0.6rem auto 1.1rem;
        padding: 0.12rem 0.12rem 0.12rem 0.8rem;
    }

    .search-icon {
        font-size: 0.95rem;
        margin-right: 0.45rem;
    }

    .search-box {
        font-size: 0.82rem;
        padding: 0.62rem 0.25rem;
    }

    .search-btn {
        width: 34px;
        height: 34px;
        font-size: 0.8rem;
    }

    .voice-icon {
        font-size: 0.88rem;
        margin: 0 0.45rem;
    }

    .carousel-track {
        gap: var(--carousel-gap);
        padding: 0 0.2rem;
    }

    .carousel-item {
        flex: 0 0 82px;
        min-width: 82px;
        max-width: 82px;
        padding: 0.38rem 0.28rem;
    }

    .carousel-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 0.38rem;
    }

    .carousel-icon i {
        font-size: 1.1rem;
    }

    .carousel-label {
        font-size: 0.7rem;
    }

    .levels-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.1rem 0.6rem;
        padding: 0.2rem 0.1rem;
    }

    .level-item {
        padding: 0.5rem 0.15rem;
    }

    .level-icon {
        width: 52px;
        height: 52px;
        margin-bottom: 0.55rem;
    }

    .level-icon i {
        font-size: 1.3rem;
    }

    .level-name {
        font-size: 0.75rem;
    }

    .education-levels {
        margin: 0.3rem 0.3rem;
        padding: 0.9rem 0.5rem 0.8rem;
    }

    .levels-heading {
        margin-bottom: 0.35rem;
        gap: 0.16rem;
    }

    .levels-title {
        font-size: 1.18rem;
    }

    .levels-subtitle {
        font-size: 0.86rem;
    }

    .levels-toolbar {
        margin: 0;
    }

    .footer-left p {
        font-size: 0.73rem;
    }

    .footer-right a {
        font-size: 0.73rem;
    }
}

/* Mobile carousel: always show 3 icons and fit them */
@media (max-width: 600px) {
    :root {
        --carousel-items-visible: 4;
    }

    .carousel-track {
        justify-content: space-between;
    }

    .carousel-item {
        flex: 0 0 calc((100% - (var(--carousel-gap) * (var(--carousel-items-visible) - 1))) / var(--carousel-items-visible));
        min-width: 0;
        max-width: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   GLOBAL RESPONSIVE POLISH — applied site-wide for every hub, sub-hub,
   auth and privacy page linked from the right-side dropdown menus.
   Ensures phones (320-480px), tablets (480-1024px) and desktops all
   render consistently without horizontal scroll or clipped UI.
   ═══════════════════════════════════════════════════════════════════ */

/* Prevent accidental horizontal scroll on every page + smooth scroll */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, canvas { max-width: 100%; height: auto; }
table { max-width: 100%; }

/* Tap-to-open dropdown (activated by nav-toggle.js on mobile/touch) */
.nav-right .nav-dropdown.open > .dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

/* ─── LARGE TABLET (≤ 1024px) ─────────────────────────────────────── */
@media (max-width: 1024px) {
    /* Every hub uses a max-width 1280 wrap; shrink padding on tablets */
    .ah-wrap, .eh-wrap, .th-wrap, .jh-wrap { padding-left: 20px; padding-right: 20px; }

    /* Any grid-with-2-columns collapses to 1 on tablet */
    .ah-hero-inner, .eh-hero-inner, .th-hero-inner { gap: 30px; }

    /* Ensure section cards never exceed viewport width */
    .ah-streams, .eh-types, .th-courses-grid { max-width: 100%; }
}

/* ─── SMALL TABLET (≤ 900px) ─────────────────────────────────────── */
@media (max-width: 900px) {
    /* Hero split → stacked */
    .ah-hero-inner, .eh-hero-inner, .th-hero-inner {
        grid-template-columns: 1fr !important;
        text-align: left;
    }
    .ah-hero-art, .eh-hero-art, .th-hero-art { height: 280px; margin-top: 8px; }

    /* Steps: 4-col → 2-col */
    .ah-steps-grid, .eh-steps-grid, .th-steps-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .ah-steps-grid::before, .eh-steps-grid::before, .th-steps-grid::before { display: none; }

    /* Two-column feed → stacked */
    .ah-2col, .eh-2col, .th-2col {
        grid-template-columns: 1fr !important;
        gap: 26px;
    }

    /* Teacher ID card + info side-by-side → stacked */
    .th-id-grid { grid-template-columns: 1fr !important; }

    /* Section vertical rhythm tightens */
    .ah-section, .eh-section, .th-section { padding: 46px 0; }
    .ah-steps, .eh-steps { padding: 46px 0; }

    /* Hero H1 scales down */
    .ah-hero h1, .eh-hero h1, .th-hero h1 { font-size: clamp(26px, 5vw, 38px); }
    .ah-h2, .eh-h2, .th-h2 { font-size: clamp(22px, 4vw, 30px); }
}

/* ─── PHONE LANDSCAPE / SMALL TABLET PORTRAIT (≤ 640px) ─────────── */
@media (max-width: 640px) {
    /* Card grids: force single-column on phones so nothing overflows */
    .ah-streams, .eh-types, .th-courses-grid, .ah-feat-grid {
        grid-template-columns: 1fr !important;
    }
    .eh-subs { grid-template-columns: repeat(2, 1fr) !important; }

    /* Exam-row (badge + body + status + button) → 2 rows */
    .ah-exam-row, .eh-exam-row, .th-exam-row {
        grid-template-columns: auto 1fr !important;
        gap: 12px !important;
    }
    .ah-exam-status, .eh-exam-status, .th-exam-status,
    .ah-exam-row .ah-btn, .eh-exam-row .eh-btn, .th-exam-row .th-btn {
        grid-column: 1 / -1 !important;
        justify-self: flex-start !important;
        margin-top: 4px !important;
    }

    /* Chips */
    .ah-hero-chips, .eh-hero-chips, .th-hero-chips { gap: 14px !important; }
    .ah-hero-chip .n, .eh-hero-chip .n, .th-hero-chip .n { font-size: 20px !important; }

    /* Tap-target size safeguard (WCAG 2.5.5) */
    .ah-btn, .eh-btn, .th-btn, .nav-link, .dropdown-item,
    .sidebar-link, .footer-right a {
        min-height: 40px;
    }

    /* Footer text stacks & centres nicely */
    .footer-container { flex-direction: column !important; text-align: center; gap: 8px; }
    .footer-right { justify-content: center; flex-wrap: wrap; }
}

/* ─── PHONE PORTRAIT (≤ 480px) ─────────────────────────────────── */
@media (max-width: 480px) {
    .ah-wrap, .eh-wrap, .th-wrap, .jh-wrap { padding-left: 16px; padding-right: 16px; }
    .ah-hero, .eh-hero, .th-hero { padding: 34px 0 44px; }
    .ah-hero-icon, .eh-hero-icon, .th-hero-icon {
        width: 120px !important; height: 120px !important;
        font-size: 50px !important; border-radius: 28px !important;
    }
    .ah-float-card, .eh-float-card, .th-float-card {
        font-size: 11px !important; padding: 7px 11px !important;
    }
    .ah-cta h2, .eh-cta h2, .th-cta h2 { font-size: 24px !important; }
    .ah-cta, .eh-cta, .th-cta { padding: 50px 0 !important; }

    /* Sub-page cards typically use 400px min-width grids — force 1-col */
    .stats, .cards-grid, .card-grid, .subject-grid,
    .prize-grid, .training-grid, .quiz-grid, .test-grid {
        grid-template-columns: 1fr !important;
    }

    /* Auth pages (login/register) */
    .auth-shell, .auth-card, .register-shell, .login-shell {
        padding: 24px 18px !important;
    }
    .bp-card { padding: 30px 22px !important; }
    .bp-card h1 { font-size: 1.65rem !important; }
}

/* ─── SMALL PHONE (≤ 380px) ─────────────────────────────────────── */
@media (max-width: 380px) {
    .ah-wrap, .eh-wrap, .th-wrap, .jh-wrap { padding-left: 12px; padding-right: 12px; }
    .ah-hero h1, .eh-hero h1, .th-hero h1 { font-size: 22px !important; }
    .ah-h2, .eh-h2, .th-h2 { font-size: 20px !important; }
    .ah-lead, .eh-lead, .th-lead { font-size: 14px !important; }
    .brand-name { font-size: 1.1rem !important; }
    .logo-icon { font-size: 1.35rem !important; }
    .eh-subs { grid-template-columns: 1fr !important; }
    .th-steps-grid, .ah-steps-grid, .eh-steps-grid {
        grid-template-columns: 1fr !important; gap: 16px !important;
    }
}

/* ─── TOUCH DEVICES — dropdowns respond to tap ─────────────────── */
@media (hover: none) and (pointer: coarse) {
    /* Kill the hover-open effect so tap-to-open (via JS .open class) wins */
    .nav-right .nav-dropdown:hover > .dropdown-menu {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
    .nav-right .nav-dropdown.open > .dropdown-menu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

/* ─── ALLOW LONG NAV BAR TO SCROLL IF STILL TOO WIDE ───────────── */
@media (max-width: 900px) {
    .nav-right {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .nav-right::-webkit-scrollbar { display: none; }
}

