:root {
    --bg: #0F0F23;
    --bg-elevated: #16162e;
    --surface: #1E1B4B;
    --surface-2: #27234f;
    --border: rgba(248, 250, 252, 0.08);
    --border-strong: rgba(248, 250, 252, 0.16);
    --fg: #F8FAFC;
    --fg-muted: #a5a8c4;
    --fg-faint: #7c7f9c;
    --primary: #1E1B4B;
    --secondary: #4338CA;
    --accent: #22C55E;
    --accent-strong: #16a34a;
    --gold: #F5B301;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    background-image:
        radial-gradient(900px 500px at 100% -10%, rgba(67, 56, 202, 0.22), transparent 60%),
        radial-gradient(700px 500px at -10% 110%, rgba(34, 197, 94, 0.10), transparent 60%);
    background-attachment: fixed;
}

body[data-locale="fa"] { --font: 'Vazirmatn', 'Inter', system-ui, sans-serif; }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
label:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; }

.skip-link {
    position: absolute;
    inset-inline-start: -9999px;
    top: 0;
    z-index: 100;
    background: var(--accent);
    color: #06210f;
    padding: 10px 16px;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.skip-link:focus { inset-inline-start: 0; }

/* ---------- Top navigation ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(15, 15, 35, 0.88);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.site-header__inner {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 22px;
    padding: 12px 28px;
}

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand__mark {
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    color: #fff;
}
.brand__name { font-weight: 700; font-size: 19px; letter-spacing: 0.2px; }

.nav { display: flex; align-items: center; flex-wrap: nowrap; gap: 4px; }
.nav__item {
    display: inline-flex; align-items: center; gap: 8px;
    flex: 0 0 auto;
    padding: 9px 15px;
    border-radius: var(--radius-sm);
    color: var(--fg-muted);
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav__item:hover { background: var(--surface); color: var(--fg); }
.nav__item.is-active { background: var(--secondary); color: #fff; }
.nav__icon { display: grid; place-items: center; opacity: 0.9; }

.site-header__actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; flex: 0 0 auto; }

.icon-btn {
    display: grid;
    place-items: center;
    width: 42px; height: 42px;
    border-radius: var(--radius-sm);
    color: var(--fg-muted);
    transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--surface); color: var(--fg); }

.header__cta {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #06210f;
    font-weight: 700;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.header__cta:hover { background: var(--accent-strong); }

/* ---------- Shell ---------- */
.shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--fg-faint);
}
.search-form:focus-within { border-color: var(--secondary); }
.search-form__icon { display: grid; place-items: center; color: var(--fg-faint); }
.search-form input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--fg);
    font: inherit;
    outline: none;
    min-width: 0;
}
.search-form input::placeholder { color: var(--fg-faint); }

.locale-select {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: var(--fg-muted);
}
.locale-select select {
    appearance: none;
    -webkit-appearance: none;
    padding: 9px 34px 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--fg-muted);
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.locale-select select:hover { color: var(--fg); border-color: var(--secondary); }
.locale-select::after {
    content: '';
    position: absolute;
    inset-inline-end: 15px;
    width: 7px; height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    pointer-events: none;
}
[dir="rtl"] .locale-select select { padding: 9px 16px 9px 34px; }

.content { padding: 26px 28px 60px; flex: 1; }

.stack { display: flex; flex-direction: column; gap: 34px; }

/* ---------- Headings ---------- */
.rail__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.rail__title { font-size: 20px; }
.rail__more { display: inline-flex; align-items: center; gap: 5px; color: var(--fg-muted); font-size: 13px; font-weight: 600; }
.rail__more:hover { color: var(--accent); }

.page-head { position: relative; overflow: hidden; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-elevated); }
.page-head__bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0.28; filter: blur(2px); }
.page-head__inner { position: relative; padding: 30px 26px; background: linear-gradient(90deg, rgba(15,15,35,0.92), rgba(15,15,35,0.55)); }
.page-head h1 { font-size: 28px; }

