/* ==========================================================
   Free Classic Movies & TV — web

   Same visual language as the Roku channel: near-black ground,
   Playfair for titles, a red focus glow, and a category-tinted
   title card wherever a film has no artwork of its own.
   ========================================================== */

@font-face {
    font-family: "Playfair Display";
    src: url("../fonts/PlayfairDisplay.woff2") format("woff2");
    font-weight: 400 900;
    font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --ink: #ece7de;
    --dim: #9a928a;
    --ground: #0b0b0b;
    --card: #141414;
    --red: #e50914;
    --line: rgba(255, 255, 255, 0.09);

    /* One number drives every card, row and gap. */
    --poster-w: clamp(116px, 15.5vw, 188px);
    --poster-h: calc(var(--poster-w) * 1.5);
    --gap: clamp(8px, 1.1vw, 16px);
    --pad: clamp(14px, 3.4vw, 56px);

    --serif: "Playfair Display", Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }

body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;

    background: var(--ground);
    color: var(--ink);
    font-family: var(--sans);

    -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }


/* ==========================================================
   TOP BAR
   ========================================================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;

    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 28px);

    padding: 10px var(--pad);
    padding-top: max(10px, env(safe-area-inset-top));

    background: linear-gradient(#0b0b0bf2, #0b0b0bd9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex: 0 1 auto;
    min-width: 0;
}

.brand-mark { width: 34px; height: 34px; object-fit: contain; flex: none; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }

.brand-text strong {
    font-family: var(--serif);
    font-size: clamp(0.95rem, 2.2vw, 1.3rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-text em {
    font-style: normal;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--dim);
}

.search-wrap { margin-left: auto; flex: 0 1 340px; min-width: 120px; }

#search {
    width: 100%;
    padding: 9px 13px;

    color: var(--ink);
    background: #1b1b1b;
    border: 1px solid var(--line);
    border-radius: 8px;

    font-family: inherit;
    font-size: 0.92rem;
}

#search:focus {
    outline: none;
    border-color: rgba(229, 9, 20, 0.65);
    background: #212121;
}

#search::-webkit-search-cancel-button { filter: invert(0.7); }


/* ==========================================================
   HERO
   ========================================================== */

.hero {
    position: relative;
    padding: clamp(26px, 6vw, 74px) var(--pad) clamp(20px, 4vw, 42px);
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("../images/home_bg.jpg") center / cover;
    opacity: 0.32;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #0b0b0be6 0%, #0b0b0bb3 55%, #0b0b0b00 100%);
}

.hero > * { position: relative; z-index: 1; }

.hero h1 {
    max-width: 18ch;
    font-family: var(--serif);
    font-size: clamp(1.7rem, 5.4vw, 3.4rem);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: 0.01em;
    text-shadow: 0 3px 24px #000;
}

.hero p {
    max-width: 46ch;
    margin-top: 12px;
    color: #cfc8bd;
    font-size: clamp(0.9rem, 1.9vw, 1.05rem);
    line-height: 1.5;
}

.hero-count {
    display: inline-block;
    margin-top: 18px;
    padding: 6px 13px;

    border: 1px solid rgba(229, 9, 20, 0.55);
    border-radius: 999px;

    color: #f0c9cb;
    font-size: 0.76rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}


/* ==========================================================
   ROWS
   ========================================================== */

.row { padding: clamp(18px, 3vw, 34px) 0 0; }

.row-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 0 var(--pad) 10px;
}

.row-head h2 {
    font-family: var(--serif);
    font-size: clamp(1.02rem, 2.3vw, 1.4rem);
    font-weight: 600;
    letter-spacing: 0.015em;
}

.row-head span { color: var(--dim); font-size: 0.78rem; }

.rail {
    display: flex;
    gap: var(--gap);

    padding: 4px var(--pad) 10px;

    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
    -webkit-overflow-scrolling: touch;
}

