/* ==========================================================
   نِبراس — الواجهة الرئيسية والتنقل
   ========================================================== */

body.w-home {
  --bg: #F6D6A1;
  --surface: #FFF4E0;
  --ink: #2A1F4A;
  --muted: #6E5A7E;
  --accent: #FFB627;
  --accent-ink: #2A1F4A;
  --line: #2A1F4A;
  --shadow: 0 4px 0 #2A1F4A;
  background: #F6D6A1;
}

/* ---------- الشريط العلوي للتطبيق ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(14px, 3vw, 32px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid color-mix(in srgb, var(--line) 14%, transparent);
}
body.w-home .appbar { position: absolute; inset-inline: 0; background: transparent; border: 0; backdrop-filter: none; color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; font-weight: 700; font-size: 1.35rem; font-family: 'Readex Pro', sans-serif; }
.brand .mini { width: 34px; }
.crumb { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; flex: 1; min-width: 0; font-weight: 600; }
.crumb a { color: inherit; text-decoration: none; opacity: .7; }
.crumb a:hover { opacity: 1; text-decoration: underline; }
.crumb .sep { opacity: .4; }
.appbar .tools { display: flex; gap: 8px; align-items: center; margin-inline-start: auto; }
body.w-home .appbar .chip, body.w-home .appbar .btn { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .55); box-shadow: none; }
body.w-home .xp-chip .bar { background: rgba(255, 255, 255, .25); }

/* ---------- البطل: صحراء عند الغروب ---------- */
.hero { position: relative; min-height: min(680px, 92vh); overflow: hidden; color: #fff; }
.hero-scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-inner {
  position: relative; z-index: 2; max-width: 1200px; margin: 0 auto;
  padding: clamp(96px, 14vh, 140px) clamp(18px, 4vw, 40px) 200px;
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); align-items: center; gap: 24px;
}
.hero .hello { font-size: clamp(1.05rem, 2vw, 1.3rem); opacity: .9; margin: 0 0 4px; }
.wordmark {
  font-family: 'Readex Pro', sans-serif; font-weight: 700;
  font-size: clamp(4rem, 11vw, 8.5rem); line-height: 1; margin: 0 0 12px;
  color: #FFE59A;
  text-shadow: 0 0 24px rgba(255, 196, 80, .75), 0 0 64px rgba(255, 150, 60, .5);
}
.hero .lead { font-size: clamp(1.15rem, 2.3vw, 1.55rem); max-width: 30ch; margin: 0 0 22px; color: #FFF4E0; }
.owner-badge {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 6px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); border: 1.5px solid rgba(255, 229, 154, .55);
  color: #FFE59A; font-weight: 700; font-size: .98rem; backdrop-filter: blur(6px);
}
.owner-badge .dot { opacity: .65; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .cta .btn { --b: #FFB627; --c: #2A1F4A; border-color: #2A1F4A; }
.hero .cta .btn.ghost { --b: rgba(255, 255, 255, .12); --c: #fff; border-color: rgba(255, 255, 255, .7); box-shadow: none; }
.hero-mascot { width: min(300px, 70%); justify-self: center; filter: drop-shadow(0 18px 30px rgba(60, 20, 80, .45)); }
@media (max-width: 760px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; padding-bottom: 170px; }
  .hero .lead { margin-inline: auto; }
  .hero .cta { justify-content: center; }
  .hero-mascot { order: -1; width: 150px; }
}

/* ---------- بوابات العوالم ---------- */
.portals {
  position: relative; z-index: 3; max-width: 1200px; margin: -150px auto 0;
  padding: 0 clamp(14px, 3vw, 32px);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 2vw, 24px);
}
@media (max-width: 900px) { .portals { grid-template-columns: 1fr; margin-top: -120px; } }
.portal {
  position: relative; display: flex; flex-direction: column; min-height: 300px; overflow: hidden;
  text-decoration: none; padding: 22px; transition: transform .18s ease;
}
.portal:hover { transform: translateY(-6px) rotate(-.4deg); }
.portal .art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.portal > *:not(.art) { position: relative; z-index: 1; }
.portal h3 { font-size: 1.9rem; margin: 0; }
.portal .stage { font-weight: 700; opacity: .85; }
.portal p { margin: 6px 0 auto; max-width: 24ch; }
.portal .go { margin-top: 16px; align-self: flex-start; }
.portal .go { font-weight: 800; padding: .35em 1.2em; border-radius: 999px; }

.portal.p-primary {
  font-family: 'Baloo Bhaijaan 2', sans-serif; color: #1D2B53;
  background: #8FD8FF; border: 3px solid #1D2B53; border-radius: 30px; box-shadow: 0 7px 0 #1D2B53;
}
.portal.p-primary .go { background: #FFCE3D; border: 3px solid #1D2B53; box-shadow: 0 4px 0 #1D2B53; }

.portal.p-middle {
  font-family: 'Readex Pro', sans-serif; color: #0B3F3C; margin-top: 18px; overflow: visible;
  background: #BFF0DC; border: 2px solid #0B3F3C; border-radius: 0 10px 10px 10px; box-shadow: 0 5px 0 #0B3F3C;
}
.portal.p-middle::before {
  content: 'ملف المهمات'; position: absolute; top: -32px; inset-inline-start: -2px; z-index: 1;
  background: #BFF0DC; border: 2px solid #0B3F3C; border-bottom: 0; border-radius: 10px 10px 0 0;
  padding: 2px 16px; font-size: .85rem; font-weight: 700;
}
.portal.p-middle .go { background: #FFA62B; border: 2px solid #0B3F3C; border-radius: 8px; color: #2B1600; }

.portal.p-secondary {
  font-family: 'IBM Plex Sans Arabic', sans-serif; color: #EAF4FF;
  background: #0E2A47; border: 1px solid #7CC4FF; border-radius: 6px;
  box-shadow: 0 0 0 6px rgba(124, 196, 255, .12);
}
.portal.p-secondary .go { background: #FF8A3D; color: #1A0B00; border-radius: 4px; }

/* ---------- الأقسام في الرئيسية ---------- */
.section { max-width: 1200px; margin: 0 auto; padding: 56px clamp(14px, 3vw, 32px) 0; }
.section > h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: 4px; }
.section > .sub { color: var(--muted); margin-bottom: 20px; }

.tickets { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.ticket {
  display: grid; grid-template-columns: 74px 1fr; gap: 14px; align-items: center;
  padding: 14px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  transition: transform .15s;
}
.ticket:hover { transform: translateY(-3px); }
.ticket .thumb { width: 74px; height: 74px; border-radius: 12px; border: 2px solid var(--line); overflow: hidden; }
.ticket .thumb svg, .ticket .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ticket small { color: var(--muted); display: block; }
.ticket strong { font-size: 1.15rem; display: block; line-height: 1.4; }
.ticket .st { display: flex; gap: 2px; margin-top: 2px; }
.ticket .st svg { width: 18px; height: 18px; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.badge-card {
  text-align: center; padding: 14px 10px; border-radius: 16px; background: var(--surface);
  border: 2px solid var(--line); box-shadow: var(--shadow);
}
.badge-card svg { width: 76px; height: 84px; margin: 0 auto 6px; }
.badge-card.locked { box-shadow: none; border-style: dashed; opacity: .75; }
.badge-card.locked svg { filter: grayscale(1) opacity(.35); }
.badge-card strong { display: block; font-size: .98rem; line-height: 1.4; }
.badge-card small { color: var(--muted); }

.footer { text-align: center; color: var(--muted); padding: 60px 20px 40px; font-size: .92rem; }
.footer-card {
  max-width: 680px; margin: 0 auto; padding: 20px 24px;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  display: grid; gap: 8px; justify-items: center;
}
.footer-card strong { font-size: 1.08rem; }
.footer-card p { margin: 0; color: var(--muted); }
.footer-links { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.footer-links a {
  color: var(--ink); text-decoration: none; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--line) 30%, transparent);
  background: color-mix(in srgb, var(--bg) 45%, transparent);
}
.footer-links a:hover { border-color: var(--line); }

/* ---------- صفحة المرحلة ---------- */
.world-head {
  max-width: 1200px; margin: 0 auto; padding: 34px clamp(14px, 3vw, 32px) 10px;
  display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center;
}
.world-head h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); margin: 0; }
.world-head .stage-name { font-weight: 700; color: var(--muted); font-size: 1.15rem; }
.world-head p { margin: 6px 0 0; font-size: 1.15rem; max-width: 46ch; }
.world-head .mini-mascot { width: 120px; }
body.w-secondary .world-head h1 { font-weight: 600; letter-spacing: 0; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 10px clamp(14px, 3vw, 32px) 80px; }

.grades { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0 28px; }
.grade-btn {
  text-decoration: none; color: var(--ink); background: var(--surface);
  border: 2px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius);
  padding: 12px 22px; display: flex; flex-direction: column; align-items: center; min-width: 120px;
  transition: transform .12s;
}
.grade-btn:hover { transform: translateY(-3px); }
.grade-btn b { font-size: 1.6rem; line-height: 1.2; }
.grade-btn span { font-size: .9rem; color: var(--muted); }
.grade-btn[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.grade-btn[aria-current="page"] span { color: inherit; opacity: .8; }
body.w-secondary .grade-btn { border-width: 1px; }

.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.subject {
  --c: #3A86FF;
  position: relative; text-decoration: none; color: var(--ink); background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 150px;
  transition: transform .12s;
}
.subject:hover { transform: translateY(-3px); }
.subject .ico {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: var(--c); color: #fff; border: 2px solid var(--line);
}
.subject .ico svg { width: 30px; height: 30px; }
.subject strong { font-size: 1.1rem; line-height: 1.4; }
.subject .count { font-size: .88rem; color: var(--muted); margin-top: auto; }
.subject .count.has { color: var(--good); font-weight: 700; }
body.w-primary .subject .ico { border-radius: 50%; }
body.w-secondary .subject { border-width: 1px; }
body.w-secondary .subject .ico { background: transparent; color: var(--c); border: 1px solid var(--c); border-radius: 4px; }
body.w-middle .subject::after {
  content: ''; position: absolute; top: 12px; inset-inline-end: 12px; width: 14px; height: 14px; border-radius: 50%;
  border: 2px dashed color-mix(in srgb, var(--line) 35%, transparent);
}

.unit { margin-bottom: 26px; }
.unit h3 { font-size: 1.35rem; display: flex; align-items: center; gap: 10px; }
.unit h3::before { content: ''; width: 10px; height: 24px; border-radius: 4px; background: var(--accent); }
.lessons { display: grid; gap: 12px; }
.lesson-row {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.lesson-row .num {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.15rem;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--line);
}
.lesson-row .t { font-size: 1.15rem; font-weight: 700; line-height: 1.4; }
.lesson-row .kinds { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.lesson-row .kinds span { font-size: .8rem; padding: 0 .6em; border-radius: 999px; background: color-mix(in srgb, var(--line) 8%, transparent); }
.lesson-row .meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.lesson-row .meta .st { display: flex; } .lesson-row .meta .st svg { width: 16px; height: 16px; }
.lesson-row.soon { box-shadow: none; border-style: dashed; opacity: .7; }
.lesson-row.soon .num { background: transparent; }
.lesson-row.soon .num svg { width: 20px; height: 20px; }
body.w-secondary .lesson-row { border-width: 1px; }
@media (max-width: 600px) { .lesson-row { grid-template-columns: 40px 1fr; } .lesson-row > :last-child { grid-column: 1 / -1; } }

.empty {
  text-align: center; padding: 34px 20px; border: 2px dashed color-mix(in srgb, var(--line) 40%, transparent);
  border-radius: var(--radius);
}
.empty .m { width: 110px; margin: 0 auto 8px; }

.head-ico { width: 84px; height: 84px; display: grid; place-items: center; border-radius: 22px; background: var(--c); color: #fff; border: 2px solid var(--line); box-shadow: var(--shadow); }
.head-ico svg { width: 48px; height: 48px; }
body.w-primary .head-ico { border-radius: 50%; }
body.w-secondary .head-ico { background: transparent; color: var(--c); border: 1px solid var(--c); border-radius: 6px; box-shadow: none; }

/* ---------- عالم محايد للبحث والأوسمة ---------- */
body.w-plain { --bg: #F6F1FA; --surface: #FFFFFF; --ink: #2A1F4A; --muted: #6E5A7E; --accent: #FFB627; --accent-ink: #2A1F4A; --line: #2A1F4A; --shadow: 0 4px 0 #2A1F4A; background: #F6F1FA; }

/* ---------- البحث ---------- */
.search-mini input {
  width: 190px; padding: .4em .9em; border-radius: 999px; border: 2px solid color-mix(in srgb, var(--line) 35%, transparent);
  background: var(--surface); color: var(--ink); font-size: .92rem;
}
body.w-home .search-mini { display: none; }
@media (max-width: 760px) { .search-mini { display: none; } }
.hero-search { display: flex; gap: 8px; margin: 0 0 18px; max-width: 560px; }
.hero-search input {
  flex: 1; min-width: 0; padding: .7em 1.1em; border-radius: 999px; font-size: 1.05rem;
  border: 2px solid rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .95); color: #2A1F4A;
}
.hero-search .btn { --b: #fff; --c: #2A1F4A; }
.hero-search.wide { max-width: 760px; }
.hero-search.wide input { border-color: var(--line); }
.results { display: grid; gap: 10px; margin-top: 12px; }
.result {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow);
}
.result .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--c); color: #fff; }
.result .ico svg { width: 26px; height: 26px; }
.result small { display: block; color: var(--muted); }
.chip.ok { background: var(--good); color: #fff; border-color: var(--good); }

/* ---------- الفصول الدراسية ---------- */
.sem-tabs { display: flex; gap: 8px; margin: -8px 0 22px; flex-wrap: wrap; }
.sem-tabs a {
  text-decoration: none; color: var(--ink); padding: .45em 1.2em; border-radius: 999px; font-weight: 700;
  border: 2px solid color-mix(in srgb, var(--line) 30%, transparent);
}
.sem-tabs a.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- الوحدات القابلة للطي ---------- */
details.unit { margin-bottom: 14px; border: 2px solid color-mix(in srgb, var(--line) 22%, transparent); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 55%, transparent); }
details.unit > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-weight: 700; font-size: 1.15rem;
}
details.unit > summary::-webkit-details-marker { display: none; }
details.unit > summary::before { content: ''; width: 10px; height: 10px; border-inline-start: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: rotate(45deg); transition: transform .2s; flex: none; }
details.unit[open] > summary::before { transform: rotate(-45deg); }
details.unit > summary .ut { flex: 1; }
details.unit > summary .uc { font-size: .85rem; color: var(--muted); font-weight: 600; }
details.unit .lessons { padding: 0 14px 14px; }
.lesson-row.compact { grid-template-columns: 40px 1fr auto; padding: 8px 14px; box-shadow: none; }
.lesson-row.compact .num { width: 32px; height: 32px; font-size: .9rem; background: transparent; }
.lesson-row.compact .t { font-size: 1rem; font-weight: 600; }
.lesson-row.soon { opacity: 1; border-style: solid; border-color: color-mix(in srgb, var(--line) 15%, transparent); }
.lesson-row.ready { border-color: var(--good); box-shadow: 0 4px 0 var(--good); }
.lesson-row.hl { outline: 3px solid var(--accent); outline-offset: 3px; }
.small { font-size: .85rem; }

/* ---------- اختيار الصوت ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { padding: .6em .8em; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.lesson-row .book-btn { white-space: nowrap; }
.lesson-row .row-btns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
