/* ============================================
   المستشارة يمنى الخضر — منصة محاضرات القانون
   ============================================ */

:root {
  --font-ui: "Tajawal", "Segoe UI", system-ui, sans-serif;
  --font-display: "Amiri", "Tajawal", serif;

  --bg: #f6f3ec;
  --bg-soft: #efeadd;
  --card: #ffffff;
  --ink: #16241e;
  --ink-2: #5c6b63;
  --hairline: #e3ddcf;
  --emerald: #0e3b2e;
  --emerald-2: #12503d;
  --emerald-soft: #e7efea;
  --gold: #b8912a;
  --gold-2: #d4af37;
  --gold-soft: #f4ecd7;
  --danger: #a33c2e;
  --shadow-sm: 0 1px 2px rgba(22, 36, 30, .06), 0 2px 8px rgba(22, 36, 30, .05);
  --shadow-md: 0 4px 14px rgba(22, 36, 30, .10), 0 14px 40px rgba(22, 36, 30, .08);
  --radius: 18px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --bg: #0b1512;
  --bg-soft: #0f1d18;
  --card: #12241e;
  --ink: #ece5d3;
  --ink-2: #9db0a6;
  --hairline: #213830;
  --emerald: #2e7d5f;
  --emerald-2: #37966f;
  --emerald-soft: #153129;
  --gold: #d4af37;
  --gold-2: #e3c56a;
  --gold-soft: #2a2413;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 10px rgba(0, 0, 0, .25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .4), 0 16px 46px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .35s ease, color .35s ease;
}

.wrap { max-width: 1060px; margin-inline: auto; padding-inline: 20px; }

::selection { background: var(--gold-2); color: #1a1405; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background .35s ease;
}
.topbar.is-scrolled { border-bottom-color: var(--hairline); }

.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-block: 10px;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--emerald), var(--emerald-2));
  color: var(--gold-2);
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.brand-text strong { font-size: 15.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 12px; color: var(--ink-2); }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .3s ease;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.icon-btn svg { width: 19px; height: 19px; }
.ic-sun { display: none; }
[data-theme="dark"] .ic-sun { display: block; }
[data-theme="dark"] .ic-moon { display: none; }

/* ---------- Hero ---------- */

.view { min-height: 60vh; }

.view > section { animation: rise .45s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .view > section { animation: none; }
  html { scroll-behavior: auto; }
}

.hero {
  position: relative;
  margin: 22px 0 8px;
  border-radius: 26px;
  overflow: hidden;
  background: linear-gradient(120deg, #0e3b2e 0%, #0a2c22 55%, #08231b 100%);
  color: #f3eedd;
  box-shadow: var(--shadow-md);
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image: url("hero.webp");
  background-size: cover;
  background-position: left center;
  opacity: .95;
}
[data-theme="dark"] .hero::before { opacity: .75; }
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to left, rgba(8, 32, 25, .93) 22%, rgba(8, 32, 25, .55) 55%, rgba(8, 32, 25, .05) 100%);
}
.hero-inner {
  position: relative; z-index: 1;
  padding: 52px 34px 42px;
  display: flex; flex-direction: column; gap: 18px;
}
.hero-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  align-self: flex-start;
  font-size: 12.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--gold-2);
  border: 1px solid rgba(212, 175, 55, .45);
  background: rgba(212, 175, 55, .12);
  padding: 5px 12px; border-radius: 999px;
}
.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(30px, 5.4vw, 52px);
  line-height: 1.35;
}
.hero p.lead {
  margin: 0; max-width: 560px;
  font-size: clamp(14.5px, 2vw, 17px);
  color: #d8d2bf;
}
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.stat-chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; color: #e7e1cf;
  backdrop-filter: blur(4px);
}
.stat-chip b { font-size: 16px; font-weight: 800; color: var(--gold-2); }

/* ---------- Search ---------- */

.searchbar { position: relative; margin: 26px 0 6px; }
.searchbar svg {
  position: absolute; inset-inline-start: 16px; top: 50%;
  translate: 0 -50%;
  width: 19px; height: 19px; color: var(--ink-2);
  pointer-events: none;
}
.searchbar input {
  width: 100%;
  padding: 15px 48px 15px 18px;
  font: inherit; font-size: 15.5px;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--hairline);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .3s ease;
}
.searchbar input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 18%, transparent);
}
.searchbar input::placeholder { color: var(--ink-2); }

/* ---------- Sections ---------- */

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 30px 0 16px;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(21px, 3vw, 27px);
  font-weight: 700;
}
.section-head .hint { font-size: 13px; color: var(--ink-2); }

/* ---------- Course grid ---------- */

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.course-card {
  position: relative;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .25s ease, border-color .25s ease, background .3s ease;
  animation: rise .5s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.course-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--gold) 55%, var(--hairline));
  box-shadow: var(--shadow-md);
}
.course-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--gold) 55%, transparent); outline-offset: 2px; }

.course-top { display: flex; align-items: flex-start; gap: 13px; }
.course-num {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700;
  color: var(--gold-2);
  background: linear-gradient(145deg, var(--emerald), var(--emerald-2));
  border-radius: 13px;
  box-shadow: var(--shadow-sm);
}
.course-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.course-subject { font-size: 17.5px; font-weight: 800; line-height: 1.45; }
.course-prof {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--ink-2);
}
.course-prof svg { width: 14px; height: 14px; flex: none; }

