/*
 * Design system do tema youplay: componentes de catálogo (E4-01/02).
 *
 * Card de vídeo, selo, chip, faixa horizontal (rail), hero, estado
 * (vazio/erro) e estados de botão (loading). Só tokens; a única cor literal
 * permitida (#fff sobre mídia) vem de --on-media.
 *
 * Carregado depois de cards.css (container.html).
 */

/* ---------- Foco visível (teclado) ---------- */

.ds-catalog a:focus-visible,
.ds-catalog button:focus-visible,
.ds-catalog [tabindex="0"]:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}

/* ---------- Botão: estados loading / disabled ---------- */

.btn.is-loading,
.btn[aria-busy="true"] {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after,
.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-foreground);
  border-inline-end-color: transparent;
  border-radius: var(--radius-full);
  animation: ds-spin .7s linear infinite;
}

.btn-secondary.is-loading::after,
.btn-ghost.is-loading::after {
  border-color: var(--foreground);
  border-inline-end-color: transparent;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

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

/* ---------- Selo ---------- */

.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: var(--leading-normal);
  letter-spacing: .01em;
}

.ds-badge-free {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  background: var(--success);
  color: var(--success-foreground);
}

.ds-badge-onmedia {
  background: var(--on-media-subtle);
  color: var(--on-media);
  backdrop-filter: blur(6px);
}

/* ---------- Chips de categoria ---------- */

.ds-chip-row {
  display: flex;
  gap: var(--space-2);
  padding-block: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.ds-chip-row::-webkit-scrollbar { display: none; }

.ds-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  padding-inline: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--background);
  color: var(--foreground);
  font-size: var(--text-base);
  font-weight: 500;
  white-space: nowrap;
  box-shadow: none;
  text-decoration: none;
  scroll-snap-align: start;
  transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

@media (min-width: 768px) {
  .ds-chip { min-height: 36px; }
}

.ds-chip-row .ds-chip:hover,
.ds-chip-row .ds-chip:focus { background: var(--accent); color: var(--accent-foreground); text-decoration: none; }

.ds-chip-row .ds-chip.is-active,
.ds-chip-row .ds-chip[aria-current="page"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

/* o modo escuro legado pinta links; reafirma as cores do chip */
html.dark .ds-chip-row .ds-chip { color: var(--foreground) !important; }
html.dark .ds-chip-row .ds-chip:hover,
html.dark .ds-chip-row .ds-chip:focus { color: var(--accent-foreground) !important; }
html.dark .ds-chip-row .ds-chip.is-active,
html.dark .ds-chip-row .ds-chip[aria-current="page"] { color: var(--primary-foreground) !important; }

/* ---------- Card de vídeo ---------- */

.ds-vcard { position: relative; min-width: 0; }   /* contém o .ds-sr-only (absoluto) */

.ds-vcard-link {
  display: block;
  color: var(--foreground);
  text-decoration: none;
}

.ds-vcard-link:hover,
.ds-vcard-link:focus { color: var(--foreground); text-decoration: none; }

.ds-vcard-cover {
  position: relative;
  display: block;
  aspect-ratio: var(--aspect-cover);   /* proporção reservada: sem salto de layout */
  overflow: hidden;
  border-radius: var(--radius-xl);
  box-shadow: 0 0 0 1px var(--border);
  transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
  background: linear-gradient(90deg, var(--placeholder) 25%, color-mix(in oklch, var(--placeholder) 60%, var(--background)) 50%, var(--placeholder) 75%);
  background-size: 200% 100%;
  animation: ds-shimmer 1.4s ease-in-out infinite;
}

.ds-vcard-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease);
}

.ds-vcard-link:hover .ds-vcard-cover img { transform: scale(1.03); }
.ds-vcard-link:hover .ds-vcard-cover { box-shadow: var(--shadow-md), 0 0 0 1px var(--border); }

.ds-vcard-cover.is-broken,
.ds-hero-media.is-broken { animation: none; background: var(--placeholder); }
.ds-vcard-cover.is-broken img,
.ds-hero-media.is-broken img { visibility: hidden; }

.ds-vcard-duration {
  position: absolute;
  inset-block-end: var(--space-2);
  inset-inline-end: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--media-overlay);
  color: var(--on-media);
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.ds-vcard-lock {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-end: var(--space-2);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--media-overlay);
  color: var(--on-media);
}

