/* ============================================================
   قصتي — واجهة أولياء الأمور
   الهوية: كحلي مدارس مدينة المعرفة + سماوي + أصفر نجمة
   ============================================================ */
:root {
  --ink: #000c40;
  --ink-2: #1b2a63;
  --sky: #01b9ff;
  --sky-soft: #e3f6ff;
  --star: #ffc93c;
  --star-soft: #fff4d6;
  --paper: #f4f8fd;
  --card: #ffffff;
  --line: #dbe4f1;
  --muted: #5b6785;
  --ok: #12a37a;
  --ok-soft: #e2f6ef;
  --err: #d93a42;
  --err-soft: #fdecec;
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 12, 64, .06), 0 10px 30px -14px rgba(0, 12, 64, .28);
  --display: "Cairo", system-ui, sans-serif;
  --body: "Cairo", system-ui, sans-serif;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .display { font-family: var(--display); font-weight: 700; line-height: 1.3; color: var(--ink); }
a { color: var(--ink-2); }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }
.text-muted { color: var(--muted) !important; }

/* ---------- الهيدر ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.site-header .inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; background: var(--ink);
  display: grid; place-items: center; flex: none;
}
.brand-name { font-family: var(--display); font-size: 24px; font-weight: 800; line-height: 1; }
.brand-sub { font-size: 12px; color: var(--muted); line-height: 1.2; margin-top: 4px; }
.header-link { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.header-link:hover { color: var(--ink); }

/* ---------- الأزرار ---------- */
.btn { font-weight: 700; border-radius: 999px; padding: .62rem 1.4rem; }
.btn-ink { background: var(--ink); color: #fff; border: 0; }
.btn-ink:hover, .btn-ink:focus { background: var(--ink-2); color: #fff; }
.btn-sky { background: var(--sky); color: var(--ink); border: 0; }
.btn-sky:hover { background: #00a6e6; color: var(--ink); }
.btn-star { background: var(--star); color: var(--ink); border: 0; }
.btn-star:hover { background: #ffbd14; color: var(--ink); }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-lg { padding: .85rem 1.9rem; font-size: 1.05rem; }

/* ---------- الصفحة الرئيسية ---------- */
.hero { padding: 56px 0 40px; overflow: hidden; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); font-weight: 800; line-height: 1.35; margin-bottom: 18px; }
.hero h1 .name-line { display: block; color: var(--ink); }
.hero p.lead { color: var(--muted); font-size: 1.15rem; max-width: 34ch; }
.hero-points { list-style: none; padding: 0; margin: 26px 0 32px; display: grid; gap: 10px; }
.hero-points li { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.hero-points .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--sky-soft); color: var(--ink); display: grid; place-items: center; flex: none; font-size: 14px; }

/* الكتاب في الواجهة: العنصر المميز للهوية */
.hero-book { position: relative; display: flex; justify-content: center; padding: 20px 0; }
.book3d {
  width: min(360px, 78vw); aspect-ratio: 1 / 1; position: relative;
  transform: perspective(1400px) rotateY(14deg) rotateX(4deg);
  transform-style: preserve-3d;
}
.book3d .cover {
  position: absolute; inset: 0; border-radius: 6px 16px 16px 6px; overflow: hidden;
  background: linear-gradient(160deg, #0a1a5c 0%, #000c40 60%);
  box-shadow: 0 30px 60px -20px rgba(0, 12, 64, .55), inset 6px 0 0 rgba(255, 255, 255, .08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px;
}
.book3d .pages {
  position: absolute; inset: 6px -10px 6px 10px; background: repeating-linear-gradient(90deg, #fff 0 2px, #e8edf6 2px 3px);
  border-radius: 4px 12px 12px 4px; transform: translateZ(-20px);
}
.book3d .stars { position: absolute; inset: 0; pointer-events: none; }
.book3d .cover-kicker { color: var(--star); font-weight: 700; font-size: 15px; }
.book3d .cover-name {
  font-family: var(--display); font-weight: 800; color: #fff; font-size: clamp(2.4rem, 7vw, 3.4rem); line-height: 1.15;
  min-height: 1.2em;
}
.book3d .cover-name .caret { display: inline-block; width: 3px; height: .9em; background: var(--sky); margin-inline-start: 4px; vertical-align: -.1em; animation: blink 1s steps(1) infinite; }
.book3d .cover-title { color: #b9cdf7; font-size: 15px; margin-top: 10px; }
.book3d .cover-moon { width: 76px; height: 76px; margin-bottom: 14px; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .book3d .cover-name .caret { animation: none; } }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head h2 { font-size: 2rem; margin: 0; }

/* بطاقات القصص */
.story-card {
  background: var(--card); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line);
  display: flex; flex-direction: column; height: 100%; text-decoration: none; color: inherit;
  transition: transform .2s ease, box-shadow .2s ease;
}
.story-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); color: inherit; }
.story-card .thumb { aspect-ratio: 1 / 1; background: var(--sky-soft); position: relative; }
.story-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-card .age { position: absolute; top: 12px; inset-inline-start: 12px; background: var(--star); color: var(--ink); font-weight: 800; font-size: 13px; padding: 2px 12px; border-radius: 999px; }
.story-card .body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.story-card h3 { font-size: 1.35rem; margin: 0; }
.story-card p { color: var(--muted); font-size: 14.5px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story-card .meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--paper); color: var(--ink-2); border: 1px solid var(--line); }

.how { background: var(--card); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 48px 0; margin-top: 56px; }
.how-step { display: flex; gap: 14px; }
.how-step .n { font-family: var(--display); font-size: 1.6rem; font-weight: 800; width: 48px; height: 48px; border-radius: 14px; background: var(--ink); color: var(--star); display: grid; place-items: center; flex: none; }
.how-step h3 { font-size: 1.15rem; margin: 2px 0 4px; }
.how-step p { color: var(--muted); font-size: 14.5px; margin: 0; }

.site-footer { padding: 28px 0 40px; color: var(--muted); font-size: 13.5px; }

/* ---------- نموذج الطلب ---------- */
.wizard-wrap { padding: 32px 0 64px; }
.wizard-title { font-size: clamp(1.7rem, 3.6vw, 2.3rem); margin-bottom: 4px; }
.steps-nav { display: flex; gap: 6px; margin: 22px 0 18px; padding: 0; list-style: none; }
.steps-nav li { flex: 1; }
.steps-nav button {
  width: 100%; border: 0; background: transparent; padding: 0; text-align: start; color: var(--muted);
  font-weight: 700; font-size: 13.5px; display: flex; flex-direction: column; gap: 8px;
}
.steps-nav .bar { height: 6px; border-radius: 999px; background: var(--line); display: block; overflow: hidden; }
.steps-nav li.done .bar { background: var(--sky); }
.steps-nav li.active .bar { background: var(--ink); }
.steps-nav li.active button, .steps-nav li.done button { color: var(--ink); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; }
.panel + .panel { margin-top: 18px; }
.panel h2 { font-size: 1.45rem; margin-bottom: 4px; }
.panel .hint { color: var(--muted); font-size: 14.5px; margin-bottom: 22px; }
.step { display: none; }
.step.active { display: block; }

.form-label { font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.form-control, .form-select {
  border-radius: var(--radius-sm); border: 1.5px solid var(--line); padding: .7rem .95rem; font-size: 15.5px; background-color: #fff;
}
.form-control:focus, .form-select:focus { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(1, 185, 255, .15); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--err); }
.field-error { color: var(--err); font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.form-text { color: var(--muted); font-size: 13px; }

/* اختيار بأزرار كبيرة (ولد/بنت، صورة/وصف) */
.choice-group { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-group input { position: absolute; opacity: 0; pointer-events: none; }
.choice-group label {
  flex: 1; min-width: 120px; cursor: pointer; border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-weight: 700; background: #fff; transition: border-color .15s, background .15s;
}
.choice-group label .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--paper); display: grid; place-items: center; font-size: 18px; flex: none; }
.choice-group input:checked + label { border-color: var(--ink); background: var(--sky-soft); }
.choice-group input:checked + label .ico { background: var(--ink); color: #fff; }
.choice-group input:focus-visible + label { outline: 3px solid var(--sky); outline-offset: 2px; }

/* رفع الصورة */
.photo-drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; display: flex; align-items: center; gap: 16px;
  cursor: pointer; background: #fff; transition: border-color .15s, background .15s; position: relative;
}
.photo-drop:hover, .photo-drop.drag { border-color: var(--sky); background: var(--sky-soft); }
.photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-drop .preview { width: 76px; height: 76px; border-radius: 14px; background: var(--paper); flex: none; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 28px; }
.photo-drop .preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-drop strong { display: block; }
.photo-drop span { color: var(--muted); font-size: 13.5px; }

/* بطاقات أفراد العائلة */
.member {
  border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; transition: border-color .15s;
}
.member + .member { margin-top: 12px; }
.member.on { border-color: var(--ink); }
.member-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; user-select: none; }
.member-head .avatar-dot { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--display); font-weight: 800; font-size: 15px; flex: none; line-height: 1; }
.member-head .who { flex: 1; }
.member-head .who strong { display: block; font-size: 16px; }
.member-head .who small { color: var(--muted); }
.member-head .tag-req { background: var(--star-soft); color: #7a5200; font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 999px; }
.member-body { display: none; padding: 4px 16px 18px; border-top: 1px solid var(--line); }
.member.on .member-body { display: block; padding-top: 16px; }
.switch { position: relative; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(-22px); }
[dir="ltr"] .switch input:checked + .track::after { transform: translateX(22px); }
.switch input:focus-visible + .track { outline: 3px solid var(--sky); outline-offset: 2px; }

.consent { background: var(--paper); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 12px; align-items: flex-start; }
.consent input { width: 22px; height: 22px; margin-top: 4px; flex: none; accent-color: var(--ink); }
.consent p { margin: 0; font-size: 14.5px; }

.wizard-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; }

