/* stack_bbs - 게시판 스택 위젯 CSS */
/* stack1의 슬롯 크기 + 데코 연장 + stack2의 게시판 렌더링 조합 */
/* 그리드 칼럼은 widget_body.php에서 인라인으로 동적 생성 */

/* ================================================
   전체 래퍼
   ================================================ */
.stack_content_wrap {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* 타이틀 영역 */
.stack_bbs .sub_stit_box {
    margin-bottom: clamp(20px, calc(1.56vw + 15px), 40px);
}
.stack_bbs .sub_stit_box:empty {
    display: none;
    margin: 0;
}

/* ================================================
   그리드 레이아웃
   - 칼럼 수/넓이는 PHP 인라인 또는 style 필드로 설정
   - CSS는 기본 fallback + 공통 스타일 담당
   ================================================ */
.stack_grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(15px, calc(1.17vw + 11.25px), 30px);
    width: 100%;
}

/* 아이템 래퍼 */
.stack_item_wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* 아이템 본체 */
.stack_item {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 리스트 영역 - 남은 높이 채움 */
.stack_list {
    flex: 1;
    min-width: 0;
}

/* 슬롯 내부 위젯이 100% 차지 */
.stack_grid .stack_item > * {
    width: 100%;
}

/* ================================================
   헤더 영역 (제목, 부제목, 더보기)
   ================================================ */
.stack_header {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: clamp(12px, calc(0.94vw + 9px), 24px);
    padding-bottom: clamp(10px, calc(0.78vw + 7.5px), 20px);
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.stack_header_txt {
    flex: 1;
    min-width: 0;
}

.stack_title {
    font-size: clamp(16px, calc(0.63vw + 14px), 20px);
    font-weight: 700;
    color: var(--item-color, #1976d2);
    margin: 0;
}

.stack_subtitle {
    font-size: clamp(12px, calc(0.23vw + 11.25px), 14px);
    color: #666;
    margin: 6px 0 0 0;
    line-height: 1.4;
}

/* 더보기 버튼 */
.stack_more {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff !important;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.stack_more:hover {
    opacity: 0.85;
    transform: scale(1.1);
}

/* 더보기 아이콘 변형 (arrow 계열) */
.stack_more.stack_more_icon {
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    color: var(--primary) !important;
    font-size: 45px;
    font-weight: 400;
    line-height: 1;
}
.stack_more.stack_more_icon:hover {
    opacity: 0.7;
    transform: none;
}
.stack_item.stack_item_fill .stack_more.stack_more_icon {
    background: none;
    color: #fff !important;
}

/* 스와이퍼 뱃지 (헤더 내 SW 표시) */
.stack_swiper_badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #7c3aed;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

/* ================================================
   아이템 타입 변형
   ================================================ */

/* 배경색 채우기 타입 */
.stack_item.stack_item_fill {
    background: var(--item-color, #1976d2);
    border-color: var(--item-color, #1976d2);
}
.stack_item.stack_item_fill .stack_header {
    border-bottom-color: rgba(255,255,255,0.3);
}
.stack_item.stack_item_fill .stack_title,
.stack_item.stack_item_fill .stack_subtitle {
    color: #fff;
}
.stack_item.stack_item_fill .stack_more {
    background: #fff;
    color: var(--item-color, #1976d2) !important;
}

/* 제목 없이 통으로 표시 */
.stack_list_full {
    /* 헤더 없으므로 꽉 채움 */
}
.stack_item:has(.stack_list_full) {
    padding: 0;
}
.stack_item:has(.stack_list_full) .stack_list_full {
    height: 100%;
}

/* 스와이퍼 사용 아이템 */
.stack_item.has_swiper .stack_list {
    overflow: hidden;
}

/* ================================================
   데코 배경 영역 (txt[99]='deco' 항목)
   ================================================ */
.stack_deco_area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.stack_deco_bg {
    position: absolute;
    pointer-events: none;
}
.stack_deco_bg .bg {
    position: absolute;
}

/* ================================================
   데코 연장 박스 (stack1 패턴)
   contents-container 외부로 확장
   ================================================ */
.stack_bbs .contents-container {
    position: relative;
}

.stack_bbs .deco_box {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    pointer-events: none;
}
.stack_bbs .deco_box.extend_right {
    left: 100%;
    width: calc(50vw - 50%);
}
.stack_bbs .deco_box.extend_left {
    right: 100%;
    width: calc(50vw - 50%);
}

/* 데코 이미지 */
.stack_bbs .deco_img {
    position: absolute;
    z-index: 3;
    pointer-events: none;
}

/* ================================================
   관리자 모드
   ================================================ */

/* 전체 설정 뱃지 */
.stack_badge {
    position: absolute;
    top: -15px;
    right: 10px;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
.stack_badge:hover {
    background: linear-gradient(135deg, #047857, #059669);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}
.stack_badge i { font-size: 14px; }
.stack_badge .badge_hint {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.85;
    margin-left: 4px;
}

/* 위젯 관리 바로가기 */
.stack_widget_link {
    position: absolute;
    top: -15px;
    right: 180px;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff !important;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.stack_widget_link:hover {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    color: #fff !important;
}
.stack_widget_link i { font-size: 13px; }

/* 관리자 그리드 모드 */
.stack_grid.stack_admin_mode {
    position: relative;
    border: 2px dashed transparent;
    transition: border-color 0.2s ease;
}
.stack_grid.stack_admin_mode:hover {
    border-color: #10b981;
}

/* 개별 항목 편집 아이콘 */
.stack_edit_icon {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.stack_edit_icon i {
    color: #fff;
    font-size: 12px;
}
.stack_item_wrapper:hover .stack_edit_icon {
    opacity: 1;
}
.stack_edit_icon:hover {
    background: #059669;
    transform: translateX(-50%) scale(1.2);
    box-shadow: 0 3px 8px rgba(16, 185, 129, 0.5);
}

/* 관리자 아이템 호버 강조 */
.stack_admin_mode .stack_item_wrapper:hover .stack_item {
    outline: 2px dashed #10b981;
    outline-offset: 2px;
}

/* ================================================
   빈 리스트
   ================================================ */
.stack_bbs .empty_li {
    text-align: center;
    color: #999;
    padding: 30px 15px;
    font-size: 14px;
}

/* ================================================
   반응형
   ================================================ */
@media screen and (max-width: 991px) {
    .stack_grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media screen and (max-width: 640px) {
    .stack_grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}
