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

:root {
  --cream:        #fdf6ec;
  --cream-dark:   #f5e9d6;
  --cream-mid:    #eedfc7;
  --accent:       #c8854a;
  --accent-soft:  #e4a96f;
  --text:         #3d2b1f;
  --text-muted:   #8a6a55;
  --glass-bg:     rgba(255, 248, 238, 0.55);
  --glass-border: rgba(200, 133, 74, 0.25);
  --shadow:       0 8px 32px rgba(100, 60, 20, 0.12);
  --radius:       14px;
  --transition:   0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --cream:        #1a1410;
  --cream-dark:   #241c14;
  --cream-mid:    #2e2318;
  --accent:       #e4a96f;
  --accent-soft:  #c8854a;
  --text:         #f0e0c8;
  --text-muted:   #a08060;
  --glass-bg:     rgba(30, 22, 14, 0.65);
  --glass-border: rgba(228, 169, 111, 0.2);
  --shadow:       0 8px 32px rgba(0, 0, 0, 0.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 2px 20px rgba(100, 60, 20, 0.08);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity var(--transition);
}
.logo:hover { opacity: 0.75; }

.search-wrap {
  display: flex;
  gap: 10px;
  flex: 1;
  max-width: 520px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  padding: 10px 18px;
  border: 1.5px solid var(--glass-border);
  border-radius: 50px;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(8px);
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
[data-theme="dark"] .search-input { background: rgba(0,0,0,0.3); }
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(200,133,74,0.15);
}

/* ===== Glass Button ===== */
.btn-glass {
  padding: 10px 22px;
  border-radius: 50px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-glass:hover:not(:disabled) {
  background: rgba(200, 133, 74, 0.15);
  border-color: var(--accent-soft);
  box-shadow: 0 4px 18px rgba(200, 133, 74, 0.25);
  transform: translateY(-2px);
}
.btn-glass:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.btn-glass:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-icon { padding: 10px 14px; }
.active-link { background: rgba(200,133,74,0.15); border-color: var(--accent-soft); }

/* ===== Tabs ===== */
.tabs-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 28px 0 0;
}

.tab {
  padding: 8px 18px;
  border-radius: 50px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
}
.tab:hover { color: var(--accent); border-color: var(--accent-soft); }
.tab.active {
  background: rgba(200,133,74,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Genre Filters ===== */
.genre-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 0;
}

.genre-btn {
  padding: 6px 14px;
  border-radius: 50px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.genre-btn:hover { color: var(--accent); border-color: var(--accent-soft); }
.genre-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== Container ===== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 52px 0 32px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.5px;
}
.hero p { margin-top: 10px; font-size: 1.1rem; color: var(--text-muted); }

/* ===== Section title ===== */
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 24px 0 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--cream-mid);
}

/* ===== Movies Grid ===== */
.movies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

/* ===== Movie Card ===== */
.movie-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}
.movie-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 40px rgba(100, 60, 20, 0.18);
}

/* fade-in animation */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeInUp 0.45s ease forwards;
}
@keyframes fadeInUp {
  to { opacity: 1; transform: translateY(0); }
}

.movie-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--cream-mid);
}
.movie-poster-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: linear-gradient(135deg, var(--cream-mid), var(--cream-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.movie-info { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.movie-title { font-size: 0.95rem; font-weight: 700; line-height: 1.3; }
.movie-year { font-size: 0.82rem; color: var(--text-muted); }
.movie-rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: auto;
}

/* ===== Movie Banner ===== */
.movie-banner {
  width: 100%;
  height: 340px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}
.movie-banner-placeholder { display: none; }

/* ===== Detail Page ===== */
.detail-wrap {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}
.detail-poster {
  width: 260px;
  flex-shrink: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  object-fit: cover;
}
.detail-poster-placeholder {
  width: 260px;
  flex-shrink: 0;
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  background: var(--cream-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
}
.detail-info { flex: 1; min-width: 260px; }
.detail-info h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.meta-tag {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 4px 14px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  backdrop-filter: blur(8px);
}
.meta-tag.accent { color: var(--accent); }
.detail-overview { font-size: 1rem; line-height: 1.7; color: var(--text-muted); margin-top: 20px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: gap var(--transition);
}
.back-link:hover { gap: 10px; }
.genres-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ===== Fav button ===== */
.fav-btn {
  margin-top: 20px;
  padding: 10px 24px;
  border-radius: 50px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
}
.fav-btn:hover {
  background: rgba(200,133,74,0.15);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(200,133,74,0.2);
}
.fav-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ===== Loader ===== */
.loader {
  text-align: center;
  padding: 60px;
  font-size: 1rem;
  color: var(--text-muted);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== No results ===== */
.no-results { text-align: center; padding: 60px; font-size: 1.1rem; color: var(--text-muted); }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 48px; }
.page-info { font-size: 0.95rem; color: var(--text-muted); }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--cream-mid);
}
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-nav {
  margin-top: 8px;
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Smooth theme switch (no flash) ===== */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
  transition:
    background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    color            0.3s cubic-bezier(0.4, 0, 0.2, 1),
    border-color     0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow       0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .header-inner { padding: 12px 16px; }
  .container { padding: 0 16px 40px; }
  .movies-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .detail-wrap { flex-direction: column; }
  .detail-poster, .detail-poster-placeholder { width: 100%; max-width: 260px; }
  .movie-banner { height: 200px; }
  .header-actions .btn-glass span { display: none; }
}
