/*
 * Carnival Figures project media viewer
 * --------------------------------------
 * This is the single visual control point for the new project film and
 * image-gallery pages. Page files provide only media IDs, image links and
 * their return destination.
 */
:root {
    --cf-media-backdrop: rgba(0, 0, 0, 0.80);
    --cf-media-border: 26px;
    --cf-media-caption-space: 64px;
    --cf-media-max-width: 1280px;
    --cf-media-caption-size: 15px;
    --cf-media-count-size: 13px;
    --cf-media-copy: #595959;
    --cf-media-control: #a8a8a8;
    --cf-media-control-active: #e8e8e8;
    --cf-media-focus: #e8e8e8;
    --cf-media-z-index: 10000;
}

/* Lock the viewport, not the fixed-height body: clipping both collapses
   the document scroll range and sends a long collection back to the top. */
html.cf-media-open {
    overflow: hidden !important;
}

[data-cf-media-fallback],
#content-project [data-cf-gallery-item] {
    display: none;
}

.cf-media-viewer {
    position: fixed;
    z-index: var(--cf-media-z-index);
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    padding: 28px 24px;
    font-family: Arial, Helvetica, sans-serif;
}

.cf-media-viewer.is-open {
    display: flex;
}

.cf-media-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--cf-media-backdrop);
    cursor: pointer;
}

.cf-media-stage {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    min-width: 0;
    max-width: var(--cf-media-max-width);
    max-height: 100%;
}

/* The stage receives programmatic focus so Escape works without a visible
   custom close control. It is not an interactive control itself. */
.cf-media-stage:focus {
    outline: 0;
}

.cf-media-viewer--video .cf-media-stage {
    width: 92vw;
    /* Preserve the full black frame on short laptop/browser viewports. */
    max-width: min(var(--cf-media-max-width), calc(177.7778vh - 140px));
}

.cf-media-viewer--video[data-aspect="4-3"] .cf-media-stage {
    width: min(68vw, 960px);
    max-width: min(960px, calc(133.3333vh - 140px));
}

.cf-media-viewer--video[data-aspect="9-16"] .cf-media-stage {
    /* Keep the full 26px frame between the site header and project nav.
       Width is derived from ~86vh minus the frame itself. */
    width: min(36vw, 580px, calc((86vh - 52px) * 0.5625));
    max-width: min(580px, calc((86vh - 52px) * 0.5625));
    max-height: 86vh;
}

.cf-media-viewer--video[data-aspect="4-5"] .cf-media-stage {
    width: min(48vw, 720px, calc((86vh - 52px) * 0.8 + 52px));
    max-width: min(720px, calc((86vh - 52px) * 0.8 + 52px));
    max-height: 86vh;
}

.cf-media-viewer--gallery .cf-media-stage {
    width: auto;
    max-width: calc(100vw - 48px);
}

.cf-media-frame {
    position: relative;
    box-sizing: border-box;
    max-width: 100%;
    background: #000;
}

.cf-media-viewer--video .cf-media-frame {
    width: 100%;
    padding: var(--cf-media-border);
}

.cf-media-video-shell {
    position: relative;
    width: 100%;
    height: 0;
    overflow: hidden;
    padding-top: 56.25%;
    background: #000;
}

.cf-media-viewer[data-aspect="4-3"] .cf-media-video-shell {
    padding-top: 75%;
}

.cf-media-viewer[data-aspect="9-16"] .cf-media-video-shell {
    padding-top: 177.7778%;
}

.cf-media-viewer[data-aspect="4-5"] .cf-media-video-shell {
    padding-top: 125%;
}

.cf-media-viewer[data-aspect="1-1"] .cf-media-video-shell {
    padding-top: 100%;
}

.cf-media-viewer--video[data-aspect="1-1"] .cf-media-stage {
    width: min(48vw, 720px, calc(86vh - 52px));
    max-width: min(720px, calc(86vh - 52px));
    max-height: 86vh;
}