.review-list { margin: 0; padding: 0; list-style: none; }
.review-list li { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.review-list li span:first-child { color: var(--muted); }
.review-list li span:last-child { font-weight: 700; text-align: end; }

/* معاينة الغلاف الحية */
.live-cover { position: sticky; top: 92px; }
.live-cover .frame {
  aspect-ratio: 1 / 1; border-radius: 8px 18px 18px 8px; overflow: hidden; position: relative; background: var(--ink);
  box-shadow: 0 26px 50px -24px rgba(0, 12, 64, .55);
}
.live-cover .frame img.bg { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .92; }
.live-cover .frame .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,12,64,0) 40%, rgba(0,12,64,.82) 100%); }
.live-cover .frame .overlay { position: absolute; inset-inline: 0; bottom: 0; padding: 26px 24px; text-align: center; color: #fff; }
.live-cover .frame .overlay .kicker { color: var(--star); font-weight: 700; font-size: 14px; }
.live-cover .frame .overlay .nm { font-family: var(--display); font-weight: 800; font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.15; word-break: break-word; }
.live-cover .frame .overlay .nm.empty { opacity: .45; }
.live-cover .cast { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.live-cover .cast span { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--display); font-weight: 800; font-size: 14px; line-height: 1; border: 3px solid var(--paper); }
.live-cover .caption { text-align: center; color: var(--muted); font-size: 13.5px; margin-top: 10px; }

/* ---------- صفحة المتابعة ---------- */
.track-head { padding: 34px 0 10px; }
.track-head .num { color: var(--muted); font-weight: 700; font-size: 14px; }
.track-head h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 4px 0 0; }
.journey { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 26px 0 26px; padding: 0; list-style: none; }
.journey li { font-size: 13px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.journey li .bar { height: 8px; border-radius: 999px; background: var(--line); position: relative; overflow: hidden; }
.journey li.done { color: var(--ink); }
.journey li.done .bar { background: var(--sky); }
.journey li.now { color: var(--ink); }
.journey li.now .bar { background: var(--line); }
.journey li.now .bar::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--ink); border-radius: 999px; animation: slide 1.6s ease-in-out infinite; }
.journey li.wait .bar { background: var(--star); }
@keyframes slide { 0% { transform: translateX(110%); } 100% { transform: translateX(-260%); } }
@media (prefers-reduced-motion: reduce) { .journey li.now .bar::after { animation: none; width: 100%; } }

