/* ============================================
   팁 갤러리 리스트 스킨 전용 CSS
   BEM 네이밍 컨벤션 사용 (tg-tips-gallery 접두사)
   모바일 퍼스트 반응형 디자인
   ============================================ */

/* ── CSS 커스텀 속성 (변수) ── */
:root {
    --tg-primary: #6C5CE7;
    --tg-primary-light: #A29BFE;
    --tg-primary-dark: #4834D4;
    --tg-accent: #00CEC9;
    --tg-accent-light: #55EFC4;
    --tg-surface: #FFFFFF;
    --tg-surface-hover: #F8F9FE;
    --tg-bg: #F0F2F8;
    --tg-text-primary: #2D3436;
    --tg-text-secondary: #636E72;
    --tg-text-muted: #B2BEC3;
    --tg-border: #E8ECF1;
    --tg-shadow-sm: 0 2px 8px rgba(108, 92, 231, 0.06);
    --tg-shadow-md: 0 8px 24px rgba(108, 92, 231, 0.10);
    --tg-shadow-lg: 0 16px 48px rgba(108, 92, 231, 0.14);
    --tg-shadow-hover: 0 20px 60px rgba(108, 92, 231, 0.18);
    --tg-radius-sm: 8px;
    --tg-radius-md: 14px;
    --tg-radius-lg: 20px;
    --tg-transition: 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --tg-transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── 최상위 래퍼 ── */
#tg-tips-gallery.tg-tips-gallery {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
}

/* ── 카테고리 네비게이션 ── */
#tg-tips-gallery .tg-tips-gallery__category {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--tg-border);
}

#tg-tips-gallery .tg-tips-gallery__category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

#tg-tips-gallery .tg-tips-gallery__category-list li {
    display: inline-block;
}

#tg-tips-gallery .tg-tips-gallery__category-list li a {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    color: var(--tg-text-secondary);
    background: var(--tg-surface);
    border: 1px solid var(--tg-border);
    text-decoration: none;
    transition: all var(--tg-transition);
    letter-spacing: -0.3px;
}

#tg-tips-gallery .tg-tips-gallery__category-list li a:hover {
    color: var(--tg-primary);
    border-color: var(--tg-primary-light);
    background: rgba(108, 92, 231, 0.06);
    transform: translateY(-1px);
}

#tg-tips-gallery .tg-tips-gallery__category-list li #bo_cate_on {
    color: var(--tg-surface);
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary-dark));
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

/* ── 관리자 전체 선택 ── */
#tg-tips-gallery .tg-tips-gallery__admin-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: flex-end;
}

#tg-tips-gallery .tg-tips-gallery__admin-check label {
    font-size: 13px;
    color: var(--tg-text-secondary);
    cursor: pointer;
}

/* ── 검색 영역 (글래스모피즘 스타일) ── */
#tg-tips-gallery .tg-tips-gallery__search {
    margin: 0 auto 32px;
    max-width: 560px;
    border: none;
    padding: 0;
}

#tg-tips-gallery .tg-tips-gallery__search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--tg-surface);
    border: 1.5px solid var(--tg-border);
    border-radius: 100px;
    padding: 6px 8px 6px 16px;
    transition: all var(--tg-transition);
    box-shadow: var(--tg-shadow-sm);
}

#tg-tips-gallery .tg-tips-gallery__search-form:focus-within {
    border-color: var(--tg-primary-light);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.10), var(--tg-shadow-md);
    transform: translateY(-1px);
}

#tg-tips-gallery .tg-tips-gallery__search-select {
    flex-shrink: 0;
    width: auto;
    min-width: 100px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--tg-text-secondary);
    padding: 8px 12px 8px 4px;
    cursor: pointer;
    outline: none;
    appearance: auto;
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    border-right: 1px solid var(--tg-border);
    margin-right: 8px;
    line-height: 1.4;
    /* 기존 #bo_sch select 규칙 덮어쓰기 */
    height: auto !important;
    float: none !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

#tg-tips-gallery .tg-tips-gallery__search-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

#tg-tips-gallery .tg-tips-gallery__search-icon {
    width: 16px;
    height: 16px;
    color: var(--tg-text-muted);
    flex-shrink: 0;
    margin-right: 8px;
    display: none;
}

#tg-tips-gallery .tg-tips-gallery__search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--tg-text-primary);
    padding: 8px 0;
    outline: none;
    width: 100%;
    min-width: 0;
}

