/* =========================================================
   COMPONENTS.CSS
   Shared components loaded on every page (layout_top).
   Split out of home.css: film cards + carousel + preview are
   used by default.asp, search.asp and film.asp's related
   carousel; section scaffolding, post-thumb, sponsors strip
   and cta-band are reusable page furniture.
   ========================================================= */


/* =========================================================
   PAGE SECTIONS
   ========================================================= */

.section {
    max-width: var(--max);
    margin: 0 auto;
    padding: 30px 60px 0px;
    position: relative;
}

.section-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}

    .section-title h2 {
        font-size: 30px;
        letter-spacing: -0.4px;
    }

    .section-title p {
        max-width: 620px;
        color: #888;
        font-size: 14.5px;
        line-height: 1.7;
    }


/* =========================================================
   FILM CAROUSEL
   ========================================================= */

.carousel-wrap {
    position: relative;
    border-radius: 18px;
    background: rgba(255,255,255,0.02);
    overflow: hidden;
}

    .carousel-wrap::before,
    .carousel-wrap::after {
        content: "";
        position: absolute;
        top: 0;
        width: 140px;
        height: 100%;
        z-index: 4;
        pointer-events: none;
    }

    .carousel-wrap::before {
        left: 0;
        background: linear-gradient(to right, var(--bg) 0%, rgba(11,11,11,0) 100%);
    }

    .carousel-wrap::after {
        right: 0;
        background: linear-gradient(to left, var(--bg) 0%, rgba(11,11,11,0) 100%);
    }

.carousel {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    scrollbar-width: none;
    scroll-behavior: smooth;
    scroll-padding-left: 20px;
}

    .carousel::-webkit-scrollbar {
        display: none;
    }

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 28px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

    .carousel-arrow:hover {
        background: var(--accent);
        color: #fff;
    }

    .carousel-arrow.left {
        left: 10px;
    }

    .carousel-arrow.right {
        right: 10px;
    }


/* =========================================================
   FILM CARD
   ========================================================= */

.film-card {
    flex: 0 0 260px;
    scroll-snap-align: start;
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 14px;
    overflow: hidden;
    transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
}

    .film-card:hover {
        background: var(--card-hover);
        border-color: rgba(255,255,255,0.08);
        transform: translateY(-4px) scale(1.04);
        box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    }

    /* thumbnail container */
    .film-card .thumb {
        position: relative;
        width: 100%;
        aspect-ratio: 16 / 9;
        overflow: visible !important;
        background: #111;
    }

        .film-card .thumb img.poster-img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s ease, opacity 0.3s ease;
            display: block;
        }

    .film-card:hover .thumb img.poster-img {
        transform: scale(1.06);
    }

    /* video preview container */
    .film-card .preview-host {
        position: absolute;
        inset: 0;
        display: none;
        background: #000;
    }

        .film-card .preview-host iframe {
            width: 100%;
            height: 100%;
            border: 0;
        }

    /* play icon overlay */
    .film-card .play-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.2s ease;
        background: rgba(0,0,0,0.25);
        pointer-events: none;
    }

    .film-card:hover .play-overlay {
        opacity: 1;
    }

    .film-card.previewing .play-overlay {
        opacity: 0 !important;
    }

.preview-host,
.play-overlay,
.preview-loader {
    pointer-events: none;
}

.play-overlay .play-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    transition: transform 0.2s ease;
}

.film-card:hover .play-icon {
    transform: scale(1.08);
}

.play-overlay svg {
    width: 18px;
    height: 18px;
    fill: #000;
    margin-left: 2px;
}

/* year badge */
.film-card .year-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #ccc;
    z-index: 2;
}

.film-card.previewing .year-badge {
    display: none;
}

/* loading spinner shown while iframe loads */
.film-card .preview-loader {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    z-index: 1;
}

.film-card.loading .preview-loader {
    display: flex;
}

