/* رُفقة — أخضر عميق، ذهبي، وورق المصحف */
:root {
  --ink: #0f3d34;
  --ink-2: #1b5a4c;
  --ink-deep: #0a2e27;
  --gold: #c39a45;
  --gold-hi: #d8b466;
  --gold-soft: #ead9b0;
  --gold-deep: #9a7429; /* ذهبي للنص الكبير على الورق */
  --gold-text: #7c5d18; /* ذهبي للنص الصغير على الورق */
  --paper: #f6efe1;
  --paper-2: #fbf7ee;
  --text: #1f2a27;
  --muted: #5f6a65;
  --line: #e4d9c3;
  --ok: #2f7d5b;
  --focus: var(--gold);
  --display: 'Markazi Text', 'Amiri', serif;
  --ui: 'Readex Pro', system-ui, sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='88'%3E%3Cg fill='none' stroke='%23c39a45' stroke-opacity='.11'%3E%3Crect x='28' y='28' width='32' height='32'/%3E%3Crect x='28' y='28' width='32' height='32' transform='rotate(45 44 44)'/%3E%3C/g%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--gold-soft) var(--paper); }
html { background: var(--paper); }
body { position: relative; isolation: isolate; margin: 0; font: 400 17px/1.8 var(--ui); color: var(--text); background: var(--paper); caret-color: var(--ink); font-variant-numeric: tabular-nums; }
::selection { background: var(--ink); color: var(--gold-soft); }
h1, h2, h3, p, figure { margin: 0; }
/* زخرفة الثُّمن تبقى في رأس الصفحة فقط وتذوب نحو الأسفل */
body::before { content: ''; position: absolute; inset: 0 0 auto; height: 620px; z-index: -1; background: var(--pattern); -webkit-mask-image: linear-gradient(#000 20%, transparent); mask-image: linear-gradient(#000 20%, transparent); pointer-events: none; }
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
main { max-width: 1120px; margin: 0 auto; padding: 0 16px 64px; }

/* ورقة: سطح فاتح واحد بحد رفيع وظل خفيف */
.sheet { background: var(--paper-2); border: 1px solid var(--line); border-radius: 22px; padding: 26px 24px; box-shadow: 0 1px 0 #fff inset, 0 18px 40px -30px rgb(15 61 52 / .45); }

/* ---------- الترويسة ---------- */
.top { display: flex; align-items: center; justify-content: space-between; max-width: 1120px; margin: 0 auto; padding: 16px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 36px/1 var(--display); }
.link-btn { background: none; border: 0; padding: 10px 4px; min-height: 44px; cursor: pointer; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 1.5px; text-underline-offset: 6px; }
.link-btn:hover { color: var(--ink); text-decoration-thickness: 2.5px; }
.link-btn.quiet { font-size: 14px; color: var(--muted); }
.link-btn.danger { color: #9b2c1c; text-decoration-color: currentColor; }
.link-btn.inline { padding: 0; min-height: 0; font-size: inherit; }

/* ---------- الأزرار ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 12px 24px; border: 0; border-radius: 14px; font-weight: 700; font-size: 17px; cursor: pointer; text-decoration: none; transition: background .2s, box-shadow .2s, transform .12s, color .2s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--ink); color: #fff; box-shadow: 0 10px 20px -12px rgb(15 61 52 / .9); }
.btn.primary:hover { background: var(--ink-2); }
.btn.gold { background: var(--gold-hi); color: var(--ink-deep); }
.btn.gold:hover { background: #e2c27a; }
.btn.outline { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn.outline:hover { background: rgb(15 61 52 / .06); }
.btn.wa { background: #1f8f55; color: #fff; }
.btn.wa:hover { background: #1a7a48; }

/* ---------- الصفحة الرئيسية ---------- */
#landing { display: grid; gap: 32px 64px; grid-template-columns: minmax(0, 1fr); padding-top: 12px; }
.intro h1 { font: 700 clamp(46px, 11vw, 80px)/1.12 var(--display); color: var(--ink); letter-spacing: -.01em; }
.intro h1 em { font-style: normal; color: var(--gold-deep); }
.lead { font-size: 18px; color: #3d4a46; max-width: 30em; margin-top: 18px; }

/* مثال حي للرفقة: بطاقة ورد اليوم وسبعة أعضاء */
.preview { margin-top: 28px; max-width: 460px; }
.pv-wird { position: relative; overflow: hidden; background: var(--ink); color: #fff; border-radius: 22px; padding: 26px 28px 24px; box-shadow: 0 24px 40px -26px rgb(10 46 39 / .9); }
.pv-wird p { color: var(--gold-hi); font-weight: 600; font-size: 15px; }
.pv-wird b { display: block; font: 700 40px/1.25 var(--display); }
.pv-wird span { color: var(--gold-soft); font: 400 22px/1.6 'Amiri Quran', var(--display); }
/* بطاقة الورد كصفحة مصحف: إطار ذهبي مزدوج */
.pv-wird::before, .pv-wird::after, .wird::before, .wird::after { content: ''; position: absolute; pointer-events: none; border: 1px solid rgb(216 180 102 / .42); }
.pv-wird::before, .wird::before { inset: 8px; border-radius: 15px; }
.pv-wird::after, .wird::after { inset: 12px; border-radius: 11px; border-color: rgb(216 180 102 / .2); }
.wird::before { border-radius: 19px; }
.wird::after { border-radius: 15px; }
.pv-circle { list-style: none; display: flex; gap: 8px; padding: 0; margin: 16px 0 8px; }
.pv-circle li { position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--line); color: var(--muted); }
.pv-circle li.ok { background: var(--ok); color: #fff; animation: tick-in .5s var(--ease-out) both; }
.pv-circle li.ok:nth-child(1) { animation-delay: .3s; } .pv-circle li.ok:nth-child(2) { animation-delay: .5s; } .pv-circle li.ok:nth-child(3) { animation-delay: .7s; } .pv-circle li.ok:nth-child(4) { animation-delay: .9s; } .pv-circle li.ok:nth-child(5) { animation-delay: 1.1s; }
.pv-circle li.ok::after { animation: inherit; animation-name: badge-in; }
@keyframes tick-in { from { background: var(--line); color: var(--muted); } }
@keyframes badge-in { from { transform: scale(0); } }
.pv-circle li.ok::after { content: ''; position: absolute; left: -2px; bottom: -2px; width: 16px; height: 16px; border-radius: 50%; background: var(--gold-hi) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.4l2.4 2.3L12 5.3' fill='none' stroke='%230a2e27' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; box-shadow: 0 0 0 2px var(--paper); }
.preview figcaption { color: var(--muted); font-size: 15px; }
.preview small { color: var(--gold-text); }

.join { display: flex; flex-direction: column; gap: 20px; align-self: start; }
.form-title { font: 700 38px/1.2 var(--display); color: var(--ink); }
.invite { background: var(--ink); color: #fff; border-radius: 14px; padding: 14px 18px; font: 700 26px/1.4 var(--display); }
.invite small { display: block; font: 400 15px/1.6 var(--ui); color: var(--gold-soft); }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-weight: 600; font-size: 15px; color: var(--ink); padding: 0; }
.field input { width: 100%; min-width: 0; min-height: 50px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 17px; color: var(--text); transition: border-color .2s, box-shadow .2s; }
.field input::placeholder { color: #8a918d; }
.field input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgb(195 154 69 / .25); }
.field input.otp { font-size: 28px; letter-spacing: .4em; text-align: center; font-weight: 700; }
.hint { font-size: 14px; color: var(--muted); }
.hint:empty { display: none; }
.pair { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.pair:not(:has(> :not([hidden]))) { display: none; }
.error { color: #9b2c1c; font-weight: 600; font-size: 15px; }
.error:empty { display: none; }
.form-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 22px; margin-top: -6px; }

/* المقادير: المختار يحيط به خط ذهبي يُرسم */
.amounts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 4px; }
.amounts label { position: relative; cursor: pointer; }
.amounts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.amounts.two b { font-size: 30px; }
.amounts input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.amounts span { position: relative; display: flex; flex-direction: column; align-items: center; padding: 10px 4px 12px; font-size: 14px; color: var(--muted); background: #fff; border: 1.5px solid var(--line); border-radius: 14px; transition: background .2s, border-color .2s, color .2s; }
.amounts b { font: 700 36px/1.1 var(--display); color: var(--ink); }
.amounts label:hover span { border-color: var(--gold); }
.ink-ring { position: absolute; inset: -5px; width: calc(100% + 10px); height: calc(100% + 10px); overflow: visible; pointer-events: none; opacity: 0; transition: opacity .2s; }
.amounts input:checked + span .ink-ring { opacity: 1; }
.ink-ring path { fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .55s var(--ease-out); }
.amounts input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--gold-soft); }
.amounts input:checked + span b { color: #fff; }
.amounts input:checked + span .ink-ring path { stroke-dashoffset: 0; }
.amounts input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 3px; }

/* كيف يمشي اليوم: خط واحد بمحطات */
.ways { display: flex; flex-direction: column; }
.ways-head { display: contents; }
.ways h2 { font: 700 clamp(34px, 7vw, 48px)/1.2 var(--display); color: var(--ink); margin-bottom: 20px; }
.explainer { order: 2; display: block; width: 100%; max-width: 280px; height: auto; aspect-ratio: 9 / 16; margin: 8px auto 0; border-radius: 20px; background: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 24px 40px -26px rgb(10 46 39 / .8); }
.day-line { list-style: none; margin: 0; padding: 0 32px 0 0; position: relative; }
.day-line::before { content: ''; position: absolute; right: 9px; top: 14px; bottom: 26px; width: 2px; background: linear-gradient(var(--gold), var(--gold-soft)); }
.day-line li { position: relative; padding: 0 0 20px; color: #3d4a46; max-width: 34em; }
/* محطات اليوم: نجمة الثُّمن من الشعار، والأخيرة (الختمة) مملوءة */
.day-line li::before { content: ''; position: absolute; right: -34px; top: 6px; width: 24px; height: 24px; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23f6efe1' stroke='%23c39a45' stroke-width='1.6' stroke-linejoin='round'%3E%3Crect x='5.5' y='5.5' width='13' height='13'/%3E%3Crect x='5.5' y='5.5' width='13' height='13' transform='rotate(45 12 12)'/%3E%3C/g%3E%3C/svg%3E") center/100% no-repeat; }
.day-line li:last-child::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23c39a45' stroke='%23c39a45' stroke-width='1.6' stroke-linejoin='round'%3E%3Crect x='5.5' y='5.5' width='13' height='13'/%3E%3Crect x='5.5' y='5.5' width='13' height='13' transform='rotate(45 12 12)'/%3E%3C/g%3E%3C/svg%3E"); }
.day-line b { display: block; font: 700 28px/1.3 var(--display); color: var(--ink); }

.stats { display: flex; flex-wrap: wrap; gap: 6px 28px; color: var(--muted); }
.stats:empty { display: none; }
.stats b { font: 700 34px/1.1 var(--display); color: var(--ink); margin-left: 6px; }

.hadith { text-align: center; padding: 30px 0 4px; }
.hadith .rule { display: block; width: 200px; height: 16px; margin: 0 auto 18px; color: var(--gold); }
.hadith blockquote { margin: 0; font: 700 clamp(34px, 7.4vw, 58px)/1.4 var(--display); color: var(--ink); }
.hadith figcaption { color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: 14px; }

@media (min-width: 960px) {
  #landing { grid-template-columns: minmax(0, 1fr) minmax(0, 480px); align-items: start; padding-top: 32px; }
  .intro { padding-top: 12px; }
  .ways { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 48px; margin-top: 24px; }
  .ways-head { display: block; }
  .explainer { margin: 4px 0 0; max-width: 240px; }
  .hadith, .foot, .stats { grid-column: 1 / -1; }
  .pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- لوحة الرفقة ---------- */
#dash { max-width: 680px; display: flex; flex-direction: column; gap: 18px; padding-top: 4px; }
.circle-head h1 { font: 700 clamp(42px, 9vw, 60px)/1.15 var(--display); color: var(--ink); }
.circle-head p { color: var(--muted); }
#dayLabel { color: var(--gold-text); font-weight: 600; }

.wird { position: relative; overflow: hidden; background: var(--ink); color: #fff; border-radius: 26px; padding: 32px 28px 26px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 50px -34px rgb(10 46 39 / .95); }
.wird h2 { font: 700 clamp(38px, 9vw, 54px)/1.2 var(--display); position: relative; }
.surah { font: 400 24px/1.6 'Amiri Quran', var(--display); color: var(--gold-soft); min-height: 1.6em; margin-top: -8px; }
.actions { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; position: relative; }
.wird .btn.outline { color: #fff; box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / .55); }
.wird .btn.outline:hover { background: rgb(255 255 255 / .08); }
#doneBtn.done { background: #fff; color: var(--ok); }
.tally { font-size: 15px; color: var(--gold-soft); position: relative; }
.tally span { font-weight: 700; color: #fff; }

.khatma-label { display: flex; justify-content: space-between; font-weight: 600; font-size: 15px; color: var(--muted); }
.khatma-label b { color: var(--ink); }
.track { --p: 0; position: relative; height: 22px; margin: 6px 0 2px; }
.track::before { content: ''; position: absolute; inset: 9px 0; border-radius: 3px; background: var(--line); }
.track::after { content: ''; position: absolute; inset: 5px 0; background: repeating-linear-gradient(to left, var(--gold) 0 2px, transparent 2px calc(100% / 30)); opacity: .45; }
.track .done { position: absolute; right: 0; top: 8px; height: 6px; width: calc(var(--p) * 100%); border-radius: 3px; background: var(--ink); z-index: 1; }
.track .here { position: absolute; top: 1px; right: calc(var(--p) * 100% - 10px); width: 20px; height: 20px; border-radius: 50%; background: var(--gold-hi); box-shadow: 0 0 0 4px var(--paper-2), 0 0 0 5px var(--gold); z-index: 2; }
.ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

.roll-title { font: 700 30px/1.3 var(--display); color: var(--ink); margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.roll { list-style: none; margin: 4px 0 0; padding: 0; }
.roll li { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 54px; border-bottom: 1px solid var(--line); }
.roll li:last-child { border-bottom: 0; }
.roll .mark { width: 34px; height: 34px; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1.5px #d4c39c; display: grid; place-items: center; }
.roll li.ok .mark { background: var(--ok); box-shadow: none; }
.roll .mark svg { width: 20px; height: 14px; overflow: visible; }
.roll .mark path { fill: none; stroke: #fff; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; animation: ink .6s var(--ease-out) both; }
.roll .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roll li:not(.ok) .who { color: var(--muted); font-weight: 400; }
.roll small { font-weight: 400; color: var(--muted); }
.roll .streak { font-size: 13px; color: var(--gold-text); font-weight: 600; }
@keyframes ink { from { stroke-dashoffset: 60; } to { stroke-dashoffset: 0; } }

.remind-head { display: flex; gap: 12px; align-items: flex-start; color: var(--gold); }
.remind-head svg { flex: none; margin-top: 4px; }
.remind h2 { font: 700 30px/1.3 var(--display); color: var(--ink); }
.remind p { color: var(--muted); }
.remind-row { display: flex; gap: 10px; margin-top: 14px; }
.remind-row select { flex: 1; min-width: 0; min-height: 52px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; padding: 0 12px; color: var(--ink); }
.remind-row .btn { flex: 1; }
.remind .hint { margin-top: 10px; }
.remind.on { border-color: var(--ok); }
.remind.on .remind-head { color: var(--ok); }

.save { display: flex; flex-direction: column; gap: 14px; border-color: var(--gold); }
.save h2 { font: 700 34px/1.2 var(--display); color: var(--ink); }
.save > p { color: var(--muted); }

.share h2 { font: 700 32px/1.25 var(--display); color: var(--ink); }
.share p { color: var(--muted); }
.share .code { font: 700 19px/1 ui-monospace, monospace; letter-spacing: .14em; color: var(--ink); margin-right: 6px; }
.share-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.share-row input { flex: 1 1 100%; min-width: 0; min-height: 48px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; background: #fff; color: var(--muted); direction: ltr; font-size: 15px; }
.share-row .btn { flex: 1; }
#leaveBtn { align-self: center; }

/* ---------- القارئ ---------- */
.reader { position: fixed; inset: 0; z-index: 10; background: #fdf9f0; display: flex; flex-direction: column; }
.reader-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.mushaf { flex: 1; overflow-y: auto; padding: 22px 16px; }
.page-text { max-width: 680px; margin: 0 auto; font: 400 clamp(22px, 4.6vw, 30px)/2.3 'Amiri Quran', var(--display); text-align: justify; color: #1a1a1a; }
.page-text .surah { text-align: center; font-size: 26px; color: var(--ink); margin: 18px 0 6px; padding: 6px; border: 1.5px solid var(--gold); border-radius: 12px; background: rgb(195 154 69 / .08); }
.basmala { text-align: center; margin: 4px 0 10px; }
.ayah-num { display: inline-grid; place-items: center; min-width: 1.5em; height: 1.5em; font: 600 .55em/1 var(--ui); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--gold); border-radius: 50%; vertical-align: middle; }
.page-num { text-align: center; color: var(--muted); font: 500 20px/1.6 var(--display); }
.loading { text-align: center; color: var(--muted); margin-top: 30vh; }
.reader-nav { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper-2); }
.reader-nav .btn { flex: 1; }

/* ---------- نافذة التنبيهات ---------- */
.ask { width: min(420px, calc(100% - 32px)); border: 0; padding: 0; border-radius: 24px; background: var(--paper-2); color: var(--text); box-shadow: 0 30px 60px -20px rgb(10 46 39 / .6); }
.ask::backdrop { background: rgb(10 46 39 / .55); }
.ask[open] { animation: ask-in .45s var(--ease-out); }
.ask[open]::backdrop { animation: fade-in .3s ease-out; }
@keyframes ask-in { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@keyframes fade-in { from { opacity: 0; } }
.ask-body { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 30px 26px 18px; text-align: center; }
.ask-body::before { content: ''; position: absolute; inset: 8px; border: 1px solid var(--line); border-radius: 18px; pointer-events: none; }
.ask-bell { align-self: center; color: var(--gold); width: 56px; height: 56px; padding: 11px; border-radius: 50%; background: var(--ink); }
.ask h2 { font: 700 38px/1.15 var(--display); color: var(--ink); }
.ask p { color: #3d4a46; }
#askPick { display: flex; flex-direction: column; gap: 12px; text-align: right; }
.ask select { width: 100%; min-height: 52px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; padding: 0 12px; color: var(--ink); }
.ask-ios { text-align: right; margin: 0; padding: 0 22px 0 0; display: flex; flex-direction: column; gap: 8px; }
.ask-ios svg { vertical-align: -3px; color: var(--ink-2); }
#askLater { align-self: center; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 160%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 14px; transition: transform .45s var(--ease-out), visibility .45s; z-index: 20; max-width: calc(100% - 32px); text-align: center; visibility: hidden; box-shadow: 0 14px 30px -14px rgb(0 0 0 / .6); }
.toast.show { transform: translate(-50%, 0); visibility: visible; }

@media (max-width: 520px) {
  .sheet { padding: 22px 18px; }
  .actions { grid-template-columns: minmax(0, 1fr); }
  .roll .streak { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