.ds-vcard-lock .ds-icon { width: 14px; height: 14px; }

.ds-vcard-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-block-start: var(--space-3);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: var(--leading-tight);
  min-height: calc(2 * 1.3em);   /* 2 linhas reservadas: alturas iguais na faixa */
}

.ds-vcard-meta span { display: inline; }
.ds-vcard-meta span + span::before { content: "·"; margin-inline: var(--space-2); }

.ds-vcard-meta {
  display: block;
  margin-block-start: var(--space-1);
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

/* ---------- Faixa horizontal (rail) ---------- */

.ds-rail { min-width: 0; margin-block-end: var(--space-8); }

.ds-rail-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-block-end: var(--space-3);
}

.ds-rail-heading { flex: 1; min-width: 0; }

.ds-rail-title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.ds-rail-desc {
  margin: var(--space-1) 0 0;
  color: var(--muted-foreground);
  font-size: var(--text-base);
}

.ds-rail-nav { display: none; gap: var(--space-2); }

@media (hover: hover) and (pointer: fine) {
  .ds-rail.has-overflow .ds-rail-nav { display: flex; }
}

.ds-rail-nav .btn:disabled { opacity: .35; }

.ds-rail-track {
  display: flex;
  gap: var(--rail-gap);
  margin-inline: calc(-1 * var(--page-gutter));
  padding-inline: var(--page-gutter);
  scroll-padding-inline: var(--page-gutter);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.ds-rail-track::-webkit-scrollbar { display: none; }

.ds-rail-track > .ds-vcard {
  flex: 0 0 calc((100% - 2 * var(--page-gutter) - (var(--rail-cols) - 1) * var(--rail-gap)) / var(--rail-cols));
  scroll-snap-align: start;
}

/* ---------- Hero ---------- */

.ds-hero {
  position: relative;
  margin-block-end: var(--space-8);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--placeholder);
  color: var(--on-media);
}

.ds-hero-media {
  display: block;
  aspect-ratio: 16 / 10;       /* reservado: o hero não "pula" quando a capa chega */
  background: var(--placeholder);
}

.ds-hero-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ds-hero-body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4);
  z-index: var(--z-base);
}

.ds-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--scrim-strong) 8%, var(--scrim-soft) 85%);
  pointer-events: none;
}

.ds-hero-eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--on-media-muted);
  font-size: var(--text-sm);
}

.ds-hero-title {
  margin: 0;
  max-width: 22ch;
  color: var(--on-media);
  font-size: var(--text-hero);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  text-wrap: balance;
}

.ds-hero-desc {
  display: none;
  margin: 0;
  max-width: 56ch;
  color: var(--on-media-muted);
  font-size: var(--text-lg);
  line-height: var(--leading-normal);
}

.ds-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-block-start: var(--space-2);
}

/* botão primário sobre mídia: invertido (claro), sempre legível */
.ds-hero .ds-hero-cta {
  background-color: var(--on-media) !important;
  color: var(--on-media-inverse) !important;
  min-height: var(--target-min);
}

.ds-hero .ds-hero-cta:hover,
.ds-hero .ds-hero-cta:focus { background-color: var(--on-media-muted) !important; }

.ds-hero a:focus-visible { outline-color: var(--on-media); }

.ds-hero-note {
  display: inline-flex;
  align-items: center;
  color: var(--on-media-muted);
  font-size: var(--text-sm);
}

/* mobile: capa + texto abaixo (título longo não disputa com a imagem) */
@media (max-width: 767px) {
  .ds-hero { background: transparent; border-radius: 0; margin-inline: calc(-1 * var(--page-gutter)); }
  .ds-hero-media { aspect-ratio: 16 / 9; }
  .ds-hero::after { display: none; }
  .ds-hero-body { position: static; background: none; padding: var(--space-4) var(--page-gutter) 0; color: var(--foreground); }
  .ds-hero-title { color: var(--foreground); max-width: none; }
  .ds-hero-eyebrow, .ds-hero-note { color: var(--muted-foreground); }
  .ds-hero .ds-badge-onmedia { background: var(--secondary); color: var(--secondary-foreground); backdrop-filter: none; }
  .ds-hero .ds-hero-cta { background-color: var(--primary) !important; color: var(--primary-foreground) !important; width: 100%; justify-content: center; }
  .ds-hero a:focus-visible { outline-color: var(--ring); }
  .ds-hero-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted-foreground); font-size: var(--text-base); }
}

