/*
 * CinemaPlayer chrome (js/cinema-player.js). Self-contained: works inside `.tc` pages and on
 * its own. The player sets --played and --buffered (0..1) on the root; --hov on the scrubber.
 */

.cp {
    --cp-accent: var(--main-theme-color, #2f57ef);
    --cp-accent-2: var(--secondary-theme-color, #b966e7);
    --cp-grad: linear-gradient(90deg, var(--cp-accent), var(--cp-accent-2));
    --played: 0;
    --buffered: 0;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 18px;
    overflow: hidden;
    color: #fff;
    font-family: 'Euclid Circular', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 40px 120px -40px rgba(0, 0, 0, .9);
    isolation: isolate;
    container-type: inline-size;
}

.cp *,
.cp *::before,
.cp *::after { box-sizing: border-box; }

.cp:focus-visible { box-shadow: 0 0 0 2px var(--cp-accent-2); }

.cp.is-fs,
.cp:fullscreen {
    border-radius: 0;
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
}

.cp__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    display: block;
}

.cp.is-idle,
.cp.is-idle .cp__video { cursor: none; }

.cp__ico {
    width: 22px;
    height: 22px;
    display: block;
    flex: none;
}

/* Gradients that keep the chrome legible over any picture. */
.cp__shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(0deg, rgba(0, 0, 0, .82) 0%, rgba(0, 0, 0, .35) 18%, rgba(0, 0, 0, 0) 34%),
        linear-gradient(180deg, rgba(0, 0, 0, .6) 0%, rgba(0, 0, 0, 0) 22%);
    transition: opacity .5s ease;
}

.cp__top {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    padding: 20px 24px;
    pointer-events: none;
    transition: opacity .5s ease, transform .5s ease;
}

.cp__top div { display: grid; gap: 3px; max-width: 80%; }

.cp__kicker {
    font-size: 11.5px;
    letter-spacing: .16em;
    text-transform: uppercase;
    opacity: .7;
    font-weight: 600;
}

.cp__title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -.01em;
    text-shadow: 0 1px 12px rgba(0, 0, 0, .6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp:not(.has-title) .cp__top { display: none; }

/* Hidden chrome while playing and idle */
.cp.is-idle .cp__shade,
.cp.is-idle .cp__top,
.cp.is-idle .cp__bar { opacity: 0; }
.cp.is-idle .cp__top { transform: translateY(-8px); }
.cp.is-idle .cp__bar { transform: translateY(8px); pointer-events: none; }

/* Fresh (never played): the poster with a big button, a softer gradient, no bar. */
.cp.is-fresh .cp__bar { opacity: 0; pointer-events: none; }

.cp__big {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 92px;
    height: 92px;
    margin: -46px 0 0 -46px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .3);
    background: rgba(255, 255, 255, .14);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    backdrop-filter: blur(14px) saturate(1.4);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    padding: 0;
    transition: transform .35s cubic-bezier(.2, .7, .2, 1), opacity .3s, background .3s;
    z-index: 3;
}

.cp__big .cp__ico { width: 34px; height: 34px; margin-left: 5px; }
.cp__big:hover { transform: scale(1.08); background: rgba(255, 255, 255, .24); }

.cp__big::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .4);
    animation: cp-pulse 2.4s cubic-bezier(.2, .7, .2, 1) infinite;
}

@keyframes cp-pulse {
    0% { transform: scale(1); opacity: .8; }
    100% { transform: scale(1.6); opacity: 0; }
}

.cp.is-playing .cp__big,
.cp.is-waiting .cp__big,
.cp.is-panel .cp__big,
.cp.is-error .cp__big,
.cp.is-ended .cp__big {
    opacity: 0;
    pointer-events: none;
    transform: scale(.8);
}

.cp.is-paused:not(.is-fresh):not(.is-ended) .cp__big { width: 76px; height: 76px; margin: -38px 0 0 -38px; }
.cp.is-paused:not(.is-fresh):not(.is-ended) .cp__big::after { display: none; }

/* Spinner */
.cp__spin {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s .25s;
    z-index: 2;
}

