/* هُدهُد | Hudhud
   سمتان (هدهد، رسمي) ولكل منهما وضع داكن خاص. الألوان من وثيقة قرارات التصميم.
   الأسلوب: خطوط وطباعة كبيرة بدل البطاقات والقوائم الجانبية. */

:root,
.theme-hudhud {
    --bg: #FAF6F0; --sf: #FFFFFF; --tx: #2A211B; --mu: #6F6055;
    --ac: #A84F1C; --on: #FFFFFF; --bd: #E6DACC; --soft: #F6E7DA;
    --ok: #1B6B34; --bad: #A3281E; --ac-on-dark: #E8894A;
}
.theme-hudhud.mode-dark {
    --bg: #1C1613; --sf: #2A211C; --tx: #F3E9DF; --mu: #B8A898;
    --ac: #E8894A; --on: #1C1613; --bd: #3D3029; --soft: #3A2A20;
    --ok: #7FCB95; --bad: #F2948A; --ac-on-dark: #A84F1C;
}
.theme-official {
    --bg: #F4F6F9; --sf: #FFFFFF; --tx: #18212F; --mu: #566377;
    --ac: #1F4E8C; --on: #FFFFFF; --bd: #DCE2EA; --soft: #E4ECF7;
    --ok: #1B6B34; --bad: #A3281E; --ac-on-dark: #6FA3E8;
}
.theme-official.mode-dark {
    --bg: #0F1622; --sf: #1A2433; --tx: #E6ECF5; --mu: #9AA8BC;
    --ac: #6FA3E8; --on: #0F1622; --bd: #2A3648; --soft: #1F2F47;
    --ok: #7FCB95; --bad: #F2948A; --ac-on-dark: #1F4E8C;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: light; }
html.mode-dark { color-scheme: dark; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--tx);
    font-family: 'Tajawal', system-ui, 'Segoe UI', Tahoma, sans-serif;
    font-size: 17px;
    line-height: 1.8;
    font-variant-numeric: lining-nums tabular-nums;
}

a { color: var(--ac); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2 { margin: 0; font-weight: 800; line-height: 1.3; }
h2 { font-size: 24px; }
p { margin: 0; }

:focus-visible { outline: 3px solid var(--ac); outline-offset: 2px; border-radius: 4px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- الشريط العلوي ---------- */
.top {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px;
    padding: 24px clamp(20px, 5vw, 56px) 8px;
}
.wordmark { font-size: 28px; font-weight: 800; color: var(--tx); }
.wordmark:hover { text-decoration: none; }
.top-nav { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.top-nav a { padding: 10px 0; font-weight: 500; color: var(--mu); border-bottom: 3px solid transparent; }
.top-nav a:hover { color: var(--tx); text-decoration: none; }
.top-nav a[aria-current="page"] { color: var(--tx); border-bottom-color: var(--ac); }
.top-end { margin-inline-start: auto; }

/* ---------- الصفحة ---------- */
.page { padding: 16px clamp(20px, 5vw, 56px) 72px; max-width: 1280px; }
.narrow { max-width: 560px; }
.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 16px; padding: 12px 0 20px; border-bottom: 4px solid var(--tx); margin-bottom: 8px;
}
.display { font-size: clamp(34px, 5vw, 56px); }
.lead { color: var(--mu); font-size: 18px; max-width: 70ch; }
.note { color: var(--mu); font-size: 15px; padding-top: 20px; }
.meta { color: var(--mu); font-size: 15px; }
.hint { color: var(--mu); font-size: 14px; }

.flash {
    background: var(--soft); border-radius: 14px; padding: 12px 18px; margin: 8px 0 16px; font-weight: 500;
}
.flash-error { color: var(--bad); border: 2px solid var(--bad); background: transparent; }
.error-text { color: var(--bad); }
.ok-text { color: var(--ok); }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 52px; padding: 0 30px; border-radius: 26px;
    font: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
    border: 2px solid transparent;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--ac); color: var(--on); }
.btn-outline { background: transparent; color: var(--tx); border-color: var(--tx); }
.btn-quiet { background: transparent; color: var(--mu); border-color: var(--bd); }
button.link {
    font: inherit; color: var(--ac); background: none; border: 0; padding: 10px 0; cursor: pointer; min-height: 44px;
}
button.link:hover { text-decoration: underline; }
.round {
    width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--bd);
    background: var(--sf); color: var(--tx); font: inherit; font-size: 22px; line-height: 1; cursor: pointer;
}
.round:disabled { color: var(--bd); cursor: default; }

