/*
 * Easy Way To Live Well branded YouTube video (pattern "ew-yt").
 * A poster image and a brand-green play button; assets/js/ew-yt.js swaps in the YouTube
 * player (youtube-nocookie) on click. Self-contained: works inside .ew-page pages and on
 * any other page. Loaded on pages that use it and inside the block editor (inc/ew-yt.php).
 */

body .ew-yt-sec,
body .ew-yt {
    --yt-ink: #27322A;
    --yt-green: #5E7852;
    --yt-green-d: #4C6642;
    --yt-leaf: #E8F0E3;
    --yt-mist: #FBF8F3;
}

/* ---------- section ---------- */
body .ew-yt-sec {
    padding-block: clamp(64px, 9vw, 112px);
    background: var(--yt-mist);
}

body .ew-yt-sec .ew-yt-wrap {
    box-sizing: border-box;
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding-inline: 32px;
}

body .ew-yt-sec .ew-yt-title {
    max-width: 760px;
    margin: 0 auto clamp(36px, 4.5vw, 56px);
    padding: 0;
    color: var(--yt-ink);
    font-family: "Fraunces", Georgia, serif;
    font-size: clamp(34px, 3.6vw, 52px);
    font-weight: 500;
    line-height: 1.12;
    letter-spacing: -0.015em;
    text-align: center;
    text-wrap: balance;
}

/* ---------- branded frame ---------- */
body .ew-yt {
    position: relative;
    isolation: isolate;
    width: 100%;
    margin: 0 0 22px;
}

/* soft leaf-green offset panel behind the frame */
body .ew-yt::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 22px -22px -22px 22px;
    border-radius: 6px;
    background: var(--yt-leaf);
}

body .ew-yt .ew-yt-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 6px;
    background: var(--yt-ink);
    box-shadow: 0 24px 60px rgba(39, 50, 42, 0.16);
}

body .ew-yt .ew-yt-poster {
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
    object-fit: cover;
    transition: transform 0.6s ease;
}

/* ---------- play button (covers the whole poster, so any click plays) ---------- */
body .ew-yt .ew-yt-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: linear-gradient(to top, rgba(39, 50, 42, 0.38), rgba(39, 50, 42, 0) 60%);
    color: #FFFFFF;
    text-decoration: none;
    cursor: pointer;
    outline: none;
}

body .ew-yt .ew-yt-play .gb-shape {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--yt-green);
    color: #FFFFFF;
    box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.45), 0 18px 40px rgba(39, 50, 42, 0.35);
    transition: transform 0.25s ease, background 0.2s ease;
}

/* gentle pulse ring */
body .ew-yt .ew-yt-play .gb-shape::after {
    content: "";
    position: absolute;
    inset: -10px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: ew-yt-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

body .ew-yt .ew-yt-play svg {
    width: 34px;
    height: 34px;
    margin-left: 5px; /* optical centre of the triangle */
    fill: currentColor;
}

body .ew-yt .ew-yt-play:hover .gb-shape,
body .ew-yt .ew-yt-play:focus-visible .gb-shape {
    background: var(--yt-green-d);
    transform: scale(1.07);
}

body .ew-yt .ew-yt-frame:hover .ew-yt-poster {
    transform: scale(1.02);
}

body .ew-yt .ew-yt-play:focus-visible .gb-shape {
    outline: 3px solid #FFFFFF;
    outline-offset: 14px;
}

@keyframes ew-yt-pulse {
    0% { opacity: 0.9; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.35); }
}

/* ---------- playing ---------- */
body .ew-yt .ew-yt-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

body .ew-yt.is-playing .ew-yt-play,
body .ew-yt.is-playing .ew-yt-poster {
    display: none;
}

/* ---------- small screens / motion ---------- */
@media (max-width: 560px) {
    body .ew-yt-sec .ew-yt-wrap {
        padding-inline: 20px;
    }

    body .ew-yt::before {
        inset: 12px -10px -12px 10px;
    }

    body .ew-yt .ew-yt-play .gb-shape {
        width: 72px;
        height: 72px;
        box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.45), 0 12px 28px rgba(39, 50, 42, 0.35);
    }

    body .ew-yt .ew-yt-play svg {
        width: 26px;
        height: 26px;
        margin-left: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body .ew-yt .ew-yt-play .gb-shape::after {
        animation: none;
        opacity: 0;
    }

    body .ew-yt .ew-yt-play .gb-shape,
    body .ew-yt .ew-yt-poster {
        transition: none;
    }
}

/* White homepage video play button. */
body .ew-yt .ew-yt-play .gb-shape,
body .ew-yt .ew-yt-play:hover .gb-shape,
body .ew-yt .ew-yt-play:focus-visible .gb-shape {
    background: #FFFFFF;
    color: #3F622F;
}

body .ew-yt .ew-yt-play .gb-shape svg {
    fill: #3F622F;
}
