/* ==========================================================
   CineSearch — style.css
   Cinematic dark theme · amber/gold accents · fully responsive
   ========================================================== */

/* ── 1. CSS VARIABLES ─────────────────────────────────────── */
:root {
  --bg:          #0c0c0f;
  --surface:     #141418;
  --surface-2:   #1c1c24;
  --border:      #2a2a38;
  --gold:        #e8b84b;
  --gold-light:  #f5d07a;
  --text:        #e8e6df;
  --muted:       #7a7880;
  --danger:      #e05c5c;
  --radius:      14px;
  --radius-sm:   8px;
  --max-w:       1200px;
  --gap:         22px;
  --ease:        cubic-bezier(0.22, 1, 0.36, 1);
  --font-head:   'Playfair Display', Georgia, serif;
  --font-body:   'DM Sans', system-ui, sans-serif;
}

/* ── 2. RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { scroll-behavior: smooth; }
body  {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img   { display: block; max-width: 100%; }
a     { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold-light); }
kbd   {
  display: inline-block; padding: 1px 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; font-size: .78em; color: var(--gold);
}
[hidden] { display: none !important; }

/* ── 3. GRAIN OVERLAY ─────────────────────────────────────── */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

/* ── 4. LAYOUT ────────────────────────────────────────────── */
.page-wrapper {
  display: flex; flex-direction: column; min-height: 100dvh;
  max-width: var(--max-w); margin-inline: auto;
  padding: 0 clamp(16px, 4vw, 40px);
}
.content-area { flex: 1; }

/* ── 5. HEADER ────────────────────────────────────────────── */
.site-header {
  padding: 48px 0 28px; text-align: center;
  animation: fadeDown .7s var(--ease) both;
}
.logo {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.logo-icon {
  font-size: 1.5rem; color: var(--gold);
  animation: pulseGlow 3s ease-in-out infinite;
}
.logo-text {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800; letter-spacing: -.5px;
}
.logo-text em { font-style: italic; color: var(--gold); }
.tagline { color: var(--muted); font-size: .9rem; font-weight: 300; letter-spacing: .3px; }

/* ── 6. SEARCH ────────────────────────────────────────────── */
.search-section {
  padding-bottom: 36px;
  animation: fadeDown .7s .1s var(--ease) both;
}
.search-form {
  display: flex; gap: 12px; align-items: center;
  max-width: 680px; margin-inline: auto;
}
.input-wrap { position: relative; flex: 1; }

.search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px;
  stroke: var(--muted); stroke-width: 2; fill: none; stroke-linecap: round;
  pointer-events: none; transition: stroke .2s;
}
.input-wrap:focus-within .search-icon { stroke: var(--gold); }

.search-input {
  width: 100%; padding: 14px 44px 14px 46px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font-body); font-size: 1rem;
  outline: none; transition: border-color .25s, box-shadow .25s;
  -webkit-appearance: none; appearance: none;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,184,75,.15);
}
/* Remove browser's native clear button */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { display: none; }

.clear-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted);
  font-size: .75rem; cursor: pointer; padding: 4px; line-height: 1;
  transition: color .2s;
}
.clear-btn:hover { color: var(--text); }

.search-btn {
  flex-shrink: 0; padding: 14px 26px;
  background: var(--gold); border: none; border-radius: var(--radius-sm);
  color: #0c0c0f; font-family: var(--font-body);
  font-size: .95rem; font-weight: 500; cursor: pointer;
  transition: background .2s, transform .15s, box-shadow .2s;
}
.search-btn:hover {
  background: var(--gold-light);
  box-shadow: 0 4px 20px rgba(232,184,75,.3);
}
.search-btn:active { transform: scale(.97); }

/* ── 7. HERO STATE ────────────────────────────────────────── */
.hero-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 40px 20px 80px;
  animation: fadeUp .6s .2s var(--ease) both;
}
.hero-icon {
  font-size: clamp(3rem, 8vw, 5rem); margin-bottom: 20px;
  filter: drop-shadow(0 0 28px rgba(232,184,75,.35));
  animation: float 4s ease-in-out infinite;
}
.hero-title {
  font-family: var(--font-head); font-size: clamp(1.3rem, 3.5vw, 2rem);
  font-weight: 700; margin-bottom: 12px; max-width: 460px;
}
.hero-sub { color: var(--muted); font-size: .9rem; margin-bottom: 32px; max-width: 360px; }

.genre-pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.genre-pills span {
  padding: 5px 14px; border: 1px solid var(--border);
  border-radius: 99px; font-size: .78rem; color: var(--muted);
  letter-spacing: .3px; opacity: 0;
  animation: fadeUp .5s var(--ease) forwards;
}
.genre-pills span:nth-child(1){animation-delay:.4s}
.genre-pills span:nth-child(2){animation-delay:.5s}
.genre-pills span:nth-child(3){animation-delay:.6s}
.genre-pills span:nth-child(4){animation-delay:.7s}
.genre-pills span:nth-child(5){animation-delay:.8s}
.genre-pills span:nth-child(6){animation-delay:.9s}

