/* =========================================================
   Zakaria Mamdouh — portfolio
   Palette is pulled from the portrait's red backdrop (#5a0205)
   ========================================================= */
:root {
  --bg: #120203;
  --bg-2: #1b0405;
  --panel: #210607;
  --line: #ffffff1a;
  --text: #f6ecea;
  --muted: #c9a9a6;
  --red: #e1252f;
  --red-deep: #5a0205;
  --pink: #ffb3b8;
  --radius: 22px;
  --wrap: min(1180px, 100% - 48px);
  --display: "Anton", Impact, "Arial Narrow", sans-serif;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.02; }
h1, h2, .job h3, .stats dd { font-family: var(--display); font-weight: 400; text-transform: uppercase; letter-spacing: .005em; }
h2 { font-size: clamp(42px, 6.6vw, 96px); line-height: .98; }
.wrap { width: var(--wrap); margin-inline: auto; }
.eyebrow {
  margin: 0 0 14px;
  font-size: 13px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--red);
}
:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; border-radius: 6px; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 44px);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: block; line-height: 0; }
.brand img { height: 34px; width: auto; }
.topbar nav { display: flex; gap: clamp(14px, 2.6vw, 32px); font-size: 14px; font-weight: 500; }
.topbar nav a { text-decoration: none; opacity: .85; }
.topbar nav a:hover { opacity: 1; }
.nav-cta { padding: 6px 14px; border: 1px solid #ffffff55; border-radius: 99px; }
.topbar.is-solid { background: #120203d9; backdrop-filter: blur(10px); }

/* ---------- hero ---------- */
.opening { position: relative; height: 125vh; }
.stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 70% at 50% 72%, #6b050a 0%, #4a0306 38%, #240203 70%, var(--bg) 100%);
  --p: 0;              /* scroll progress through the hero, 0 → 1 (set by main.js) */
  --photo: min(88vh, 782px);   /* portrait height */
  --name-top: calc(100% - var(--photo) * .56);   /* just under the chin */
  --cx: 0; --cy: 0;    /* cursor (or idle drift) position in the hero, -1 → 1 (set by main.js) */
}
/* soft red spotlight that follows the mouse */
.spot {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(520px circle at var(--gx, 50%) var(--gy, 40%), #ff3b4440, transparent 62%);
  opacity: 0; transition: opacity .6s;
}
.stage.has-cursor .spot { opacity: 1; }
.glow {
  position: absolute; inset: auto 10% -20% 10%; height: 70%;
  background: radial-gradient(closest-side, #ff3b4466, transparent);
  opacity: calc(.9 - var(--p) * .6);
}
.portrait {
  position: absolute; left: 50%; bottom: 0;
  height: var(--photo); width: auto; aspect-ratio: 1;   /* never stretched beyond the photo's real 782px */
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  /* fade the photo's square edges into the page so the red backdrop blends in */
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 16%, #000 84%, transparent 100%),
                      linear-gradient(to bottom, transparent 0%, #000 14%);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to right, transparent 0%, #000 16%, #000 84%, transparent 100%),
                      linear-gradient(to bottom, transparent 0%, #000 14%);
          mask-composite: intersect;
  z-index: 2;
  animation: rise 1.1s cubic-bezier(.2,.8,.2,1) both;
}
.name {
  position: absolute; inset: var(--name-top) 0 auto; z-index: 3;
  display: flex; justify-content: center; gap: 3vw;
  font-size: clamp(64px, 12.5vw, 230px); line-height: .9; letter-spacing: .005em;
  opacity: calc(1.5 - var(--p) * 1.4);
  pointer-events: none;
}
.name span { display: block; animation: slide-in 1.1s .25s cubic-bezier(.2,.8,.2,1) both; }
.name-first {
  transform: translateX(calc(var(--p) * -18vw));
  text-shadow: 0 10px 40px #00000066;
}
.name-last {
  --from: 60px;
  transform: translateX(calc(var(--p) * 18vw));
  background: linear-gradient(100deg, #ffffff 10%, var(--pink) 60%, #ff6b74 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.name-first { --from: -60px; }
.role {
  position: absolute; left: 0; right: 0; top: calc(var(--name-top) + clamp(64px, 12.5vw, 230px) * .92 + 10px); z-index: 3;
  display: flex; justify-content: center; gap: 22vw;
  font-size: clamp(12px, 1.15vw, 16px); font-weight: 500; letter-spacing: .04em;
  opacity: calc(1 - var(--p) * 2.2);
  animation: fade 1s .6s both;
}
.role p { margin: 0; text-shadow: 0 2px 12px #000a; }
.role i { font-style: normal; color: var(--pink); padding: 0 .2em; }
.role-ar { font-family: "Cairo", sans-serif; font-weight: 800; font-size: 1.35em; letter-spacing: 0; }

/* floating tool icons */
.tools { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.tool {
  --size: calc(clamp(52px, 6.6vw, 104px) * var(--s));
  --side: 1;
  position: absolute;
  left: calc(var(--x) * 1%); top: calc(var(--y) * 1%);
  width: var(--size);
  display: grid; justify-items: center; gap: 8px;
  /* scroll parallax: deeper icons drift further outward and up */
  transform: translate(-50%, -50%)
             translate(calc((var(--x) - 50) * var(--p) * var(--depth) * .9vw),
                       calc(var(--p) * var(--depth) * -26vh));
  opacity: calc(1 - var(--p) * 1.3);
}
.fly {
  display: block; width: 100%;
  animation: fly-in 1.2s calc(.35s + var(--d) * 70ms) cubic-bezier(.2,.9,.25,1.15) both;
}
.tile {
  --hov: 0;
  display: block; width: 100%; aspect-ratio: 1;
  pointer-events: auto; cursor: pointer;
  /* idle: tilted like a sticker; hovered: straightens, lifts and leans toward the cursor */
  transform: perspective(420px) translate(var(--hx, 0px), var(--hy, 0px))
             rotateX(var(--hrx, 0deg)) rotateY(var(--hry, 0deg))
             rotate(calc(var(--r) * 1deg * (1 - var(--hov)))) skewY(calc(var(--r) * -.3deg * (1 - var(--hov))))
             scale(calc(1 + var(--hov) * .2));
  transition: transform .45s cubic-bezier(.2,.8,.2,1.2), filter .35s;
  /* first shadow = the tile's thickness, second = soft shadow on the backdrop */
  will-change: transform;
  animation: bob 6s calc(var(--d) * -.7s) ease-in-out infinite;
}
.tile img { width: 100%; height: 100%; object-fit: contain; border-radius: 22%; box-shadow: 0 calc(var(--size) * .14) calc(var(--size) * .25) #000000a0; }
.tool.is-hover .tile {
  --hov: 1;
  filter: brightness(1.12);
}
.tool.is-hover .tool-label { color: #fff; }
.tile.pop img { animation: pop .8s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { 40% { transform: scale(1.25) rotate(200deg); } 100% { transform: rotate(360deg); } }
.tool-label {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap;
  color: #ffffffcc; text-shadow: 0 2px 8px #000;
  animation: fade .8s calc(1s + var(--d) * 70ms) both;
}
.scroll-hint {
  position: absolute; left: 50%; bottom: 22px; z-index: 5; transform: translateX(-50%);
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase; text-decoration: none;
  padding: 8px 16px; border-radius: 99px; background: #00000055; backdrop-filter: blur(6px);
  opacity: calc(1 - var(--p) * 4);
  animation: fade 1s 1.4s both;
}

@keyframes rise { from { opacity: 0; translate: 0 6%; } }
@keyframes slide-in { from { opacity: 0; translate: var(--from) 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes fly-in {
  from {
    opacity: 0;
    transform: translate(calc((50 - var(--x)) * .8vw), calc((60 - var(--y)) * .8vh)) scale(.2) rotate(-30deg);
  }
}
@keyframes bob {
  33% { translate: 0 -8px; rotate: 2deg; }
  66% { translate: 0 3px; rotate: -1.5deg; }
}

/* ---------- about ---------- */
.about { padding: clamp(90px, 12vw, 160px) 0 60px; }
.about-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: clamp(30px, 6vw, 90px); align-items: end; }
.about h2 { font-size: clamp(38px, 5.2vw, 72px); }
.lead { margin: 0 0 34px; font-size: clamp(17px, 1.5vw, 20px); color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0; }
.stats div { padding: 16px 16px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.stats dt { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.stats dd { margin: 2px 0 0; font-size: clamp(30px, 3.2vw, 44px); line-height: 1.1; }

/* ---------- section heads ---------- */
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 44px; }
.section-note { margin: 0; max-width: 300px; color: var(--muted); font-size: 15px; }

/* ---------- carousel ---------- */
.work { padding: 90px 0 40px; overflow: hidden; }
.carousel { --card: min(420px, 74vw); --step: calc(var(--card) * .78); }
.carousel-viewport {
  position: relative; height: calc(var(--card) * 1.22);
  perspective: 1400px;
  touch-action: pan-y;
}
.card {
  --slot: 0; --abs: 0;
  position: absolute; left: 50%; top: 0;
  width: var(--card);
  margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left;
  cursor: pointer;
  transform: translateX(-50%) translateX(calc(var(--slot) * var(--step)))
             scale(calc(1 - var(--abs) * .14)) rotateY(calc(var(--slot) * -8deg));
  transform-origin: 50% 40%;
  z-index: calc(10 - var(--abs));
  filter: brightness(calc(1 - var(--abs) * .32));
  transition: transform .7s cubic-bezier(.2,.8,.2,1), filter .7s, opacity .5s;
}
.card.is-offstage { opacity: 0; pointer-events: none; }
.card.is-resetting { transition: none; }
.card-img {
  position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  background: var(--panel);
  box-shadow: 0 30px 60px #00000080, 0 0 0 1px var(--line);
}
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.card-img { transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.card-img.is-tilting { transition: transform .12s linear; }
.card-img::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), #ffffff38, transparent 50%);
  opacity: 0; transition: opacity .4s;
}
.card-img.is-tilting::after { opacity: 1; }
/* magnetic buttons: they lean toward the cursor */
.magnetic { translate: var(--mgx, 0px) var(--mgy, 0px); transition: translate .35s cubic-bezier(.2,.8,.2,1), background .2s, transform .2s; }
/* page scroll progress */
.progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 60; transform-origin: 0 50%; transform: scaleX(var(--sp, 0)); background: linear-gradient(90deg, var(--red), var(--pink)); pointer-events: none; }
.card[aria-current="true"]:hover .card-img img { transform: scale(1.04); }
.card-count {
  position: absolute; right: 12px; bottom: 12px;
  padding: 5px 11px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: #000000a6; backdrop-filter: blur(6px);
}
.card-meta { padding: 16px 6px 0; transition: opacity .4s; }
.card:not([aria-current="true"]) .card-meta { opacity: 0; }
.card-meta h3 { font-size: 21px; font-weight: 700; line-height: 1.2; }
.card-meta p { margin: 3px 0 0; font-size: 14px; color: var(--muted); }
.carousel-controls { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.carousel-controls button, .lb-nav, .lb-close {
  min-width: 46px; height: 46px; padding: 0 16px;
  border: 1px solid #ffffff33; border-radius: 99px;
  background: #ffffff0d; color: var(--text); font: inherit; font-size: 15px; cursor: pointer;
  transition: background .2s;
}
.carousel-controls button:hover, .lb-nav:hover, .lb-close:hover { background: #ffffff22; }

/* ---------- branding ---------- */
.branding { padding: 110px 0 40px; }
.brand-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.brand-card {
  display: flex; flex-direction: column; justify-content: flex-start;
  margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.brand-card .card-img { aspect-ratio: 4 / 5; box-shadow: 0 0 0 1px var(--line); }
.brand-card .card-img img { object-position: 50% 0; }
.brand-card:hover .card-img img { transform: scale(1.04); }
.brand-card .card-meta { padding: 12px 4px 0; }
.brand-card .card-meta h3 { font-size: 18px; }

/* ---------- AI shoots ---------- */
.shoots { padding: 110px 0 40px; }
.shoot-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.shoot-grid .card-img { aspect-ratio: 1; }
.shoot-grid .card-img img { object-position: 50% 20%; }
.shoot-grid .card-meta h3 { font-size: 22px; }
@media (max-width: 600px) { .shoot-grid { grid-template-columns: 1fr; } }

/* ---------- experience ---------- */
.experience { padding: 110px 0 60px; }
.timeline { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.job {
  display: grid; grid-template-columns: 220px 1fr; gap: 24px;
  padding: 30px 0; border-bottom: 1px solid var(--line);
}
.when { margin: 4px 0 0; font-weight: 700; color: var(--pink); font-variant-numeric: tabular-nums; }
.job h3 { font-size: clamp(26px, 2.8vw, 38px); }
.job-role { margin: 6px 0 10px; color: var(--muted); }
.job ul { margin: 0; padding-left: 18px; columns: 2; column-gap: 40px; }
.job li { break-inside: avoid; margin-bottom: 4px; font-size: 15.5px; }
.job li::marker { color: var(--red); }
.skills { margin-top: 60px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; }
.chips li { padding: 8px 16px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-size: 14.5px; }

/* ---------- contact ---------- */
.contact {
  padding: 130px 0 50px; margin-top: 80px;
  background: radial-gradient(ellipse 80% 90% at 50% 110%, #6b050a 0%, #2a0304 55%, var(--bg) 100%);
}
.contact h2 { font-size: clamp(44px, 8vw, 120px); }
.mail {
  display: inline-block; margin: 30px 0 26px;
  font-size: clamp(20px, 3vw, 38px); font-weight: 700; text-decoration-thickness: 2px; text-underline-offset: 6px;
  word-break: break-all;
}
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; height: 50px; padding: 0 22px; border-radius: 99px;
  border: 1px solid #ffffff44; text-decoration: none; font-weight: 700; transition: background .2s, transform .2s;
}
.btn:hover { background: #ffffff1a; transform: translateY(-2px); }
.btn-primary { background: var(--red); border-color: var(--red); }
.btn-primary:hover { background: #f53b45; }
.btn-wa { gap: 10px; height: 56px; padding: 0 26px 0 14px; background: #25d366; border-color: #25d366; color: #07240f; font-size: 17px; }
.btn-wa:hover { background: #3be07a; }
.btn-wa img { width: 30px; height: 30px; }
.socials {
  list-style: none; margin: 44px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px;
}
.socials a {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px 12px; border-radius: 18px; text-decoration: none;
  background: #ffffff08; border: 1px solid var(--line); color: var(--muted); font-size: 13.5px;
  transition: transform .2s, background .2s, color .2s;
}
.socials a:hover { transform: translateY(-3px); background: #ffffff14; color: var(--text); }
.socials img, .socials svg { width: 44px; height: 44px; object-fit: contain; border-radius: 12px; }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 70px; padding-top: 26px; border-top: 1px solid var(--line); }
.footer-logo { width: 190px; height: auto; }
@media (max-width: 600px) {
  .socials { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .socials a { padding: 12px 4px 10px; font-size: 11px; gap: 6px; border-radius: 14px; }
  .socials img, .socials svg { width: 34px; height: 34px; }
  .footer-logo { width: 150px; }
}
.fine { margin: 0; font-size: 13px; color: #ffffff70; }

/* ---------- lightbox ---------- */
.lightbox {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 18px clamp(14px, 3vw, 34px) 14px; border: 0;
  background: #0c0102f2; color: var(--text);
  display: none; grid-template-rows: auto 1fr auto; gap: 12px;
}
.lightbox[open] { display: grid; }
.lightbox::backdrop { background: #000c; }
.lb-top { display: flex; align-items: center; gap: 18px; }
.lb-top > div { flex: 1; min-width: 0; }
.lb-type { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--red); font-weight: 700; }
.lb-top h3 { font-size: clamp(18px, 2.2vw, 26px); font-weight: 700; }
.lb-count { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; touch-action: pan-y; }
.lb-stage img {
  position: absolute; inset: 0 56px; width: calc(100% - 112px); height: 100%;
  object-fit: contain; filter: drop-shadow(0 24px 60px #000);
}
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: #000000a0; z-index: 1; }
@media (max-width: 600px) { .lb-stage img { inset: 0; width: 100%; } }
.lb-prev { left: 0; } .lb-next { right: 0; }
.lb-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px; justify-content: safe center; scrollbar-width: thin; }
.lb-thumbs button { flex: none; width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--panel); cursor: pointer; opacity: .55; }
.lb-thumbs button[aria-current="true"] { border-color: var(--red); opacity: 1; }
.lb-thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- scroll reveal ---------- */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s, transform .8s cubic-bezier(.2,.8,.2,1); }
.js .reveal.is-in { opacity: 1; transform: none; }

/* ---------- phones & tablets ---------- */
@media (max-width: 900px) {
  .about-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand-grid { grid-template-columns: repeat(2, 1fr); }
  .job { grid-template-columns: 1fr; gap: 6px; }
  .job ul { columns: 1; }
  .section-head { flex-direction: column; align-items: start; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .topbar nav a:not(.nav-cta) { display: none; }
  .portrait { height: auto; width: 128vw; max-height: 64svh; }
  .name { inset: 12% 0 auto; flex-direction: column; align-items: center; gap: 0; font-size: 21vw; line-height: .9; text-align: center; }
  .role { top: calc(12% + 38vw + 12px); flex-direction: column; align-items: center; gap: 2px; font-size: 12px; text-align: center; }
  .role-en { font-size: 11.5px; white-space: nowrap; }
  .tool { left: calc(var(--mx) * 1%); top: calc(var(--my) * 1%); --size: calc(42px * var(--s) + 2vw); }
  .tool-label { display: none; }
  .tool { transform: translate(-50%, -50%) translate(calc((var(--mx) - 50) * var(--p) * var(--depth) * .9vw), calc(var(--p) * var(--depth) * -20vh)) }
  @keyframes fly-in { from { opacity: 0; transform: translate(calc((50 - var(--mx)) * .8vw), calc((60 - var(--my)) * .8vh)) scale(.2) rotate(-30deg); } }
}

@media (prefers-reduced-motion: reduce) {
  /* motion stays on but calmer: main.js also halves the cursor and scroll movement */
  html { scroll-behavior: auto; }
  .tile { animation-duration: 9s; }
}
