/* ============================================================
   Media section (home page). Shares the Technology backdrop and tokens
   (css/tech.css) but has its own shape: a cinematic feature banner with the
   thumbnail bleeding across the card under a scrim, a row of filter chips,
   and a scroll-snapping filmstrip of poster tiles with the titles set into
   the image. Rendered by js/media-section.js from blogs.js.
   ============================================================ */

/* ── Filters ───────────────────────────────────────────────────────── */

.md-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: -6px 0 16px;
    text-align: left;
}

.md-bar {
    border-bottom: 1px solid var(--tk-line);
    margin-bottom: 18px;
}

/* Plain underline tabs. */
.md-chips {
    display: flex;
    gap: 26px;
}

.md-chip {
    position: relative;
    padding: 8px 2px 12px;
    border: 0;
    background: none;
    color: var(--tk-muted);
    font-family: var(--font-display);
    font-size: 1.14rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.md-chip .tk-count {
    margin-left: 4px;
    font-size: 0.92rem;
    font-weight: 500;
}

.md-chip:hover {
    color: var(--tk-text);
}

.md-chip.is-active {
    color: var(--tk-text);
}

.md-chip.is-active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--tk-text);
}

.md-count {
    font-family: var(--font-display);
    font-size: 0.98rem;
    color: var(--tk-muted);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ── Feature banner ────────────────────────────────────────────────── */

.md-feature {
    position: relative;
    padding: 1px;
    border-radius: 18px;
    background: var(--tk-edge);
    text-align: left;
    box-shadow: 0 8px 22px rgba(6, 8, 26, 0.22);
}

html[data-theme="light"] .md-feature {
    box-shadow: 0 2px 8px rgba(40, 50, 100, 0.05);
}

.md-feature-inner {
    position: relative;
    display: block;
    min-height: 340px;
    border-radius: 17px;
    background: var(--tk-card);
    overflow: hidden;
    text-decoration: none;
    color: var(--tk-text);
}

.md-feature-inner:hover {
    color: var(--tk-text);
    text-decoration: none;
}

/* The thumbnail runs across the whole banner, brightest on the left, and
   dissolves into the panel where the copy sits. */
.md-feature-art {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Non-16:9 thumbnails sit uncropped over a blurred copy of themselves. */
.md-blur,
.md-img {
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-position: center;
}

.md-blur {
    background-size: cover;
    filter: blur(22px) brightness(0.55) saturate(1.1);
    transform: scale(1.15);
}

.md-img {
    background-size: contain;
}

.md-feature-inner:hover .md-feature-art {
    transform: scale(1.03);
}

/* Only a thin blend at the picture's edge, nothing over the picture. */
.md-feature-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(15, 16, 36, 0) 0%, rgba(15, 16, 36, 0) 40%, rgba(15, 16, 36, 0.35) 45%, rgba(15, 16, 36, 0.96) 50%, rgba(15, 16, 36, 1) 100%);
}

html[data-theme="light"] .md-feature-inner::after {
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0.35) 45%, rgba(255, 255, 255, 0.97) 50%, rgba(255, 255, 255, 1) 100%);
}

.md-feature-copy {
    position: relative;
    z-index: 1;
    margin-left: 54%;
    padding: 40px 40px 36px 0;
    max-width: 560px;
}

.md-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--hero-cyan, #4dc3ff);
    margin-bottom: 10px;
}

html[data-theme="light"] .md-eyebrow {
    color: #0b6fa8;
}

.md-eyebrow .md-badge {
    position: static;
}

.md-feature-title {
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 2.4vw, 2.5rem);
    font-weight: 700;
    line-height: 1.04;
    margin: 0 0 8px;
    color: var(--tk-text);
}

.md-feature-meta {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--tk-muted);
    margin: 0 0 18px;
}

.md-feature-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 8px;
    background: #fff;
    color: #0f1024;
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

html[data-theme="light"] .md-feature-cta {
    background: #1e2748;
    color: #fff;
    box-shadow: 0 6px 16px rgba(30, 39, 72, 0.25);
}

