/* Netflix-style TV interface: dark, wide rows, D-pad focus. */
:root {
  --nf-bg: #141414;
  --nf-red: #e50914;
  --nf-text: #ffffff;
  --nf-dim: #b3b3b3;
  --nf-panel: #1f1f1f;
  --nf-line: #2a2a2a;
  --topbar-h: 68px;
}

html {
  font-size: 17px;
  background: var(--nf-bg);
}
body.tv {
  background: var(--nf-bg);
  color: var(--nf-text);
  margin: 0;
  overflow-x: hidden;
  user-select: none;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 34px;
  padding: 0 48px;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.85), transparent);
  transition: background 0.3s ease;
}
.topbar.solid {
  background: var(--nf-bg);
  border-bottom: 1px solid var(--nf-line);
}
.brand {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--nf-red);
  text-transform: uppercase;
  flex: none;
  line-height: 1;
}
.topnav {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tv-nav-btn {
  border: 2px solid transparent;
  background: none;
  color: var(--nf-dim);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 9px 15px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}
.tv-nav-btn.active {
  color: var(--nf-text);
  font-weight: 700;
}
.tv-nav-btn:focus {
  outline: none;
  color: #000;
  background: #fff;
  border-color: #fff;
  transform: scale(1.05);
}
.topbar .right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Hero ---------- */
.tv-stage {
  padding-bottom: 80px;
  min-height: 100vh;
}

.tv-hero {
  position: relative;
  height: 78vh;
  min-height: 480px;
  display: flex;
  align-items: center;
  padding: 0 48px;
  margin-bottom: 8px;
}
.tv-hero .bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tv-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgb(20 20 20 / 0.95) 0%, rgb(20 20 20 / 0.55) 42%, transparent 72%),
    linear-gradient(to top, var(--nf-bg) 0%, transparent 28%);
}
.tv-hero-content {
  position: relative;
  z-index: 1;
  max-width: 46%;
  padding-top: var(--topbar-h);
}
.tv-hero h1 {
  font-size: 3.6rem;
  line-height: 1.02;
  margin: 0 0 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-shadow: 0 3px 20px rgb(0 0 0 / 0.7);
}
.tv-hero .meta {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--nf-text);
  font-size: 0.95rem;
  margin-bottom: 16px;
  font-weight: 500;
}
.tv-hero .meta .match {
  color: #46d369;
  font-weight: 700;
}
.tv-hero .meta .tag {
  border: 1px solid rgb(255 255 255 / 0.45);
  padding: 1px 8px;
  font-size: 0.8rem;
  border-radius: 3px;
  color: var(--nf-dim);
}
.tv-hero p {
  font-size: 1.1rem;
  line-height: 1.45;
  color: var(--nf-text);
  margin: 0 0 26px;
  text-shadow: 0 2px 10px rgb(0 0 0 / 0.8);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tv-btn {
  padding: 13px 30px;
  border-radius: 5px;
  border: 2px solid transparent;
  background: rgb(109 109 110 / 0.7);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.tv-btn.primary {
  background: #fff;
  color: #000;
}
.tv-btn:focus {
  outline: none;
  background: #fff;
  color: #000;
  border-color: #fff;
  transform: scale(1.06);
}
.tv-btn.primary:focus {
  background: var(--nf-red);
  color: #fff;
  border-color: #fff;
}

/* ---------- Rows ---------- */
.tv-row {
  margin-bottom: 34px;
}
.tv-row h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 12px 48px;
  color: #e5e5e5;
  letter-spacing: -0.01em;
}
.tv-track {
  display: flex;
  gap: 8px;
  padding: 26px 48px 34px;
  margin: -26px 0 -34px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tv-track::-webkit-scrollbar {
  display: none;
}

/* Netflix uses landscape thumbnails on TV */
.tv-card {
  flex: 0 0 300px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  position: relative;
}
.tv-card .art {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  overflow: hidden;
  background: var(--nf-panel);
  outline: 3px solid transparent;
  transition: transform 0.22s ease, outline-color 0.22s ease, box-shadow 0.22s ease;
}
.tv-card .art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tv-card:focus {
  outline: none;
  z-index: 5;
}
.tv-card:focus .art {
  transform: scale(1.13);
  outline-color: #fff;
  box-shadow: 0 16px 44px rgb(0 0 0 / 0.75);
}
.tv-card .art .q {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 7px;
  border-radius: 3px;
  background: rgb(0 0 0 / 0.75);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.tv-card .art .bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgb(255 255 255 / 0.28);
}
.tv-card .art .bar > i {
  display: block;
  height: 100%;
  background: var(--nf-red);
}
/* Title strip appears under the thumbnail only while focused, as on Netflix */
.tv-card .label {
  margin-top: 9px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--nf-text);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tv-card .sub {
  font-size: 0.78rem;
  color: var(--nf-dim);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.tv-card:focus .label,
.tv-card:focus .sub {
  opacity: 1;
  transform: none;
}

/* Poster-shaped variant for the "Top picks" style row */
.tv-card.poster {
  flex-basis: 190px;
}
.tv-card.poster .art {
  aspect-ratio: 2 / 3;
}

.art-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 14px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.25;
  color: rgb(255 255 255 / 0.85);
}

/* ---------- Detail overlay ---------- */
.tv-detail {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: var(--nf-bg);
  overflow-y: auto;
  animation: nf-fade 0.22s ease;
}
.tv-detail[hidden] {
  display: none;
}
@keyframes nf-fade {
  from {
    opacity: 0;
  }
}
.tv-detail .bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 72vh;
  object-fit: cover;
}
.tv-detail::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 72vh;
  background: linear-gradient(to top, var(--nf-bg) 4%, rgb(20 20 20 / 0.35) 60%, transparent),
    linear-gradient(to right, rgb(20 20 20 / 0.9), transparent 70%);
  pointer-events: none;
}
.tv-detail-inner {
  position: relative;
  z-index: 2;
  padding: 26vh 48px 70px;
  max-width: 1180px;
}
.tv-detail h1 {
  font-size: 3.2rem;
  margin: 0 0 16px;
  font-weight: 900;
  letter-spacing: -0.03em;
}
.tv-detail .meta {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--nf-dim);
  margin-bottom: 18px;
  flex-wrap: wrap;
  font-size: 0.95rem;
}
.tv-detail p.overview {
  font-size: 1.08rem;
  line-height: 1.55;
  color: var(--nf-text);
  margin: 0 0 32px;
  max-width: 760px;
}
.tv-detail .actions {
  display: flex;
  gap: 14px;
  margin-bottom: 46px;
  flex-wrap: wrap;
}
.tv-detail h3.section-title {
  font-size: 1.25rem;
  margin: 0 0 16px;
  font-weight: 700;
}

