/**
 * MůjFlix — Objevování (Discover)
 * ════════════════════════════════════════════════════════════════
 * Nahrazuje starý řádkový layout Objevování (styles-discover-redesign.css)
 * novým vzhledem: hero nadpis, chytré filtry (typ/řazení/rok/žánr),
 * Top 10 žebříček, karty podle nálady a mřížka doporučení s
 * "Načíst další". Vše je odsazené pod #universeOverlay, aby se to
 * nemíchalo s jiným vzhledem appky (žádné globální !important).
 */

#universeOverlay {
  --mfd-card: #141418;
  --mfd-card-2: #1c1c22;
  --mfd-text-2: rgba(255, 255, 255, 0.65);
  --mfd-star: #fbbf24;
  --mfd-accent-soft: rgba(10, 132, 255, 0.16);
  --mfd-accent-border: rgba(10, 132, 255, 0.38);
}

/* ── Header ── */
#universeOverlay .mfd-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top, 14px)) 24px 14px;
  background: rgba(6, 6, 9, 0.9);
  backdrop-filter: blur(44px) saturate(1.8);
  -webkit-backdrop-filter: blur(44px) saturate(1.8);
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.06);
}
#universeOverlay .mfd-brand {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  flex-shrink: 0;
  color: var(--text, #fff);
}
#universeOverlay .mfd-brand span { color: var(--accent, #0a84ff); }

/* Vyhledávací pole je mezi logem MujFlix a zavíracím křížkem, ve
   stejné řádce jako logo (dřív bylo přesunuté na samostatný řádek
   pod hlavičku — na přání zpátky vedle sebe). */
#universeOverlay .mfd-search-wrap {
  position: relative;
  flex: 1;
  max-width: 460px;
  margin: 0 8px;
}
/* Popisek "Vyhledávání" je jen pro čtečky obrazovky — input má stejný
   text i jako placeholder, takže vizuálně by se zobrazoval dvakrát. */
#universeOverlay .mf-search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
#universeOverlay .mfd-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 0.5px solid rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.85rem;
  transition: all 0.18s ease;
}
#universeOverlay .mfd-close:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* ── Vyhledávací pole — sjednocený vzhled ──
   Přebíjí roztříštěné/protichůdné styly nastřádané z fúze
   styles-premium.css + styles-apple-tv.css + styles-glass.css do
   styles.css (každý dřív stylovat .uni-search-wrap i .uni-input
   trochu jinak, což dělalo z pole "krabici v krabici"). Tady vyhrává
   díky vyšší specificitě (#universeOverlay + třída) i pořadí načtení
   (discover.css jde za styles.css). ── */
#universeOverlay .uni-search-wrap {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
#universeOverlay .uni-search-wrap:focus-within {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--mfd-accent-border);
  box-shadow: 0 0 0 4px var(--mfd-accent-soft);
}
#universeOverlay .uni-search-icon {
  color: rgba(255, 255, 255, 0.35);
  transition: color 0.2s ease;
}
#universeOverlay .uni-search-wrap:focus-within .uni-search-icon {
  color: var(--accent, #0a84ff);
}
#universeOverlay .uni-input {
  background: transparent;
  border: none;
  padding: 12px 44px 12px 46px;
  font-weight: 500;
  font-family: inherit;
}
#universeOverlay .uni-input::placeholder { color: rgba(255, 255, 255, 0.32); }
#universeOverlay .uni-clear-btn {
  background: rgba(255, 255, 255, 0.09);
  border: none;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}
#universeOverlay .uni-clear-btn:hover {
  background: var(--mfd-accent-soft);
  color: #fff;
  transform: translateY(-50%) scale(1.12);
}

/* ── Dropdown "Poslední hledání" — ukotvený pod polem ── */
#universeOverlay .mf-search-history {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  padding: 14px 16px 15px;
  background: rgba(14, 14, 18, 0.92);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
  animation: mfSearchHistoryIn 0.16s ease both;
}
#universeOverlay .mf-search-history:empty { display: none; }
#universeOverlay .mf-search-history-title {
  flex-basis: 100%;
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 2px;
}
#universeOverlay .mf-search-history-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.76rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
#universeOverlay .mf-search-history-item:hover {
  background: var(--mfd-accent-soft);
  border-color: var(--mfd-accent-border);
  color: #fff;
}
#universeOverlay .mf-search-history-item span {
  opacity: 0.45;
  font-size: 0.68rem;
}
@keyframes mfSearchHistoryIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 720px) {
  #universeOverlay .mf-search-history { padding: 12px 14px 13px; border-radius: 16px; }
}

