/* ================================================
   SPACEGOODS MOBILE/RESPONSIVE DESIGN
   Cosmic Scrolling Journey Experience
   ================================================ */

/* ================================================
   1. VARIABLES & BASE OVERRIDES
   ================================================ */

:root {
    /* Mobile spacing */
    --mobile-padding: 20px;
    --mobile-title: 48px;
    --mobile-subtitle: 28px;
    --mobile-body: 17px;

    /* Existing colors from main site */
    --bg: #EAE9E6;
    --fg: #0f0f10;
    --red: #ea2225;
    --muted: #5f6268;

    /* Animation timings */
    --transition-fast: 0.2s;
    --transition-medium: 0.3s;
    --transition-slow: 0.6s;
}

/* ================================================
   2. MOBILE NAVIGATION - HAMBURGER BUTTON
   ================================================ */

.mobile-menu-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    width: 50px;
    height: 50px;
    background: var(--fg);
    border: 3px solid var(--fg);
    cursor: pointer;
    display: none; /* Show only on mobile */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    transform: rotate(-2deg);
    transition: all var(--transition-medium);
}

.mobile-menu-btn span {
    width: 24px;
    height: 3px;
    background: var(--bg);
    transition: all var(--transition-medium);
    transform-origin: center;
}

.mobile-menu-btn:hover {
    transform: rotate(0deg) scale(1.05);
}

.mobile-menu-btn.open {
    transform: rotate(0deg);
}

.mobile-menu-btn.open span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.mobile-menu-btn.open span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.open span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* ================================================
   3. MOBILE DRAWER NAVIGATION
   ================================================ */

.mobile-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 75%;
    max-width: 320px;
    height: 100vh;
    background: rgba(234, 233, 230, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 4px solid var(--fg);
    z-index: 1000;
    transition: left 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow-y: auto;
    padding: 80px 30px 40px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.mobile-drawer.open {
    left: 0;
}

.drawer-logo {
    width: 150px;
    height: auto;
    animation: float 6s ease-in-out infinite;
}

.drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.drawer-nav a {
    text-decoration: none;
    color: var(--fg);
    padding: 15px 20px;
    font-size: 18px;
    font-weight: 700;
    border: 3px solid var(--fg);
    background: var(--bg);
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drawer-nav a:nth-child(1) {
    transform: rotate(-2deg);
}

.drawer-nav a:nth-child(2) {
    transform: rotate(1deg);
}

.drawer-nav a:nth-child(3) {
    transform: rotate(-1deg);
}

.drawer-nav a:nth-child(4) {
    transform: rotate(0.5deg);
}

.drawer-nav a:hover,
.drawer-nav a.active {
    background: var(--fg);
    color: var(--bg);
    transform: rotate(0deg) scale(1.02);
}

.drawer-decoration {
    width: 80px;
    height: auto;
    margin-top: auto;
    align-self: center;
    opacity: 0.6;
    animation: rotate 25s linear infinite;
}

/* ================================================
   4. DRAWER OVERLAY
   ================================================ */

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(15, 15, 16, 0.6);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-medium);
}

.drawer-overlay.active {
    opacity: 1;
    pointer-events: all;
}

body.no-scroll {
    overflow: hidden;
}

/* ================================================
   5. FLOATING CART FAB
   ================================================ */

