/* ========== الخطوط العربية ========== */
html[dir="rtl"],
html[dir="rtl"] body,
html[dir="rtl"] * {
  font-family: 'Almarai', sans-serif;
}

/* Cyberpunk Matrix Background */
html {
    height: 100%;
}
body {
    /* الخط الأساسي يأتي من Tailwind (DM Mono) */
    background: black;
    color: #00ff00;
    overflow: hidden;
    margin: 0;
    padding: 0;
    height: 100%;
  }
  
  /* Matrix Effect */
  canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
    opacity: 0.2;
  }

/* ========== Light mode (الافتراضي: ليلي؛ .theme-light = نهاري) ========== */
html.theme-light {
  background: #f1f5f9 !important;
}
html.theme-light body {
  background: #f1f5f9 !important;
  color: #0f172a;
}
html.theme-light .rotating-border {
  --rotating-border-bg: #e2e8f0 !important;
  background-color: #e2e8f0 !important;
  background: linear-gradient(#e2e8f0, #e2e8f0) padding-box, var(--border) border-box !important;
}
/* في الوضع النهاري: الـ canvas كان خلف body (z-index:-1) فتُغطى خلفيته — نرفعه ونُشفّف main ليرى المستخدم المطر */
html.theme-light canvas {
  z-index: 1;
  opacity: 0.4;
  pointer-events: none;
}
html.theme-light main {
  background: transparent !important;
}
html.theme-light .theme-toggle {
  border-color: rgba(0,0,0,.1);
  background: rgba(0,0,0,.05);
}
html.theme-light .theme-toggle:hover {
  background: rgba(0,0,0,.1);
}
html.theme-light main .max-w-7xl {
  background: transparent;
}

/* الهيدر في الوضع النهاري */
html.theme-light header {
  color: #1e293b;
}
html.theme-light header nav a {
  color: #475569;
}
html.theme-light header nav a:hover {
  color: #0f172a;
}
html.theme-light header button {
  border-color: rgba(0,0,0,.1);
  background: rgba(0,0,0,.05);
  color: #334155;
}
html.theme-light header button:hover {
  background: rgba(0,0,0,.1);
}
html.theme-light header #mobile-menu-toggle .space-y-\[3px\] span {
  background: #475569;
}
html.theme-light header .h-10.w-10.overflow-hidden {
  border-color: rgba(0,0,0,.15);
}
html.theme-light #lang-dropdown {
  background: #f1f5f9;
  border-color: rgba(0,0,0,.1);
}
html.theme-light #lang-dropdown .lang-option {
  color: #334155;
}
html.theme-light #lang-dropdown .lang-option:hover {
  background: rgba(0,0,0,.06);
}

/* قائمة الموبايل */
html.theme-light #mobile-menu-overlay {
  background: rgba(0,0,0,.3);
}
html.theme-light #mobile-side-menu {
  background: #f8fafc;
  color: #1e293b;
  border-color: rgba(0,0,0,.08);
}
html.theme-light #mobile-side-menu nav a {
  color: #475569;
}
html.theme-light #mobile-side-menu .border-t {
  border-color: rgba(0,0,0,.08);
}

/* المحتوى داخل main: أقسام ونصوص */
html.theme-light main section {
  background-color: #e2e8f0 !important;
  background-image: none !important;
  color: #0f172a;
}
/* إلغاء أي خلفية داكنة من كلاسات Tailwind على الأقسام */
html.theme-light main section[class*="bg-"] {
  background-color: #e2e8f0 !important;
}
html.theme-light main .text-white,
html.theme-light main .text-gray-100 {
  color: #0f172a !important;
}
html.theme-light main .text-white\/90 {
  color: #334155 !important;
}
html.theme-light main .text-gray-500 {
  color: #64748b !important;
}
html.theme-light main .border-white\/10 {
  border-color: rgba(0,0,0,.1) !important;
}
html.theme-light main .bg-white\/5 {
  background-color: rgba(0,0,0,.05) !important;
}
html.theme-light main a:hover {
  border-color: rgba(196, 12, 12, 0.3);
}
/* إجبار خلفيات الهيدر في الوضع النهاري */
html.theme-light header.rotating-border {
  background-color: #e2e8f0 !important;
  --rotating-border-bg: #e2e8f0 !important;
}

