/* assets/css/responsive.css */
/* Comprehensive Tablet & Mobile Responsive Rules */

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

@media (max-width: 1240px) {
    .nav-link {
        padding: 0.42rem 0.65rem;
        font-size: 0.84rem;
    }

    .mega-subgroups-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1200px) {
    /* Keep the five-column homepage rhythm from the reference at laptop width. */
    .category-section > .container,
    .hero-section > .container {
        padding-left: 3rem;
        padding-right: 3rem;
    }

    .category-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .category-card {
        gap: 0.6rem;
        padding: 0.75rem;
        border-radius: 12px;
    }

    .category-card-icon,
    .category-card-svg-icon {
        width: 40px;
        height: 40px;
    }

    .category-card-name {
        font-size: 0.76rem;
    }

    .popular-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (min-width: 993px) and (max-width: 1200px) {
    .hero-grid {
        grid-template-columns: minmax(0, 1.15fr) 390px;
        gap: 2rem;
        max-width: 100%;
    }

    .hero-title {
        font-size: 3rem;
    }

    .hero-calc-wrapper {
        width: 390px;
    }

    .hero-calc-fluid-bg {
        width: 500px;
        height: 520px;
        top: -40px;
        left: -55px;
    }

    .promo-banner-section {
        grid-template-columns: 280px 1fr 210px;
        gap: 1.5rem;
        padding: 2rem;
    }
}

@media (max-width: 900px) {
    .category-section > .container,
    .hero-section > .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .popular-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .site-navigation {
        display: none;
    }

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

    .categories-mega-menu {
        width: 96vw;
    }

    .mega-menu-grid {
        grid-template-columns: 245px minmax(0, 1fr);
    }

    .mega-category-panel.active {
        grid-template-columns: minmax(0, 1fr);
    }

    .mega-panel-promo,
    .mega-menu-promo {
        display: none;
    }
}

@media (max-width: 992px) {
    .hero-section {
        overflow-x: hidden;
    }

    .hero-grid {
        grid-template-columns: 1fr;
        gap: 2.25rem;
    }

    .hero-calc-wrapper {
        width: 100%;
        max-width: 440px;
        margin: 0 auto;
    }

    .hero-calc-fluid-bg {
        width: 100%;
        max-width: 460px;
        height: 440px;
        top: -20px;
        left: 50%;
        transform: translateX(-50%);
    }

    .hero-quick-calc-card {
        margin-left: 0;
        max-width: 100%;
    }

    .hero-title {
        font-size: 2.65rem;
    }

    .categories-mega-menu {
        width: 95vw;
    }

    .mega-menu-grid {
        grid-template-columns: 260px minmax(0, 1fr);
    }

    .mega-subgroups-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mega-category-panel.active {
        grid-template-columns: 1fr;
    }

    .mega-panel-promo,
    .mega-menu-promo {
        display: none;
    }

    .promo-banner-section {
        grid-template-columns: 1fr;
        padding: 2.5rem;
        gap: 2rem;
    }

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

    .popular-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .calc-workbench-grid {
        grid-template-columns: 1fr;
    }

    .calc-info-section {
        grid-template-columns: 1fr;
    }

    .footer-top {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    .footer-newsletter-card {
        grid-template-columns: 1fr;
        padding: 2rem;
        gap: 1.5rem;
        text-align: center;
    }

    .newsletter-illustration {
        display: none;
    }

    .newsletter-form-box {
        max-width: 520px;
        margin: 0 auto;
        width: 100%;
    }

    .newsletter-trust-tags {
        justify-content: center;
    }

    .footer-main-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2.5rem;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 64px;
    }

    .nav-links {
        display: none; /* In mobile view, Category or Search open directly */
    }

    .hero-title {
        font-size: 2.25rem;
    }

    .hero-trust-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

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

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

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

    .form-dual-input {
        flex-direction: column;
        align-items: stretch;
    }

    .form-number-box {
        width: 100%;
    }

    .results-subgrid {
        grid-template-columns: 1fr;
    }

    .footer-main-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-bottom-bar {
        flex-direction: column;
        gap: 1.25rem;
        text-align: center;
    }

    .footer-bottom-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .footer-bottom-right {
        width: 100%;
        justify-content: center;
    }

    .categories-mega-menu,
    .categories-mega-menu.active {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100vw;
        height: calc(100vh - var(--header-height));
        height: calc(100dvh - var(--header-height));
        transform: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
        max-height: none;
    }

    .mega-menu-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
    }

    .mega-mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.65rem 1rem;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }

    .mega-mobile-title {
        font-size: 0.92rem;
        font-weight: 800;
        color: var(--text-primary);
    }

    .mega-mobile-close {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        padding: 0.38rem 0.72rem;
        border-radius: 9999px;
        border: 1px solid var(--border-color);
        background: var(--bg-surface-secondary);
        color: var(--text-primary);
        font-family: var(--font-sans);
        font-size: 0.78rem;
        font-weight: 700;
        cursor: pointer;
    }

    .mega-panel-main {
        padding: 1rem;
    }

    .mega-panel-title-row {
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    .mega-menu-sidebar {
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .mega-sidebar-list {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0.4rem;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.6rem 0.85rem;
        height: auto;
        scrollbar-width: none;
    }

    .mega-sidebar-list::-webkit-scrollbar {
        display: none;
    }

    .mega-category-item {
        flex: 0 0 auto;
        margin-bottom: 0;
        padding: 0.42rem 0.72rem;
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
    }

    .mega-category-item.active {
        box-shadow: none;
        border-color: #2563eb;
    }

    .mega-cat-chevron {
        display: none;
    }

    .mega-sidebar-footer {
        flex: 0 0 auto;
        margin-top: 0;
        padding: 0;
        border-top: none;
    }

    .mega-subgroups-grid {
        grid-template-columns: 1fr;
    }

    .mega-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .calc-chart-canvas-wrap {
        height: 270px;
    }

    .calc-actions-row {
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .brand-tagline {
        display: none;
    }

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

    .brand-tld {
        font-size: 0.68rem;
        padding: 0.06rem 0.3rem;
    }

    .brand-icon {
        width: 34px;
        height: 34px;
    }

    .brand-icon svg {
        width: 34px;
        height: 34px;
    }

    .header-actions {
        gap: 0.4rem;
    }

    .btn-favorites {
        padding: 0.45rem 0.65rem;
    }

    .btn-favorites > span:not(.favorites-count-badge) {
        display: none;
    }

    .footer-top,
    .footer-stats-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .popular-grid {
        grid-template-columns: 1fr;
    }

    .hero-popular-pills {
        display: none;
    }

    .hero-search-btn {
        padding: 0.65rem 1rem;
        font-size: 0.85rem;
    }
}

