/* ==========================================================
   دراما للجميع — نظام التصميم
   ========================================================== */

:root {
  /* لوحة الألوان */
  --ink:        #0B0A0F;
  --surface:    #16141C;
  --surface-2:  #211D2B;
  --line:       #2C2636;
  --rose:       #FF3D71;
  --rose-dim:   rgba(255, 61, 113, 0.14);
  --gold:       #FFC46B;
  --text:       #F5F2F7;
  --muted:      #9A93A8;

  /* مقياس المسافات */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --r-sm: 10px; --r-md: 16px; --r-lg: 24px; --r-full: 999px;

  --shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.75);
  --pad-x: clamp(16px, 5vw, 64px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; min-width: 0; }
img, video, svg { max-width: 100%; }

/* عناصر الـ grid والـ flex لازم تقدر تنكمش تحت عرض محتواها */
.wrap, .shelf, .series-body, .series-hero > *, .hero-inner, .page-head, .card, .stat, .ccard { min-width: 0; }

html { scroll-behavior: smooth; overflow-x: hidden; max-width: 100%; }

body {
  max-width: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .display { font-family: 'Almarai', 'Cairo', sans-serif; font-weight: 800; line-height: 1.25; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; border-radius: 4px; }

img { display: block; max-width: 100%; }
img, video, iframe, svg { max-width: 100%; }

/* ---------- خلفية متدرجة ثابتة ---------- */
.aura {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(60% 45% at 78% 8%,  rgba(255, 61, 113, 0.16), transparent 70%),
    radial-gradient(55% 40% at 12% 4%,  rgba(122, 92, 255, 0.14), transparent 70%),
    var(--ink);
}

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 90;
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--pad-x);
  background: rgba(11, 10, 15, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--s2); flex-shrink: 0; }
.brand img { height: 40px; width: auto; }
.brand img { height: 40px; }

.topnav { display: flex; gap: var(--s1); margin-inline-start: var(--s4); }
.topnav a {
  padding: var(--s2) var(--s3); border-radius: var(--r-full);
  font-size: 0.88rem; font-weight: 700; color: var(--muted);
  transition: color .18s, background .18s;
}
.topnav a:hover { color: var(--text); background: var(--surface-2); }
.topnav a.on { color: var(--rose); background: var(--rose-dim); }

.topbar-tools { margin-inline-start: auto; display: flex; align-items: center; gap: var(--s2); }

.chip-btn {
  width: 40px; height: 40px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 0.95rem;
  transition: border-color .18s, color .18s;
}
.chip-btn:hover { border-color: var(--rose); color: var(--rose); }
.chip-btn.wide { width: auto; padding: 0 var(--s3); font-weight: 800; font-size: 0.8rem; letter-spacing: 0.04em; }

/* ---------- البحث ---------- */
.searchpane { display: none; padding: var(--s4) var(--pad-x) var(--s5); border-bottom: 1px solid var(--line); background: var(--surface); position: relative; z-index: 89; }
.searchpane.open { display: block; }
.searchrow { display: flex; gap: var(--s2); max-width: 720px; margin-inline: auto; }
.searchrow input {
  flex: 1; padding: var(--s3) var(--s4); font-family: inherit; font-size: 1rem;
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-full); color: var(--text);
}
.searchrow input::placeholder { color: var(--muted); }
.searchrow input:focus { outline: none; border-color: var(--rose); }
.searchrow button { padding: 0 var(--s5); border-radius: var(--r-full); background: var(--rose); color: #fff; font-weight: 800; }

.suggest { max-width: 720px; margin: var(--s3) auto 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; display: none; max-height: 60vh; overflow-y: auto; }
.suggest.open { display: block; }
.suggest-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: var(--rose-dim); }
.suggest-item img { width: 34px; height: 51px; object-fit: cover; border-radius: 6px; background: var(--ink); }
.suggest-item span { font-size: 0.9rem; font-weight: 700; }

/* ---------- البطل: خلفية كاملة قابلة للسحب ---------- */
.hero { position: relative; min-height: 62vh; display: grid; align-items: end; overflow: hidden;
        touch-action: pan-y; user-select: none; }
@media (max-width: 700px) { .hero { min-height: 68vh; } }

.hero-slide { position: absolute; inset: 0; background-size: cover; background-position: center 18%;
              opacity: 0; transition: opacity .6s ease; }
