/* ---------------------------------------------------------
 *  Category flyer popup (front end)
 *
 *  Self-contained: no framework classes, and every rule is scoped to
 *  .darley-catflyer-* so it cannot leak into the active theme.
 * --------------------------------------------------------- */

.darley-catflyer-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.75);
}

/* The hidden attribute loses to display:flex without this. */
.darley-catflyer-overlay[hidden] {
    display: none;
}

/* Stop the page behind the popup from scrolling. */
body.darley-catflyer-open {
    overflow: hidden;
}

/* Nothing but the image: no panel background, border or shadow. The dialog is
   shrink-wrapped around the flyer so the backdrop shows everywhere else. */
.darley-catflyer-dialog {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    line-height: 0;
}

/* Floats over the top-right corner of the image itself. The !important flags
   are deliberate: themes routinely style bare `button` elements, and this one
   sits inside theme-controlled markup. */
.darley-catflyer-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 0;
    padding: 0 !important;
    color: #fff !important;
    cursor: pointer;
    background: rgba(17, 17, 17, 0.55) !important;
    border: 0 !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    transition: background 0.2s ease, transform 0.2s ease;
}

.darley-catflyer-close:hover,
.darley-catflyer-close:focus-visible {
    background: rgba(17, 17, 17, 0.85) !important;
    transform: scale(1.08);
}

.darley-catflyer-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.darley-catflyer-close svg {
    display: block;
    width: 18px;
    height: 18px;
}

@media (prefers-reduced-motion: reduce) {
    .darley-catflyer-close {
        transition: none;
    }

    .darley-catflyer-close:hover,
    .darley-catflyer-close:focus-visible {
        transform: none;
    }
}

/* The flyer at its uploaded dimensions, scaled down only when it would not
   otherwise fit the viewport. */
.darley-catflyer-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 40px);
}

/* PDF flyers need explicit dimensions: an iframe has no intrinsic size, and the
   dialog no longer supplies a width of its own. */
.darley-catflyer-pdf {
    display: block;
    width: min(800px, 90vw);
    height: 75vh;
    border: 0;
}

.darley-catflyer-fallback {
    margin: 0;
    padding: 12px 16px;
    line-height: 1.4;
    text-align: center;
}

.darley-catflyer-fallback a {
    color: #fff;
}

/* iOS Safari will not render a PDF in an iframe, so lean on the fallback link. */
@supports (-webkit-touch-callout: none) {
    .darley-catflyer-pdf {
        height: 45vh;
    }
}

@media (max-width: 576px) {
    .darley-catflyer-overlay {
        padding: 10px;
    }

    .darley-catflyer-image {
        max-height: calc(100vh - 20px);
    }
}

/* ---------------------------------------------------------
 *  Admin media picker
 * --------------------------------------------------------- */

.darley-catflyer-media {
    display: block;
}

.darley-catflyer-media__preview {
    display: block;
    margin-bottom: 8px;
}

.darley-catflyer-media__preview img {
    max-width: 150px;
    height: auto;
    border: 1px solid #dcdcde;
}

.darley-catflyer-media__empty {
    color: #787c82;
    font-style: italic;
}

.darley-catflyer-media__pdf {
    color: #d63638;
    vertical-align: middle;
}

.darley-catflyer-media__name {
    vertical-align: middle;
    margin-left: 4px;
}