/* Hero: حدود الصورة والنص */
html.theme-light main .border-2 {
  border-color: rgba(0,0,0,.12) !important;
}

/* Stats section */
html.theme-light .stats-section {
  background-color: #e2e8f0 !important;
  background-image: none !important;
  background: #e2e8f0 !important;
  border-color: rgba(0,0,0,.1) !important;
}
html.theme-light .stats-grid-pattern {
  background-image:
    linear-gradient(rgba(0,0,0,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.06) 1px, transparent 1px);
}
html.theme-light .stats-section .text-white,
html.theme-light .stats-section .text-white\/90 {
  color: #0f172a !important;
}
html.theme-light .stats-section .relative.z-10 > div {
  background-color: rgba(196, 12, 12, 0.06) !important;
}

/* قسم التعاون والمشاريع في الوضع النهاري */
html.theme-light .cooperation-projects .rounded-xl.border {
  background-color: #e2e8f0 !important;
  border-color: rgba(0,0,0,.1) !important;
}
html.theme-light .cooperation-projects .rounded-lg.bg-white\/5 {
  background-color: rgba(255,255,255,.6) !important;
  border-color: rgba(0,0,0,.1) !important;
}
html.theme-light .cooperation-projects .bg-white {
  background: #fff !important;
}
html.theme-light .cooperation-projects .text-gray-700 {
  color: #334155 !important;
}
html.theme-light .cooperation-projects .ring-offset-\[\#0f0f12\] {
  --tw-ring-offset-color: #e2e8f0;
}

