/* ===================== Reset & Base ===================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --accent: #e50914;
  --bg: #0d0d12;
  --bg-elevated: #16161d;
  --bg-card: #1c1c24;
  --text: #f2f2f5;
  --text-muted: #9a9aa5;
  --border: #2a2a34;
  --radius: 10px;
  --gutter: clamp(16px, 4vw, 32px); /* horizontal page spacing: 16px phones -> 32px desktops */
  --font: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
}
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  /* Sticky footer: footer always sits at the bottom even on short pages */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.site-main { flex: 1 0 auto; width: 100%; }
.site-header, .site-footer { flex-shrink: 0; }
input, button, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { max-width: 1200px; margin: 0 auto; padding-inline: var(--gutter); }
.section { padding-block: 28px; } /* vertical only, so it never wipes the container's side padding */
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-head a { color: var(--accent); font-size: 14px; }
.empty { color: var(--text-muted); padding: 12px 0; }

/* ===================== Header ===================== */
.site-header { background: var(--bg-elevated); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 20px; padding-block: 12px; flex-wrap: wrap; }
.logo { font-size: 22px; font-weight: 800; color: var(--accent); }
.main-nav { display: flex; gap: 16px; flex: 1; }
.main-nav a { color: var(--text-muted); font-weight: 600; }
.main-nav a:hover { color: var(--text); }
.main-nav a.active { color: var(--accent); }
.header-search { display: flex; align-items: center; margin-inline-start: auto; }
.header-search-wrap { position: relative; margin-inline-start: auto; }
.header-search-wrap .header-search { margin-inline-start: 0; }

.header-search {
  display: flex; align-items: center; gap: 2px;
  background: var(--bg-card); border: 1.5px solid var(--border); border-radius: 999px;
  padding: 3px 4px 3px 14px; width: 220px; transition: border-color .18s ease, box-shadow .18s ease, width .18s ease;
}
.header-search:focus-within {
  border-color: var(--accent); width: 260px;
  box-shadow: 0 0 0 4px rgba(229, 9, 20, .14);
}
.header-search input {
  background: transparent; border: none; color: var(--text); font-size: 14px;
  padding: 6px 4px; width: 100%; min-width: 0;
}
.header-search input:focus { outline: none; }
.header-search input::placeholder { color: var(--text-muted); }

.header-search-submit {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; transition: transform .15s ease, filter .15s ease;
}
.header-search-submit:hover { filter: brightness(1.1); transform: scale(1.06); }
.header-search-submit:active { transform: scale(.94); }
.header-search-submit svg { display: block; }

/* ===================== Hamburger toggle (mobile/tablet only) ===================== */
.menu-toggle {
  display: none; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  width: 40px; height: 40px; flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 8px;
  margin-inline-start: auto;
}
.menu-toggle span { display: block; width: 100%; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }

/* ===================== Full-screen mobile menu overlay ===================== */
.mobile-menu-overlay {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; flex-direction: column; padding: 16px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  overflow-y: auto;
}
.mobile-menu-overlay.hidden { display: none; }
.mobile-menu-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.mobile-menu-header .logo { font-size: 20px; font-weight: 800; color: var(--accent); }
.mobile-menu-close {
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 50%;
  color: var(--text); font-size: 24px; line-height: 1; cursor: pointer;
}
.mobile-menu-close:hover { border-color: var(--accent); color: var(--accent); }

.mobile-menu-search { display: flex; align-items: center; gap: 8px; margin-bottom: 26px; }
.mobile-menu-search input {
  flex: 1; min-width: 0; background: var(--bg-card); border: 1.5px solid var(--border); border-radius: 999px;
  color: var(--text); padding: 12px 16px; font-size: 15px;
}
.mobile-menu-search input::placeholder { color: var(--text-muted); }
.mobile-menu-search input:focus { outline: none; border-color: var(--accent); }
.mobile-menu-search button {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--accent); color: #fff; cursor: pointer;
}

