/* ============================================================
   BrettZone v2 — commentary captions + transcript (fight page)
   Loaded only when the fight has a ready transcript.
   Behavior: assets/js/bz-fight-captions.js
   ============================================================ */

/* ---- Captions: native cues on the main video --------------------------------
   Rendered by the browser inline and in every fullscreen (the page fullscreens
   the <video> itself; iOS uses its native player, which applies the viewer's
   own caption style). Size stays the platform default, which scales with the
   player and honors the viewer's caption settings. */
#bz-fight-video::cue {
  color: #f0eff6;
  background-color: rgba(11, 10, 22, 0.82);
  font-family: "DIN Next LT Pro", "Inter", system-ui, -apple-system, sans-serif;
  font-weight: 500;
  line-height: 1.3;
  text-shadow: none;
}
/* On a small inline player the platform default (5% of the video height) is
   under 11 px; keep a readable floor there. Fullscreen and large players stay
   on the default. */
@media (max-width: 767.98px) {
  #bz-fight-video:not(:fullscreen)::cue { font-size: max(14px, 1em); }
}

/* ---- CC button in the transport bar -------------------------------------------- */
.bz-fight__transport-btn.bz-fight__cc {
  position: relative;
  min-width: 36px;
  min-height: 28px;
  font-weight: 700;
  color: var(--bz-text-dim);
  flex-shrink: 0;
}
.bz-fight__transport-btn.bz-fight__cc:hover { color: var(--bz-text); }
.bz-fight__transport-btn.bz-fight__cc.is-on {
  background: var(--bz-accent);
  border-color: var(--bz-accent);
  color: var(--bz-bg);
}
.bz-fight__transport-btn.bz-fight__cc.is-on:hover {
  background: var(--bz-accent-strong);
  border-color: var(--bz-accent-strong);
}
.bz-fight__transport-btn.bz-fight__cc:disabled {
  opacity: 0.4;
  cursor: default;
}
/* This angle cannot be lined up with the transcript (older fights): CC stays
   focusable so its tooltip explains which angle carries the captions. */
.bz-fight__transport-btn.bz-fight__cc.is-unavailable {
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* ---- "Play from here" for ?t= deep links ------------------------------------------ */
.bz-tx-cue {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 20px 12px 16px;
  border: 0;
  background: var(--bz-accent);
  color: var(--bz-bg);
  font: 800 13px/1 var(--bz-font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
  transition: background var(--bz-d-fast) var(--bz-ease);
}
.bz-tx-cue[hidden] { display: none; }
.bz-tx-cue:hover { background: var(--bz-accent-strong); }
.bz-tx-cue:focus-visible { box-shadow: inset 0 0 0 2px var(--bz-bg), inset 0 0 0 4px var(--bz-focus); }
.bz-tx-cue .bz-icon { width: 16px; height: 16px; }
.bz-tx-cue .bz-mono { font-weight: 700; font-size: 14px; letter-spacing: 0.02em; }

/* ---- Commentary panel ------------------------------------------------------------------ */
.bz-tx {
  margin-top: 8px;
  padding: 12px 14px 10px;
  background: var(--bz-surface-1);
  border: 1px solid var(--bz-border);
  border-radius: var(--bz-r-sm);
}
.bz-tx__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.bz-tx__head .bz-eyebrow { margin: 0; font-size: 11px; }
.bz-tx__meta { color: var(--bz-text-faint); font-size: 10px; letter-spacing: 0.06em; white-space: nowrap; }

.bz-tx__tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 8px;
}
.bz-tx__search { flex: 1 1 auto; max-width: 440px; position: relative; }
.bz-tx__search .bz-icon { color: var(--bz-text-muted); flex-shrink: 0; }
.bz-tx__search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.bz-tx__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: -4px -6px -4px 0;
  padding: 0;
  border: 0;
  border-radius: var(--bz-r-xs);
  background: transparent;
  color: var(--bz-text-muted);
  cursor: pointer;
}
.bz-tx__clear[hidden] { display: none; }
.bz-tx__clear:hover { color: var(--bz-text); background: var(--bz-surface-2); }
.bz-tx__count {
  color: var(--bz-text-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.bz-tx__body { position: relative; }
.bz-tx__list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  /* Fixed from the server-known line count, so nothing shifts when lines arrive. */
  height: min(360px, calc(var(--bz-tx-rows, 9) * 34px + 8px));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bz-border-strong) transparent;
  border-top: 1px solid var(--bz-border);
  border-bottom: 1px solid var(--bz-border);
}
@media (hover: hover) and (pointer: fine) {
  .bz-tx__list { overscroll-behavior: contain; }
}

