/* ==========================================================
   ANDALUS_YOUTUBE_EMBED_V1 — site-wide YouTube presentation
   Pairs with includes/andalus-youtube-embed.php + assets/andalus-youtube-v1.js
   ========================================================== */

.an-yt{
    --an-yt-max:980px;
    --an-yt-brand:#7d1d2b;
    --an-yt-radius:26px;
    width:min(100%, var(--an-yt-max));
    margin:0 auto;
    padding:0;
}

/* The frame: dark card with a blurred, zoomed copy of the poster behind the stage */
.an-yt__frame{
    position:relative;
    overflow:hidden;
    isolation:isolate;
    border-radius:var(--an-yt-radius);
    background:#0d0a0a;
    box-shadow:0 26px 70px rgba(36,16,20,.28);
    border:1px solid rgba(255,255,255,.06);
}
.an-yt__bg{
    position:absolute;
    inset:-8%;
    width:116%;
    height:116%;
    object-fit:cover;
    filter:blur(26px) brightness(.5) saturate(1.25);
    transform:scale(1.05);
    z-index:0;
    pointer-events:none;
}

/* Stage = the real video box (poster first, iframe after the tap) */
.an-yt__stage{
    position:relative;
    z-index:1;
    width:100%;
    aspect-ratio:16/9;
    margin:0 auto;
    background:#000;
    overflow:hidden;
}
.an-yt[data-yt-layout="square"] .an-yt__stage{ aspect-ratio:1; width:min(100%,720px); }

/* Vertical shorts: 9:16 stage centred inside a 16:9 frame on wide screens */
.an-yt[data-yt-layout="portrait"] .an-yt__frame{ aspect-ratio:16/9; }
.an-yt[data-yt-layout="portrait"] .an-yt__stage{
    position:absolute;
    inset:0;
    width:auto;
    height:100%;
    aspect-ratio:9/16;
    margin:0 auto;
    border-radius:0;
    box-shadow:0 0 0 1px rgba(255,255,255,.12), 0 20px 60px rgba(0,0,0,.45);
}

.an-yt__tap{
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    margin:0;
    padding:0;
    border:0;
    background:#000;
    cursor:pointer;
    display:block;
    font-family:inherit;
}
.an-yt__poster{
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
    transition:transform .5s ease, filter .3s ease;
}
.an-yt__tap:hover .an-yt__poster{ transform:scale(1.03); filter:brightness(.92); }

/* Play button: brand circle, soft pulse */
.an-yt__btn{
    position:absolute;
    left:50%;
    top:50%;
    width:84px;
    height:84px;
    margin:-42px 0 0 -42px;
    display:grid;
    place-items:center;
    border-radius:50%;
    color:#fff;
    background:var(--an-yt-brand);
    box-shadow:0 18px 40px rgba(0,0,0,.45), 0 0 0 10px rgba(255,255,255,.16);
    transition:transform .2s ease, box-shadow .2s ease;
}
.an-yt__btn svg{ margin-inline-start:4px; }
.an-yt__tap:hover .an-yt__btn{ transform:scale(1.07); box-shadow:0 20px 46px rgba(0,0,0,.5), 0 0 0 14px rgba(255,255,255,.2); }
@keyframes an-yt-pulse{ 0%{ box-shadow:0 18px 40px rgba(0,0,0,.45), 0 0 0 10px rgba(255,255,255,.16);} 70%{ box-shadow:0 18px 40px rgba(0,0,0,.45), 0 0 0 22px rgba(255,255,255,0);} 100%{ box-shadow:0 18px 40px rgba(0,0,0,.45), 0 0 0 10px rgba(255,255,255,0);} }
@media (prefers-reduced-motion:no-preference){ .an-yt__btn{ animation:an-yt-pulse 2.4s ease-out infinite; } }

.an-yt__hint{
    position:absolute;
    left:50%;
    top:calc(50% + 58px);
    transform:translateX(-50%);
    padding:7px 14px;
    border-radius:100px;
    background:rgba(0,0,0,.55);
    color:#fff;
    font-size:14px;
    font-weight:900;
    white-space:nowrap;
    backdrop-filter:blur(6px);
    -webkit-backdrop-filter:blur(6px);
}

/* Title ribbon at the bottom of the frame */
.an-yt__title{
    position:absolute;
    z-index:2;
    inset:auto 0 0;
    padding:46px 20px 16px;
    color:#fff;
    font-size:17px;
    font-weight:900;
    line-height:1.5;
    text-align:right;
    background:linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0));
    pointer-events:none;
}
.an-yt[data-yt-layout="portrait"] .an-yt__title{ text-align:center; }

.an-yt__caption{
    margin:12px 4px 0;
    color:#80675a;
    font-size:15px;
    font-weight:800;
    line-height:1.7;
    text-align:center;
}

/* Playing state */
.an-yt.is-playing .an-yt__title,
.an-yt.is-playing .an-yt__hint{ display:none; }
.an-yt__stage iframe{
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    border:0;
    display:block;
}