.tv-ep {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
  padding: 16px 20px;
  margin-bottom: 8px;
  border-radius: 6px;
  border: 3px solid transparent;
  background: var(--nf-panel);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, transform 0.15s ease;
}
.tv-ep:focus {
  outline: none;
  background: #333;
  border-color: #fff;
  transform: scale(1.012);
}
.tv-ep .n {
  flex: none;
  width: 46px;
  text-align: center;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--nf-dim);
}
.tv-ep:focus .n {
  color: #fff;
}
.tv-ep .t {
  font-weight: 600;
  font-size: 1rem;
}
.tv-ep .s {
  font-size: 0.83rem;
  color: var(--nf-dim);
  margin-top: 4px;
}

/* ---------- Search ---------- */
.tv-search {
  padding: calc(var(--topbar-h) + 40px) 48px 0;
}
.tv-search input {
  width: 100%;
  max-width: 760px;
  padding: 18px 24px;
  font-size: 1.15rem;
  border-radius: 5px;
  border: 3px solid #333;
  background: var(--nf-panel);
  color: #fff;
}
.tv-search input::placeholder {
  color: #777;
}
.tv-search input:focus {
  outline: none;
  border-color: #fff;
}

.tv-empty {
  padding: 30vh 48px;
  text-align: center;
  color: var(--nf-dim);
}
.tv-empty h2 {
  color: var(--nf-text);
  font-size: 1.7rem;
  margin: 0 0 12px;
  font-weight: 700;
}

.first-row-offset {
  padding-top: calc(var(--topbar-h) + 40px);
}

.tv-hint {
  position: fixed;
  bottom: 16px;
  right: 24px;
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
  color: #5a5a5a;
  z-index: 5;
}
.tv-hint kbd {
  background: #262626;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 2px 6px;
  margin-right: 5px;
  font-family: inherit;
}

@media (max-width: 900px) {
  html {
    font-size: 14px;
  }
  .topbar,
  .tv-hero,
  .tv-detail-inner,
  .tv-search {
    padding-left: 20px;
    padding-right: 20px;
  }
  .tv-row h2 {
    margin-left: 20px;
  }
  .tv-track {
    padding-left: 20px;
    padding-right: 20px;
  }
  .tv-hero-content {
    max-width: 100%;
  }
  .tv-card {
    flex-basis: 230px;
  }
  .tv-hint {
    display: none;
  }
}
