:root {
  --bg: #07060f;
  --bg-2: #0d0a1a;
  --panel: #110d22;
  --panel-2: #15102b;
  --line: #2a2150;
  --ink: #f4f1ff;
  --muted: #8d83bf;
  --magenta: #c026d3;
  --purple: #a855f7;
  --indigo: #6366f1;
  --cyan: #06b6d4;
  --amber: #ffb347;
  --grad: linear-gradient(110deg, #c026d3, #6366f1 50%, #06b6d4);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Space Grotesk', 'Vazirmatn', system-ui, sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh; overflow-x: hidden; position: relative;
}
:lang(fa), .fa-text { font-family: 'Vazirmatn', sans-serif; }

#bg-grid { position: fixed; inset: 0; z-index: -3; opacity: .5; }
.scanlines {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .3;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,.22) 2px 3px);
  animation: scan 9s linear infinite;
}
@keyframes scan { to { background-position: 0 100px; } }
body::before {
  content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(40vw 40vw at 12% -5%, rgba(192,38,211,.22), transparent 60%),
    radial-gradient(45vw 45vw at 95% 5%, rgba(6,182,212,.16), transparent 60%),
    radial-gradient(50vw 50vw at 50% 115%, rgba(99,102,241,.18), transparent 60%);
  animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translateY(-3%) scale(1.08); } }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; position: sticky; top: 0; z-index: 30;
  background: rgba(7,6,15,.6); backdrop-filter: blur(12px); border-bottom: 2px solid var(--line);
}
.brand img { display: block; transition: transform .25s, filter .25s; }
.brand:hover img { transform: translateX(2px); filter: drop-shadow(0 0 14px rgba(168,85,247,.6)); }
.topbar-right { display: flex; align-items: center; gap: 22px; }
.status { font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: 1px; color: var(--muted); display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); padding: 6px 10px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 10px #22c55e; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }
.navlink { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 13px; letter-spacing: 1px; position: relative; }
.navlink::after { content: ''; position: absolute; left: 0; bottom: -4px; width: 0; height: 2px; background: var(--grad); transition: width .25s; }
.navlink:hover::after { width: 100%; }

.view { max-width: 1240px; margin: 0 auto; padding: 0 26px 90px; }
.hidden { display: none !important; }