.cp__spin i {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .18);
    border-top-color: #fff;
    animation: cp-spin .8s linear infinite;
}

.cp.is-waiting .cp__spin { opacity: 1; }

@keyframes cp-spin { to { transform: rotate(360deg); } }

/* Centre flash on play/pause */
.cp__flash {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    display: grid;
    place-items: center;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
}

.cp__flash .cp__ico { width: 28px; height: 28px; }
.cp__flash.is-on { animation: cp-flash .6s ease-out; }

@keyframes cp-flash {
    0% { opacity: .9; transform: scale(.8); }
    100% { opacity: 0; transform: scale(1.4); }
}

/* Double-tap / J / L seek feedback */
.cp__seekfx {
    position: absolute;
    top: 50%;
    width: 110px;
    height: 110px;
    margin-top: -55px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .4);
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
}

.cp__seekfx b { font-size: 13px; font-weight: 600; }
.cp__seekfx--l { left: 12%; }
.cp__seekfx--r { right: 12%; }
.cp__seekfx.is-on { animation: cp-flash .7s ease-out; }

/* Toast (resume, volume, speed) */
.cp__toast {
    position: absolute;
    left: 50%;
    top: 22px;
    transform: translate(-50%, -8px);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px 10px 18px;
    border-radius: 999px;
    background: rgba(12, 14, 20, .82);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, .12);
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .4s cubic-bezier(.2, .7, .2, 1);
    z-index: 6;
    white-space: nowrap;
}

.cp__toast:not(:has(button)) { padding-right: 18px; }
.cp__toast.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

.cp .cp__toast-btn {
    height: 30px;
    padding: 0 14px;
    border-radius: 999px;
    border: 0;
    background: #fff;
    color: #000;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

/* Bottom bar */
.cp__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0 14px 10px;
    z-index: 4;
    transition: opacity .5s ease, transform .5s ease;
}

.cp__scrub {
    --hov: 0;
    position: relative;
    height: 22px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
    margin: 0 6px;
    outline: none;
}

.cp__rail {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .22);
    transition: height .18s ease;
}

.cp__scrub:hover .cp__rail,
.cp.is-scrubbing .cp__rail,
.cp__scrub:focus-visible .cp__rail { height: 7px; }

.cp__rail i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: inherit;
}

.cp__buf { width: calc(var(--buffered) * 100%); background: rgba(255, 255, 255, .32); }
.cp__hov { width: calc(var(--hov) * 100%); background: rgba(255, 255, 255, .25); opacity: 0; transition: opacity .15s; }
.cp__scrub:hover .cp__hov { opacity: 1; }
.cp__fill { width: calc(var(--played) * 100%); background: var(--cp-grad); box-shadow: 0 0 16px var(--cp-accent); }

.cp__rail .cp__knob {
    left: calc(var(--played) * 100%);
    top: 50%;
    bottom: auto;
    width: 15px;
    height: 15px;
    margin: -7.5px 0 0 -7.5px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .18), 0 2px 8px rgba(0, 0, 0, .5);
    transform: scale(0);
    transition: transform .18s ease;
}

.cp__scrub:hover .cp__knob,
.cp.is-scrubbing .cp__knob,
.cp__scrub:focus-visible .cp__knob { transform: scale(1); }

.cp__tip {
    position: absolute;
    bottom: 26px;
    left: calc(var(--hov) * 100%);
    transform: translateX(-50%);
    padding: 5px 9px;
    border-radius: 6px;
    background: rgba(12, 14, 20, .9);
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    white-space: nowrap;
}

.cp__scrub:hover .cp__tip,
.cp.is-scrubbing .cp__tip { opacity: 1; }

.cp__row {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 2px;
}

.cp__btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    padding: 0;
    transition: background .2s, transform .2s;
    flex: none;
}

.cp__btn:hover { background: rgba(255, 255, 255, .12); }
.cp__btn:active { transform: scale(.92); }
.cp__btn[aria-pressed="true"] { color: var(--cp-accent-2); }

