/* ================================================================
   الترجمة — Islamic design system
   Palette: emerald (زمردي) · gold (ذهبي) · parchment (رقّي)
   ================================================================ */
:root {
  --emerald: #0B3D2E;
  --emerald-600: #0E5540;
  --emerald-300: #2F8168;
  --gold: #B08D2E;
  --gold-soft: #D9BE6A;
  --gold-ink: #7A5F14;
  --parchment: #FAF6EC;
  --parchment-2: #F3EBD9;
  --surface: #FFFDF8;
  --ink: #241F17;
  --muted-ink: #6B6357;
  --border: #E5D9BF;
  --danger: #A8291A;
  --success: #15703F;

  --kufi: "Reem Kufi", "Tajawal", sans-serif;
  --naskh: "Amiri", serif;
  --ui: "Tajawal", system-ui, sans-serif;

  --radius: 14px;
  --shadow: 0 2px 10px rgb(11 61 46 / .06);
  --shadow-lg: 0 8px 30px rgb(11 61 46 / .12);

  /* legacy aliases kept for /admin.html */
  --serif: var(--kufi);
  --navy: var(--emerald);
  --muted: var(--muted-ink);
  --line: var(--border);
  --soft: var(--parchment-2);
  --accent: var(--emerald);
  --accent-dark: var(--emerald-600);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  background-color: var(--parchment);
  background-image: url("data:image/svg+xml,%3Csvg width='72' height='72' viewBox='0 0 72 72' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%230B3D2E' stroke-opacity='.055' stroke-width='1'%3E%3Cpath d='M36 4 42 18 56 12 50 26 64 32 50 38 56 52 42 46 36 60 30 46 16 52 22 38 8 32 22 26 16 12 30 18Z'/%3E%3Ccircle cx='36' cy='32' r='7'/%3E%3C/g%3E%3C/svg%3E");
}
.wrap { max-width: 720px; margin-inline: auto; padding-inline: 20px; }
:focus-visible { outline: 3px solid var(--emerald-300); outline-offset: 3px; border-radius: 6px; }

/* ---------------- شريط الحكم ---------------- */
.ribbon {
  background:
    radial-gradient(ellipse at 12% -30%, rgb(217 190 106 / .18), transparent 58%),
    linear-gradient(105deg, #06281E 0%, #0B3D2E 55%, #0A4A38 100%);
  color: #FBF7EC;
  border-bottom: 3px solid var(--gold);
  padding: 14px 20px 12px;
}
.ribbon-inner {
  max-width: 1000px; margin-inline: auto;
  display: flex; align-items: center; gap: 26px;
}
.quote-area {
  flex: 1; text-align: center; min-height: 76px;
  display: flex; flex-direction: column; justify-content: center;
  transition: opacity .9s ease, transform .9s ease;
}
.quote-area.fading { opacity: 0; transform: translateY(6px); }
.quote-text {
  margin: 0; font-family: var(--naskh); font-size: 1.3rem; line-height: 1.95;
  text-shadow: 0 1px 8px rgb(0 0 0 / .3);
}
.quote-author {
  margin: 2px 0 0; font-family: var(--naskh); font-size: .92rem; color: var(--gold-soft);
}
.quote-author::before { content: "❁ "; font-size: .7rem; }
.quote-author::after  { content: " ❁"; font-size: .7rem; }
.hijri-clock {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding-inline-start: 26px; border-inline-start: 1px solid rgb(217 190 106 / .35);
  white-space: nowrap;
}
.clock-time {
  font-family: var(--naskh); font-size: 1.35rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: #FDF9F0;
}
.clock-date { font-family: var(--naskh); font-size: .88rem; color: var(--gold-soft); }

/* ---------------- الترويسة ---------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--emerald); }
.brand-mark { position: relative; display: grid; place-items: center; width: 44px; height: 44px; }
.brand-mark svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.brand-mark .star { fill: var(--emerald); }
.brand-letter {
  position: relative; font-family: var(--naskh); font-size: 19px;
  color: var(--gold-soft); font-weight: 700; line-height: 1;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text strong { font-family: var(--kufi); font-size: 1.35rem; font-weight: 600; }
.brand-text small { color: var(--muted-ink); font-size: .78rem; }

/* ---------------- البطاقة ---------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px;
  margin-block: 34px 26px;
  text-align: center;
}
.card::before {
  content: ""; position: absolute; inset: 7px;
  border: 1px solid rgb(176 141 46 / .28); border-radius: 8px; pointer-events: none;
}
.corner {
  position: absolute; width: 16px; height: 16px; pointer-events: none;
  border-color: var(--gold); border-style: solid; border-width: 0;
}
.corner.tl { top: 3px; right: 3px; border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 6px; }
.corner.tr { top: 3px; left: 3px;  border-top-width: 2px; border-left-width: 2px;  border-top-left-radius: 6px; }
.corner.bl { bottom: 3px; right: 3px; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 6px; }
.corner.br { bottom: 3px; left: 3px;  border-bottom-width: 2px; border-left-width: 2px;  border-bottom-left-radius: 6px; }

/* ---------------- منطقة الإسقاط (محراب) ---------------- */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 44% 44% 12px 12px / 22% 22% 12px 12px;
  padding: 46px 22px 30px;
  cursor: pointer; background: #FEFCF6;
  transition: border-color .2s ease, background .2s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--emerald-300); background: #F5FAF6;
}
.dropzone.dragover { border-style: solid; }
.arch-ornament {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 120px; color: var(--gold); opacity: .75;
}
.arch-ornament svg { width: 100%; display: block; }
.dz-icon { width: 40px; height: 40px; color: var(--emerald); margin-top: 6px; }
.dz-main {
  margin: 8px 0 0; font-family: var(--kufi); font-size: 1.4rem;
  font-weight: 600; color: var(--emerald);
}
.dz-sub { margin: 2px 0 0; color: var(--muted-ink); font-size: .95rem; }
.dz-hint {
  margin: 10px 0 0; color: var(--gold-ink); font-size: .8rem;
  letter-spacing: .08em; font-weight: 500;
}
.dz-file {
  margin: 12px auto 0; display: inline-block;
  background: var(--parchment-2); border: 1px solid var(--border);
  padding: 6px 18px; border-radius: 999px; font-weight: 700; font-size: .92rem;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--emerald);
}

