/* ==========================================================================
   Video (Content Block dddiy_video, im Website-Baukasten gepflegt):
   Vorschaubild mit Play-Knopf, der Player oeffnet sich in einem <dialog>
   (JavaScript/Frontend/VideoModal.js). Seitenverhaeltnis aus
   Content\SiteVideo::FORMATS als --dd-video-ratio; hochkant bleibt die
   Vorschau schmal und mittig.

   Farben, Schriften und Masse aus den Tokens von festival.css (--fest-*),
   mit Fallback fuer Seiten ohne festival.css; die dunkle Variante kommt
   von dort - wie image-text.css.
   ========================================================================== */

.dd-video {
    --x-ink: var(--fest-ink, #14181f);
    --x-muted: var(--fest-ink-muted, #4a5568);
    --x-surface-quiet: var(--fest-flaeche-leise, #f5f6f8);
    --x-primary: var(--fest-primary, var(--bs-primary, #e5007d));
    --x-on-primary: var(--fest-on-primary, #fff);
    --x-radius: var(--fest-radius, 14px);
    --x-display: var(--fest-font-display, var(--brand-font-display, inherit));
    padding-block: var(--fest-space-l, 3rem);
    color: var(--x-ink);
}

.dd-video__intro {
    max-width: var(--fest-mass, 68ch);
    margin: 0 auto var(--fest-space-m, 2rem);
    text-align: center;
}

.dd-video__title {
    margin: 0 0 .5rem;
    font-family: var(--x-display);
    color: var(--x-ink);
}

.dd-video__text > :last-child {
    margin-bottom: 0;
}

.dd-video__stage {
    max-width: 1100px;
    margin: 0 auto;
}

/* Hochkant und quadratisch nicht ueber die ganze Breite - sonst ist das Bild hoeher als der Bildschirm. */
.dd-video--portrait .dd-video__stage { max-width: min(420px, 100%); }
.dd-video--square .dd-video__stage { max-width: min(720px, 100%); }

.dd-video__preview {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: var(--dd-video-ratio, 16 / 9);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: var(--x-radius);
    background: #111 linear-gradient(135deg, color-mix(in srgb, var(--x-primary) 55%, #111), #111);
    color: inherit;
    cursor: pointer;
}

.dd-video__poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease, filter .4s ease;
    pointer-events: none;
}

/* Gegen ".festival-theme img { height: auto }" - sonst fuellt ein 16:9-Bild kein 4:3 oder Quadrat. */
.dd-video__preview .dd-video__poster {
    height: 100%;
}

.dd-video__preview::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, .35), rgba(0, 0, 0, 0) 55%);
    pointer-events: none;
}

.dd-video__play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    display: grid;
    place-items: center;
    width: clamp(64px, 12vw, 96px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--x-primary);
    color: var(--x-on-primary);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
    transform: translate(-50%, -50%);
    transition: transform .2s ease;
}

.dd-video__play svg {
    width: 46%;
    height: 46%;
    margin-left: 8%;
    fill: currentColor;
}

.dd-video__preview:hover .dd-video__poster,
.dd-video__preview:focus-visible .dd-video__poster {
    transform: scale(1.03);
    filter: brightness(.9);
}

.dd-video__preview:hover .dd-video__play,
.dd-video__preview:focus-visible .dd-video__play {
    transform: translate(-50%, -50%) scale(1.08);
}

.dd-video__preview:focus-visible {
    outline: 3px solid var(--x-primary);
    outline-offset: 4px;
}

.dd-video__note {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .25rem 1rem;
    margin-top: .5rem;
    color: var(--x-muted);
    font-size: .8rem;
    line-height: 1.35;
}

.dd-video__credit {
    margin-left: auto;
}

/* --------------------------------------------------------------------------
   Dialog: dunkle Buehne, Player so gross wie es der Bildschirm erlaubt.
   -------------------------------------------------------------------------- */

.dd-video__dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
}

.dd-video__dialog::backdrop {
    background: rgba(8, 9, 12, .9);
}

.dd-video__box {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    padding: 4rem clamp(1rem, 4vw, 3rem) 1.5rem;
}

.dd-video__frame {
    /* Groesst moegliche Flaeche im Seitenverhaeltnis, die in den Bildschirm passt. */
    width: min(1280px, 100%, calc((100dvh - 6rem) * (var(--dd-video-ratio, 16 / 9))));
    aspect-ratio: var(--dd-video-ratio, 16 / 9);
    position: relative;
    overflow: hidden;
    border-radius: calc(var(--x-radius, 14px) / 2);
    background: #000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

/* Fest im Rahmen - das Theme setzt video sonst teils absolut ueber die ganze Flaeche. */
.dd-video__frame iframe,
.dd-video__frame video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

.dd-video__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, .7);
    border-radius: 50%;
    background: rgba(0, 0, 0, .4);
    color: #fff;
    cursor: pointer;
}

.dd-video__close svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.dd-video__close:hover {
    background: rgba(255, 255, 255, .15);
}

.dd-video__close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

html.dd-video-open {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .dd-video__poster,
    .dd-video__play {
        transition: none;
    }

    .dd-video__preview:hover .dd-video__poster,
    .dd-video__preview:focus-visible .dd-video__poster {
        transform: none;
    }
}
