/* MovieNest Phase 3 - mobile-first responsive streaming theme.
   Tokens: navy background, coral accent. Contrast: body text #e2e8f0 on
   #0b0e14 (13+ :1), muted #94a3b8 on #0b0e14 (7+ :1). Touch targets
   are at least 44px. No page ever scrolls horizontally: grids reflow,
   tables scroll inside their own container, media never exceeds width. */
:root {
  --bg: #0b0e14;
  --surface: #121826;
  --surface-2: #1f2937;
  --line: #1f2937;
  --input-line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --accent: #ff5e3a;
  --accent-strong: #e5482a;
  --link: #7dd3fc;
  --ok: #22c55e;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}
img, video { max-width: 100%; }
a { color: var(--link); }
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Header + navigation (desktop row, phone drawer) --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(11, 14, 20, 0.96);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.brand span { color: var(--accent); }
.menu-btn {
  margin-left: auto;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.menu-btn span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.main-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  flex-direction: column;
  background: #121826;
  border-bottom: 1px solid var(--line);
  padding: 8px 16px 16px;
}
.main-nav.open { display: flex; }
.main-nav a {
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.main-nav a:last-child { border-bottom: none; }
.main-nav a:hover { color: var(--accent); }
/* Hidden must always win over component display rules (e.g. .main-nav a sets display:flex, which beat the hidden attribute and leaked the Admin link to visitors). */
[hidden] { display: none !important; }

/* --- Page shell --- */
.view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  min-height: 60vh;
}
h1 { color: #ffffff; font-size: clamp(1.5rem, 5vw, 2.25rem); line-height: 1.2; margin: 12px 0; }
h2 { color: #ffffff; font-size: clamp(1.15rem, 4vw, 1.5rem); margin: 24px 0 12px; }
h3 { color: #ffffff; font-size: 1rem; margin: 16px 0 8px; }
p { margin: 8px 0; }

/* --- Hero (featured film, works on phones) --- */
.hero { padding: 20px 0 8px; }
.hero p { color: var(--muted); max-width: 640px; }
.hero-featured {
  background: linear-gradient(135deg, #1e3a5f, #7c2d12);
  border-radius: 14px;
  padding: 24px 20px;
  margin: 4px 0 24px;
  overflow: hidden;
}
.hero-featured h1 { margin: 10px 0; }
.hero-featured p { color: var(--text); max-width: 640px; }
.hero-tag {
  display: inline-block;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.meta { color: var(--muted); font-size: 0.9rem; }

/* --- Pro banner (Home upsell, no price, no payment) --- */
.pro-banner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(135deg, #3b1d5e, #7c2d12);
  border: 1px solid #7c3aed;
  border-radius: 14px;
  padding: 20px;
  margin: 8px 0 24px;
}
.pro-banner h2 { margin: 0; }
.pro-banner p { margin: 0; color: var(--text); }
.pro-banner ul { margin: 0; padding-left: 20px; }
.pro-banner .btn { align-self: flex-start; }

/* --- Poster grid: 2 columns on phones, more as width grows --- */
.row-title { margin-top: 28px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.card-link { text-decoration: none; color: inherit; display: block; min-width: 0; }
.card-link:hover .card { border-color: var(--accent); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
  height: 100%;
}
.card-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}
.poster-fallback {
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  background: linear-gradient(135deg, #1e3a5f, #7c2d12);
}
.poster-fallback span {
  color: #ffffff;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.card-body { padding: 12px; }
.card-body h3 { margin: 0 0 6px; font-size: 1rem; color: #ffffff; overflow-wrap: anywhere; }
.card-body p.meta { margin: 0; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
/* --- Detail page: poster large beside the info --- */
.detail { display: grid; gap: 16px; }
.detail-poster {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.detail-info { min-width: 0; }
.detail-info h1 { margin-top: 0; }
.edit-poster-preview { width: 120px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; display: block; }
.how-line { color: var(--muted); text-align: center; margin: 28px 0 8px; }

/* --- Buttons, forms (44px targets, visible labels) --- */
button, .btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  font-size: 1rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
button:hover, .btn:hover { background: var(--accent-strong); }
button.secondary, .btn.secondary { background: var(--surface-2); }
button.danger { background: #7f1d1d; }
button:disabled { opacity: 0.55; cursor: default; }
form { max-width: 520px; display: grid; gap: 12px; }
form.wide { max-width: none; }
label { font-weight: 600; }
input, textarea, select {
  width: 100%;
  padding: 12px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--input-line);
  background: #0f172a;
  color: var(--text);
  font-size: 1rem;
}
.search-bar {
  display: flex;
  gap: 10px;
  max-width: 640px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.search-bar input { flex: 1 1 200px; min-width: 0; }
.search-bar select { flex: 1 1 160px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.check-row { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check-row input { width: auto; min-height: 0; }

/* --- Notices, steps, tables (tables scroll inside, page never does) --- */
.notice {
  background: var(--surface);
  border: 1px solid var(--input-line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 0;
  overflow-wrap: anywhere;
}
.notice.error { border-color: var(--accent); }
.notice.success { border-color: var(--ok); }
.table-wrap { overflow-x: auto; margin: 16px 0; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td .btn, td button { margin: 2px; }
.steps { display: grid; gap: 12px; grid-template-columns: 1fr; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.step strong { color: #ffffff; }

/* --- Player: 16:9 on every screen, portrait and landscape --- */
.video-wrap {
  background: #000000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
}
.video-wrap video { width: 100%; height: 100%; display: block; object-fit: contain; }

/* --- Ad slots (hidden by default; loader shows only allowed ones) --- */
.ad-slot {
  display: none;
  border: 1px dashed var(--input-line);
  border-radius: 8px;
  margin: 16px auto;
  max-width: 1100px;
  padding: 10px;
  text-align: center;
  color: var(--faint);
  overflow: hidden;
}
.ad-label { font-size: 0.75rem; letter-spacing: 1px; text-transform: uppercase; }
.ad-banner { max-width: 728px; min-height: 90px; }
.ad-slot.ad-preview, #ad-social-host.ad-preview {
  display: block;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 12px;
  margin: 16px auto;
  text-align: center;
  color: var(--muted);
}
#ad-social-host:empty { display: none; }
body[data-view="watch"] .ad-slot,
body[data-view="watch"] #ad-social-host { display: none !important; }
.badge-hidden {
  display: inline-block;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}
.admin-section { margin-top: 36px; }

/* --- Upload progress --- */
.progress-wrap { margin: 12px 0; }
.progress-bar {
  height: 16px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.2s ease; }
.progress-text { color: var(--muted); font-size: 0.9rem; margin-top: 6px; overflow-wrap: anywhere; }

/* --- Contact threads --- */
.thread {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin: 12px 0;
}
.thread .msg { margin: 8px 0; overflow-wrap: anywhere; }
.thread .msg.admin { border-left: 3px solid var(--accent); padding-left: 10px; }
.thread .msg .who { font-weight: 700; color: #ffffff; }
.thread .msg .when { color: var(--muted); font-size: 0.85rem; }

/* --- Footer --- */
.site-footer {
  text-align: center;
  color: var(--faint);
  padding: 24px 12px 40px;
  border-top: 1px solid var(--line);
}
.footer-nav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; }
.footer-nav a {
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
}

/* --- Tablet and up --- */
@media (min-width: 640px) {
  .view { padding: 20px; }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .detail { grid-template-columns: 260px minmax(0, 1fr); }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .pro-banner { flex-direction: row; align-items: center; justify-content: space-between; }
  .pro-banner .btn { flex-shrink: 0; }
  .hero-featured { padding: 32px 28px; }
}
@media (min-width: 900px) {
  .menu-btn { display: none; }
  .main-nav {
    display: flex;
    position: static;
    flex-direction: row;
    gap: 16px;
    flex-wrap: wrap;
    background: transparent;
    border-bottom: none;
    padding: 0;
    margin-left: auto;
  }
  .main-nav a { border-bottom: none; padding: 8px 4px; }
  .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .search-bar select { flex: 0 0 180px; }
}
@media (min-width: 1200px) {
  .card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
/* Phone landscape: banner never exceeds phone width, player stays 16:9. */
@media (max-width: 640px) {
  .ad-banner { max-width: 300px; min-height: 250px; }
}
@media (prefers-reduced-motion: reduce) {
  .progress-fill { transition: none; }
}
