/* Plex-like anime list, cards, carousels and hero */
/* Variables and fonts are defined in styles.css */

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(15, 15, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar-search {
  position: relative;
  max-width: 280px;
  width: 100%;
  transition: max-width 0.3s ease;
}

.topbar-search:focus-within {
  max-width: 400px;
}

.topbar-search input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: all 0.2s ease;
}

.topbar-search input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.topbar-search input:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.topbar-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
  pointer-events: none;
}

/* Hero Billboard */
.hero-billboard {
  position: relative;
  width: 100%;
  height: 70vh;
  min-height: 520px;
  max-height: 800px;
  overflow: hidden;
  margin-bottom: 40px;
}

.hero-billboard .hero-backdrop,
.hero-billboard .hero-gradient,
.hero-billboard .hero-content {
  transition: opacity 0.4s ease;
}

.hero-billboard.hero-transitioning .hero-backdrop,
.hero-billboard.hero-transitioning .hero-gradient,
.hero-billboard.hero-transitioning .hero-content {
  opacity: 0;
}

.hero-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
}

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    #0f0f0f 0%,
    rgba(15, 15, 15, 0.85) 25%,
    rgba(15, 15, 15, 0.4) 60%,
    rgba(15, 15, 15, 0.1) 100%
  );
}

.hero-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 32px 56px;
  display: flex;
  align-items: flex-end;
  gap: 32px;
  z-index: 2;
}

.hero-poster {
  width: 200px;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
  display: block;
}

.hero-text {
  flex: 1;
  max-width: 720px;
  padding-bottom: 4px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 12px;
  line-height: 1.2;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.hero-meta .dot {
  width: 4px;
  height: 4px;
  background: var(--text-secondary);
  border-radius: 50%;
  display: inline-block;
}

.hero-synopsis {
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 24px;
}

.hero-actions {
  display: flex;
  gap: 12px;
}

.hero-actions button {
  padding: 12px 28px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
}

.btn-watch {
  background: var(--accent);
  color: #000;
}

.btn-watch:hover {
  background: #f0b023;
  transform: translateY(-1px);
}

.btn-details {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-details:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.hero-dots {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.hero-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
}

.hero-dot:hover {
  background: rgba(255, 255, 255, 0.6);
}

.hero-dot.active {
  background: var(--accent, #e5a00d);
  box-shadow: 0 0 8px rgba(229, 160, 13, 0.4);
}

/* Carousel Sections */
.carousel-section {
  margin-bottom: 40px;
}

.carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px 12px;
}

.carousel-title {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.carousel-nav {
  display: flex;
  gap: 8px;
}

.carousel-nav button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  padding: 0;
}

.carousel-nav button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.carousel-row {
  position: relative;
  padding: 0 32px;
}

/* Anime List / Row */
.anime-list {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

.anime-list::-webkit-scrollbar {
  display: none;
}

/* Anime Card */
.anime-item {
  flex-shrink: 0;
  width: 180px;
  aspect-ratio: 2/3;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform 250ms ease, box-shadow 250ms ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  scroll-snap-align: start;
  background: var(--surface);
}

.anime-item:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(229, 160, 13, 0.3), 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 5;
}

.anime-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.anime-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.9) 0%,
    rgba(0, 0, 0, 0.5) 50%,
    transparent 100%
  );
  padding: 40px 12px 12px;
  pointer-events: none;
}

.anime-info h2 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.anime-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  z-index: 3;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

.new-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ef4444;
  color: #fff;
  font-weight: 700;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  z-index: 3;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

/* Hover Overlay (Plex style) */
.anime-hover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.anime-item:hover .anime-hover-overlay {
  opacity: 1;
  pointer-events: auto;
}

.play-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.85);
  transition: transform 0.2s ease;
}

.anime-item:hover .play-icon {
  transform: scale(1.1);
}

/* Progress Bar */
.progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 4;
  border-radius: 0 0 0 2px;
}

/* All Anime Grid Override */
.all-anime .anime-list {
  flex-wrap: wrap;
  overflow-x: visible;
  scroll-snap-type: none;
  padding: 0 32px;
}

/* Loading */
#loading {
  display: none;
  background: rgba(15, 15, 15, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  width: 100%;
  position: fixed;
  height: 100%;
  padding: 0;
  margin: 0;
  z-index: 99;
  left: 0;
  top: 0;
}

