:root {
  --bg: #0b0b10;
  --bg-soft: #121219;
  --surface: #1a1a24;
  --surface-2: #23232f;
  --line: #2c2c3a;
  --text: #f3f1ea;
  --muted: #9a98a6;
  --gold: #e8b84b;
  --gold-soft: #f0cd78;
  --radius: 14px;
  --shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(232, 184, 75, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(80, 90, 160, 0.10), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
img { display: block; }

/* ----------------------------- الشريط العلوي ----------------------------- */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 48px;
  background: linear-gradient(to bottom, rgba(11, 11, 16, 0.96), rgba(11, 11, 16, 0.55) 70%, transparent);
  backdrop-filter: blur(6px);
}

.brand {
  font-family: "Readex Pro", sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.5px;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px var(--gold);
}

nav { display: flex; gap: 6px; }
nav a {
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.98rem;
  transition: all 0.18s ease;
  cursor: pointer;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--bg); background: var(--gold); font-weight: 600; }

.spacer { flex: 1; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  width: 240px;
  transition: width 0.25s ease, border-color 0.2s;
}
.search-box:focus-within { border-color: var(--gold); width: 300px; }
.search-box input {
  background: none; border: none; outline: none;
  color: var(--text); width: 100%; font-family: inherit; font-size: 0.95rem;
}
.search-box svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }

.admin-btn {
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  transition: all 0.18s;
}
.admin-btn:hover { color: var(--gold); border-color: var(--gold); }

/* ------------------------------- الواجهة ------------------------------- */
main { position: relative; z-index: 1; padding-bottom: 80px; }

/* البطل */
.hero {
  position: relative;
  min-height: 64vh;
  margin-bottom: 8px;
  overflow: hidden;
}
.hero-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 48px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .7s ease;
}
.hero-slide.active {
  opacity: 1;
  pointer-events: auto;
}
.hero-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: saturate(1.05);
  transform: scale(1.02);
  transition: transform 5.2s ease;
}
.hero-slide.active .hero-bg {
  transform: scale(1.08);
}
.hero-bg::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(to top, var(--bg) 4%, transparent 55%),
    linear-gradient(to left, var(--bg) 0%, transparent 50%);
}
.hero-content { position: relative; max-width: 620px; }
.hero-tag {
  display: inline-block;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 2px;
  font-size: 0.8rem;
  margin-bottom: 14px;
}
.hero h1 {
  font-family: "Readex Pro", sans-serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.1;
  margin-bottom: 16px;
}
.hero p { color: #d6d4cc; font-size: 1.05rem; line-height: 1.7; max-width: 540px; margin-bottom: 26px; }
.hero-actions { display: flex; gap: 14px; }
.hero-dots {
  position: absolute;
  z-index: 3;
  left: 48px;
  bottom: 36px;
  display: flex;
  gap: 8px;
  direction: ltr;
}
.hero-dots button {
  width: 9px;
  height: 9px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.34);
  cursor: pointer;
  transition: width .2s ease, background .2s ease;
}
.hero-dots button.active {
  width: 28px;
  background: var(--gold);
}

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 30px;
  border-radius: 999px;
  font-family: inherit; font-size: 1rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: transform 0.15s ease, box-shadow 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-play { background: var(--gold); color: #16130a; box-shadow: 0 10px 30px -8px var(--gold); }
.btn-play:hover { background: var(--gold-soft); }
.btn-ghost { background: rgba(255, 255, 255, 0.08); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

/* الصفوف */
.row { padding: 0 48px; margin-top: 38px; }
.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.row h2 {
  font-family: "Readex Pro", sans-serif;
  font-size: 1.3rem; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.row h2::before { content: ""; width: 4px; height: 22px; background: var(--gold); border-radius: 4px; }
.show-all,
.back-btn {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
}
.show-all:hover,
.back-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.track-wrap {
  position: relative;
}
.track-wrap::before,
.track-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 12px;
  width: 72px;
  z-index: 2;
  pointer-events: none;
}
.track-wrap::before {
  right: 0;
  background: linear-gradient(to left, var(--bg), transparent);
}
.track-wrap::after {
  left: 0;
  background: linear-gradient(to right, var(--bg), transparent);
}
.track-wrap.no-scroll::before,
.track-wrap.no-scroll::after {
  display: none;
}
.track {
  display: flex; gap: 16px;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}
.track::-webkit-scrollbar { height: 8px; }
.track::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 8px; }
.track-nav {
  position: absolute;
  top: calc(50% - 18px);
  z-index: 4;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  background: rgba(26,26,36,.78);
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 14px 34px -16px #000;
  backdrop-filter: blur(8px);
  transition: opacity .18s ease, transform .18s ease, border-color .18s ease, color .18s ease;
}
.track-nav:hover {
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-1px);
}
.track-nav-prev { right: 8px; }
.track-nav-next { left: 8px; }
.track-nav.disabled,
.track-wrap.no-scroll .track-nav {
  opacity: 0;
  pointer-events: none;
}

