/**
 * Game Boy Bento Grid
 * Masonry-style grid for works portfolio
 * v2.0 - True bento layout with varied card sizes
 */

/* ========================================
   CONTAINER
   ======================================== */

.gb-bento {
    width: 100% !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 0 20px !important;
    box-sizing: border-box !important;
}

/* ========================================
   CATEGORY STRIP
   ======================================== */

.gb-bento-categories {
    display: flex !important;
    gap: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 0 16px 0 !important;
    margin: 0 0 20px 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    white-space: nowrap !important;
}

.gb-bento-categories::-webkit-scrollbar {
    display: none;
}

.gb-bento-cat {
    font-size: 12px !important;
    letter-spacing: 3px !important;
    text-transform: uppercase !important;
    color: rgba(255, 255, 255, 0.35) !important;
    padding: 8px 16px !important;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: color 0.15s ease, border-color 0.15s ease;
    border-bottom: 2px solid transparent !important;
    flex-shrink: 0;
    line-height: 1.4 !important;
    margin: 0 !important;
}

.gb-bento-cat:hover {
    color: rgba(255, 255, 255, 0.6) !important;
}

.gb-bento-cat-active {
    color: #fff !important;
    border-bottom-color: var(--gb-red) !important;
}

.gb-bento-cat.gb-bento-cat-focused {
    color: #fff !important;
    border-bottom-color: var(--gb-red) !important;
}

.gb-bento-cat.gb-glitch-selected {
    animation: glitch-select 0.22s steps(1) forwards,
               glitch-text   0.22s steps(1) forwards;
}

/* ========================================
   BENTO GRID — true masonry with row spans
   Base unit: grid-auto-rows sets a small row height,
   cards span multiple rows for varied sizes.
   grid-auto-flow: dense fills gaps.
   ======================================== */

.gb-bento-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: 100px !important;
    grid-auto-flow: dense !important;
    gap: 8px !important;
    width: 100% !important;
}

/* ========================================
   CARDS — base
   ======================================== */

