/* Click-to-load YouTube trailer (see assets/trailer.js). Shared by the homepage and the game pages.
   Colour comes from --trailer-accent, then the card's --game-accent, then the Codai orange. */

.trailer,
.trailer-modal {
    --trailer-color: var(--trailer-accent, var(--game-accent, var(--brand, #ffac75)));
}

.trailer {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: #070b14;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.trailer__poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease, filter 0.25s ease;
}

.trailer:hover .trailer__poster,
.trailer:focus-visible .trailer__poster {
    transform: scale(1.03);
    filter: brightness(1.08);
}

.trailer__play {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
    border-radius: 50%;
    background: var(--trailer-color);
    color: #0a0f1a;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease;
}

/* Optical centring: a triangle looks left-heavy in a circle. */
.trailer__play svg {
    margin-left: 3px;
}

.trailer:hover .trailer__play,
.trailer:focus-visible .trailer__play {
    transform: scale(1.1);
}

.trailer:focus-visible {
    outline: 3px solid var(--trailer-color);
    outline-offset: 3px;
}

.trailer__note {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.75rem 1rem 0.7rem;
    background: linear-gradient(to top, rgba(7, 11, 20, 0.92), rgba(7, 11, 20, 0));
    font-size: 0.75rem;
    line-height: 1.4;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
}

.trailer__frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}

.trailer__frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ── Modal ────────────────────────────────────── */

.trailer-modal {
    width: min(960px, calc(100vw - 2rem));
    max-width: none;
    /* Pages reset margins globally, which would pin the dialog to the top-left corner. */
    margin: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    overflow: visible;
}

.trailer-modal::backdrop {
    background: rgba(5, 8, 15, 0.88);
}

html:has(.trailer-modal[open]) {
    overflow: hidden;
}

.trailer-modal__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.trailer-modal__title {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.75);
}

.trailer-modal__close {
    flex: none;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.9);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.trailer-modal__close:hover {
    border-color: var(--trailer-color);
}

.trailer-modal__close:focus-visible {
    outline: 3px solid var(--trailer-color);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .trailer__play {
        width: 56px;
        height: 56px;
        margin: -28px 0 0 -28px;
    }

    .trailer__note {
        padding: 1.5rem 0.75rem 0.5rem;
        font-size: 0.68rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .trailer__poster,
    .trailer__play {
        transition: none;
    }
}
