/* ========================================= */
/* --- MACHINES CATALOG LAYOUT --- */
/* ========================================= */

/* 1. Page Header (Breadcrumbs & Title) */
.page-header {
    background: #f4f4f4;
    padding: 40px 0;
    text-align: center;
    margin-bottom: 40px;
}
.breadcrumb {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.page-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    color: var(--primary);
    margin: 0;
}

/* 2. Main Container (Sidebar + Grid) */
.catalog-container {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 80px;
    gap: 40px; /* Space between sidebar and grid */
    position: relative;
}

/* 3. Sidebar Filters (Left) */
.filter-sidebar {
    width: 250px;
    flex-shrink: 0;
    /* Sticky Magic: Stays on screen while you scroll */
    position: sticky;
    top: 100px; 
    height: fit-content;
}

.filter-group {
    margin-bottom: 30px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}
.filter-group:last-child { border: none; }

.filter-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex; justify-content: space-between;
}

/* Checkbox Styling */
.filter-option {
    display: flex; align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #555;
    transition: 0.2s;
}
.filter-option:hover { color: var(--gold); }
.filter-option input { margin-right: 10px; accent-color: var(--primary); }

/* 4. Product Grid (Right) */
.catalog-content {
    flex-grow: 1;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}
.result-count { color: #888; font-size: 0.9rem; }
.sort-select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: transparent;
    font-family: 'Poppins', sans-serif;
}

/* The Grid Logic */
.machines-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 Columns by default */
    gap: 30px;
}

/* Re-using Product Card Styles from Index, but ensuring they fit */
.product-card {
    background: #fff;
    border: 1px solid #eee; /* Subtle border for catalog */
    transition: transform 0.3s, box-shadow 0.3s;
}
.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

/* 5. Mobile Responsiveness */
@media (max-width: 900px) {
    .machines-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .catalog-container { flex-direction: column; } /* Stack sidebar on top */
    .filter-sidebar { width: 100%; position: static; margin-bottom: 30px; }
    .machines-grid { grid-template-columns: 1fr; } /* 1 Column on phone */
}

/* --- PAGINATION STYLES --- */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

.page-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    background: #fff;
    color: #555;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #eee;
}

/* ========================================= */
/* --- PIXEL ANIMATION SEQUENCE (V3 - Fixed) --- */
/* ========================================= */

.card-image-wrapper {
    position: relative;
    overflow: hidden; 
}

/* 1. The Grid Container */
.pixel-grid {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    display: flex;
    flex-wrap: wrap;
    opacity: 0; 
    z-index: 10;
}

/* 2. Individual Pixel Shards */
.pixel-shard {
    position: relative;
    /* FIX: Set back to 10% to prevent layout breaking */
    width: 10%; 
    height: 10%;
    background-size: 1000% 1000%;
    
    /* FIX: Use scale(1.05) to overlap and hide gaps without changing layout size */
    transform: translateY(0) rotate(0deg) scale(1.05);
    opacity: 1;
    
    /* Base transition setup */
    transition: transform 0.5s ease-in, opacity 0.5s ease-in;
    will-change: transform, opacity; /* Performance booster */
}

/* --- STATE 1: ACTIVE (Grid becomes visible) --- */
.card-image-wrapper.animating .pixel-grid {
    opacity: 1;
}
.card-image-wrapper.animating .card-img {
    opacity: 0; /* Hide real image while animating */
}


/* --- STATE 2: SHATTER (Falling Down) --- */
/* Occurs immediately when hover starts */
.card-image-wrapper.shatter .pixel-shard {
    /* Fall way down, rotate, and shrink slightly */
    transform: translateY(150%) rotate(var(--r-angle)) scale(0.8);
    opacity: 0;
    
    /* FAST fall: 0.4s duration, NO Delay */
    transition: transform 0.4s ease-in, opacity 0.4s ease-in;
    transition-delay: 0s !important; /* Force instant start */
}


/* --- STATE 3: REBUILD (Coming Back Up) --- */
/* JS adds this class after the fall is done */
.card-image-wrapper.rebuild .pixel-shard {
    /* Return to home position AND scale up to cover gaps */
    transform: translateY(0) rotate(0deg) scale(1.05);
    opacity: 1;
    
    /* SLOW rebuild: Bouncy effect */
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s;
    
    /* STAGGERED DELAY: Bottom rows first! */
    /* Row 9 (Bottom) waits 0s */
    /* Row 0 (Top) waits 0.45s */
    transition-delay: calc((9 - var(--row)) * 0.05s);
}

