@font-face { font-family: "Vazirmatn"; src: url("../fonts/vazirmatn-arabic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../fonts/vazirmatn-arabic-600.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Miremad"; src: url("../fonts/Miremad.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Amiri Quran"; src: url("../fonts/amiri-quran.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #0f1726;
  --bg-2: #0a101b;
  --panel: rgba(255, 255, 255, .035);
  --panel-line: rgba(194, 168, 120, .22);
  --text: #ece7dc;
  --muted: #a3a9b6;
  --gold: #c2a878;
  --gold-soft: rgba(194, 168, 120, .14);
  --ink-on-gold: #10151f;
  --field: rgba(255, 255, 255, .06);
  --field-line: rgba(255, 255, 255, .14);
  --taken: rgba(255, 255, 255, .03);
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
[data-theme="light"] {
  --bg: #eceef1;
  --bg-2: #dfe2e7;
  --panel: rgba(255, 255, 255, .75);
  --panel-line: rgba(140, 115, 70, .28);
  --text: #1c2230;
  --muted: #5c6475;
  --gold: #8f7444;
  --gold-soft: rgba(143, 116, 68, .12);
  --ink-on-gold: #fff;
  --field: #fff;
  --field-line: rgba(28, 34, 48, .16);
  --taken: rgba(28, 34, 48, .05);
  --shadow: 0 14px 40px rgba(28, 34, 48, .12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 400 16px/1.9 "Vazirmatn", Tahoma, sans-serif;
  color: var(--text);
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--bg) 82%, #3a4a6a) 0%, var(--bg) 55%, var(--bg-2) 100%) fixed;
  background-color: var(--bg);
}
[data-theme="light"] body { background: radial-gradient(120% 70% at 50% 0%, #fff 0%, var(--bg) 60%, var(--bg-2) 100%) fixed; }
img { max-width: 100%; display: block; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }
[hidden] { display: none !important; }

.admin-bar { position: sticky; top: 0; z-index: 50; padding: 8px 16px; text-align: center; font-size: 13px; background: #7a2a2a; color: #fff; }
.admin-bar a { color: #fff; font-weight: 600; }

/* ورود */
.gate { display: none; }
.js .gate {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px;
  background: var(--bg); transition: opacity 1.1s ease, visibility 1.1s;
}
.js .gate.is-gone { opacity: 0; visibility: hidden; }
.gate-inner { text-align: center; max-width: 420px; }
.gate-opening { margin: 0; color: var(--gold); font-size: 15px; letter-spacing: .5px; }
.gate-line { display: block; width: 1px; height: 64px; margin: 18px auto; background: linear-gradient(var(--gold), transparent); }
.gate-type { margin: 0; color: var(--muted); font-size: 14px; }
.gate-name { margin: 6px 0 34px; font: 400 clamp(34px, 10vw, 52px)/1.5 "Miremad", "Vazirmatn", serif; }

.card { width: min(560px, 100%); margin: 0 auto; padding: 28px 16px 40px; }
.notice { margin: 0 0 18px; padding: 8px 14px; border: 1px solid var(--panel-line); border-radius: 999px; text-align: center; font-size: 13px; color: var(--muted); }

/* سرصفحه */
.hero { text-align: center; padding-top: 10px; }
.opening { margin: 0 0 22px; color: var(--gold); font-size: 15px; }
.portrait { position: relative; width: min(250px, 66vw); margin: 0 auto 22px; }
.portrait-frame {
  display: block; position: relative; padding: 7px; border-radius: 50%;
  border: 1px solid var(--gold);
  box-shadow: 0 0 0 6px var(--bg), 0 0 0 7px var(--panel-line), var(--shadow);
}
.portrait img { width: 100%; aspect-ratio: 10 / 13; object-fit: cover; border-radius: 50%; background: var(--bg-2); }
.portrait.is-bw img, .slides.is-bw img { filter: grayscale(1) contrast(1.04); }
.portrait-clip { display: block; position: relative; overflow: hidden; border-radius: 50%; }
.ribbon { position: absolute; top: 15%; left: -24%; width: 75%; height: 15px; background: #050608; transform: rotate(-42deg); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
[data-theme="dark"] .ribbon { background: #000; box-shadow: 0 0 0 1px rgba(194,168,120,.35); }
.prefix { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
.name { margin: 0; font: 400 clamp(36px, 11vw, 56px)/1.45 "Miremad", "Vazirmatn", serif; color: var(--text); }
.dates { margin: 4px 0 0; color: var(--muted); font-size: 15px; letter-spacing: .3px; }
.dates.hijri { margin-top: 0; font-size: 13px; }

.divider { display: block; width: 180px; margin: 0 auto 14px; fill: var(--gold); stroke: var(--gold); stroke-width: .8; opacity: .8; }
.verse { text-align: center; margin: 34px 0 26px; }
.verse-text { margin: 0; font-size: 19px; line-height: 2.2; white-space: normal; }
.verse-text.is-quran { font: 400 25px/2.1 "Amiri Quran", "Vazirmatn", serif; }
.verse-note { margin: 8px 0 0; color: var(--muted); font-size: 13.5px; }

.panel {
  margin: 18px 0; padding: 24px 20px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 12px; text-align: center; font-size: 17px; font-weight: 600; color: var(--gold); }

.invite-text { margin: 0 0 20px; text-align: justify; text-align-last: center; }
.when-where { text-align: center; padding-top: 18px; border-top: 1px solid var(--panel-line); }
.when-where p { margin: 0; }
.when { font-size: 19px; font-weight: 600; }
.time { color: var(--muted); }
.venue { margin-top: 12px !important; font-size: 18px; font-weight: 600; }
.address { color: var(--muted); font-size: 14.5px; }
.venue-note { margin-top: 8px !important; font-size: 13.5px; color: var(--gold); }
.map-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }

.family { text-align: center; margin: 30px 0; }
.memorial-line { margin: 0 0 18px; font-size: 17px; font-style: normal; }
.family-label { margin: 0; color: var(--muted); font-size: 13px; }
.family-names { margin: 2px 0 0; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--gold); background: transparent; color: var(--text);
  text-decoration: none; font-weight: 600; font-size: 15px; transition: background .25s, opacity .25s;
}
.btn-gold { background: var(--gold); color: var(--ink-on-gold); }
.btn-gold:hover { opacity: .9; }
.btn-ghost:hover { background: var(--gold-soft); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .juz:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* صوت */
.track-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.track.is-on { background: var(--gold); color: var(--ink-on-gold); }
.track .ic { fill: currentColor; stroke: none; }
.player { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.player-toggle { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--gold); background: transparent; cursor: pointer; display: grid; place-items: center; }
.player-toggle .ic { width: 16px; }
.player-bar { flex: 1; height: 4px; border-radius: 4px; background: var(--field-line); overflow: hidden; cursor: pointer; }
.player-bar span { display: block; height: 100%; width: 0; background: var(--gold); }
.player-time { font-size: 13px; color: var(--muted); min-width: 42px; text-align: left; }

/* فاتحه و صلوات */
.prayers { display: grid; gap: 22px; }
.prayer { text-align: center; }
.prayer + .prayer { padding-top: 22px; border-top: 1px solid var(--panel-line); }
.prayer-title { margin: 0 0 12px; }
.prayer-count { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.prayer-count b { color: var(--text); font-size: 17px; }
.salavat-btn.is-pulse { background: var(--gold-soft); }
.fatiha-text { margin-top: 12px; font-size: 14px; color: var(--muted); }
.fatiha-text summary { cursor: pointer; }
.quran-inline { font: 400 21px/2.2 "Amiri Quran", serif; color: var(--text); margin: 10px 0 0; }

/* ختم */
.khatm-intro { margin: 0 0 8px; text-align: center; font-size: 14.5px; color: var(--muted); }
.khatm-progress { margin: 0 0 6px; text-align: center; font-size: 14px; }
.khatm-done { margin: 0 0 12px; padding: 8px 12px; text-align: center; font-size: 14px; border-radius: 12px; background: var(--gold-soft); }
.juz-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 14px; }
.juz {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 62px; padding: 6px 2px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--panel-line); background: transparent; transition: background .2s;
}
.juz:hover { background: var(--gold-soft); }
.juz-n { font-size: 17px; font-weight: 600; line-height: 1.3; }
.juz-who { font-size: 10.5px; line-height: 1.3; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.juz.is-taken { background: var(--taken); border-color: transparent; cursor: default; }
.juz.is-taken .juz-n { color: var(--muted); }
.juz.is-mine { border-color: var(--gold); background: var(--gold-soft); cursor: pointer; }
.juz.is-mine .juz-n { color: var(--gold); }
.my-juz { margin-top: 16px; text-align: center; font-size: 14px; }
.my-juz p { margin: 0 0 8px; color: var(--muted); }
.my-juz-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.my-juz-list .btn { min-height: 38px; padding: 6px 14px; font-size: 14px; }

/* گالری */
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 0; border-radius: 16px; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; margin: 0; scroll-snap-align: center; }
.slide img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 16px; background: var(--bg-2); }
.slide figcaption { text-align: center; font-size: 13.5px; color: var(--muted); margin-top: 8px; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--field-line); transition: background .2s, width .2s; }
.dots span.on { background: var(--gold); width: 16px; border-radius: 3px; }

/* دفتر یادبود */
.book-intro { margin: 0 0 14px; text-align: center; color: var(--muted); font-size: 14.5px; }
.book-form { display: grid; gap: 10px; }
.book-form input, .book-form textarea, .sheet input {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--field-line);
  background: var(--field); outline: none; font-size: 15px; resize: vertical;
}
.book-form input:focus, .book-form textarea:focus, .sheet input:focus { border-color: var(--gold); }
.book-form .hp { position: absolute !important; width: 1px !important; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); opacity: 0; pointer-events: none; }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chars { font-size: 12.5px; color: var(--muted); }
.form-msg { margin: 0; min-height: 1.5em; font-size: 13.5px; text-align: center; color: var(--gold); }
.messages { margin-top: 18px; display: grid; gap: 12px; }
.message { padding: 14px 16px; border-radius: 16px; background: var(--field); border: 1px solid var(--field-line); }
.message-body { margin: 0; white-space: normal; overflow-wrap: anywhere; }
.message-meta { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.message-meta b { color: var(--text); font-weight: 600; }
.message.is-new { border-color: var(--gold); }
.empty { text-align: center; color: var(--muted); font-size: 14px; margin: 0; }

.share { text-align: center; margin: 30px 0 10px; }
.share p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.share-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.share-buttons .btn { min-height: 40px; padding: 8px 16px; font-size: 14px; }

.foot { text-align: center; margin-top: 34px; }
.foot-line { margin: 0 0 14px; font: 400 26px/1.6 "Miremad", "Vazirmatn", serif; color: var(--gold); }
.credit { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); text-decoration: none; opacity: .8; }
.credit img { border-radius: 50%; }

/* پنجره‌ها */
.sheet { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; padding: 16px; background: rgba(5, 8, 14, .6); }
.sheet-box { width: min(440px, 100%); padding: 24px 20px 20px; border-radius: 22px; background: var(--bg); border: 1px solid var(--panel-line); box-shadow: var(--shadow); text-align: center; }
.sheet-box h4 { margin: 0 0 8px; font-size: 18px; color: var(--gold); }
.sheet-box p { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; }
.sheet-actions { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
@media (min-width: 640px) { .sheet { place-items: center; } }

.reader { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: var(--bg); }
.reader-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--panel-line); }
.reader-head h4 { flex: 1; margin: 0; text-align: center; color: var(--gold); font-size: 17px; }
.reader-close { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--panel-line); background: transparent; font-size: 22px; cursor: pointer; }
.reader-size { display: flex; gap: 6px; }
.reader-size button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--panel-line); background: transparent; cursor: pointer; font-size: 13px; }
.reader-body { flex: 1; overflow-y: auto; padding: 18px 18px 60px; font: 400 var(--q-size, 24px)/2.25 "Amiri Quran", serif; text-align: justify; }
.reader-body .surah-head { margin: 18px 0 10px; padding: 8px; text-align: center; border: 1px solid var(--panel-line); border-radius: 12px; font: 600 16px/1.8 "Vazirmatn", sans-serif; color: var(--gold); }
.reader-body .bism { text-align: center; margin: 0 0 6px; }
.reader-body .aya-n { display: inline-block; min-width: 1.6em; margin: 0 .2em; text-align: center; color: var(--gold); font-size: .75em; }
.reader-body .loading { text-align: center; color: var(--muted); font: 400 15px "Vazirmatn", sans-serif; }

/* نمایش آرام هنگام اسکرول (فقط محو شدن) */
.js .reveal { opacity: 0; transform: translateY(10px); transition: opacity 1s ease, transform 1s ease; }
.js .reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .reveal, .js .gate { transition: none; transform: none; }
}

/* صفحه‌ی پایان */
.ended { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.ended-box { text-align: center; max-width: 420px; }
.ended-text { font-size: 19px; margin: 0 0 6px; }
.ended-sub { color: var(--muted); margin: 0 0 30px; font-size: 14px; }

@media (max-width: 360px) {
  .juz-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .juz { min-height: 56px; }
  .panel { padding: 20px 14px; }
}