.preview-loader .spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* card body */
.film-card .card-body {
    padding: 16px 18px 8px;
}

    .film-card .card-body h3 {
        font-size: 15px;
        font-weight: 700;
        margin-bottom: 7px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

.film-card .card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

    .film-card .card-meta span {
        font-size: 13px;
        color: #666;
        line-height: 1.4;
    }

    .film-card .card-meta .filmmaker-name {
        color: #888;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

/* ---- Target size on the film card, EVERY pointer type -------------
 *
 * WCAG 2.5.8 (AA) sets the floor at 24x24 CSS px and it is not a touch
 * rule - it applies to a mouse as well, and Lighthouse's target-size
 * audit checks it on desktop runs too. A card title anchor at 15px with
 * default line-height is about 20px tall, so it fails on a desktop
 * report even when the 44px block below is doing its job on mobile.
 *
 * That is the trap here: the 44px rule sat inside
 * "(max-width: 768px), (pointer: coarse)" and looked like the whole
 * answer, so a desktop failure read as the mobile fix not working.
 *
 * 24px unconditionally, 44px where a finger is involved.
 *
 * block, NOT flex, for the unconditional rule. .filmmaker-name is
 * white-space:nowrap + overflow:hidden + text-overflow:ellipsis, and a
 * flex container puts its text in an anonymous flex item where the
 * ellipsis does not resolve the same way. Long school names - "Cleveland
 * District State High School" - truncate on this card constantly, so
 * that is not a theoretical risk. block keeps the anchor in normal flow
 * and the parent clips it exactly as it does today.
 *
 * The 44px rule below can use flex safely: it only applies on narrow or
 * touch viewports, where it has been in search.css for months. */
.film-card .film-card-title a,
.film-card .card-meta .filmmaker-name a {
    display: block;
    min-height: 24px;
    line-height: 1.6;
}

/* ---- Touch targets on the film card ------------------------------
 *
 * The card stacks a title link directly above a filmmaker link, both at
 * text height. On a touch screen that is two targets a few pixels apart,
 * which is what PageSpeed flags on film.asp:
 *
 *     Three Legged King     <a href="/films/2022/three-legged-king-11500">
 *     Kelvin Maxwell Ngoma  <a href="/filmmakers/kelvin-maxwell-ngoma-5623">
 *
 * THIS RULE ALREADY EXISTED, in search.css - and search.css is only
 * loaded by search.asp. The identical cards rendered into the related
 * films carousel on a film page never got it, because film.asp loads
 * base + components + film. So the fix has been written for months and
 * has never applied on the page that was measured.
 *
 * It belongs here: components.css is where .film-card is defined and is
 * loaded site-wide by layout_top.asp, so every page that renders a card
 * gets the same behaviour. The copy in search.css is now redundant, but
 * harmless - it is the same declaration - and is left alone rather than
 * touched during voting week.
 *
 * 44px is the figure Apple, Google and WCAG 2.5.8 (AAA) converge on;
 * the AA threshold is 24px, which the untouched text height already
 * fails at 13px.
 *
 * pointer:coarse as well as a width query - a large tablet is a touch
 * device at 1024px wide, and a narrow desktop window is not. */
@media (max-width: 768px), (pointer: coarse) {

    .film-card .film-card-title a,
    .film-card .card-meta .filmmaker-name a {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 6px 0;
        line-height: 1.35;
    }

    .film-card .film-card-title + .card-meta { margin-top: 4px; }
    .film-card .card-meta + .meta-row        { margin-top: 8px; }
}

    .film-card .card-meta .country-line {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .film-card .card-meta .country-flag {
        width: 18px;
        height: 13px;
        border-radius: 2px;
        object-fit: cover;
        flex-shrink: 0;
        box-shadow: 0 0 0 1px rgba(255,255,255,0.1);
    }


/* =========================================================
   BLOG THUMB FALLBACK
   ========================================================= */

/* #4 - graceful fallback for missing blog post images */
.post-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    opacity: 0.15;
    pointer-events: none;
}

.post-thumb {
    position: relative;
}


/* =========================================================
   SPONSORS STRIP
   ========================================================= */

.sponsors {
    padding: 14px 0 120px;
}

/* THIS is the rule that applies. base.css also defines .sponsors-label,
   but components.css loads after it at the same specificity, so this
   colour wins - which is why fixing base.css alone changed nothing that
   Lighthouse could see.

   #555 on the #0b0b0b page background measures 2.64:1, against a 4.5
   minimum. --muted is #aaa and measures 8.47:1. The variable is
   declared in base.css's :root, which loads first, so it resolves here. */
.sponsors-label {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    margin-top: 18px;
    margin-bottom: 18px;
    text-align: center;
}

.sponsors-carousel {
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    position: relative;
}

    .sponsors-carousel::before,
    .sponsors-carousel::after {
        content: "";
        position: absolute;
        top: 0;
        width: 110px;
        height: 100%;
        z-index: 3;
        pointer-events: none;
    }

    .sponsors-carousel::before {
        left: 0;
        background: linear-gradient(to right, var(--bg) 0%, rgba(11,11,11,0) 100%);
    }

    .sponsors-carousel::after {
        right: 0;
        background: linear-gradient(to left, var(--bg) 0%, rgba(11,11,11,0) 100%);
    }

.sponsors-track {
    display: flex;
    gap: 44px;
    align-items: center;
    width: max-content;
    padding: 22px 26px;
    animation: scrollSponsors 36s linear infinite;
}

.sponsors-carousel:hover .sponsors-track {
    animation-play-state: paused;
}

@keyframes scrollSponsors {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }
}

.sponsor-item {
    flex: 0 0 auto;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .sponsor-item img {
        height: 56px;
        max-width: 190px;
        object-fit: contain;
        opacity: .85;
        filter: grayscale(100%);
        transition: transform .25s ease, opacity .25s ease, filter .25s ease;
    }

    .sponsor-item:hover img {
        transform: scale(1.06);
        opacity: 1;
        filter: grayscale(0%);
    }


/* =========================================================
   CTA BAND
   ========================================================= */

.cta-band {
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.06);
    background: radial-gradient(700px 260px at 10% 30%, rgba(47,125,255,0.14), transparent 62%), radial-gradient(700px 260px at 90% 70%, rgba(214,0,0,0.14), transparent 62%), linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    padding: 34px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
}

    .cta-band h3 {
        font-size: 22px;
        letter-spacing: -0.3px;
        margin-bottom: 8px;
    }

    .cta-band p {
        color: #aaa;
        font-size: 14.5px;
        line-height: 1.7;
        max-width: 680px;
    }


/* =========================================================
   STATS BLOCK
   Moved here from home.css. default.asp and about.asp both ship this
   markup, but home.css is gated on default.asp in layout_top.asp, so
   the About page rendered four unstyled stacked divs.
   ========================================================= */

.home-stats {
    max-width: var(--max);
    margin: -40px auto 0;
    padding: 0 60px;
    position: relative;
    z-index: 5;
}

.stats-card {
    border-radius: 22px;
    background: radial-gradient(600px 200px at 10% 20%, rgba(47,125,255,0.15), transparent 60%), radial-gradient(600px 200px at 90% 80%, rgba(214,0,0,0.15), transparent 60%), rgba(15,15,15,0.95);
    border: 1px solid rgba(255,255,255,0.08);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    overflow: hidden;
}

.stat-item {
    padding: 48px 28px;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,0.06);
}

    .stat-item:last-child {
        border-right: none;
    }

