*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #141414;
  color: #fff;
  overflow-x: hidden;
}

#page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
}

.bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.bg-layer.active {
  opacity: 1;
}

/* ── Top Bar ── */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, transparent 100%);
  z-index: 200;
  transition: background 0.3s;
}


.topbar-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.topbar-logout {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.topbar-logout:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

/* ── Sidebar ── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 80px;
  height: 100vh;
  background: linear-gradient(90deg, rgba(20,20,20,0.85) 0%, transparent 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 72px;
  z-index: 100;
}

.sidebar-icons {
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
  flex: 1;
  justify-content: center;
  padding-bottom: 80px;
}

.sidebar-icon {
  background: none;
  border: none;
  color: #e50914;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: color 0.2s, background-color 0.2s;
  position: relative;
}

.sidebar-icon svg {
  width: 50px;
  height: 50px;
}

.sidebar-icon:hover,
.sidebar-icon.active {
  color: #ff3b30;
}

.sidebar-icon:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 64px;
  top: 50%;
  transform: translateY(-50%);
  background: #333;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Main Content ── */

.main-content {
  margin-left: 80px;
  min-height: 100vh;
  padding-top: 56px;
}

/* ── Hero ── */

.hero {
  position: relative;
  width: 100vw;
  margin-left: calc(-80px);
  min-height: 40vh;
  padding-bottom: 80px;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 350px;
  background: linear-gradient(180deg, transparent 0%, rgba(20,20,20,0.85) 50%);
  pointer-events: none;
}

.hero-skeleton {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #1f1f1f 25%, #2a2a2a 50%, #1f1f1f 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.hero-info {
  position: absolute;
  bottom: 60px;
  left: 40px;
  max-width: 600px;
  z-index: 2;
  padding-left: 80px;
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.hero-overview {
  font-size: 1rem;
  line-height: 1.5;
  color: #ccc;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 20px;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #e50914;
  color: #fff;
  border: none;
  padding: 10px 28px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.hero-btn:hover {
  background: #f40612;
}

/* ── Genre Page ── */

.genre-header {
  padding: 40px 40px 0;
  width: 100vw;
  margin-left: calc(-80px);
  padding-left: 120px;
}

.genre-title {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.genre-rows {
  min-height: 60vh;
}

/* ── Content Rows ── */

.row {
  padding: 20px 40px;
  width: 100vw;
  margin-left: calc(-80px);
  padding-left: 120px;
  background: rgba(20, 20, 20, 0.85);
  position: relative;
}

.row:first-of-type {
  padding-top: 40px;
}

.row-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.row-cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-behavior: smooth;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.row-cards::-webkit-scrollbar {
  display: none;
}

/* ── Row arrows ── */

.row-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60px;
  border: none;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  color: #fff;
}

.row:hover .row-arrow {
  opacity: 1;
}

.row-arrow-left {
  left: 120px;
  background: linear-gradient(90deg, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.row-arrow-right {
  right: 40px;
  background: linear-gradient(270deg, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.row-arrow-left:hover {
  background: linear-gradient(90deg, rgba(0,0,0,0.85) 0%, transparent 100%);
}

.row-arrow-right:hover {
  background: linear-gradient(270deg, rgba(0,0,0,0.85) 0%, transparent 100%);
}

.row-arrow svg {
  transition: transform 0.15s;
}

.row-arrow:hover svg {
  transform: scale(1.3);
}

@media (max-width: 768px) {
  .row-arrow {
    display: none !important;
  }
}

/* ── Cards ── */

.card {
  flex: 0 0 auto;
  width: 240px;
  border-radius: 4px;
  overflow: hidden;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.card:hover {
  transform: scale(1.05);
}

.card img {
  width: 240px;
  height: 360px;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}

/* ── Card loading state (skeleton holds until image loads) ── */

.card-loading {
  background: linear-gradient(90deg, #1f1f1f 25%, #2a2a2a 50%, #1f1f1f 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  position: relative;
  overflow: hidden;
}

.card-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.04) 30%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 70%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: glass-wipe 2s infinite ease-in-out;
}

.card-loading img {
  opacity: 0;
}

.card-loading.loaded {
  background: none;
  animation: none;
}

.card-loading.loaded::after {
  display: none;
}

.card-loading.loaded img {
  opacity: 1;
}

/* ── Skeleton Cards ── */

.skeleton-card {
  flex: 0 0 auto;
  width: 240px;
  height: 360px;
  border-radius: 4px;
  background: linear-gradient(90deg, #1f1f1f 25%, #2a2a2a 50%, #1f1f1f 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  position: relative;
  overflow: hidden;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.04) 30%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 70%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: glass-wipe 2s infinite ease-in-out;
}

@keyframes glass-wipe {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Fade in transition ── */

.card {
  animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Search Overlay ── */

.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.search-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
}

.search-panel {
  position: relative;
  width: min(90vw, 800px);
  margin-top: 60px;
  z-index: 1;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1f1f1f;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 12px 16px;
  transition: border-color 0.2s;
}

.search-input-wrap:focus-within {
  border-color: #e50914;
}

.search-input-icon {
  flex-shrink: 0;
  color: #555;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  outline: none;
  font-family: inherit;
}

.search-input::placeholder {
  color: #555;
}

.search-close {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
}

.search-close:hover {
  color: #fff;
}

.search-results {
  margin-top: 20px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

.search-results::-webkit-scrollbar {
  width: 6px;
}

.search-results::-webkit-scrollbar-track {
  background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.search-hint {
  text-align: center;
  color: #555;
  padding: 40px 0;
  font-size: 1rem;
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.search-result-card {
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}

.search-result-card:hover {
  transform: scale(1.05);
}

.search-result-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
}

.search-result-title {
  padding: 8px 4px;
  font-size: 0.85rem;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-type {
  font-size: 0.7rem;
  color: #555;
  padding: 0 4px 8px;
}

.search-person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.search-person:hover {
  background: #1f1f1f;
}

.search-person img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.search-person-info {
  flex: 1;
}

.search-person-name {
  font-size: 0.95rem;
  color: #fff;
}

.search-person-role {
  font-size: 0.8rem;
  color: #555;
}

/* ── Mobile: bottom nav bar ── */

@media (max-width: 768px) {
  .sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: auto;
    background: linear-gradient(180deg, transparent 0%, rgba(20,20,20,0.85) 100%);
    flex-direction: row;
    justify-content: space-around;
    padding: 16px 0 8px;
  }

  .topbar {
    padding: 0 12px;
    height: 48px;
  }

  .sidebar-icons {
    flex-direction: row;
    gap: 0;
    flex: 1;
    justify-content: space-around;
    padding-bottom: 0;
  }

  .sidebar-icon {
    padding: 6px;
  }

  .sidebar-icon svg {
    width: 28px;
    height: 28px;
  }

  .sidebar-icon:hover::after {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding-top: 48px;
    padding-bottom: 60px;
  }

  .hero {
    width: 100%;
    margin-left: 0;
    min-height: 50vh;
    padding-bottom: 80px;
  }

  .hero::after {
    height: 200px;
    background: linear-gradient(180deg, transparent 0%, rgba(20,20,20,0.85) 60%);
  }

  .hero-info {
    left: 20px;
    padding-left: 0;
    bottom: 40px;
  }

  .hero-title {
    font-size: 1.6rem;
  }

  .hero-overview {
    font-size: 0.85rem;
    -webkit-line-clamp: 2;
  }

  .hero-btn {
    font-size: 0.85rem;
    padding: 8px 20px;
  }

  .row {
    padding: 12px 16px;
    width: 100%;
    margin-left: 0;
    padding-left: 16px;
  }

  .row:first-of-type {
    padding-top: 24px;
  }

  .row-title {
    font-size: 1.1rem;
  }

  .genre-header {
    padding: 20px 16px 0;
    width: 100%;
    margin-left: 0;
    padding-left: 16px;
  }

  .genre-title {
    font-size: 1.4rem;
  }

  .card {
    width: 160px;
  }

  .card img {
    width: 160px;
    height: 240px;
  }

  .search-panel {
    width: 100vw;
    margin-top: 0;
    padding: 12px;
  }

  .search-input-wrap {
    border-radius: 0;
    padding: 10px 12px;
  }

  .search-input {
    font-size: 1rem;
  }

  .search-results-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

/* ── Smart TV ── */

.tv body {
  overflow: hidden;
  border: 3vh solid transparent;
  box-sizing: border-box;
}

.tv .main-content {
  margin-left: 80px;
}

/* Focus states for TV */
.tv a:focus-visible,
.tv button:focus-visible,
.tv [tabindex]:focus-visible {
  outline: 3px solid #e50914;
  outline-offset: 3px;
  border-radius: 4px;
}

/* Card focus */
.tv .card:focus-visible {
  outline: 3px solid #e50914;
  outline-offset: 3px;
  transform: scale(1.08);
  z-index: 2;
}

/* Row arrows always visible on TV */
.tv .row-arrow {
  opacity: 1 !important;
}

.tv input:focus-visible,
.tv .search-overlay-input:focus-visible {
  outline: 3px solid #e50914;
  outline-offset: 2px;
}

.tv .row-arrow-left {
  left: 120px;
}

.tv .row-arrow-right {
  right: 40px;
}

/* ── TV visual tuning ── */

.tv .hero-section {
  height: 70vh;
  min-height: 400px;
  max-height: 900px;
}

.tv .hero-title {
  font-size: 3rem;
}

.tv .hero-overview {
  font-size: 1.1rem;
  max-width: 600px;
}

.tv .hero-btn {
  font-size: 1rem;
  padding: 12px 32px;
}

.tv .row-label {
  font-size: 1.3rem;
}

.tv .card {
  width: 320px;
}

.tv .card img {
  width: 320px;
  height: 480px;
  object-fit: cover;
  border-radius: 4px;
}

.tv .sidebar {
  width: 100px;
}

.tv .sidebar-icon svg {
  width: 40px;
  height: 40px;
}

.tv .topbar {
  height: 64px;
}

.tv .topbar-brand img:first-child {
  width: 36px;
  height: 36px;
}

.tv .topbar-brand img:last-child {
  height: 24px;
}

.tv .row-arrow svg {
  width: 40px;
  height: 40px;
}

/* ── TV search overlay ── */

.tv .search-overlay-input {
  font-size: 1.5rem;
  padding: 16px 24px;
}

.tv .search-result-card {
  width: 200px;
}

.tv .search-result-card img {
  height: 300px;
}

@media (min-width: 1920px) and (pointer: coarse) {
  body {
    overflow: hidden;
    border: 3vh solid transparent;
    box-sizing: border-box;
  }
  .main-content {
    margin-left: 80px;
  }
}

/* ── TV virtual keyboard ── */
.tv .tv-keyboard {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(30,30,30,0.95);
  padding: 16px;
  z-index: 1000;
}

.tv .tv-keyboard-inner {
  max-width: 900px;
  margin: 0 auto;
}

.tv .tv-keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}

.tv .tv-key-btn {
  background: #333;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 1.2rem;
  min-width: 48px;
  text-align: center;
  cursor: pointer;
}

.tv .tv-key-btn:focus-visible {
  outline: 3px solid #e50914;
  outline-offset: 2px;
  background: #555;
}

.tv .tv-key-btn:active {
  background: #555;
}

.tv .tv-key-action {
  min-width: 72px;
  background: #444;
}

/* ── Person Page ── */

.person-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

.person-header {
  position: relative;
  min-height: 320px;
  display: flex;
  align-items: flex-end;
  padding: 40px 0 32px;
  margin: 0 -24px;
  padding-left: 24px;
  padding-right: 24px;
  overflow: hidden;
}

.person-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 2px;
  overflow: hidden;
}

.person-bg-tile {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
}

.person-header-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(20,20,20,0.6) 0%, #141414 100%);
}

.person-header-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 28px;
  width: 100%;
}

.person-photo-wrap {
  flex-shrink: 0;
}

.person-photo {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.person-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1f1f1f;
}

.person-header-info {
  flex: 1;
  min-width: 0;
  padding-bottom: 8px;
}

.person-name {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: #fff;
  line-height: 1.2;
}

.person-department {
  display: inline-block;
  font-size: 0.85rem;
  color: #aaa;
  background: rgba(255,255,255,0.08);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.person-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.person-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: #999;
}

.person-meta-item svg {
  flex-shrink: 0;
}

.person-meta-death {
  color: #e50914;
}

.person-body {
  padding-top: 8px;
}

.person-section {
  margin-bottom: 36px;
}

.person-section-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #fff;
  margin: 0 0 16px;
}

.person-count {
  font-weight: 400;
  color: #666;
  font-size: 0.9rem;
}

.person-bio {
  font-size: 0.92rem;
  line-height: 1.7;
  color: #bbb;
  max-height: 240px;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.person-bio.expanded {
  max-height: none;
}

.person-bio-toggle {
  background: none;
  border: none;
  color: #e50914;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 6px 0;
  margin-top: 4px;
}

.person-bio-toggle:hover {
  text-decoration: underline;
}

.person-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 32px;
}

.person-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.person-info-label {
  font-size: 0.78rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.person-info-value {
  font-size: 0.9rem;
  color: #ccc;
}

.person-info-value a {
  color: #e50914;
  text-decoration: none;
}

.person-info-value a:hover {
  text-decoration: underline;
}

/* Known For row */
.person-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
}

.person-row::-webkit-scrollbar {
  display: none;
}

/* Credit cards (Known For & Filmography) */
.person-credit-card {
  text-decoration: none;
  flex-shrink: 0;
  transition: transform 0.2s;
  cursor: pointer;
}

.person-credit-card:hover {
  transform: scale(1.05);
}

.person-row .person-credit-card {
  width: 150px;
}

.person-credit-poster {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 6px;
  overflow: hidden;
  background: #1f1f1f;
}

.person-credit-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.person-credit-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1f1f1f;
}

.person-credit-info {
  padding: 6px 2px 0;
}

.person-credit-title {
  font-size: 0.8rem;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-credit-role {
  font-size: 0.72rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-credit-year {
  font-size: 0.72rem;
  color: #666;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.person-credit-type {
  display: inline-block;
  font-size: 0.65rem;
  color: #555;
  border: 1px solid #444;
  padding: 0 4px;
  border-radius: 2px;
  line-height: 1.3;
}

/* Filmography grid */
.person-credits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.person-credits-grid .person-credit-card {
  width: auto;
}

/* Responsive */
@media (max-width: 768px) {
  .person-header-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .person-photo {
    width: 120px;
    height: 120px;
  }

  .person-name {
    font-size: 1.5rem;
  }

  .person-meta {
    justify-content: center;
  }

  .person-info-grid {
    grid-template-columns: 1fr;
  }

  .person-credits-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
  }
}