/* ---------- صفوف (بدل الجداول والبطاقات) ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
    padding: 14px 16px; border-bottom: 1px solid var(--bd); border-inline-start: 3px solid transparent;
}
.row-hot { border-inline-start-color: var(--ac); }
.row-main { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 19px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.row-meta { color: var(--mu); font-size: 15px; overflow-wrap: anywhere; }
.row-time { color: var(--mu); font-size: 15px; white-space: nowrap; }
.pill { font-size: 14px; padding: 1px 12px; border-radius: 999px; border: 1px solid var(--ac); color: var(--ac); }
.pill-solid { background: var(--ac); color: var(--on); }

.empty { padding: 48px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 20px; font-size: 22px; }

/* ---------- الصناديق: أعمدة متجاورة ---------- */
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 32px 16px; padding-top: 24px; }
.column { border-top: 4px solid var(--bd); padding: 14px 20px 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.column-on { border-top-color: var(--ac); }
.column-add { border-top-style: dashed; align-items: flex-start; justify-content: center; }
.column-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.status { color: var(--mu); font-size: 15px; }
.status-bad { color: var(--bad); font-weight: 700; }
.address { color: var(--mu); font-size: 15px; overflow-wrap: anywhere; text-align: start; }
.stepper { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.stepper form { display: inline-flex; }
.stepper-value { font-size: 22px; font-weight: 800; min-width: 2ch; text-align: center; }
.column-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 22px; margin-top: auto; }
.column-actions a { padding: 10px 0; }

/* ---------- النماذج ---------- */
.form { display: flex; flex-direction: column; gap: 18px; padding-top: 20px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-short { max-width: 220px; }
.field label { font-weight: 700; }
.field input {
    min-height: 52px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--bd);
    background: var(--sf); color: var(--tx); font: inherit; width: 100%;
}
.field input:focus { border-color: var(--ac); outline: none; }
.field-error { color: var(--bad); font-size: 15px; font-weight: 500; }
.field-error:empty { display: none; }
.field-error ul { margin: 0; padding: 0; list-style: none; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 8px; }

/* ---------- الإعدادات ---------- */
.block { padding: 24px 0; border-bottom: 1px solid var(--bd); display: flex; flex-direction: column; gap: 14px; }
.choices { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 40px; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
legend { padding: 0 0 6px; font-weight: 700; color: var(--mu); float: none; width: 100%; }
.choice { display: inline-flex; align-items: center; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span {
    min-height: 44px; display: inline-flex; align-items: center; padding: 0 22px;
    border-radius: 22px; border: 2px solid var(--bd); font-weight: 700;
}
.choice input:checked + span { background: var(--tx); color: var(--bg); border-color: var(--tx); }
.choice input:focus-visible + span { outline: 3px solid var(--ac); outline-offset: 2px; }
.facts { margin: 0; display: grid; grid-template-columns: minmax(140px, max-content) minmax(0, 1fr); gap: 8px 24px; }
.facts dt { color: var(--mu); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
code {
    font-family: Consolas, 'Courier New', monospace; font-size: 15px;
    background: var(--soft); border-radius: 8px; padding: 2px 8px; unicode-bidi: plaintext;
}

.form-wide { max-width: 560px; }
.kicker { color: var(--ac); font-weight: 700; font-size: 16px; }
.rule-line { height: 2px; background: var(--tx); }
.row-muted .row-title { color: var(--mu); font-weight: 500; }
a.row-main { color: inherit; }
a.row-main:hover { text-decoration: none; }
a.row-main:hover .row-title { text-decoration: underline; }
.link-quiet { color: var(--mu) !important; }

/* ---------- المدار ---------- */
.orbit-layout {
    display: grid; grid-template-columns: minmax(0, 720px) minmax(280px, 1fr);
    gap: 24px 48px; align-items: center; padding-top: 8px;
}
/* الدائرة لا تتجاوز ارتفاع الشاشة، فتُرى كاملة دون تمرير على الحاسوب. */
.orbit { position: relative; width: 100%; aspect-ratio: 1 / 1; max-width: min(720px, calc(100vh - 140px)); min-width: min(100%, 300px); margin-inline: auto; }
.ring { position: absolute; border: 1px solid var(--bd); border-radius: 50%; }
.ring-label {
    position: absolute; left: 50%; transform: translate(-50%, -50%);
    background: var(--bg); color: var(--mu); font-size: 14px; padding: 0 10px; white-space: nowrap;
}
.ring-more { color: var(--ac); }
.orbit-core {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 12.5%; min-width: 64px; aspect-ratio: 1 / 1; border-radius: 50%;
    background: var(--tx); color: var(--bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.orbit-core strong { font-size: clamp(18px, 2.4vw, 26px); font-weight: 800; }
.orbit-core span { font-size: 12px; }

/* مساحة اللمس 44 بكسل ثابتة، والنقطة المرئية داخلها أصغر. */
.dot, .swatch {
    display: inline-flex; align-items: center; justify-content: center;
}
.dot { position: absolute; width: 44px; height: 44px; transform: translate(-50%, -50%); border-radius: 50%; }
.dot > span, .swatch > span { display: block; border-radius: 50%; }
.dot-urgent > span { width: 28px; height: 28px; background: var(--ac); }
.dot-needsreply > span { width: 21px; height: 21px; background: var(--sf); border: 3px solid var(--ac); }
.dot-fyi > span { width: 13px; height: 13px; background: var(--mu); }
.dot-unsorted > span { width: 13px; height: 13px; background: var(--bg); border: 2px dashed var(--mu); }
.dot.is-selected > span { box-shadow: 0 0 0 6px var(--soft), 0 0 0 8px var(--ac); }
.dot:hover > span { box-shadow: 0 0 0 5px var(--soft); }
.dot.is-selected:hover > span { box-shadow: 0 0 0 6px var(--soft), 0 0 0 8px var(--ac); }
.swatch { width: 22px; height: 22px; }
.swatch.dot-urgent > span { width: 16px; height: 16px; }
.swatch.dot-needsreply > span { width: 14px; height: 14px; border-width: 2px; }
.swatch.dot-fyi > span, .swatch.dot-unsorted > span { width: 10px; height: 10px; }

.orbit-panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; }
.panel-top a { padding: 10px 0; }
.panel-title { font-size: clamp(28px, 3.4vw, 42px); overflow-wrap: anywhere; }
.panel-summary { font-size: 19px; overflow-wrap: anywhere; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--mu); font-size: 14px; padding-top: 10px; border-top: 1px solid var(--bd); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- الرسول ---------- */
.messenger { position: relative; min-height: calc(100vh - 170px); display: flex; flex-direction: column; gap: 24px; overflow: hidden; }
.messenger-done { justify-content: center; }
.messenger-ghost {
    position: absolute; inset-inline-end: 0; top: 40px; font-size: clamp(180px, 34vw, 420px);
    font-weight: 800; line-height: 1; color: var(--soft); pointer-events: none; user-select: none;
}
.messenger-top, .messenger-body, .messenger-foot { position: relative; }
.messenger-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.messenger-top a { padding: 10px 0; font-weight: 500; }
.crest { display: flex; align-items: flex-end; gap: 6px; }
.crest > span:not(.crest-text) { width: 6px; border-radius: 3px; background: var(--bd); }
.crest > .crest-on { background: var(--ac) !important; }
.crest-text { color: var(--mu); font-size: 15px; margin-inline-start: 8px; }
.messenger-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; max-width: 920px; }
.messenger-title { font-size: clamp(36px, 6vw, 68px); line-height: 1.25; overflow-wrap: anywhere; }
.messenger-summary { font-size: clamp(19px, 2.2vw, 24px); color: var(--mu); }
.messenger-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.btn-large { min-height: 64px; padding: 0 40px; border-radius: 32px; font-size: 21px; }

/* ---------- قراءة الرسالة ---------- */
.reader { max-width: 820px; display: flex; flex-direction: column; gap: 14px; }
.reader-back { display: flex; flex-wrap: wrap; gap: 0 24px; }
.reader-back a { padding: 10px 0; font-weight: 500; }
.reader-title { font-size: clamp(30px, 4.4vw, 46px); overflow-wrap: anywhere; }
.summary-box { background: var(--soft); border-radius: 14px; padding: 14px 18px; font-size: 18px; }
.reader-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 18px; line-height: 1.9; padding: 8px 0 12px; border-top: 1px solid var(--bd); }

/* ---------- القواعد: جمل تُقرأ كما تُقال ---------- */
.rules { padding-top: 40px; }
.rules-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; padding-bottom: 8px; }
.rule-list { list-style: none; margin: 0; padding: 0; }
.rule { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 12px 0; border-top: 1px solid var(--bd); }
.rule-number { font-size: 34px; font-weight: 800; color: var(--bd); width: 36px; line-height: 1; }
.rule-sentence { flex: 1 1 320px; min-width: 0; font-size: 19px; line-height: 2.2; }
.rule-fixed .rule-sentence { color: var(--mu); }
.term { background: var(--soft); border-radius: 10px; padding: 2px 12px; font-weight: 700; unicode-bidi: isolate; overflow-wrap: anywhere; }
.outcome { border: 2px solid var(--ac); color: var(--ac); border-radius: 10px; padding: 0 12px; font-weight: 700; white-space: nowrap; }
.arrow { color: var(--mu); padding: 0 6px; }
[dir="ltr"] .arrow { display: inline-block; transform: scaleX(-1); }
.rule-tools { display: flex; align-items: center; gap: 8px; }
.rule-tools form { display: inline-flex; }
.rule-builder {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
    padding: 18px 0 0; border-top: 4px solid var(--tx); margin-top: 8px; font-size: 18px;
}
.rule-builder select, .rule-builder input {
    min-height: 48px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--bd);
    background: var(--sf); color: var(--tx); font: inherit;
}
.rule-builder input { flex: 1 1 220px; min-width: 0; }
.rule-builder select:focus, .rule-builder input:focus { border-color: var(--ac); outline: none; }

/* ---------- بوابة الدخول وأول التشغيل ---------- */
.gate { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.gate-art {
    position: relative; overflow: hidden; background: var(--tx); color: var(--bg);
    padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: flex-end;
}
.gate-orbit {
    position: absolute; aspect-ratio: 1 / 1; height: 118%; top: -30%; inset-inline-end: -22%;
}
.gate-orbit i { position: absolute; display: block; border-radius: 50%; }
.g-ring { border: 1px solid var(--mu); opacity: 0.55; }
.g-ring-3 { inset: 4%; }
.g-ring-2 { inset: 20%; }
.g-ring-1 { inset: 35%; }
.g-core { left: 50%; top: 50%; width: 9%; height: 9%; transform: translate(-50%, -50%); background: var(--bg); }
.g-dot { transform: translate(-50%, -50%); }
.g-solid { width: 4.6%; height: 4.6%; background: var(--ac-on-dark, var(--ac)); }
.g-open { width: 3.4%; height: 3.4%; border: 3px solid var(--ac-on-dark, var(--ac)); }
.g-small { width: 1.9%; height: 1.9%; background: var(--mu); }
.gate-brand { position: relative; max-width: 30ch; }
.gate-word { font-size: clamp(72px, 11vw, 168px); font-weight: 800; line-height: 1.25; }
.gate-tagline { font-size: clamp(22px, 2.6vw, 34px); font-weight: 700; }
.gate-points { font-size: 16px; opacity: 0.72; padding-top: 14px; line-height: 2; }
.gate-form { display: flex; align-items: center; padding: clamp(24px, 6vw, 88px); }
.gate-inner { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 8px; }
.gate-title { font-size: clamp(44px, 6vw, 76px); line-height: 1.2; }
.gate-fields { gap: 22px; padding-top: 28px; }
.gate-fields .field label { font-size: 18px; }
.gate-fields .field input {
    min-height: 62px; font-size: 20px; border-radius: 0; border: 0; border-bottom: 3px solid var(--tx);
    background: transparent; padding: 0 4px;
}
.gate-fields .field input:focus { border-bottom-color: var(--ac); }
.gate-submit { width: 100%; margin-top: 10px; }

@media (max-width: 900px) {
    .gate { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
    .gate-art { min-height: 250px; }
    .gate-orbit { height: 190%; top: -70%; inset-inline-end: -30%; }
    .gate-points { display: none; }
    .gate-form { align-items: flex-start; }
    .orbit-layout { grid-template-columns: minmax(0, 1fr); }
    .orbit { max-width: min(720px, 100%); }
    .messenger { min-height: calc(100vh - 220px); }
}

@media (max-width: 560px) {
    .dot-urgent > span { width: 22px; height: 22px; }
    .dot-needsreply > span { width: 17px; height: 17px; }
    .dot-fyi > span, .dot-unsorted > span { width: 11px; height: 11px; }
    .ring-label { font-size: 12px; padding: 0 6px; }
    .btn-large { min-height: 56px; padding: 0 28px; font-size: 19px; }
    .messenger-foot .actions { width: 100%; }
    /* شريط علوي مضغوط: الاسم والخروج في سطر، والروابط في سطر واحد تحتهما. */
    .top { padding-top: 14px; gap: 0 16px; }
    .wordmark { font-size: 24px; }
    .top-end { margin-inline-start: auto; }
    .top-nav { order: 3; flex-basis: 100%; gap: 0 16px; flex-wrap: nowrap; overflow-x: auto; }
    .top-nav a { font-size: 15px; white-space: nowrap; padding: 8px 0; }
    .page { padding-top: 8px; }
    .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .facts dd { padding-bottom: 10px; }
}