/* ── 8. LOADER ────────────────────────────────────────────── */
.loader-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 80px 20px; gap: 20px;
}
.spinner { position: relative; width: 60px; height: 60px; }
.reel {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2.5px solid transparent;
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
.reel--2 { inset: 8px; border-top-color: var(--gold-light); animation-duration: .75s; animation-direction: reverse; }
.reel--3 { inset: 16px; border-top-color: rgba(232,184,75,.4); animation-duration: 1.4s; }
.loader-text { color: var(--muted); font-size: .88rem; letter-spacing: .4px; }

/* ── 9. ERROR STATE ───────────────────────────────────────── */
.error-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 60px 20px;
  animation: fadeUp .4s var(--ease);
}
.error-icon  { font-size: 3rem; margin-bottom: 14px; opacity: .5; filter: grayscale(1); }
.error-title { font-family: var(--font-head); font-size: 1.4rem; color: var(--danger); margin-bottom: 8px; }
.error-sub   { color: var(--muted); font-size: .88rem; max-width: 320px; }

/* ── 10. RESULTS GRID ─────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: var(--gap);
  padding-bottom: 60px;
}

/* ── 11. MOVIE CARD ───────────────────────────────────────── */
.movie-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; cursor: default;
  opacity: 0; transform: translateY(24px);
  animation: cardIn .5s var(--ease) forwards;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .3s;
}
.movie-card:hover {
  transform: translateY(-6px) scale(1.015);
  box-shadow: 0 20px 50px rgba(0,0,0,.6), 0 0 0 1px var(--gold);
  border-color: var(--gold);
}

/* Poster */
.card-poster {
  position: relative; aspect-ratio: 2/3;
  overflow: hidden; background: var(--surface-2);
}
.card-poster img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .5s var(--ease), filter .4s;
}
.movie-card:hover .card-poster img { transform: scale(1.06); filter: brightness(1.08); }

/* Gradient overlay on poster */
.card-poster::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(12,12,15,.85) 0%, transparent 50%);
}

/* Year badge */
.card-year {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  background: rgba(12,12,15,.75); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 2px 8px; font-size: .7rem; font-weight: 500;
  color: var(--gold); letter-spacing: .3px;
}

/* Type / description badge */
.card-type {
  position: absolute; bottom: 10px; left: 10px; z-index: 1;
  background: var(--gold); color: #0c0c0f;
  border-radius: 4px; padding: 2px 8px;
  font-size: .65rem; font-weight: 500;
  letter-spacing: .5px; text-transform: uppercase;
  max-width: calc(100% - 20px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* No-poster fallback */
.poster-fallback {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; color: var(--muted); font-size: .8rem;
  background: var(--surface-2);
}
.poster-fallback .fi { font-size: 2.5rem; opacity: .35; }

/* Card body */
.card-body {
  padding: 14px 16px 16px; display: flex;
  flex-direction: column; gap: 6px; flex: 1;
}
.card-title {
  font-family: var(--font-head); font-size: .95rem; font-weight: 700;
  color: var(--text); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  transition: color .2s;
}
.movie-card:hover .card-title { color: var(--gold-light); }

.card-plot {
  font-size: .8rem; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-link {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: auto; padding-top: 10px;
  font-size: .76rem; font-weight: 500; color: var(--gold);
  border-top: 1px solid var(--border);
  transition: gap .2s, color .2s;
}
.card-link:hover { color: var(--gold-light); gap: 8px; }

/* ── 12. FOOTER ───────────────────────────────────────────── */
.site-footer {
  padding: 22px 0; text-align: center;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: .8rem;
}

/* ── 13. ANIMATIONS ───────────────────────────────────────── */
@keyframes fadeDown { from{opacity:0;transform:translateY(-16px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeUp   { from{opacity:0;transform:translateY(16px)}  to{opacity:1;transform:translateY(0)} }
@keyframes cardIn   { to{opacity:1;transform:translateY(0)} }
@keyframes spin     { to{transform:rotate(360deg)} }
@keyframes float    { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
@keyframes pulseGlow{
  0%,100%{text-shadow:0 0 8px rgba(232,184,75,.3)}
  50%    {text-shadow:0 0 24px rgba(232,184,75,.8)}
}

/* ── 14. RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  .search-form { flex-direction: column; gap: 10px; }
  .search-btn  { width: 100%; padding: 13px; }
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; }
}
@media (max-width: 480px) {
  .results-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card-body    { padding: 10px 12px 12px; }
  .card-plot    { display: none; }
  .card-title   { font-size: .88rem; }
}
@media (max-width: 320px) {
  .results-grid { grid-template-columns: 1fr; }
}