/* Was a flat 64px at every width, and no media query ever reduced it.
   "Votes Received" renders 6-7 digits plus separators and a "+", which
   at 64px needs ~330px - against roughly 294px of usable width inside
   .stat-item on a 390px phone. display:inline-flex means it cannot wrap
   or shrink, so html{overflow-x:hidden} in base.css just clipped it and
   the number appeared cut off or missing. clamp() scales it with the
   viewport instead; min-width:0 lets it shrink inside the grid cell. */
.stat-number {
    font-size: clamp(32px, 8vw, 64px);
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    max-width: 100%;
    min-width: 0;
    font-weight: 950;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #8a8a8a;
    font-weight: 800;
    margin-top: 8px;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 980px) {
    .section {
        padding: 60px 20px 40px;
    }

    .film-card {
        flex: 0 0 220px;
    }

    .home-stats {
        padding: 0 20px;
    }

    .stats-card {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-item {
        padding: 36px 18px;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }

        .stat-item:nth-child(2n) {
            border-right: none;
        }
}

@media (max-width: 640px) {
    /* Header rules - belong in base.css; parked here so they
       stay global now that home.css is homepage-only.

       DELETED: `nav a { display: none }`.

       It matched every anchor in every <nav> on the site, including
       film.asp's <nav class="breadcrumb">, whose links set no display of
       their own and so disappeared completely on phones. The drawer
       links and the pagination buttons survived it only by winning on
       specificity - luck, not design.

       It is not replaced by a narrower version because it had no job
       left to do: the drawer takes over at 900px, so by 640px the
       header's own links are already inside a panel parked off-screen
       at left:-320px. Hiding them again here achieved nothing except
       the breadcrumb collateral. */

    .nav-search {
        margin-left: 0;
    }

    .nav-search-input:focus {
        width: 180px;
    }

    .film-card {
        flex-basis: 280px;
    }

    .stats-card {
        grid-template-columns: 1fr;
    }

    .stat-item {
        border-right: none;
    }
}
