/* 347movies — dark cinema aesthetic, poster-first, mobile-first. No inline styles anywhere. */

:root {
  --bg: #0b0b10;
  --surface: #14141d;
  --surface-2: #1b1b27;
  --border: #26263a;
  --text: #ece9e2;
  --muted: #9c98a8;
  --accent: #f2a93b;
  --radius: 10px;
  --maxw: 1120px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

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

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

button {
  font-family: inherit;
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  left: 8px;
  top: 8px;
  width: auto;
  height: auto;
  z-index: 100;
  background: var(--accent);
  color: #17130a;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 11, 16, 0.92);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.brand::before {
  content: "\25B6";
  font-size: 0.75em;
  margin-right: 7px;
  vertical-align: 1px;
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 18px;
  font-size: 0.95rem;
}

.site-nav a {
  color: var(--muted);
}

.site-nav a:hover {
  color: var(--text);
}

.header-search {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.header-search input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  width: 200px;
  font-size: 0.9rem;
}

.header-search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.header-search button {
  background: var(--accent);
  border: 0;
  color: #17130a;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- hero ---------- */
.hero {
  padding: 48px 0 36px;
  text-align: center;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5vw, 3rem);
  margin: 0 0 10px;
  letter-spacing: 0.3px;
}

.hero-sub {
  color: var(--muted);
  margin: 0 auto 26px;
  max-width: 560px;
}

.hero-search {
  display: flex;
  justify-content: center;
}

.hero-search form {
  display: flex;
  gap: 8px;
  width: min(560px, 100%);
}

.hero-search input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 1rem;
}

.hero-search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.hero-search button {
  background: var(--accent);
  border: 0;
  color: #17130a;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
}

.genre-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
}

.genre-chip:hover,
.genre-chip.is-active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- sections & grids ---------- */
.section {
  padding: 24px 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0;
}

.see-all {
  color: var(--accent);
  font-size: 0.85rem;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1120px) {
  .grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card__main {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Watchlist save toggle (localStorage only — never sent to any server, vow 5/11). */
.watch-btn {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top: 0;
  color: var(--muted);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.watch-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.watch-btn.is-saved {
  color: var(--accent);
  border-color: var(--accent);
}

.watch-btn--hero {
  width: auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  margin-top: 12px;
}

.watchlist-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 16px;
}

.watch-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  cursor: pointer;
}

.watch-clear:hover {
  color: #e07a7a;
  border-color: #e07a7a;
}

.watchlist-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 8px;
}

.card__poster {
  aspect-ratio: 3 / 4;
  width: 100%;
  object-fit: cover;
  background: var(--surface-2);
}

.card__poster--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 1px;
}

.card__body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card__title {
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
}

.card__year {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- ad slots (constitution §4 / vow 2: never over or inside the player) ---------- */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 90px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  padding: 12px;
}

.ad-slot__label {
  color: var(--text);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.72rem;
}

.ad-slot__note {
  max-width: 460px;
}

.ad-slot__note a {
  color: var(--accent);
  text-decoration: underline;
}

.ad-slot--leaderboard {
  min-height: 90px;
  margin: 8px 0 24px;
}

.ad-slot--sidebar {
  min-height: 250px;
}

/* ---------- movie detail ---------- */
.movie {
  display: grid;
  gap: 24px;
  padding: 24px 0 48px;
}

@media (min-width: 900px) {
  .movie {
    grid-template-columns: 1fr 300px;
  }
}

.movie-main,
.movie-side {
  min-width: 0;
}

.player-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}

.player-wrap iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.movie-head {
  margin-top: 20px;
}

.movie-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  margin: 0 0 6px;
}

.movie-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.chip--license {
  color: var(--accent);
  border-color: var(--accent);
}

.movie-body {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

@media (min-width: 900px) {
  .movie-body {
    grid-template-columns: 220px 1fr;
  }
}

.movie-poster {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
}

.movie-poster--empty {
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 1px;
}

.movie-info h2 {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 18px 0 6px;
}

.movie-info p {
  margin: 0 0 10px;
  color: #cfcbd8;
}

.movie-desc {
  white-space: pre-line;
}

.movie-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.source-link,
.back-link {
  color: var(--accent);
  font-size: 0.9rem;
}

.affiliate-slot {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.affiliate-note {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0 0 8px;
}

.affiliate-link {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.92rem;
}

/* ---------- search / browse ---------- */
.page-head {
  padding: 32px 0 8px;
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin: 0 0 6px;
}

.page-head .count {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 16px 0 12px;
}

.filters .genre-chips {
  justify-content: flex-start;
  margin: 0;
}

.filters select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 0 8px;
}

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

.pagination span {
  color: var(--muted);
  font-size: 0.9rem;
}

.pagination .pagination__current {
  color: var(--text);
}

.empty,
.error-box {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.error-box .retry {
  margin-top: 12px;
  background: var(--accent);
  color: #17130a;
  border: 0;
  border-radius: 999px;
  padding: 9px 20px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- prose pages ---------- */
.prose {
  max-width: 720px;
  padding: 32px 0 48px;
}

.prose h1 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  margin: 0 0 8px;
}

.prose h2 {
  font-size: 1.15rem;
  margin-top: 28px;
}

.prose p,
.prose li {
  color: #cfcbd8;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
}

.prose ul {
  padding-left: 20px;
}

/* ---------- 404 ---------- */
.notfound {
  text-align: center;
  padding: 80px 0;
}

.notfound h1 {
  font-family: var(--font-display);
  font-size: 4rem;
  margin: 0;
  color: var(--accent);
}

.notfound p {
  color: var(--muted);
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 28px 0 40px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-tag {
  font-family: var(--font-display);
  color: var(--accent);
  margin: 0;
}

.site-footer nav {
  display: flex;
  gap: 16px;
}

.site-footer nav a {
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-note {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
  max-width: 640px;
}

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