.course-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 13px;
  border-top: 1px dashed var(--hairline);
}
.count-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700;
  color: var(--emerald-2);
  background: var(--emerald-soft);
  padding: 4px 11px; border-radius: 999px;
}
[data-theme="dark"] .count-chip { color: #7fc7a8; }
.count-chip svg { width: 13px; height: 13px; }
.course-go {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 700; color: var(--gold);
  transition: gap .2s ease;
}
.course-card:hover .course-go { gap: 9px; }
.course-go svg { width: 15px; height: 15px; }

/* ---------- Search results ---------- */

.results-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 40px; }
.no-results {
  padding: 34px 20px; text-align: center;
  color: var(--ink-2); font-size: 14.5px;
  background: var(--card); border: 1px dashed var(--hairline);
  border-radius: var(--radius);
}

/* ---------- Course page ---------- */

.crumb {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 22px 0 14px;
  font-size: 13.5px; font-weight: 700;
  color: var(--ink-2); text-decoration: none;
  transition: color .2s ease;
}
.crumb:hover { color: var(--gold); }
.crumb svg { width: 15px; height: 15px; }

.course-hero {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
  padding: 26px 26px 22px;
  margin-bottom: 22px;
  background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-2) 100%);
  border-radius: 22px;
  color: #f3eedd;
  box-shadow: var(--shadow-md);
}
.course-hero .course-num {
  width: 58px; height: 58px;
  font-size: 26px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(212, 175, 55, .5);
  box-shadow: none;
}
.course-hero-meta { flex: 1; min-width: 220px; }
.course-hero h1 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.4;
}
.course-hero .prof { display: flex; align-items: center; gap: 7px; font-size: 14.5px; color: #cfd8c9; margin: 0; }
.course-hero .prof svg { width: 15px; height: 15px; }
.course-hero .count-chip {
  background: rgba(212, 175, 55, .16);
  border: 1px solid rgba(212, 175, 55, .4);
  color: var(--gold-2);
}

/* ---------- Lectures ---------- */

.lecture-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 26px; }

.lecture-card {
  display: flex; align-items: center; gap: 15px;
  padding: 15px 18px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .2s ease, box-shadow .2s ease, background .3s ease;
  animation: rise .45s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
.lecture-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--gold) 45%, var(--hairline));
  box-shadow: var(--shadow-md);
}

.lecture-badge {
  flex: none;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700;
  color: var(--emerald-2);
  background: var(--emerald-soft);
}
[data-theme="dark"] .lecture-badge { color: #8fd3b3; }
.lecture-badge.is-cases { color: var(--gold); background: var(--gold-soft); }

.lecture-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lecture-name { font-size: 15px; font-weight: 700; line-height: 1.5; }
.lecture-file {
  font-size: 12px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kind-chip {
  align-self: flex-start;
  font-size: 11px; font-weight: 700;
  color: var(--gold);
  background: var(--gold-soft);
  padding: 2px 9px; border-radius: 999px;
  margin-bottom: 2px;
}

.lecture-actions { display: flex; gap: 8px; flex: none; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px;
  font: inherit; font-size: 13.5px; font-weight: 700;
  border-radius: 11px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(140deg, var(--emerald), var(--emerald-2));
  color: #f3eedd;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.btn-ghost {
  background: var(--card);
  color: var(--ink);
  border-color: var(--hairline);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

.btn-gold {
  background: linear-gradient(140deg, var(--gold), #96741c);
  color: #fffdf4;
  box-shadow: var(--shadow-sm);
}
.btn-gold:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.btn-sm { padding: 7px 13px; font-size: 12.5px; border-radius: 9px; }

/* ---------- Prev / next ---------- */

.pn-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 44px;
}
.pn-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 15px 18px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease, transform .15s ease;
}
.pn-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.pn-card small { font-size: 12px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; }
.pn-card small svg { width: 13px; height: 13px; }
.pn-card strong { font-size: 14.5px; }
.pn-card.next { text-align: end; align-items: flex-end; }
.pn-card.disabled { opacity: .45; pointer-events: none; }

/* ---------- Viewer modal ---------- */

.viewer { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; }
.viewer[hidden] { display: none; }
.viewer-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 15, 12, .62);
  backdrop-filter: blur(6px);
  animation: fade .25s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.viewer-panel {
  position: relative;
  width: min(1040px, 100%);
  height: min(88vh, 900px);
  display: flex; flex-direction: column;
  background: var(--card);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .45);
  animation: pop .3s cubic-bezier(.2, .8, .3, 1.05) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(22px) scale(.985); } to { opacity: 1; transform: none; } }

.viewer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--hairline);
}
.viewer-meta { display: flex; flex-direction: column; line-height: 1.5; min-width: 0; }
.viewer-meta strong { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-meta small { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.viewer-body { position: relative; flex: 1; background: var(--bg-soft); }
.viewer-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.viewer-loading {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--ink-2); font-size: 14px;
  background: var(--bg-soft);
  transition: opacity .3s ease;
}
.viewer-loading.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--hairline);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Footer ---------- */

.footer {
  margin-top: 30px;
  border-top: 1px solid var(--hairline);
  padding: 26px 0 40px;
  text-align: center;
}
.footer-line { margin: 0 0 4px; font-weight: 700; font-size: 14px; }
.footer-sub { margin: 0; font-size: 12.5px; color: var(--ink-2); }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .wrap { padding-inline: 15px; }
  .hero { border-radius: 20px; margin-top: 14px; }
  .hero-inner { padding: 34px 22px 30px; }
  .course-grid { grid-template-columns: 1fr; gap: 12px; }
  .lecture-card { flex-wrap: wrap; padding: 13px 14px; }
  .lecture-actions { width: 100%; }
  .lecture-actions .btn { flex: 1; }
  .pn-nav { grid-template-columns: 1fr; }
  .course-hero { padding: 20px; }
  .viewer { padding: 0; }
  .viewer-panel { height: 100dvh; width: 100%; border-radius: 0; }
  .viewer-actions .btn span.lbl { display: none; }
  .brand-text small { display: none; }
}