.cf-media-video-shell iframe {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

.cf-media-viewer--gallery .cf-media-frame {
    display: inline-block;
    padding: var(--cf-media-border) var(--cf-media-border) var(--cf-media-caption-space);
}

.cf-media-image {
    display: block;
    width: auto;
    height: auto;
    max-width: calc(100vw - 100px);
    max-height: calc(100vh - 164px);
    background: #000;
}

.cf-media-hotspot {
    position: absolute;
    z-index: 4;
    top: var(--cf-media-border);
    bottom: var(--cf-media-caption-space);
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cf-media-hotspot:hover,
.cf-media-hotspot:focus,
.cf-media-hotspot:active {
    border: 0;
    outline: 0;
    background: transparent;
}

.cf-media-hotspot--previous {
    right: 50%;
    left: var(--cf-media-border);
}

.cf-media-hotspot--next {
    right: var(--cf-media-border);
    left: 50%;
}

.cf-media-caption {
    position: absolute;
    z-index: 3;
    right: var(--cf-media-border);
    bottom: 14px;
    left: var(--cf-media-border);
    color: var(--cf-media-copy);
    text-align: left;
}

.cf-media-title {
    display: block;
    margin: 0 0 5px;
    font-size: var(--cf-media-caption-size);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.25;
}

.cf-media-count {
    display: block;
    margin: 0;
    font-size: var(--cf-media-count-size);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.2;
}

.cf-media-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    clip-path: inset(50%) !important;
}

@media screen and (max-width: 800px) {
    html.cf-media-open,
    body.cf-media-open {
        overflow: auto !important;
    }

    .cf-media-viewer {
        display: none !important;
    }
    /* An already-open overlay survives rotation without replacing its iframe. */
    .cf-media-viewer.is-open {
        display: flex !important;
    }
}

/* Mobile portrait movies leave a generous backdrop for tap-to-close. */
@media screen and (max-width: 800px) {
    .cf-media-viewer--video[data-aspect="9-16"] { padding: 8px; }
    .cf-media-viewer--video[data-aspect="9-16"] .cf-media-stage {
        width: min(80vw, calc((100vh - 32px) * 0.5625));
        width: min(80vw, calc((100dvh - 32px) * 0.5625));
        max-width: none;
        max-height: none;
    }
    .cf-media-viewer--video[data-aspect="9-16"] .cf-media-frame { padding: 0; }
}


/* Square mobile movies can fill the width while leaving backdrop above/below. */
@media screen and (max-width: 800px) {
    .cf-media-viewer--video[data-aspect="1-1"] { padding: 8px; }
    .cf-media-viewer--video[data-aspect="1-1"] .cf-media-stage {
        width: min(calc(100vw - 16px), calc(100vh - 16px));
        width: min(calc(100vw - 16px), calc(100dvh - 16px));
        max-width: none;
        max-height: none;
    }
    .cf-media-viewer--video[data-aspect="1-1"] .cf-media-frame { padding: 0; }
}


/* 4:5 portrait campaigns retain their own shape, including mobile overlays. */
@media screen and (max-width: 800px) {
    .cf-media-viewer--video[data-aspect="4-5"] { padding: 8px; }
    .cf-media-viewer--video[data-aspect="4-5"] .cf-media-stage {
        width: min(80vw, calc((100vh - 32px) * 0.8));
        width: min(80vw, calc((100dvh - 32px) * 0.8));
        max-width: none;
        max-height: none;
    }
    .cf-media-viewer--video[data-aspect="4-5"] .cf-media-frame { padding: 0; }
}

/* Keyboard-only closing control: no change to pointer/touch layout or sizing. */
.cf-media-keyboard-close {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%);
    white-space: nowrap; border: 0;
}
.cf-media-keyboard-close:focus {
    clip: auto; clip-path: none; width: auto; height: auto;
    top: 4px; right: 4px; margin: 0; padding: 8px 12px; z-index: 5;
    background: #000; color: #f5f5f5; border: 1px solid #aaa;
    font: 16px/1.3 Arial, sans-serif; outline: 2px solid #f5f5f5;
}

/* Floating image galleries: no browser decoration around artwork or hotspots.
   Keep the black padding and the separate keyboard-close control intact. */
html body .cf-media-viewer--gallery,
html body .cf-media-viewer--gallery .cf-media-stage,
html body .cf-media-viewer--gallery .cf-media-frame,
html body .cf-media-viewer--gallery .cf-media-image,
html body .cf-media-viewer--gallery .cf-media-hotspot {
  outline: 0 !important; border: 0 !important; box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}