/* ========================================= */
/* --- BUTTON VISIBILITY LOGIC --- */
/* ========================================= */

/* 1. Default State: Hidden & Unclickable */
.card-overlay {
    opacity: 0;
    z-index: 20; /* Must be higher than pixel-grid (z-index: 10) */
    pointer-events: none; /* Can't click it while hidden */
    transition: opacity 0.3s ease;
}

/* 2. Disable Standard Hover (Important Override) */
/* We don't want the button to show up immediately when mouse enters */
.card-image-wrapper:hover .card-overlay {
    opacity: 0;
}

/* 3. The Reveal (Only during Rebuild) */
/* This class is added by JS after the fall animation */
.card-image-wrapper.rebuild .card-overlay {
    opacity: 1;
    pointer-events: auto; /* Now you can click it */
    
    /* THE MAGIC DELAY: 
       The rebuild starts at 0.5s.
       The pixels take about 0.8s to fly up.
       We wait 1.0s so the button fades in smoothly right as the image finishes.
    */
    transition: opacity 0.5s ease 1.0s; 
}


/* ========================================= */
/* --- MOBILE FILTER DRAWER LOGIC --- */
/* ========================================= */

/* 1. THE TRIGGER BUTTON (Hidden by default) */
/* This button only appears on mobile screens */
.btn-mobile-filter {
    display: none; 
}

/* 2. MOBILE VIEW (Max Width 900px) */
@media (max-width: 900px) {
    
    /* A. Make the Button Visible */
    .btn-mobile-filter {
        display: flex;             /* Show it now */
        width: 100%;               /* Full width */
        padding: 12px;
        background: #0D261F;       /* Dark Green */
        color: white;
        border: none;
        border-radius: 5px;
        font-size: 1rem;
        justify-content: center;   /* Center text */
        align-items: center;
        gap: 10px;                 /* Space between icon and text */
        cursor: pointer;
        margin-bottom: 15px;
    }

    /* B. Re-arrange the Toolbar */
    .toolbar {
        flex-direction: column;    /* Stack items vertically */
        height: auto;              /* Let it grow */
        gap: 10px;
    }

    /* C. TRANSFORM THE SIDEBAR INTO A DRAWER */
    .filter-sidebar {
        position: fixed;           /* Float above everything */
        top: 0; 
        left: -100%;               /* HIDE IT: Push it completely off the left screen */
        width: 85%;                /* Width of the drawer */
        height: 100vh;             /* Full screen height */
        background: white;
        z-index: 9999;             /* Put it on top of all images */
        padding: 20px;
        overflow-y: auto;          /* Allow scrolling inside the drawer */
        box-shadow: 5px 0 15px rgba(0,0,0,0.2); /* Shadow on the right edge */
        transition: left 0.3s ease; /* Animate the slide-in */
    }

    /* D. THE 'ACTIVE' CLASS */
    /* When Javascript adds this class, the sidebar slides in */
    .filter-sidebar.active {
        left: 0;                   /* Bring it back to the screen */
    }

    /* E. Sidebar Header (Only visible on mobile) */
    .sidebar-mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        border-bottom: 1px solid #eee;
        padding-bottom: 10px;
    }
    .sidebar-mobile-header h3 { margin: 0; }
    #closeFilterBtn {
        font-size: 2rem;
        background: none;
        border: none;
        cursor: pointer;
        line-height: 1;
    }
}

/* 3. DESKTOP SAFETY */
/* Ensure the mobile header is hidden on big screens */
@media (min-width: 901px) {
    .sidebar-mobile-header { display: none; }
}

/* TOAST NOTIFICATION */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px); /* Start hidden below */
    background-color: #0D261F; /* Primary Green */
    color: #fff;
    padding: 12px 24px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    font-size: 0.9rem;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0); /* Slide Up */
}

/* --- PROFESSIONAL PAGE FEATURES --- */
.pro-features-row {
    display: flex;
    justify-content: space-between;
    background-color: #f9f9f9;
    padding: 30px;
    margin-bottom: 40px;
    border-radius: 4px;
    border: 1px solid #eee;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 30%;
}

.feat-icon {
    font-size: 2rem;
    background: #fff;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.feat-text h4 {
    margin: 0;
    font-size: 1rem;
    color: #0D261F;
    font-weight: 700;
}

.feat-text p {
    margin: 5px 0 0;
    font-size: 0.85rem;
    color: #666;
}

/* Mobile Layout */
@media (max-width: 768px) {
    .pro-features-row {
        flex-direction: column;
        gap: 20px;
    }
    .feature-item {
        width: 100%;
    }
}