/* ── Jemný vstup karet ve výsledkové mřížce (browse i search) ── */
#universeOverlay .mfd-rec-card {
  animation: mfdRecCardIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes mfdRecCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Body / content ── */
#universeOverlay .mfd-body {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px 24px 140px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.05) transparent;
}
#universeOverlay .mfd-body::-webkit-scrollbar { width: 3px; }
#universeOverlay .mfd-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.07); border-radius: 2px; }
#universeOverlay .mfd-hero-title {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.8px;
  margin: 0 0 6px;
  line-height: 1.1;
  color: var(--text, #fff);
}
#universeOverlay .mfd-hero-sub {
  font-size: 0.9rem;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  margin: 0 0 22px;
}

/* ── Filters row 1: type + sort + year ── */
#universeOverlay .mfd-filters-1 {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
#universeOverlay .mfd-f-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--mfd-text-2);
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}
#universeOverlay .mfd-f-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
#universeOverlay .mfd-f-btn.active {
  background: var(--mfd-accent-soft);
  border-color: var(--mfd-accent-border);
  color: #fff;
  box-shadow: 0 0 0 0.5px rgba(10, 132, 255, 0.4);
}
#universeOverlay .mfd-f-btn svg { width: 13px; height: 13px; }
#universeOverlay .mfd-f-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 2px;
}
#universeOverlay .mfd-select {
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--mfd-text-2);
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}
#universeOverlay .mfd-select:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
#universeOverlay .mfd-select:focus { outline: none; border-color: var(--mfd-accent-border); }
#universeOverlay .mfd-select option { background: #141418; color: #fff; }

/* ── Filters row 2: genre pills (#discoNav reused as container) ── */
#universeOverlay .mfd-filters-2,
#universeOverlay .disco-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 28px;
  scrollbar-width: none;
}
#universeOverlay .mfd-filters-2::-webkit-scrollbar,
#universeOverlay .disco-nav::-webkit-scrollbar { display: none; }

/* ── Oprava konfliktu .disco-nav (styles.css) vs .mfd-filters-2 (zde) ──
   #discoNav má obě třídy zároveň; toto pravidlo má díky #ID selektoru
   vyšší specificitu, takže vždy vyhraje bez ohledu na pořadí souborů. ── */
#universeOverlay #discoNav.disco-nav.mfd-filters-2 {
  background: transparent !important;
  padding: 6px 24px 18px !important;
  border-bottom: none !important;
}
#universeOverlay .mfd-pill {
  padding: 7px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  flex-shrink: 0;
}
#universeOverlay .mfd-pill:hover { background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.85); }
#universeOverlay .mfd-pill.active {
  background: var(--mfd-accent-soft);
  border-color: var(--mfd-accent-border);
  color: #fff;
}

/* ── Section headers ── */
#universeOverlay .mfd-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
#universeOverlay .mfd-section-title {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text, #fff);
}
#universeOverlay .mfd-em { color: var(--accent, #0a84ff); }

/* ── Top 10 row ── */
#universeOverlay .mfd-top10-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 0 24px;
  scrollbar-width: none;
  margin-bottom: 4px;
  min-height: 100px;
}
#universeOverlay .mfd-top10-row::-webkit-scrollbar { display: none; }
#universeOverlay .mfd-t10-item {
  position: relative;
  min-width: 130px;
  height: 195px;
  flex-shrink: 0;
  padding-left: 42px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#universeOverlay .mfd-t10-item:hover { transform: translateY(-4px); }
#universeOverlay .mfd-t10-num {
  position: absolute;
  left: -6px;
  bottom: -18px;
  font-size: 132px;
  font-weight: 900;
  line-height: 0.85;
  color: transparent;
  -webkit-text-stroke: 2.5px rgba(255, 255, 255, 0.32);
  font-family: Impact, "Arial Black", sans-serif;
  pointer-events: none;
  z-index: 1;
  transition: -webkit-text-stroke-color 0.25s;
}
#universeOverlay .mfd-t10-item:hover .mfd-t10-num { -webkit-text-stroke-color: rgba(10, 132, 255, 0.9); }
#universeOverlay .mfd-t10-poster {
  position: relative;
  z-index: 2;
  width: 130px;
  height: 195px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #2a2a35 0%, #16161c 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
#universeOverlay .mfd-t10-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
#universeOverlay .mfd-t10-poster::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, transparent 55%);
  z-index: 1;
}
#universeOverlay .mfd-t10-label {
  position: absolute;
  bottom: 8px;
  left: 10px;
  right: 10px;
  z-index: 2;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Mood cards ── */
