/* ============================================================
   MovieStream — Styles
   Dark-themed, Netflix-inspired, mobile-first responsive design
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #141414;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222;
  --bg-overlay: rgba(0, 0, 0, 0.85);
  --bg-input: #2a2a2a;
  --accent: #e50914;
  --accent-hover: #ff1a25;
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #808080;
  --border-color: #333;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.8);
  --transition: 0.3s ease;
  --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --max-width: 1400px;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #666;
}

/* ---------- Header / Navbar ---------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 70%, transparent 100%);
  transition: background var(--transition);
}

.navbar.scrolled {
  background: rgba(13, 13, 13, 0.97);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

.navbar__logo {
  flex-shrink: 0;
  height: 32px;
  width: auto;
}

.navbar__search {
  flex: 1;
  max-width: 400px;
  margin-left: auto;
  position: relative;
}

.navbar__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.navbar__search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.navbar__search-input::placeholder {
  color: var(--text-muted);
}

.navbar__search-input:focus {
  border-color: var(--accent);
  background: #1e1e1e;
}

.navbar__filter {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23b3b3b3' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5l6.5 6.5 6.5-6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  transition: border-color var(--transition);
}

.navbar__filter:focus {
  border-color: var(--accent);
}

/* ---------- Hero Section ---------- */
.hero {
  position: relative;
  width: 100%;
  min-height: 70vh;
  display: flex;
  align-items: flex-end;
  padding: 80px 24px 60px;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(13,13,13,0.3) 0%,
    rgba(13,13,13,0.6) 50%,
    rgba(13,13,13,1) 100%
  );
}

.hero__content {
  position: relative;
  z-index: 2;
  max-width: 600px;
}

.hero__badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.hero__title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
}

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

.hero__rating {
  color: #46d369;
  font-weight: 700;
}

.hero__description {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  transform: scale(1.03);
}

.btn--secondary {
  background: rgba(109, 109, 110, 0.7);
  color: #fff;
}

.btn--secondary:hover {
  background: rgba(109, 109, 110, 0.5);
}

/* ---------- Section ---------- */
.section {
  padding: 32px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.section__title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

/* ---------- Movie Grid ---------- */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
}

.movie-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-card);
}

.movie-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

.movie-card:hover .movie-card__overlay {
  opacity: 1;
}

.movie-card__poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg-card);
}

.movie-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  opacity: 0;
  transition: opacity var(--transition);
}

.movie-card__play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  background: rgba(229, 9, 20, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.movie-card__play-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
  margin-left: 3px;
}

.movie-card__title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.movie-card__info {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.movie-card__info .rating {
  color: #46d369;
  font-weight: 600;
}

/* Bottom info bar always visible */
.movie-card__bottom {
  padding: 12px;
  background: var(--bg-card);
}

.movie-card__bottom-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movie-card__bottom-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Player Modal ---------- */
.player-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--bg-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.player-modal.active {
  opacity: 1;
  visibility: visible;
}

.player-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

.player-modal__title {
  font-size: 18px;
  font-weight: 700;
}

.player-modal__close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  transition: background var(--transition);
}

.player-modal__close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.player-modal__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
}

.player-modal__iframe-wrapper {
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 16 / 9;
  position: relative;
  border-radius: var(--radius-md);
  overflow: visible;
  background: #000;
  box-shadow: var(--shadow-modal);
  z-index: 10;
  -webkit-overflow-scrolling: touch;
}

.player-modal__iframe-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  z-index: 11;
  touch-action: auto;
}

.player-modal__info {
  flex-shrink: 0;
  padding: 16px 24px 24px;
  background: rgba(0, 0, 0, 0.6);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.player-modal__meta {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.player-modal__meta .rating {
  color: #46d369;
  font-weight: 700;
}

.player-modal__description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 800px;
}

/* ---------- No Results ---------- */
.no-results {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.no-results__icon {
  font-size: 60px;
  margin-bottom: 16px;
}

.no-results__text {
  font-size: 18px;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border-color);
  margin-top: 60px;
}

.footer a {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.footer a:hover {
  color: var(--accent);
}

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

.skeleton-card {
  aspect-ratio: 2 / 3;
}

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

/* ---------- Continue Watching Badge ---------- */
.continue-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  background: var(--accent);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  z-index: 5;
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */

/* Small phones */
@media (max-width: 480px) {
  .navbar {
    padding: 10px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .navbar__logo {
    height: 26px;
  }

  .navbar__search {
    order: 3;
    max-width: 100%;
    flex-basis: 100%;
  }

  .navbar__filter {
    font-size: 12px;
    padding: 8px 28px 8px 10px;
  }

  .hero {
    min-height: 55vh;
    padding: 70px 16px 40px;
  }

  .hero__title {
    font-size: 1.8rem;
  }

  .hero__description {
    font-size: 14px;
    -webkit-line-clamp: 2;
  }

  .btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .section {
    padding: 20px 14px;
  }

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

  .player-modal__header {
    padding: 10px 16px;
  }

  .player-modal__title {
    font-size: 15px;
  }

  .player-modal__body {
    padding: 4px;
    align-items: flex-start;
    padding-top: 8px;
  }

  .player-modal__iframe-wrapper {
    border-radius: 6px;
    width: 100%;
    max-width: 100%;
  }

  .player-modal__info {
    padding: 10px 16px;
  }

  .player-modal__description {
    display: none;
  }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 768px) {
  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
  }

  .hero {
    min-height: 60vh;
  }
}

/* Desktop */
@media (min-width: 769px) and (max-width: 1024px) {
  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* Large Desktop */
@media (min-width: 1025px) {
  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .hero {
    min-height: 75vh;
    padding: 100px 60px 80px;
  }

  .section {
    padding: 40px 60px;
  }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    min-height: 90vh;
    padding-top: 70px;
  }

  .player-modal__info {
    display: none;
  }

  .player-modal__body {
    padding: 4px;
  }

  .player-modal__header {
    padding: 8px 16px;
  }
}
