/*
 * Short Film of the Week: the header slot item and the dialog it opens.
 *
 * A global stylesheet, not a .razor.css file, because every element here is made by
 * wwwroot/js/headerSlot.film.js and Blazor's scoped CSS only reaches markup a component wrote.
 * Sizes that depend on the slot's box are set inline by that script.
 */

/* ---- the header item ---------------------------------------------------------------------- */

.aa-film {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: inherit;
    color: #f1e6c8;
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    /* a warm projection-room glow on the dark background the slot paints */
    background: radial-gradient(ellipse at 70% 50%, rgba(255, 214, 140, 0.12), transparent 65%);
}

.aa-film:focus-visible {
    outline: 2px solid #e8b04a;
    outline-offset: -3px;
}

.aa-film-stage {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
}

/* ---- the ticket ----
   Claude Design's "Short Film of the Week" banner, without its cream surround: the film strip
   itself fills the slot. Built at the design's 180px ticket height by headerSlot.film.js and
   scaled to the slot as one piece; its width is set there too. Colours, fonts and the scratch
   timings are the design's. The strip stays for the whole turn and the frames pass through
   its gate: first the title, then the film. */

.aa-film-tk {
    --aa-film-tk-paper: #F7F2E8;   /* ticket panels and sprocket holes */
    --aa-film-tk-ink: #161616;     /* film strip and text */
    --aa-film-tk-accent: #FF5533;  /* "Roll film" */
    --aa-film-tk-grime: #707070;   /* scratches and dust */
    --aa-film-tk-grit: 1;          /* scratch strength, 0 to 1 */
    position: absolute;
    top: 0;
    left: 0;
    height: 180px;
    box-sizing: border-box;
    transform-origin: 0 0;
    color: var(--aa-film-tk-ink);
    line-height: normal;
}

.aa-film-tk * { box-sizing: border-box; }

.aa-film-tk-ticket {
    position: relative;
    height: 180px;
    display: flex;
    flex-direction: column;
    background: var(--aa-film-tk-ink);
}

.aa-film-tk-sprockets { display: block; flex: none; }
.aa-film-tk-hole { fill: var(--aa-film-tk-paper); }

/* The window between the two rows of sprocket holes. Frames are stacked in it so one can slide
   out as the next slides in. */
.aa-film-tk-gate {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.aa-film-tk-row {
    position: absolute;
    inset: 0;
    display: flex;
    gap: 6px;
    padding: 0 22px;
}

.aa-film-tk-stub {
    width: 60px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--aa-film-tk-paper);
    border-radius: 4px;
}

.aa-film-tk-stub-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.aa-film-tk-title {
    position: relative;
    overflow: hidden;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 24px;
    background: var(--aa-film-tk-paper);
    border-radius: 4px;
}

.aa-film-tk-words {
    position: relative;
    display: block;
    width: max-content;
}

.aa-film-tk-head {
    display: block;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 800;
    font-size: 66px;
    line-height: .88;
    letter-spacing: -2.5px;
    white-space: nowrap;
}

.aa-film-tk-sub {
    display: block;
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 46px;
    line-height: .95;
    white-space: nowrap;
}

.aa-film-tk-btn {
    width: 150px;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--aa-film-tk-accent);
    border-radius: 4px;
    color: var(--aa-film-tk-ink);
}

/* the whole slot is the button, so the orange panel answers to it */
.aa-film:hover .aa-film-tk-btn,
.aa-film:focus-visible .aa-film-tk-btn { filter: brightness(1.06); }

.aa-film-tk-disc circle { fill: var(--aa-film-tk-ink); }
.aa-film-tk-disc path { fill: var(--aa-film-tk-accent); }