/* ---------------- الحقول ---------------- */
.field { border: 0; margin: 24px 0 0; padding: 0; text-align: center; }
.field legend, .notes-label {
  font-family: var(--kufi); font-size: 1.02rem; font-weight: 600;
  color: var(--emerald); margin-bottom: 10px; display: inline-flex;
  align-items: center; gap: 7px; justify-content: center;
}
.notes-label { display: flex; }
.notes-icon { width: 18px; height: 18px; color: var(--gold); }
.optional {
  font-family: var(--ui); font-size: .72rem; font-weight: 400;
  color: var(--muted-ink); background: var(--parchment-2);
  border-radius: 999px; padding: 1px 9px;
}

.segmented {
  display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 3px;
  border: 1px solid var(--border); border-radius: 10px; padding: 4px;
  background: var(--parchment-2);
}
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span {
  display: inline-block; padding: 9px 18px; border-radius: 7px;
  font-size: .92rem; color: var(--muted-ink); min-height: 24px;
  transition: background .18s ease, color .18s ease;
}
.segmented input:checked + span {
  background: var(--emerald); color: #FBF7EC; font-weight: 700;
  box-shadow: 0 1px 4px rgb(11 61 46 / .25);
}
.segmented input:focus-visible + span { outline: 3px solid var(--emerald-300); outline-offset: 2px; }

.divider { margin: 26px auto 0; width: 170px; color: var(--gold); opacity: .65; }
.divider svg { width: 100%; display: block; }

.notes-field { text-align: start; }
.notes-field .notes-label { justify-content: flex-start; }
.notes-help { margin: 0 0 8px; color: var(--muted-ink); font-size: .86rem; line-height: 1.6; }
#notes {
  width: 100%; resize: vertical; min-height: 96px;
  font-family: var(--ui); font-size: 1rem; line-height: 1.8; color: var(--ink);
  background: #FEFCF6; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
#notes:hover { border-color: #D8C79F; }
#notes:focus { outline: none; border-color: var(--emerald-300); box-shadow: 0 0 0 3px rgb(47 129 104 / .16); }
#notes::placeholder { color: #A79E8C; }
.counter {
  display: block; text-align: start; margin-top: 4px;
  font-size: .75rem; color: var(--muted-ink); font-variant-numeric: tabular-nums;
}