.status-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; }
.status-card.attention { border-color: var(--star); box-shadow: 0 0 0 4px var(--star-soft); }
.status-card h2 { font-size: 1.5rem; }
.progress-line { height: 12px; background: var(--paper); border-radius: 999px; overflow: hidden; margin: 18px 0 8px; }
.progress-line > span { display: block; height: 100%; background: var(--sky); border-radius: 999px; transition: width .6s ease; }

.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-top: 20px; }
.avatar-card { border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.avatar-card .img { aspect-ratio: 3 / 4; background: var(--paper); display: grid; place-items: center; }
.avatar-card .img img { width: 100%; height: 100%; object-fit: contain; }
.avatar-card .info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.avatar-card .info strong { font-size: 16px; }
.avatar-card .info small { color: var(--muted); }
.avatar-card details summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.avatar-card details textarea { margin-top: 8px; font-size: 14px; }
.spinner-dot { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--sky); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.book-frame { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #e9eef6; }

.alert-soft { border-radius: var(--radius); padding: 14px 18px; font-weight: 600; }
.alert-soft.err { background: var(--err-soft); color: #8c1d23; }
.alert-soft.ok { background: var(--ok-soft); color: #0b5e47; }
.alert-soft.info { background: var(--sky-soft); color: var(--ink); }

@media (max-width: 991px) {
  .live-cover { position: static; max-width: 340px; margin: 0 auto 18px; }
  .panel { padding: 20px; }
  .journey { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .journey li { font-size: 11px; }
}

.flex-none { flex: none; }
.wizard-wrap { overflow-x: clip; }
.personal-panel { background: linear-gradient(135deg, #fff7fb 0%, #f3f0ff 100%); border-color: #e9d5ff; }
.personal-panel h2 i { color: #a855f7; }

/* الكتاب المقلّب داخل صفحة الطلب */
.flip-wrap { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.book-frame.flip { height: min(86vh, 820px); background: #0a1238; border: 0; box-shadow: 0 24px 50px -28px rgba(0,12,64,.7); }
.flip-open { border-radius: 999px; padding: 6px 16px; font-weight: 700; background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.flip-open:hover { border-color: var(--ink); }