#universeOverlay .mfd-mood-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
#universeOverlay .mfd-mood-card {
  position: relative;
  height: 128px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: flex-end;
  padding: 16px;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s;
}
#universeOverlay .mfd-mood-card:hover { transform: translateY(-4px); border-color: rgba(10, 132, 255, 0.35); }
#universeOverlay .mfd-mood-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, transparent 65%);
  z-index: 1;
}
#universeOverlay .mfd-mood-card.m1 { background: linear-gradient(135deg, #3b1e2e 0%, #1a0e15 100%); }
#universeOverlay .mfd-mood-card.m2 { background: linear-gradient(135deg, #1e2f3b 0%, #0e1820 100%); }
#universeOverlay .mfd-mood-card.m3 { background: linear-gradient(135deg, #3b2f1e 0%, #201810 100%); }
#universeOverlay .mfd-mood-content { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 2px; }
#universeOverlay .mfd-mood-emoji { font-size: 1.35rem; margin-bottom: 4px; }
#universeOverlay .mfd-mood-title { font-size: 0.92rem; font-weight: 800; letter-spacing: -0.3px; color: #fff; }
#universeOverlay .mfd-mood-sub { font-size: 0.64rem; color: rgba(255, 255, 255, 0.5); font-weight: 500; }

/* ── Results grid ── */
#universeOverlay .mfd-rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  min-height: 120px;
}
#universeOverlay .mfd-rec-card {
  background: var(--mfd-card);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
#universeOverlay .mfd-rec-card:hover {
  transform: translateY(-4px);
  border-color: rgba(10, 132, 255, 0.3);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(10, 132, 255, 0.15);
}
#universeOverlay .mfd-rec-thumb {
  aspect-ratio: 2/3;
  background: linear-gradient(135deg, #2a2a35 0%, #16161c 100%);
  position: relative;
  overflow: hidden;
}
#universeOverlay .mfd-rec-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
#universeOverlay .mfd-rec-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 60%);
  z-index: 1;
}
#universeOverlay .mfd-rec-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  background: rgba(10, 132, 255, 0.9);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.56rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4);
}
#universeOverlay .mfd-rec-finder {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
}
#universeOverlay .mfd-rec-card:hover .mfd-rec-finder { opacity: 1; }
#universeOverlay .mfd-rec-info { padding: 10px 11px 12px; }
#universeOverlay .mfd-rec-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  color: var(--text, #fff);
}
#universeOverlay .mfd-rec-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.66rem;
  color: var(--muted, rgba(255, 255, 255, 0.5));
}
#universeOverlay .mfd-rec-rating { color: var(--mfd-star); font-weight: 700; }

/* ── Load more ── */
#universeOverlay .mfd-loadmore-wrap { display: flex; justify-content: center; padding: 22px 0 10px; }
#universeOverlay .mfd-loadmore-btn {
  padding: 10px 26px;
  background: rgba(255, 255, 255, 0.06);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s ease;
}
#universeOverlay .mfd-loadmore-btn:hover { background: rgba(10, 132, 255, 0.18); border-color: rgba(10, 132, 255, 0.4); }
#universeOverlay .mfd-loadmore-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Empty / error state ── */
#universeOverlay .mfd-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 50px 16px;
  color: rgba(255, 255, 255, 0.45);
}
#universeOverlay .mfd-empty-icon { font-size: 2.2rem; margin-bottom: 10px; }

/* ── Search mode: hide browse sections, show only results ── */
#universeOverlay .mfd-body.mfd-searching #mfdHeroSub,
#universeOverlay .mfd-body.mfd-searching #mfdFiltersSection,
#universeOverlay .mfd-body.mfd-searching #mfdTop10Section,
#universeOverlay .mfd-body.mfd-searching #mfdMoodSection {
  display: none;
}

@media (max-width: 720px) {
  #universeOverlay .mfd-body { padding: 20px 16px 140px; }
  #universeOverlay .mfd-header { padding: 12px 16px; }
  #universeOverlay .mfd-brand { font-size: 0.95rem; }
  #universeOverlay .mfd-hero-title { font-size: 1.55rem; }
  #universeOverlay .mfd-rec-grid { grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 10px; }
  #universeOverlay .mfd-t10-item { min-width: 108px; height: 162px; padding-left: 34px; }
  #universeOverlay .mfd-t10-poster { width: 108px; height: 162px; }
  #universeOverlay .mfd-t10-num { font-size: 116px; }
}
