/*!
 * Buzzin Content Studio - front-end video transcript accordion.
 *
 * This renders inside arbitrary customer themes, light and dark, so it uses no
 * brand palette and no hard-coded text colour: everything derives from
 * currentColor and rgba() so it inherits whatever the theme already set. Every
 * rule is scoped under .buzzin-transcript-block to keep the plugin out of the
 * theme's way.
 */

.buzzin-transcript-block {
    margin: 2rem 0;
}

.buzzin-transcript-details {
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: 6px;
    /* Faint neutral wash: readable over both white and near-black themes. */
    background-color: rgba(128, 128, 128, 0.05);
    overflow: hidden;
}

/* --------------------------------------------------------------------------
 * Summary: the whole row is the hit target, with a CSS-drawn chevron instead
 * of the default triangle so it looks the same across browsers.
 * ------------------------------------------------------------------------ */
.buzzin-transcript-block .buzzin-transcript-summary {
    display: flex;
    align-items: center;
    gap: 0.6em;
    padding: 0.85em 1em;
    margin: 0;
    cursor: pointer;
    font-weight: 600;
    line-height: 1.4;
    list-style: none;
    user-select: none;
    transition: background-color 0.15s ease;
}

.buzzin-transcript-block .buzzin-transcript-summary::-webkit-details-marker {
    display: none;
}

.buzzin-transcript-block .buzzin-transcript-summary::before {
    content: '';
    flex: 0 0 auto;
    width: 0.5em;
    height: 0.5em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    /* Points right when collapsed, down when open. */
    transform: rotate(-45deg);
    transform-origin: center;
    opacity: 0.7;
    transition: transform 0.15s ease;
}

.buzzin-transcript-block .buzzin-transcript-details[open] > .buzzin-transcript-summary::before {
    transform: rotate(45deg);
}

.buzzin-transcript-block .buzzin-transcript-summary:hover {
    background-color: rgba(128, 128, 128, 0.1);
}

.buzzin-transcript-block .buzzin-transcript-summary:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

/* --------------------------------------------------------------------------
 * Panel: positioning context for the copy button, which floats over the
 * scrolling transcript rather than scrolling away with it.
 * ------------------------------------------------------------------------ */
.buzzin-transcript-block .buzzin-transcript-panel {
    position: relative;
    padding: 0 1em 1em;
    border-top: 1px solid rgba(128, 128, 128, 0.25);
}

.buzzin-transcript-block .buzzin-transcript-copy {
    position: absolute;
    top: 0.75em;
    right: 1em;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.35em 0.7em;
    border: 1px solid rgba(128, 128, 128, 0.4);
    border-radius: 4px;
    /* Opaque-ish so the scrolling text never shows through the button. */
    background-color: rgba(128, 128, 128, 0.12);
    color: inherit;
    font: inherit;
    font-size: 0.8125em;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.buzzin-transcript-block .buzzin-transcript-copy:hover {
    background-color: rgba(128, 128, 128, 0.22);
    border-color: rgba(128, 128, 128, 0.6);
}

.buzzin-transcript-block .buzzin-transcript-copy:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
 * Copy glyph: two overlapping rounded rectangles, drawn from borders rather
 * than shipped as an inline <svg>. kses has no svg/rect/path in
 * $allowedposttags, so an SVG icon would be deleted from the stored post the
 * first time an editor without unfiltered_html re-saved it. Borders in
 * currentColor, sized in em, need no icon font and inherit the theme's colour
 * and text size.
 * ------------------------------------------------------------------------ */
.buzzin-transcript-block .buzzin-transcript-copy-icon {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 1em;
    height: 1em;
    /* Optical alignment against the adjacent label's baseline. */
    top: 0.05em;
}

/*
 * Back sheet. Only the two edges that the front sheet does not cover are
 * drawn: hiding a full rectangle would need an opaque fill, and inside an
 * arbitrary customer theme there is no colour we can know is opaque and
 * correct on both light and dark backgrounds. Borders alone always render
 * correctly, and the two ends running under the front sheet read as the sheet
 * continuing behind it.
 */
.buzzin-transcript-block .buzzin-transcript-copy-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0.62em;
    height: 0.62em;
    border-top: 1px solid currentColor;
    border-left: 1px solid currentColor;
    border-top-left-radius: 0.2em;
    opacity: 0.75;
}

/* Front sheet: the complete rounded rectangle, offset down and to the right. */
.buzzin-transcript-block .buzzin-transcript-copy-icon::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 0.72em;
    height: 0.72em;
    border: 1px solid currentColor;
    border-radius: 0.2em;
}

/* --------------------------------------------------------------------------
 * Transcript body: capped height so a 40-minute transcript cannot dominate the
 * article, with the top padding clearing the floating copy button.
 * ------------------------------------------------------------------------ */
.buzzin-transcript-block .buzzin-transcript-text {
    max-height: 26rem;
    overflow: auto;
    padding-top: 3.25em;
    /* Room for the scrollbar so text does not sit under it. */
    padding-right: 0.5em;
    line-height: 1.7;
    overflow-wrap: break-word;
    -webkit-overflow-scrolling: touch;
}

.buzzin-transcript-block .buzzin-transcript-text p {
    margin: 0 0 1em;
}

.buzzin-transcript-block .buzzin-transcript-text p:last-child {
    margin-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
    .buzzin-transcript-block .buzzin-transcript-summary,
    .buzzin-transcript-block .buzzin-transcript-summary::before,
    .buzzin-transcript-block .buzzin-transcript-copy {
        transition: none;
    }
}
