/* ============================================================
   Royal — Portfolio  |  Dark futuristic theme
   ============================================================ */

:root {
  --bg: #06060a;
  --bg-soft: #0d0d16;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-border: rgba(255, 255, 255, 0.09);
  --text: #f3f3fb;
  --text-dim: #9a9ab0;
  --c1: #7c5cff;   /* violet */
  --c2: #16e0e0;   /* cyan   */
  --c3: #ff5cad;   /* pink   */
  --grad: linear-gradient(120deg, var(--c1), var(--c2) 55%, var(--c3));
  --radius: 18px;
  --maxw: 1180px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: "Tajawal", "Cairo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .nav__logo { font-family: "Cairo", sans-serif; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--c1); color: #fff; }

/* ---------- Background FX ---------- */
.particles {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}
.aurora {
  position: fixed;
  inset: -20%;
  z-index: -3;
  background:
    radial-gradient(40% 40% at 20% 25%, rgba(124, 92, 255, 0.22), transparent 70%),
    radial-gradient(35% 35% at 80% 20%, rgba(22, 224, 224, 0.16), transparent 70%),
    radial-gradient(45% 45% at 65% 85%, rgba(255, 92, 173, 0.16), transparent 70%);
  filter: blur(20px);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(0,-4%,0) scale(1.08); }
}

/* ---------- Loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: var(--bg);
  transition: opacity .6s var(--ease), visibility .6s;
}
.loader.hidden { opacity: 0; visibility: hidden; }
.loader__ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--c2);
  animation: spin .8s linear infinite;
}
.loader__text { color: var(--text-dim); letter-spacing: .3em; font-size: .75rem; text-transform: uppercase; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Custom cursor ---------- */
.cursor, .cursor-dot { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 9000; border-radius: 50%; }
.cursor {
  width: 38px; height: 38px; border: 1.5px solid rgba(255,255,255,0.35);
  transform: translate(-50%, -50%);
  transition: width .25s var(--ease), height .25s var(--ease), background .25s, border-color .25s;
}
.cursor-dot { width: 6px; height: 6px; background: var(--c2); transform: translate(-50%, -50%); }
.cursor.is-hover { width: 64px; height: 64px; background: rgba(124,92,255,0.12); border-color: transparent; }
@media (hover: none) { .cursor, .cursor-dot { display: none; } }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 60px);
  transition: padding .4s var(--ease), background .4s, backdrop-filter .4s, border-color .4s;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  padding: 14px clamp(20px, 5vw, 60px);
  background: rgba(6,6,10,0.6);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--surface-border);
}
.nav__logo { font-size: 1.4rem; font-weight: 800; }
.nav__logo span { color: var(--c2); }
.nav__links { display: flex; gap: 34px; }
.nav__links a { position: relative; color: var(--text-dim); font-weight: 500; transition: color .25s; }
.nav__links a::after {
  content: ""; position: absolute; inset-inline-start: 0; bottom: -6px; height: 2px; width: 0;
  background: var(--grad); transition: width .3s var(--ease);
}
.nav__links a:hover { color: var(--text); }
.nav__links a:hover::after { width: 100%; }
.nav__burger { display: none; background: none; border: 0; cursor: pointer; flex-direction: column; gap: 5px; }
.nav__burger span { width: 26px; height: 2px; background: var(--text); transition: .3s var(--ease); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 14px 28px; border-radius: 100px;
  font-weight: 600; font-size: .95rem; cursor: pointer; border: 1px solid transparent;
  transition: transform .25s var(--ease), box-shadow .3s, background .3s;
}
.btn--primary { background: var(--grad); color: #fff; background-size: 180% 180%; }
.btn--primary:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(124,92,255,0.4); }
.btn--ghost { border-color: var(--surface-border); color: var(--text); background: var(--surface); }
.btn--ghost:hover { transform: translateY(-3px); border-color: var(--c2); }

/* ---------- Layout helpers ---------- */
.section { max-width: var(--maxw); margin: 0 auto; padding: clamp(80px, 12vw, 160px) clamp(20px, 5vw, 40px); }
.section__head { text-align: center; max-width: 640px; margin: 0 auto 64px; }
.section__title { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; line-height: 1.1; }
.section__lead { color: var(--text-dim); margin-top: 16px; font-size: 1.05rem; }

