/* Videos tab on the Company Profile page (bto-profile-videos.php).
 *
 * #reno-ajax-grid is a card grid tuned for the other tabs. :has() lets this tab
 * take the full width without touching reno-portal's script, which only knows
 * the four original grid modes. */
#reno-ajax-grid:has(> .bto-videos) {
    display: block;
}

.bto-videos {
    --bto-v-blue: var(--theme-palette-color-2, #1f4e9c);
    --bto-v-text: var(--theme-palette-color-3, #1c2434);
    --bto-v-navy: #0b1d3a;   /* the section heading colour */
    --bto-v-amber: #d98a06;  /* the section kicker amber, a shade darker so small caps stay legible */
    width: 100%;
}

/* ---- category chips ---- */
.bto-videos__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 24px;
}

.bto-videos .bto-videos__chip {
    appearance: none;
    border: 1px solid #d8dde6;
    background: #fff;
    color: var(--bto-v-text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    padding: 12px 18px;
    min-height: 44px;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.bto-videos .bto-videos__chip:hover {
    border-color: var(--bto-v-blue);
}

.bto-videos .bto-videos__chip.is-active {
    background: var(--bto-v-blue);
    border-color: var(--bto-v-blue);
    color: #fff;
}

.bto-videos .bto-videos__chip:focus-visible {
    outline: 3px solid var(--bto-v-blue);
    outline-offset: 3px;
}

.bto-videos .bto-videos__card:focus-visible {
    outline: none;
}

.bto-videos .bto-videos__card:focus-visible .bto-videos__thumb {
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--bto-v-blue);
}

/* ---- grid of cards ----
   Posters are 4:5 crops (the footage is 9:16 with captions along the bottom; the
   crop drops them), so a card is about 30% shorter than a full-height Short and a
   row of four stays a row of four on a laptop. */
.bto-videos__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 14px;
    align-items: start;
}

@media (min-width: 600px) {
    .bto-videos__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 20px; }
}

@media (min-width: 900px) {
    .bto-videos__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Four is the ceiling on purpose (owner asked 2026-11-11 whether five was crowded). */

/* The card is a <button>, and a button centres its content vertically in whatever
   height the grid gives it: a one-line title next to a two-line one pushed the whole
   picture 9px down. A flex column pinned to the top stops that. */
.bto-videos .bto-videos__card {
    appearance: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.bto-videos .bto-videos__card[hidden] {
    display: none;
}

.bto-videos__thumb {
    position: relative;
    display: block;
    aspect-ratio: 4 / 5;
    border-radius: 16px;
    overflow: hidden;
    background: #e9edf3;
    box-shadow: 0 1px 2px rgba(11, 29, 58, .06), 0 8px 20px rgba(11, 29, 58, .10);
    transition: transform .22s ease, box-shadow .22s ease;
}

/* A soft shade under the badge so it reads on a bright kitchen. */
.bto-videos__thumb::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 38%;
    background: linear-gradient(to top, rgba(11, 29, 58, .38), rgba(11, 29, 58, 0));
    pointer-events: none;
}

.bto-videos__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}

.bto-videos__card:hover .bto-videos__thumb {
    transform: translateY(-3px);
    box-shadow: 0 2px 4px rgba(11, 29, 58, .08), 0 14px 28px rgba(11, 29, 58, .16);
}

.bto-videos__card:hover .bto-videos__thumb img {
    transform: scale(1.04);
}

/* Play + length in one white pill, bottom left (a centred dark disc is what every
   YouTube embed looks like). */
.bto-videos__badge {
    position: absolute;
    z-index: 1;
    left: 10px;
    bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px 5px 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .95);
    color: var(--bto-v-navy);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 2px 8px rgba(11, 29, 58, .22);
    transition: background-color .18s ease, color .18s ease;
}

.bto-videos__badge:not(:has(.bto-videos__len)) {
    padding-right: 5px;
}

.bto-videos__play {
    position: relative;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bto-v-blue);
    transition: background-color .18s ease;
}

.bto-videos__play::after {
    content: "";
    position: absolute;
    left: 10px;
    top: 8px;
    border-style: solid;
    border-width: 5px 0 5px 8px;
    border-color: transparent transparent transparent #fff;
}

.bto-videos__card:hover .bto-videos__badge {
    background: var(--bto-v-blue);
    color: #fff;
}

.bto-videos__card:hover .bto-videos__play {
    background: #fff;
}

.bto-videos__card:hover .bto-videos__play::after {
    border-left-color: var(--bto-v-blue);
}

.bto-videos__cat {
    display: block;
    margin-top: 13px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .14em;
    line-height: 1.2;
    text-transform: uppercase;
    color: var(--bto-v-amber);
}

.bto-videos__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-top: 5px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--bto-v-navy);
}

.bto-videos__more {
    margin: 40px 0 0;
    text-align: center;
}

/* The channel link as a button. The site's link-colour rules (bto-link-contrast) reach every <a>,
   hence the doubled selector and the !important on colour and underline. */
