/* ===== الثيمات: كلها داكنة، والذهبي هو الافتراضي ===== */
:root {
  --font-ui: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  --sand: #0B0B10;        /* الخلفية الأساسية */
  --parchment: #14141C;   /* الكروت */
  --edge: #06060A;        /* أطراف الخلفية */
  --brown: #F1E9D8;       /* لون النص (عاجي) */
  --brown-soft: #BDB4A2;
  --gold: #C9A961;
  --gold-light: #7E6B3F;
  --seal-hi: #2B2B3A;
  --seal-base: #15151D;
  --on-brown: #0B0B10;
  --shade: 0, 0, 0;
}
[data-theme="pink"] { --sand: #120B0E; --parchment: #1D1217; --edge: #080507; --brown: #F3E6E8; --brown-soft: #C4AEB3; --gold: #D39AAB; --gold-light: #7C5360; --seal-hi: #3B2A31; --seal-base: #1A1115; --on-brown: #120B0E; }
[data-theme="green"] { --sand: #0B100D; --parchment: #131B16; --edge: #060907; --brown: #E9EFE4; --brown-soft: #B3BFB4; --gold: #B7B67E; --gold-light: #5E6544; --seal-hi: #26352C; --seal-base: #101712; --on-brown: #0B100D; }
[data-theme="blue"] { --sand: #0A0E14; --parchment: #111822; --edge: #05080C; --brown: #E6EEF5; --brown-soft: #AEBBC8; --gold: #7FA6C6; --gold-light: #44607A; --seal-hi: #263648; --seal-base: #0F1620; --on-brown: #0A0E14; }
[data-theme="purple"] { --sand: #0E0B14; --parchment: #17121F; --edge: #07050B; --brown: #EEE8F5; --brown-soft: #BAB0C6; --gold: #A98FCB; --gold-light: #5E4D7A; --seal-hi: #30263F; --seal-base: #130F1A; --on-brown: #0E0B14; }
[data-theme="sunset"] { --sand: #120C09; --parchment: #1C1410; --edge: #080504; --brown: #F5E9DC; --brown-soft: #C8B6A3; --gold: #D08B5B; --gold-light: #7F5436; --seal-hi: #3B2A20; --seal-base: #18110D; --on-brown: #120C09; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

body {
  min-height: 100vh;
  color: var(--brown);
  font-family: var(--font-ui);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-tap-highlight-color: transparent;
  /* ورق قديم: حبيبات + تعتيق من الأطراف */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .15 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 40%, var(--parchment) 0%, var(--sand) 62%, var(--edge) 100%);
  background-attachment: fixed;
}

main { width: 100%; max-width: 520px; }

.frame {
  position: relative;
  text-align: center;
  padding: 36px 24px 28px;
  border: 2px solid var(--gold);
  outline: 1px solid var(--gold);
  outline-offset: -9px;
  background: color-mix(in srgb, var(--parchment) 45%, transparent);
  box-shadow: 0 0 0 6px rgba(var(--shade), .08), 0 18px 40px rgba(var(--shade), .18);
}

h1 {
  font-family: "Aref Ruqaa", "Amiri", serif;
  font-weight: 700;
  font-size: clamp(2.8rem, 12vw, 4.6rem);
  line-height: 1.4;
  color: var(--brown);
  text-shadow: 0 1px 0 var(--gold-light);
}

.verse {
  font-size: 1.2rem;
  line-height: 2.1;
  color: var(--brown-soft);
  margin: .6rem auto 1.6rem;
  padding-top: 1rem;
  max-width: 30ch;
  border-top: 1px solid var(--gold);
}

/* زر الختم: دائرة فقط بدون كتابة */
.seal {
  position: relative;
  width: 156px;
  height: 156px;
  border-radius: 50%;
  border: 3px double var(--gold-light);
  cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--seal-hi), var(--seal-base) 70%);
  box-shadow: 0 0 0 4px var(--seal-base), 0 0 0 6px var(--gold), 0 8px 18px rgba(var(--shade), .35);
  transition: transform .12s ease, box-shadow .12s ease;
}
/* حلقة داخلية رفيعة تعطي الزر شكل الختم */
.seal::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid var(--gold-light);
  opacity: .7;
  pointer-events: none;
}
.seal:active, .seal.pop { transform: scale(.94); box-shadow: 0 0 0 4px var(--seal-base), 0 0 0 6px var(--gold), 0 3px 8px rgba(var(--shade), .35); }
.seal:focus-visible, .btn:focus-visible, .theme-toggle:focus-visible, .theme-option:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

.counter {
  margin: 1.4rem 0 1.6rem;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .5rem;
}
#count {
  font-family: "Aref Ruqaa", "Amiri", serif;
  font-size: 2.6rem;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 1px 0 rgba(var(--shade), .25);
  min-width: 2ch;
}
.counter small { font-size: 1.15rem; color: var(--brown-soft); }

.actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  min-height: 36px;
  padding: 4px 16px;
  border-radius: 5px;
  border: 1px solid var(--brown);
  background: transparent;
  color: var(--brown);
  cursor: pointer;
  transition: transform .12s ease;
}
.btn.primary { background: var(--brown); color: var(--on-brown); }
.btn.ghost { border-color: transparent; color: var(--brown-soft); text-decoration: underline; text-decoration-color: var(--gold); }
.btn:active { transform: scale(.96); }

.status { min-height: 1.8rem; margin-top: 1rem; font-size: 1.1rem; color: var(--brown-soft); }

/* ===== زر الثيمات (أعلى اليسار) ===== */
.theme-wrap { position: fixed; top: 14px; left: 14px; z-index: 10; }

.theme-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: color-mix(in srgb, var(--parchment) 85%, transparent);
  color: var(--brown);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(var(--shade), .2);
  transition: transform .12s ease;
}
.theme-toggle:active { transform: scale(.92); }
.theme-toggle svg { width: 22px; height: 22px; }

.theme-panel {
  position: absolute;
  top: 54px;
  left: 0;
  min-width: 160px;
  padding: 8px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: var(--parchment);
  box-shadow: 0 10px 28px rgba(var(--shade), .3);
  transform-origin: top left;
  animation: pop-in .14s ease;
}
.theme-panel[hidden] { display: none; }

.theme-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--brown);
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  text-align: right;
}
.theme-option:hover { background: rgba(var(--shade), .08); }
.theme-option[aria-pressed="true"] { font-weight: 700; background: rgba(var(--shade), .12); }

.swatch {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--brown);
}

/* ===== نافذة التأكيد (بديل confirm) ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(var(--shade), .55);
  animation: fade-in .15s ease;
}
.overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 340px;
  text-align: center;
  padding: 28px 22px 22px;
  border: 2px solid var(--gold);
  outline: 1px solid var(--gold);
  outline-offset: -7px;
  background: var(--parchment);
  box-shadow: 0 18px 40px rgba(var(--shade), .4);
  animation: pop-in .16s ease;
}
.modal h2 {
  font-family: "Aref Ruqaa", "Amiri", serif;
  font-size: 1.9rem;
  line-height: 1.4;
  color: var(--brown);
}
.modal p { margin: .4rem 0 1.3rem; font-size: 1.15rem; color: var(--brown-soft); }
.modal .actions { gap: 10px; }

@keyframes pop-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .seal, .btn, .theme-toggle { transition: none; }
  .theme-panel, .overlay, .modal { animation: none; }
}

/* ===== قسم «رسالة اليوم» (إضافة) ===== */
.daily {
  position: relative;
  overflow: hidden;
  margin-top: 14px;
  text-align: center;
  padding: 14px 16px 12px;
  border: 1px solid var(--gold);
  outline: 1px solid var(--gold-light);
  outline-offset: -5px;
  border-radius: 70px 70px 5px 5px / 30px 30px 5px 5px; /* قوس يشبه محراب */
  background:
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--gold-light) 30%, transparent), transparent 70%),
    color-mix(in srgb, var(--parchment) 55%, transparent);
  box-shadow: 0 6px 16px rgba(var(--shade), .1);
}
.daily > :not(.daily-sparks) { position: relative; z-index: 1; }

.daily h2 {
  font-family: "Aref Ruqaa", "Amiri", serif;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--gold);
  text-shadow: 0 1px 0 rgba(var(--shade), .15);
}
.daily h2::after {
  content: "";
  display: block;
  width: 48px;
  height: 1px;
  margin: .15rem auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.daily-msg {
  min-height: 3.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: .4rem auto .6rem;
  max-width: 34ch;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--brown);
  opacity: 1;
  transition: opacity .35s ease;
}
.daily-msg.fade-out { opacity: 0; }

