/* M14321 — cinematic dark theme. No external fonts or libraries. */
:root {
  --bg: #0b0c0f;
  --surface: #14161b;
  --surface-2: #1b1e25;
  --line: #272b35;
  --text: #eceef2;
  --muted: #9ba2af;
  --accent: #f4b740;
  --accent-ink: #1a1305;
  --radius: 14px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans);
}
main { flex: 1; outline: none; }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.muted { color: var(--muted); }
.wrap { width: min(1280px, 100% - 2rem); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; border-radius: 8px; font-weight: 700; text-decoration: none; }
.skip:focus { top: .75rem; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(11, 12, 15, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding-block: .75rem; }
.logo { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: .02em; }
.logo-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-family: var(--sans); font-weight: 900; }
.logo-text { font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.menu-btn { margin-left: auto; width: 44px; height: 44px; display: grid; place-items: center; background: transparent; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.menu-icon, .menu-icon::before, .menu-icon::after { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; content: ""; }
.menu-icon { position: relative; }
.menu-icon::before { position: absolute; top: -6px; }
.menu-icon::after { position: absolute; top: 6px; }
.site-nav { display: none; flex-direction: column; width: 100%; order: 3; gap: .25rem; }
.site-nav.open { display: flex; }
.site-nav a { padding: .6rem .75rem; border-radius: 8px; text-decoration: none; color: var(--muted); }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
.search { order: 2; width: 100%; position: relative; }
.search input { width: 100%; height: 44px; padding: 0 3rem 0 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.search input::placeholder { color: var(--muted); }
.search input:focus-visible { outline-offset: 2px; border-color: var(--accent); }
.search-btn { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; display: grid; place-items: center; background: transparent; border: 0; border-radius: 999px; cursor: pointer; color: var(--muted); }
.search-btn:hover { color: var(--accent); }
.search-btn svg { width: 20px; height: 20px; }
@media (min-width: 860px) {
  .menu-btn { display: none; }
  .site-nav { display: flex; flex-direction: row; width: auto; order: 0; margin-right: auto; }
  .search { order: 0; width: min(340px, 34vw); }
}

/* ---------- Buttons, chips, states ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: 0 1.25rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-decoration: none; font-weight: 600; cursor: pointer; transition: background-color .15s, border-color .15s; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ffc85c; border-color: #ffc85c; }
.btn.is-disabled { opacity: .45; pointer-events: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { padding: .3rem .8rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .9rem; }
.chip-accent { background: rgba(244, 183, 64, .12); border-color: rgba(244, 183, 64, .5); color: var(--accent); font-weight: 700; }
.state { display: grid; justify-items: center; gap: 1rem; padding: 3rem 1rem; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.state h1 { color: var(--text); }
.state-lg { margin-top: 3rem; padding-block: 5rem; }

.skeleton, .sk-line { background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--radius); }
.sk-line { height: 1em; margin-top: .75rem; border-radius: 6px; }
.sk-line.w60 { width: 60%; } .sk-line.w90 { width: 90%; } .sk-line.title { height: 2.4rem; width: min(480px, 80%); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Hero ---------- */
.hero { position: relative; display: flex; align-items: flex-end; min-height: clamp(420px, 72vh, 660px); overflow: hidden; background: radial-gradient(120% 90% at 80% 0%, #2a2230 0%, #15161c 45%, var(--bg) 100%); }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 3%, rgba(11, 12, 15, .5) 45%, rgba(11, 12, 15, .2)), linear-gradient(to right, rgba(11, 12, 15, .85), transparent 65%); }
.hero-content { position: relative; z-index: 1; padding-block: 2.5rem 3rem; display: grid; gap: .9rem; justify-items: start; }
.hero-content > * { max-width: 640px; }
.hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.8rem); line-height: 1.04; text-wrap: balance; }
.hero-label { color: var(--accent); font-weight: 600; }
.hero-meta { display: flex; gap: .75rem; align-items: center; color: var(--muted); font-weight: 600; }
.hero-meta .rating { color: var(--accent); }
.hero-overview { color: #d3d7de; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Shelves, cards, grid ---------- */
.shelf { padding-top: 2.5rem; scroll-margin-top: 90px; }
.shelf:last-of-type { padding-bottom: 3rem; }
.shelf h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: 1rem; }
.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: clamp(140px, 17vw, 200px); gap: 1rem; overflow-x: auto; padding-bottom: 1rem; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.carousel > li { scroll-snap-align: start; }
.carousel:focus-visible { outline-offset: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.25rem 1rem; }
.card { display: block; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; transition: transform .2s ease, border-color .2s ease; }
.card:hover { transform: translateY(-3px); border-color: #3a4050; }
.card:focus-visible { outline-offset: 2px; border-radius: var(--radius); }
.card-media { position: relative; aspect-ratio: 2 / 3; background: var(--surface-2); }
.poster { width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; top: .5rem; right: .5rem; padding: .15rem .55rem; border-radius: 999px; background: rgba(11, 12, 15, .85); color: var(--accent); font-size: .85rem; font-weight: 700; }
.card-body { padding: .7rem .8rem .9rem; }
.card-title { font-family: var(--sans); font-size: .95rem; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.sk-card { aspect-ratio: 2 / 3.6; }
.more-btn { width: 100%; height: 100%; min-height: 200px; border: 1px dashed var(--line); background: transparent; border-radius: var(--radius); color: var(--muted); cursor: pointer; padding: 1rem; }
.more-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.more { display: block; }

/* ---------- Search page ---------- */
.page { padding-block: 2rem 3rem; }
.page-title { font-size: clamp(1.6rem, 4vw, 2.4rem); margin-bottom: .5rem; overflow-wrap: anywhere; }
.result-count { color: var(--muted); margin-bottom: 1.5rem; }
.pager { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 1rem; margin-top: 2.5rem; }
.pager-info { color: var(--muted); }

/* ---------- Movie detail ---------- */
.detail { position: relative; }
.detail-backdrop { position: absolute; inset: 0 0 auto 0; height: clamp(260px, 55vw, 560px); overflow: hidden; background: linear-gradient(135deg, #22212b, var(--bg)); }
.backdrop-img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; opacity: .75; }
.detail-backdrop .hero-shade { background: linear-gradient(to top, var(--bg) 2%, rgba(11, 12, 15, .35) 70%); }
.detail-inner { position: relative; z-index: 1; padding-top: 1.5rem; padding-bottom: 3.5rem; }
.detail-grid { display: grid; gap: 1.5rem; margin-top: clamp(4rem, 20vw, 14rem); }
.detail-poster { width: min(240px, 60%); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); box-shadow: 0 20px 50px rgba(0, 0, 0, .55); aspect-ratio: 2 / 3; }
.detail-poster img { width: 100%; height: 100%; object-fit: cover; }
.detail-info { display: grid; gap: 1rem; align-content: start; min-width: 0; }
.detail-info h1 { font-size: clamp(1.9rem, 5vw, 3rem); text-wrap: balance; }
.detail-info h1 .year { color: var(--muted); font-weight: 400; }
.tagline { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 1.1rem; }
.detail-info h2 { font-size: 1.25rem; margin-top: .5rem; }
.overview { max-width: 70ch; color: #d3d7de; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem 1.5rem; margin-top: .5rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { overflow-wrap: anywhere; }
.facts a { color: var(--accent); }
.detail-skel { height: 70vh; margin-top: 1.5rem; }
@media (min-width: 760px) {
  .detail-grid { grid-template-columns: 280px 1fr; gap: 2.5rem; }
  .detail-poster { width: 100%; }
}

/* ---------- Footer and static pages ---------- */
.site-footer { border-top: 1px solid var(--line); background: #08090b; padding-block: 2rem; }
.footer-grid { display: grid; gap: 1.25rem; }
.footer-nav { display: flex; gap: 1.25rem; }
.footer-nav a { color: var(--muted); }
.footer-nav a:hover { color: var(--text); }
.attribution { color: var(--muted); font-size: .9rem; max-width: 70ch; }
.attribution a { color: var(--text); }
@media (min-width: 860px) { .footer-grid { grid-template-columns: 1fr auto; } .attribution { grid-column: 1 / -1; } }
.prose { max-width: 70ch; display: grid; gap: 1rem; }
.prose h1 { font-size: clamp(2rem, 5vw, 2.8rem); }
.prose h2 { font-size: 1.35rem; margin-top: 1rem; }
.prose li { margin-left: 1.2rem; list-style: disc; }
.prose a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card:hover { transform: none; }
}