/* قسم Cooperation Services في الوضع الفاتح */
html.theme-light .cooperation-services {
  background-color: #e2e8f0 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .cooperation-services .cooperation-services__card {
  background-color: #f8fafc !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .cooperation-services .text-gray-400,
html.theme-light .cooperation-services .text-gray-500 {
  color: #475569 !important;
}
html.theme-light .cooperation-services .text-white {
  color: #0f172a !important;
}
html.theme-light .cooperation-services .text-green-500 {
  color: #15803d !important;
}
html.theme-light .cooperation-services a.coop-cta-reach {
  color: #C40C0C !important;
}
/* تدرج قائمة المشاريع: نهاية التدرج بلون الخلفية في الوضع الفاتح */
html.theme-light .timeline-fade-overlay {
  background: linear-gradient(to bottom, transparent, #e2e8f0) !important;
}

/* ========== Timeline: دعم RTL/LTR ========== */
.timeline-line {
  left: 0.75rem;
}
[dir="rtl"] .timeline-line {
  left: auto;
  right: 0.75rem;
}

.timeline-list {
  padding-left: 1.5rem;
}
[dir="rtl"] .timeline-list {
  padding-left: 0;
  padding-right: 1.5rem;
}

.timeline-bullet {
  left: -1.5rem;
}
[dir="rtl"] .timeline-bullet {
  left: auto;
  right: -1.5rem;
}

.timeline-dot {
  left: 50%;
  transform: translate(-50%, -50%);
}
[dir="rtl"] .timeline-dot {
  left: auto;
  right: 0;
  transform: translate(0, -50%);
}

.timeline-date {
  min-width: 3rem;
}
[dir="rtl"] .timeline-date {
  min-width: 4rem;
  text-align: right;
}

/* قسم Contact في الوضع الفاتح: الحلقات والنص */
html.theme-light .contact-block .contact-avatar__outer-ring {
  border-color: rgba(0, 0, 0, 0.15) !important;
}
html.theme-light .contact-block .contact-avatar__inner-ring {
  border-color: rgba(0, 0, 0, 0.2) !important;
}
html.theme-light .contact-block .contact-avatar__status {
  border-color: #e2e8f0 !important;
}
html.theme-light .contact-block .contact-block__value {
  color: #be185d !important;
}
html.theme-light .contact-block [class*="flex h-8"] {
  color: #334155 !important;
}

/* ========== Experience: لوحة التفاصيل 3D واللون الرئيسي ========== */
.experience-section {
  isolation: isolate;
}
.experience-tabs {
  align-content: start;
}
.experience-tab {
  min-height: 72px;
  justify-content: flex-start;
}
.experience-tab[data-active="true"] {
  background-color: rgba(196, 12, 12, 0.1);
  box-shadow: inset 0 0 0 1px rgba(196, 12, 12, 0.2);
}
[dir="rtl"] .experience-tab {
  text-align: right;
}
.experience-panels {
  perspective: 1000px;
}
.experience-panel {
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease, visibility 0.4s;
  backface-visibility: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: perspective(1000px) rotateY(25deg) scale(0.96);
}
.experience-panel--active {
  visibility: visible;
  opacity: 1;
  transform: perspective(1000px) rotateY(0deg) scale(1);
  pointer-events: auto;
  position: relative;
  z-index: 1;
}
[dir="rtl"] .experience-panel:not(.experience-panel--active) {
  transform: perspective(1000px) rotateY(-25deg) scale(0.96);
}
@media (max-width: 639px) {
  .experience-panel__list li {
    align-items: flex-start;
  }
}

/* قسم Experience في الوضع الفاتح */
html.theme-light .experience-section {
  background-color: #e2e8f0 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .experience-section .experience-tab {
  background-color: transparent !important;
  border-color: rgba(196, 12, 12, 0.5) !important;
}
html.theme-light .experience-section .experience-tab[data-active="true"] {
  border-color: #C40C0C !important;
}
html.theme-light .experience-section .experience-panel {
  background-color: rgba(248, 250, 252, 0.95) !important;
  border-color: rgba(196, 12, 12, 0.35) !important;
}
html.theme-light .experience-section .text-gray-300,
html.theme-light .experience-section .text-gray-400,
html.theme-light .experience-section .text-gray-500 {
  color: #475569 !important;
}
html.theme-light .experience-section .text-white {
  color: #0f172a !important;
}
html.theme-light .experience-section .text-green-500 {
  color: #15803d !important;
}
html.theme-light .experience-section .experience-panel__title {
  color: #C40C0C !important;
}
html.theme-light .experience-section [data-active="true"].experience-tab {
  border-color: #C40C0C !important;
}
html.theme-light .experience-section .experience-panel span.rounded-lg {
  background-color: rgba(196, 12, 12, 0.08) !important;
  border-color: rgba(196, 12, 12, 0.35) !important;
  color: #334155 !important;
}

/* ========== Skills: أيقونات تقنيات (tabs) + لوحة مهارات 3D ========== */
.skills-panels {
  perspective: 1000px;
}
.skills-panel {
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease, visibility 0.4s;
  backface-visibility: hidden;
  visibility: hidden;
  opacity: 0;
  transform: perspective(1000px) rotateY(25deg) scale(0.96);
}
.skills-panel--active {
  visibility: visible;
  opacity: 1;
  transform: perspective(1000px) rotateY(0deg) scale(1);
  pointer-events: auto;
  position: relative;
  z-index: 1;
}
[dir="rtl"] .skills-panel:not(.skills-panel--active) {
  transform: perspective(1000px) rotateY(-25deg) scale(0.96);
}

/* Skills في الوضع الفاتح */
html.theme-light .skills-section {
  background-color: #e2e8f0 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
html.theme-light .skills-section .skills-tab {
  background-color: transparent !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}
html.theme-light .skills-section .skills-tab[data-active="true"] {
  border-color: #C40C0C !important;
}
html.theme-light .skills-section .skills-panel {
  background-color: rgba(248, 250, 252, 0.95) !important;
  border-color: rgba(196, 12, 12, 0.25) !important;
}
html.theme-light .skills-section .skills-panel__heading,
html.theme-light .skills-section .text-white {
  color: #0f172a !important;
}
html.theme-light .skills-section .text-gray-300,
html.theme-light .skills-section .text-gray-400 {
  color: #475569 !important;
}

/* الشريط الجانبي للتواصل */
html.theme-light aside.rotating-border {
  --rotating-border-bg: #e2e8f0 !important;
  background-color: #e2e8f0 !important;
}
html.theme-light aside.rotating-border a {
  background: rgba(0,0,0,.05) !important;
  color: #475569 !important;
}
html.theme-light aside.rotating-border a:hover {
  background: rgba(196, 12, 12, 0.12) !important;
  color: #C40C0C !important;
}

/* ========== الحد الدوّار (كلاس عام لأي box) ==========
   الاستخدام: أضف class="rotating-border" للعنصر.
   لا يغيّر شيئاً داخل الـ box (المحتوى، الـ padding، إلخ) إلا الحد.
   اختياري: --rotating-border-bg (لون خلفية الـ box)، --rotating-border-radius
*/
@property --angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes border-rotate-perimeter {
  0%   { --angle: 0deg; }
  100% { --angle: 360deg; }
}

.rotating-border {
  --angle: 0deg;
  --rotating-border-bg: #1b1d23;
  --rotating-border-radius: 1rem;
  border: 2px solid transparent;
  border-radius: var(--rotating-border-radius);
  background:
    linear-gradient(var(--rotating-border-bg), var(--rotating-border-bg)) padding-box,
    linear-gradient(
      var(--angle),
      #C40C0C 0%,
      #C40C0C 12%,
      rgba(196, 12, 12, 0.25) 20%,
      transparent 28%,
      transparent 100%
    ) border-box;
  animation: border-rotate-perimeter 4s linear infinite;
}

/* أيقونة Hero: دوران يميناً على محور Y مع وجهين (لا تختفي في المنتصف) */
@keyframes hero-icon-rotate-y {
  0%   { transform: translate(-50%, 50%) rotateY(0deg); }
  100% { transform: translate(-50%, 50%) rotateY(360deg); }
}

@keyframes hero-icon-rotate-y-rtl {
  0%   { transform: translate(50%, 50%) rotateY(0deg); }
  100% { transform: translate(50%, 50%) rotateY(360deg); }
}

.hero-icon-3d {
  transform-origin: center center;
  animation: hero-icon-rotate-y 4s linear infinite;
  left: 50%;
}

[dir="rtl"] .hero-icon-3d {
  left: auto;
  right: 50%;
  animation-name: hero-icon-rotate-y-rtl;
}

.hero-icon-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.hero-icon-face-back {
  transform: rotateY(180deg);
}

/* مظهر واقعي: عمق + إضاءة + توهج خفيف */
.hero-icon-text {
  color: #C40C0C;
  background: linear-gradient(180deg, #e63939 0%, #C40C0C 35%, #8b0808 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,0.15)) drop-shadow(0 4px 0 rgba(139,8,8,0.9)) drop-shadow(0 6px 12px rgba(0,0,0,0.5)) drop-shadow(0 0 20px rgba(196,12,12,0.25));
  text-shadow: none;
}

/* ========== سلايدر التقنيات ========== */
.hero-tech-slider__wrap {
  --tech-item-size: 3rem;
  --tech-gap: 0.5rem;
  width: calc(4 * var(--tech-item-size) + 3 * var(--tech-gap));
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  user-select: none;
}
@media (min-width: 640px) {
  .hero-tech-slider__wrap {
    --tech-item-size: 4rem;
    --tech-gap: 0.875rem;
  }
}
@media (min-width: 768px) {
  .hero-tech-slider__wrap {
    --tech-item-size: 5rem;
    --tech-gap: 1.5rem;
  }
}

.hero-tech-slider__track {
  display: flex;
  width: max-content;
  gap: var(--tech-gap);
  margin: 0;
  padding: 0;
  list-style: none;
  animation: hero-tech-marquee 15s linear infinite;
}

.hero-tech-slider__wrap:hover .hero-tech-slider__track {
  animation-play-state: paused;
}

[dir="rtl"] .hero-tech-slider__track,
.hero-tech-slider[dir="rtl"] .hero-tech-slider__track {
  animation-direction: reverse;
}

.hero-tech-slider__item {
  flex-shrink: 0;
  width: var(--tech-item-size);
  height: var(--tech-item-size);
}

.hero-tech-slider__box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.375rem;
}
@media (min-width: 768px) {
  .hero-tech-slider__box {
    border-radius: 0.75rem;
    padding: 1rem;
  }
}

/* حلقة متصلة: النصف الثاني مطابق للأول، -50% = نفس المنظر فلا فاصل عند إعادة التشغيل */
@keyframes hero-tech-marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes hero-tech-marquee-rtl {
  0%   { transform: translateX(0); }
  100% { transform: translateX(50%); }
}

[dir="rtl"] .hero-tech-slider__track,
.hero-tech-slider[dir="rtl"] .hero-tech-slider__track {
  animation-name: hero-tech-marquee-rtl;
  animation-direction: normal;
}

/* ========== Skills sliders (صفّين يتحركان بعكس الاتجاه) ========== */
.skills-slider__wrap {
  --skills-item-size: 3.25rem;
  --skills-gap: 0.65rem;
  width: calc(5 * var(--skills-item-size) + 4 * var(--skills-gap));
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  user-select: none;
  margin-inline: auto;
}
@media (min-width: 640px) {
  .skills-slider__wrap {
    --skills-item-size: 3.75rem;
    --skills-gap: 0.8rem;
    width: calc(6 * var(--skills-item-size) + 5 * var(--skills-gap));
  }
}
@media (min-width: 768px) {
  .skills-slider__wrap {
    --skills-item-size: 4.25rem;
    --skills-gap: 1rem;
    width: calc(7 * var(--skills-item-size) + 6 * var(--skills-gap));
  }
}
.skills-slider__track {
  display: flex;
  width: max-content;
  gap: var(--skills-gap);
  margin: 0;
  padding: 0;
  list-style: none;
  animation: hero-tech-marquee 18s linear infinite;
}
.skills-slider__track--reverse {
  animation-direction: reverse;
}
.skills-slider__wrap:hover .skills-slider__track {
  animation-play-state: paused;
}
.skills-slider__item {
  flex-shrink: 0;
  width: var(--skills-item-size);
  height: var(--skills-item-size);
}
.skills-slider__box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.5rem;
  background: transparent;
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
  position: relative;
}
.skills-slider__box:hover {
  border-color: rgba(196, 12, 12, 0.6);
  background-color: rgba(255, 255, 255, 0.03);
}
.skills-slider__box[data-skill-label]::after {
  content: attr(data-skill-label);
  position: absolute;
  inset-inline-start: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: rgba(12, 12, 14, 0.95);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  padding: 6px 10px;
  font-size: 0.75rem;
  line-height: 1.1;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
  z-index: 5;
}
.skills-slider__box[data-skill-label]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-2px);
}
@media (min-width: 768px) {
  .skills-slider__box {
    border-radius: 0.9rem;
    padding: 0.75rem;
  }
}