.mobile-menu-nav { display: flex; flex-direction: column; gap: 2px; }
.mobile-menu-link {
  padding: 16px 14px; font-size: 16px; font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--border); border-radius: 8px;
}
.mobile-menu-link:hover { background: var(--bg-card); }
.mobile-menu-link.active { color: var(--accent); background: rgba(229, 9, 20, .1); }

body.menu-open { overflow: hidden; }

@media (max-width: 900px) {
  .main-nav, .header-search-wrap { display: none; }
  .menu-toggle { display: flex; }
}
@media (min-width: 901px) {
  .mobile-menu-overlay { display: none !important; }
}
.search-dropdown {
  position: absolute; top: calc(100% + 6px); inset-inline-start: 0; inset-inline-end: 0;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0,0,0,.35); max-height: 420px; overflow-y: auto; z-index: 60;
}
.search-dropdown.hidden { display: none; }
.search-group-label { padding: 8px 12px 4px; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.search-result-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.search-result-item:hover { background: var(--bg-elevated); }
.search-result-item img { width: 36px; height: 50px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.search-result-item span { font-size: 14px; }
.search-empty { padding: 14px 12px; color: var(--text-muted); font-size: 13px; text-align: center; }

/* ===================== Hero ===================== */
.hero { padding-block: 40px; text-align: center; }
.hero h1 { font-size: 32px; margin-bottom: 8px; }
.hero p { color: var(--text-muted); }

/* ===================== Cards / Grid ===================== */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.grid-cards--roomy { gap: 24px; }
.related-section { margin-top: 12px; }
.related-section h2 { margin-bottom: 14px; }
.card { background: var(--bg-card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); transition: transform .15s ease; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-4px); border-color: var(--accent); }
.card img { aspect-ratio: 2/3; object-fit: cover; width: 100%; background: var(--bg-elevated); }
.card-title { padding: 8px 10px; font-size: 14px; font-weight: 600; text-align: center; align-self: center; }
.card-views { padding: 0 10px 8px; font-size: 12px; color: var(--text-muted); }

/* ===================== Genre chips ===================== */
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; font-size: 13px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ===================== Breadcrumbs ===================== */
.breadcrumbs { padding: 14px 0; font-size: 13px; color: var(--text-muted); }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumbs li:not(:last-child)::after { content: '›'; margin-inline-start: 6px; }
.breadcrumbs a:hover { color: var(--accent); }

/* ===================== Anime details ===================== */
.details-hero { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 30px; }
.details-hero .poster { width: 220px; border-radius: var(--radius); }
.details-info { flex: 1; min-width: 260px; }
.details-info h1 { font-size: 28px; margin-bottom: 4px; }
.original-title { color: var(--text-muted); margin-bottom: 10px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-muted); font-size: 14px; margin: 10px 0; }
.description { margin-top: 14px; color: var(--text); white-space: pre-line; }

.season-block { margin-top: 30px; }
.season-block h2 { margin-bottom: 12px; font-size: 20px; border-inline-start: 4px solid var(--accent); padding-inline-start: 10px; }
.episode-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.episode-list:has(.episode-item--text) { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.episode-item--text { display: flex; align-items: center; justify-content: center; min-height: 44px; font-weight: 700; }
.episode-item--text span { padding: 10px; }
.episode-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 13px; }
.episode-item img { aspect-ratio: 16/9; object-fit: cover; background: var(--bg-elevated); }
.episode-item span { display: block; padding: 8px 10px; text-align: center; }
.episode-item:hover { border-color: var(--accent); }

