
/* --- Headline Grid Layout --- */
#headline-grid-container {
    max-width: 1200px;
    margin: 140px auto 10px auto; 
    /* 
       4. 타이틀과 메인 이미지 사이 space를 1/2로. (Previously 155px for desktop)
       Header 100px. Space was ~55px. 1/2 of 55 = 27px. 
       So margin-top = 100 + 27 = 127px. (approx 130px)
    */
    margin-top: 130px;
    padding: 0 40px;
    box-sizing: border-box;
    width: 100%;
    display: block; 
}

@media screen and (min-width: 1024px) {
    #headline-grid-container {
        padding: 0 60px;
        /* Desktop */
        margin-top: 90px; 
    }
}

.headline-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* Fixed to 6 columns for balanced layout */
    /* Keep width, but match top row aspect ratio to bottom row (wow/new/review) */
    --headline-row-bottom: 250px;
    --headline-top-scale: 1.35; /* 2.25 cols / 2 cols = 1.125 */
    grid-template-rows: calc(var(--headline-row-bottom) * var(--headline-top-scale)) var(--headline-row-bottom);
    gap: 10px;
}

/* --- Headline Filter Bar (Top Tags/Themes) --- */
.headline-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    margin: 0 0 12px 0;
}

.headline-filter-item {
    font-size: 13px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    background: #0f1d2e;
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.15);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.headline-filter-item:hover {
    transform: translateY(-1px);
    background: #14273d;
    border-color: rgba(255,255,255,0.35);
}

/* Grid Slots Definition */
/* Top Row: 2 Big items - Reduced width to 75% (3/4) */
.headline-slot-1 { /* Hot */
    grid-column: 1 / 4; 
    grid-row: 1;
    width: 75%;
    justify-self: end; /* Push to center */
}
.headline-slot-2 { /* Focus */
    grid-column: 4 / 7; 
    grid-row: 1;
    width: 75%;
    justify-self: start; /* Push to center */
}

/* Bottom Row: 3 items - Full Width */
.headline-slot-3 { /* Wow */
    grid-column: 1 / 3; 
    grid-row: 2;
    /* Default width auto, justify stretch */
}
.headline-slot-4 { /* New */
    grid-column: 3 / 5; 
    grid-row: 2;
}
.headline-slot-5 { /* Mixed */
    grid-column: 5 / 7; 
    grid-row: 2;
}

/* Adjust Grid Template for 6 columns */
.headline-grid {
    grid-template-columns: repeat(6, 1fr);
}

/* Card Styling */
.headline-card {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background-color: #f0f0f0;
}

/* Image */
.headline-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 5s ease;
}
.headline-card:hover .headline-img {
    transform: scale(1.05); /* Slow zoom effect */
}

/* Overlay for text readability */
.headline-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}

/* Theme Label (Top Right) */
.headline-theme {
    position: absolute;
    top: 6px; 
    right: 6px; /* near top-right corner */
    left: auto;
    background-color: rgba(0,0,0,0.78);
    border: 1px solid rgba(255,255,255,0.24);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    letter-spacing: 0.01em;
    text-transform: uppercase;
    z-index: 2;
}

/* Specific styling for Top Row (Hot/Focus) */
.headline-slot-1 .headline-theme,
.headline-slot-2 .headline-theme {
    font-size: 14px;
    padding: 5px 15px;
}

/* Title (Bottom Center) */
.headline-title {
    --headline-title-size: 20px;
    position: absolute;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px 14px 14px;
    background: rgba(0, 0, 0, 0.68);
    border-radius: 0 0 12px 12px; /* top corners square, bottom corners rounded */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 2;
    text-decoration: none;
}

.headline-title-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    width: 100%;
    max-height: calc(var(--headline-title-size) * 1.24 * 2);
    color: white;
    text-align: center;
    font-size: var(--headline-title-size);
    font-weight: 800;
    line-height: 1.24;
    word-break: keep-all;
    overflow-wrap: anywhere;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.headline-slot-1 .headline-title,
.headline-slot-2 .headline-title {
    --headline-title-size: 30px; /* Larger title for top row */
}

.headline-card:hover .headline-title {
    text-decoration: underline;
}

@media screen and (min-width: 1024px) {
    .headline-slot-3 .headline-title,
    .headline-slot-4 .headline-title,
    .headline-slot-5 .headline-title {
        --headline-title-size: 24px;
    }
}

/* Fading Transition Classes */
.headline-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: 1;
}
.headline-content.active {
    opacity: 1;
    z-index: 2;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    #headline-grid-container {
        margin-top: 78px; /* Task 3: Reduced spacing by 1/2 (Header 70px + ~8px gap) */
        padding: 0 15px; /* Matches header padding */
    }

    .headline-grid {
        display: flex;
        flex-direction: column;
        grid-template: none;
        height: auto;
    }
    .headline-card {
        height: 250px;
    }

    .headline-filter-bar {
        display: none;
    }

    .headline-filter-item {
        font-size: 12px;
        padding: 5px 10px;
    }

    /* Task 3: Normalize sizes for Top 2 headlines (Hot/Focus) */
    .headline-slot-1 .headline-theme,
    .headline-slot-2 .headline-theme {
        font-size: 14px; /* Same as others */
        padding: 5px 15px;
    }

    .headline-slot-1 .headline-title,
    .headline-slot-2 .headline-title {
        --headline-title-size: 20px; /* Same as others */
    }

    .headline-title {
        padding: 10px 10px 12px 10px;
    }
    
    /* Ensure slots take full width if needed, though flex-direction column handles it */
    .headline-slot-1, .headline-slot-2 {
        width: 100%;
    }
}
