/* 🍱 Bento Grid Block Styles (v17.1 Optimized) */

/* 1. 공통 그리드 컨테이너 */
.givia-activity-bento-grid {
    display: grid;
    /*grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(100px, auto);*/
    width: 100%;
    box-sizing: border-box;
}

/* 2. 아이템 기본 스타일 */
.bento-item {
    position: relative;
    overflow: hidden;
    background: transparent;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.4s ease;
    box-sizing: border-box;
    text-decoration: none !important;

    /* 부모로부터 상속받는 공통 스타일 */
    border-radius: var(--bento-radius, 18px) !important;
    border: var(--bento-border, 1px solid #ebebeb) !important;
    
    /* 배경색 상태 제어 */
    --bento-bg: transparent;
    --bento-bg-hover: var(--bento-bg);
    --bento-bg-active: var(--bento-bg-hover);
}

.bento-item .bento-bg-color {
    background-color: var(--bento-bg) !important;
    transition: background-color 0.3s ease;
}

.bento-item:hover .bento-bg-color {
    background-color: var(--bento-bg-hover) !important;
}

.bento-item:active .bento-bg-color {
    background-color: var(--bento-bg-active) !important;
}

.bento-item:hover {
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

/* 텍스트 및 요소 스타일링 */
.bento-item h1, .bento-item h2, .bento-item h3, .bento-item h4, .bento-item h5, .bento-item h6 {
    font-size: var(--bento-title-size) !important;
    color: var(--bento-title-color) !important;
    margin: 0;
    line-height: 1.2;
}

.bento-item p {
    font-size: var(--bento-desc-size) !important;
    color: var(--bento-desc-color) !important;
    margin: 10px 0 0 0;
    line-height: 1.5;
}

.bento-item .activity-btn {
    background: var(--bento-btn-bg, #fff) !important;
    color: var(--bento-btn-text, #000) !important;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 14px;
    transition: opacity 0.3s ease;
}

.bento-item:hover .activity-btn {
    opacity: 0.9;
}

/* 배경 이미지/비디오 효과 */
.bento-item .bento-bg-img,
.bento-item .bento-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    transition: transform 1.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.bento-item:hover .bento-bg-img,
.bento-item:hover .bento-bg-video {
    transform: scale(1.05);
}

/* 가독성 오버레이 */
.bento-content-overlay {
    position: relative;
    z-index: 2;
    padding: var(--bento-padding, 30px) !important;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: background 0.4s ease;
}

/* 3. 그리드 점유율 (Grid Spans) */
.span-col-1 { grid-column: span 1 !important; }
.span-col-2 { grid-column: span 2 !important; }
.span-col-3 { grid-column: span 3 !important; }
.span-col-4 { grid-column: span 4 !important; }

.span-row-1 { grid-row: span 1 !important; }
.span-row-2 { grid-row: span 2 !important; }
.span-row-3 { grid-row: span 3 !important; }
.span-row-4 { grid-row: span 4 !important; }

/* 4. 🌐 프론트엔드 반응형 (Mobile-First or Proper Breakpoints) */
@media (max-width: 1024px) {
    .givia-activity-bento-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 767px) {
    .givia-activity-bento-grid {
        grid-template-columns: 1fr !important;
    }
    .bento-item {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        min-height: 250px !important;
    }
}

/* 5. 🚀 최대 노출 개수 제어 (Fallback) */
[class*="shown-count-"] .bento-item { display: flex; }
.shown-count-1 .bento-item:nth-child(n+2),
.shown-count-2 .bento-item:nth-child(n+3),
.shown-count-3 .bento-item:nth-child(n+4),
.shown-count-4 .bento-item:nth-child(n+5),
.shown-count-5 .bento-item:nth-child(n+6),
.shown-count-6 .bento-item:nth-child(n+7),
.shown-count-7 .bento-item:nth-child(n+8),
.shown-count-8 .bento-item:nth-child(n+9),
.shown-count-9 .bento-item:nth-child(n+10),
.shown-count-10 .bento-item:nth-child(n+11),
.shown-count-11 .bento-item:nth-child(n+12),
.shown-count-12 .bento-item:nth-child(n+13) {
    display: none !important;
}

/* 🛠️ 6. Gutenberg Editor 전용 스타일 격리 */
.givia-bento-grid-editor {
    width: 100% !important;
}

.givia-bento-grid-editor > .block-editor-inner-blocks > .block-editor-block-list__layout {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    grid-auto-rows: minmax(100px, auto) !important;
    gap: var(--bento-gap, 20px) !important;
}

/* 에디터 기기 전환 탭 대응 */
.givia-bento-grid-editor.is-device-tablet > .block-editor-inner-blocks > .block-editor-block-list__layout {
    grid-template-columns: repeat(2, 1fr) !important;
}

.givia-bento-grid-editor.is-device-mobile > .block-editor-inner-blocks > .block-editor-block-list__layout {
    grid-template-columns: 1fr !important;
}

/* 에디터 아이템 점유율 강제 적용 */
.givia-bento-item-editor {
    height: 100% !important;
}

/* 에디터 내 숨김 처리 */
.givia-bento-grid-editor.shown-count-1 .block-editor-block-list__block:nth-child(n+2),
.givia-bento-grid-editor.shown-count-2 .block-editor-block-list__block:nth-child(n+3),
.givia-bento-grid-editor.shown-count-3 .block-editor-block-list__block:nth-child(n+4),
.givia-bento-grid-editor.shown-count-4 .block-editor-block-list__block:nth-child(n+5),
.givia-bento-grid-editor.shown-count-5 .block-editor-block-list__block:nth-child(n+6),
.givia-bento-grid-editor.shown-count-6 .block-editor-block-list__block:nth-child(n+7),
.givia-bento-grid-editor.shown-count-7 .block-editor-block-list__block:nth-child(n+8),
.givia-bento-grid-editor.shown-count-8 .block-editor-block-list__block:nth-child(n+9),
.givia-bento-grid-editor.shown-count-9 .block-editor-block-list__block:nth-child(n+10),
.givia-bento-grid-editor.shown-count-10 .block-editor-block-list__block:nth-child(n+11),
.givia-bento-grid-editor.shown-count-11 .block-editor-block-list__block:nth-child(n+12),
.givia-bento-grid-editor.shown-count-12 .block-editor-block-list__block:nth-child(n+13) {
    display: none !important;
}