.daily-btn { font-size: .95rem; min-height: 32px; padding: 3px 14px; }

/* نقاط ضوء تتحرك ببطء شديد */
.daily-sparks { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.daily-sparks span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--gold-light);
  box-shadow: 0 0 4px var(--gold-light);
  opacity: 0;
  animation: spark-drift var(--d) ease-in-out var(--del) infinite;
}
@keyframes spark-drift {
  0%   { opacity: 0;  transform: translate(0, 0); }
  25%  { opacity: .5; }
  50%  { transform: translate(var(--dx), -16px); }
  75%  { opacity: .4; }
  100% { opacity: 0;  transform: translate(calc(var(--dx) * -1), -34px); }
}

@media (max-width: 420px) {
  .daily { padding: 12px 12px 10px; border-radius: 56px 56px 5px 5px / 26px 26px 5px 5px; }
  .daily-msg { font-size: 1rem; min-height: 3.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .daily-msg { transition: none; }
  .daily-sparks span { animation: none; opacity: .3; }
}

/* ===== بطاقة «غرفة السكينة» في الصفحة الرئيسية ===== */
.sakina-card {
  margin-top: 14px;
  text-align: center;
  padding: 14px 16px 14px;
  border: 1px solid var(--gold);
  outline: 1px solid var(--gold-light);
  outline-offset: -5px;
  background: color-mix(in srgb, var(--parchment) 55%, transparent);
  box-shadow: 0 6px 16px rgba(var(--shade), .1);
}
.sakina-card h2 {
  font-family: "Aref Ruqaa", "Amiri", serif;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.4;
  color: var(--gold);
}
.sakina-card p { margin: .1rem 0 .7rem; font-size: 1.05rem; color: var(--brown-soft); }
.sakina-card .btn { font-size: .95rem; min-height: 32px; padding: 3px 16px; }

/* ===== غرفة السكينة ===== */
.room {
  position: fixed;
  inset: 0;
  z-index: 15;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 20px 150px;
  color: var(--brown);
  background: radial-gradient(ellipse at 50% 0%, var(--parchment) 0%, var(--sand) 70%, var(--edge) 100%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .5s ease, transform .5s ease, visibility 0s linear .5s;
}
.room.open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}
.room-back { position: fixed; top: 14px; right: 14px; z-index: 2; background: color-mix(in srgb, var(--parchment) 85%, transparent); }

/* ضوء ناعم يدخل من النافذة */
.room-light {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--gold-light) 40%, transparent), transparent 55%),
    linear-gradient(180deg, color-mix(in srgb, var(--gold-light) 28%, transparent), transparent 75%);
  clip-path: polygon(36% 0, 64% 0, 100% 100%, 0 100%);
  opacity: .7;
}

.room-inner {
  position: relative;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.room-window { width: 96px; height: auto; margin-bottom: -2px; }
.room-window .w-glass { fill: color-mix(in srgb, var(--gold-light) 35%, transparent); }
.room-window .w-frame { fill: none; stroke: var(--gold); stroke-width: 3; }
.room-window .w-bar { fill: none; stroke: var(--gold); stroke-width: 2; }
.room-window .w-sill { fill: var(--gold); }

.room-card {
  position: relative;
  width: 100%;
  margin-top: 14px;
  text-align: center;
  padding: 26px 22px 20px;
  border: 2px solid var(--gold);
  outline: 1px solid var(--gold);
  outline-offset: -9px;
  background: color-mix(in srgb, var(--parchment) 80%, transparent);
  box-shadow: 0 0 0 6px rgba(var(--shade), .08), 0 18px 40px rgba(var(--shade), .18);
}
.room-card > h2 {
  font-family: "Aref Ruqaa", "Amiri", serif;
  font-size: 2rem;
  line-height: 1.4;
  color: var(--brown);
  text-shadow: 0 1px 0 var(--gold-light);
}
.room-block { padding: 14px 4px 4px; }
.room-block + .room-block { margin-top: 12px; border-top: 1px solid var(--gold-light); }
.room-block h3 {
  font-family: "Aref Ruqaa", "Amiri", serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: .3rem;
}
.room-ayah { font-size: 1.3rem; line-height: 2.1; color: var(--brown); }
.room-block small { display: block; font-size: 1rem; color: var(--brown-soft); }
.room-dhikr { font-size: 1.35rem; line-height: 1.9; color: var(--brown); margin-bottom: .7rem; }
.room-salat { font-size: 1.2rem; line-height: 2; color: var(--brown-soft); }

.room-tap {
  width: 96px;
  height: 96px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 3px double var(--gold-light);
  cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--seal-hi), var(--seal-base) 70%);
  color: var(--on-brown);
  box-shadow: 0 0 0 3px var(--seal-base), 0 0 0 5px var(--gold), 0 6px 14px rgba(var(--shade), .3);
  transition: transform .12s ease;
}
.room-tap span { font-family: "Aref Ruqaa", "Amiri", serif; font-size: 1.9rem; line-height: 1; }
.room-tap:active { transform: scale(.94); }
.room-reset { display: block; margin: .6rem auto 0; font-size: .95rem; min-height: 30px; }
.room-tap:focus-visible, .room-back:focus-visible, .room-reset:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