/* Tooltips on hover (pointer devices only) */
@media (hover: hover) {
    .cp__btn[data-tip]::after {
        content: attr(data-tip);
        position: absolute;
        bottom: calc(100% + 6px);
        left: 50%;
        transform: translateX(-50%) translateY(4px);
        padding: 5px 9px;
        border-radius: 6px;
        background: rgba(12, 14, 20, .92);
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity .15s, transform .2s;
    }

    .cp__btn[data-tip]:hover::after { opacity: 1; transform: translateX(-50%); }
    .cp__row > .cp__btn:last-child[data-tip]::after { left: auto; right: 0; transform: translateY(4px); }
    .cp__row > .cp__btn:last-child[data-tip]:hover::after { transform: none; }
    .cp.is-menu .cp__btn::after { display: none; }
}

.cp__volwrap {
    display: flex;
    align-items: center;
}

.cp__vol {
    --v: 1;
    -webkit-appearance: none;
    appearance: none;
    width: 0;
    height: 4px;
    margin: 0;
    padding: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, #fff calc(var(--v) * 100%), rgba(255, 255, 255, .25) 0);
    opacity: 0;
    cursor: pointer;
    transition: width .25s cubic-bezier(.2, .7, .2, 1), opacity .2s, margin .25s;
    outline: none;
    border: 0;
}

.cp__volwrap:hover .cp__vol,
.cp__vol:focus-visible { width: 78px; opacity: 1; margin: 0 10px 0 2px; }

.cp__vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    border: 0;
}

.cp__vol::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    border: 0;
}

.cp__time {
    display: flex;
    gap: 5px;
    padding: 0 8px;
    font-size: 13.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cp__sep,
.cp__dur { opacity: .6; }

.cp__spacer { flex: 1; }

.cp__rate {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 5px;
    background: rgba(255, 255, 255, .16);
    margin-right: 4px;
}

.cp__rate:empty { display: none; }

@container (max-width: 560px) {
    .cp__toast { top: auto; bottom: 74px; font-size: 13px; }
    .cp.is-fresh .cp__toast { bottom: 14px; }
    .cp__hide-xs { display: none !important; }
    .cp__btn { width: 40px; height: 40px; }
    .cp__time { font-size: 12.5px; padding: 0 4px; }
    .cp__top { padding: 14px 16px; }
    .cp__title { font-size: 15px; }
    .cp__big { width: 72px; height: 72px; margin: -36px 0 0 -36px; }
}

@container (max-width: 760px) {
    .cp__hide-s { display: none !important; }
}

/* Settings menu */
.cp__menu {
    position: absolute;
    right: 14px;
    bottom: 76px;
    width: 280px;
    max-height: calc(100% - 100px);
    overflow-y: auto;
    padding: 10px;
    border-radius: 16px;
    background: rgba(14, 16, 23, .94);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .8);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .2s, transform .25s cubic-bezier(.2, .7, .2, 1), visibility .2s;
    z-index: 7;
}

.cp.is-menu .cp__menu { opacity: 1; visibility: visible; transform: none; }

.cp__menu-sec { padding: 6px 6px 12px; border-bottom: 1px solid rgba(255, 255, 255, .08); margin-bottom: 6px; }

.cp__menu-h {
    display: block;
    font-size: 11.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    opacity: .55;
    margin-bottom: 10px;
    font-weight: 600;
}

.cp__rates {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.cp .cp__rates button {
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .1);
    background: rgba(255, 255, 255, .04);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.cp__rates button:hover { background: rgba(255, 255, 255, .1); }
.cp .cp__rates button[aria-checked="true"] { background: #fff; color: #000; border-color: #fff; }
.cp__rates button:first-child { grid-column: span 1; }

.cp__switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    color: #fff;
}

.cp__switch:hover { background: rgba(255, 255, 255, .05); }
.cp__switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.cp__switch i {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .2);
    transition: background .2s;
    flex: none;
}

.cp__switch i::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform .25s cubic-bezier(.2, .7, .2, 1);
}

.cp__switch input:checked + i { background: var(--cp-grad); }
.cp__switch input:checked + i::after { transform: translateX(16px); }
.cp__switch input:focus-visible + i { outline: 2px solid var(--cp-accent-2); outline-offset: 2px; }

