/* =================================================================
   WindyFlo Blog Index - Custom Styles
   ================================================================= */

/* --- 1. 기본 설정 및 변수 --- */
:root {
    --gp-blog-index-primary: #FF4600;
    --gp-blog-index-secondary: #0D74F7;
    --gp-blog-index-accent: #854BFF;
    --gp-blog-index-success: #A6FF00;
    --gp-blog-index-text: #333;
    --gp-blog-index-text-light: #666;
    --gp-blog-index-border: #e0e0e0;
    --gp-blog-index-bg-light: #f5f5f5;
    --gp-blog-index-gap: 20px;
    --gp-blog-index-transition: all 0.3s ease;
}

/* --- 2. Blog Index Wrapper --- */
.gp-blog-index-wrapper {
    position: relative;
    width: 100%;
    /* 콘텐츠 패딩 영역에서 히어로가 비치는 현상 방지 */
    background-color: #fff;
    z-index: var(--z-content);
}

/* --- 3. Mobile Category Filter (Desktop에서 숨김) --- */
.gp-blog-index-mobile-filter {
    display: none;
    margin-bottom: 30px;
}

/* 메인 인덱스 콘텐츠도 불투명 배경 및 레이어 고정 */
.gp-blog-index-content {
    position: relative;
    background-color: #fff;
    z-index: var(--z-content);
}

@media (max-width: 768px) {
    /* Mobile에서 표시 */
    .gp-blog-index-mobile-filter {
        display: block;
    }
}

/* --- 4. Category Filter Widget --- */
/* Category filter widget styles moved to gp-category-filter-widget.css */

/* 상위 GeneratePress 컨테이너들도 확실히 불투명 처리 */
#primary.content-area,
main#main.site-main,
.site-content#content,
.site.grid-container#page,
.grid-container {
    background-color: #fff;
}

/* All category filter styles moved to gp-category-filter-widget.css */

/* --- 5. Category Section --- */
.gp-category-section {
    margin-bottom: 60px;
    /* 섹션 자체의 패딩 영역도 항상 불투명 처리 */
    background-color: #fff;
}

/* Section Divider - Light gray horizontal line */
.gp-section-divider {
    width: 100%;
    height: 1px;
    background-color: #e5e7eb; /* Light gray color */
    margin: 40px 0;
    opacity: 0.6;
}

.gp-category-section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.gp-category-section__title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: #1a1d1f;
    line-height: 34px;
    letter-spacing: -0.5px;
}

.gp-category-section__more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--gp-blog-index-text);
    text-decoration: none;
    font-weight: 500;
    transition: var(--gp-blog-index-transition);
}

.gp-category-section__more:hover {
    color: var(--gp-blog-index-primary);
    gap: 12px;
}

.gp-icon-arrow {
    transition: var(--gp-blog-index-transition);
}

/* --- Featured Post Group Layout --- */
.gp-featured-group { display:flex; flex-direction:column; gap:52px; }

/* Featured header spacing */
.gp-category-section--featured .gp-category-section__header { margin-bottom: 24px; }

/* Featured sub row wrapper (ensure row layout aligns visually) */
.gp-featured-group__row2 .uq-post-card-group--row .uq-post-card-group__inner { column-gap: 20px; }

/*
  Card background policy (theme):
  - Keep .uq-post-card root transparent in lists/rows so segmented surfaces define paint.
  - Provide body background via segmented surface tokens (e.g., card_surfaces.body.bg) when needed.
*/
/* Regular groups: ensure row layout cards have compact proportions */
.gp-regular-posts-grid .uq-post-card { --uq-card-surface-gap:12px; background-color: transparent; }
.gp-regular-posts-grid .uq-post-card__title { 
    font-size: 20px;
    font-weight: 700;
    line-height: 30px;
    letter-spacing: -0.5px;
}
.gp-regular-posts-grid .uq-post-card__excerpt { 
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: #6b7280;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 20px; /* Fallback to prevent height overflow */
}
.gp-regular-posts-grid .entry-meta { 
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: #6b7280;
}

/* Media skin (approximate the benchmark styles) */
.gp-regular-posts-grid .uq-post-card__media,
.gp-featured-sub-cards .uq-post-card__media {
    /* Override aspect ratio to match Channel Talk design (305:162 = 1.883:1) */
    aspect-ratio: 305 / 162 !important;
    background-color: #fafafa;
    border-radius: 12px;
    border: 1px solid #e5e8eb;
    overflow: hidden;
}

/* Images already handled by uq-post-card library CSS */

