/* ─────────────────────────────────────────────────────────────────────────
   Lite-YouTube Consent — wrapper, overlay, and embedded player styles
   ───────────────────────────────────────────────────────────────────────── */

/* The wrapper takes the place of the original <lite-youtube> in the layout,
   so its sizing rules mirror Paul Irish's defaults. */
.rlyt-embed {
    position: relative;
    display: block;
    max-width: 720px;
    margin: 0 auto;
    background: #000;
    contain: content;
    overflow: hidden;
}

/* 16:9 aspect ratio reservation */
.rlyt-embed::before {
    content: "";
    display: block;
    padding-bottom: calc(100% / (16 / 9));
}

/* Poster image fills the wrapper, slightly darkened + greyscale to signal
   "not loaded" state */
.rlyt-embed .rlyt-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%) brightness(0.65);
    transition: filter 0.15s ease;
}
.rlyt-embed .rlyt-poster-empty {
    position: absolute;
    inset: 0;
    background: #222;
}

/* Play icon centered on top of the poster. pointer-events:none so the
   underlying form catches clicks. */
.rlyt-embed .rlyt-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68px;
    height: 48px;
    pointer-events: none;
    filter: grayscale(100%);
    transition: filter 0.15s ease;
}
.rlyt-embed .rlyt-play-icon {
    width: 100%;
    height: 100%;
    display: block;
}
.rlyt-embed:hover .rlyt-play,
.rlyt-embed:hover .rlyt-poster {
    filter: none;
}

/* Consent form: pinned to the bottom edge, semi-transparent backdrop,
   short text + button. */
.rlyt-embed .rlyt-consent {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    font-size: 0.85rem;
    line-height: 1.35;
    backdrop-filter: blur(2px);
    z-index: 2;
}
.rlyt-embed .rlyt-consent p {
    margin: 0;
    flex: 1 1 14rem;
    font-size: 0.85rem;
    min-width: 0;
}
.rlyt-embed .rlyt-consent button {
    flex: 0 0 auto;
    background: #fff;
    color: #000;
    border: 0;
    border-radius: 2px;
    padding: 0.45rem 0.9rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.rlyt-embed .rlyt-consent button:hover,
.rlyt-embed .rlyt-consent button:focus {
    background: #ffe60d;
    outline: none;
}

/* The original <lite-youtube> sits inside the wrapper but is hidden until
   the user gives consent. It will be activated by lite-yt-embed.js after the
   consent click. */
.rlyt-embed > lite-youtube {
    display: none;
}

/* Active state: hide the consent overlay, reveal the lite-youtube element. */
.rlyt-embed.rlyt-active .rlyt-poster,
.rlyt-embed.rlyt-active .rlyt-play,
.rlyt-embed.rlyt-active .rlyt-consent {
    display: none;
}
/* Remove the wrapper's own 16:9 spacer — lite-youtube provides its own. */
.rlyt-embed.rlyt-active::before {
    display: none;
}
.rlyt-embed.rlyt-active > lite-youtube {
    display: block;
}

/* Optional <figure> wrapper (added by shortcode when caption= is set) */
.rlyt-figure {
    margin: 0;
}
.rlyt-figure figcaption {
    margin-top: 0.4rem;
}

/* Small screens: stack text + button */
@media (max-width: 28rem) {
    .rlyt-embed .rlyt-consent {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .rlyt-embed .rlyt-consent button {
        align-self: center;
    }
}

/* ─────────────────────────────────────────────────────────────────────────
   Paul Irish's lite-youtube styles (used once the wrapper is .rlyt-active)
   ───────────────────────────────────────────────────────────────────────── */

lite-youtube {
    background-color: #000;
    position: relative;
    display: block;
    contain: content;
    background-position: center center;
    background-size: cover;
    cursor: pointer;
    max-width: 720px;
}

lite-youtube::before {
    content: "";
    display: block;
    position: absolute;
    top: 0;
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==);
    background-position: top;
    background-repeat: repeat-x;
    height: 60px;
    padding-bottom: 50px;
    width: 100%;
    transition: all 0.2s cubic-bezier(0, 0, 0.2, 1);
}

/* responsive iframe 16:9 */
lite-youtube::after {
    content: "";
    display: block;
    padding-bottom: calc(100% / (16 / 9));
}
lite-youtube > iframe {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border: 0;
}

lite-youtube > .lty-playbtn {
    display: block;
    width: 100%;
    height: 100%;
    background: no-repeat center/68px 48px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 68 48"><path d="M66.52 7.74c-.78-2.93-2.49-5.41-5.42-6.19C55.79.13 34 0 34 0S12.21.13 6.9 1.55c-2.93.78-4.63 3.26-5.42 6.19C.06 13.05 0 24 0 24s.06 10.95 1.48 16.26c.78 2.93 2.49 5.41 5.42 6.19C12.21 47.87 34 48 34 48s21.79-.13 27.1-1.55c2.93-.78 4.64-3.26 5.42-6.19C67.94 34.95 68 24 68 24s-.06-10.95-1.48-16.26z" fill="red"/><path d="M45 24 27 14v20" fill="white"/></svg>');
    position: absolute;
    cursor: pointer;
    z-index: 1;
    filter: grayscale(100%);
    transition: filter 0.1s cubic-bezier(0, 0, 0.2, 1);
    border: 0;
}

lite-youtube:hover > .lty-playbtn,
lite-youtube .lty-playbtn:focus {
    filter: none;
}

lite-youtube.lyt-activated {
    cursor: unset;
}
lite-youtube.lyt-activated::before,
lite-youtube.lyt-activated > .lty-playbtn {
    opacity: 0;
    pointer-events: none;
}

.lyt-visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}