/* hero */
.hero { padding: 80px 0 44px; }
.kicker { font-family: 'Space Mono', monospace; font-size: 12px; letter-spacing: 3px; color: var(--cyan); margin-bottom: 18px; animation: flicker 4s steps(2) infinite; }
@keyframes flicker { 0%,96%,100% { opacity: 1; } 97% { opacity: .3; } 98% { opacity: 1; } }
.hero-title { font-size: clamp(44px, 10vw, 120px); line-height: .92; font-weight: 700; letter-spacing: -.04em; text-transform: uppercase; }
.hero-title .line { display: block; }
.hero-title .line:nth-child(1) { animation: slideIn .6s cubic-bezier(.2,.8,.2,1) both; }
.hero-title .line:nth-child(2) { animation: slideIn .6s .12s cubic-bezier(.2,.8,.2,1) both; }
@keyframes slideIn { from { opacity: 0; transform: translateY(40px) skewY(4deg); } }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.glitch { position: relative; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.glitch::before { left: 2px; text-shadow: -2px 0 var(--magenta); animation: gl1 3s infinite linear alternate-reverse; }
.glitch::after { left: -2px; text-shadow: 2px 0 var(--cyan); animation: gl2 2.4s infinite linear alternate-reverse; }
@keyframes gl1 { 0%,92%,100% { clip-path: inset(0 0 100% 0); } 93% { clip-path: inset(20% 0 50% 0); } 95% { clip-path: inset(60% 0 10% 0); } }
@keyframes gl2 { 0%,90%,100% { clip-path: inset(100% 0 0 0); } 91% { clip-path: inset(40% 0 40% 0); } 94% { clip-path: inset(10% 0 70% 0); } }
.hero-sub { color: var(--muted); margin-top: 22px; font-size: 17px; max-width: 520px; }

/* search bar */
.search-wrap { display: flex; align-items: stretch; max-width: 720px; margin: 34px 0 0; border: 2px solid var(--line); background: var(--panel); position: relative; transition: border-color .2s, box-shadow .2s, transform .2s; }
.search-wrap:focus-within { border-color: var(--purple); box-shadow: 8px 8px 0 0 rgba(168,85,247,.35); transform: translate(-2px,-2px); }
.search-wrap.compact { margin: 20px 0 30px; }
.search-tag { font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: 2px; display: flex; align-items: center; padding: 0 16px; color: var(--bg); background: var(--grad); font-weight: 700; }
.search-wrap input { flex: 1; background: transparent; border: none; outline: none; color: var(--ink); font-size: 17px; padding: 18px 16px; font-family: inherit; }
.search-wrap input::placeholder { color: var(--muted); }
.search-btn { border: none; cursor: pointer; background: var(--ink); color: var(--bg); font-weight: 700; letter-spacing: 1px; font-size: 14px; padding: 0 24px; display: flex; align-items: center; gap: 8px; transition: background .2s, color .2s, gap .2s; }
.search-btn em { font-style: normal; transition: transform .2s; }
.search-btn:hover { background: var(--grad); color: var(--bg); gap: 14px; }

/* rails */
.rail-block { margin-top: 56px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.rail-head h2 { display: flex; align-items: center; gap: 12px; font-size: 16px; letter-spacing: 2px; font-weight: 700; }
.rail-head .bar { width: 28px; height: 4px; background: var(--magenta); }
.rail-head .bar.cyan { background: var(--cyan); }
.rail-head .rnd { color: var(--muted); font-family: 'Space Mono', monospace; font-size: 12px; letter-spacing: 1px; }
.reroll { font-family: 'Space Mono', monospace; font-size: 12px; letter-spacing: 1px; cursor: pointer; background: var(--panel); border: 1px solid var(--line); color: var(--muted); padding: 8px 14px; transition: border-color .2s, color .2s, transform .14s; }
.reroll:hover { border-color: var(--magenta); color: var(--ink); transform: translateY(-1px); }
.rail { display: flex; gap: 16px; overflow-x: auto; padding: 6px 2px 16px; scroll-snap-type: x mandatory; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.rail::-webkit-scrollbar { height: 6px; }
.rail::-webkit-scrollbar-thumb { background: var(--line); }

/* poster card */
.pcard { flex: 0 0 190px; scroll-snap-align: start; cursor: pointer; text-decoration: none; color: inherit; background: var(--panel); border: 1px solid var(--line); position: relative; transition: transform .16s, border-color .2s, box-shadow .2s; animation: pop .4s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(16px); } }
.pcard:hover { transform: translate(-3px,-3px); border-color: var(--purple); box-shadow: 6px 6px 0 0 rgba(99,102,241,.4); }
.pwrap { position: relative; }
.pwrap .poster { width: 100%; aspect-ratio: 2/3; object-fit: cover; background: var(--bg-2); display: block; }
.pwrap .poster.ph { display: flex; align-items: center; justify-content: center; color: var(--line); font-family: 'Space Mono', monospace; font-size: 12px; }
.pwrap .imdb { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 4px; background: rgba(7,6,15,.85); color: var(--amber); border: 1px solid rgba(255,179,71,.4); padding: 3px 7px; font-family: 'Space Mono', monospace; font-size: 12px; font-weight: 700; }
.pwrap .imdb i { font-style: normal; font-size: 8px; opacity: .7; }
.type-tag { position: absolute; top: 8px; left: 8px; font-family: 'Space Mono', monospace; font-size: 10px; font-weight: 700; letter-spacing: 1px; padding: 3px 7px; }
.type-tag.tv { background: rgba(6,182,212,.2); color: #67e8f9; border: 1px solid rgba(6,182,212,.4); }
.type-tag.mv { background: rgba(192,38,211,.2); color: #f0abfc; border: 1px solid rgba(192,38,211,.4); }
.season-badge { position: absolute; bottom: 8px; left: 8px; font-family: 'Space Mono', monospace; font-size: 11px; font-weight: 700; padding: 3px 8px; background: rgba(7,6,15,.85); border: 1px solid var(--line); color: var(--ink); }
.pmeta { padding: 11px 12px 13px; }
.pmeta .pt { font-weight: 600; font-size: 14px; line-height: 1.25; }
.pmeta .py { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* split search */
.result-section { display: flex; align-items: center; gap: 10px; font-size: 14px; letter-spacing: 2px; font-weight: 700; margin: 30px 0 16px; text-transform: uppercase; }
.result-section .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--magenta); }
.result-section small { font-family: 'Space Mono', monospace; color: var(--muted); font-weight: 400; }
.poster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.poster-grid .pcard { flex: initial; }

/* headings */
.section-title { font-size: clamp(22px, 4vw, 34px); font-weight: 700; letter-spacing: -.01em; text-transform: uppercase; margin: 6px 0 22px; }
.lang-note { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--muted); letter-spacing: 1px; }

/* detail */
.back-btn { background: var(--panel); color: var(--ink); border: 2px solid var(--line); padding: 10px 18px; cursor: pointer; font-weight: 700; font-size: 13px; letter-spacing: 1px; margin: 8px 0 24px; transition: transform .16s, border-color .2s, box-shadow .2s; }
.back-btn:hover { transform: translate(-2px,-2px); border-color: var(--cyan); box-shadow: 4px 4px 0 rgba(6,182,212,.5); }
.detail-head { display: flex; gap: 24px; align-items: flex-end; margin-bottom: 24px; }
.detail-head img { width: 140px; aspect-ratio: 2/3; object-fit: cover; background: var(--bg-2); border: 1px solid var(--line); box-shadow: 0 24px 60px -24px #000; }
.detail-head h1 { font-size: clamp(28px, 5vw, 46px); letter-spacing: -.02em; text-transform: uppercase; line-height: .98; }
.dh-meta { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.dh-meta .py { font-family: 'Space Mono', monospace; color: var(--muted); }
.dh-meta .imdb { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,179,71,.14); color: var(--amber); border: 1px solid rgba(255,179,71,.35); padding: 4px 9px; font-family: 'Space Mono', monospace; font-size: 13px; font-weight: 700; }
.dh-count { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--muted); }

/* season dropdown */
#season-bar { margin-bottom: 26px; }
.season-picker { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--cyan); padding: 14px 18px; }
.season-picker .sp-label { font-family: 'Space Mono', monospace; font-size: 12px; letter-spacing: 1px; color: var(--muted); }
.season-chip { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 13px; cursor: pointer; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink); padding: 8px 16px; transition: all .18s; }
.season-chip:hover { border-color: var(--cyan); transform: translateY(-1px); }
.season-chip.active { background: var(--grad); border-color: transparent; color: var(--bg); }
.season-chip small { font-family: 'Space Mono', monospace; font-weight: 400; opacity: .7; margin-left: 6px; }