.hero-slide.on { opacity: 1; }
.hero::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, var(--ink) 2%, rgba(11,10,15,.86) 32%, rgba(11,10,15,.30) 66%, rgba(11,10,15,.55)); }

.hero-inner { max-width: 100%; position: relative; z-index: 2; padding: var(--s6) var(--pad-x) var(--s7); width: 100%; max-width: min(760px, 100%); }
.hero-title { overflow-wrap: anywhere; font-size: clamp(1.6rem, 6vw, 3.2rem); margin-bottom: var(--s3); text-shadow: 0 4px 24px rgba(0,0,0,.6); }
.hero-desc { color: #CFC9D8; font-size: .95rem; line-height: 1.75; margin-bottom: var(--s4);
             display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.hero-meta { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s5); }
.hero-meta span { background: rgba(255,255,255,.10); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.14);
                  padding: 6px 14px; border-radius: var(--r-full); font-size: .8rem; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.hero-meta i { color: var(--rose); font-size: .78rem; }
.hero-meta .g i { color: var(--gold); }

.hero-cta { display: flex; gap: var(--s3); flex-wrap: wrap; }

.hero-dots { position: absolute; z-index: 3; inset-inline-start: var(--pad-x); bottom: var(--s4); display: flex; gap: 6px; }
.hero-dots i { width: 18px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.28); transition: background .25s, width .25s; }
.hero-dots i.on { background: var(--rose); width: 30px; }

.hero-arrow { position: absolute; z-index: 4; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: 999px; background: rgba(11,10,15,.5); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.14); display: none; place-items: center; color: #fff; }
@media (min-width: 860px) { .hero-arrow { display: grid; } }
.hero-arrow:hover { background: var(--rose); border-color: var(--rose); }
.hero-arrow.prev { inset-inline-start: 14px; }
.hero-arrow.next { inset-inline-end: 14px; }

/* ---------- بطاقات الأرقام ---------- */
.statline { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: var(--s2);
            margin-bottom: var(--s5); max-width: min(520px, 100%); width: 100%; }
@media (min-width: 760px) { .statline { margin-inline: 0; } }
@media (max-width: 759px) { .statline { margin-inline: auto; } }

.stat { min-width: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        padding: var(--s3) var(--s2); background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--r-md); text-align: center; }
.stat b { max-width: 100%; overflow: hidden; white-space: nowrap;
          font-family: 'Almarai', sans-serif; font-size: clamp(.78rem, 3.4vw, 1.2rem); font-weight: 800; line-height: 1.15;
          color: var(--text); display: block; font-variant-numeric: tabular-nums; }
.stat span { font-size: .68rem; white-space: nowrap; color: var(--muted); letter-spacing: .03em; font-weight: 700; }
.stat.gold b { color: var(--gold); }
.stat.rose b { color: var(--rose); }

/* ---------- الأقسام ---------- */
.wrap { padding-inline: var(--pad-x); flex: 1; width: 100%; max-width: 100%; }
.shelf { margin-bottom: var(--s7); }
.shelf-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.shelf-head h2 { font-size: 1.15rem; }
.shelf-head .rule { flex: 1; height: 1px; background: var(--line); }
.shelf-head .more { font-size: 0.82rem; font-weight: 700; color: var(--rose); white-space: nowrap; }

.rail { display: flex; align-items: flex-start; gap: var(--s3); overflow-x: auto; padding-bottom: var(--s3); scroll-snap-type: x proximity; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; flex: 0 0 auto; }

