/* ============================================================
   HYPE STEPS — Custom Styles
   ============================================================ */

/* ============================================================
   GLOBAL OVERFLOW FIX — Prevent horizontal scrolling everywhere
   ============================================================ */

/* Root overflow prevention — use 'clip' not 'hidden' so touch
   scrolling can't bypass it. Use 100% not 100vw (100vw includes
   scrollbar width on some mobile browsers → causes overflow). */
html {
    overflow-x: clip;
    max-width: 100%;
}
body {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
}

/* Constrain all media to viewport */
img, video, iframe, canvas, embed, object {
    max-width: 100%;
    height: auto;
}

/* Prevent sections from overflowing — but NOT nav (would break
   hamburger dropdown menu) */
main, footer, section, article, aside, header {
    overflow-x: clip;
    max-width: 100%;
}

/* Long text / URLs should break instead of overflow */
h1, h2, h3, h4, h5, h6, p, a, td, th, li, label {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Tables should scroll horizontally inside their container */
table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

/* Pre/code blocks no overflow */
pre, code {
    overflow-x: auto;
    max-width: 100%;
}

/* ============================================================
   MOBILE HAMBURGER MENU — Toggle icon between ≡ and ✕
   ============================================================ */
/* When menu is open, hide the hamburger lines icon, show the X icon */
#mobile-menu-btn .icon-hamburger,
#mobile-menu-btn .icon-close {
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#mobile-menu-btn .icon-close {
    display: none;
}
#mobile-menu-btn.menu-open .icon-hamburger {
    display: none;
}
#mobile-menu-btn.menu-open .icon-close {
    display: block;
}

/* Mobile menu slide-down animation */
#mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}
#mobile-menu.menu-visible {
    max-height: 600px;
    opacity: 1;
}

/* ============================================================
   MOBILE NAVBAR — Compact layout, no overflow
   ============================================================ */

/* Force the nav to never exceed viewport width */
nav {
    max-width: 100vw;
    overflow-x: clip;
}

@media (max-width: 767px) {
    /* Tighter padding on the nav container */
    nav .max-w-7xl {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Tighter spacing for right-side nav icons on mobile */
    .nav-actions {
        gap: 0px !important;
    }
    .nav-actions a,
    .nav-actions button {
        padding: 6px !important;
    }

    /* Make the logo text smaller on small screens */
    .nav-logo-text {
        font-size: 1rem !important;
    }

    /* Hide login text on very small screens — shown in mobile menu */
    .nav-login-text {
        display: none !important;
    }

    /* Compact sign-up button on mobile */
    .nav-signup-btn {
        padding: 4px 10px !important;
        font-size: 0.7rem !important;
    }

    /* User icon compact */
    .nav-user-menu button {
        padding: 4px 6px !important;
    }
    .nav-user-menu button span {
        display: none !important;
    }
}

/* Extra small screens (< 360px, e.g. SE) */
@media (max-width: 359px) {
    .nav-logo-text {
        font-size: 0.875rem !important;
    }
    .nav-signup-btn {
        padding: 3px 8px !important;
        font-size: 0.65rem !important;
    }
}

/* ============================================================
   MOBILE PRODUCT CARDS — Better sizing for 2-col grid
   ============================================================ */
@media (max-width: 639px) {
    /* Slightly reduce inner padding on product cards */
    .product-card .p-3 {
        padding: 8px 10px;
    }
    .product-card .p-3 h3 {
        font-size: 0.8125rem;
        line-height: 1.3;
    }
    .product-card .p-3 .text-xs {
        font-size: 0.6875rem;
    }
}

/* ============================================================
   MOBILE HERO — better spacing
   ============================================================ */
@media (max-width: 639px) {
    .hero-section h1 {
        font-size: 2rem;
        line-height: 1.2;
    }
    .hero-section p {
        font-size: 0.9375rem;
    }
    /* Make hero brand buttons wrap properly on small screens */
    .hero-section .flex-wrap {
        gap: 8px !important;
    }
    .hero-section .flex-wrap a {
        font-size: 0.75rem;
        padding: 6px 14px;
    }
}

/* ============================================================
   MOBILE FOOTER — readable text, proper padding
   ============================================================ */
@media (max-width: 639px) {
    footer .max-w-7xl {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* ============================================================
   MOBILE PRODUCT LIST PAGE — Fix filter/sort row overflow
   ============================================================ */
@media (max-width: 639px) {
    /* Make the title + sort row stack vertically on mobile */
    .product-list-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
}

/* ============================================================
   MOBILE CHECKOUT / FORMS — proper padding
   ============================================================ */
@media (max-width: 639px) {
    .max-w-7xl {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #11111b; }
::-webkit-scrollbar-thumb { background: #313244; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #45475a; }

/* Product Card */
.product-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.12);
}
.product-card:hover img {
    transform: scale(1.08);
}
.product-card img {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sale Badge */
.sale-badge {
    animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Line clamp */
.line-clamp-1 { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; }
.line-clamp-2 { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

/* has:[:checked] polyfill fallback */
label:has(input:checked) {
    border-color: #6366f1 !important;
    background: rgba(99, 102, 241, 0.1) !important;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #818cf8, #a78bfa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Page transitions */
.htmx-swapping { opacity: 0.5; transition: opacity 200ms ease-out; }
.htmx-settling { opacity: 1; transition: opacity 200ms ease-in; }

/* Fade in animation */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in-up {
    animation: fadeInUp 0.4s ease-out;
}

/* Prose invert for descriptions */
.prose-invert { color: #94a3b8; }
.prose-invert a { color: #818cf8; }
.prose-invert strong { color: #e2e8f0; }
.prose-invert h2, .prose-invert h3 { color: #f1f5f9; }

/* Custom select */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Mobile filter overlay */
@media (max-width: 1023px) {
    #filter-drawer:not(.hidden) {
        position: fixed;
        inset: 0;
        z-index: 50;
        background: rgba(17, 17, 27, 0.98);
        padding: 1.5rem;
        overflow-y: auto;
    }
}
