/* ============================================================
   أكاديمية حمد بن سعيدان — الهوية البصرية
   الألوان الرسمية (دليل الهوية 2022): أخضر #115B3E · ذهبي #E3B65B · ذهبي فاتح #F1CD79
   ============================================================ */

:root {
  --navy: #115B3E;          /* الأخضر الرسمي (اسم المتغيّر تاريخي) */
  --navy-light: #1B7A54;
  --navy-deep: #0B3F2B;
  --gold: #E3B65B;
  --gold-light: #F1CD79;
  --gold-dark: #A67C2E;
  --sand: #F7F3EA;
  --stone: #6B7280;
  --green: #2F7D5B;
}

html { scroll-behavior: smooth; }
/* خط الهوية الرسمي Expo Arabic إن كان مثبتًا محليًا، وإلا بدائل ويب قريبة */
@font-face { font-family: "Expo Arabic"; src: local("Expo Arabic"), local("ExpoArabic-Book"), local("ExpoArabic"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Expo Arabic"; src: local("Expo Arabic Medium"), local("ExpoArabic-Medium"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Expo Arabic"; src: local("Expo Arabic SemiBold"), local("ExpoArabic-SemiBold"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Expo Arabic"; src: local("Expo Arabic Bold"), local("ExpoArabic-Bold"); font-weight: 800 900; font-display: swap; }
body { font-family: "Expo Arabic", "IBM Plex Sans Arabic", "Almarai", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, .font-tajawal { font-family: "Expo Arabic", "Almarai", sans-serif; letter-spacing: -0.005em; }
.font-plex { font-family: "Expo Arabic", "IBM Plex Sans Arabic", "Almarai", sans-serif; }

/* ---------- Navbar ---------- */
.nav-link {
  display: inline-flex; align-items: center;
  padding: .5rem .85rem; border-radius: .75rem;
  color: rgba(255,255,255,.85); transition: all .2s;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link-active { background: rgba(227,182,91,.18); color: #fff; box-shadow: inset 0 -2px 0 var(--gold); }

/* ---------- Patterns ---------- */
.hero-pattern {
  background-image:
    linear-gradient(30deg, var(--gold) 12%, transparent 12.5%, transparent 87%, var(--gold) 87.5%, var(--gold)),
    linear-gradient(150deg, var(--gold) 12%, transparent 12.5%, transparent 87%, var(--gold) 87.5%, var(--gold)),
    linear-gradient(30deg, var(--gold) 12%, transparent 12.5%, transparent 87%, var(--gold) 87.5%, var(--gold)),
    linear-gradient(150deg, var(--gold) 12%, transparent 12.5%, transparent 87%, var(--gold) 87.5%, var(--gold)),
    linear-gradient(60deg, rgba(227,182,91,.6) 25%, transparent 25.5%, transparent 75%, rgba(227,182,91,.6) 75%, rgba(227,182,91,.6));
  background-size: 60px 105px;
  background-position: 0 0, 0 0, 30px 52px, 30px 52px, 0 0;
}

/* ---------- Buttons ---------- */
.btn-gold, .btn-navy, .btn-outline, .btn-outline-light, .btn-green, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; padding: .7rem 1.4rem; border-radius: .9rem;
  transition: all .2s; cursor: pointer; white-space: nowrap; line-height: 1.2;
  font-family: "Expo Arabic", "Almarai", sans-serif; border: 2px solid transparent;
}
.btn-gold { background: linear-gradient(135deg, var(--gold-light), var(--gold) 60%, #CFA047); color: var(--navy-deep); box-shadow: 0 6px 18px -6px rgba(227,182,91,.7); }
.btn-gold:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-light); }
.btn-outline { background: #fff; color: var(--navy); border-color: #D3E6DC; }
.btn-outline:hover { border-color: var(--gold); color: var(--gold-dark); }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.btn-outline-light:hover { border-color: var(--gold); color: var(--gold); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--navy-light); }
.btn-danger { background: #fff; color: #B91C1C; border-color: #FECACA; }
.btn-danger:hover { background: #FEF2F2; }
button:disabled, .btn-gold:disabled, .btn-navy:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* ---------- Form ---------- */
.input-field {
  width: 100%; border: 2px solid #E5E7EB; border-radius: .9rem;
  padding: .7rem 1rem; background: #fff; outline: none; transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.input-field:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(227,182,91,.18); }
select.input-field { appearance: none; }
textarea.input-field { min-height: 90px; resize: vertical; }

/* ---------- Cards & tiles ---------- */
.stat-tile { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 1.2rem; padding: 1.1rem; text-align: center; }
.dept-chip { display: inline-flex; align-items: center; background: var(--sand); color: var(--navy); border: 1px solid #EADFCB; font-weight: 800; font-size: .9rem; padding: .55rem 1.1rem; border-radius: 999px; }
.unit-preview { background: #fff; border: 1px solid #EADFCB; border-radius: 1.25rem; padding: 1.25rem; display: flex; gap: 1rem; align-items: flex-start; transition: all .2s; }
.unit-preview:hover { box-shadow: 0 12px 28px -14px rgba(17,91,62,.35); transform: translateY(-2px); border-color: var(--gold); }
.card { background: #fff; border: 1px solid #EADFCB; border-radius: 1.25rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.kpi-card { background: #fff; border: 1px solid #EADFCB; border-radius: 1.25rem; padding: 1.25rem; position: relative; overflow: hidden; }
.kpi-card::after { content: ""; position: absolute; inset-inline-end: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: rgba(227,182,91,.12); }

/* ---------- Dept radio cards ---------- */
.dept-card { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border: 2px solid #E5E7EB; border-radius: 1rem; cursor: pointer; transition: all .2s; background: #fff; }
.dept-card:hover { border-color: #DCC47C; }
.dept-card input { position: absolute; opacity: 0; pointer-events: none; }
.dept-card.selected { border-color: var(--gold); background: #FDF8EC; box-shadow: 0 0 0 4px rgba(227,182,91,.15); }
.dept-card .dept-icon { width: 38px; height: 38px; border-radius: .75rem; background: var(--navy); color: var(--gold); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ---------- Unit cards in course ---------- */
.unit-card { background: #fff; border: 1px solid #EADFCB; border-radius: 1.25rem; padding: 1.25rem; transition: all .2s; position: relative; }
.unit-card.done { border-color: #CFE5DA; background: linear-gradient(180deg, #fff, #F3FAF6); }
.unit-card.locked { opacity: .6; }
.unit-card.active { border-color: var(--gold); box-shadow: 0 10px 30px -14px rgba(227,182,91,.6); }
.unit-card.active:hover { transform: translateY(-2px); }

/* ---------- Progress ---------- */
.progress-track { height: 10px; background: #EADFCB; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold-dark), var(--gold)); border-radius: 999px; transition: width .6s ease; }

/* ---------- Prompt boxes ---------- */
.prompt-box { background: var(--navy-deep); color: #F7F3EA; border-radius: 1rem; padding: 1rem 1.1rem; position: relative; }
.prompt-box pre { white-space: pre-wrap; font-family: "Almarai", sans-serif; font-size: .95rem; line-height: 1.8; margin: 0; }
.prompt-box .copy-btn { position: absolute; top: .6rem; inset-inline-start: .6rem; background: rgba(227,182,91,.2); color: var(--gold); border: 1px solid rgba(227,182,91,.4); border-radius: .5rem; font-size: .75rem; padding: .25rem .6rem; cursor: pointer; }
.prompt-box .copy-btn:hover { background: rgba(227,182,91,.35); }

/* ---------- Quiz ---------- */
.quiz-option { display: flex; align-items: flex-start; gap: .75rem; padding: .85rem 1rem; border: 2px solid #E5E7EB; border-radius: 1rem; cursor: pointer; transition: all .15s; background: #fff; }
.quiz-option:hover { border-color: #DCC47C; background: #FBF7EC; }
.quiz-option.selected { border-color: var(--navy); background: #EEF6F2; }
.quiz-option input { margin-top: .3rem; accent-color: var(--navy); }

/* ---------- Star rating ---------- */
.star-rating { display: inline-flex; flex-direction: row-reverse; gap: .25rem; }
.star-rating input { display: none; }
.star-rating label { font-size: 1.7rem; color: #D3E6DC; cursor: pointer; transition: transform .1s, color .1s; }
.star-rating label:hover, .star-rating label:hover ~ label, .star-rating input:checked ~ label { color: var(--gold); }
.star-rating label:hover { transform: scale(1.15); }

/* ---------- Toasts ---------- */
.toast { min-width: 240px; max-width: 360px; padding: .8rem 1rem; border-radius: 1rem; color: #fff; font-weight: 700; font-size: .9rem; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); animation: toast-in .3s ease; display: flex; align-items: center; gap: .6rem; }
.toast-success { background: var(--green); }
.toast-error { background: #B91C1C; }
.toast-info { background: var(--navy); border: 1px solid var(--gold); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Animations ---------- */
@keyframes bounce-in { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
.animate-bounce-in { animation: bounce-in .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.animate-fade-up { animation: fade-up .35s ease; }
.confetti-piece { position: fixed; top: -10px; width: 10px; height: 14px; z-index: 70; pointer-events: none; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

/* ---------- Tables ---------- */
.data-table { width: 100%; font-size: .85rem; border-collapse: separate; border-spacing: 0; }
.data-table th { background: var(--navy); color: #fff; font-weight: 800; padding: .7rem .8rem; text-align: right; white-space: nowrap; font-family: "Expo Arabic", "Almarai", sans-serif; }
.data-table th:first-child { border-start-end-radius: .75rem; }
.data-table th:last-child { border-start-start-radius: .75rem; }
.data-table td { padding: .65rem .8rem; border-bottom: 1px solid #F1EBDD; vertical-align: middle; }
.data-table tbody tr:hover td { background: #FBF9F4; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.badge-gold { background: #FAEFD2; color: var(--gold-dark); }
.badge-green { background: #CFE5DA; color: #256548; }
.badge-navy { background: #D3E6DC; color: var(--navy); }
.badge-gray { background: #F3F4F6; color: #4B5563; }
.badge-red { background: #FEE2E2; color: #B91C1C; }

/* ---------- Certificate ---------- */
#cert-print-area { font-family: "Amiri", "Almarai", serif; }
.cert-frame { position: relative; background: #fff; }
.cert-border-outer { position: absolute; inset: 14px; border: 3px solid var(--navy); border-radius: 6px; pointer-events: none; }
.cert-border-inner { position: absolute; inset: 22px; border: 1.5px solid var(--gold); border-radius: 4px; pointer-events: none; }
.cert-corner { position: absolute; width: 60px; height: 60px; border-color: var(--gold); border-style: solid; pointer-events: none; }
.cert-corner.tl { top: 30px; left: 30px; border-width: 4px 0 0 4px; }
.cert-corner.tr { top: 30px; right: 30px; border-width: 4px 4px 0 0; }
.cert-corner.bl { bottom: 30px; left: 30px; border-width: 0 0 4px 4px; }
.cert-corner.br { bottom: 30px; right: 30px; border-width: 0 4px 4px 0; }
.cert-watermark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: .04; pointer-events: none; }
.cert-watermark img { width: 55%; }

/* ---------- Print ---------- */
@media print {
  @page { size: A4 landscape; margin: 0; }
  body { background: #fff !important; }
  .print\:hidden, #site-header, #site-footer, #toasts { display: none !important; }
  main { max-width: none !important; padding: 0 !important; margin: 0 !important; }
  #cert-print-area { width: 297mm !important; height: 210mm !important; margin: 0 !important; box-shadow: none !important; border-radius: 0 !important; page-break-after: avoid; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D3E6DC; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ============================================================
   تحسينات تجربة الاستخدام (الهوية الرسمية)
   ============================================================ */
/* خلفية الهيرو: تدرّج أخضر عميق + لمعة ذهبية ناعمة */
.hero-brand {
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(241,205,121,.22), transparent 60%),
    radial-gradient(700px 380px at 5% 110%, rgba(27,122,84,.55), transparent 65%),
    linear-gradient(135deg, #0B3F2B 0%, #115B3E 55%, #0F4F36 100%);
}
.hero-mark { position: absolute; inset-inline-end: -40px; bottom: -60px; width: 420px; opacity: .06; pointer-events: none; }

/* مسار الرحلة: 4 خطوات */
.journey { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .75rem; }
.journey-step { position: relative; background: #fff; border: 1px solid #EAE3D3; border-radius: 1.1rem; padding: 1.1rem 1rem; text-align: center; transition: transform .2s, box-shadow .2s; }
.journey-step:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -18px rgba(17,91,62,.45); }
.journey-step .step-num { position: absolute; top: -12px; inset-inline-start: 50%; transform: translateX(50%); width: 26px; height: 26px; border-radius: 999px; background: var(--gold); color: var(--navy-deep); font-weight: 900; font-size: .8rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px -3px rgba(227,182,91,.7); }
.journey-step .step-icon { width: 46px; height: 46px; border-radius: .9rem; background: #EEF6F2; color: var(--navy); display: flex; align-items: center; justify-content: center; margin: .35rem auto .6rem; font-size: 1.15rem; }
.journey-step.is-done .step-icon { background: var(--navy); color: var(--gold-light); }
.journey-step.is-current { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(227,182,91,.18); }
@media (max-width: 640px) { .journey { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* شريط التقدّم اللاصق داخل صفحة الدورة */
.sticky-progress { position: sticky; top: 68px; z-index: 30; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); border: 1px solid #EAE3D3; border-radius: 1rem; padding: .7rem 1rem; box-shadow: 0 8px 24px -18px rgba(17,91,62,.4); }

/* بطاقة "استكمل من حيث توقفت" */
.resume-card { background: linear-gradient(135deg, #FDF8EC, #fff 60%); border: 1px solid #F1CD79; border-radius: 1.25rem; }

/* بطاقة وحدة أكبر ولمسة صورة */
.unit-card { overflow: hidden; }
.unit-card .unit-thumb { width: 96px; height: 72px; object-fit: cover; border-radius: .8rem; flex-shrink: 0; background: #EEF6F2; }
.unit-card .unit-thumb.is-locked { filter: grayscale(1) brightness(.85); }
.unit-card.done::after { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; top: .75rem; inset-inline-start: .75rem; width: 26px; height: 26px; border-radius: 999px; background: var(--navy); color: var(--gold-light); font-size: .8rem; display: flex; align-items: center; justify-content: center; }
.unit-card { position: relative; }

/* شارة خطوة داخل مودال الوحدة */
.step-dots { display: flex; gap: .35rem; align-items: center; }
.step-dots span { width: 8px; height: 8px; border-radius: 999px; background: rgba(255,255,255,.35); transition: all .2s; }
.step-dots span.on { width: 22px; background: var(--gold-light); }

/* تركيز الوصولية */
:focus-visible { outline: 3px solid rgba(227,182,91,.7); outline-offset: 2px; border-radius: .5rem; }
/* تخفيف الحركة */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