.grid { min-width: 0; display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); width: 100%; }
@media (min-width: 720px) { .grid { gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }

/* ---------- بطاقة المسلسل ---------- */
.card { width: 128px; display: block; }
.grid .card { width: 100%; }
@media (min-width: 700px)  { .card { width: 150px; } }
@media (min-width: 1200px) { .card { width: 164px; } }

.card { display: block; }
.card-art {
  display: block; position: relative; width: 100%; aspect-ratio: 2 / 3;
  border-radius: var(--r-md); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: transform .2s ease, border-color .2s ease;
}
.card:hover .card-art { transform: translateY(-4px); border-color: var(--rose); }
.card-art img { width: 100%; height: 100%; object-fit: cover; }

.card-eps {
  position: absolute; inset-block-end: 6px; inset-inline-start: 6px;
  background: rgba(11,10,15,.85); backdrop-filter: blur(6px);
  font-size: .66rem; font-weight: 800; padding: 3px 8px; border-radius: var(--r-full); color: var(--gold);
}
.card-title {
  display: -webkit-box; margin-top: 7px; font-size: .8rem; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.card-meta { display: flex !important; gap: 10px; flex-wrap: wrap; margin-top: 3px; font-size: .68rem; color: var(--muted); }
.card-meta i { font-size: .62rem; margin-inline-end: 3px; }
.card-meta .lk i { color: var(--rose); }
.card-sub { display: block; font-size: .68rem; color: var(--rose); font-weight: 700; margin-top: 2px; }

/* حلقة التقدّم — العنصر المميّز */
.ring { position: absolute; inset-block-end: 6px; inset-inline-end: 6px; width: 34px; height: 34px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; }
.ring .bg { stroke: rgba(255,255,255,.20); }
.ring .fg { stroke: var(--rose); stroke-linecap: round; transition: stroke-dashoffset .9s ease; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: .58rem; font-weight: 800; font-family: 'Almarai', sans-serif; }

.card-remove {
  position: absolute; top: 6px; inset-inline-end: 6px;
  width: 26px; height: 26px; border-radius: var(--r-full);
  background: rgba(11,10,15,.85); color: var(--text);
  display: grid; place-items: center; font-size: .7rem; opacity: 0; transition: opacity .18s;
}
.card:hover .card-remove, .card-remove:focus-visible { opacity: 1; }
@media (hover: none) { .card-remove { opacity: 1; } }
.card-remove:hover { background: var(--rose); }

/* ---------- الحالة الفارغة ---------- */
.empty { text-align: center; padding: var(--s8) var(--s4); color: var(--muted); }
.empty i { font-size: 2.2rem; color: var(--line); margin-bottom: var(--s3); display: block; }
.empty h3 { font-size: 1.1rem; color: var(--text); margin-bottom: var(--s2); }
.empty p { font-size: 0.9rem; margin-bottom: var(--s4); }

/* ---------- المرشحات والصفحات ---------- */
.filters { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s5); }
.pill { padding: var(--s2) var(--s4); border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line); font-size: 0.82rem; font-weight: 700; color: var(--muted); transition: .18s; }
.pill:hover { color: var(--text); }
.pill.on { background: var(--rose); border-color: var(--rose); color: #fff; }
.divider-dot { width: 1px; background: var(--line); margin-inline: var(--s2); }

.pager-top { margin-top: 0; margin-bottom: var(--s4); }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s3); margin: var(--s6) 0; font-size: 0.85rem; color: var(--muted); }
.pager a { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 1.1rem; }
.pager a:hover { background: var(--rose); border-color: var(--rose); color: #fff; }
.pager a.off { opacity: 0.25; pointer-events: none; }

.page-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; padding-block: var(--s6) var(--s4); }
.page-head h1 { font-size: clamp(1.25rem, 4vw, 2rem); overflow-wrap: anywhere; }
.page-head .count { color: var(--muted); font-size: 0.85rem; }

/* ---------- صفحة المسلسل ---------- */
.series-hero { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); padding-block: var(--s6); }
.series-hero > * { min-width: 0; }
@media (min-width: 760px) { .series-hero { grid-template-columns: 230px minmax(0, 1fr); } }
.series-cover { width: 190px; margin-inline: auto; aspect-ratio: 2/3; object-fit: cover; border-radius: var(--r-lg); border: 1px solid var(--line); box-shadow: var(--shadow); }
@media (min-width: 760px) { .series-cover { width: 100%; margin-inline: 0; } }
.series-body { min-width: 0; max-width: 100%; text-align: center; }
@media (min-width: 760px) { .series-body { text-align: start; } }
.series-body h1 { font-size: clamp(1.35rem, 4.5vw, 2.3rem); margin-bottom: var(--s3); overflow-wrap: anywhere; }

.tagrow { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: center; margin-bottom: var(--s4); }
@media (min-width: 760px) { .tagrow { justify-content: flex-start; } }
.tag { max-width: 100%; overflow-wrap: anywhere; background: var(--rose-dim); color: var(--rose); padding: 4px 12px; border-radius: var(--r-full); font-size: 0.76rem; font-weight: 700; }