#tg-tips-gallery .tg-tips-gallery__search-input::placeholder {
    color: var(--tg-text-muted);
    font-weight: 400;
}

#tg-tips-gallery .tg-tips-gallery__search-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary-dark));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--tg-transition);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

#tg-tips-gallery .tg-tips-gallery__search-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(108, 92, 231, 0.4);
}

#tg-tips-gallery .tg-tips-gallery__search-btn:active {
    transform: scale(0.95);
}

#tg-tips-gallery .tg-tips-gallery__search-btn svg {
    width: 16px;
    height: 16px;
    stroke: white;
}

/* ── 카드 그리드 레이아웃 ── */
#tg-tips-gallery .tg-tips-gallery__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 32px;
}

/* ── 개별 카드 아이템 ── */
#tg-tips-gallery .tg-tips-gallery__card {
    position: relative;
    background: var(--tg-surface);
    border-radius: var(--tg-radius-md);
    overflow: hidden;
    box-shadow: var(--tg-shadow-sm);
    border: 1px solid var(--tg-border);
    transition: all var(--tg-transition);
    /* 등장 애니메이션 초기 상태 */
    opacity: 0;
    transform: translateY(30px);
}

/* 카드 등장 애니메이션 (visible 상태) */
#tg-tips-gallery .tg-tips-gallery__card--visible {
    opacity: 1;
    transform: translateY(0);
}

/* 카드 호버 효과 */
#tg-tips-gallery .tg-tips-gallery__card:hover {
    box-shadow: var(--tg-shadow-hover);
    transform: translateY(-6px);
    border-color: rgba(108, 92, 231, 0.15);
}

#tg-tips-gallery .tg-tips-gallery__card--visible:hover {
    transform: translateY(-6px);
}

/* ── 카드 썸네일 영역 ── */
#tg-tips-gallery .tg-tips-gallery__card-thumb-link {
    display: block;
    text-decoration: none;
}

#tg-tips-gallery .tg-tips-gallery__card-thumb {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 비율 */
    overflow: hidden;
    background: linear-gradient(135deg, #667eea22, #764ba233);
}

#tg-tips-gallery .tg-tips-gallery__card-video,
#tg-tips-gallery .tg-tips-gallery__card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 호버 시 이미지/비디오 줌인 */
#tg-tips-gallery .tg-tips-gallery__card:hover .tg-tips-gallery__card-video,
#tg-tips-gallery .tg-tips-gallery__card:hover .tg-tips-gallery__card-img {
    transform: scale(1.06);
}

/* 카드 오버레이 (호버 시 등장) */
#tg-tips-gallery .tg-tips-gallery__card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    background: linear-gradient(
        to top,
        rgba(45, 52, 54, 0.65) 0%,
        rgba(45, 52, 54, 0.15) 40%,
        transparent 100%
    );
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 20px;
    opacity: 0;
    transition: opacity var(--tg-transition);
}

#tg-tips-gallery .tg-tips-gallery__card:hover .tg-tips-gallery__card-overlay {
    opacity: 1;
}

/* "자세히 보기" 텍스트 */
#tg-tips-gallery .tg-tips-gallery__card-read-more {
    display: inline-block;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 100px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transform: translateY(10px);
    transition: transform var(--tg-transition-bounce);
}

#tg-tips-gallery .tg-tips-gallery__card:hover .tg-tips-gallery__card-read-more {
    transform: translateY(0);
}

/* ── 카드 콘텐츠 바디 ── */
#tg-tips-gallery .tg-tips-gallery__card-body {
    padding: 18px 20px 20px;
}

/* 카드 제목 */
#tg-tips-gallery .tg-tips-gallery__card-title {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: -0.3px;
    color: var(--tg-text-primary);
    /* 2줄 말줄임 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#tg-tips-gallery .tg-tips-gallery__card-title a {
    color: inherit;
    text-decoration: none;
    transition: color var(--tg-transition);
}

#tg-tips-gallery .tg-tips-gallery__card:hover .tg-tips-gallery__card-title a {
    color: var(--tg-primary);
}

/* 카드 설명 */
#tg-tips-gallery .tg-tips-gallery__card-desc-link {
    text-decoration: none;
}

#tg-tips-gallery .tg-tips-gallery__card-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.65;
    color: var(--tg-text-secondary);
    /* 3줄 말줄임 */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 관리자 체크박스 ── */
