/* =====================================================
   أكاديمية إتقان البيان — ملف التنسيقات الرئيسي
   ===================================================== */

:root {
    --brand-emerald: #059669;
    --brand-emerald-dark: #047857;
    --danger: #dc2626;
}

/* الخطوط حسب اللغة */
:lang(ar) { font-family: 'Cairo', sans-serif; }
:lang(en), :lang(de) { font-family: 'Inter', sans-serif; }

html { scroll-behavior: smooth; }

/* يمنع اختفاء عناوين الأقسام خلف الشريط العلوي الثابت */
section[id] { scroll-margin-top: 5rem; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--brand-emerald);
    outline-offset: 2px;
}

/* ===================== الشعار (Logo slot) ===================== */
.logo-slot {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 3rem;
    min-width: 3rem;
    flex-shrink: 0;
}

.logo-slot-sm { height: 2.5rem; min-width: 2.5rem; }

/* الحرفان الاحتياطيان (يظهران حتى يُضاف ملف الشعار) */
.logo-fallback {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    background: var(--brand-emerald);
    color: #fff;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.logo-img { display: none; height: 100%; width: auto; max-width: 10rem; object-fit: contain; }

/* عند نجاح تحميل صورة الشعار */
.logo-slot.has-logo .logo-img { display: block; }
.logo-slot.has-logo .logo-fallback { display: none; }

/* ===================== التنقل ===================== */
.nav-link.active { color: var(--brand-emerald) !important; font-weight: 700; }

/* زر "التسجيل" في قائمة الجوال خلفيته خضراء: يبقى نصه أبيض حتى وهو نشط (وإلا يصير أخضر على أخضر) */
.nav-link.nav-cta.active { color: #fff !important; background: var(--brand-emerald-dark); }
#mobile-menu .nav-link.active:not(.nav-cta) { background: #ecfdf5; }

#mobile-menu { animation: fadeSlideDown .2s ease-out; }

/* مبدّل اللغة: زر واحد منسدل */
.lang-dropdown { position: relative; }

.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .6rem;
    border: 1px solid #e2e8f0;
    border-radius: .6rem;
    background: #f1f5f9;
    color: #475569;
    font-size: .75rem;
    font-weight: 700;
    direction: ltr;
    transition: background-color .15s ease, color .15s ease;
}

.lang-toggle:hover { background: #ecfdf5; color: var(--brand-emerald); }
.lang-icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.lang-chevron { width: .7rem; height: .7rem; flex-shrink: 0; transition: transform .15s ease; }
.lang-toggle[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }

.lang-menu {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + .4rem);
    min-width: 9rem;
    margin: 0;
    padding: .3rem;
    list-style: none;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    box-shadow: 0 10px 25px -8px rgba(15,23,42,.25);
    z-index: 60;
    animation: fadeSlideDown .15s ease-out;
}
.lang-menu[hidden] { display: none; }

.lang-btn {
    display: block;
    width: 100%;
    text-align: start;
    padding: .5rem .75rem;
    border-radius: .5rem;
    font-size: .9rem;
    font-weight: 600;
    color: #334155;
    transition: background-color .15s ease, color .15s ease;
}

.lang-btn:hover { background: #ecfdf5; color: var(--brand-emerald); }
.lang-btn.active { background: var(--brand-emerald); color: #fff; }

/* ===================== من نحن ===================== */
.about-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 2rem;
    transition: box-shadow .2s ease, transform .2s ease;
}

.about-card:hover { box-shadow: 0 10px 25px -10px rgba(15,23,42,.15); transform: translateY(-2px); }

.about-icon {
    width: 3rem;
    height: 3rem;
    border-radius: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
}

/* ===================== البطاقات والأسهم ===================== */
.arrow { display: inline-block; transition: transform .15s ease; }
[dir="ltr"] .arrow { transform: scaleX(-1); }

/* ===================== الأسئلة الشائعة ===================== */
.faq-answer { max-height: 0; overflow: hidden; transition: max-height .3s ease-out; }
.faq-item.faq-active .faq-answer { max-height: 300px; }
.faq-icon { transition: transform .25s ease; }
.faq-item.faq-active .faq-icon { transform: rotate(180deg); }

/* ===================== الاختبار ===================== */
.quiz-option {
    display: block;
    width: 100%;
    text-align: start;
    padding: .9rem 1.1rem;
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    margin-bottom: .65rem;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, transform .1s ease;
}

.quiz-option:hover:not(:disabled) { border-color: var(--brand-emerald); background: #ecfdf5; }
.quiz-option:active:not(:disabled) { transform: scale(.99); }
.quiz-option.correct { border-color: var(--brand-emerald); background: #d1fae5; }
.quiz-option.incorrect { border-color: #ef4444; background: #fee2e2; }
.quiz-option:disabled { cursor: default; }

/* ===================== نموذج التسجيل ===================== */
.form-input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: .5rem;
    padding: .75rem 1rem;
    background: #fff;
    color: #0f172a;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--brand-emerald);
    box-shadow: 0 0 0 3px rgba(16,185,129,.25);
}

.form-input.input-invalid { border-color: var(--danger); background: #fef2f2; }
.form-input.input-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.2); }

/* قائمة رمز البلد: عرض ثابت حتى لا تضغط حقل الرقم */
.phone-country { width: 11rem; flex-shrink: 0; }

@media (max-width: 420px) {
    .phone-country { width: 8.5rem; padding-inline: .5rem; }
}

.field-error { color: var(--danger); font-size: .8rem; margin-top: .4rem; }
.field-error[hidden] { display: none; }
.form-error { background: #fef2f2; border: 1px solid #fecaca; border-radius: .5rem; padding: .6rem .9rem; font-size: .9rem; }

/* حقل الفخ للروبوتات */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ===================== شروط الخصوصية (أكورديون) ===================== */
.policy-link {
    display: inline;
    padding: 0;
    background: none;
    border: 0;
    font: inherit;
    font-weight: 700;
    color: var(--brand-emerald);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.policy-link::after {
    content: "\25BE";
    display: inline-block;
    margin-inline-start: .25rem;
    font-size: .8em;
    transition: transform .2s ease;
}
.policy-link[aria-expanded="true"]::after { transform: rotate(180deg); }
.policy-link:hover { color: var(--brand-emerald-dark); }
.policy-link--footer { color: #34d399; }
.policy-link--footer:hover { color: #6ee7b7; }
.policy-sep { margin-inline: .5rem; }

/* اللوحة: تنفتح بحركة سلسة، ولا يمكن الوصول لمحتواها بالتبويب وهي مغلقة */
.policy-panel {
    display: grid;
    grid-template-rows: 0fr;
    visibility: hidden;
    transition: grid-template-rows .3s ease-out, visibility 0s linear .3s;
}
.policy-panel.open {
    grid-template-rows: 1fr;
    visibility: visible;
    transition: grid-template-rows .3s ease-out, visibility 0s;
}
.policy-panel-inner { min-height: 0; overflow: hidden; }

.policy-content {
    margin-top: .75rem;
    max-height: 16rem;
    overflow-y: auto;
    padding: 1rem 1.1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    color: #334155;
    font-size: .9rem;
    line-height: 1.8;
    text-align: start;
}
.policy-content h4 { font-weight: 700; color: #0f172a; margin: .9rem 0 .25rem; }
.policy-content h4:first-child { margin-top: 0; }
.policy-content p { margin: 0 0 .6rem; }
.policy-content ul { list-style: disc; padding-inline-start: 1.25rem; margin: 0 0 .6rem; }
.policy-panel--footer .policy-content { background: #0f172a; border-color: #1e293b; color: #cbd5e1; }
.policy-panel--footer .policy-content h4 { color: #fff; }

/* مربع الموافقة الإجباري في النموذج */
.consent-row { display: flex; align-items: flex-start; gap: .65rem; font-size: .9rem; color: #334155; line-height: 1.7; }
.consent-box { width: 1.15rem; height: 1.15rem; margin-top: .3rem; flex-shrink: 0; accent-color: var(--brand-emerald); cursor: pointer; }
.consent-box.input-invalid { outline: 2px solid var(--danger); outline-offset: 2px; }

/* ===================== زر العودة للأعلى ===================== */
#scroll-top-btn { display: none; }
#scroll-top-btn.visible { display: flex; animation: fadeSlideUp .2s ease-out; }

/* ===================== التذييل: منع قصّ النصوص الطويلة (البريد…) ===================== */
footer .grid > * { min-width: 0; }
footer li, footer a { overflow-wrap: anywhere; }

/* ===================== حركات ===================== */
@keyframes fadeSlideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeSlideUp   { from { opacity: 0; transform: translateY(8px); }  to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
    nav, #scroll-top-btn, #register form, .cookie-banner { display: none; }
}


/* ===================== شريط ملفات تعريف الارتباط ===================== */
.cookie-banner {
    position: fixed;
    inset-inline: 1rem;
    bottom: 1rem;
    z-index: 9999;
    max-width: 40rem;
    margin-inline: auto;
    padding: 1rem 1.25rem;
    background: #0f172a;
    color: #fff;
    text-align: center;
    border-radius: .75rem;
    box-shadow: 0 10px 25px rgba(0,0,0,.35);
    font-size: .9rem;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0 0 .75rem; }
.cookie-actions { display: flex; justify-content: center; gap: .6rem; flex-wrap: wrap; }
.cookie-btn { padding: .5rem 1.5rem; border-radius: .5rem; font-weight: 700; cursor: pointer; border: 1px solid transparent; transition: background-color .15s ease; }
.cookie-btn-accept { background: var(--brand-emerald); color: #fff; }
.cookie-btn-accept:hover { background: var(--brand-emerald-dark); }
.cookie-btn-decline { background: transparent; color: #fff; border-color: #64748b; }
.cookie-btn-decline:hover { background: #1e293b; }
.cookie-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ===================== الجوال: منع خروج عناصر شريط التنقل ===================== */
@media (max-width: 400px) {
    .lang-toggle { padding: .4rem .45rem; gap: .25rem; }
}

/* ===================== الجوال: شريط تنقل أقل ارتفاعاً (الشعار والمحتويات بحجمها نفسه) ===================== */
@media (max-width: 639px) {
    nav .nav-bar { height: 3.75rem; }      /* بدلاً من 5rem؛ الشعار 3rem فيبقى بحجمه الكامل */
    section[id] { scroll-margin-top: 4.25rem; }
}

/* ===================== الخريطة: دبوس الأكاديمية فوق خريطة جوجل ===================== */
.map-frame-static { pointer-events: none; }

/* رابط شفاف يغطي الخريطة ويفتح خرائط جوجل؛ يُترك الشريط السفلي حراً ليبقى شعار جوجل وروابطه ظاهرة */
.map-hit { position: absolute; inset: 0 0 2rem 0; display: none; z-index: 2; cursor: pointer; }
.map-hit.ready { display: block; }

.map-pin {
    position: absolute;
    display: none;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, -100%);   /* رأس الدبوس السفلي هو نقطة الإحداثيات */
    z-index: 3;
    pointer-events: none;
}
.map-pin.ready { display: flex; }
.map-pin-label {
    max-width: 150px;
    margin-bottom: .2rem;
    padding: .2rem .5rem;
    background: #fff;
    color: #0f172a;
    border-radius: .4rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}
.map-pin-name { display: block; }
.map-pin-rating { display: block; margin-top: .1rem; font-size: .7rem; font-weight: 600; color: #475569; }
.map-pin-rating[hidden] { display: none; }
.map-star { color: #d97706; }
.map-pin svg { width: 1.6rem; height: 2.1rem; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