/* ---------- Hero ---------- */
.hero { position: relative; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.hero__viewport { position: relative; min-height: 420px; }
.hero__slide { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity 0.6s ease; }
.hero__slide.is-active { position: relative; opacity: 1; visibility: visible; }
.hero__bg { position: absolute; inset: 0; background-size: cover; background-position: center 20%; transform: scale(1.05); }
.hero__slide::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(15,15,35,0.96) 8%, rgba(15,15,35,0.65) 55%, rgba(15,15,35,0.9)); }
.hero__inner { position: relative; display: flex; gap: 26px; align-items: center; padding: 40px 36px; }
.hero__poster { flex: 0 0 180px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.hero__poster img { width: 180px; height: 270px; object-fit: cover; }
.hero__body { max-width: 560px; }
.hero__title { font-size: 34px; margin-bottom: 12px; }
.hero__meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.hero__text { color: var(--fg-muted); margin: 0 0 22px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }

.hero__dots { position: absolute; bottom: 16px; inset-inline-end: 22px; display: flex; gap: 8px; }
.hero__dot { width: 9px; height: 9px; padding: 0; border: none; border-radius: 50%; background: rgba(248,250,252,0.3); cursor: pointer; transition: background 0.2s ease, width 0.2s ease; }
.hero__dot.is-active { background: var(--accent); width: 22px; border-radius: 999px; }

.meta-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--fg-muted);
}
.meta-pill--imdb { color: var(--gold); border-color: rgba(245, 179, 1, 0.35); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 22px;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #06210f; }
.btn--primary:hover { background: var(--accent-strong); }
.btn--ghost { border-color: var(--border-strong); color: var(--fg); }
.btn--ghost:hover { border-color: var(--secondary); background: var(--surface); }
.btn--lg { padding: 14px 28px; font-size: 15.5px; }
.btn.is-disabled { opacity: 0.55; cursor: default; }

/* ---------- Cards / rails ---------- */
.rail__track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 168px;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-2) transparent;
}
.rail__track::-webkit-scrollbar { height: 6px; }
.rail__track::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 999px; }

.card { display: flex; flex-direction: column; gap: 9px; scroll-snap-align: start; }
.card__media {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: transform 0.18s ease, border-color 0.18s ease;
}
.card:hover .card__media { transform: translateY(-4px); border-color: var(--secondary); }
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__placeholder { display: block; width: 100%; height: 100%; background: linear-gradient(135deg, var(--surface), var(--bg-elevated)); }
.card__scrim { position: absolute; inset: auto 0 0 0; height: 45%; background: linear-gradient(180deg, transparent, rgba(15,15,35,0.85)); }
.card__rating {
    position: absolute; top: 8px; inset-inline-start: 8px;
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 8px; border-radius: 999px;
    background: rgba(15, 15, 35, 0.82);
    color: var(--gold); font-size: 12px; font-weight: 700;
}
.card__tag {
    position: absolute; top: 8px; inset-inline-end: 8px;
    padding: 3px 9px; border-radius: 999px;
    background: rgba(34, 197, 94, 0.92); color: #06210f;
    font-size: 11px; font-weight: 700;
}
.card__play {
    position: absolute; inset-inline-end: 8px; bottom: 8px;
    display: grid; place-items: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(34, 197, 94, 0.95); color: #06210f;
    opacity: 0; transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.card:hover .card__play { opacity: 1; transform: translateY(0); }
.card__body { display: flex; flex-direction: column; gap: 2px; }
.card__title { font-size: 14px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card__sub { font-size: 12px; color: var(--fg-faint); }
.card__sub:empty { display: none; }

.card--landscape .card__media { aspect-ratio: 16 / 9; }
.card--landscape .rail__track { grid-auto-columns: 300px; }
.rail__track.is-static { grid-auto-columns: minmax(0, 1fr); }

/* ---------- Genre grid ---------- */
.chips__row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-weight: 600; font-size: 13.5px; color: var(--fg-muted);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.chip__icon { opacity: 0.7; }
.chip--sm { padding: 6px 13px; font-size: 12.5px; }

.genre-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.genre-card { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); min-height: 120px; display: flex; align-items: flex-end; }
.genre-card__media { position: absolute; inset: 0; }
.genre-card__media img { width: 100%; height: 100%; object-fit: cover; }
.genre-card__scrim { position: absolute; inset: 0; background: linear-gradient(135deg, rgba(30,27,75,0.9), rgba(15,15,35,0.72)); }
.genre-card__name { position: relative; padding: 16px 18px; font-weight: 700; font-size: 16px; }
.genre-card:hover { border-color: var(--secondary); }

/* ---------- Grid + filter ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 20px 16px; }

.filter { display: flex; gap: 8px; flex-wrap: wrap; }
.filter__item {
    padding: 8px 18px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--fg-muted);
    font-weight: 600; font-size: 13.5px;
}
.filter__item:hover { color: var(--fg); }
.filter__item.is-active { background: var(--secondary); color: #fff; border-color: var(--secondary); }

/* ---------- Detail ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-muted); font-size: 13px; font-weight: 600; width: fit-content; }
.back-link:hover { color: var(--accent); }

.detail { position: relative; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.detail__bg { position: absolute; inset: 0; background-size: cover; background-position: center 15%; opacity: 0.3; }
.detail > .detail__inner { position: relative; }
.detail::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(15,15,35,0.96) 5%, rgba(15,15,35,0.7) 60%, rgba(15,15,35,0.92)); }
.detail__inner { position: relative; z-index: 1; display: flex; gap: 28px; padding: 34px 32px; }
.detail__poster { flex: 0 0 216px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); align-self: flex-start; }
.detail__poster img { width: 216px; height: 324px; object-fit: cover; }
.detail__body { max-width: 640px; }
.detail__body h1 { font-size: 32px; margin-bottom: 14px; }
.detail__badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.detail__genres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.detail__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.detail__note { color: var(--fg-faint); font-size: 13px; margin: 0; }

.block { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 26px; }
.block__title { display: flex; align-items: center; gap: 12px; font-size: 19px; margin-bottom: 14px; }
.block__count { font-size: 13px; font-weight: 500; color: var(--fg-faint); }
.block__text { color: var(--fg-muted); margin: 0; white-space: pre-line; }

.credits { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 22px; }
.credits__title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-faint); margin-bottom: 8px; }
.credits__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; color: var(--fg-muted); }

.trailers { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.trailer { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #000; }
.trailer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Comments ---------- */
.comments { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.comment { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.comment__head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.comment__avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--secondary), var(--accent)); color: #fff; font-weight: 700; }
.comment__meta { display: flex; flex-direction: column; }
.comment__name { font-weight: 600; }
.comment__date { font-size: 12px; color: var(--fg-faint); }
.comment__rate { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--gold); font-weight: 700; font-size: 13px; }
.comment__text { margin: 0; color: var(--fg-muted); white-space: pre-line; }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 26px; }
.pager__link { padding: 9px 20px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--border); font-weight: 600; font-size: 13.5px; color: var(--fg-muted); }
.pager__link:hover { color: var(--fg); border-color: var(--secondary); }
.pager__link.is-disabled { opacity: 0.4; }
.pager__status { font-size: 13px; color: var(--fg-faint); }