.rail::-webkit-scrollbar { height: 8px; }
.rail::-webkit-scrollbar-thumb { background: #2c2c2c; border-radius: 4px; }

/* The search results and the "keep watching" strip wrap instead of
   scrolling sideways — you want to see everything you matched. */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--poster-w), 1fr));
    gap: var(--gap);
    padding: 4px var(--pad) 10px;
}


/* ==========================================================
   CARDS
   ========================================================== */

.card {
    position: relative;
    flex: 0 0 var(--poster-w);
    width: var(--poster-w);
    height: var(--poster-h);

    scroll-snap-align: start;

    border: none;
    border-radius: 7px;

    background: var(--card);
    color: inherit;

    padding: 0;
    overflow: hidden;
    cursor: pointer;

    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.grid .card { flex: 1 1 auto; width: 100%; }

.card:hover,
.card:focus-visible {
    transform: scale(1.055);
    box-shadow: 0 0 0 2px var(--red), 0 12px 30px rgba(0, 0, 0, 0.7);
    outline: none;
    z-index: 2;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Title card — the fallback when a film has no artwork we own. */
.card.titlecard {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding: 12px 10px 26px;
    text-align: center;

    background:
        radial-gradient(
            ellipse at 50% 34%,
            var(--glow, #b5544a) 0%,
            transparent 68%
        ),
        url("../images/titlecard_bg.png") center / cover,
        var(--card);
}

.card.titlecard .tc-title {
    font-family: var(--serif);
    font-size: clamp(0.78rem, 1.35vw, 1.02rem);
    line-height: 1.24;
    color: #e8e4da;

    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card.titlecard .tc-year {
    position: absolute;
    bottom: 9px;
    left: 0;
    right: 0;

    font-family: var(--serif);
    font-size: 0.76rem;
    color: var(--dim);
}

/* The hover strip that names a card that only shows artwork. */
.card .cap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;

    padding: 22px 8px 8px;

    background: linear-gradient(#0000, #000000e0 62%);
    font-size: 0.76rem;
    line-height: 1.25;

    opacity: 0;
    transition: opacity 0.16s ease;
}

.card:hover .cap,
.card:focus-visible .cap { opacity: 1; }

.card.titlecard .cap { display: none; }

/* Resume bar along the bottom of a part-watched title. */
.card .progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;

    background: var(--red);
}


/* ==========================================================
   SHEET (detail)
   ========================================================== */

.sheet { position: fixed; inset: 0; z-index: 60; display: flex; }
.sheet[hidden] { display: none; }

.sheet-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(3px);
}

.sheet-card {
    position: relative;
    margin: auto;

    display: flex;
    gap: clamp(14px, 2.6vw, 30px);

    width: min(760px, calc(100% - 24px));
    max-height: min(90dvh, 640px);

    padding: clamp(16px, 2.6vw, 28px);

    background: #131313;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.85);

    overflow: auto;
}

.sheet-art {
    flex: 0 0 clamp(120px, 20vw, 190px);
    height: calc(clamp(120px, 20vw, 190px) * 1.5);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card);
}

.sheet-art .card { width: 100%; height: 100%; cursor: default; }
.sheet-art .card:hover { transform: none; box-shadow: none; }

.sheet-body { min-width: 0; }

.sheet-body h2 {
    font-family: var(--serif);
    font-size: clamp(1.25rem, 3vw, 1.9rem);
    font-weight: 600;
    line-height: 1.15;
}

.sheet-meta {
    margin-top: 6px;
    color: var(--dim);
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sheet-desc {
    margin-top: 14px;
    color: #cfc8bd;
    font-size: 0.95rem;
    line-height: 1.55;
}

.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.sheet-licence {
    margin-top: 16px;
    color: #6f6a64;
    font-size: 0.74rem;
    line-height: 1.4;
}

.btn {
    padding: 10px 20px;

    border: 1px solid var(--line);
    border-radius: 7px;

    background: #232323;
    color: var(--ink);

    font-family: inherit;
    font-size: 0.92rem;
    letter-spacing: 0.03em;

    cursor: pointer;
    transition: filter 0.14s ease, transform 0.1s ease;
}

.btn:hover { filter: brightness(1.35); }
.btn:active { transform: translateY(1px); }

.btn.primary {
    background: linear-gradient(var(--red), #a4060f);
    border-color: rgba(255, 255, 255, 0.22);
    font-weight: 600;
}

.icon-btn {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #1c1c1c;
    color: var(--ink);
    font-size: 1.3rem;
    line-height: 1;
    padding: 6px 12px;
    cursor: pointer;
}

.sheet-close { position: absolute; top: 10px; right: 10px; z-index: 2; }


/* ==========================================================
   PLAYER
   ========================================================== */

.player {
    position: fixed;
    inset: 0;
    z-index: 80;

    display: flex;
    flex-direction: column;

    background: #000;
    padding-top: max(0px, env(safe-area-inset-top));
}

.player[hidden] { display: none; }

.player-close { position: absolute; top: 12px; left: 12px; z-index: 2; }

.player-title {
    padding: 14px 60px;
    text-align: center;

    font-family: var(--serif);
    font-size: clamp(0.95rem, 2.2vw, 1.25rem);
    font-weight: 600;
}

#video { flex: 1; width: 100%; min-height: 0; background: #000; }

.player-error {
    padding: 16px;
    text-align: center;
    color: #f0a6a9;
    font-size: 0.92rem;
}


/* ==========================================================
   ODDS AND ENDS
   ========================================================== */

.loading, .empty {
    padding: 70px var(--pad);
    text-align: center;
    color: var(--dim);
    font-family: var(--serif);
    font-size: 1.05rem;
}

.sitefoot {
    margin-top: auto;
    padding: 28px var(--pad);
    padding-bottom: max(28px, env(safe-area-inset-bottom));

    border-top: 1px solid var(--line);
    color: var(--dim);
    font-size: 0.82rem;
    line-height: 1.6;
}

.sitefoot .tiny { margin-top: 6px; font-size: 0.74rem; color: #6f6a64; }

.support {
    margin: 36px var(--pad) 8px;
    padding: 24px 22px;
    max-width: 640px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--dim);
    font-size: 0.9rem;
    line-height: 1.6;
}
.support h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.25rem; color: inherit; }
.support p { margin: 0 0 14px; }
.support .tiny { margin: 10px 0 0; font-size: 0.74rem; color: #6f6a64; }
.support .support-btn { display: inline-block; text-decoration: none; }

body.locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}


/* ==========================================================
   NARROW SCREENS

   At phone widths the brand and the search box were fighting
   over the same row: the title wrapped to three lines and
   still got cut off. The byline is the part worth losing.
   ========================================================== */

@media (max-width: 680px) {
    .topbar { gap: 10px; }

    .brand-text em { display: none; }

    .brand-text strong {
        font-size: 0.95rem;
        line-height: 1.2;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .brand-mark { width: 28px; height: 28px; }

    .search-wrap { flex: 1 1 0; min-width: 0; }

    #search { font-size: 0.86rem; padding: 8px 10px; }
}

@media (max-width: 420px) {
    /* Below this the two cannot share a line at all. */
    .topbar { flex-wrap: wrap; }
    .brand { flex: 1 1 100%; }
    .search-wrap { flex: 1 1 100%; margin-left: 0; }
}


/* The bumper that runs ahead of a feature is labelled, plainly.
   An unlabelled advert is the thing viewers complain about. */
.ad-badge {
    align-self: center;

    margin-bottom: 6px;
    padding: 3px 12px;

    border: 1px solid rgba(229, 9, 20, 0.5);
    border-radius: 999px;

    color: #f0c9cb;
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.ad-badge[hidden] { display: none; }
