/* =====================================================================
   al3jman.com — الواجهة العامة (المرحلة الثالثة)
   الألوان والخطوط تأتي من إعدادات الهوية في لوحة التحكم (brand.theme)
   ===================================================================== */
:root {
  --bg: #0A1426;
  --surface: #111E36;
  --surface-2: #0d1930;
  --line: #22314f;
  --accent: #B8975A;
  --accent-soft: #D4BC8A;
  --text: #EDE6D6;
  --muted: #9aa6bd;
  --danger: #d0605e;
  --ok: #3fa37a;
  --mourn: #9aa3b2;
  --font: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Amiri", "Cairo", serif;
  --radius: 16px;
  --top-h: 64px;
  --bar-h: 74px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F6F2E9;
  --surface: #FFFFFF;
  --surface-2: #FBF8F2;
  --line: #E4DACA;
  --accent: #9A7A3E;
  --accent-soft: #7d6230;
  --text: #1C2436;
  --muted: #6B7180;
  --mourn: #6b7280;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 17px; line-height: 1.7; min-height: 100dvh; -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- الشعار ---------- */
.flag-dot { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; display: inline-block; flex: none; box-shadow: 0 0 0 1.5px var(--accent); }
.flag-dot svg { width: 100%; height: 100%; display: block; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 30px; color: var(--accent-soft); line-height: 1; }

/* ---------- الشريط العلوي ---------- */
.top {
  position: sticky; top: 0; z-index: 30; height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0; display: grid; grid-template-columns: 52px 1fr 52px; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top .brand { justify-self: center; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 14px; border: 0; background: transparent; display: grid; place-items: center;
  position: relative; color: var(--text);
}
.icon-btn:active { background: var(--surface); }
.icon-btn svg { width: 26px; height: 26px; }
.dot-badge {
  position: absolute; top: 5px; inset-inline-start: 5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; line-height: 1;
}

/* ---------- الشريط السفلي ---------- */
.bar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 30; height: calc(var(--bar-h) + env(safe-area-inset-bottom));
  padding: 6px 6px env(safe-area-inset-bottom); display: flex; justify-content: space-around; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bar a {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 12.5px; font-weight: 600; border-radius: 14px;
}
.bar a .ic { font-size: 23px; line-height: 1; }
.bar a.on { color: var(--accent-soft); }
.bar a.hi .ic {
  width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; background: var(--accent); color: #0A1426;
  display: grid; place-items: center; font-size: 28px; box-shadow: 0 6px 18px rgba(0,0,0,.35), 0 0 0 4px var(--bg);
}
.bar a.hi { color: var(--accent-soft); }

/* ---------- القائمة الجانبية ---------- */
.scrim { position: fixed; inset: 0; background: rgba(3,8,18,.6); z-index: 40; animation: fade .15s; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(330px, 86vw); z-index: 41;
  background: var(--surface); border-inline-end: 1px solid var(--line); overflow: auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px 24px; animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(100%); } }
:root[dir=ltr] .drawer { animation-name: slide-l; }
@keyframes slide-l { from { transform: translateX(-100%); } }
@keyframes fade { from { opacity: 0; } }
.drawer .plaque { margin-bottom: 14px; }
.drawer-x { display: block; margin: -6px 0 6px auto; font-size: 20px; background: var(--surface-2); border: 1px solid var(--line); }
.drawer nav a {
  display: flex; align-items: center; gap: 12px; padding: 13px 12px; border-radius: 12px; text-decoration: none;
  font-weight: 600; font-size: 17px;
}
.drawer nav a .ic { width: 28px; text-align: center; font-size: 21px; }
.drawer nav a.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-soft); }
.drawer nav a.sub { padding-inline-start: 52px; font-size: 15px; color: var(--muted); }
.drawer hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.theme-row { display: flex; gap: 6px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.theme-row button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 4px; font-weight: 600; font-size: 14px; color: var(--muted); }
.theme-row button.on { background: var(--accent); color: #0A1426; }

/* ---------- اللوحة (الشعار الكبير) ---------- */
.plaque {
  text-align: center; padding: 18px 12px 16px; border-radius: 20px; position: relative;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%), var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
.plaque .name { font-family: var(--font-head); font-size: 50px; font-weight: 700; color: var(--accent-soft); line-height: 1.15; }
.plaque .sub { color: var(--muted); font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ---------- المحتوى ---------- */
main { max-width: 760px; margin: 0 auto; padding: 14px 14px 30px; }
.today { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 16px 2px 8px; }
.today b { font-size: 18px; }
.today span { color: var(--muted); font-size: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 22px; padding: 8px 16px;
  font-weight: 600; font-size: 15px; min-height: 42px;
}
.chips button.on { background: var(--accent); color: #0A1426; border-color: transparent; }
.day-h { display: flex; align-items: center; gap: 10px; margin: 18px 4px 8px; font-weight: 700; font-size: 16px; color: var(--accent-soft); }
.day-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day-h small { color: var(--muted); font-weight: 400; font-size: 13px; }

.ev {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: start; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  border-inline-start: 4px solid var(--type, var(--accent));
}
.ev:active { transform: scale(.99); }
.ev .ico { font-size: 28px; line-height: 1.2; width: 36px; text-align: center; flex: none; }
.ev .b { flex: 1; min-width: 0; }
.ev .k { font-size: 13px; font-weight: 700; color: var(--type, var(--accent-soft)); }
.ev .t { font-weight: 700; font-size: 18px; line-height: 1.45; overflow-wrap: anywhere; }
.ev .h { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.ev .m { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14.5px; margin-top: 4px; }
.ev .m span { display: inline-flex; gap: 5px; align-items: center; }
.ev.mourn { --type: var(--mourn); }
.tag { display: inline-block; font-size: 12px; padding: 0 9px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-soft); font-weight: 700; margin-inline-start: 6px; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 44px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 18px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 16px;
  text-decoration: none; color: var(--text);
}
.btn.gold { background: var(--accent); color: #0A1426; border-color: transparent; }
.btn.wa { background: #1f8f4e; color: #fff; border-color: transparent; }
.btn.block { width: 100%; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.btns .full { grid-column: 1 / -1; }

/* ---------- صفحة المناسبة ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); font-weight: 600; padding: 6px 2px; margin-bottom: 6px; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px 18px; border-top: 5px solid var(--type, var(--accent)); }
.detail.mourn { --type: var(--mourn); }
.detail .k { font-weight: 700; color: var(--type, var(--accent-soft)); font-size: 15px; }
.detail h1 { font-family: var(--font-head); font-size: 32px; line-height: 1.35; margin: 4px 0 2px; overflow-wrap: anywhere; }
.detail .host { color: var(--muted); font-size: 16px; }
.facts { margin: 16px 0 4px; display: grid; gap: 10px; }
.fact { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.fact .i { font-size: 22px; width: 28px; text-align: center; flex: none; }
.fact b { display: block; font-size: 17px; }
.fact small { color: var(--muted); font-size: 14px; display: block; }
.invite { width: 100%; border-radius: 14px; border: 1px solid var(--line); margin-top: 12px; display: block; }
.desc { white-space: pre-wrap; margin-top: 12px; color: var(--text); }
.mourn-note { text-align: center; color: var(--mourn); font-family: var(--font-head); font-size: 20px; margin: 4px 0 10px; }

/* ---------- عام ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h2 { margin: 0 0 6px; font-size: 19px; }
.page-title { font-family: var(--font-head); font-size: 30px; margin: 10px 2px 12px; color: var(--accent-soft); }
.notif { display: block; text-decoration: none; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: 0; }
.notif .t { font-weight: 700; }
.notif .s { color: var(--muted); font-size: 14px; }
.notif.new { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.social { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 26px; }
.offline { background: #3a2a10; color: #f1d9a3; text-align: center; font-size: 14px; padding: 6px; }
.skel { height: 96px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 10px; border: 1px solid var(--line); }
@keyframes sk { to { background-position: -200% 0; } }
#toast { position: fixed; bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: 90vw; }

/* ---------- الشاشات الكبيرة ---------- */
@media (min-width: 900px) {
  .bar { max-width: 640px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; }
  .events-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .top { padding-inline: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
