@font-face {
  font-family: "Noto Sans Arabic";
  src: url("../fonts/NotoSansArabic-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --black: #000;
  --ink: #f5f5f7;
  --muted: #a1a1a6;
  --muted-2: #6e6e73;
  --line: rgba(255, 255, 255, 0.12);
  --glass: rgba(22, 22, 24, 0.62);
  --card: #161618;
  --elev: #1c1c1e;
  --white: #fff;
  --nav-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --page-pad: 22px;
  --radius-poster: 12px;
  --radius-card: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--black);
  color: var(--ink);
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "SF Arabic", "Noto Sans Arabic", system-ui, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { overflow-x: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; }

#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding-bottom: calc(48px + var(--safe-bot));
  animation: enter 0.45s var(--ease) both;
}
@keyframes enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.boot, .error {
  text-align: center;
  color: var(--muted);
  padding: 30vh 24px;
}

/* ——— Nav ——— */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--nav-h) + var(--safe-top));
  padding: var(--safe-top) var(--page-pad) 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.72), rgba(0,0,0,0.28) 70%, transparent);
}
.nav-solid {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--line);
}
.nav-brand {
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--white);
  line-height: 1;
}
.nav-brand span { opacity: 0.92; }
.nav-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--white);
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
}
.nav-back:active { transform: scale(0.96); background: rgba(255,255,255,0.2); }
.nav-start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* ——— Featured hero (home & series) ——— */
.hero {
  position: relative;
  margin-top: calc(-1 * (var(--nav-h) + var(--safe-top)));
  min-height: 58vh;
  display: flex;
  align-items: flex-end;
  isolation: isolate;
  overflow: hidden;
}
.hero-series { min-height: 52vh; }
.hero-episode { min-height: 48vh; }
@media (min-width: 860px) {
  .hero { min-height: 86vh; }
  .hero-series { min-height: 74vh; }
  .hero-episode { min-height: 62vh; }
  :root { --page-pad: 48px; }
}
@media (min-width: 1200px) {
  :root { --page-pad: 72px; }
}

.hero-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #111;
}
.hero-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}
.hero-episode .hero-art img { object-position: center center; }
.hero-art.missing {
  background: radial-gradient(ellipse at 30% 20%, #2a2a2e, #000 70%);
}
.hero-art.missing img { display: none; }

.hero-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to top, #000 0%, rgba(0,0,0,0.92) 34%, rgba(0,0,0,0.35) 62%, rgba(0,0,0,0.4) 100%),
    linear-gradient(to left, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.15) 42%, transparent 70%);
}
[dir="rtl"] .hero-shade {
  background:
    linear-gradient(to top, #000 0%, rgba(0,0,0,0.92) 34%, rgba(0,0,0,0.35) 62%, rgba(0,0,0,0.4) 100%),
    linear-gradient(to right, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.15) 42%, transparent 70%);
}