.gradient-text {
  background: var(--grad); background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 6s linear infinite;
}
@keyframes shine { to { background-position: 200% center; } }

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
  max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(20px, 5vw, 40px);
  position: relative;
}
/* full-bleed: break out of the width-constrained hero to span the viewport */
.hero__bg, .hero__overlay {
  position: absolute; top: 0; height: 100%; left: 50%; width: 100vw;
  transform: translateX(-50%); pointer-events: none;
}
.hero__bg {
  object-fit: cover; z-index: 0; opacity: 0; transition: opacity 1.4s var(--ease);
}
.hero__bg.ready { opacity: 1; }
.hero__overlay { z-index: 1; opacity: 0; transition: opacity 1.4s var(--ease); }
.hero.has-video .hero__overlay {
  opacity: 1;
  background:
    linear-gradient(to bottom, rgba(6,6,10,0.55), rgba(6,6,10,0.78)),
    radial-gradient(70% 60% at 50% 45%, transparent, rgba(6,6,10,0.55));
}
.hero__inner { position: relative; z-index: 2; }
.hero__scroll { z-index: 2; }
.hero__eyebrow { color: var(--c2); letter-spacing: .25em; text-transform: uppercase; font-size: .8rem; font-weight: 600; }
.hero__title { font-size: clamp(2.6rem, 8vw, 5.6rem); font-weight: 800; line-height: 1.02; margin: 22px 0; }
.hero__title .line { display: block; }
.hero__sub { color: var(--text-dim); font-size: clamp(1rem, 2vw, 1.25rem); max-width: 540px; }
.hero__cta { display: flex; gap: 16px; margin-top: 38px; flex-wrap: wrap; }
.hero__scroll {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  color: var(--text-dim); font-size: .7rem; letter-spacing: .3em; text-transform: uppercase;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.hero__scroll span {
  width: 1px; height: 46px; background: linear-gradient(var(--c2), transparent);
  animation: scrollPulse 2s ease-in-out infinite;
}
@keyframes scrollPulse { 0%,100% { opacity: .3; transform: scaleY(.6); } 50% { opacity: 1; transform: scaleY(1); } }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 22px; }
.card {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--surface-border);
  transition: transform .4s var(--ease), border-color .4s, box-shadow .4s;
  transform-style: preserve-3d; will-change: transform;
}
.card:hover { border-color: rgba(124,92,255,0.5); box-shadow: 0 24px 60px rgba(0,0,0,0.5); }
.card__media {
  aspect-ratio: 4 / 5; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1a1330, #0d2a2e 60%, #2a1326);
}
.card__screen { display: block; width: 100%; height: 100%; }
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.card:hover .card__screen img { transform: scale(1.06); }

/* "screen assembles" reveal: hide the screen above the phone frame until the
   card enters the viewport, then drop it in. Gated behind .js so no-JS
   visitors always see the full screenshot. */
/* Screen starts lifted above the frame; a transition (not a keyframe animation)
   drops it in when .in-view is added. Using declared states + transition means
   that if motion is unavailable the screen simply jumps to the visible state. */
html.js .card__screen { transform: translateY(-101%); transition: transform 1.05s cubic-bezier(0.22, 1, 0.36, 1); }
.card.in-view .card__screen { transform: translateY(0); }
.card.in-view .card__scan { animation: scanSweep 0.95s ease-in 0.1s; }
@keyframes scanSweep { 0% { top: -25%; opacity: 0; } 25% { opacity: 0.9; } 100% { top: 120%; opacity: 0; } }
.card__media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(6,6,10,0.85), transparent 55%);
}
.card__scan {
  position: absolute; left: -5%; right: -5%; top: -25%; height: 22%;
  pointer-events: none; z-index: 2; opacity: 0;
  background: linear-gradient(to bottom, transparent, rgba(22,224,224,0.45), rgba(124,92,255,0.25), transparent);
  filter: blur(3px);
}

