/* ===== الألوان: الوضع الفاتح ===== */
:root {
  --paper: #F3F6F5;
  --ink: #10272B;
  --muted: #4B6266;
  --rule: #CFDBD8;
  --accent: #8A5808;
  --hero-bg: #0E3B43;
  --hero-ink: #F4EFE4;
  --hero-muted: #B9CCCB;
  --hero-light: #E2B55C;
  --focus: #C47A00;

  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Amiri", "Traditional Arabic", serif;
  --measure: 40rem;
}

/* ===== الوضع الداكن ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1A1C;
    --ink: #E4ECEA;
    --muted: #9DB2B0;
    --rule: #26393C;
    --accent: #E2B55C;
    --hero-bg: #12333A;
    --focus: #F0C36A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0D1A1C;
  --ink: #E4ECEA;
  --muted: #9DB2B0;
  --rule: #26393C;
  --accent: #E2B55C;
  --hero-bg: #12333A;
  --focus: #F0C36A;
  color-scheme: dark;
}

/* ===== الأساس ===== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.9;
}

a { color: var(--accent); text-underline-offset: 0.3em; }
a:hover { text-decoration-thickness: 2px; }

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

.wrap {
  max-width: 60rem;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* رابط التخطي: يظهر عند الوصول إليه بلوحة المفاتيح */
.skip {
  position: absolute;
  inset-inline-start: 16px;
  top: -4rem;
  z-index: 10;
  background: var(--hero-light);
  color: #10272B;
  padding: 0.5rem 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
}
.skip:focus { top: 0.75rem; }

/* ===== الترويسة: قائمة الصفحات وأقسام الصفحة ===== */
.site-head { background: var(--hero-bg); color: var(--hero-ink); }
.site-head__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.75rem;
  padding-block: 1rem;
}
.site-head ul { margin: 0; padding: 0; list-style: none; }

.site-menu { position: relative; }
.site-menu__btn {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--hero-ink);
  background: transparent;
  border: 1px solid var(--hero-muted);
  border-radius: 6px;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
}
.site-menu__btn::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin-inline-start: 0.55em;
  border-inline-end: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.2em) rotate(45deg);
}
.site-menu__btn[aria-expanded="true"]::after { transform: translateY(0.1em) rotate(-135deg); }
.site-menu__btn:hover { border-color: var(--hero-ink); }

.site-menu__list {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 0.5rem);
  z-index: 20;
  min-width: 12rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 39, 43, 0.18);
  padding-block: 0.4rem;
}
.site-menu__list a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--ink);
  text-decoration: none;
}
.site-menu__list a:hover { background: var(--rule); }
.site-menu__list a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
  border-inline-start: 3px solid var(--accent);
}

.page-sections ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.page-sections a {
  color: var(--hero-muted);
  text-decoration: none;
  font-size: 1rem;
}
.page-sections a:hover { color: var(--hero-ink); text-decoration: underline; }

/* ===== الواجهة: الاسم والعبارة ===== */
.hero {
  background: var(--hero-bg);
  color: var(--hero-ink);
  padding-block: 3rem 4.5rem;
}
.hero__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.75rem, 8vw, 4.75rem);
  line-height: 1.3;
}
.motto { margin: 2.5rem 0 0; }
.motto blockquote { margin: 0; }
.motto p {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4.2vw, 2.6rem);
  line-height: 1.75;
}
.motto span {
  display: block;
  text-wrap: balance;
  padding-inline-start: calc(var(--i) * 2.25rem);
  animation: glow-in 900ms ease-out both;
  animation-delay: calc(250ms + var(--i) * 350ms);
}
.motto .motto__lead {
  color: var(--hero-light);
  font-size: 0.75em;
  margin-bottom: 0.25rem;
}
@keyframes glow-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== المحتوى ===== */
.content { padding-block: 1rem 4rem; }
.content > p,
.content > ul,
.content > ol { max-width: var(--measure); }

h1, h2, h3 { line-height: 1.5; text-wrap: balance; }

.content h2 {
  margin: 3.5rem 0 1rem;
  font-size: 1.6rem;
  font-weight: 600;
}
.content h2::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-bottom: 0.75rem;
  background: var(--accent);
}
.content h3 { margin: 0 0 0.5rem; font-size: 1.15rem; font-weight: 600; }

/* ===== المسيرة: خط زمني ===== */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-inline-start: 2px solid var(--rule);
}
.timeline li {
  position: relative;
  padding-inline-start: 1.75rem;
  padding-bottom: 1.5rem;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: -7px;
  top: 0.55em;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
}
.timeline strong {
  display: block;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ===== المهارات ===== */
.skills { display: grid; gap: 2rem; }
@media (min-width: 52rem) {
  .skills { grid-template-columns: repeat(3, 1fr); }
}
.skills > div { border-top: 3px solid var(--accent); padding-top: 1rem; }
.skills ul { margin: 0; padding-inline-start: 1.25rem; }
.skills li { margin-bottom: 0.35rem; }
.skills li::marker { color: var(--muted); }

/* ===== التواصل ===== */
.contact { list-style: none; margin: 0; padding: 0; }
.contact li { border-bottom: 1px solid var(--rule); }
.contact li:first-child { border-top: 1px solid var(--rule); }
.contact a {
  display: block;
  padding-block: 0.85rem;
  color: var(--ink);
  text-decoration: none;
}
.contact a:hover { color: var(--accent); }
.contact bdi { unicode-bidi: isolate; }

/* ===== الروابط المفيدة ===== */
.links-group { max-width: var(--measure); }
.links-group ul { list-style: none; margin: 0; padding: 0; }
.links-group li { padding-block: 0.75rem; border-bottom: 1px solid var(--rule); }
.links-group li p { margin: 0.15rem 0 0; color: var(--muted); font-size: 1rem; }

/* ===== الشروحات ===== */
.post-list { list-style: none; margin: 0; padding: 0; max-width: var(--measure); }
.post-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1rem;
  padding-block: 0.85rem;
  border-bottom: 1px solid var(--rule);
}
.post-list time, .post__meta { color: var(--muted); font-size: 1rem; }

.post__head h1 {
  margin: 2.5rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.75rem);
}
.post__meta { margin-top: 0.25rem; }
.post > :not(.post__head) { max-width: var(--measure); }
.post pre, .post code { direction: ltr; text-align: left; font-size: 0.95rem; }
.post pre { overflow-x: auto; padding: 1rem; background: var(--rule); border-radius: 6px; }
.post img { max-width: 100%; height: auto; }
.post table { border-collapse: collapse; }
.post th, .post td { border: 1px solid var(--rule); padding: 0.4rem 0.75rem; }
.post__back { margin-top: 3rem; }

/* ===== التذييل ===== */
.site-foot {
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 1rem;
  padding-block: 1.5rem;
}
.site-foot p { margin: 0; }

/* ===== الشاشات الصغيرة والحركة ===== */
@media (max-width: 40rem) {
  .motto span { padding-inline-start: 0; }
  .hero { padding-block: 2rem 3rem; }
}
@media (prefers-reduced-motion: reduce) {
  .motto span { animation: none; }
}