/* ========== سلايدر شعارات الشركات (نفس شكل وتنسيقات hero-tech-slider) ========== */
.companies-slider__wrap {
  --company-item-size: 3rem;
  --company-gap: 0.5rem;
  width: calc(4 * var(--company-item-size) + 3 * var(--company-gap));
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  user-select: none;
}
@media (min-width: 640px) {
  .companies-slider__wrap {
    --company-item-size: 4rem;
    --company-gap: 0.875rem;
  }
}
@media (min-width: 768px) {
  .companies-slider__wrap {
    --company-item-size: 5rem;
    --company-gap: 1.5rem;
  }
}

.companies-slider__track {
  display: flex;
  width: max-content;
  gap: var(--company-gap);
  margin: 0;
  padding: 0;
  list-style: none;
  animation: companies-marquee 15s linear infinite;
}

.companies-slider__wrap:hover .companies-slider__track {
  animation-play-state: paused;
}

[dir="rtl"] .companies-slider__track,
.companies-slider[dir="rtl"] .companies-slider__track {
  animation-name: companies-marquee-rtl;
  animation-direction: normal;
}

.companies-slider__item {
  flex-shrink: 0;
  width: var(--company-item-size);
  height: var(--company-item-size);
}

.companies-slider__box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.375rem;
}
@media (min-width: 768px) {
  .companies-slider__box {
    border-radius: 0.75rem;
    padding: 1rem;
  }
}

@keyframes companies-marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes companies-marquee-rtl {
  0%   { transform: translateX(0); }
  100% { transform: translateX(50%); }
}

[dir="rtl"] .companies-slider__track,
.companies-slider[dir="rtl"] .companies-slider__track {
  animation-name: companies-marquee-rtl;
  animation-direction: normal;
}

/* ========== Stats Section: شبكة خلفية (شكل الـ terminal/كود) ========== */
.stats-section {
  position: relative;
}

.stats-grid-pattern {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

.stats-icon svg {
  stroke-width: 1.5;
}
