/* BejaBikeStore — media component: silent looping clips, full-video dialog and photo crops.
   Production code. Self-contained, no inline styles or scripts needed (CSP: style-src/script-src 'self').
   Colours reuse the site.css tokens, with the brand values as fallbacks. */

/* --- Silent loops --------------------------------------------------------------------------- */

.media-loop {
    position: relative;
    margin: 0 0 0.75rem;
    border-radius: var(--radius, 12px);
    overflow: hidden;
    background: var(--ink, #1F1B1B);
}

/* width/height attributes + aspect-ratio reserve the box, so the poster appears with no layout shift. */
.media-loop-video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--ink, #1F1B1B);
}

/* In long-form pages a loop (with its "open video" button, wrapped in .media-block) always gets its
   own full-width row, below any floated .content-figure. */
.prose .media-block { clear: both; margin: 1.25rem 0 0; }
.prose .media-loop { clear: both; margin: 0 0 0.75rem; }

.media-loop-toggle {
    position: absolute;
    right: 0.6rem;
    bottom: 0.6rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
    min-width: 44px;
    padding: 0.45rem 0.85rem;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--white, #FFFFFF);
    background: rgba(31, 27, 27, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    cursor: pointer;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.media-loop-toggle:hover { background: rgba(31, 27, 27, 0.9); }
.media-loop-toggle::before {
    /* Pause bars while playing, a triangle when paused; drawn in CSS so no icon font or emoji fallback. */
    content: "";
    flex: 0 0 auto;
    width: 0.7rem;
    height: 0.8rem;
    border-left: 0.22rem solid currentColor;
    border-right: 0.22rem solid currentColor;
    box-sizing: border-box;
}
.media-loop-toggle.is-paused::before {
    width: 0;
    height: 0;
    border-top: 0.42rem solid transparent;
    border-bottom: 0.42rem solid transparent;
    border-left: 0.7rem solid var(--yellow, #FFD800);
    border-right: 0;
}

/* --- Opening the full (narrated) video ------------------------------------------------------ */

.media-actions { margin: 0 0 1.5rem; }
.prose .media-actions { clear: both; }
.video-open-icon { font-variant-emoji: text; font-size: 0.8em; }

/* --- A video shown in the page (controls, sound, never autoplayed) -------------------------- */

.video-inline { margin: 0; }
.video-inline-video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    background: var(--ink, #1F1B1B);
    border-radius: var(--radius, 12px);
}
.video-inline figcaption { margin-top: 0.5rem; font-size: 0.9rem; color: var(--muted, #5C5657); }
.page-head .video-inline figcaption { color: var(--on-dark-muted, #C8C2BF); }

/* --- Shared dialog ------------------------------------------------------------------------- */

.video-dialog {
    width: min(64rem, calc(100vw - 2rem));
    max-width: none;
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 0;
    border-radius: var(--radius, 12px);
    background: var(--ink, #1F1B1B);
    color: var(--on-dark, #F2F0EC);
    overflow: hidden;
}
.video-dialog::backdrop { background: rgba(31, 27, 27, 0.85); }
html:has(.video-dialog[open]) { overflow: hidden; }

.video-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border-bottom: 4px solid var(--yellow, #FFD800);
}
.video-dialog-title {
    margin: 0;
    font-size: 1.05rem;
    color: var(--white, #FFFFFF);
}
.video-dialog-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 44px;
    min-width: 44px;
    padding: 0.4rem 1rem;
    font: inherit;
    font-weight: 800;
    font-stretch: 90%;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.85rem;
    color: var(--ink, #1F1B1B);
    background: var(--yellow, #FFD800);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}
.video-dialog-close:hover { background: #FFE04D; }

.video-dialog-video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    max-height: calc(100vh - 6rem);
    background: #000;
}

/* --- Photos ---------------------------------------------------------------------------------- */

/* Portrait photos placed in landscape slots: crop to the slot, keeping the face (upper-middle third). */
.media-crop { width: 100%; object-fit: cover; object-position: 50% 28%; aspect-ratio: 4 / 3; }
.media-crop.is-square { aspect-ratio: 1 / 1; object-position: 50% 35%; }

/* A full-width photo inside long-form text (the narrow floated .content-figure is the other option). */
.media-figure { clear: both; margin: 1.25rem 0 1.5rem; }
.media-figure img { width: 100%; border-radius: var(--radius, 12px); }

/* Gallery with a leading 16:9 clip across the full row, then the photos in an even grid. */
.gallery.gallery-lead { grid-template-columns: 1fr 1fr; }
.gallery-lead > .gallery-lead-item { grid-column: 1 / -1; }
.gallery-lead .media-loop { margin-bottom: 0.5rem; border-radius: 8px; }
.gallery-lead .media-actions { margin: 0 0 0.75rem; }
@media (min-width: 64rem) {
    .gallery.gallery-lead { grid-template-columns: repeat(4, 1fr); }
}

/* --- Shimano Service Center seal (Oficina) ----------------------------------------------------- */

/* Official SSC logo as published on bike.shimano.com (PNG, 263×110). Shown at 9rem (~144 px) so it
   stays sharp on high-density screens; it is a square-cornered blue block, so no rounding. For
   production, swap in the vector file from SC Vouga / Shimano and follow their usage rules
   (clear space, colours, background). */
.ssc-seal {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
    margin: 0.5rem 0 1.5rem;
    padding: 1rem;
    background: var(--paper, #F6F5F2);
    border-radius: var(--radius, 12px);
}
.ssc-seal-img {
    flex: 0 0 auto;
    width: 9rem;
    max-width: 100%;
    height: auto;
}
.ssc-seal-text {
    flex: 1 1 16rem;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}