.blurb { overflow-wrap: anywhere; color: var(--muted); font-size: 0.93rem; line-height: 1.85; margin-bottom: var(--s4); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.blurb.open { -webkit-line-clamp: unset; }
.blurb-toggle { color: var(--rose); font-weight: 700; font-size: 0.85rem; margin-bottom: var(--s5); display: block; }

.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: var(--s2); }
.ep-cell { padding: var(--s3) 0; text-align: center; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-weight: 800; font-size: 0.9rem; transition: .15s; }
.ep-cell:hover { background: var(--rose); border-color: var(--rose); color: #fff; transform: translateY(-2px); }
.ep-cell.seen { border-color: var(--rose); color: var(--rose); }

/* ---------- التعليقات ---------- */
.cbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s4); }
.cbox { max-width: 100%; }
.cbox input, .cbox textarea { max-width: 100%; min-width: 0; background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s3); color: var(--text); font-family: inherit; font-size: 0.9rem; resize: vertical; }
.cbox input:focus, .cbox textarea:focus { outline: none; border-color: var(--rose); }
.cbox button { background: var(--rose); color: #fff; padding: var(--s3); border-radius: var(--r-sm); font-weight: 800; }
.ccard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); margin-bottom: var(--s2); }
.ccard .who { color: var(--gold); font-weight: 800; font-size: 0.85rem; margin-bottom: 2px; }
.ccard .what { color: var(--muted); font-size: 0.88rem; line-height: 1.7; word-break: break-word; }

/* ---------- أمان العرض ---------- */
.series-hero, .series-hero > *, .series-body, .hero-inner, .wrap, .shelf, main { min-width: 0; max-width: 100%; }
.blurb, .card-title, .ccard .what, .page-head h1, .series-body h1, .hero-title { overflow-wrap: anywhere; }
.series-cover { max-width: 100%; }
img, video, iframe { max-width: 100%; }
.cbox { max-width: 100%; }
.cbox input, .cbox textarea { max-width: 100%; min-width: 0; width: 100%; max-width: 100%; }
.tagrow, .filters, .hero-meta, .hero-cta { max-width: 100%; }

/* ---------- التذييل ---------- */
.foot { margin-top: var(--s8); padding: var(--s6) var(--pad-x); border-top: 1px solid var(--line); background: #08070B; text-align: center; }
.foot-note { color: #5C5568; font-size: 0.78rem; max-width: 60ch; margin: 0 auto var(--s3); line-height: 1.8; }
.foot-links { display: flex; gap: var(--s4); justify-content: center; flex-wrap: wrap; margin-bottom: var(--s3); }
.foot-links a { color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.foot-links a:hover { color: var(--rose); }
.foot-copy { color: #443E52; font-size: 0.78rem; }

/* ---------- شريط سفلي للموبايل ---------- */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 95;
  display: flex; background: rgba(11, 10, 15, 0.94); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; padding: var(--s2) 0 var(--s3); text-align: center; color: var(--muted); font-size: 0.66rem; font-weight: 700; }
.tabbar a i { display: block; font-size: 1.1rem; margin-bottom: 3px; }
.tabbar a.on { color: var(--rose); }
@media (min-width: 860px) { .tabbar { display: none; } }
@media (max-width: 859px) { body { padding-bottom: 62px; } .topnav { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- اتجاه المشغل ---------- */
.rtl-flip { display: inline-block; }
[dir="ltr"] .rtl-flip { transform: scaleX(-1); }

/* ---------- تلميح التقديم السريع ---------- */
.seek-flash {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 18;
  background: rgba(11,10,15,.72); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.16); border-radius: 999px;
  padding: 10px 18px; font-size: .85rem; font-weight: 800; color: #fff;
  opacity: 0; transition: opacity .18s; pointer-events: none; display: flex; align-items: center; gap: 8px;
}
.seek-flash.show { opacity: 1; }
.seek-flash.back { left: 12%; }
.seek-flash.fwd  { right: 12%; }
.speed-flag {
  position: absolute; top: 14%; left: 0; right: 0; margin: auto; width: max-content; z-index: 18;
  background: rgba(255,61,113,.92); border-radius: 999px; padding: 7px 16px;
  font-size: .8rem; font-weight: 800; color: #fff; opacity: 0; transition: opacity .18s; pointer-events: none;
}
.speed-flag.show { opacity: 1; }

/* ---------- نص السيو ---------- */
.seo-line { color: var(--muted); font-size: .88rem; line-height: 1.75; margin-bottom: var(--s4); }
.seo-block { border-top: 1px solid var(--line); padding-top: var(--s5); }
.seo-block h2 { font-size: 1.05rem; margin-bottom: var(--s3); }
.seo-block p { color: var(--muted); font-size: .85rem; line-height: 1.9; margin-bottom: var(--s3); }
.seo-block strong { color: var(--text); font-weight: 700; }
