/* ليل ملدس: نفس ألوان المتجر وعربون */
@font-face { font-family: "Plex"; src: url(fonts/plex-arabic-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex"; src: url(fonts/plex-arabic-500.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex"; src: url(fonts/plex-arabic-700.woff2) format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex"; src: url(fonts/plex-latin-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122; }
@font-face { font-family: "Plex"; src: url(fonts/plex-latin-500.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122; }
@font-face { font-family: "Plex"; src: url(fonts/plex-latin-700.woff2) format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122; }
@font-face { font-family: "Alexandria"; src: url(fonts/alexandria-latin.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #130A27;
  --surface: #1F1536;
  --surface-2: #2A1F45;
  --surface-3: #33274F;
  --ink: #F4F2FB;
  --ink-2: #CBC7DD;
  --ink-3: #A39CBD;
  --gold: #F0D002;
  --gold-ink: #130A27;
  --ok: #5EE0A8;
  --r: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --pad: 16px;
  --bar: 76px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.6 "Plex", system-ui, sans-serif;
  padding-bottom: calc(var(--bar) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: inherit; }
.num { font-family: "Alexandria", "Plex", sans-serif; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* الرأس */
.hero { position: relative; overflow: hidden; isolation: isolate; }
.mosaic {
  position: absolute; inset: -40px -20px auto; height: 340px; z-index: -1;
  display: grid; grid-auto-flow: column; grid-auto-columns: 96px; gap: 10px;
  transform: rotate(-8deg) translateY(-30px); opacity: .5;
}
.mosaic img { width: 96px; aspect-ratio: 2/3; object-fit: cover; border-radius: 10px; background: var(--surface); }
.mosaic img:nth-child(even) { margin-top: 48px; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(19,10,39,.55) 0%, rgba(19,10,39,.86) 55%, var(--bg) 100%);
}
.hero-in { max-width: 1100px; margin: 0 auto; padding: 28px var(--pad) 18px; }
.logo img { width: 92px; height: auto; }
h1 { font-size: 28px; line-height: 1.3; margin: 14px 0 6px; font-weight: 700; }
.lead { margin: 0; color: var(--ink-2); max-width: 34em; }
.buy-top { display: none; }

/* البحث */
.search-bar {
  position: sticky; top: 0; z-index: 20; padding: 10px var(--pad);
  background: rgba(19,10,39,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent; transition: border-color .2s var(--ease);
}
.search-bar.stuck { border-bottom-color: var(--surface-2); }
.search {
  max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 14px; border-radius: 14px; background: var(--surface);
  border: 1.5px solid var(--surface-3); transition: border-color .16s var(--ease);
}
.search:focus-within { border-color: var(--gold); }
.search svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--ink);
  font: 500 16px "Plex", sans-serif; outline: none;
}
.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-cancel-button { display: none; }
.clear { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; cursor: pointer; flex: none; }
.clear svg { width: 16px; height: 16px; stroke: var(--ink); }

main { max-width: 1100px; margin: 0 auto; padding: 0 var(--pad); }
.block { margin-top: 28px; }
.block-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
h2 { font-size: 20px; margin: 0; font-weight: 700; }
.hint, .count { color: var(--ink-3); font-size: 14px; }
.block-note { margin: -6px 0 12px; color: var(--ink-3); font-size: 14px; }

/* الأغلفة */
.covers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 10px; }
.cover { border: 0; padding: 0; background: none; text-align: start; cursor: pointer; transition: transform .16s var(--ease); }
.cover:active { transform: scale(.97); }
.art {
  position: relative; aspect-ratio: 2/3; border-radius: 12px; overflow: hidden;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
}
.art img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s var(--ease); }
.art img.on { opacity: 1; }
.art .ph {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; text-align: center;
  font: 700 14px/1.3 "Plex", sans-serif; color: var(--ink-2); direction: ltr;
}
.cover .name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 6px; font-size: 13px; line-height: 1.35; color: var(--ink-2); direction: ltr; text-align: right;
  text-wrap: balance;
}

/* السلاسل */
.series { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.serie {
  position: relative; border: 0; padding: 0; cursor: pointer; border-radius: 12px; overflow: hidden;
  aspect-ratio: 460/215; background: var(--surface); text-align: start; transition: transform .16s var(--ease);
}
.serie:active { transform: scale(.97); }
.serie img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s var(--ease); }
.serie img.on { opacity: 1; }
.serie::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(19,10,39,.95) 0%, rgba(19,10,39,.2) 70%); }
.serie .lbl { position: absolute; inset: auto 10px 8px; z-index: 1; line-height: 1.25; }
.serie b { display: block; font-size: 15px; }
.serie small { font-size: 12px; color: var(--ink-2); }