.aa-film-tk-btn-text {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 800;
    font-size: 19px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ---- the film's frame: thumbnail and description ---- */

.aa-film-tk-pic {
    position: relative;
    flex: none;
    align-self: center;
    overflow: hidden;
    border-radius: 4px;
    background: #000;
}

.aa-film-tk-pic .aa-film-thumb {
    width: 100%;
    height: 100%;
    /* hqdefault is 4:3 with black bars; cropping to the 16:9 box takes the bars off */
    object-fit: cover;
    display: block;
}

.aa-film-tk-pic .aa-film-badge { max-width: 76px; }

.aa-film-tk-desc {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding: 10px 20px;
    background: var(--aa-film-tk-paper);
    border-radius: 4px;
}

/* What a page of the description must fit; a page sits in its middle. */
.aa-film-tk-desc-window {
    display: flex;
    align-items: center;
    height: 100%;
    overflow: hidden;
}

/* A plain face, dark on cream, at TEXT_PX on screen (the script sets the size): the worn
   typewriter face this replaced was hard to read at header size. */
.aa-film-tk-desc-text {
    display: block;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 500;
    line-height: 1.3;
    color: var(--aa-film-tk-ink);
    overflow-wrap: anywhere;
}

/* reduced motion: no pages turning, so a long first page is cut off with an ellipsis instead */
.aa-film-tk-desc-clamped .aa-film-tk-desc-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

/* The scratched-film layer: behind the words, in front of the paper. Each layer runs on its own
   mismatched clock so the combined pattern takes minutes to repeat. */
.aa-film-tk-grime {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: var(--aa-film-tk-grit);
}

.aa-film-tk-grime g { stroke: var(--aa-film-tk-grime); fill: var(--aa-film-tk-grime); }
.aa-film-tk-grime g.aa-film-tk-lines { fill: none; stroke-linecap: round; }
.aa-film-tk-grime g.aa-film-tk-dust { stroke: none; }

.aa-film-tk-frame {
    position: absolute;
    top: -40px;
    left: -60px;
    width: calc(100% + 120px);
    height: calc(100% + 80px);
    opacity: 0;
}

.aa-film-tk-frame line,
.aa-film-tk-frame path { stroke-width: 1.5px; }

.aa-film-tk-frame circle,
.aa-film-tk-frame g.aa-film-tk-dust path {
    transform-box: fill-box;
    transform-origin: center;
    transform: scale(1.9);
}

.aa-film-tk-drift {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.aa-film-tk-drift line { stroke-width: 2.2px; }

.aa-film-tk-a { animation: aa-film-tk-on-a .61s steps(1, end) infinite, aa-film-tk-move-a 1.73s steps(1, end) infinite; }
.aa-film-tk-b { animation: aa-film-tk-on-b .79s steps(1, end) infinite, aa-film-tk-move-b 2.11s steps(1, end) infinite; }
.aa-film-tk-c { animation: aa-film-tk-on-c .97s steps(1, end) infinite, aa-film-tk-move-c 2.57s steps(1, end) infinite; }
.aa-film-tk-drift { animation: aa-film-tk-drift 2.93s steps(1, end) infinite, aa-film-tk-flicker .43s steps(1, end) infinite; }

@keyframes aa-film-tk-on-a { 0% { opacity: 1 } 22% { opacity: 0 } 41% { opacity: 1 } 55% { opacity: 0 } 100% { opacity: 0 } }
@keyframes aa-film-tk-on-b { 0% { opacity: 0 } 18% { opacity: 1 } 37% { opacity: 0 } 71% { opacity: 1 } 84% { opacity: 0 } 100% { opacity: 0 } }
@keyframes aa-film-tk-on-c { 0% { opacity: 0 } 30% { opacity: 1 } 46% { opacity: 0 } 62% { opacity: 1 } 79% { opacity: 0 } 100% { opacity: 0 } }
@keyframes aa-film-tk-move-a { 0% { transform: translate(0, 0) } 23% { transform: translate(-37px, 12px) } 47% { transform: translate(61px, -20px) } 71% { transform: translate(-14px, 31px) } 88% { transform: translate(29px, -8px) } 100% { transform: translate(0, 0) } }
@keyframes aa-film-tk-move-b { 0% { transform: translate(0, 0) scaleX(-1) } 19% { transform: translate(44px, -26px) } 38% { transform: translate(-52px, 9px) scaleX(-1) } 64% { transform: translate(18px, 24px) } 81% { transform: translate(-29px, -15px) scaleX(-1) } 100% { transform: translate(0, 0) scaleX(-1) } }
@keyframes aa-film-tk-move-c { 0% { transform: translate(0, 0) } 27% { transform: translate(53px, 18px) scaleY(-1) } 44% { transform: translate(-23px, -28px) } 69% { transform: translate(-58px, 6px) scaleY(-1) } 91% { transform: translate(12px, -19px) } 100% { transform: translate(0, 0) } }
@keyframes aa-film-tk-drift { 0% { transform: translateX(0) } 17% { transform: translateX(3px) } 34% { transform: translateX(-2px) } 51% { transform: translateX(5px) } 68% { transform: translateX(1px) } 85% { transform: translateX(-3px) } 100% { transform: translateX(0) } }
@keyframes aa-film-tk-flicker { 0% { opacity: .55 } 25% { opacity: .85 } 50% { opacity: .4 } 75% { opacity: .7 } 100% { opacity: .55 } }

/* The play badge over a thumbnail, here and in the dialog. */
.aa-film-badge {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 30%;
    max-width: 34px;
    transform: translate(-50%, -50%);
    opacity: 0.9;
    transition: opacity 0.2s, transform 0.2s;
}

.aa-film:hover .aa-film-badge,
.aa-film:focus-visible .aa-film-badge {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
}

.aa-film-badge-bg,
.aa-film-play-icon .aa-film-badge-bg { fill: #e62117; }

@media (prefers-reduced-motion: reduce) {
    .aa-film-tk-frame,
    .aa-film-tk-drift { animation: none; }
    .aa-film-tk-a { opacity: 1; }
}

/* ---- the dialog --------------------------------------------------------------------------- */

html.aa-film-open {
    overflow: hidden;
}

.aa-film-dialog {
    width: 80vw;
    height: 80vh;
    max-width: none;
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #f1e6c8;
    /* the close button sits on the card's corner, half outside it */
    overflow: visible;
}

.aa-film-dialog::backdrop {
    background: rgba(8, 6, 4, 0.82);
    backdrop-filter: blur(3px);
}

.aa-film-dialog[open] {
    animation: aa-film-pop 0.4s cubic-bezier(.2, 1.2, .4, 1);
}

/* Never scrolls, so the close button pinned to it stays put; only the description does. */
.aa-film-card {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 20px 16px;
    border-radius: 14px;
    background: radial-gradient(ellipse at 50% 0%, #2a231c 0%, #15120e 70%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(217, 184, 120, 0.3);
}

.aa-film-head {
    flex: 0 0 auto;
    padding-right: 20px;
}

.aa-film-kicker {
    font-family: 'Limelight', Georgia, serif;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: #e8b04a;
}

.aa-film-title {
    margin: 2px 0 0;
    font-size: clamp(1.05rem, 2.2vw, 1.5rem);
    font-weight: 600;
    color: #f6e3b4;
    line-height: 1.25;
}

/* The picture area takes whatever height is left; the video box inside is the largest 16:9
   rectangle that fits it, in both directions. */
.aa-film-screen {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    container-type: size;
}

.aa-film-box {
    position: relative;
    width: min(100cqw, 100cqh * 16 / 9);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
    box-shadow: 0 0 0 1px rgba(217, 184, 120, 0.35);
}

.aa-film-play {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: #000;
    cursor: pointer;
}

.aa-film-play .aa-film-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.aa-film-play-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    width: clamp(56px, 9%, 96px);
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
    opacity: 0.92;
    transition: transform 0.15s, opacity 0.15s;
}

.aa-film-play:hover .aa-film-play-icon,
.aa-film-play:focus-visible .aa-film-play-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.aa-film-play:focus-visible {
    outline: 3px solid #e8b04a;
    outline-offset: -3px;
}

.aa-film-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.aa-film-desc {
    flex: 0 1 auto;
    max-height: 22%;
    margin: 0;
    overflow-y: auto;
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.45;
    color: #e6dcc2;
    white-space: pre-line;
}

@keyframes aa-film-pop {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}

@media (max-width: 600px) {
    .aa-film-card { padding: 16px 12px 12px; gap: 10px; }
    .aa-film-desc { max-height: 30%; }
}

/* no film to show: the title card stays, as decoration rather than a button */
.aa-film.aa-film-none {
    cursor: default;
}