/* subtitle cue blocks */
.subs { display: flex; flex-direction: column; gap: 12px; }
.scue { background: var(--panel); border: 1px solid var(--line); overflow: hidden; transition: border-color .2s, transform .14s, box-shadow .2s; animation: pop .4s ease both; }
.scue:hover { transform: translateX(4px); box-shadow: -5px 0 0 0 var(--accent, var(--cyan)); }
.scue.fa { --accent: var(--magenta); }
.scue.en { --accent: var(--cyan); }
.scue-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px dashed var(--line); background: var(--panel-2); }
.lang-tag { font-family: 'Space Mono', monospace; font-weight: 700; font-size: 12px; padding: 4px 10px; letter-spacing: .5px; }
.scue.fa .lang-tag { background: rgba(192,38,211,.16); color: #f0abfc; border: 1px solid rgba(192,38,211,.35); }
.scue.en .lang-tag { background: rgba(6,182,212,.14); color: #67e8f9; border: 1px solid rgba(6,182,212,.32); }
.uploader { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px 5px 6px; }
.uploader .av { width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto; background: linear-gradient(135deg, var(--purple), var(--cyan)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; color: var(--bg); }
.uploader .un { font-weight: 600; font-size: 13px; line-height: 1.2; }
.uploader .un small { color: var(--muted); font-weight: 400; font-family: 'Space Mono', monospace; font-size: 10px; }
.scue-body { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; }
.scue-rel { font-size: 14px; line-height: 1.4; }
.scue-rel .dl-count { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--muted); display: block; margin-top: 4px; }
.dl-group { display: flex; gap: 8px; flex: 0 0 auto; }
.dl { text-decoration: none; font-size: 13px; font-weight: 600; padding: 9px 16px; white-space: nowrap; cursor: pointer; border: 1px solid var(--line); color: var(--ink); transition: transform .14s, box-shadow .2s, border-color .2s; }
.dl:hover { transform: translateY(-2px); }
.dl.primary { background: var(--grad); border-color: transparent; color: var(--bg); }
.dl.primary:hover { box-shadow: 4px 4px 0 rgba(192,38,211,.5); }
.dl.ghost { background: transparent; color: var(--muted); }
.dl.ghost:hover { border-color: var(--cyan); color: var(--ink); }

/* loader / empty */
.loader { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 70px; }
.loader p { font-family: 'Space Mono', monospace; letter-spacing: 3px; color: var(--muted); font-size: 13px; }
.cube { width: 46px; height: 46px; position: relative; transform: rotate(45deg); }
.cube span { position: absolute; width: 20px; height: 20px; background: var(--grad); animation: cube 1.4s ease-in-out infinite; }
.cube span:nth-child(1) { top: 0; left: 0; } .cube span:nth-child(2) { top: 0; right: 0; animation-delay: .15s; }
.cube span:nth-child(3) { bottom: 0; left: 0; animation-delay: .45s; } .cube span:nth-child(4) { bottom: 0; right: 0; animation-delay: .3s; }
@keyframes cube { 50% { transform: scale(.4); opacity: .4; } }
.empty { font-family: 'Space Mono', monospace; text-align: center; color: var(--muted); padding: 60px; border: 1px dashed var(--line); margin-top: 16px; letter-spacing: 1px; }

.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: 2px; color: var(--muted); padding: 26px; border-top: 2px solid var(--line); max-width: 1240px; margin: 0 auto; }

@media (max-width: 760px) {
  .detail-head { flex-direction: column; align-items: flex-start; }
  .scue-body { flex-direction: column; align-items: stretch; }
  .dl-group { justify-content: stretch; } .dl { flex: 1; text-align: center; }
  .uploader { margin-left: 0; } .scue-top { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