/* القوائم */
.letters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: 0 calc(var(--pad) * -1) 6px; padding-inline: var(--pad); scrollbar-width: none; direction: ltr; }
.letters::-webkit-scrollbar { display: none; }
.letters button {
  flex: none; min-width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--surface);
  color: var(--ink-2); font: 600 14px "Alexandria", sans-serif; cursor: pointer; padding: 0 10px;
}
.letters button[aria-selected="true"] { background: var(--gold); color: var(--gold-ink); }
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 0;
  border: 0; border-bottom: 1px solid var(--surface); background: none; cursor: pointer; text-align: start;
}
.row:active { opacity: .7; }
.thumb { flex: none; width: 92px; aspect-ratio: 460/215; border-radius: 8px; overflow: hidden; background: var(--surface); position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s var(--ease); }
.thumb img.on { opacity: 1; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; font: 700 15px "Alexandria", sans-serif; color: var(--ink-3); }
.row .t { flex: 1; min-width: 0; direction: ltr; text-align: right; font-weight: 500; line-height: 1.35; text-wrap: balance; }
.row .t small { display: block; direction: rtl; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.tick { flex: none; width: 22px; height: 22px; color: var(--ok); }
mark { background: none; color: var(--gold); }

.more {
  display: block; width: 100%; height: 48px; margin-top: 14px; border: 1.5px solid var(--surface-3);
  border-radius: 12px; background: none; color: var(--ink); cursor: pointer; font-weight: 500;
}

/* الطلب والنتائج */
.ask-card { background: var(--surface); border-radius: var(--r); padding: 18px; }
.ask-card p { color: var(--ink-2); margin: 6px 0 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border: 0; border-radius: 12px; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .16s var(--ease), opacity .16s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn.gold { background: var(--gold); color: var(--gold-ink); }
.btn.quiet { background: var(--surface-2); color: var(--ink); }
.btn[disabled] { opacity: .6; pointer-events: none; }
.notes { color: var(--ink-3); font-size: 14px; }
.notes p { margin: 4px 0; }

#results { min-height: calc(100vh - 80px); }
.res-head { margin: 18px 0 6px; color: var(--ink-3); font-size: 14px; }
.empty { text-align: center; padding: 28px 8px 8px; }
.empty .big { font-size: 18px; font-weight: 700; margin: 0 0 6px; }
.empty .big bdi { color: var(--gold); }
.empty p { color: var(--ink-2); margin: 0 auto 16px; max-width: 30em; }
.res-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding: 14px; background: var(--surface); border-radius: var(--r); }
.res-foot span { color: var(--ink-2); }

.foot { text-align: center; padding: 32px var(--pad) 12px; color: var(--ink-3); font-size: 13px; }
.foot img { margin: 0 auto 6px; opacity: .8; }

/* شريط الشراء */
.buy-bar {
  position: fixed; inset: auto 0 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  background: rgba(31,21,54,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--surface-3);
}
.buy-bar b { display: block; font-size: 15px; line-height: 1.3; }
.buy-bar span { font-size: 13px; color: var(--ink-2); }

/* النافذة */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.scrim { position: absolute; inset: 0; background: rgba(8,4,18,.6); opacity: 0; transition: opacity .24s var(--ease); touch-action: none; }
.sheet {
  position: absolute; inset: auto 0 0; max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px var(--pad) calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .3s var(--ease);
}
.sheet-wrap.open .scrim { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.x { position: absolute; top: 12px; left: 12px; z-index: 2; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(19,10,39,.7); display: grid; place-items: center; cursor: pointer; }
.x svg { width: 18px; height: 18px; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; line-height: 1.35; }
.sheet .en { direction: ltr; text-align: right; }
.g-art { margin: -20px calc(var(--pad) * -1) 14px; aspect-ratio: 460/215; background: var(--surface-2); position: relative; overflow: hidden; border-radius: 20px 20px 0 0; }
.g-art img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s var(--ease); }
.g-art img.on { opacity: 1; }
.have { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 700; margin: 4px 0 14px; }
.have svg { width: 20px; height: 20px; }
.chip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 52px;
  padding: 8px 14px; margin-bottom: 12px; border: 0; border-radius: 12px; background: var(--surface-2); cursor: pointer; text-align: start;
}
.chip small { color: var(--ink-3); }
.sheet .actions { display: grid; gap: 10px; margin-top: 6px; }
.sheet .covers { margin-top: 12px; }

.form label { display: block; margin: 12px 0 6px; font-weight: 500; }
.form label small { color: var(--ink-3); font-weight: 400; }
.form input {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--surface-3);
  background: var(--bg); color: var(--ink); font: 500 16px "Plex", sans-serif; outline: none;
}
.form input:focus { border-color: var(--gold); }
.form input.ltr { direction: ltr; text-align: right; }
.form .err { color: #FF8D96; font-size: 14px; min-height: 22px; margin: 6px 0 0; }
.form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.done { text-align: center; padding: 16px 0 4px; }
.done svg { width: 56px; height: 56px; color: var(--ok); margin: 0 auto 8px; display: block; }
.done svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .4s .1s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done p { color: var(--ink-2); margin: 4px 0 16px; }

@media (min-width: 640px) {
  .covers { grid-template-columns: repeat(4, 1fr); }
  .series { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  :root { --pad: 24px; --bar: 0px; }
  h1 { font-size: 36px; }
  .hero-in { position: relative; padding-top: 36px; }
  .buy-top {
    display: inline-flex; position: absolute; top: 36px; left: var(--pad); min-height: 44px; padding: 0 18px; align-items: center;
    border-radius: 12px; background: var(--gold); color: var(--gold-ink); font-weight: 700; text-decoration: none;
  }
  .buy-bar { display: none; }
  .covers { grid-template-columns: repeat(6, 1fr); gap: 16px 14px; }
  .series { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .rows { columns: 2; column-gap: 32px; }
  .row { break-inside: avoid; }
  .sheet-wrap { display: grid; place-items: center; }
  .sheet { position: relative; inset: auto; width: min(560px, calc(100vw - 48px)); border-radius: 20px; transform: translateY(16px); opacity: 0; transition: transform .24s var(--ease), opacity .24s var(--ease); }
  .sheet-wrap.open .sheet { opacity: 1; }
  .sheet .covers { grid-template-columns: repeat(4, 1fr); }
  .letters { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; }
}
@media (hover: hover) {
  .cover:hover .art { box-shadow: 0 0 0 2px var(--gold); }
  .serie:hover { box-shadow: 0 0 0 2px var(--gold); }
  .row:hover .t { color: var(--gold); }
  .more:hover { border-color: var(--ink-3); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