/* auto-scrolling real screenshot inside a phone frame = clean in-app tour */
.card__media:has(.card__device) {
  background: radial-gradient(58% 48% at 50% 44%, rgba(124,92,255,0.22), transparent 70%), #0a0a0f;
}
.card__media:has(.card__device)::after { display: none; }
.card__device {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  height: 86%; aspect-ratio: 9 / 19.5; padding: 2.4%;
  background: linear-gradient(150deg, #18181f, #070709);
  border-radius: 32px;
  box-shadow: 0 24px 55px rgba(0,0,0,0.6), 0 0 0 1.5px rgba(255,255,255,0.07), 0 0 60px rgba(124,92,255,0.18);
}
.card__screenwrap {
  position: relative; width: 100%; height: 100%;
  border-radius: 23px; overflow: hidden; background: #fff;
}
.card__island {
  position: absolute; z-index: 3; top: 3.4%; left: 50%; transform: translateX(-50%);
  width: 26%; height: 3%; min-height: 9px; background: #070709; border-radius: 20px;
}
/* override the global .card__media img height:100% so the feed keeps its tall natural height */
.card__media img.card__feed { width: 100%; height: auto; object-fit: fill; display: block; will-change: transform; }

/* looping app video that plays inside the phone screen */
.card__vid { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover .card__screen .card__vid { transform: scale(1.04); transition: transform .6s var(--ease); }

/* ===== Choreographed intro for cssMotion cards =====
   meals fly in from outside -> app powers on (glow) -> gentle cinematic tour.
   Built in CSS on the real screenshot so the Arabic UI stays pixel-perfect. */
.card--css .card__media { container-type: size; }        /* enables cq* units for meal offsets */
html.js .card--css .card__screen { transform: none; }    /* intro handles the reveal, not the drop-in */

.card--css .card__kb {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform-origin: 50% 42%; opacity: 0; will-change: transform, opacity, filter;
}
.card--css.in-view .card__kb {
  animation:
    kbFade 0.9s ease 0.15s both,
    kenburns 18s ease-in-out 0.3s infinite alternate;
}
@keyframes kbFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kenburns {
  0%   { transform: scale(1.02) translate3d(0, 0, 0); }
  100% { transform: scale(1.13) translate3d(0, -2.2%, 0); }
}

/* power-on glow flash */
.card__flash {
  position: absolute; inset: 0; z-index: 3; opacity: 0; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle at 50% 44%, rgba(124,92,255,0.55), rgba(22,224,224,0.22) 36%, transparent 66%);
}
.card--css.in-view .card__flash { animation: cardFlash 1.1s ease-out 1.15s both; }
@keyframes cardFlash { 0% { opacity: 0; } 25% { opacity: 0.95; } 100% { opacity: 0; } }

/* meals flying in from outside the frame and converging into the phone */
.card__meals { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.card__meals span {
  position: absolute; left: 50%; top: 46%; opacity: 0; line-height: 1; font-size: 14cqw;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,0.55));
}
.card--css.in-view .card__meals span { animation: mealIn 1.5s cubic-bezier(0.33, 1.2, 0.5, 1) both; }
@keyframes mealIn {
  0%   { opacity: 0; transform: translate(calc(-50% + var(--mx)), calc(-50% + var(--my))) rotate(var(--mr)) scale(0.5); }
  35%  { opacity: 1; }
  74%  { opacity: 1; transform: translate(-50%, -50%) rotate(6deg) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(0) scale(0.35); }
}
.card__meals span:nth-child(1) { --mx: -78cqw; --my: -66cqh; --mr: -35deg; animation-delay: 0s;   }
.card__meals span:nth-child(2) { --mx:  80cqw; --my: -58cqh; --mr:  30deg; animation-delay: .10s; }
.card__meals span:nth-child(3) { --mx:   4cqw; --my: -90cqh; --mr: -12deg; animation-delay: .20s; }
.card__meals span:nth-child(4) { --mx: -80cqw; --my:  60cqh; --mr:  22deg; animation-delay: .30s; }
.card__meals span:nth-child(5) { --mx:  82cqw; --my:  66cqh; --mr: -26deg; animation-delay: .26s; }

