/* =====================================================
   BlueStream — الأساس (style.css)
   محايدة فاخرة + لون هوية كـ"توقيع" مركّز
   ===================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: "Cairo", "Tajawal", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

/* زخرفة محايدة خلفية: دوائر كبيرة بشفافية منخفضة جداً (بلا لون هوية) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(620px 620px at 88% -8%, rgba(255,255,255,0.05), transparent 60%),
    radial-gradient(520px 520px at -6% 12%, rgba(255,255,255,0.04), transparent 60%);
}

::selection { background: var(--accent-soft); color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-3); }
.hidden { display: none !important; }

/* ===== الهيدر ===== */
.topbar {
  position: fixed; top: 0; inset-inline: 0; z-index: 50;
  display: flex; align-items: center; gap: 32px;
  padding: 14px var(--side-pad);
  background: linear-gradient(180deg, rgba(9,9,11,0.92) 0%, rgba(9,9,11,0) 100%);
  transition: background var(--transition);
}
.topbar.scrolled {
  background: rgba(9,9,11,0.88);
  backdrop-filter: blur(16px) saturate(120%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.3rem; font-weight: 800; white-space: nowrap; user-select: none; }
.brand-icon {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  font-size: 0.82rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
}
.brand-name b { font-weight: 900; }

.main-nav { display: flex; gap: 4px; }
.nav-link {
  position: relative; padding: 8px 16px; border: 1px solid transparent;
  border-radius: var(--radius-sm); background: transparent;
  color: var(--text-dim); font-family: inherit; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); background: var(--surface); border-color: var(--border); }
.nav-link.active::after {
  content: ""; position: absolute; top: 50%; inset-inline-end: 8px;
  transform: translateY(-50%); width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-solid); box-shadow: var(--accent-glow);
}

.search-wrap { position: relative; margin-inline-start: auto; width: clamp(160px,24vw,340px); }
.search-input {
  width: 100%; padding: 10px 40px 10px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--bg-raised); color: var(--text);
  font-family: inherit; font-size: 0.92rem; outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus { border-color: var(--border-strong); background: var(--surface); }
.search-icon {
  position: absolute; inset-inline-end: 14px; top: 50%;
  transform: translateY(-50%); color: var(--text-faint);
  font-size: 1.1rem; pointer-events: none;
}

/* ===== الهيرو ===== */
.hero { position: relative; min-height: 82vh; display: flex; align-items: flex-end; z-index: 1; }
.hero-backdrop { position: absolute; inset: 0; overflow: hidden; }
.hero-backdrop img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.hero-backdrop::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to left, rgba(9,9,11,0.95) 6%, rgba(9,9,11,0.5) 42%, rgba(9,9,11,0.12) 75%),
    linear-gradient(to top, var(--bg) 2%, rgba(9,9,11,0.6) 24%, transparent 58%);
}
.hero-content { position: relative; z-index: 2; max-width: 640px; padding: 0 var(--side-pad) 96px; animation: hero-in 0.7s var(--ease); }
@keyframes hero-in { from { transform: translateY(26px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.hero-content h1 {
  font-size: clamp(1.9rem,4.4vw,3.4rem); font-weight: 900;
  line-height: 1.2; margin-bottom: 16px; letter-spacing: -0.5px;
  text-shadow: 0 4px 30px rgba(0,0,0,0.8);
}
.hero-meta { display: flex; gap: 10px; margin-bottom: 16px; }
.hero-badge {
  padding: 4px 12px; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 700;
  color: var(--text-dim); background: rgba(9,9,11,0.6); backdrop-filter: blur(6px);
  border: 1px solid var(--border);
}
.hero-badge-type { color: var(--text); border-color: var(--border-strong); }
.hero-content p {
  font-size: 1rem; line-height: 1.85; color: var(--text-dim); font-weight: 400;
  margin-bottom: 26px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; text-shadow: 0 2px 12px rgba(0,0,0,0.7);
}
.hero-actions { display: flex; gap: 14px; }

/* ===== الأزرار ===== */
.btn-play {
  padding: 13px 40px; border: none; border-radius: var(--radius-pill);
  font-size: 1.05rem; font-weight: 800; font-family: inherit;
  color: #000; background: #fff; cursor: pointer;
  transition: transform var(--transition), opacity var(--transition);
}
.btn-play:hover { transform: scale(1.04); }
.btn-play:active { transform: scale(1); }
.btn-play:disabled { opacity: 0.55; cursor: wait; transform: none; }

.btn-info {
  padding: 13px 32px; border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  font-size: 1.05rem; font-weight: 700; font-family: inherit;
  color: var(--text); cursor: pointer;
  background: rgba(255,255,255,0.06); backdrop-filter: blur(8px);
  transition: background var(--transition), transform var(--transition);
}
.btn-info:hover { background: rgba(255,255,255,0.1); transform: scale(1.04); }

.btn-more {
  display: block; margin: 34px auto 0; padding: 12px 46px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: transparent; color: var(--text);
  font-family: inherit; font-size: 0.98rem; font-weight: 700; cursor: pointer;
  transition: background var(--transition);
}
.btn-more:hover { background: var(--surface); }
.btn-more:disabled { opacity: 0.55; cursor: wait; }

/* ===== الصفوف والشبكات ===== */
.rows-wrap { position: relative; z-index: 3; margin-top: -52px; padding: 0 var(--side-pad) 80px; }
.page-section { position: relative; z-index: 3; padding: 108px var(--side-pad) 80px; }
.row-section { margin-bottom: 40px; }
.row-title {
  display: flex; align-items: center; gap: 12px;
  font-size: 1.22rem; font-weight: 800; margin-bottom: 14px;
}
.row-title::before {
  content: ""; width: 6px; height: 18px; border-radius: var(--radius-pill);
  background: var(--accent-solid); box-shadow: var(--accent-glow);
}
.row-scroller {
  display: flex; gap: 12px; overflow-x: auto; padding: 8px 2px 18px;
  scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--surface-2) transparent;
}
.row-scroller > * { scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px,1fr)); gap: 14px; }