#loading > p {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font-body);
  background-color: var(--surface);
  color: var(--text-primary);
  padding: 24px 36px;
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #1a1a1a 25%, #252525 50%, #1a1a1a 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-card {
  flex-shrink: 0;
  width: 180px;
  aspect-ratio: 2/3;
  border-radius: 4px;
}

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

/* Responsive */
@media (max-width: 768px) {
  body > .container > .side-menu {
    width: 100%;
    transform: translateX(-100%);
  }

  body > .container > .side-menu.open {
    transform: translateX(0);
  }

  body > .container > .content {
    margin-left: 0;
    width: 100vw;
  }

  .topbar {
    padding: 14px 20px;
  }

  .hero-billboard {
    min-height: 420px;
    height: 55vh;
  }

  .hero-content {
    padding: 0 20px 32px;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .hero-poster {
    width: 120px;
    display: none;
  }

  .hero-title {
    font-size: 24px;
  }

  .carousel-header {
    padding: 0 20px 12px;
  }

  .carousel-row {
    padding: 0 20px;
  }

  .all-anime .anime-list {
    padding: 0 20px;
    justify-content: space-between;
  }

  .anime-item {
    width: calc(50% - 8px);
    scroll-snap-align: center;
  }

  .skeleton-card {
    width: calc(50% - 8px);
  }

  .autocomplete-dropdown {
    max-height: 240px;
  }
}

@media (max-width: 480px) {
    .hero-billboard {
        padding: 16px !important;
    }
    .hero-billboard .hero-content {
        padding: 16px !important;
    }
    .anime-grid {
        grid-template-columns: 1fr !important;
    }
    .carousel-row {
        padding: 0 12px !important;
    }
    .all-anime {
        padding: 12px !important;
    }
    .provider-tabs {
        flex-wrap: wrap !important;
    }
}

/* ================================================
   Stagger Animation for Anime Cards
   ================================================ */

@keyframes cardFadeIn {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.anime-list.stagger .anime-item {
  opacity: 0;
  animation: cardFadeIn 0.4s ease forwards;
  animation-delay: calc(var(--i, 0) * 60ms);
}

/* ================================================
   Hero Progress Bar
   ================================================ */

.hero-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent, #e5a00d);
  z-index: 5;
  transition: none;
}

.hero-progress-bar.running {
  animation: heroProgress 7s linear forwards;
}

@keyframes heroProgress {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

/* ================================================
   Autocomplete Dropdown
   ================================================ */

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface, #1a1a1a);
  border: 1px solid var(--border, #2a2a2a);
  border-top: none;
  border-radius: 0 0 var(--radius-sm, 4px) var(--radius-sm, 4px);
  max-height: 300px;
  overflow-y: auto;
  z-index: 60;
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.45));
}

.autocomplete-item {
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-secondary, #b3b3b3);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border, #2a2a2a);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-soft, rgba(229, 160, 13, 0.12));
  color: var(--text-primary, #ffffff);
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: normal;
  overflow: visible;
}

.autocomplete-cover {
  width: 32px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm, 4px);
  flex-shrink: 0;
  background: var(--elevated, #252525);
}

.autocomplete-title {
  font-weight: 500;
  color: var(--text-primary, #ffffff);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.autocomplete-item .item-title {
  font-weight: 600;
  color: var(--text-primary, #ffffff);
}

.autocomplete-item .item-meta {
  font-size: 12px;
  color: var(--text-muted, #666666);
  margin-left: 8px;
}

/* ================================================
   Enhanced Skeleton Shimmer
   ================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface, #1a1a1a) 25%,
    #3a3a3a 50%,
    var(--surface, #1a1a1a) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  opacity: 0;
  animation-fill-mode: forwards;
  border-radius: var(--radius-sm, 4px);
}

.skeleton-card {
  flex-shrink: 0;
  width: 180px;
  aspect-ratio: 2/3;
  border-radius: var(--radius, 8px);
  opacity: 0;
  animation: skeleton-shimmer 1.5s ease-in-out infinite, cardFadeIn 0.4s ease forwards;
  animation-delay: 0s, calc(var(--i, 0) * 60ms);
}