@media (min-width: 768px) {
  .ds-hero-media { aspect-ratio: 21 / 9; }
  .ds-hero-body { padding: var(--space-8); max-width: 720px; }
  .ds-hero-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
}

/* ---------- Estado vazio / erro ---------- */

.ds-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  max-width: 420px;
  margin: var(--space-16) auto;
  padding-inline: var(--space-4);
  text-align: center;
}

.ds-state-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--muted);
  color: var(--muted-foreground);
}

.ds-state-icon .ds-icon { width: 24px; height: 24px; }
.ds-state-title { margin: 0; font-size: var(--text-2xl); font-weight: 600; }
.ds-state-text { margin: 0; color: var(--muted-foreground); font-size: var(--text-lg); }

/* ---------- Skeleton (blocos prontos) ---------- */

.ds-skeleton-line { height: 1em; border-radius: var(--radius-sm); }
.ds-skeleton-cover { aspect-ratio: var(--aspect-cover); border-radius: var(--radius-lg); }

/* ---------- Página: catálogo ---------- */

.ds-catalog {
  width: 100%;
  min-width: 0;
  overflow-x: clip;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--space-2) var(--page-gutter) var(--space-12);
}

@media (prefers-reduced-motion: reduce) {
  .ds-vcard-cover { animation: none; }
  .ds-vcard-link:hover .ds-vcard-cover img { transform: none; }
}

/* Abas de duas opções na mesma tela (ex.: Enviar arquivo / Importar de link) */
.ds-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 420px;
  margin: 0 0 var(--space-5);
  border-block-end: 1px solid var(--border);
}

.ds-tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target-min);
  margin-block-end: -1px;
  border-block-end: 2px solid transparent;
  color: var(--muted-foreground);
  font-size: var(--text-md);
  font-weight: 500;
  text-decoration: none;
}

.ds-tabs a:hover {
  color: var(--foreground);
}

.ds-tabs a[aria-current="page"] {
  border-block-end-color: var(--brand-text);
  color: var(--foreground);
}

/* Adicionar vídeo: zona de envio, progresso e formulário enxuto */
.ds-add { max-width: 640px; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-10); }
.ds-add-title { margin: 0 0 var(--space-1); font-size: var(--text-3xl); font-weight: 600; }
.ds-add-sub { margin: 0 0 var(--space-5); color: var(--muted-foreground); font-size: var(--text-md); }

.ds-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  background: var(--muted);
  transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.ds-drop.is-over { border-color: var(--brand); background: var(--brand-subtle); }

.ds-drop-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-4);
  color: var(--muted-foreground);
  text-align: center;
}

.ds-drop-body strong { color: var(--foreground); font-size: var(--text-lg); }

.ds-progress { padding: var(--space-8) var(--space-5); }
.ds-progress-bar { height: 8px; border-radius: var(--radius-full); background: var(--border); overflow: hidden; }
.ds-progress-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width var(--duration) var(--ease); }
.ds-progress p { margin: var(--space-3) 0 0; color: var(--muted-foreground); text-align: center; }

.ds-add-form[hidden], .ds-drop[hidden], .ds-drop-body[hidden], .ds-progress[hidden] { display: none; }
.ds-add-done { margin: 0 0 var(--space-5); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--brand-subtle); color: var(--foreground); }
.ds-add-submit { margin-top: var(--space-2); }
.ds-opt { color: var(--muted-foreground); font-weight: 400; }

.ds-add-row { display: flex; gap: var(--space-2); }
.ds-add-row .ds-input { flex: 1; min-width: 0; }
.ds-add-preview { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.ds-add-preview .thumb { flex: none; width: 160px; height: 90px; border-radius: var(--radius-md); object-fit: cover; background: var(--muted); }
.ds-add-preview .ds-add-done { flex: 1; margin: 0; }

.ds-thumb-prev { display: block; width: 160px; height: 90px; margin-bottom: var(--space-2); border-radius: var(--radius-md); object-fit: cover; background: var(--muted); }
.ds-thumb-prev[hidden] { display: none; }