#tg-tips-gallery .tg-tips-gallery__card-check {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 6px;
    padding: 4px 6px;
}

/* ── 빈 게시물 상태 ── */
#tg-tips-gallery .tg-tips-gallery__empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

#tg-tips-gallery .tg-tips-gallery__empty-icon {
    width: 56px;
    height: 56px;
    color: var(--tg-text-muted);
    margin-bottom: 20px;
    opacity: 0.5;
}

#tg-tips-gallery .tg-tips-gallery__empty-text {
    font-size: 14px;
    color: var(--tg-text-muted);
    margin: 0;
}

/* ── 하단 페이징 & 관리 버튼 영역 ── */
#tg-tips-gallery .tg-tips-gallery__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 24px 0;
    border-top: 1px solid var(--tg-border);
    margin-top: 8px;
}

#tg-tips-gallery .tg-tips-gallery__admin-btns {
    display: flex;
    gap: 8px;
}

/* 관리 버튼 공통 스타일 */
#tg-tips-gallery .tg-tips-gallery__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--tg-border);
    background: var(--tg-surface);
    color: var(--tg-text-secondary);
    cursor: pointer;
    transition: all var(--tg-transition);
}

#tg-tips-gallery .tg-tips-gallery__btn:hover {
    border-color: var(--tg-primary-light);
    color: var(--tg-primary);
    background: rgba(108, 92, 231, 0.06);
    transform: translateY(-2px);
    box-shadow: var(--tg-shadow-sm);
}

#tg-tips-gallery .tg-tips-gallery__btn svg {
    width: 18px;
    height: 18px;
}

/* 글쓰기 버튼 강조 */
#tg-tips-gallery .tg-tips-gallery__btn--write {
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary-dark));
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

#tg-tips-gallery .tg-tips-gallery__btn--write:hover {
    background: linear-gradient(135deg, var(--tg-primary-light), var(--tg-primary));
    color: white;
    box-shadow: 0 6px 16px rgba(108, 92, 231, 0.4);
}

#tg-tips-gallery .tg-tips-gallery__btn--write svg {
    stroke: white;
}

/* 페이지네이션 영역 */
#tg-tips-gallery .tg-tips-gallery__pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

#tg-tips-gallery .tg-tips-gallery__pagination .pg_wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

#tg-tips-gallery .tg-tips-gallery__pagination .pg_wrap a,
#tg-tips-gallery .tg-tips-gallery__pagination .pg_wrap .pg_current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--tg-transition);
    border: none;
}

#tg-tips-gallery .tg-tips-gallery__pagination .pg_wrap a {
    color: var(--tg-text-secondary);
    background: var(--tg-surface);
    border: 1px solid var(--tg-border);
}

#tg-tips-gallery .tg-tips-gallery__pagination .pg_wrap a:hover {
    color: var(--tg-primary);
    border-color: var(--tg-primary-light);
    background: rgba(108, 92, 231, 0.06);
    transform: translateY(-2px);
}

#tg-tips-gallery .tg-tips-gallery__pagination .pg_wrap .pg_current {
    color: white;
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary-dark));
    border: 1px solid transparent;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
    font-weight: 700;
}

/* 페이지네이션 화살표 (처음/이전/다음/맨끝) 텍스트 숨기고 아이콘 표시 */
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_start,
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_prev,
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_next,
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_end,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_start,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_prev,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_next,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_end {
    text-indent: -9999px;
    overflow: hidden;
    position: relative;
}

/* 화살표 가상요소 공통 */
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_start::after,
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_prev::after,
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_next::after,
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_end::after,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_start::after,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_prev::after,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_next::after,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_end::after {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    text-indent: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--tg-text-secondary);
}

/* 처음 \00AB = « */
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_start::after,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_start::after {
    content: "\00AB";
}

/* 이전 \2039 = ‹ */
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_prev::after,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_prev::after {
    content: "\2039";
}

/* 다음 \203A = › */
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_next::after,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_next::after {
    content: "\203A";
}

/* 맨끝 \00BB = » */
#tg-tips-gallery .tg-tips-gallery__pagination .pg_page.pg_end::after,
#tg-tips-gallery .tg-tips-gallery__pagination a.pg_end::after {
    content: "\00BB";
}

/* 페이지네이션 .sound_only 숨김 처리 */
#tg-tips-gallery .tg-tips-gallery__pagination .sound_only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
}