/* ===================== Watch page ===================== */
.watch-page h1 { font-size: 22px; margin-bottom: 16px; }
.video-wrapper { position: relative; width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-wrapper video { width: 100%; max-height: 70vh; display: block; }
.video-wrapper iframe { width: 100%; aspect-ratio: 16 / 9; min-height: 220px; max-height: 78vh; border: 0; display: block; background: #000; }
.no-source { padding: 40px 16px; text-align: center; color: var(--text-muted); }

/* Server picker */
.source-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.source-picker-label { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-inline-end: 2px; }
.source-btn { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 6px 16px; font-size: 13px; font-weight: 700; cursor: pointer; transition: border-color .15s, background .15s; }
.source-btn:hover { border-color: #45455a; }
.source-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.source-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.episode-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.episode-actions--single { justify-content: center; } /* movie page: lone report button sits centered, like in the episode row */
.views-count { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

.btn { display: inline-block; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 14px; }
.btn:hover { filter: brightness(1.1); }
.btn-nav { display: inline-flex; align-items: center; gap: 6px; }
.btn-arrow { flex-shrink: 0; }
.btn.disabled { background: var(--bg-card); color: var(--text-muted); cursor: not-allowed; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* ===================== Episode/Season quick navigator ===================== */
.ep-navigator { margin-top: 26px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.ep-navigator-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.ep-navigator-head h2 { font-size: 17px; }
.ep-navigator-panel.hidden { display: none; }
.season-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.season-tab { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-muted); border-radius: 20px; padding: 6px 16px; font-size: 13px; font-weight: 700; cursor: pointer; }
.season-tab:hover { color: var(--text); }
.season-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.season-episodes-panel h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }
.episode-number-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ep-number {
  display: flex; align-items: center; justify-content: center; padding: 10px 8px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--text); white-space: nowrap;
}
.ep-number:hover { border-color: var(--accent); color: var(--accent); }
.ep-number[hidden] { display: none; }
.ep-pagination { justify-content: center; align-items: center; margin-top: 16px; }
.ep-pagination[hidden] { display: none; }
.ep-pagination .page-link { background: var(--bg-elevated); color: var(--text); cursor: pointer; font-family: inherit; min-width: 38px; text-align: center; }
.ep-pagination .page-link:hover:not(:disabled):not(.active) { border-color: var(--accent); color: var(--accent); }
.ep-pagination .page-link:disabled { opacity: .4; cursor: not-allowed; }
.ep-pagination .page-link.active { color: #fff; }
.ep-pagination { gap: 6px; }
.ep-pagination .page-link { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
@media (max-width: 480px) {
  .ep-pagination { gap: 4px; }
  .ep-pagination .page-link { min-width: 30px; padding: 6px 5px; font-size: 12px; }
  .ep-pagination { flex-wrap: nowrap; }
  .ep-pagination .ep-lbl { display: none; }
}
.ep-page-gap { color: var(--text-muted); padding: 0 2px; }
.ep-number.current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ===================== Modal (Report) ===================== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-content { background: var(--bg-elevated); border-radius: var(--radius); padding: 24px; width: 90%; max-width: 480px; position: relative; max-height: 90vh; overflow-y: auto; }
.modal-close { position: absolute; top: 10px; inset-inline-end: 14px; background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; }
body.modal-open { overflow: hidden; }
.modal { backdrop-filter: blur(3px); padding: 16px; }
.modal-close:hover { color: var(--text); }

/* ===================== Report-a-problem modal ===================== */
.rp-box { max-width: 520px; width: 100%; padding: 26px 24px 22px; border: 1px solid var(--border); box-shadow: 0 24px 60px rgba(0,0,0,.5); animation: rp-pop .18s ease-out; }
@keyframes rp-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.rp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding-inline-end: 24px; }
.rp-head-icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: rgba(229, 9, 20, .14); font-size: 22px; }
.rp-head h2 { font-size: 18px; line-height: 1.3; }
.rp-subject { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.rp-types { border: 0; margin-bottom: 16px; min-width: 0; }
.rp-types legend, .rp-label { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; padding: 0; }
.rp-label small { font-weight: 500; opacity: .8; }
.rp-type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rp-type { display: block; cursor: pointer; }
/* Visually hidden radio (clip technique - no off-screen positioning, safe for RTL) */
.rp-type input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); border: 0; opacity: 0; }
.rp-type-card { display: flex; align-items: center; gap: 8px; padding: 11px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px; font-weight: 600; transition: border-color .15s, background .15s; }
.rp-type-icon { font-size: 16px; }
.rp-type:hover .rp-type-card { border-color: #45455a; }
.rp-type input:checked + .rp-type-card { border-color: var(--accent); background: rgba(229, 9, 20, .12); }
.rp-type input:focus-visible + .rp-type-card { outline: 2px solid var(--accent); outline-offset: 2px; }

.rp-field { display: flex; flex-direction: column; margin-bottom: 14px; }
.rp-field textarea, .rp-field input { width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 10px 12px; font-size: 14px; transition: border-color .15s; }
.rp-field textarea { resize: vertical; min-height: 84px; }
.rp-field textarea:focus, .rp-field input:focus { outline: none; border-color: var(--accent); }
.rp-counter { align-self: flex-end; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.rp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.rp-error { background: rgba(229, 9, 20, .14); color: #ff8085; border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.rp-error.hidden, .rp-success.hidden, #reportFormView.hidden { display: none; }
.rp-actions { display: flex; gap: 10px; justify-content: flex-end; }
.rp-submit { position: relative; min-width: 130px; }
.rp-submit:disabled { opacity: .75; cursor: progress; }
.rp-spinner { display: none; width: 16px; height: 16px; margin-inline-start: 8px; vertical-align: -3px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: rp-spin .7s linear infinite; }
.rp-submit.is-loading .rp-spinner { display: inline-block; }
@keyframes rp-spin { to { transform: rotate(360deg); } }

.rp-success { text-align: center; padding: 18px 8px 6px; }
.rp-success-icon { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 50%; background: rgba(46, 204, 113, .16); color: #2ecc71; font-size: 30px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.rp-success h2 { font-size: 20px; margin-bottom: 6px; }
.rp-success p { color: var(--text-muted); margin-bottom: 18px; }

@media (max-width: 520px) {
  .modal { align-items: flex-end; padding: 0; }
  .rp-box { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .rp-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .rp-box, .rp-spinner { animation: none; } }

/* ===================== Forms ===================== */
.form { display: flex; flex-direction: column; gap: 14px; max-width: 600px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.form input, .form textarea, .form select {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 10px 12px; font-family: inherit; font-size: 14px;
}
.narrow { max-width: calc(600px + var(--gutter) * 2); margin: 0 auto; }
.request-intro { color: var(--text-muted); margin: 8px 0 20px; }
.req { color: var(--accent); }
/* Honeypot anti-spam field: invisible to humans, no off-screen positioning (which breaks RTL layouts by adding horizontal scroll) */
.hp-field { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; opacity: 0; pointer-events: none; }
.form-section-title { font-weight: 700; color: var(--text-muted); font-size: 13px; border-top: 1px solid var(--border); padding-top: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.alert-success { background: rgba(46, 204, 113, .15); color: #2ecc71; }
.alert-error { background: rgba(229, 9, 20, .15); color: #ff6b6f; }

/* ===================== Pagination ===================== */
.pagination { display: flex; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.page-link { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.page-link.active { background: var(--accent); border-color: var(--accent); }

/* ===================== Filters ===================== */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
h1 + .filters { margin-top: 16px; } /* breathing room between the page title and its filters */
.filters select { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 10px; }

/* ===================== Footer ===================== */
.site-footer { background: var(--bg-elevated); border-top: 1px solid var(--border); margin-top: 40px; padding: 24px 0; }
.footer-inner { text-align: center; }
.copyright { color: var(--text-muted); font-size: 13px; }

/* ===================== Responsive ===================== */
@media (max-width: 640px) {
  /* Episode page actions on phones: previous + next share the first row, "report" drops to its own row.
     DOM order is unchanged (prev, report, next) so desktop/tablet are untouched; only `order` moves report last. */
  .episode-actions { gap: 10px; }
  .episode-actions .btn-nav { flex: 1 1 0; min-width: 0; justify-content: center; padding: 10px 12px; font-size: 13px; }
  .episode-actions #reportBtn { order: 3; flex: 1 0 100%; text-align: center; }
  .details-hero { flex-direction: column; }
  .details-hero .poster { width: 100%; max-width: 220px; }
}

.captcha-field input { max-width: 120px; align-self: flex-start; text-align: center; letter-spacing: 2px; }
.captcha-turnstile { min-height: 70px; }
.captcha-turnstile input { max-width: none; }