.card {
  flex: 0 0 auto;
  width: 190px;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform 0.22s ease;
}
.card:hover { transform: translateY(-6px); }
.card .poster {
  width: 100%; aspect-ratio: 2/3;
  border-radius: var(--radius);
  background: var(--surface) center/cover no-repeat;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card.live .poster { aspect-ratio: 16/10; }
.card .poster::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.55), transparent 45%);
  opacity: 0; transition: opacity 0.2s;
}
.card:hover .poster::after { opacity: 1; }
.card .poster img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.card .poster .ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 2rem;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
}
.card .live-badge {
  position: absolute; top: 10px; right: 10px;
  background: #e23b3b; color: #fff;
  font-size: 0.7rem; font-weight: 700;
  padding: 3px 9px; border-radius: 6px;
  display: flex; align-items: center; gap: 5px;
}
.card .live-badge .pulse {
  width: 6px; height: 6px; border-radius: 50%; background: #fff;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.card .title {
  margin-top: 10px; font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.category-page {
  padding: 38px 48px 80px;
}
.category-head {
  margin: 26px 0 24px;
}
.category-head span {
  color: var(--gold);
  font-weight: 700;
  font-size: .85rem;
}
.category-head h1 {
  font-family: "Readex Pro", sans-serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.15;
  margin: 8px 0;
}
.category-head p {
  color: var(--muted);
}
.grid-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 24px 16px;
}
.grid-catalog .card {
  width: 100%;
}
.load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 190px;
  max-width: 100%;
  margin: 38px auto 0;
  border: 1px solid rgba(232, 184, 75, .45);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #16130a;
  border-radius: 999px;
  padding: 13px 30px;
  font-family: inherit;
  font-weight: 700;
  font-size: .98rem;
  cursor: pointer;
  box-shadow: 0 12px 30px -14px var(--gold);
  transition: transform .16s ease, box-shadow .18s ease, background .18s ease;
}
.load-more:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px -14px var(--gold);
}
.load-more:disabled {
  cursor: wait;
  opacity: .72;
  transform: none;
}

/* حالات */
.state {
  text-align: center; padding: 90px 24px; color: var(--muted);
}
.state .big { font-size: 1.3rem; color: var(--text); margin-bottom: 10px; font-family: "Readex Pro"; }
.state a { color: var(--gold); }

.loader {
  width: 38px; height: 38px; margin: 90px auto;
  border: 3px solid var(--surface-2); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------- المشغّل ------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 5, 8, 0.92);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
}
.modal.open { display: flex; }
.player-shell {
  width: min(1100px, 100%);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.player-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.player-head h3 { font-family: "Readex Pro"; font-size: 1.1rem; }
.close-x {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.close-x:hover { color: var(--gold); }
video { width: 100%; aspect-ratio: 16/9; background: #000; display: block; }

/* تفاصيل المسلسل */
.series-detail { padding: 20px; max-height: 80vh; overflow-y: auto; }
.season-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.season-tabs button {
  padding: 7px 16px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-family: inherit;
}
.season-tabs button.active { background: var(--gold); color: #16130a; border-color: var(--gold); }
.episodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.episode {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; transition: all 0.15s;
}
.episode:hover { border-color: var(--gold); background: var(--surface-2); }
.episode .n {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px;
  background: var(--gold); color: #16130a; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
}

footer {
  position: relative; z-index: 1;
  padding: 30px 48px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.85rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}

@media (max-width: 720px) {
  header { padding: 14px 18px; gap: 14px; flex-wrap: wrap; }
  nav { order: 3; width: 100%; overflow-x: auto; }
  .search-box { width: 150px; }
  .search-box:focus-within { width: 180px; }
  .hero, .row, footer, .category-page { padding-left: 18px; padding-right: 18px; }
  .hero-slide { padding: 38px 18px; }
  .hero-dots { left: 18px; bottom: 22px; }
  .row-head { align-items: flex-start; }
  .show-all { padding: 7px 12px; font-size: .85rem; }
  .track-nav { width: 36px; height: 36px; font-size: 1.55rem; }
  .track-wrap::before,
  .track-wrap::after { width: 44px; }
  .grid-catalog { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 20px 12px; }
  .card { width: 140px; }
}