/* Global excerpt height fix to prevent overflow issues */
.uq-post-card__excerpt {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Featured sub-cards: transparent card root to rely on segmented surfaces */
.gp-featured-sub-cards .uq-post-card { background-color: transparent; }

/* Row 1: 1 Large Post */
.gp-featured-group__row1 {
    width: 100%;
}

/* Row 2: 3 Small Posts */
.gp-featured-group__row2 {
    width: 100%;
}

/* Featured Main Card Styles */
.gp-featured-main-card {
    background-color: #ffffff; /* Ensure white background for segmented mode */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e8eb;
}

.gp-featured-main-card.uq-post-card {
    background-color: #ffffff !important; /* Override transparent background from segmented mode */
}

/* For segmented mode - direct children layout */
.gp-featured-main-card.uq-post-card--card-surface-segmented {
    display: grid !important;
    grid-template-columns: 2fr 1fr !important; /* Clear 2:1 ratio */
    align-items: center !important; /* Vertical center alignment */
    min-height: 320px;
    gap: 0 !important; /* Remove gap between media and body */
}

.gp-featured-main-card .uq-post-card__inner {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Clear 2:1 ratio */
    align-items: center; /* Vertical center alignment */
    min-height: 320px;
    background-color: #ffffff; /* Ensure inner container is also white */
}

.gp-featured-main-card .uq-post-card__media,
.gp-featured-main-card .uq-card-surface--media { 
    /* Remove any padding that might be inherited */
    padding: 0 !important;
    height: 100%;
    width: 100%;
    /* Aspect ratio handled by grid container */
    aspect-ratio: unset !important;
    margin-right: var(--featured-media-right-inset, 8px); /* Media right inset alignment */
    margin-bottom: 0 !important; /* Remove bottom margin */
    background-color: transparent; /* Media area should be transparent to show image */
    display: block;
}

/* ensure media covers left grid area */
.gp-featured-main-card .uq-post-card__media img,
.gp-featured-main-card .uq-card-surface--media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gp-featured-main-card .uq-post-card__body,
.gp-featured-main-card .uq-card-surface--body,
.gp-featured-main-card .uq-post-card__content {
    padding: 32px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important; /* vertical center */
    transform: translateY(var(--featured-body-offset-y, -6px)); /* Body vertical offset */
    background-color: white !important;
    width: 100%;
    height: 100%;
}

.gp-featured-main-card .uq-post-card__title {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 42px;
    letter-spacing: -1px; /* Channel Talk style */
}

.gp-featured-main-card .uq-post-card__title a {
    color: #1a1d1f;
    text-decoration: none;
}

.gp-featured-main-card .uq-post-card__title a:hover {
    color: #1a1d1f;
    text-decoration: none;
}

.gp-featured-main-card .uq-post-card__excerpt {
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: #6b7280;
}
/* Entry meta on featured main card */
.gp-featured-main-card .entry-meta { font-size: 14px; }

/* Featured Sub Cards */
.gp-featured-sub-cards .uq-post-card__title { 
    font-size: 20px;
    font-weight: 700;
    line-height: 30px;
    letter-spacing: -0.5px;
}
.gp-featured-sub-cards .uq-post-card__excerpt { 
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: #6b7280;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 20px; /* Fallback to prevent height overflow */
}
.gp-featured-sub-cards .entry-meta { 
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: #6b7280;
}

/* Regular Post Section */
.gp-category-section--regular .gp-regular-posts {
    margin-top: 0;
}

.gp-regular-posts-grid .uq-post-card__title { font-size: 20px; }

/* Removed duplicate .uq-post-card__excerpt rules - already defined above */

/* Featured Main Card Meta Information */
.gp-featured-main-card .uq-post-card__category {
    margin-bottom: 12px;
}

.gp-featured-main-card .uq-post-card__category-link {
    display: inline-block;
    padding: 4px 12px;
    background: #f3f4f6;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #7c3aed;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
}

.gp-featured-main-card .uq-post-card__category-link:hover {
    background: #ede9fe;
    color: #6d28d9;
}

.gp-featured-main-card .uq-post-card__date-author {
    margin-top: 16px;
    font-size: 14px;
    color: #9ca3af;
}

/* --- 6. Category Posts Grid --- */
.gp-category-posts {
    margin-bottom: 50px;
}

.gp-category-posts__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.gp-category-posts__title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--gp-blog-index-text);
}

.gp-category-posts__more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--gp-blog-index-text-light);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--gp-blog-index-transition);
}

.gp-category-posts__more:hover {
    color: var(--gp-blog-index-primary);
    gap: 10px;
}

/* --- 7. Filtered Posts --- */
.gp-filtered-posts {
    animation: fadeIn 0.3s ease;
}

.gp-filtered-posts__title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 30px;
    color: var(--gp-blog-index-text);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 8. 반응형 디자인 --- */