/* ---------------- الأزرار ---------------- */
.primary-btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  background: var(--emerald); color: #FBF7EC;
  font-family: var(--kufi); font-weight: 600; font-size: 1.08rem;
  padding: 13px 40px; border-radius: 10px; min-height: 50px;
  margin-top: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgb(11 61 46 / .2);
  transition: background .18s ease, transform .12s ease, box-shadow .18s ease;
}
.primary-btn:hover:not(:disabled) { background: var(--emerald-600); box-shadow: 0 4px 14px rgb(11 61 46 / .28); }
.primary-btn:active:not(:disabled) { transform: scale(.98); }
.primary-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.link-btn {
  display: block; margin: 14px auto 0; background: none; border: 0;
  color: var(--muted-ink); font: inherit; font-size: .93rem;
  text-decoration: underline; text-underline-offset: 4px; cursor: pointer;
  min-height: 44px;
}
.link-btn:hover { color: var(--emerald); }

.error-text { color: var(--danger); font-weight: 500; margin: 14px 0 0; }
.error-title { font-family: var(--kufi); font-size: 1.2rem; color: var(--danger); margin: 0; }

/* ---------------- حالة العمل ---------------- */
.work-lamp { display: block; width: 46px; margin: 0 auto 10px; color: var(--gold); }
.work-lamp .star { fill: var(--gold-soft); }
.work-lamp .spin { transform-origin: 20px 20px; animation: rotate 9s linear infinite; }
@keyframes rotate { to { transform: scale(.8) translate(5px, 5px) rotate(360deg); } }
.work-file { font-family: var(--kufi); font-size: 1.05rem; color: var(--emerald); margin: 0 0 18px; overflow-wrap: anywhere; }
.progress { height: 10px; background: var(--parchment-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--emerald), var(--emerald-300));
  transition: width .6s ease;
}
.work-stage { color: var(--muted-ink); margin: 12px 0 0; font-size: .96rem; }
.pct { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--emerald); }

/* ---------------- الدعاء أثناء الانتظار ---------------- */
.dua {
  margin-top: 28px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(180deg, #FCF7E9, #FAF3E2);
  border: 1px solid #E6D6AC;
  border-radius: 12px;
  padding: 18px 20px;
  position: relative;
}
.dua::before {
  content: ""; position: absolute; inset: 5px;
  border: 1px solid rgb(176 141 46 / .3); border-radius: 8px; pointer-events: none;
}
.dua-orn { color: var(--gold); font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
.dua-text {
  margin: 0;
  font-family: var(--naskh);
  font-size: 1.35rem;
  line-height: 2;
  color: var(--emerald);
  font-weight: 700;
}
@media (max-width: 560px) {
  .dua { gap: 10px; padding: 15px 14px; }
  .dua-text { font-size: 1.12rem; }
}

/* ---------------- حالة الإتمام ---------------- */
.done-icon { width: 56px; height: 56px; color: var(--success); }
.done-title { font-family: var(--kufi); font-size: 1.35rem; color: var(--emerald); margin: 8px 0 2px; }
.done-file { color: var(--muted-ink); margin: 0; font-size: .93rem; overflow-wrap: anywhere; }

/* ---------------- السجل ---------------- */
.history-title {
  font-family: var(--kufi); font-size: 1.08rem; font-weight: 600;
  color: var(--emerald); margin: 0 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.history-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.history { list-style: none; margin: 0 0 56px; padding: 0; }
.history li {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; margin-bottom: 8px;
}
.history .h-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.history .h-meta { color: var(--muted-ink); font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.history a.h-dl, .history button.h-x {
  display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 9px; border: 0; background: none; cursor: pointer;
}
.history a.h-dl { color: var(--emerald); }
.history a.h-dl:hover { background: var(--parchment-2); }
.history button.h-x { color: var(--muted-ink); }
.history button.h-x:hover { background: #FBEDEA; color: var(--danger); }
.history .icon { width: 18px; height: 18px; }

.footer {
  text-align: center; color: var(--muted-ink); font-family: var(--naskh);
  font-size: .95rem; padding-block: 22px 34px;
}
.footer p { margin: 0; }

/* ---------------- الشاشات الصغيرة ---------------- */
@media (max-width: 720px) {
  .ribbon-inner { flex-direction: column; gap: 8px; }
  .hijri-clock {
    border-inline-start: 0; padding-inline-start: 0;
    flex-direction: row; gap: 12px; align-items: baseline;
  }
  .clock-time { font-size: 1.05rem; }
  .quote-area { min-height: 98px; }
  .quote-text { font-size: 1.08rem; }
}
@media (max-width: 560px) {
  .card { padding: 26px 18px; margin-block-start: 22px; }
  .dropzone { padding: 40px 14px 26px; }
  .dz-main { font-size: 1.2rem; }
  .segmented { width: 100%; }
  .segmented label { flex: 1; }
  .segmented span { display: block; text-align: center; padding-inline: 8px; }
  .primary-btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