/* ── 반응형 디자인 (모바일 퍼스트) ── */

/* 모바일 (기본) - 1열 */
/* 이미 grid-template-columns: 1fr 로 설정됨 */

/* 태블릿 세로 (480px 이상) */
@media (min-width: 480px) {
    #tg-tips-gallery .tg-tips-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    #tg-tips-gallery .tg-tips-gallery__card-title {
        font-size: 14px;
    }

    #tg-tips-gallery .tg-tips-gallery__card-desc {
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    /* 2열 마지막 아이템 정렬 규칙은 하단 통합 미디어 쿼리로 이동 */
}

/* 태블릿 가로 (768px 이상) */
@media (min-width: 768px) {
    #tg-tips-gallery.tg-tips-gallery {
        padding: 0 20px;
    }

    #tg-tips-gallery .tg-tips-gallery__search {
        margin-bottom: 40px;
    }

    #tg-tips-gallery .tg-tips-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    #tg-tips-gallery .tg-tips-gallery__card-title {
        font-size: 15px;
    }

    #tg-tips-gallery .tg-tips-gallery__card-body {
        padding: 20px 22px 22px;
    }

    #tg-tips-gallery .tg-tips-gallery__search-icon {
        display: block;
    }
}

/* 데스크톱 (1024px 이상) */
@media (min-width: 1024px) {
    #tg-tips-gallery .tg-tips-gallery__grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 28px;
    }

    #tg-tips-gallery .tg-tips-gallery__card-title {
        font-size: 16px;
    }

    #tg-tips-gallery .tg-tips-gallery__card-desc {
        -webkit-line-clamp: 3;
        line-clamp: 3;
        font-size: 13.5px;
    }

    #tg-tips-gallery .tg-tips-gallery__card-body {
        padding: 20px 24px 24px;
    }

    /* 3열 마지막 아이템 정렬 규칙은 하단 통합 미디어 쿼리로 이동 */
}

/* 와이드 데스크톱 (1280px 이상) */
@media (min-width: 1280px) {
    #tg-tips-gallery.tg-tips-gallery {
        max-width: 1300px;
    }
}

/* ── 마지막 줄 아이템 가운데 정렬 처리 ── */

/* 2열 레이아웃 (태블릿: 480px ~ 1023px) */
/* 1024px 이상에서는 이 이상한 span 규칙이 적용되지 않도록 범위 제한 */
@media (min-width: 480px) and (max-width: 1023px) {
    #tg-tips-gallery .tg-tips-gallery__card:last-child:nth-child(2n + 1):not(:only-child) {
        grid-column: 1 / -1;
        width: calc(50% - 10px); /* 1열짜리 크기 유지 */
        max-width: none;
        margin: 0 auto;
    }
}



/* ── 다크모드 지원 (시스템 기본 설정 연동) ── */
@media (prefers-color-scheme: dark) {
    /* 다크모드는 사이트 전체 테마와 조화를 위해 비활성화 상태 유지 */
    /* 필요 시 아래 주석을 해제하여 활성화 가능 */
    /*
    :root {
        --tg-surface: #1E1E2E;
        --tg-bg: #11111B;
        --tg-text-primary: #CDD6F4;
        --tg-text-secondary: #A6ADC8;
        --tg-text-muted: #585B70;
        --tg-border: #313244;
    }
    */
}

/* ── 접근성: 모션 감소 모드 지원 ── */
@media (prefers-reduced-motion: reduce) {
    #tg-tips-gallery .tg-tips-gallery__card {
        transition: none;
        opacity: 1;
        transform: none;
    }

    #tg-tips-gallery .tg-tips-gallery__card-video,
    #tg-tips-gallery .tg-tips-gallery__card-img {
        transition: none;
    }

    #tg-tips-gallery .tg-tips-gallery__card-overlay {
        transition: none;
    }

    #tg-tips-gallery .tg-tips-gallery__card-read-more {
        transition: none;
        transform: none;
    }
}

/* ── 프린트 스타일 ── */
@media print {
    #tg-tips-gallery .tg-tips-gallery__search {
        display: none;
    }

    #tg-tips-gallery .tg-tips-gallery__card {
        opacity: 1;
        transform: none;
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    #tg-tips-gallery .tg-tips-gallery__card-overlay {
        display: none;
    }

    #tg-tips-gallery .tg-tips-gallery__footer {
        display: none;
    }
}