/* Phones: a portrait short fills the width as a 9:16 card (no side blur needed) */
@media (max-width:720px){
    .an-yt{ --an-yt-radius:20px; }
    .an-yt[data-yt-layout="portrait"]{ width:min(100%, 360px); }
    .an-yt[data-yt-layout="portrait"] .an-yt__frame{ aspect-ratio:auto; }
    .an-yt[data-yt-layout="portrait"] .an-yt__stage{
        position:relative;
        inset:auto;
        width:100%;
        height:auto;
        box-shadow:none;
    }
    .an-yt[data-yt-layout="portrait"] .an-yt__bg{ display:none; }
    .an-yt__btn{ width:72px; height:72px; margin:-36px 0 0 -36px; }
    .an-yt__btn svg{ width:30px; height:30px; }
    .an-yt__hint{ top:calc(50% + 50px); font-size:13px; }
    .an-yt__title{ font-size:15px; padding:36px 14px 12px; }
    .an-yt__caption{ font-size:14px; }
}
@media (max-width:720px){
    .an-yt[data-yt-layout="landscape"] .an-yt__hint,
    .an-yt[data-yt-layout="square"] .an-yt__hint{ display:none; }
    .an-yt[data-yt-layout="landscape"] .an-yt__btn{ width:64px; height:64px; margin:-32px 0 0 -32px; }
}

/* Taps always reach the button, never an image-preview handler */
.an-yt__poster,
.an-yt__bg,
.an-yt__btn,
.an-yt__hint{ pointer-events:none; }
.an-yt__tap{ touch-action:manipulation; -webkit-tap-highlight-color:transparent; }


/* ==========================================================
   Controls under the player + fullscreen / theater modes
   ========================================================== */
.an-yt__bar{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:10px;
    flex-wrap:wrap;
    margin:12px auto 0;
}
.an-yt__fs,
.an-yt__open{
    min-height:46px;
    padding:0 18px;
    display:inline-flex;
    align-items:center;
    gap:8px;
    border-radius:100px;
    font-family:inherit;
    font-size:15px;
    font-weight:900;
    text-decoration:none;
    cursor:pointer;
    transition:transform .15s ease, box-shadow .15s ease;
}
.an-yt__fs{
    border:0;
    background:var(--an-yt-brand);
    color:#fff;
    box-shadow:0 10px 24px rgba(125,29,43,.22);
}
.an-yt__open{
    border:1px solid #e3d3c6;
    background:#fff;
    color:#4e352a;
}
.an-yt__fs:hover,.an-yt__open:hover{ transform:translateY(-1px); }
.an-yt__fs:focus-visible,.an-yt__open:focus-visible,.an-yt__close:focus-visible{ outline:3px solid #f0d4a8; outline-offset:2px; }

.an-yt__close{
    display:none;
    position:absolute;
    z-index:5;
    top:max(12px, env(safe-area-inset-top));
    left:12px;
    width:46px;
    height:46px;
    border:0;
    border-radius:50%;
    background:rgba(0,0,0,.62);
    color:#fff;
    place-items:center;
    cursor:pointer;
    backdrop-filter:blur(6px);
    -webkit-backdrop-filter:blur(6px);
}

/* Native fullscreen: the frame fills the screen, video keeps its ratio */
.an-yt__frame:fullscreen,
.an-yt__frame:-webkit-full-screen{
    width:100vw !important;
    height:100vh !important;
    max-width:none !important;
    aspect-ratio:auto !important;
    border-radius:0 !important;
    border:0 !important;
    background:#000 !important;
    display:grid;
    place-items:center;
}
.an-yt__frame:fullscreen .an-yt__stage,
.an-yt__frame:-webkit-full-screen .an-yt__stage{
    position:relative !important;
    inset:auto !important;
    width:min(100vw, calc(100vh * 16 / 9)) !important;
    height:auto !important;
    aspect-ratio:16/9 !important;
    box-shadow:none !important;
}
.an-yt[data-yt-layout="portrait"] .an-yt__frame:fullscreen .an-yt__stage,
.an-yt[data-yt-layout="portrait"] .an-yt__frame:-webkit-full-screen .an-yt__stage{
    width:auto !important;
    height:100vh !important;
    max-width:100vw;
    aspect-ratio:9/16 !important;
}
.an-yt__frame:fullscreen .an-yt__bg,
.an-yt__frame:-webkit-full-screen .an-yt__bg{ display:block !important; }
.an-yt__frame:fullscreen .an-yt__close,
.an-yt__frame:-webkit-full-screen .an-yt__close{ display:grid; }

/* Theater fallback (iPhone and browsers without the Fullscreen API) */
html.an-yt-lock,
html.an-yt-lock body{ overflow:hidden !important; }
.an-yt.is-theater .an-yt__frame{
    position:fixed !important;
    inset:0 !important;
    z-index:2147483000;
    width:100vw !important;
    height:100dvh !important;
    max-width:none !important;
    aspect-ratio:auto !important;
    border-radius:0 !important;
    border:0 !important;
    background:#000 !important;
    display:grid;
    place-items:center;
}
.an-yt.is-theater .an-yt__stage{
    position:relative !important;
    inset:auto !important;
    width:min(100vw, calc(100dvh * 16 / 9)) !important;
    height:auto !important;
    aspect-ratio:16/9 !important;
    box-shadow:none !important;
}
.an-yt.is-theater[data-yt-layout="portrait"] .an-yt__stage{
    width:min(100vw, calc(100dvh * 9 / 16)) !important;
    height:auto !important;
    aspect-ratio:9/16 !important;
}
.an-yt.is-theater .an-yt__bg{ display:block !important; }
.an-yt.is-theater .an-yt__close{ display:grid; }

@media (max-width:720px){
    .an-yt__bar{ gap:8px; }
    .an-yt__fs,.an-yt__open{ min-height:44px; padding:0 14px; font-size:14px; }
}