/* ===== البطاقة ===== */
.card {
  position: relative; flex: 0 0 176px; width: 176px;
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid transparent;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
  will-change: transform;
}
.grid .card { width: auto; flex: initial; }
.card:hover, .card.active {
  transform: translateY(-4px); background: var(--surface-2); border-color: var(--border-strong);
}
.card-poster { position: relative; aspect-ratio: 2/3; background: var(--surface-2); }
.card-poster img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s var(--ease); }
.card:hover .card-poster img { transform: scale(1.06); }
.card-rating {
  position: absolute; z-index: 3; top: 8px; inset-inline-start: 8px;
  padding: 3px 9px; border-radius: var(--radius-pill); font-size: 0.72rem; font-weight: 700;
  color: var(--text); background: rgba(9,9,11,0.78); backdrop-filter: blur(4px);
  border: 1px solid var(--border);
}
/* نقطة الحالة: رمادي باهت → لون هوية + توهج عند التفعيل */
.card-status {
  position: absolute; z-index: 4; top: 10px; inset-inline-end: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint); opacity: 0.5;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.card:hover .card-status,
.card.active .card-status,
.card.available .card-status,
.card.watching .card-status,
.card.in-my-list .card-status,
.card.is-watched .card-status {
  background: var(--accent-solid); box-shadow: var(--accent-glow); opacity: 1;
}
.card-flags {
  position: absolute;
  z-index: 4;
  top: 26px;
  inset-inline-end: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.card-flag {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: rgba(9, 9, 11, 0.82);
  color: var(--text);
  font-size: 0.65rem;
  font-weight: 900;
  backdrop-filter: blur(5px);
}
.card-flag-watched {
  color: var(--accent-solid);
  box-shadow: 0 0 10px var(--accent-glow-far);
}
.card-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; padding: 12px;
  background: linear-gradient(to top, rgba(9,9,11,0.96) 0%, rgba(9,9,11,0.4) 45%, transparent 72%);
  opacity: 0; transition: opacity var(--transition);
}
.card:hover .card-overlay { opacity: 1; }
.card-overlay .card-title {
  font-size: 0.9rem; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-overlay .card-sub { font-size: 0.74rem; font-weight: 500; color: var(--text-dim); }
.card-progress { position: absolute; z-index: 4; bottom: 0; inset-inline: 0; height: 3px; background: rgba(255,255,255,0.1); }
.card-progress > span { display: block; height: 100%; background: var(--accent-solid); box-shadow: 0 0 8px var(--accent-glow-near); }
.card.completed .card-progress > span {
  box-shadow: 0 0 10px var(--accent-glow-near), 0 0 20px var(--accent-glow-far);
}
.card.completed .card-overlay .card-sub {
  color: var(--accent-solid);
  font-weight: 800;
}
.card-remove {
  position: absolute; z-index: 5; top: 8px; inset-inline-end: 8px;
  width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 50%;
  background: rgba(9,9,11,0.82); color: var(--text); font-size: 0.72rem;
  cursor: pointer; opacity: 0; transition: opacity var(--transition), background var(--transition);
}
.card:hover .card-remove { opacity: 1; }
.card-remove:hover { background: #b3261e; }

/* هيكل تحميل — وميض محايد + نقطة هوية مركزية */
.skeleton {
  position: relative; flex: 0 0 176px; width: 176px;
  border-radius: var(--radius); aspect-ratio: 2/3;
  background: var(--surface); border: 1px solid var(--border);
  background-image: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; overflow: hidden;
}
.skeleton::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 8px; height: 8px;
  border-radius: 50%; transform: translate(-50%,-50%);
  background: var(--accent-solid); box-shadow: var(--accent-glow); animation: pulse 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 50% { opacity: 0.35; } }

.row-error {
  color: var(--text-dim); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 22px; font-size: 0.9rem;
}
.load-more-wrap { text-align: center; }

.site-footer {
  position: relative;
  z-index: 3;
  padding: 20px var(--side-pad) 34px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.75rem;
  text-align: center;
}
.site-footer a {
  color: var(--text-dim);
  font-weight: 700;
  text-decoration: none;
}
.site-footer a:hover { color: var(--accent-solid); }

/* ===== الحساب والملف في الهيدر ===== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline-start: auto;
  min-width: 0;
}
.header-actions .search-wrap { margin-inline-start: 0; }
.profile-menu-wrap { position: relative; flex: 0 0 auto; }
.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 5px 10px 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(15, 15, 19, 0.88);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition:
    background var(--transition),
    border-color var(--transition),
    transform var(--transition);
}
.profile-trigger:hover,
.profile-trigger[aria-expanded="true"] {
  background: var(--surface);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.profile-trigger-name {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 700;
}
.profile-trigger-chevron {
  color: var(--text-faint);
  font-size: 0.85rem;
  transition: transform var(--transition);
}
.profile-trigger[aria-expanded="true"] .profile-trigger-chevron {
  transform: rotate(180deg);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  z-index: 80;
  width: min(330px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: rgba(15, 15, 19, 0.97);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(20px) saturate(120%);
  animation: dropdown-in 0.2s var(--ease);
}
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.profile-dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 7px 11px;
}
.profile-dropdown-head > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.profile-dropdown-head strong {
  font-size: 0.84rem;
  font-weight: 800;
}
.profile-dropdown-head span:not(.sync-dot) {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sync-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}
.sync-dot.sync-synced {
  background: var(--accent-solid);
  box-shadow: var(--accent-glow);
}
.sync-dot.sync-syncing {
  background: var(--accent-solid);
  box-shadow: var(--accent-glow);
  animation: sync-pulse 0.9s infinite alternate;
}
.sync-dot.sync-pending { background: var(--text-dim); }
.sync-dot.sync-error,
.sync-dot.sync-offline { opacity: 0.55; }
@keyframes sync-pulse { to { opacity: 0.35; } }

.profile-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 235px;
  overflow-y: auto;
}
.profile-switch-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.profile-switch-item:hover,
.profile-switch-item.active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}
.profile-switch-name {
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-switch-check {
  color: var(--accent-solid);
  font-size: 0.72rem;
  font-weight: 900;
}
.profile-menu-divider {
  height: 1px;
  margin: 9px 3px;
  background: var(--border);
}
.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.profile-menu-item > span {
  display: inline-grid;
  place-items: center;
  width: 18px;
  color: var(--text-faint);
  font-weight: 900;
}
.profile-menu-item:hover {
  background: var(--surface);
  color: var(--text);
}
.profile-auth-action { color: var(--text); font-weight: 800; }

/* ===== صفحات القوائم الخاصة ===== */
.library-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.library-page-head .row-title { margin: 5px 0 6px; }
.library-eyebrow {
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.library-description {
  max-width: 640px;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.75;
}
.library-close { flex: 0 0 auto; padding: 9px 22px; font-size: 0.82rem; }

@media (max-width: 980px) {
  :root { --side-pad: 24px; }
  .topbar { gap: 15px; flex-wrap: wrap; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; }
  .header-actions { flex: 1; }
  .header-actions .search-wrap { width: 100%; }
  .hero { min-height: 76vh; }
}

@media (max-width: 620px) {
  :root { --side-pad: 14px; }
  .topbar { padding-block: 10px; }
  .brand-name { display: none; }
  .brand-icon { width: 40px; height: 40px; }
  .profile-trigger-name { display: none; }
  .profile-trigger { padding: 4px; }
  .profile-trigger-chevron { display: none; }
  .search-input { font-size: 0.82rem; }
  .nav-link { padding: 7px 13px; font-size: 0.82rem; }
  .hero-content { padding-bottom: 66px; }
  .rows-wrap { margin-top: -24px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .card, .skeleton { flex-basis: 145px; width: 145px; }
  .library-page-head { align-items: flex-start; flex-direction: column; }
  .library-close { align-self: stretch; }
}