/* light sweep across the screen during the tour */
.card__shine {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; mix-blend-mode: screen; opacity: 0;
  background: linear-gradient(115deg, transparent 38%, rgba(255,255,255,0.16) 50%, transparent 62%);
  background-size: 260% 100%; background-position: 160% 0;
}
.card--css.in-view .card__shine { opacity: 1; animation: cardShine 9s ease-in-out 2.6s infinite; }
@keyframes cardShine { 0%, 70%, 100% { background-position: 160% 0; } 35% { background-position: -60% 0; } }
.card__body { padding: 22px 24px 26px; position: relative; z-index: 1; }
.card__title { font-size: 1.35rem; font-weight: 700; }
.card__tagline { color: var(--c2); font-size: .9rem; margin-top: 4px; }
.card__desc { color: var(--text-dim); font-size: .95rem; margin-top: 12px; }
.card__tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.card__tag { font-size: .72rem; padding: 5px 12px; border-radius: 100px; background: rgba(255,255,255,0.06); border: 1px solid var(--surface-border); color: var(--text-dim); }
.card__links { display: flex; gap: 18px; margin-top: 20px; }
.card__links a { font-size: .88rem; font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 6px; transition: color .25s; }
.card__links a:hover { color: var(--c2); }
.card__links a svg { width: 15px; height: 15px; }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: clamp(40px, 6vw, 80px); align-items: center; }
.about__media { position: relative; }
.about__photo {
  aspect-ratio: 4 / 5; border-radius: 24px; overflow: hidden;
  background: linear-gradient(140deg, #241a45, #0e2e31 55%, #34172c);
  background-size: cover; background-position: center;
  border: 1px solid var(--surface-border);
}
.about__glow {
  position: absolute; inset: -10% -10% 20% -10%; z-index: -1; border-radius: 30px;
  background: var(--grad); filter: blur(60px); opacity: .35;
}
.about__content p { color: var(--text-dim); margin-top: 20px; font-size: 1.05rem; }
.about__skills { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.about__skills li { padding: 8px 16px; border-radius: 100px; background: var(--surface); border: 1px solid var(--surface-border); font-size: .85rem; }

/* ---------- Contact ---------- */
.contact__inner { max-width: 620px; margin: 0 auto; text-align: center; }
.contact__form { margin-top: 40px; display: grid; gap: 22px; text-align: left; }
.field { position: relative; }
.field input, .field textarea {
  width: 100%; padding: 18px 16px 14px; border-radius: 12px; resize: vertical;
  background: var(--surface); border: 1px solid var(--surface-border); color: var(--text);
  font-family: inherit; font-size: 1rem; transition: border-color .3s, background .3s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--c2); background: rgba(255,255,255,0.06); }
.field label {
  position: absolute; inset-inline-start: 16px; top: 16px; color: var(--text-dim); pointer-events: none;
  transition: .2s var(--ease); font-size: 1rem;
}
.field input:focus + label, .field input:not(:placeholder-shown) + label,
.field textarea:focus + label, .field textarea:not(:placeholder-shown) + label {
  top: -10px; inset-inline-start: 12px; font-size: .72rem; color: var(--c2);
  background: var(--bg); padding: 0 6px;
}
.contact__form .btn { justify-self: center; }
.contact__status { text-align: center; font-size: .9rem; min-height: 1.2em; }
.contact__status.ok { color: var(--c2); }
.contact__status.err { color: var(--c3); }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 60px 20px 50px; border-top: 1px solid var(--surface-border); }
.footer__socials { display: flex; gap: 20px; justify-content: center; margin-bottom: 24px; }
.footer__socials a {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--surface-border);
  color: var(--text-dim); transition: transform .25s var(--ease), color .25s, border-color .25s;
}
.footer__socials a:hover { transform: translateY(-4px); color: var(--text); border-color: var(--c2); }
.footer__socials svg { width: 20px; height: 20px; }
.footer__copy { color: var(--text-dim); font-size: .85rem; }

/* ---------- Reveal animations ---------- */
.reveal { opacity: 0; transform: translateY(28px); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .about { grid-template-columns: 1fr; }
  .about__media { max-width: 360px; margin: 0 auto; }
  .nav__links {
    position: fixed; inset: 0 0 0 auto; width: min(72vw, 320px);
    flex-direction: column; justify-content: center; gap: 28px; padding: 40px;
    background: rgba(10,10,16,0.95); backdrop-filter: blur(18px);
    transform: translateX(100%); transition: transform .4s var(--ease);
  }
  .nav__links.open { transform: translateX(0); }
  .nav__burger { display: flex; z-index: 101; }
  .nav__burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav__burger.open span:nth-child(2) { opacity: 0; }
  .nav__burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* ---------- Mobile-first polish (phones) ---------- */
@media (max-width: 560px) {
  .nav { padding: 16px 18px; }
  .nav.scrolled { padding: 12px 18px; }
  .hero { padding: 0 22px; }
  .hero__title { margin: 18px 0; }
  .hero__sub { font-size: 1.02rem; }
  .hero__cta { gap: 12px; margin-top: 30px; }
  .hero__cta .btn { flex: 1 1 auto; text-align: center; padding: 16px 20px; }
  .hero__scroll { bottom: 24px; }

  .section { padding: 72px 18px; }
  .section__head { margin-bottom: 40px; }
  .projects { gap: 18px; }
  .card__body { padding: 20px 20px 24px; }
  .card__title { font-size: 1.25rem; }

  .about { gap: 36px; }
  .about__media { max-width: 280px; }

  .contact__form .btn { width: 100%; }
  .footer { padding: 48px 18px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  html.js .card__screen { transform: none; }
}