.bz-tx__row { display: flex; align-items: stretch; gap: 2px; }
.bz-tx__row[hidden] { display: none; }
.bz-tx__line {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  margin: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--bz-r-xs);
  background: transparent;
  color: var(--bz-text-dim);
  font: 400 14px/1.45 var(--bz-font-ui);
  text-align: left;
  cursor: pointer;
  transition: background var(--bz-d-fast) var(--bz-ease), color var(--bz-d-fast) var(--bz-ease);
}
.bz-tx__line:hover { background: var(--bz-surface-2); color: var(--bz-text); }
.bz-tx__line:focus-visible,
.bz-tx__copy:focus-visible,
.bz-tx__resume:focus-visible,
.bz-tx__clear:focus-visible { box-shadow: inset 0 0 0 2px var(--bz-focus); }
.bz-tx__time {
  color: var(--bz-accent-strong);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.bz-tx__row.is-pre .bz-tx__time,
.bz-tx__row.is-post .bz-tx__time { color: var(--bz-text-muted); }
.bz-tx__text { overflow-wrap: anywhere; }
.bz-tx__text mark {
  background: rgba(207, 35, 202, 0.32);
  color: var(--bz-text);
  border-radius: 1px;
  box-shadow: inset 0 -1px 0 var(--bz-accent-strong);
}
.bz-tx__row.is-current .bz-tx__line {
  background: var(--bz-accent-bg);
  color: var(--bz-text);
  box-shadow: inset 3px 0 0 var(--bz-accent);
}
.bz-tx__row.is-current .bz-tx__line:focus-visible { box-shadow: inset 3px 0 0 var(--bz-accent), inset 0 0 0 2px var(--bz-focus); }
.bz-tx__row.is-cued .bz-tx__line {
  color: var(--bz-text);
  background: var(--bz-accent-bg);
  box-shadow: inset 3px 0 0 var(--bz-accent), inset 0 0 0 1px var(--bz-accent-dim);
}

.bz-tx__copy {
  flex: 0 0 auto;
  width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--bz-r-xs);
  background: transparent;
  color: var(--bz-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--bz-d-fast) var(--bz-ease), color var(--bz-d-fast) var(--bz-ease);
}
.bz-tx__row:hover .bz-tx__copy,
.bz-tx__row:focus-within .bz-tx__copy,
.bz-tx__row.is-current .bz-tx__copy,
.bz-tx__copy.is-copied { opacity: 1; }
.bz-tx__copy:hover { color: var(--bz-text); background: var(--bz-surface-2); }
.bz-tx__copy.is-copied { color: var(--bz-accent-strong); }
@media (hover: none) {
  .bz-tx__copy { opacity: 1; color: var(--bz-text-faint); }
}

.bz-tx__mark {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 6px;
  color: var(--bz-text-muted);
  font: 700 10px/1 var(--bz-font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.bz-tx__mark[hidden] { display: none; }
.bz-tx__mark::before,
.bz-tx__mark::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--bz-border);
}
.bz-tx__mark--pre::before { flex: 0 0 12px; }
/* fight.php orders every untagged descendant of .bz-fight on phones; the
   divider's label must stay between its two rules. */
