/*
 * Homepage featured section, redesign (13 Nov 2026).
 * Paired with app/Views/themes/magazine/partials/_featured_section_news.php.
 *
 * Problems this fixes, as seen on the live layout:
 *   1. Images sat in fixed-height cells with object-fit: cover, so the 16:9
 *      artwork was cropped. Because the artwork carries its own headline
 *      ("DEVOPS ENGINEER COURSE", "OpenShift 5"), the crop cut words in half.
 *   2. The post title was overlaid on that artwork, so two headlines fought
 *      for the same space and neither read cleanly.
 *   3. Top Headlines had a fixed height with overflow hidden, so the last
 *      item was sliced off, and titles were cut by character count mid-word.
 *   4. On tablet the two side cards shrank to a 2:1 strip with overlaid text.
 *
 * Approach: show every image whole at 16:9 and put the text below it.
 * Everything is scoped to .fs2, so the old rules in style-3.1.css stay
 * untouched for the other themes.
 */

.fs2 {
    --fs2-gap: 24px;
    --fs2-radius: 12px;
    --fs2-radius-sm: 10px;
    --fs2-text: var(--vr-text-main, #18181b);
    --fs2-muted: var(--vr-text-muted, #6b7280);
    --fs2-line: var(--vr-gray-150, #e5e7eb);
    --fs2-accent: var(--vr-theme-color, #e50914);
    --fs2-media-bg: var(--vr-gray-100, #f3f4f6);
    padding-top: 1.25rem;
    padding-bottom: 2rem;
}

/* ---------- Grid ---------- */

.fs2 .fs2-grid {
    display: grid;
    gap: var(--fs2-gap);
    grid-template-columns: 1fr;
    grid-template-areas: "main" "side" "headlines";
    align-items: start;
}

.fs2 .fs2-main { grid-area: main; min-width: 0; }
.fs2 .fs2-side { grid-area: side; min-width: 0; display: grid; gap: var(--fs2-gap); }
.fs2 .fs2-headlines { grid-area: headlines; min-width: 0; }

@media (min-width: 576px) and (max-width: 991.98px) {
    .fs2 .fs2-side { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 992px) {
    .fs2 .fs2-grid {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "main side headlines";
    }
}

/* Undo the theme's fixed-height, full-bleed mobile container. */
@media (max-width: 991.98px) {
    .featured-section.fs2 > .container-xl { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Cards ---------- */

.fs2 .fs2-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    height: 100%;
    background: none;
}

.fs2 .fs2-media {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    border-radius: var(--fs2-radius);
    overflow: hidden;
    background: var(--fs2-media-bg);
    isolation: isolate;
}

.fs2 .fs2-card-side .fs2-media { border-radius: var(--fs2-radius-sm); }

.fs2 .fs2-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;            /* never crop: 24 newer images are 3:2, one is portrait */
    z-index: 1;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fs2 .fs2-card:hover .fs2-img { transform: scale(1.025); }

/* Same image, blurred, filling whatever the contained image leaves empty.
   Same URL and srcset as the real image, so it comes from cache: no extra bytes.
   On 16:9 images it sits entirely underneath and is never seen. */
.fs2 .fs2-img-bg {
    position: absolute;
    inset: -24px;
    width: calc(100% + 48px);
    height: calc(100% + 48px);
    object-fit: cover;
    filter: blur(22px) saturate(1.15);
    opacity: 0.75;
    z-index: 0;
    pointer-events: none;
}

/* Badges from getPostBadges() expect an absolutely positioned parent. */
.fs2 .fs2-media > :not(.fs2-img):not(.fs2-img-bg) { z-index: 2; }

.fs2 .fs2-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

/* Category: a pill on the lead story, plain coloured text on the side cards. */
.fs2 .fs2-cat {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: var(--cat, var(--fs2-accent));
    color: #fff !important;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: filter 0.2s ease;
}

.fs2 .fs2-cat:hover { filter: brightness(0.92); }

.fs2 .fs2-cat-text {
    padding: 0;
    background: none;
    color: var(--cat, var(--fs2-accent)) !important;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.fs2 .fs2-cat-text:hover { filter: none; text-decoration: underline; text-underline-offset: 3px; }

/* Titles: clamp by lines, never by character count. */
.fs2 .fs2-title {
    margin: 0;
    color: var(--fs2-text);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-shadow: none;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fs2 .fs2-card-lead .fs2-title {
    font-size: clamp(1.3rem, 1.05rem + 0.9vw, 1.75rem);
    line-height: 1.25;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.fs2 .fs2-card-side .fs2-title {
    font-size: 1rem;
    line-height: 1.4;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.fs2 .fs2-title a {
    color: inherit !important;
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0 1px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.25s ease, color 0.2s ease;
}

.fs2 .fs2-card:hover .fs2-title a,
.fs2 .fs2-title a:focus-visible { background-size: 100% 1px; }

/* Make the whole card clickable through the title link, without nesting. */
.fs2 .fs2-title a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.fs2 .fs2-cat,
.fs2 .fs2-meta a { position: relative; z-index: 3; }

.fs2 .fs2-meta,
.fs2 .fs2-meta a,
.fs2 .fs2-meta span,
.fs2 .fs2-meta i {
    color: var(--fs2-muted) !important;
    font-size: 0.8rem;
    font-weight: 500;
    text-shadow: none;
    text-decoration: none;
}

.fs2 .fs2-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; }
.fs2 .fs2-meta a:hover { color: var(--fs2-text) !important; }

/* Side cards on phones: compact horizontal rows rather than two more big images. */
@media (max-width: 575.98px) {
    .fs2 .fs2-card-side {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.85rem;
    }

    .fs2 .fs2-card-side .fs2-media { flex: 0 0 40%; }
    .fs2 .fs2-card-side .fs2-title { font-size: 0.95rem; }
    .fs2 .fs2-card-side .fs2-meta { display: none; }
}

/* ---------- Slider ---------- */

.fs2 .fs2-slider { position: relative; overflow: hidden; }
.fs2 .fs2-slider .swiper-slide { height: auto; }

/* Arrows sit over the image only, not over the text beneath it. */
.fs2 .fs2-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    z-index: 5;
    pointer-events: none;
}

.fs2 .fs2-nav-btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #18181b;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.fs2 .fs2-slider:hover .fs2-nav-btn,
.fs2 .fs2-nav-btn:focus-visible { opacity: 1; transform: scale(1); }

.fs2 .fs2-nav-btn:hover { background: #fff; }

/* Touch screens have no hover, so keep the arrows visible there. */
/* Touch screens have no hover, so the arrows must stay visible. Mid-height on
   the left edge they covered the artwork's own headline, so on touch they move
   to a small pair in the bottom-right corner. Swiping works as well. */
@media (hover: none) {
    .fs2 .fs2-nav {
        justify-content: flex-end;
        align-items: flex-end;
        gap: 0.4rem;
        padding: 0.6rem;
    }

    .fs2 .fs2-nav-btn {
        opacity: 1;
        transform: none;
        width: 32px;
        height: 32px;
        background: rgba(255, 255, 255, 0.85);
    }

    .fs2 .fs2-nav-btn svg { width: 16px; height: 16px; }
}

/* ---------- Top Headlines ---------- */

.fs2 .fs2-headlines { padding: 0 !important; }

.fs2 .fs2-headlines-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--fs2-text);
    color: var(--fs2-text);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.fs2 .fs2-headlines-title::before {
    content: "";
    width: 4px;
    height: 1.1em;
    border-radius: 2px;
    background: var(--fs2-accent);
}

.fs2 .fs2-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: fs2;
}

.fs2 .fs2-list-item {
    position: relative;
    counter-increment: fs2;
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    column-gap: 0.5rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--fs2-line);
}

.fs2 .fs2-list-item:last-child { border-bottom: 0; }

.fs2 .fs2-list-item::before {
    content: counter(fs2, decimal-leading-zero);
    grid-row: span 2;
    color: var(--fs2-accent);
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
}

.fs2 .fs2-list-title {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.fs2 .fs2-list-title a {
    color: var(--fs2-text) !important;
    text-decoration: none;
    transition: color 0.2s ease;
}

.fs2 .fs2-list-title a::after { content: ""; position: absolute; inset: 0; }

.fs2 .fs2-list-item:hover .fs2-list-title a,
.fs2 .fs2-list-title a:focus-visible { color: var(--fs2-accent) !important; }

.fs2 .fs2-list-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    font-size: 0.72rem;
    line-height: 1.3;
    color: var(--fs2-muted);
}

.fs2 .fs2-list-cat {
    position: relative;
    z-index: 2;
    color: var(--fs2-muted) !important;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
}

.fs2 .fs2-list-cat::after { content: "\00B7"; margin-left: 0.5rem; color: var(--fs2-line); }
.fs2 .fs2-list-meta:not(:has(time)) .fs2-list-cat::after { content: none; }
.fs2 .fs2-list-cat:hover { color: var(--fs2-accent) !important; }

/* Tablet: headlines in two columns so the list does not run on forever. */
@media (min-width: 576px) and (max-width: 991.98px) {
    .fs2 .fs2-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--fs2-gap); }
    .fs2 .fs2-list-item:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}

/* ---------- Focus + motion ---------- */

.fs2 a:focus-visible,
.fs2 button:focus-visible {
    outline: 2px solid var(--fs2-accent);
    outline-offset: 3px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .fs2 .fs2-img,
    .fs2 .fs2-title a,
    .fs2 .fs2-nav-btn { transition: none; }
    .fs2 .fs2-card:hover .fs2-img { transform: none; }
    .fs2 .fs2-img-bg { filter: blur(22px); }
}

/* ---------- Dark mode ---------- */

[data-bs-theme="dark"] .fs2 {
    --fs2-text: var(--vr-text-main, #f4f4f5);
    --fs2-muted: var(--vr-text-muted, #a1a1aa);
    --fs2-line: rgba(255, 255, 255, 0.12);
    --fs2-media-bg: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .fs2 .fs2-nav-btn { background: rgba(24, 24, 27, 0.9); color: #fff; }