.cart-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--red);
    border: 3px solid var(--fg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 998;
    transform: rotate(-3deg);
    transition: all var(--transition-medium);
    animation: float 6s ease-in-out infinite;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.cart-fab:hover {
    transform: rotate(0deg) scale(1.1);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.cart-fab.pulse {
    animation: pulse 0.6s ease-in-out;
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--fg);
    color: var(--bg);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid var(--bg);
}

/* ================================================
   6. HERO FULL-VIEWPORT (Mobile)
   ================================================ */

@media (max-width: 900px) {
    /* Hide cart button in header on mobile (we have floating FAB) */
    header .nav-cart {
        display: none;
    }

    /* Center logo in header, hamburger is fixed position so won't interfere */
    header .topbar {
        justify-content: center;
        padding: 15px 70px; /* Add padding on sides to avoid overlap with fixed hamburger */
    }

    /* Size logo appropriately for mobile */
    header .logo-svg {
        height: 80px !important;
        width: auto;
    }

    .hero {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 80px var(--mobile-padding) 60px;
        position: relative;
        overflow: hidden;
    }

    .hero-content {
        max-width: 100%;
        display: flex;
        flex-direction: column;
        gap: 25px;
        align-items: center;
        z-index: 2;
    }

    .hero-logo-mobile {
        width: 180px;
        max-width: 80%;
        height: auto;
        margin: 0 auto 20px;
        display: block;
    }

    /* Hide desktop hero visual on mobile */
    .hero-visual {
        display: none;
    }

    .hero h1 {
        font-size: var(--mobile-title);
        line-height: 1.1;
        letter-spacing: -2px;
    }

    .hero-description {
        font-size: 18px;
        max-width: 100%;
    }

    .hero-buttons {
        display: flex;
        flex-direction: column;
        gap: 15px;
        width: 100%;
        max-width: 300px;
    }

    .hero-buttons a,
    .hero-buttons button {
        width: 100%;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .scroll-indicator {
        position: absolute;
        bottom: 30px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 14px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 1px;
        opacity: 0.7;
        animation: bounce 2s ease-in-out infinite;
    }
}

/* ================================================
   7. PARALLAX ELEMENTS
   ================================================ */

.parallax-section {
    position: relative;
    overflow: hidden;
    min-height: 60vh;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: 60px var(--mobile-padding);
}

@media (max-width: 900px) {
    .parallax-section {
        display: flex; /* Show on mobile */
    }
}

.parallax-element {
    will-change: transform;
    transition: transform 0.1s linear;
}

.parallax-bg {
    position: absolute;
    width: 100%;
    max-width: 600px;
    height: auto;
    z-index: 0;
    opacity: 0.9;
}

.floating-element {
    position: absolute;
    z-index: 1;
}

.floating-element.meteor {
    top: 15%;
    right: 10%;
    width: 60px;
    height: auto;
    animation: float 8s ease-in-out infinite, rotate 20s linear infinite;
}

.floating-element.planets {
    bottom: 20%;
    left: 5%;
    width: 80px;
    height: auto;
    animation: float 10s ease-in-out infinite 2s;
}

/* ================================================
   8. SCROLL-TRIGGERED ANIMATIONS
   ================================================ */

.scroll-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity var(--transition-slow) ease,
                transform var(--transition-slow) ease;
}

.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity var(--transition-slow) ease,
                transform var(--transition-slow) ease;
}

.scroll-reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-right {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity var(--transition-slow) ease,
                transform var(--transition-slow) ease;
}

.scroll-reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity var(--transition-slow) ease,
                transform var(--transition-slow) ease;
}

.scroll-reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* Stagger delays for sequential animations */
.scroll-reveal:nth-child(1) { transition-delay: 0s; }
.scroll-reveal:nth-child(2) { transition-delay: 0.15s; }
.scroll-reveal:nth-child(3) { transition-delay: 0.3s; }
.scroll-reveal:nth-child(4) { transition-delay: 0.45s; }

/* ================================================
   9. CAROUSEL (Swipeable Horizontal Scroll)
   ================================================ */

.carousel-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 20px;
    padding: 20px 0;
    scrollbar-width: none; /* Firefox */
}

.carousel-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.carousel-item {
    flex: 0 0 85%;
    scroll-snap-align: center;
    transition: transform var(--transition-medium);
}

.carousel-item:hover {
    transform: scale(1.02);
}