.hero-copy {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 720px;
  padding: 0 var(--page-pad) 36px;
}
@media (min-width: 860px) {
  .hero-copy { padding-bottom: 56px; max-width: 640px; }
}
.kicker {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero-copy h1 {
  margin: 0;
  font-size: clamp(2.1rem, 7vw, 4.2rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
  text-shadow: 0 2px 28px rgba(0,0,0,0.45);
}
.hero-sub {
  margin: 8px 0 0;
  font-size: clamp(1.05rem, 2.4vw, 1.45rem);
  font-weight: 500;
  color: rgba(255,255,255,0.86);
  letter-spacing: -0.02em;
}
.meta-line {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}
.hero-desc {
  margin: 14px 0 0;
  color: rgba(245,245,247,0.86);
  font-size: 1.02rem;
  line-height: 1.7;
  max-width: 36em;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  border-radius: 980px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: -0.015em;
  border: 0;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease), color 0.18s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-solid {
  background: #fff;
  color: #000;
}
.btn-solid:hover { background: #e8e8ed; }
.btn-ghost {
  background: rgba(255,255,255,0.14);
  color: #fff;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.btn-ghost:hover { background: rgba(255,255,255,0.22); }

/* ——— Rows ——— */
.shelf {
  padding: 8px 0 10px;
}
.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 var(--page-pad);
  margin: 18px 0 14px;
}
.shelf-head h2 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.row-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 4px var(--page-pad) 22px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.row-scroll::-webkit-scrollbar { display: none; }

/* Poster cards */
.poster-card {
  flex: 0 0 auto;
  width: 148px;
  text-decoration: none;
  color: inherit;
  scroll-snap-align: start;
  transition: transform 0.28s var(--ease);
}
@media (min-width: 700px) { .poster-card { width: 180px; } }
@media (min-width: 1100px) { .poster-card { width: 200px; } }
.poster-card:hover { transform: scale(1.05); }
.poster-card:active { transform: scale(0.98); }
.poster-frame {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-poster);
  overflow: hidden;
  background: var(--elev);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.poster-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.poster-card h3 {
  margin: 10px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.poster-card p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Episode thumb cards */
.ep-card {
  flex: 0 0 auto;
  width: min(72vw, 300px);
  text-decoration: none;
  color: inherit;
  scroll-snap-align: start;
  transition: transform 0.28s var(--ease);
}
@media (min-width: 700px) { .ep-card { width: 320px; } }
.ep-card:hover { transform: scale(1.03); }
.ep-card:active { transform: scale(0.99); }
.ep-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: var(--elev);
  box-shadow: 0 10px 28px rgba(0,0,0,0.4);
}
.ep-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ep-thumb.missing {
  background: linear-gradient(160deg, #2c2c30, #141416);
}
.ep-num-pill {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  border-radius: 980px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
}
.ep-card .ep-it {
  margin: 10px 0 0;
  font-weight: 650;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.ep-card .ep-ar {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.ep-card .ep-teaser {
  margin: 6px 0 0;
  color: var(--muted-2);
  font-size: 0.8rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Season segmented control */
.season-bar {
  padding: 4px var(--page-pad) 0;
}
.segmented {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 0 8px;
}
.segmented::-webkit-scrollbar { display: none; }
.seg {
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255,255,255,0.08);
  border-radius: 980px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
  white-space: nowrap;
}
.seg.is-on {
  background: #fff;
  color: #000;
}
.seg:hover:not(.is-on) { background: rgba(255,255,255,0.16); }
.season-blurb {
  padding: 4px var(--page-pad) 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 40em;
  margin: 0;
}

/* Frosted content cards (episode) */
.stack {
  padding: 8px var(--page-pad) 0;
  max-width: 820px;
}
.glass {
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(22px);
  -webkit-backdrop-filter: saturate(160%) blur(22px);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px 18px 20px;
  margin: 0 0 14px;
}
.glass h3 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.summary p { margin: 0 0 12px; color: rgba(245,245,247,0.92); line-height: 1.75; }
.summary p:last-child { margin-bottom: 0; }

.people, .words { list-style: none; margin: 0; padding: 0; }
.people li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.people li:last-child { border-bottom: 0; }
.people .name { font-weight: 650; letter-spacing: -0.015em; }
.people .role { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

.words li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.words li:last-child { border-bottom: 0; }
.words .it {
  font-weight: 650;
  direction: ltr;
  text-align: start;
  letter-spacing: -0.02em;
}
[dir="rtl"] .words .it { text-align: left; }
.words .ar { color: var(--ink); }
.words .hint {
  grid-column: 1 / -1;
  color: var(--muted-2);
  font-size: 0.82rem;
}

.missing-plot {
  background: rgba(255, 196, 80, 0.1);
  border: 1px solid rgba(255, 196, 80, 0.28);
  color: #f3d399;
  border-radius: var(--radius-card);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.source {
  color: var(--muted-2);
  font-size: 0.78rem;
  margin: 6px 2px 0;
  line-height: 1.6;
}
.footnote {
  color: var(--muted-2);
  font-size: 0.78rem;
  text-align: center;
  margin: 28px var(--page-pad) 0;
}

.ep-badge {
  display: inline-block;
  background: rgba(255,255,255,0.14);
  border-radius: 980px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 10px;
}

@media (max-width: 700px) {
  .hero-copy { padding-bottom: 24px; }
  .hero-series .hero-desc {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

.beats {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: beat;
}
.beats li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.beats li:last-child { border-bottom: 0; padding-bottom: 2px; }
.beats .beat-n {
  counter-increment: beat;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.10);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.beats .beat-n::before { content: counter(beat); }
.beats .beat-text {
  color: rgba(245,245,247,0.94);
  line-height: 1.8;
  font-size: 1.02rem;
}
.thin-note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}
@media (max-width: 700px) {
  .beats .beat-text { font-size: 1.0rem; line-height: 1.85; }
  .glass.beats-card { padding: 16px 16px 18px; }
}