.bto-videos .bto-videos__more .bto-videos__more-link {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 13px 26px;
    border-radius: 999px;
    background: var(--bto-v-blue);
    color: #fff !important;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none !important;
    box-shadow: 0 1px 2px rgba(11, 29, 58, .10), 0 8px 18px rgba(33, 81, 151, .24);
    transition: background-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.bto-videos .bto-videos__more .bto-videos__more-link:hover,
.bto-videos .bto-videos__more .bto-videos__more-link:focus-visible {
    background: var(--bto-v-navy);
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(11, 29, 58, .14), 0 12px 24px rgba(11, 29, 58, .26);
}

.bto-videos .bto-videos__more .bto-videos__more-link:focus-visible {
    outline: 3px solid var(--bto-v-blue);
    outline-offset: 3px;
}

/* Read out by screen readers only, with its own rule so it does not depend on the theme defining one. */
.bto-videos__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.bto-videos__more-icon {
    flex: 0 0 auto;
    transition: transform .18s ease;
}

.bto-videos__more-link:hover .bto-videos__more-icon {
    transform: translate(2px, -2px);
}

/* ---- player overlay (built by videos.js) ---- */
.bto-videos-modal {
    position: fixed;
    inset: 0;
    /* Above everything: the 11.11 coupon launcher floats at a higher z-index than
       100000 and sat on top of the player on a phone (staging, 2026-11-11). */
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(10, 14, 22, .86);
}

.bto-videos-modal__frame {
    position: relative;
    height: min(86vh, 800px);
    aspect-ratio: 9 / 16;
    max-width: 100%;
    background: #000;
    border-radius: 14px;
    overflow: hidden;
}

/* A phone in portrait is narrower than 86vh * 9/16 can be; size from the width
   instead so the player is never cut off at the sides. */
@media (max-aspect-ratio: 9/14) {
    .bto-videos-modal__frame {
        height: auto;
        width: 100%;
    }
}

.bto-videos-modal__frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.bto-videos-modal .bto-videos-modal__close {
    appearance: none;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 26px;
    line-height: 44px;
    text-align: center;
    padding: 0;
    cursor: pointer;
}

.bto-videos-modal .bto-videos-modal__close:hover {
    background: rgba(255, 255, 255, .3);
}

/* ---- phones ---- */
@media (max-width: 599px) {
    /* reno-portal gives the tab bar and the section header 14px side padding on
       phones and lets the grid run edge to edge (the craft cards want that). The
       videos should line up with the header text above them instead. */
    .reno-portal-main .bto-videos {
        padding-inline: 14px;
        box-sizing: border-box;
    }

    /* One swipeable row, like the tab bar. Wrapping would push the first video
       down a full row as soon as a fourth category has a public video. */
    .bto-videos__chips {
        flex-wrap: nowrap;
        gap: 8px;
        margin: 0 -14px 18px;
        padding: 2px 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .bto-videos__chips::-webkit-scrollbar {
        display: none;
    }

    .bto-videos .bto-videos__chip {
        flex: 0 0 auto;
        white-space: nowrap;
        padding-inline: 16px;
    }

    .bto-videos__grid {
        gap: 12px;
    }

    .bto-videos__thumb {
        border-radius: 14px;
    }

    .bto-videos__badge {
        left: 8px;
        bottom: 8px;
        gap: 6px;
        padding: 4px 9px 4px 4px;
        font-size: 11px;
    }

    .bto-videos__play {
        width: 22px;
        height: 22px;
    }

    .bto-videos__play::after {
        left: 8px;
        top: 6px;
        border-width: 5px 0 5px 7px;
    }

    .bto-videos__cat {
        margin-top: 10px;
        font-size: 10px;
        letter-spacing: .12em;
    }

    .bto-videos__title {
        margin-top: 4px;
        font-size: 13px;
    }

    /* The site's floating WhatsApp / assistant buttons sit bottom-right; keep the
       closing link clear of them. */
    .bto-videos__more {
        margin-top: 26px;
        padding-bottom: 72px;
    }

    .bto-videos .bto-videos__more .bto-videos__more-link {
        width: 100%;
        max-width: 360px;
        padding-inline: 20px;
        font-size: 14px;
    }

    .bto-videos-modal {
        padding: 12px;
    }

    /* Thumb reach: bottom centre instead of the top corner. */
    .bto-videos-modal .bto-videos-modal__close {
        top: auto;
        right: auto;
        left: 50%;
        bottom: max(14px, env(safe-area-inset-bottom));
        margin-left: -24px;
        width: 48px;
        height: 48px;
        line-height: 48px;
    }

    /* Leave room for that button under the player. */
    .bto-videos-modal__frame {
        max-height: calc(100vh - 110px);
        max-height: calc(100dvh - 110px);
    }
}

/* A phone held sideways: the player must fit the short side. */
@media (orientation: landscape) and (max-height: 500px) {
    .bto-videos-modal__frame {
        height: calc(100vh - 24px);
        height: calc(100dvh - 24px);
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bto-videos__thumb,
    .bto-videos__thumb img,
    .bto-videos__badge,
    .bto-videos__play,
    .bto-videos__more-icon,
    .bto-videos .bto-videos__more .bto-videos__more-link,
    .bto-videos .bto-videos__chip { transition: none; }

    .bto-videos__card:hover .bto-videos__thumb,
    .bto-videos__card:hover .bto-videos__thumb img { transform: none; }
}
