:root {
  --bg: #050d24;
  --text: #eaf1ff;
  --muted: #9fb2d8;
  --accent: #4f8cff;
  --card-a: #14398f;
  --card-b: #081a4a;
  --line: rgba(79,140,255, .55);
  --head: "Space Grotesk", system-ui, sans-serif;
  --body: "Poppins", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  background: radial-gradient(ellipse at 50% 0, #0c2a66 0, var(--bg) 55%) fixed, var(--bg);
  color: var(--text); font: 300 16px/1.6 var(--body);
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.accent { color: var(--accent); }
section { padding: 5rem 1.25rem; max-width: 1100px; margin: 0 auto; }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 500; line-height: 1.15; }

/* header */
.nav { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  padding: .9rem 1.5rem; background: rgba(5,13,36, .7); backdrop-filter: blur(10px); }
.logo { font: 700 1.6rem var(--head); }
.nav nav { display: flex; align-items: center; gap: 2rem; font-size: .9rem; }
.lang { font: inherit; color: var(--accent); background: none; border: 1px solid var(--line); border-radius: 6px; padding: .15rem .7rem; cursor: pointer; }
.lang:hover { background: var(--accent); color: var(--bg); }
.nav nav a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* hero */
.hero { display: flex; align-items: center; justify-content: center; gap: 2.5rem; padding-top: 4rem; flex-wrap: wrap; }
.avatar { width: 220px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  font: 700 4rem var(--head); color: var(--text);
  background: radial-gradient(circle at 50% 40%, #2f6bff, #0c2a66 70%); box-shadow: 0 0 90px 20px rgba(47,107,255, .45); }
.eyebrow { font-size: .8rem; letter-spacing: .02em; }
.small { font-size: .8rem; color: var(--muted); }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin: .4rem 0; }

.about { text-align: center; }
.typed { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.caret { display: inline-block; width: 2px; height: 1em; margin-inline-start: 4px; vertical-align: -.1em; background: var(--text); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.sub { color: var(--muted); font-size: .9rem; margin: .5rem 0 1.5rem; }
.bio { font-size: .9rem; color: var(--muted); }

/* section titles + cards */
.section-title { font-size: 1.1rem; margin-bottom: 1.5rem; font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.card { display: flex; align-items: center; gap: 1.5rem; padding: 1.75rem; border-radius: 14px;
  background: radial-gradient(circle at 20% 50%, rgba(47,107,255, .45), transparent 60%), linear-gradient(135deg, var(--card-a), var(--card-b));
  border-top: 1px solid var(--line); transition: transform .25s; }
.card:hover { transform: translateY(-4px); }
.card h4 { font-size: 1.4rem; }
.card p { font-size: .75rem; color: var(--muted); margin: .4rem 0 1rem; }
.btn { display: inline-block; padding: .3rem 1rem; border: 1px solid var(--line); border-radius: 6px; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.btn:hover { background: var(--accent); color: var(--bg); }
.orb { flex: none; width: 84px; height: 84px; border-radius: 50%; box-shadow: 0 12px 30px rgba(0, 0, 0, .4); }
.o1 { background: linear-gradient(135deg, #5b8cff, #1e40af); border-radius: 18px; }
.o2 { background: radial-gradient(circle at 35% 30%, #ffd1a8, #ff7ab6 60%, #3b82f6); }
.o3 { background: radial-gradient(circle at 35% 30%, #9ec5ff, #2563eb 60%, #0b2a7a); }
.o4 { background: linear-gradient(135deg, #7fb0ff, #1d4ed8); border-radius: 30% 70% 60% 40%; }

/* team + skills + orbit */
.team { text-align: center; }
.team h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
.team > p { color: var(--muted); margin-top: .4rem; }
.skills { list-style: none; padding: 0; margin: 2rem auto 0; display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; max-width: 560px; }
.skills li { padding: .35rem .9rem; border-radius: 999px; font-size: .8rem; background: rgba(79,140,255, .12); border: 1px solid rgba(79,140,255, .3); }
.orbit { position: relative; height: 260px; margin-top: 2rem; display: grid; place-items: center; }
.ring { position: absolute; border: 1px solid rgba(79,140,255, .3); border-radius: 50%; }
.r1 { width: 380px; height: 120px; } .r2 { width: 260px; height: 80px; }
.core { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font: 700 2.2rem var(--head);
  background: radial-gradient(circle, #3b82f6, #0f2f80); box-shadow: 0 0 80px 18px rgba(59,130,246, .55); }

/* featured projects */
.featured { display: grid; gap: 5rem; }
.project { position: relative; display: flex; align-items: center; }
.shot { width: 58%; aspect-ratio: 16 / 10; border-radius: 10px; margin-inline-start: auto;
  background: linear-gradient(135deg, #f3f7ff, #c3d4f2); box-shadow: 0 0 80px rgba(47,107,255, .35); overflow: hidden; }
.shot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.info { position: absolute; inset-inline-start: 0; width: 46%; padding: 1.5rem; border-radius: 12px;
  background: rgba(10,32,84, .75); backdrop-filter: blur(8px); border: 1px solid rgba(79,140,255, .25); }
.info h3 { font-size: 1.4rem; margin: .2rem 0 .6rem; }
.info p { font-size: .8rem; color: var(--muted); }
.links { display: flex; gap: 1rem; margin-top: 1rem; font-size: .8rem; }
.links a:hover { color: var(--accent); }
.flip .shot { margin-inline: 0 auto; }
.flip .info { inset-inline: auto 0; text-align: end; }
.flip .links { justify-content: flex-end; }

/* contact */
.contact p { font-size: .85rem; color: var(--muted); max-width: 520px; }
.mail { display: inline-block; margin: 1rem 0; color: var(--accent); }
.socials { display: flex; gap: 1rem; font-size: .85rem; }
.socials a:hover { color: var(--accent); }
footer { text-align: center; padding: 2rem 1rem; font-size: .75rem; color: var(--muted); }

/* ===== animations ===== */
/* Living background: three blurred glows drifting slowly behind everything */
.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; filter: blur(90px); will-change: transform; }
.aurora i:nth-child(1) { width: 46vmax; height: 46vmax; left: -12vmax; top: -12vmax; background: #1e40af; opacity: .3; animation: drift1 24s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { width: 38vmax; height: 38vmax; right: -10vmax; top: 28vh; background: #1d4ed8; opacity: .2; animation: drift2 30s ease-in-out infinite alternate; }
.aurora i:nth-child(3) { width: 34vmax; height: 34vmax; left: 22vw; bottom: -16vmax; background: #0369a1; opacity: .16; animation: drift3 36s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate3d(20vmax, 14vmax, 0) scale(1.18); } }
@keyframes drift2 { to { transform: translate3d(-22vmax, -10vmax, 0) scale(.88); } }
@keyframes drift3 { to { transform: translate3d(14vmax, -18vmax, 0) scale(1.2); } }

/* Cursor spotlight + scroll progress */
.spot { position: fixed; left: 0; top: 0; z-index: -1; width: 560px; height: 560px; margin: -280px 0 0 -280px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(79,140,255, .16), transparent 65%); opacity: 0; transition: opacity .4s; }
.progress { position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: 3px; transform: scaleX(0); transform-origin: left; pointer-events: none;
  background: linear-gradient(90deg, #2563eb, #60a5fa, #a5d8ff); box-shadow: 0 0 12px rgba(96,165,250, .7); }
[dir="rtl"] .progress { transform-origin: right; }

/* Scroll reveal (only when JS opted in via html.anim; uses the separate "translate" property so it never fights hover/tilt transforms) */
.anim .reveal { opacity: 0; translate: 0 30px; scale: .98;
  transition: opacity .9s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms), translate .9s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms), scale .9s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms); }
.anim .reveal.in { opacity: 1; translate: 0 0; scale: 1; }
.anim .card.reveal { transition: opacity .9s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms), translate .9s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms), scale .9s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms), transform .15s ease-out, box-shadow .3s; }
@media print { .reveal { opacity: 1 !important; translate: none !important; scale: none !important; } }

/* Header links: underline slides in */
.nav nav a { position: relative; }
.nav nav a::after { content: ""; position: absolute; inset-inline: 0; bottom: -4px; height: 2px; background: var(--accent); transform: scaleX(0); transition: transform .3s; }
.nav nav a:hover::after { transform: scaleX(1); }
.logo { display: inline-block; transition: transform .6s cubic-bezier(.3, 1.6, .5, 1); }
.logo:hover { transform: rotate(360deg) scale(1.15); }

/* Hero: floating avatar with a pulsing halo, shimmering accent words */
.avatar { position: relative; animation: float 6s ease-in-out infinite; }
.avatar::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid rgba(79,140,255, .55); animation: halo 3.2s ease-out infinite; }
@keyframes float { 50% { transform: translateY(-12px); } }
@keyframes halo { from { transform: scale(.96); opacity: .8; } to { transform: scale(1.35); opacity: 0; } }
.hero h1 .accent, .team h2 .accent { background: linear-gradient(90deg, var(--accent), #a5d8ff, var(--accent)); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Cards: 3D tilt (driven by JS), cursor-following highlight, floating icons, shine on buttons */
.card { position: relative; transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .15s ease-out, box-shadow .3s; }
.card:hover { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-6px); box-shadow: 0 18px 50px rgba(29,78,216, .45); }
.card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), rgba(96,165,250, .28), transparent 60%); }
.card:hover::after { opacity: 1; }
.orb { animation: float 5s ease-in-out infinite; }
.card:nth-child(2) .orb { animation-delay: -1.2s; } .card:nth-child(3) .orb { animation-delay: -2.4s; } .card:nth-child(4) .orb { animation-delay: -3.6s; }
.btn { position: relative; overflow: hidden; transition: background .25s, color .25s, transform .2s; }
.btn:hover { transform: translateY(-2px); }
.btn::before { content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; transform: skewX(-20deg); background: rgba(255, 255, 255, .35); transition: left .5s; }
.btn:hover::before { left: 130%; }

/* Skill chips pop and glow */
.skills li { transition: transform .25s cubic-bezier(.3, 1.6, .5, 1), background .25s, box-shadow .25s; cursor: default; }
.skills li:hover { transform: translateY(-5px) scale(1.08); background: rgba(79,140,255, .3); box-shadow: 0 8px 24px rgba(37,99,235, .5); }

/* Orbit: glowing satellites travel around the rings, the core breathes */
.ring .dot { position: absolute; top: 0; left: 0; width: 9px; height: 9px; border-radius: 50%; background: #dbeafe; box-shadow: 0 0 14px 4px rgba(96,165,250, .9);
  offset-rotate: 0deg; animation: orbit 9s linear infinite; }
.r1 .dot { offset-path: path("M 0 60 a 190 60 0 1 0 380 0 a 190 60 0 1 0 -380 0"); }
.r2 .dot { offset-path: path("M 0 40 a 130 40 0 1 1 260 0 a 130 40 0 1 1 -260 0"); animation-duration: 6s; animation-direction: reverse; }
@keyframes orbit { from { offset-distance: 0%; } to { offset-distance: 100%; } }
.core { animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.08); box-shadow: 0 0 110px 30px rgba(59,130,246, .75); } }

/* Featured screenshots: tilt + zoom; text card slides slightly */
.shot { transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .2s ease-out, box-shadow .3s, scale .4s; }
.project:hover .shot { scale: 1.03; box-shadow: 0 0 110px rgba(59,130,246, .55); }
.shot img { transition: transform .8s ease; }
.project:hover .shot img { transform: scale(1.06); }
.info { transition: translate .4s ease, background .3s; }
.project:hover .info { translate: 8px 0; background: rgba(14,42,104, .85); }
.flip:hover .info { translate: -8px 0; }
[dir="rtl"] .project:hover .info { translate: -8px 0; } [dir="rtl"] .flip:hover .info { translate: 8px 0; }

/* Contact links */
.socials a, .mail { transition: transform .25s, color .25s; }
.socials a:hover, .mail:hover { transform: translateY(-3px); }

/* Arabic: Cairo font, no letter-spacing (it breaks joined letters) */
:lang(ar) { --head: "Cairo", system-ui, sans-serif; --body: "Cairo", system-ui, sans-serif; }
:lang(ar) .eyebrow, :lang(ar) .btn { letter-spacing: 0; }
:lang(ar) body { line-height: 1.8; }

/* mobile */
@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
  .project, .flip { flex-direction: column; }
  .shot { width: 100%; }
  .info, .flip .info { position: static; width: 100%; margin-top: -2rem; text-align: start; }
  .flip .links { justify-content: flex-start; }
  .r1 { width: 300px; } .r2 { width: 200px; }
  .aurora i { filter: blur(60px); } /* cheaper on phones */
  .r1 .dot { offset-path: path("M 0 60 a 150 60 0 1 0 300 0 a 150 60 0 1 0 -300 0"); }
  .r2 .dot { offset-path: path("M 0 40 a 100 40 0 1 1 200 0 a 100 40 0 1 1 -200 0"); }
  .project:hover .info, .flip:hover .info, [dir="rtl"] .project:hover .info, [dir="rtl"] .flip:hover .info { translate: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto; } }
