/* ==========================================================================
   WDFabrik Mobile Styles
   This file only loads at <=768px via media="(max-width: 768px)"
   ========================================================================== */

/* --- Global --- */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Constrain sections that overflow on mobile */
.section-header,
.footer-content,
.footer-main {
    max-width: 100%;
    box-sizing: border-box;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* --- Header --- */
header {
    height: auto;
}

.header-content {
    padding: 0 1rem;
    min-height: 60px;
    flex-wrap: wrap;
}

.logo-img {
    width: 36px;
    height: 36px;
}

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

/* --- Hamburger Button --- */
.header-content .mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 8px;
    order: 2;
    margin-left: auto;
    z-index: 1001;
}

.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hamburger -> X animation */
.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* --- Nav Dropdown Panel --- */
/* header nav beats inline `nav { display: flex }` by specificity */
header nav {
    display: none;
    flex-direction: column;
    width: calc(100% + 2rem);
    margin-left: -1rem;
    margin-right: -1rem;
    order: 3;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 1000;
    padding: 0;
    gap: 0;
}

header nav.mobile-open {
    display: flex;
}

/* --- Nav Links (vertical stack) --- */
header nav a {
    width: 100%;
    padding: 0.9rem 1.5rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
    font-size: 0.9rem;
}

header nav a::after {
    display: none !important;
}

header nav a:last-child {
    border-bottom: none;
}

/* Cart link in mobile nav */
.cart-link {
    background: none !important;
    color: var(--text-secondary) !important;
    padding: 0.9rem 1.5rem !important;
}

.cart-link:hover {
    background: var(--bg-tertiary) !important;
}

/* Theme toggle in mobile nav */
header nav .theme-toggle {
    margin: 0;
    margin-left: 0;
    padding: 0.9rem 1.5rem;
    min-height: 44px;
    width: 100%;
    height: auto;
    justify-content: flex-start;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-sizing: border-box;
}

/* --- Category Dropdown (mobile) --- */
.nav-dropdown {
    position: static;
    width: 100%;
}

.dropdown-trigger {
    width: 100%;
}

header .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: var(--bg-tertiary);
    border: none;
    min-width: 0;
    display: none;
    box-shadow: none;
}

header .nav-dropdown.mobile-dropdown-open .dropdown-menu {
    display: block;
}

/* Prevent hover behavior on mobile */
header .nav-dropdown:hover .dropdown-menu {
    display: none;
}

header .nav-dropdown.mobile-dropdown-open:hover .dropdown-menu {
    display: block;
}

header .dropdown-menu a {
    padding: 0.75rem 1.25rem 0.75rem 2.5rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
}

/* =============================================
   Page-Specific Mobile Styles
   ============================================= */

/* --- Index Page --- */
.hero {
    min-height: auto;
    padding: 4rem 0;
}

.stats-content {
    grid-template-columns: 1fr;
}

.stat-item::after {
    display: none;
}

.about-features {
    grid-template-columns: 1fr;
}

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

footer .footer-column a {
    word-break: break-all;
}

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

/* --- Products Page --- */
.page-header-content {
    flex-direction: column;
    align-items: flex-start;
}

.page-header-right {
    text-align: left;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    width: 100%;
}

.products-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.products-section {
    padding: 2rem 1rem 4rem;
}

/* --- Product Detail Page --- */
.related-grid {
    grid-template-columns: 1fr 1fr;
}

/* --- Cart Page --- */
/* 600px cart item reflow handled in sub-breakpoint below */
.cart-layout,
.cart-item,
.cart-item-details,
.cart-item-actions,
.cart-summary,
.summary-row {
    min-width: 0;
}

.cart-item-details h3,
.cart-item-sku,
.cart-item-options,
.cart-item-price {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.summary-row {
    gap: 0.5rem;
}

.summary-row span:last-child {
    margin-left: auto;
    text-align: right;
    overflow-wrap: anywhere;
}

/* --- Checkout Page --- */
/* 500px and 600px rules handled in sub-breakpoints below */
.checkout-container,
.checkout-form,
.form-section,
.order-summary,
.order-items,
.order-item,
.order-item-details,
.summary-row {
    min-width: 0;
}

.checkout-container {
    max-width: 100%;
    padding: 1.5rem 1rem 4rem;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.form-section,
.order-summary {
    padding: 1rem;
}

.order-item {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.75rem;
}

.order-item-image {
    width: 64px;
    height: 64px;
}

.order-item-name,
.order-item-options,
.order-item-qty {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.order-item-price {
    white-space: normal;
    text-align: right;
}


/* =============================================
   Sub-Breakpoints
   ============================================= */

/* --- 600px --- */
@media (max-width: 600px) {
    /* Cart */
    .page-header {
        padding: 6rem 1rem 1rem;
    }

    .cart-item {
        grid-template-columns: 80px 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .cart-item-image {
        width: 80px;
        height: 80px;
    }

    .cart-item-actions {
        grid-column: 1 / -1;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        column-gap: 0.75rem;
        row-gap: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
        margin-top: 0.5rem;
    }

    .cart-item-total {
        font-size: 1.05rem;
    }

    .qty-control {
        margin-left: auto;
    }

    .remove-btn {
        flex: 1 0 100%;
        text-align: left;
    }

    .cart-item-details h3 {
        font-size: 0.95rem;
    }

    /* Checkout */
    .checkout-container {
        padding: 1rem 0.75rem 3rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .order-details-grid {
        grid-template-columns: 1fr;
    }

    .order-item {
        grid-template-columns: 56px minmax(0, 1fr);
        gap: 0.625rem;
    }

    .order-item-image {
        width: 56px;
        height: 56px;
    }

    .order-item-price {
        grid-column: 1 / -1;
        justify-self: end;
    }

    .success-actions {
        flex-direction: column;
    }
}

/* --- 500px --- */
@media (max-width: 500px) {
    .payment-methods {
        grid-template-columns: 1fr;
    }
}

/* --- 480px (extra small) --- */
@media (max-width: 480px) {
    header {
        height: auto;
    }

    .header-content {
        min-height: 50px;
        padding: 0 0.75rem;
    }

    .logo-img {
        width: 30px;
        height: 30px;
    }

    .logo-text {
        font-size: 1.2rem;
    }

    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
    }

    /* Product page - single column related */
    .related-grid {
        grid-template-columns: 1fr;
    }

    /* Tighter padding throughout */
    .products-section {
        padding: 2rem 1rem 4rem;
    }

    .hero {
        padding: 3rem 0;
    }

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