/* Lesson cards and a site-native, accessible player surround. */
@property --btv-charge-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

html body.bt-home .video-card {
    isolation: isolate;
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    background: linear-gradient(145deg, #152440, #0b1324 64%);
    border: 1px solid rgba(122, 161, 239, .22);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .22);
}
html body.bt-home .video-card::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
    padding: 1.5px;
    border-radius: inherit;
    background: conic-gradient(from var(--btv-charge-angle), transparent 0deg 230deg, #1878ff 265deg, #b6efff 285deg, #fff 289deg, #4697ff 298deg, transparent 320deg);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    animation: btv-charge 4s linear infinite;
}
html body.bt-home .video-card:nth-child(3n+2)::after { animation-delay: -1.3s; }
html body.bt-home .video-card:nth-child(3n+3)::after { animation-delay: -2.6s; }
html body.bt-home .video-card .video-thumb { height: auto; aspect-ratio: 16 / 9; border-radius: 21px 21px 0 0; }
html body.bt-home .video-card .video-thumb img { height: 100%; }
html body.bt-home .video-card .play-btn {
    opacity: 1;
    width: 58px;
    height: 42px;
    border-radius: 13px;
    background: rgba(14, 24, 44, .86);
    border: 1px solid rgba(199, 226, 255, .65);
    box-shadow: 0 6px 24px rgba(4, 12, 24, .5), 0 0 24px rgba(40, 128, 255, .15);
    color: #fff;
    z-index: 3;
    transform: translate(-50%, -50%);
}
html body.bt-home .video-card:hover .play-btn,
html body.bt-home .video-card:focus-visible .play-btn { background: #1674ee; transform: translate(-50%, -50%) scale(1.1); }
html body.bt-home .video-card:focus-visible { outline: 3px solid #98c9ff; outline-offset: 5px; }
@keyframes btv-charge { to { --btv-charge-angle: 360deg; } }

.btv-dialog {
    --btv-ink: #eef4ff;
    --btv-dim: #a7b9d1;
    color-scheme: dark;
    box-sizing: border-box;
    color: var(--btv-ink);
    width: min(1000px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    border: 1px solid rgba(132, 183, 255, .4);
    border-radius: 24px;
    background: #0b1425;
    box-shadow: 0 28px 100px #0009, 0 0 55px #237afa20;
    font-family: inherit;
    overflow: auto;
}
.btv-dialog[open] { animation: btv-appear .28s ease-out both; }
.btv-dialog::backdrop { background: rgba(2, 7, 16, .84); backdrop-filter: blur(10px); }
.btv-dialog *, .btv-dialog *::before, .btv-dialog *::after { box-sizing: border-box; }
.btv-dialog [hidden] { display: none !important; }
.btv-shell { background: radial-gradient(ellipse at 100% 0, #17335a 0, transparent 45%), #0b1425; }
.btv-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 25px 18px; }
.btv-eyebrow { margin: 0 0 7px; color: #90bfff; font-size: 10px; font-weight: 700; letter-spacing: 2.2px; }
.btv-header h2 { margin: 0; color: var(--btv-ink); font-size: clamp(17px, 2vw, 23px); line-height: 1.45; overflow-wrap: anywhere; }
.btv-dialog button, .btv-dialog select { font: inherit; }
.btv-dialog button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    min-height: 42px;
    padding: 8px 12px;
    color: var(--btv-ink);
    border: 1px solid #99c5ff36;
    border-radius: 10px;
    background: #192a44;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}
.btv-dialog button:hover { background: #24436d; border-color: #8cbdff99; }
.btv-dialog button:focus-visible, .btv-dialog input:focus-visible, .btv-dialog select:focus-visible { outline: 2px solid #a3d3ff; outline-offset: 4px; }
.btv-dialog button.btv-close { padding: 0; min-width: 42px; width: 42px; height: 42px; font-size: 29px; font-weight: 400; flex-shrink: 0; line-height: 1; }
.btv-loading { display: flex; align-items: center; justify-content: center; gap: 18px; min-height: 106px; padding: 10px 22px 20px; color: #b7cdf0; font-size: 14px; }
.btv-logo-wrap { position: relative; display: grid; place-items: center; width: 84px; height: 64px; padding: 11px; border-radius: 15px; background: #10203a; font-size: 29px; font-weight: 800; }
.btv-logo-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }
.btv-logo-wrap::after { content: ''; position: absolute; inset: -4px; border: 1.5px solid #418dff30; border-top-color: #8fd2ff; border-bottom-color: #267dff; border-radius: 20px; animation: btv-logo-glow 1.1s ease-in-out infinite alternate; }
.btv-loading-dots { display: inline-block; animation: btv-logo-glow .8s ease-in-out infinite alternate; }
.btv-stage { width: 100%; aspect-ratio: 16 / 9; min-height: 200px; background: #000; }
.btv-stage iframe, .btv-mount { display: block; width: 100%; height: 100%; min-height: 200px; border: 0; }
.btv-controls { min-width: 0; border: 0; padding: 15px 22px 10px; margin: 0; }
.btv-controls:disabled { opacity: .45; }
.btv-controls:disabled button { cursor: wait; }
.btv-timeline { display: flex; align-items: center; gap: 16px; }
.btv-time { min-width: 100px; color: #c2d3ea; font-size: 12px; font-variant-numeric: tabular-nums; }
.btv-dialog input[type=range] { min-width: 0; margin: 0; height: 30px; accent-color: #65aaff; cursor: pointer; }
.btv-seek { flex: 1; width: 100%; }
.btv-control-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.btv-transport, .btv-volume-group { display: flex; align-items: center; gap: 7px; }
.btv-dialog button.btv-play { min-width: 65px; background: #226dc6; border-color: #62a9ff; }
.btv-volume-group { margin-left: auto; }
.btv-volume { width: 88px; }
.btv-speed-label { display: inline-flex; gap: 6px; align-items: center; color: var(--btv-dim); font-size: 11px; }
.btv-speed { min-height: 42px; max-width: 80px; padding: 6px; border: 1px solid #99c5ff36; border-radius: 10px; color: var(--btv-ink); background: #192a44; font-size: 12px; }
.btv-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 7px 20px; padding: 10px 24px 20px; color: var(--btv-dim); font-size: 11px; line-height: 1.6; }
.btv-status { color: #9dc8ff; }
.btv-error { padding: 40px 25px; text-align: center; background: #0c172a; }
.btv-error strong { display: block; color: #d3e7ff; font-size: 20px; }
.btv-error p { margin: 12px auto 22px; max-width: 470px; color: var(--btv-dim); font-size: 14px; line-height: 1.7; }
.btv-shell:fullscreen { display: flex; flex-direction: column; width: 100vw; height: 100dvh; overflow: auto; background: #050a13; }
.btv-shell:fullscreen .btv-header { padding-top: 12px; padding-bottom: 12px; }
.btv-shell:fullscreen .btv-stage { flex: 1; aspect-ratio: auto; min-height: 200px; }
@keyframes btv-appear { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes btv-logo-glow { from { opacity: .45; box-shadow: 0 0 2px #2d8aff; } to { opacity: 1; box-shadow: 0 0 24px #2d8aff88; } }
@media (max-width: 600px) {
    .btv-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 17px; }
    .btv-header { padding: 17px 14px 14px; gap: 10px; }
    .btv-eyebrow { font-size: 9px; letter-spacing: 1.7px; }
    .btv-controls { padding: 11px 12px 8px; }
    .btv-control-row { gap: 10px; justify-content: space-between; }
    .btv-transport { gap: 5px; }
    .btv-dialog button { padding: 8px 9px; }
    .btv-dialog button.btv-play { min-width: 59px; }
    .btv-volume-group { margin-left: 0; }
    .btv-volume { width: 72px; }
    .btv-speed-label { margin-left: 0; }
    .btv-footer { padding: 10px 14px 16px; font-size: 10px; }
    .btv-timeline { gap: 10px; }
    .btv-time { min-width: 85px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
    html body.bt-home .video-card::after, .btv-dialog[open], .btv-logo-wrap::after, .btv-loading-dots { animation: none !important; }
    .btv-dialog button { transition: none; }
}

/* Captions toggle. YouTube's gear menu is gone with controls:0, so the CC
   control lives on our own bar and has to read as on/off by itself. */
.btv-dialog button.btv-cc { min-width: 48px; font-variant: small-caps; letter-spacing: .5px; }
.btv-dialog button.btv-cc.btv-cc-on { background: #226dc6; border-color: #62a9ff; color: #fff; }
.btv-dialog button.btv-cc[hidden] { display: none; }

/* Transparent click layer over the player. It has to sit above the iframe, so
   .btv-stage needs a positioning context. Left click plays/pauses, double
   click goes full screen, right click does nothing — the same gestures the
   player already supports, just handled by our code instead of YouTube's. */
.btv-stage { position: relative; }
.btv-shield { position: absolute; inset: 0; z-index: 2; cursor: pointer; background: transparent; -webkit-tap-highlight-color: transparent; }
.btv-shield[hidden] { display: none; }

/* Pause screen. Transparent while the lesson runs; opaque the moment YouTube
   would paint its own overlay, so the lesson window never shows a channel
   name, a "More videos" strip or a "Watch on YouTube" button. */
.btv-shield { display: grid; place-content: center; justify-items: center; gap: 16px;
  background: transparent; transition: background .2s ease; }
.btv-shield > * { opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.btv-shield.is-covered { background: #040b18; }
.btv-shield.is-covered > * { opacity: 1; }
.btv-shield-badge {
  display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%;
  background: linear-gradient(115deg, #0f6fd8, #7a45cf);
  border: 1px solid #8a6cff5c; box-shadow: 0 10px 34px #0009, 0 0 26px #2b7de84d;
  color: #fff; font-size: 27px; line-height: 1; padding-left: 4px;
}
.btv-shield-label { color: #cfe4ff; font-size: 13.5px; letter-spacing: .3px; text-align: center; padding: 0 18px; }
@media (max-width: 600px) {
  .btv-shield-badge { width: 60px; height: 60px; font-size: 22px; }
  .btv-shield-label { font-size: 12.5px; }
}
