/* ===== RESPONSIVE — Mobile-First ===== */

/* Base: Mobile (default, < 640px) */
/* All base styles in layout.css + components.css should work mobile-first.
   This file OVERRIDES for specific breakpoints. */

/* ── Hamburger Menu ─────────────────────────────────────────── */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 110;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text);
    border-radius: 1px;
    transition: all 200ms ease;
}

.hamburger.open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
    opacity: 0;
}

.hamburger.open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 639px) {
    .hamburger {
        display: flex;
    }

    #app-header nav {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
        flex-direction: column;
        padding: 0.5rem 1.5rem 1rem;
        gap: 0;
        transform: translateY(-110%);
        opacity: 0;
        transition: transform 250ms ease, opacity 200ms ease;
        z-index: 99;
    }

    #app-header nav.open {
        transform: translateY(0);
        opacity: 1;
    }

    #app-header nav a {
        padding: 0.75rem 0;
        font-size: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }

    #app-header nav a::after {
        display: none;
    }
}

/* ── Safe Area Insets ──────────────────────────────────────── */
#app-header {
    padding-top: env(safe-area-inset-top, 0px);
}

#app {
    padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
}

/* ── 640px+ Tablet ─────────────────────────────────────────── */
@media (min-width: 640px) {
    #supplier-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .hero-actions {
        flex-direction: row;
    }

    #app {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ── 768px+ ────────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Hero */
    .hero {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        min-height: auto;
        padding: 1.5rem 0;
        text-align: center;
    }

    .hero-content {
        align-items: center;
    }

    .hero-subtitle {
        max-width: 100%;
    }

    .hero-visual {
        order: -1;
    }

    .hero-proof {
        max-width: 100%;
    }

    .hero-proof-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero-proof-stats {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .hero-actions {
        flex-direction: column;
        width: 100%;
    }

    .hero-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* How it works */
    .how-it-works {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 2rem;
        padding-top: 1.5rem;
    }

    /* Grid */
    #supplier-grid {
        grid-template-columns: 1fr;
    }

    /* Browse toolbar */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .browse-toolbar {
        flex-direction: column;
    }

    .browse-toolbar .search-input {
        min-width: 0;
    }

    .browse-meta {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    /* Compare table */
    .compare-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    /* Compare tray */
    .compare-tray {
        left: 0.75rem;
        right: 0.75rem;
        bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        transform: translateY(200%);
        border-radius: var(--radius-md);
        justify-content: space-between;
    }

    .compare-tray.visible {
        transform: translateY(0);
    }

    /* Compare header */
    .compare-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    /* Modal — full screen on mobile */
    .modal-content {
        margin: 0;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        overflow-y: auto;
        padding: 1.5rem;
    }

    /* Footer */
    .footer-inner {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* ── 480px and below (tight phones) ────────────────────────── */
@media (max-width: 480px) {

    /* Header */
    .logo {
        font-size: 1rem;
    }

    .logo-mark {
        width: 20px;
        height: 20px;
    }

    /* Hero */
    .hero-headline {
        font-size: 1.65rem;
    }

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

    .hero-proof-card {
        padding: 1rem;
    }

    .hero-gauge {
        width: 64px;
        height: 64px;
    }

    .hero-bar-label {
        width: 72px;
        font-size: 0.65rem;
    }

    /* Cards */
    .card {
        padding: 0.9rem;
    }

    .card-body {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-gauge {
        width: 56px;
        height: 56px;
    }

    .card-title {
        font-size: 0.95rem;
    }

    .card-specs {
        font-size: 0.75rem;
    }

    /* Browse */
    .browse-sort {
        flex-direction: column;
        align-items: flex-start;
    }

    .dropdown {
        width: 100%;
    }

    /* Compare table */
    .compare-table {
        font-size: 0.78rem;
    }

    .compare-cell {
        padding: 0.5rem 0.6rem;
    }

    .tray-chip-name {
        max-width: 80px;
    }

    /* Toast */
    .toast {
        left: 0.5rem;
        right: 0.5rem;
        bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    }

    /* Skeleton */
    .skel-title {
        width: 50%;
    }

    .skel-block {
        width: 85%;
    }

    /* Touch target minimums */
    .btn {
        min-height: 44px;
    }

    .dropdown {
        min-height: 40px;
    }
}

/* ── 1024px+ Desktop ───────────────────────────────────────── */
@media (min-width: 1024px) {
    #supplier-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .hero {
        min-height: calc(100vh - 200px);
    }
}