/* نبتة صغيرة في الزاوية */
.room-plant { position: fixed; bottom: 0; left: 14px; width: 86px; height: auto; pointer-events: none; }
.room-plant .p-leaf { fill: var(--brown-soft); opacity: .75; }
.room-plant .p-pot { fill: var(--gold); }
.room-plant .p-rim { fill: var(--brown); }

@media (max-width: 420px) {
  .room { padding-top: 60px; }
  .room-window { width: 80px; }
  .room-card { padding: 22px 14px 16px; }
  .room-ayah { font-size: 1.2rem; }
  .room-plant { width: 70px; left: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .room { transition: none; transform: none; }
  .room-tap { transition: none; }
}

/* ===== نسخة مدمجة + خطوط ناعمة (تعديلات) ===== */
body { padding: 12px; }
.frame { padding: 18px 18px 12px; outline-offset: -7px; }
h1 { font-size: clamp(2rem, 9vw, 2.7rem); line-height: 1.3; }
.verse { font-size: 1rem; line-height: 1.85; margin: .3rem auto .9rem; padding-top: .5rem; }
.seal { width: 104px; height: 104px; }
.seal::after { inset: 10px; }
.counter { margin: .8rem 0; }
#count { font-family: var(--font-ui); font-weight: 500; font-size: 2rem; }
.counter small { font-size: 1rem; }
.btn { font-weight: 500; font-size: 1rem; min-height: 34px; }
.status { min-height: 1.3rem; margin-top: .5rem; font-size: 1rem; }

.daily { margin-top: 8px; padding: 8px 14px; border-radius: 44px 44px 5px 5px / 20px 20px 5px 5px; }
.daily h2 { font-family: var(--font-ui); font-weight: 500; font-size: 1.05rem; }
.daily-msg { min-height: 3.2rem; max-width: 40ch; margin: .2rem auto .4rem; font-size: .95rem; line-height: 1.7; }
.daily-btn { font-size: .9rem; min-height: 30px; }

.sakina-card { margin-top: 8px; padding: 8px 14px; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center; text-align: start; }
.sakina-card h2 { font-family: var(--font-ui); font-weight: 500; font-size: 1.05rem; line-height: 1.5; }
.sakina-card p { margin: 0; font-size: .9rem; }
.sakina-card .btn { grid-column: 2; grid-row: 1 / 3; font-size: .9rem; min-height: 30px; }

.modal h2, .room-block h3 { font-family: var(--font-ui); font-weight: 500; }
.room-tap { color: var(--brown); }
.room-tap span { font-family: var(--font-ui); font-weight: 500; }
.room-light { background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 55%), linear-gradient(180deg, color-mix(in srgb, var(--gold) 10%, transparent), transparent 75%); }
.room-window .w-glass { fill: color-mix(in srgb, var(--gold) 14%, transparent); }
.room-plant .p-leaf { fill: var(--gold-light); opacity: 1; }
.room-plant .p-rim { fill: var(--gold); }
.room-plant .p-pot { fill: var(--seal-hi); }