.cp__menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 8px;
    border-radius: 8px;
    border: 0;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}

.cp__menu-link:hover { background: rgba(255, 255, 255, .05); }
.cp__menu-link .cp__ico { width: 18px; height: 18px; opacity: .7; }

.cp kbd {
    margin-left: auto;
    font: inherit;
    font-size: 12px;
    padding: 2px 7px;
    border-radius: 5px;
    background: rgba(255, 255, 255, .12);
}

/* Keyboard sheet */
.cp__keys {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, .7);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, visibility .2s;
    padding: 16px;
}

.cp.is-keys .cp__keys { opacity: 1; visibility: visible; }

.cp__keys-in {
    width: min(560px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 18px 22px 22px;
    border-radius: 18px;
    background: rgba(14, 16, 23, .96);
    border: 1px solid rgba(255, 255, 255, .12);
}

.cp__keys header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 16px;
}

.cp__keys dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 24px;
    margin: 0;
}

.cp__keys dl div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.cp__keys dt {
    font-weight: 700;
    font-size: 12.5px;
    padding: 2px 8px;
    border-radius: 5px;
    background: rgba(255, 255, 255, .1);
    white-space: nowrap;
}

.cp__keys dd { margin: 0; opacity: .75; font-size: 13.5px; text-align: right; }

@container (max-width: 560px) {
    .cp__keys dl { grid-template-columns: 1fr; }
}

/* Up-next / finished panels */
.cp__layer {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: none;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at center, rgba(0, 0, 0, .55), rgba(0, 0, 0, .85));
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.cp.is-panel .cp__layer { display: grid; animation: cp-fade .5s ease; }

@keyframes cp-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cp__next {
    width: min(460px, 100%);
    display: grid;
    gap: 14px;
    animation: cp-rise .6s cubic-bezier(.2, .7, .2, 1);
}

@keyframes cp-rise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
}

.cp__next-k {
    font-size: 12px;
    letter-spacing: .18em;
    text-transform: uppercase;
    opacity: .65;
    font-weight: 600;
}

.cp__next-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: center;
}

.cp__next-row img {
    width: 150px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .15);
}

.cp__next-row strong,
.cp__panel-t {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -.015em;
    line-height: 1.25;
}

.cp__next--panel { text-align: center; justify-items: center; }
.cp__next--panel p { margin: 0; opacity: .75; font-size: 15px; max-width: 40ch; }
.cp__panel-t { font-size: clamp(22px, 4cqw, 34px); }

.cp__next-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.cp__next--panel .cp__next-actions { justify-content: center; }

.cp__pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    padding: 0 20px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .1);
    color: #fff !important;
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, transform .2s;
}

.cp__pill:hover { background: rgba(255, 255, 255, .2); transform: translateY(-1px); }
.cp__pill .cp__ico { width: 18px; height: 18px; }

.cp__pill--primary {
    background: #fff;
    color: #000 !important;
    border-color: #fff;
}

.cp__pill--primary:hover { background: #e8eaf0; }

.cp__ring {
    width: 24px;
    height: 24px;
    transform: rotate(-90deg);
    flex: none;
}

.cp__ring circle {
    fill: none;
    stroke: rgba(0, 0, 0, .15);
    stroke-width: 4;
}

.cp__ring .cp__ring-on {
    stroke: #000;
    stroke-dasharray: 97.4;
    stroke-dashoffset: 97.4;
    animation: cp-ring linear forwards;
}

@keyframes cp-ring { to { stroke-dashoffset: 0; } }

/* Error */
.cp__err {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: none;
    place-content: center;
    justify-items: center;
    gap: 8px;
    text-align: center;
    padding: 20px;
    background: rgba(0, 0, 0, .75);
}

.cp__err strong { font-size: 18px; }
.cp__err span { opacity: .7; margin-bottom: 8px; }
.cp.is-error .cp__err { display: grid; }

@media (prefers-reduced-motion: reduce) {
    /* The up-next ring stays: it is a countdown, not decoration. */
    .cp *:not(.cp__ring-on),
    .cp *::before,
    .cp *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
