/* cards.css — YouTube-style responsive card grid, shared by every media list
   page (Sách nói / Video / Music video, and any future list). Container is
   .yt-grid; each item is a .yt-card. Cards are flat like YouTube: a rounded
   16:9 thumbnail with a corner badge, a 2-line title, a meta line, and a
   kebab. Each page keeps its OWN kebab menu + JS; only the card shell + the
   .yt-card__kebab trigger styling are shared. */

.yt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
  gap: 26px 16px;
  align-items: start;
}
@media (max-width: 560px) {
  .yt-grid { grid-template-columns: 1fr; gap: 18px; }
}

.yt-card { position: relative; min-width: 0; }

/* ---- Thumbnail (16:9) ---- */
.yt-card__thumb {
  position: relative; display: block; aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden; background: #0f172a;
  text-decoration: none;
}
.yt-card__thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .28s ease;
}
.yt-card:hover .yt-card__thumb img { transform: scale(1.035); }
.yt-card__thumb--ph {
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; color: #64748b;
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

/* Bottom-right badge (duration / page count) */
.yt-card__badge {
  position: absolute; right: 6px; bottom: 6px; z-index: 2;
  background: rgba(0, 0, 0, .82); color: #fff;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 3px 5px; border-radius: 4px; font-variant-numeric: tabular-nums;
}
/* Top-left state pill (only for non-ready items) */
.yt-card__state {
  position: absolute; left: 8px; top: 8px; z-index: 2;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: #fff; color: #1e293b; box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
}
.yt-card__state--busy    { background: #dbeafe; color: #1e40af; }
.yt-card__state--error   { background: #fee2e2; color: #991b1b; }
.yt-card__state--planned { background: #fef9c3; color: #854d0e; }
.yt-card__state--tr      { left: auto; right: 8px; }   /* top-right variant */

/* ---- Info row ---- */
.yt-card__info {
  display: flex; gap: 10px; padding: 11px 2px 0; align-items: flex-start;
}
.yt-card__text { flex: 1 1 auto; min-width: 0; }
.yt-card__title {
  margin: 0; font-weight: 600; font-size: .95rem; line-height: 1.32;
  color: var(--text, #0f172a); text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
a.yt-card__title:hover { color: var(--accent, #2563eb); }
.yt-card__meta {
  margin-top: 5px; color: var(--text-soft, #64748b); font-size: .8rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px 7px;
  line-height: 1.45;
}
.yt-card__meta .dot { opacity: .45; }
.yt-card__cost {
  background: #f1f5f9; color: #475569; border-radius: 6px;
  padding: 0 6px; font-size: .74rem; font-weight: 600;
}

/* ---- Kebab trigger (menu markup + JS stay per-page) ----
   YouTube style: borderless, no fill, dark dots, a round hover target. The
   compound selector wins over per-page button rules (e.g. .bk-kebab__btn). */
.yt-card .yt-card__kebab {
  flex: 0 0 auto; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: none; color: var(--text, #0f172a);
  font-size: 1.45rem; line-height: 1; cursor: pointer; padding: 0;
  margin: -5px -6px 0 0;            /* sit level with the title's first line */
  transition: background .12s;
}
.yt-card .yt-card__kebab:hover { background: rgba(0, 0, 0, .08); }

/* Bulk-select checkbox overlay (video / music pages). Hidden by default —
   YouTube doesn't show one; it only appears when the user turns on delete mode
   (.yt-grid--select on the grid). Sits on the thumb top-left. */
.yt-card__check {
  display: none;
  position: absolute; left: 8px; top: 8px; z-index: 3;
  width: 22px; height: 22px; cursor: pointer; accent-color: var(--accent, #2563eb);
}
.yt-grid--select .yt-card__check { display: block; }

/* Section heading + grid spacing helper for list pages */
.yt-section-title {
  margin: 6px 0 14px; font-size: 1rem; font-weight: 700;
  color: var(--text, #1e293b);
}

/* ---- Bulk select + delete bar (shared by Video / Music video / Sách nói) ----
   The toggle is a borderless blue link in the page head; turning it on adds
   .yt-grid--select to the grid (reveals .yt-card__check) and shows .yt-bulkbar
   with a select-all checkbox + a red delete button carrying a live count. */
.yt-selecttoggle {
  background: none; border: 0; color: var(--accent, #2563eb); cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; padding: 9px 4px;
}
.yt-bulkbar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 10px; padding: 8px 12px;
  border: 1px solid rgba(99, 102, 241, .25); border-radius: 10px;
  background: rgba(238, 240, 255, .75);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.yt-bulkbar[hidden] { display: none; }
.yt-bulkbar__all {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #374151; cursor: pointer;
}
.yt-bulkbar__all input { accent-color: #4f46e5; }
.yt-bulk-del {
  background: #ef4444; color: #fff; border: none; border-radius: 8px;
  padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 120ms;
}
.yt-bulk-del:hover:not(:disabled) { background: #dc2626; }
.yt-bulk-del:disabled { opacity: .5; cursor: not-allowed; }

/* ---- YouTube-style playback lightbox (shared by Video / Music video) ----
   Click a finished card -> a dark overlay opens with a large player centred
   on black, then a title + meta line + action buttons below (like a YouTube
   watch lightbox). Handles both landscape (16:9) and portrait (9:16 / 4:5)
   sources: the <video> is bounded by max-width/height so it never overflows,
   leaving theatre-style black bars on the short axis. Each page injects the
   markup with its own ids + open/close JS; only these styles are shared. */
.ytlb {
  position: fixed; inset: 0; z-index: 9100; display: none;
  background: rgba(0, 0, 0, .9);
  align-items: center; justify-content: center; padding: 24px;
}
.ytlb[data-open="true"] { display: flex; }
.ytlb__dialog {
  width: min(960px, 100%); max-height: 100%;
  display: flex; flex-direction: column;
  background: #0f0f0f; border-radius: 14px; overflow: hidden;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .6); position: relative;
}
.ytlb__media {
  background: #000; display: flex; align-items: center; justify-content: center;
  min-height: 0;
}
.ytlb__media video {
  display: block; max-width: 100%; max-height: 78vh;
  width: auto; height: auto;
}
.ytlb__close {
  position: absolute; top: 8px; right: 10px; z-index: 2;
  border: 0; background: rgba(0, 0, 0, .45); color: #fff;
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 26px; line-height: 1; cursor: pointer; opacity: .9;
}
.ytlb__close:hover { opacity: 1; background: rgba(0, 0, 0, .7); }
.ytlb__info { padding: 14px 18px 18px; color: #f1f1f1; }
.ytlb__title {
  margin: 0; font-size: 1.05rem; font-weight: 600; line-height: 1.35;
  word-break: break-word;
}
.ytlb__meta {
  margin-top: 5px; font-size: .82rem; color: #aaa;
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px;
}
.ytlb__actions {
  margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px;
}
.ytlb__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px; border: 0;
  background: rgba(255, 255, 255, .12); color: #fff;
  font: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .12s;
}
.ytlb__btn:hover { background: rgba(255, 255, 255, .22); }
.ytlb__btn--accent { background: #2563eb; }
.ytlb__btn--accent:hover { background: #1d4ed8; }

@media (max-width: 640px) {
  .ytlb { padding: 0; }
  .ytlb__dialog {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    border-radius: 0;
  }
  .ytlb__media { flex: 1 1 auto; }
  .ytlb__media video { max-height: 100%; }
  .ytlb__info { padding: 12px 14px 16px; }
}