.bz-fight .bz-tx__mark > span { order: 0; }
.bz-tx__mark--start,
.bz-tx__mark--end { color: var(--bz-text-dim); }
.bz-tx__mark--start::before,
.bz-tx__mark--start::after,
.bz-tx__mark--end::before,
.bz-tx__mark--end::after { background: var(--bz-border-strong); }

/* Skeleton while the lines load: static, no shimmer. */
.bz-tx__skel {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 8px;
}
.bz-tx__skel i {
  display: block;
  height: 10px;
  border-radius: var(--bz-r-xs);
  background: var(--bz-surface-2);
}
.bz-tx__skel i + i { width: 78%; }
.bz-tx__skel:nth-child(3n) i + i { width: 56%; }
.bz-tx__skel:nth-child(3n + 1) i + i { width: 90%; }

.bz-tx__state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 16px;
  color: var(--bz-text-muted);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}
.bz-tx__state[hidden] { display: none; }
.bz-tx__state button { pointer-events: auto; }

.bz-tx__resume {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid var(--bz-border-strong);
  border-radius: var(--bz-r-sm);
  background: var(--bz-surface-3);
  color: var(--bz-text);
  font: 700 11px/1 var(--bz-font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(11, 10, 22, 0.6);
  cursor: pointer;
}
.bz-tx__resume[hidden] { display: none; }
.bz-tx__resume:hover { border-color: var(--bz-accent); }

.bz-tx__note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  color: var(--bz-text-muted);
  font-size: 11px;
  line-height: 1.4;
}
.bz-tx__note .bz-icon { flex-shrink: 0; width: 12px; height: 12px; }

.bz-tx .bz-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- Phones and tablets: a tab in the fight detail tabs ---------------------------------- */
@media (max-width: 1099.98px) {
  .bz-fight__mtabs.bz-fight__mtabs--commentary { display: flex; }
  .bz-fight__mtabs.bz-fight__mtabs--commentary .bz-fight__mtab {
    flex: 1 1 auto;
    padding-left: 6px;
    padding-right: 6px;
    white-space: nowrap;
  }
  .bz-tx { margin-top: 0; }
  .bz-tx__list { height: min(58vh, calc(var(--bz-tx-rows, 9) * 46px + 8px)); }
  @supports (height: 1dvh) {
    .bz-tx__list { height: min(58dvh, calc(var(--bz-tx-rows, 9) * 46px + 8px)); }
  }
}

@media (max-width: 767.98px) {
  .bz-fight__mtabs.bz-fight__mtabs--commentary .bz-fight__mtab { letter-spacing: 0.04em; padding-left: 4px; padding-right: 4px; }
  /* 44 px touch target without growing the transport row. */
  .bz-fight__transport-btn.bz-fight__cc::after {
    content: "";
    position: absolute;
    inset: -8px -4px;
  }
  .bz-tx { padding: 12px 12px 10px; }
  .bz-tx__tools { flex-wrap: wrap; gap: 8px; }
  .bz-tx__search { max-width: none; min-height: var(--bz-touch-min); }
  .bz-tx__search input { font-size: 16px; } /* avoid iOS zoom on focus */
  .bz-tx__clear { width: 36px; height: 36px; margin: -6px -8px -6px 0; }
  .bz-tx__line {
    min-height: var(--bz-touch-min);
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    padding: 10px 6px;
    font-size: 15px;
    line-height: 1.4;
  }
  .bz-tx__copy { width: var(--bz-touch-min); min-height: var(--bz-touch-min); }
  .bz-tx__resume { min-height: var(--bz-touch-min); padding: 10px 14px; }
  .bz-tx__mark { padding-top: 12px; }
  .bz-tx-cue { min-height: var(--bz-touch-min); padding: 12px 16px 12px 14px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .bz-tx__line,
  .bz-tx__copy,
  .bz-tx-cue { transition: none; }
}
