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

:root {
  --bg:        #0d0d0d;
  --surface:   #1a1a1a;
  --surface2:  #242424;
  --border:    #2e2e2e;
  --text:      #f0f0f0;
  --text-muted:#999;
  --accent:    #e50914;
  --accent2:   #f5a623;
  --radius:    10px;
  --shadow:    0 4px 20px rgba(0,0,0,.6);
  --font:      'Segoe UI', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ── Header / Nav ────────────────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,13,13,.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; gap: 24px;
  height: 60px;
}

.logo { font-size: 1.5rem; font-weight: 800; color: var(--accent); letter-spacing: -.5px; flex-shrink: 0; }

nav#nav-menu { display: flex; align-items: center; gap: 8px; }
.nav-link {
  padding: 6px 14px; border-radius: 20px; font-size: .9rem; font-weight: 500;
  color: var(--text-muted); transition: background .2s, color .2s; cursor: pointer;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }

.search-wrap {
  margin-left: auto; display: flex; align-items: center;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 24px; overflow: hidden; padding: 0 12px; gap: 6px;
}
.search-wrap svg { color: var(--text-muted); flex-shrink: 0; }
#search-input {
  background: none; border: none; outline: none; color: var(--text);
  font-size: .9rem; padding: 8px 4px; width: 200px;
}

#hamburger {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text); padding: 6px;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  position: relative; height: 520px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  background-size: cover; background-position: center;
  display: flex; align-items: flex-end;
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(13,13,13,1) 0%, rgba(13,13,13,.4) 50%, rgba(13,13,13,.1) 100%);
}
.hero-content {
  position: relative; z-index: 1;
  padding: 48px 40px; max-width: 640px;
}
.hero-content h1 { font-size: 2.2rem; font-weight: 800; line-height: 1.2; margin-bottom: 12px; text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.hero-content p  { font-size: 1rem; color: rgba(240,240,240,.8); margin-bottom: 20px; line-height: 1.5; text-shadow: 0 1px 6px rgba(0,0,0,.9); }
.btn-hero {
  display: inline-block; padding: 12px 28px; border-radius: 24px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .95rem;
  border: none; cursor: pointer; transition: background .2s, transform .15s;
}
.btn-hero:hover { background: #c1070f; transform: translateY(-2px); }

/* ── Main content ────────────────────────────────────────────────────────── */
main { max-width: 1280px; margin: 0 auto; padding: 40px 24px 80px; }

/* Search results */
#search-results { margin-bottom: 40px; }
#search-results:empty { display: none; }

/* Section */
.section { margin-bottom: 48px; }
.section-title {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

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

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .2s, box-shadow .2s;
  outline: none;
}
.card:hover, .card:focus {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow);
}
.card-img {
  position: relative; aspect-ratio: 2/3; background: var(--surface2);
  overflow: hidden;
}
.card-img img { transition: transform .3s; }
.card:hover .card-img img { transform: scale(1.06); }

.no-img-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center;
  justify-content: center; font-size: 3rem; background: var(--surface2);
}
.no-img-placeholder.big { font-size: 5rem; }

.badge {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 8px; border-radius: 12px; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
}
.badge-filme  { background: #1565c0; color: #fff; }
.badge-serie  { background: #2e7d32; color: #fff; }

.rating {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,.75); padding: 3px 7px;
  border-radius: 10px; font-size: .75rem; font-weight: 600;
}

.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: .9rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-year { font-size: .78rem; color: var(--text-muted); margin-top: 4px; display: block; }

/* ── Skeleton ────────────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton .card-img,
.skel-line {
  background: linear-gradient(90deg, var(--surface2) 25%, #2a2a2a 50%, var(--surface2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
}
.skel-line { height: 14px; border-radius: 6px; margin-top: 10px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.8); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-box {
  position: relative; background: var(--surface);
  border-radius: 14px; max-width: 860px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.9);
}
.modal-close-btn {
  position: absolute; top: 14px; right: 14px; z-index: 10;
  background: rgba(0,0,0,.6); border: none; color: #fff;
  width: 36px; height: 36px; border-radius: 50%; font-size: 1.2rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.modal-close-btn:hover { background: var(--accent); }

.modal-inner {
  display: flex; gap: 28px; padding: 28px;
}
.modal-poster {
  flex-shrink: 0; width: 220px; aspect-ratio: 2/3;
  border-radius: 10px; overflow: hidden; background: var(--surface2);
}
.modal-info { flex: 1; }
.modal-info h2 { font-size: 1.6rem; font-weight: 800; margin: 8px 0 12px; line-height: 1.2; }
.modal-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.meta-item { background: var(--surface2); padding: 4px 10px; border-radius: 16px; font-size: .82rem; }
.meta-genres { font-size: .85rem; color: var(--text-muted); margin-bottom: 14px; }
.modal-overview { font-size: .95rem; line-height: 1.65; color: rgba(240,240,240,.85); margin-bottom: 20px; }
.btn-watch {
  display: inline-block; padding: 10px 22px; border-radius: 22px;
  background: var(--accent); color: #fff; font-weight: 700;
  transition: background .2s;
}
.btn-watch:hover { background: #c1070f; }

.modal-loading {
  display: flex; align-items: center; justify-content: center;
  height: 300px;
}
.spinner {
  width: 42px; height: 42px; border: 4px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Messages ────────────────────────────────────────────────────────────── */
.empty-msg, .error-msg, .searching {
  padding: 40px; text-align: center; color: var(--text-muted); font-size: 1rem;
}
.error-msg { color: #e57373; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border); padding: 32px 24px;
  text-align: center; color: var(--text-muted); font-size: .82rem; line-height: 1.6;
}
footer a { color: var(--text-muted); text-decoration: underline; }
footer a:hover { color: var(--text); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #hamburger { display: flex; }

  nav#nav-menu {
    display: none; position: fixed; top: 60px; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: 12px 16px; gap: 4px; z-index: 99;
  }
  nav#nav-menu.open { display: flex; }
  .nav-link { width: 100%; padding: 10px 16px; border-radius: 8px; }

  .hero { height: 360px; }
  .hero-content { padding: 28px 20px; }
  .hero-content h1 { font-size: 1.5rem; }

  .modal-inner { flex-direction: column; }
  .modal-poster { width: 100%; max-width: 240px; margin: 0 auto; }

  main { padding: 24px 16px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
}

@media (max-width: 480px) {
  .hero { height: 280px; }
  .search-wrap { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .section-title { font-size: 1.1rem; }
}