@media (max-width: 1024px) {
    .gp-featured-main-card { grid-template-columns: 60% 40%; }
    
    .gp-featured-main-card .uq-post-card__content {
        padding: 24px;
    }
    
    .gp-featured-main-card .uq-post-card__title {
        font-size: 20px;
    }
    
    .gp-featured-main-card .uq-post-card__excerpt {
        font-size: 15px;
    }
}

@media (max-width: 768px) {
    .gp-category-section {
        margin-bottom: 40px;
    }
    
    .gp-category-section__title {
        font-size: 20px;
    }
    
    .gp-category-section__featured {
        margin-bottom: 20px;
    }
    
    /* 모바일에서 Featured Group 레이아웃 조정 */
    .gp-featured-group {
        gap: 16px;
    }
    
    /* Featured Main Card - 모바일에서는 Vertical layout */
    .gp-featured-main-card.uq-post-card--card-surface-segmented {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        min-height: auto;
    }
    
    .gp-featured-main-card .uq-post-card__media,
    .gp-featured-main-card .uq-card-surface--media {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16/9 !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }
    
    .gp-featured-main-card .uq-post-card__body,
    .gp-featured-main-card .uq-card-surface--body,
    .gp-featured-main-card .uq-post-card__content {
        padding: 20px !important;
        transform: none !important;
    }
    
    .gp-featured-main-card .uq-post-card__title {
        font-size: 18px;
        line-height: 26px;
    }
    
    .gp-featured-main-card .uq-post-card__excerpt {
        font-size: 14px;
    }
    
    /* Regular Posts Grid - 모바일에서는 1 Column + Horizontal layout */
    .gp-regular-posts-grid .uq-post-card-group__inner,
    .gp-featured-sub-cards .uq-post-card-group__inner {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    /* Regular Cards - Horizontal layout on mobile with media on right (35% width) */
    .gp-regular-posts-grid .uq-post-card,
    .gp-featured-sub-cards .uq-post-card {
        display: grid !important;
        grid-template-columns: 1fr 35% !important;
        gap: 12px !important;
        align-items: center !important;
    }
    
    /* For segmented mode cards */
    .gp-regular-posts-grid .uq-post-card--card-surface-segmented,
    .gp-featured-sub-cards .uq-post-card--card-surface-segmented {
        display: grid !important;
        grid-template-columns: 1fr 35% !important;
        gap: 0 !important;
    }
    
    /* Move media to the right on mobile */
    .gp-regular-posts-grid .uq-post-card__media,
    .gp-regular-posts-grid .uq-card-surface--media,
    .gp-featured-sub-cards .uq-post-card__media,
    .gp-featured-sub-cards .uq-card-surface--media {
        order: 2 !important; /* Media on right */
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1/1 !important; /* Square aspect for mobile */
    }
    
    .gp-regular-posts-grid .uq-post-card__body,
    .gp-regular-posts-grid .uq-card-surface--body,
    .gp-regular-posts-grid .uq-post-card__content,
    .gp-featured-sub-cards .uq-post-card__body,
    .gp-featured-sub-cards .uq-card-surface--body,
    .gp-featured-sub-cards .uq-post-card__content {
        order: 1 !important; /* Body on left */
        padding: 12px !important;
    }
    
    /* Adjust title and excerpt for mobile horizontal cards */
    .gp-regular-posts-grid .uq-post-card__title,
    .gp-featured-sub-cards .uq-post-card__title {
        font-size: 16px;
        line-height: 22px;
    }
    
    .gp-regular-posts-grid .uq-post-card__excerpt,
    .gp-featured-sub-cards .uq-post-card__excerpt {
        display: none; /* Hide excerpt on mobile for cleaner look */
    }
    
    .gp-regular-posts-grid .entry-meta,
    .gp-featured-sub-cards .entry-meta {
        font-size: 12px;
    }
    
    /* 카테고리 포스트 그리드 간격 조정 */
    .gp-category-posts {
        margin-bottom: 30px;
    }
    
    .gp-category-posts__title {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .gp-category-section__header {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .gp-category-section__more {
        font-size: 14px;
    }
    
    .gp-preview-posts .uq-post-card__title {
        font-size: 16px;
    }
    
    .gp-featured-main-card .uq-post-card__content {
        padding: 16px;
    }
}

/* --- 9. 카테고리별 색상 테마 (선택사항) --- */
.gp-category-section[data-section="recent"] .gp-category-section__title {
    color: var(--gp-blog-index-primary);
}

.gp-category-section[data-section="featured"] .gp-category-section__title {
    color: var(--gp-blog-index-secondary);
}

.gp-category-section[data-section="success-stories"] .gp-category-section__title {
    color: var(--gp-blog-index-success);
}

/* --- 10. Loading States --- */
.gp-blog-index-content.loading {
    opacity: 0.6;
    pointer-events: none;
}

.gp-blog-index-content.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--gp-blog-index-border);
    border-top-color: var(--gp-blog-index-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}