.md-feature-inner:hover .md-feature-cta {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

/* Type badge, shared by banner and tiles. */
.md-badge {
    display: inline-block;
    /* Khand carries extra space under the baseline; trim the bottom to centre the caps. */
    padding: 5px 9px 1px;
    line-height: 1.15;
    border-radius: 6px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(10, 10, 26, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.md-badge--video { background: rgba(124, 92, 255, 0.88); }
.md-badge--series { background: rgba(16, 122, 84, 0.9); }
.md-badge--article { background: rgba(6, 135, 201, 0.88); }

/* ── Filmstrip ─────────────────────────────────────────────────────── */

.md-strip-wrap {
    position: relative;
    margin-top: 22px;
    text-align: left;
}

.md-strip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.md-strip-title {
    font-family: var(--font-display);
    font-size: 1.18rem;
    font-weight: 600;
    color: var(--tk-text);
    letter-spacing: 0.02em;
}

.md-strip-nav {
    display: flex;
    gap: 8px;
}

.md-arrow {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--tk-btn-border);
    background: var(--tk-btn-bg);
    color: var(--tk-text);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
}

.md-arrow:hover {
    border-color: rgba(167, 139, 250, 0.8);
}

.md-arrow[disabled] {
    opacity: 0.35;
    cursor: default;
}

/* Scrollbar hidden; the arrows and the edge fade say there is more. */
.md-strip-clip {
    position: relative;
}

.md-strip-clip.has-more::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 14px;
    opacity: 0.3;
    pointer-events: none;
    /* transparent, not a dark alpha, so light mode does not get a grey smear */
    background: linear-gradient(90deg, transparent, var(--tk-bg));
}

.md-strip {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 4px 0 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.md-strip::-webkit-scrollbar {
    display: none;
}

.md-tile {
    position: relative;
    flex: 0 0 calc((100% - 42px) / 4);
    min-width: 230px;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    scroll-snap-align: start;
    background: #0b0c1d;
    border: 1px solid var(--tk-line);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    color: #fff;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

html[data-theme="light"] .md-tile {
    box-shadow: 0 2px 6px rgba(40, 50, 100, 0.06);
}

.md-tile:hover {
    color: #fff;
    text-decoration: none;
    transform: translateY(-3px);
    border-color: rgba(167, 139, 250, 0.8);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5), 0 0 18px var(--tk-glow);
}

.md-tile[hidden] {
    display: none;
}

/* Bottom scrim carrying the title, always readable over any thumbnail. */
.md-tile-scrim {
    position: absolute;
    inset: -1px;
    background: linear-gradient(0deg, rgba(8, 9, 24, 0.96) 0%, rgba(8, 9, 24, 0.62) 40%, rgba(8, 9, 24, 0) 70%);
}

.md-tile .md-badge {
    position: absolute;
    right: 10px;
    bottom: 10px;
    /* Same trim as the feature badge: Khand sits high in its line box. */
    padding: 4px 6px 1px;
    line-height: 1.15;
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    border-width: 0;
}

.md-tile-play {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.5);
    font-size: 11px;
    padding-left: 2px;
    transition: background var(--transition-fast);
}

.md-tile:hover .md-tile-play {
    background: rgba(124, 92, 255, 0.9);
}

.md-tile-text {
    position: absolute;
    left: 12px;
    right: 70px;
    bottom: 10px;
}

.md-tile-title {
    font-family: var(--font-display);
    font-size: 1.14rem;
    font-weight: 600;
    line-height: 1.12;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.md-tile-date {
    display: block;
    margin-top: 3px;
    font-family: var(--font-display);
    font-size: 0.86rem;
    color: rgba(220, 228, 255, 0.75);
}

.md-empty {
    padding: 28px 0;
    font-family: var(--font-display);
    color: var(--tk-muted);
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 1199.98px) {
    .md-tile {
        flex-basis: calc((100% - 28px) / 3);
    }

    .md-feature-copy {
        margin-left: 46%;
    }
}

@media (max-width: 767.98px) {
    .md-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .md-feature-inner {
        min-height: 0;
    }

    /* Thumbnail on top, copy below, on phones. */
    .md-feature-art {
        position: relative;
        left: auto;
        top: auto;
        height: auto;
        width: 100%;
        aspect-ratio: 16 / 9;
    }

    .md-feature-inner::after {
        background: linear-gradient(0deg, rgba(15, 16, 36, 1) 0%, rgba(15, 16, 36, 0.9) 42%, rgba(15, 16, 36, 0) 62%);
    }

    html[data-theme="light"] .md-feature-inner::after {
        background: linear-gradient(0deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.9) 42%, rgba(255, 255, 255, 0) 62%);
    }

    .md-feature-copy {
        margin: -34px 0 0;
        padding: 0 18px 18px;
        max-width: none;
    }

    .md-tile {
        flex-basis: 78%;
        min-width: 0;
    }
}