.gb-bento-card {
    position: relative !important;
    display: block !important;
    overflow: hidden !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

/* ========================================
   BENTO PATTERN — Mobile 2 cols
   Repeating 5-card tile:
     1: wide   (2col, 2row)
     2: normal (1col, 2row)
     3: tall   (1col, 3row)
     4: normal (1col, 2row)
     5: normal (1col, 1row) — short
   Dense flow fills the gap next to tall.
   ======================================== */

/* Default: normal (1col, 2row) */
.gb-bento-card {
    grid-column: span 1;
    grid-row: span 2;
}

/* 1st of every 5: wide banner */
.gb-bento-card:nth-child(5n+1) {
    grid-column: span 2;
    grid-row: span 2;
}

/* 3rd of every 5: tall */
.gb-bento-card:nth-child(5n+3) {
    grid-row: span 3;
}

/* 5th of every 5: short — creates asymmetry */
.gb-bento-card:nth-child(5n+5) {
    grid-row: span 1;
}

/* ========================================
   CARD STATES
   ======================================== */

.gb-bento-card:hover {
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* D-pad focused — scale + persistent chromatic glow */
.gb-bento-card.gb-bento-card-focused {
    border-color: var(--gb-red) !important;
    transform: scale(1.02);
    z-index: 2;
    box-shadow:
        3px 0 0 0 rgba(255, 32, 32, 0.35),
        -3px 0 0 0 rgba(32, 255, 255, 0.35) !important;
}

/* GlitchGL canvas inherits card size */
.gb-bento-card canvas[data-glitch-target] {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
    pointer-events: none;
}

/* Hidden by filter / pagination */
.gb-bento-card.gb-bento-card-hidden {
    display: none !important;
}

/* ========================================
   THUMBNAIL
   ======================================== */

.gb-bento-thumb {
    position: absolute !important;
    inset: 0 !important;
    overflow: hidden !important;
}

.gb-bento-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

/* Video preview iframe */
.gb-bento-thumb iframe {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 300% !important;
    height: 300% !important;
    transform: translate(-50%, -50%) !important;
    pointer-events: none !important;
    border: none !important;
}

/* ========================================
   CARD OVERLAY (title + client)
   ======================================== */

.gb-bento-card-overlay {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 24px 12px 10px 12px !important;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    pointer-events: none;
}

.gb-bento-card-client {
    font-size: 10px !important;
    letter-spacing: 2px !important;
    text-transform: uppercase !important;
    color: var(--gb-red) !important;
    opacity: 0.8;
    line-height: 1.3 !important;
}

.gb-bento-card-title {
    font-size: 13px !important;
    letter-spacing: 2px !important;
    text-transform: uppercase !important;
    color: #fff !important;
    font-weight: bold !important;
    line-height: 1.3 !important;
}

/* Focused: stronger gradient */
.gb-bento-card.gb-bento-card-focused .gb-bento-card-overlay {
    background: linear-gradient(transparent 20%, rgba(0, 0, 0, 0.85)) !important;
}

/* ========================================
   PAGINATION BAR
   ======================================== */

.gb-bento-pager {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 16px !important;
    padding: 20px 0 !important;
    margin: 0 !important;
}

.gb-bento-pager-btn {
    font-size: 12px !important;
    letter-spacing: 3px !important;
    text-transform: uppercase !important;
    color: rgba(255, 255, 255, 0.4) !important;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    padding: 6px 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    transition: color 0.15s ease, border-color 0.15s ease;
    background: transparent !important;
}

.gb-bento-pager-btn:hover {
    color: rgba(255, 255, 255, 0.7) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.gb-bento-pager-btn.gb-focused {
    color: #fff !important;
    border-color: var(--gb-red) !important;
}

.gb-bento-pager-btn[disabled] {
    opacity: 0.2 !important;
    pointer-events: none;
}

.gb-bento-pager-info {
    font-size: 11px !important;
    letter-spacing: 2px !important;
    color: rgba(255, 255, 255, 0.35) !important;
    text-transform: uppercase !important;
}

/* ========================================
   EMPTY STATE
   ======================================== */

.gb-bento-empty {
    font-size: 14px !important;
    letter-spacing: 3px !important;
    text-transform: uppercase !important;
    color: rgba(255, 255, 255, 0.35) !important;
    text-align: center !important;
    padding: 60px 20px !important;
}

.gb-bento-no-results {
    grid-column: 1 / -1 !important;
    font-size: 13px !important;
    letter-spacing: 2px !important;
    text-transform: uppercase !important;
    color: rgba(255, 255, 255, 0.3) !important;
    text-align: center !important;
    padding: 40px 20px !important;
}

/* ========================================
   RESPONSIVE — TABLET (768-1199px)
   3 cols, adjusted row height
   ======================================== */

@media (min-width: 768px) {
    .gb-bento-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-auto-rows: 110px !important;
        gap: 10px !important;
    }

    /* 3-col bento pattern (repeating 6):
       1: wide  (2col 2row)
       2: tall  (1col 3row)
       3: normal (1col 2row)
       4: normal (1col 2row)
       5: short (1col 1row)
       6: normal (1col 2row) */
    .gb-bento-card { grid-column: span 1; grid-row: span 2; }
    .gb-bento-card:nth-child(6n+1) { grid-column: span 2; grid-row: span 2; }
    .gb-bento-card:nth-child(6n+2) { grid-row: span 3; }
    .gb-bento-card:nth-child(6n+5) { grid-row: span 1; }

    .gb-bento-card-title {
        font-size: 14px !important;
    }

    .gb-bento-cat {
        font-size: 13px !important;
    }
}

/* ========================================
   RESPONSIVE — DESKTOP (1200px+)
   4 cols
   ======================================== */

@media (min-width: 1200px) {
    .gb-bento-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        grid-auto-rows: 100px !important;
        gap: 12px !important;
    }

    /* 4-col bento pattern (repeating 8):
       1: wide   (2col 2row)
       2: normal (1col 2row)
       3: tall   (1col 3row)
       4: short  (1col 1row)
       5: normal (1col 2row)
       6: normal (1col 2row)
       7: wide   (2col 2row)
       8: normal (1col 2row) */
    .gb-bento-card { grid-column: span 1; grid-row: span 2; }
    .gb-bento-card:nth-child(8n+1) { grid-column: span 2; grid-row: span 2; }
    .gb-bento-card:nth-child(8n+3) { grid-row: span 3; }
    .gb-bento-card:nth-child(8n+4) { grid-row: span 1; }
    .gb-bento-card:nth-child(8n+7) { grid-column: span 2; grid-row: span 2; }

    .gb-bento-card-title {
        font-size: 15px !important;
        letter-spacing: 3px !important;
    }

    .gb-bento-card-client {
        font-size: 11px !important;
    }

    .gb-bento-cat {
        padding: 10px 20px !important;
    }
}

/* ========================================
   RESPONSIVE — SMALL MOBILE (<400px)
   ======================================== */

@media (max-width: 399px) {
    .gb-bento {
        padding: 0 10px !important;
    }

    .gb-bento-grid {
        grid-auto-rows: 80px !important;
        gap: 6px !important;
    }

    .gb-bento-categories {
        margin: 0 0 12px 0 !important;
        padding: 0 0 10px 0 !important;
    }

    .gb-bento-cat {
        font-size: 11px !important;
        letter-spacing: 2px !important;
        padding: 6px 10px !important;
    }

    .gb-bento-card-title {
        font-size: 12px !important;
        letter-spacing: 1px !important;
    }

    .gb-bento-card-client {
        font-size: 9px !important;
    }

    .gb-bento-pager-btn {
        font-size: 11px !important;
        letter-spacing: 2px !important;
        padding: 5px 10px !important;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .gb-bento-card {
        transition: none !important;
    }

    .gb-bento-thumb img {
        transition: none !important;
    }

    .gb-bento-cat {
        transition: none !important;
    }
}
