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

:root {
  --primary: #6366f1;
  --primary-soft: #4f46e5;
  --secondary: #22c55e;
  --accent: #0ea5e9;
  --bg-light: #f9fafb;
  --bg-dark: #020617;
  --text-light: #0f172a;
  --text-dark: #e5e7eb;
  --card-light: #ffffff;
  --card-dark: #020617;
  --border-light: #e2e8f0;
  --border-dark: #1e293b;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.18);
  --radius-xl: 20px;
  --radius-full: 999px;
  --transition-fast: 0.2s ease;
  --transition-slow: 0.4s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #eef2ff, #f9fafb 55%);
  color: var(--text-light);
  transition: background var(--transition-slow), color var(--transition-slow);
  position: relative;
  overflow-x: hidden;
}

/* Arabic font */
body.ar {
  font-family: "Cairo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Dark theme */
body.dark {
  background: radial-gradient(circle at top, #020617, #020617 55%);
  color: var(--text-dark);
}

/* Animated background blobs */
body::before,
body::after {
  content: "";
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.35), transparent 60%);
  filter: blur(4px);
  opacity: 0.7;
  z-index: -2;
  animation: blob-move 22s ease-in-out infinite alternate;
}
body::after {
  background: radial-gradient(circle at 30% 30%, rgba(34, 197, 94, 0.32), transparent 60%);
  animation-duration: 26s;
}

@keyframes blob-move {
  0% {
    top: -160px;
    right: -100px;
    transform: translate3d(0, 0, 0);
  }
  50% {
    top: 40%;
    right: -150px;
    transform: translate3d(-60px, 40px, 0);
  }
  100% {
    top: 70%;
    right: 10%;
    transform: translate3d(40px, -40px, 0);
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6366f1, #22c55e);
  border-radius: 999px;
}

/* Containers & layout */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.section {
  padding: 6rem 0;
}

.section-title {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.section-title::after {
  content: "";
  width: 62px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.section-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #4b5563;
}

body.dark .section-text {
  color: #cbd5f5;
}

/* Cards */
.card {
  background: var(--card-light);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.7rem;
  border: 1px solid var(--border-light);
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.09);
  backdrop-filter: blur(18px);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 0% 0%, rgba(148, 163, 253, 0.22), transparent 55%);
  opacity: 0;
  transition: opacity var(--transition-slow);
  pointer-events: none;
}

.card:hover::before {
  opacity: 1;
}

.card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.16);
}

body.dark .card {
  background: radial-gradient(circle at top, #020617, #020617 60%);
  border-color: var(--border-dark);
  box-shadow: var(--shadow-soft);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
}

/* ========== Navbar ========== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
  background: rgba(249, 250, 251, 0.88);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

body.dark .navbar {
  background: rgba(15, 23, 42, 0.9);
  border-bottom-color: rgba(30, 64, 175, 0.75);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.brand-logo {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 1.15rem;
  background: conic-gradient(from 180deg, #22c55e, #0ea5e9, #6366f1, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f9fafb;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.6);
  position: relative;
  overflow: hidden;
}

.brand-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent 60%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.brand:hover .brand-logo::after {
  opacity: 1;
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.brand-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.brand-sub {
  font-size: 0.7rem;
  color: #6b7280;
}

body.dark .brand-sub {
  color: #9ca3af;
}

/* Nav links */
.nav-links {
  display: none;
  gap: 1rem;
  font-size: 0.8rem;
}

.nav-link {
  border: none;
  background: none;
  padding: 0;
  color: #4b5563;
  cursor: pointer;
  font-weight: 500;
  position: relative;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.35rem;
  height: 2px;
  border-radius: 999px;
  transform: scaleX(0);
  transform-origin: center;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: transform var(--transition-fast);
}

.nav-link:hover::after {
  transform: scaleX(1);
}

body.dark .nav-link {
  color: #e5e7eb;
}

/* Controls */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-toggle {
  display: flex;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.65);
  overflow: hidden;
}

.lang-toggle button {
  border: none;
  background: transparent;
  font-size: 0.7rem;
  padding: 0.22rem 0.5rem;
  cursor: pointer;
  color: #4b5563;
}

.lang-toggle button.active {
  background: var(--primary);
  color: #f9fafb;
}

body.dark .lang-toggle {
  border-color: rgba(148, 163, 184, 0.9);
}

.theme-toggle {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6b7280;
}

body.dark .theme-toggle {
  border-color: rgba(148, 163, 184, 0.9);
  color: #e5e7eb;
}

/* Responsive nav */
@media (min-width: 768px) {
  .nav-links {
    display: flex;
  }
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: "";
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle at 0 0, rgba(255, 255, 255, 0.7), transparent 55%);
  opacity: 0;
  transform: translate3d(-40%, -40%, 0);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.btn:hover::after {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  color: white;
  box-shadow: 0 18px 35px rgba(79, 70, 229, 0.65);
}

.btn-primary:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 22px 45px rgba(79, 70, 229, 0.8);
}

.btn-outline {
  border-color: rgba(148, 163, 184, 0.9);
  color: #111827;
  background: rgba(255, 255, 255, 0.9);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

body.dark .btn-outline {
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.9);
}

/* Secondary (green) */
.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), #16a34a);
  color: #022c22;
  border-color: transparent;
}

.btn-secondary:hover {
  filter: brightness(1.08);
}

/* ========== Hero ========== */
.hero {
  padding-top: 6.5rem;
  position: relative;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.18), transparent 60%);
  opacity: 0.8;
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr);
  gap: 2.5rem;
  align-items: center;
}

.hero-text {
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.07);
  color: var(--primary);
  font-size: 0.72rem;
  padding: 0.24rem 0.7rem;
  margin-bottom: 0.9rem;
  box-shadow: 0 8px 25px rgba(79, 70, 229, 0.18);
  animation: float-soft 4s ease-in-out infinite;
}