.carousel-pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
    border: 2px solid var(--fg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.carousel-dot.active {
    background: var(--red);
    transform: scale(1.3);
}

/* ================================================
   10. GALLERY MASONRY (2-column Mobile)
   ================================================ */

@media (max-width: 900px) {
    .gallery {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        grid-auto-flow: dense;
    }

    .gallery-item {
        position: relative;
        overflow: hidden;
        border: 3px solid var(--fg);
        cursor: pointer;
        transition: all var(--transition-medium);
    }

    .gallery-item:hover {
        transform: rotate(0deg) scale(1.02);
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    }

    .gallery-item:nth-child(odd) {
        transform: rotate(-1deg);
    }

    .gallery-item:nth-child(even) {
        transform: rotate(1deg);
    }

    .gallery-item:nth-child(3n+1) {
        aspect-ratio: 1/1;
    }

    .gallery-item:nth-child(3n+2) {
        aspect-ratio: 3/4;
    }

    .gallery-item:nth-child(3n) {
        aspect-ratio: 4/3;
    }

    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* ================================================
   11. LIGHTBOX MODAL
   ================================================ */

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(15, 15, 16, 0.95);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    max-width: 90%;
    max-height: 80vh;
    position: relative;
}

.lightbox-content img {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--bg);
    border: 3px solid var(--fg);
    cursor: pointer;
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2001;
    transform: rotate(45deg);
    transition: all var(--transition-fast);
}