/* ---------- App CTA ---------- */
.app-cta {
    display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
    padding: 28px 32px;
    border-radius: var(--radius-lg);
    background: linear-gradient(120deg, var(--secondary), var(--primary));
    border: 1px solid var(--border-strong);
}
.app-cta h2 { font-size: 22px; margin-bottom: 6px; }
.app-cta p { margin: 0; color: rgba(248, 250, 252, 0.82); }

/* ---------- Static / errors ---------- */
.static-page { max-width: 820px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px 38px; display: flex; flex-direction: column; gap: 20px; }
.static-page h1 { font-size: 30px; }
.static-page__body { color: var(--fg-muted); display: flex; flex-direction: column; gap: 14px; }
.static-page__body p { margin: 0; }

.error-page { text-align: center; padding: 70px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.error-page__code { font-size: 84px; font-weight: 800; line-height: 1; background: linear-gradient(135deg, var(--secondary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-page p { color: var(--fg-muted); margin: 0; max-width: 460px; }
.error-page__actions { display: flex; gap: 12px; margin-top: 10px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 34px 28px; display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; color: var(--fg-muted); }
.footer__brand p { margin: 8px 0 0; font-size: 13.5px; max-width: 420px; color: var(--fg-faint); }
.footer__links { display: flex; flex-wrap: wrap; gap: 16px; align-content: flex-start; justify-content: flex-end; font-size: 13.5px; }
.footer__links a:hover { color: var(--accent); }
.footer__rights { grid-column: 1 / -1; margin: 0; font-size: 12.5px; color: var(--fg-faint); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 56px 20px; color: var(--fg-faint); text-align: center; }
.empty p { margin: 0; max-width: 420px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
    .hero__poster { flex-basis: 150px; }
    .hero__poster img { width: 150px; height: 225px; }
    .hero__title { font-size: 28px; }
}

@media (max-width: 900px) {
    .site-header__inner { gap: 10px 12px; flex-wrap: wrap; }
    .brand { order: 1; }
    .site-header__actions { order: 2; margin-inline-start: auto; gap: 4px; }
    .nav { order: 3; flex-basis: 100%; flex-wrap: wrap; }
    .detail__inner { flex-direction: column; padding: 26px 22px; }
    .detail__poster, .detail__poster img { width: 160px; height: 240px; flex-basis: auto; }
    .hero__inner { flex-direction: column; align-items: flex-start; padding: 30px 24px; }
    .hero__viewport { min-height: 0; }
    .footer { grid-template-columns: 1fr; }
    .footer__links { justify-content: flex-start; }
}

@media (max-width: 560px) {
    .content { padding: 20px 16px 48px; }
    .site-header__inner { padding: 10px 16px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 16px 12px; }
    .rail__track { grid-auto-columns: 132px; }
    .card--landscape .rail__track { grid-auto-columns: 240px; }
    .detail__body h1 { font-size: 26px; }
    .static-page { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