.hero-badge::before {
  content: "";
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 6px rgba(129, 140, 248, 0.45);
}

.hero-title {
  font-size: 2.1rem;
  line-height: 1.15;
  margin-bottom: 0.6rem;
}

.hero-subtitle {
  font-size: 0.95rem;
  color: #4b5563;
  max-width: 30rem;
  margin-bottom: 1.4rem;
  min-height: 2.2em; /* مساحة للتايبينج */
  border-right: 2px solid transparent;
}

.hero-subtitle.typing {
  border-right-color: rgba(148, 163, 184, 0.9);
  animation: caret-blink 1s step-end infinite;
}

@keyframes caret-blink {
  0%, 100% {
    border-right-color: transparent;
  }
  50% {
    border-right-color: rgba(148, 163, 184, 0.9);
  }
}

body.dark .hero-subtitle {
  color: #cbd5f5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

/* Hero visual */
.hero-visual {
  display: flex;
  justify-content: center;
}

.circle-outer {
  width: 15rem;
  height: 15rem;
  border-radius: 999px;
  background: conic-gradient(from 210deg, var(--primary), var(--accent), var(--secondary), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.55);
  position: relative;
  will-change: transform;
  transition: transform 0.22s ease-out;
}

.circle-inner {
  width: 11.5rem;
  height: 11.5rem;
  border-radius: 999px;
  background: radial-gradient(circle at top, #0f172a, #020617 70%);
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  text-align: center;
  padding: 0.5rem;
  color: #e5e7eb;
}

.circle-tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #a5b4fc;
}

.circle-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.circle-sub {
  font-size: 0.7rem;
  color: #9ca3af;
}

.circle-float {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow: 0 0 0 5px rgba(15, 23, 42, 0.4);
}

.circle-float-1 {
  width: 2.7rem;
  height: 2.7rem;
  top: -0.6rem;
  left: -0.4rem;
  animation: float-soft 3.4s ease-in-out infinite;
}

.circle-float-2 {
  width: 3.2rem;
  height: 3.2rem;
  right: -0.6rem;
  bottom: -0.7rem;
  animation: float-soft 3.8s ease-in-out infinite;
}

@keyframes float-soft {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.85;
  }
  50% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Responsive hero */
@media (min-width: 768px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  }
}

/* ========== Skills ========== */
.skills-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .skills-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.pill-list span {
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid rgba(209, 213, 219, 0.8);
  backdrop-filter: blur(10px);
}

body.dark .pill-list span {
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  border-color: #1e293b;
}

/* ========== Projects ========== */
.projects-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .projects-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.project-role {
  font-size: 0.7rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.project-desc {
  font-size: 0.8rem;
  color: #4b5563;
}

body.dark .project-desc {
  color: #cbd5f5;
}

/* ========== Experience ========== */
.experience-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .experience-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-item {
  border-left: 2px solid rgba(99, 102, 241, 0.4);
  padding-left: 0.7rem;
  position: relative;
}

.timeline-item::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--primary);
  position: absolute;
  left: -0.32rem;
  top: 0.17rem;
  box-shadow: 0 0 0 5px rgba(129, 140, 248, 0.35);
}

.timeline-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.timeline-place {
  font-size: 0.8rem;
  color: #6b7280;
}

.timeline-time {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 0.2rem;
}

.timeline-desc {
  font-size: 0.78rem;
  color: #4b5563;
  margin-top: 0.3rem;
}

body.dark .timeline-place {
  color: #9ca3af;
}
body.dark .timeline-time {
  color: #64748b;
}
body.dark .timeline-desc {
  color: #cbd5f5;
}

/* ========== Contact ========== */
.contact-grid {
  display: grid;
  gap: 1.2rem;
}

@media (min-width: 768px) {
  .contact-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  }
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 0.8rem;
  font-size: 0.8rem;
}

.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.contact-form input,
.contact-form textarea {
  border-radius: 0.8rem;
  border: 1px solid var(--border-light);
  padding: 0.45rem 0.7rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.9);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.6);
  transform: translateY(-1px);
}

body.dark .contact-form input,
body.dark .contact-form textarea {
  border-color: var(--border-dark);
  background: #020617;
  color: var(--text-dark);
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.info-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.info-item i {
  margin-top: 0.15rem;
  color: var(--primary);
}

.info-label {
  font-size: 0.75rem;
  color: #9ca3af;
}

.contact-info a {
  color: #111827;
  text-decoration: none;
  font-size: 0.8rem;
}

body.dark .contact-info a {
  color: #e5e7eb;
}

.contact-info a:hover {
  color: var(--secondary);
}

.contact-footer {
  margin-top: auto;
  font-size: 0.75rem;
  color: #9ca3af;
}

/* ========== Footer ========== */
.footer {
  padding-bottom: 2rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  font-size: 0.75rem;
  color: #9ca3af;
}

/* ========== Animations (scroll) ========== */
[data-animate] {
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

[data-animate].visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ========== RTL adjustments ========== */
html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .brand-text {
  align-items: flex-end;
}

html[dir="rtl"] .nav-inner {
  flex-direction: row-reverse;
}

html[dir="rtl"] .nav-links {
  direction: rtl;
}

html[dir="rtl"] .timeline-item {
  border-left: none;
  border-right: 2px solid rgba(99, 102, 241, 0.4);
  padding-left: 0;
  padding-right: 0.7rem;
}

html[dir="rtl"] .timeline-item::before {
  left: auto;
  right: -0.32rem;
}

/* Small screens */
@media (max-width: 640px) {
  .hero-title {
    font-size: 1.6rem;
  }
  .section {
    padding: 4.2rem 0;
  }
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}