.lightbox-close:hover {
    transform: rotate(90deg) scale(1.1);
    background: var(--red);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: var(--bg);
    border: 3px solid var(--fg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    transition: all var(--transition-fast);
}

.lightbox-nav:hover {
    background: var(--fg);
    color: var(--bg);
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

/* ================================================
   11.5 FOOTER MOBILE IMPROVEMENTS
   ================================================ */

@media (max-width: 900px) {
    footer {
        padding: 60px 40px 30px;
        overflow: hidden;
    }

    .footer-content {
        gap: 40px;
        text-align: left;
    }

    footer .footer-logo {
        max-width: 200px;
        height: auto;
        margin-bottom: 15px;
    }

    /* Hide Legal section */
    footer .footer-content > div:last-child {
        display: none;
    }

    footer h4 {
        font-size: 18px;
        margin-bottom: 15px;
        position: relative;
        padding-bottom: 10px;
    }

    footer h4::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        width: 40px;
        height: 3px;
        background: var(--red);
        transform: rotate(-2deg);
    }

    footer ul {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    footer ul li a {
        font-size: 15px;
        padding: 5px 0;
        display: inline-block;
        position: relative;
    }

    footer ul li a::before {
        content: "→";
        position: absolute;
        left: -20px;
        opacity: 0;
        transition: all 0.3s;
    }

    footer ul li a:hover::before {
        left: -15px;
        opacity: 1;
    }

    .footer-bottom {
        padding-top: 30px;
        margin-top: 40px;
        font-size: 14px;
    }
}

@media (max-width: 600px) {
    footer {
        padding: 50px 20px 25px;
    }

    .footer-content {
        text-align: center;
    }

    footer h4::after {
        left: 50%;
        transform: translateX(-50%) rotate(-2deg);
    }

    footer ul li a::before {
        display: none;
    }
}

/* ================================================
   11.6 BUTTON HOVER ANIMATIONS (Color Fill)
   ================================================ */

.btn-svg-wrapper {
    position: relative;
    display: inline-block;
    line-height: 0; /* Remove extra space */
}

.btn-svg-wrapper .btn-svg {
    transition: opacity 0.5s ease;
    display: block;
    position: relative;
    z-index: 1;
}

/* Create hover effect with colored buttons */
.btn-svg-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 2; /* Above the original image */
}

/* Shop Now button - swap to colored version on hover */
a[href*="products"].btn-svg-wrapper::before,
.btn-svg-wrapper:has(img[src*="shopnow"])::before {
    background-image: url('../img/SVG/shopnowcolor.svg');
}

/* Buy Now button */
.btn-svg-wrapper:has(img[src*="buynow"])::before {
    background-image: url('../img/SVG/buynowcolor.svg');
}

/* Learn More button */
.btn-svg-wrapper:has(img[src*="learnmore"])::before {
    background-image: url('../img/SVG/learnmorecolor.svg');
}

/* Cookie button */
.btn-svg-wrapper:has(img[src*="cookie"])::before {
    background-image: url('../img/SVG/cookiebuttoncolor.svg');
}

/* Hover state - smooth color fill */
.btn-svg-wrapper:hover::before {
    opacity: 1;
}

.btn-svg-wrapper:hover .btn-svg {
    opacity: 0;
}

/* NO movement, NO scale - just color fill */
/* Keep existing rotation from parent styles */

/* Mobile touch enhancement */
@media (max-width: 900px) {
    .btn-svg-wrapper:active::before {
        opacity: 1;
    }

    .btn-svg-wrapper:active .btn-svg {
        opacity: 0;
    }
}

/* ================================================
   12. RESPONSIVE BREAKPOINTS
   ================================================ */

/* Prevent horizontal scroll on all sections */
@media (max-width: 900px) {
    body {
        overflow-x: hidden;
    }

    section {
        overflow-x: hidden;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    /* Ensure all containers respect viewport */
    .hero, .features, .merch-section, .gallery, .newsletter, footer {
        max-width: 100vw;
        overflow-x: hidden;
    }
}

/* ============ MOBILE SMALL (< 375px) ============ */
@media (max-width: 375px) {
    :root {
        --mobile-padding: 15px;
        --mobile-title: 38px;
    }

    .mobile-menu-btn {
        width: 45px;
        height: 45px;
    }

    .cart-fab {
        width: 55px;
        height: 55px;
        font-size: 20px;
    }
}

/* ============ MOBILE STANDARD (< 600px) ============ */
@media (max-width: 600px) {
    .mobile-menu-btn {
        display: flex;
    }

    /* Hide desktop header elements on mobile */
    header .topbar {
        padding: 15px 70px; /* Keep space for fixed hamburger */
        justify-content: center;
    }

    header .logo-svg {
        height: 70px !important;
        width: auto;
    }

    header nav a:not(.nav-cart):not(.mobile-menu-btn) {
        display: none;
    }

    /* Adjust sections */
    section {
        padding: 60px var(--mobile-padding);
    }

    h1 {
        font-size: var(--mobile-title) !important;
        letter-spacing: -2px !important;
    }

    h2 {
        font-size: var(--mobile-subtitle) !important;
        letter-spacing: -1px !important;
    }

    /* Features grid to single column */
    .features {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }

    /* Merch grid becomes carousel */
    .merch-grid {
        display: flex !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        gap: 20px !important;
    }

    .merch-grid > * {
        flex: 0 0 85% !important;
        scroll-snap-align: center !important;
    }

    /* Products grid to single column */
    .products-grid {
        grid-template-columns: 1fr !important;
    }

    /* Footer stacking */
    footer .footer-content {
        grid-template-columns: 1fr !important;
        gap: 40px !important;
        text-align: center;
    }
}

/* ============ TABLET PORTRAIT (600px - 899px) ============ */
@media (min-width: 600px) and (max-width: 899px) {
    :root {
        --mobile-padding: 40px;
        --mobile-title: 58px;
    }

    .features,
    .merch-grid,
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    footer .footer-content {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ============ TABLET LANDSCAPE (900px - 1199px) ============ */
@media (min-width: 900px) and (max-width: 1199px) {
    .mobile-menu-btn,
    .mobile-drawer,
    .drawer-overlay {
        display: none !important;
    }

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

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

/* ============ DESKTOP (1200px+) ============ */
@media (min-width: 1200px) {
    .mobile-menu-btn,
    .mobile-drawer,
    .drawer-overlay {
        display: none !important;
    }

    .cart-fab {
        display: none; /* Optional: hide on desktop if cart is in header */
    }
}

/* ================================================
   13. ANIMATIONS & KEYFRAMES
   ================================================ */

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1) rotate(-3deg);
    }
    50% {
        transform: scale(1.15) rotate(0deg);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(60px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ================================================
   14. TOUCH OPTIMIZATIONS
   ================================================ */

/* Minimum touch target size */
button,
a,
.clickable {
    min-width: 44px;
    min-height: 44px;
}

/* Prevent pull-to-refresh when drawer is open */
body.drawer-open {
    overscroll-behavior-y: contain;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Better touch scrolling on iOS */
.carousel-container,
.mobile-drawer {
    -webkit-overflow-scrolling: touch;
}

/* ================================================
   15. UTILITY CLASSES
   ================================================ */

.mobile-only {
    display: none !important;
}

@media (max-width: 900px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }
}

.text-center-mobile {
    text-align: left;
}

@media (max-width: 600px) {
    .text-center-mobile {
        text-align: center;
    }
}

/* Hidden but accessible (for screen readers) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
