/* ==========================================================
   KARIM SABRI — PORTFOLIO
   Black / white editorial + kinetic. One theme: dark.
   Display: Clash Display · Body: Satoshi
   ========================================================== */

:root {
  --bg: #0c0c0c;
  --bg-soft: #131313;
  --ink: #f2f0ec;
  --ink-dim: #9b9891;
  --line: rgba(242, 240, 236, 0.14);
  --font-display: 'Clash Display', system-ui, sans-serif;
  --font-body: 'Satoshi', system-ui, sans-serif;
  --nav-h: 72px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  /* z-scale: 1 content / 5 preview / 10 nav / 20 menu / 30 lightbox / 40 grain / 50 preloader */
}

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

html { scroll-behavior: auto; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { list-style: none; }

::selection { background: var(--ink); color: var(--bg); }

/* ---------- Grain ---------- */
.grain {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Preloader ---------- */
.preloader {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.preloader__inner { text-align: center; position: relative; z-index: 2; }
.preloader__name { display: flex; gap: 0.35em; overflow: hidden; }
.preloader__word {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.4rem, 8vw, 6rem);
  line-height: 1.05; letter-spacing: -0.02em;
  display: inline-block; transform: translateY(110%);
}
.preloader__word--outline {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--ink);
}
.preloader__count {
  position: fixed; right: 5vw; bottom: 4vh;
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.2rem, 3vw, 2rem); color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.preloader__curtain {
  position: absolute; inset: 0; background: var(--bg); z-index: 1;
}

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  mix-blend-mode: difference;
}
.nav__logo {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.35rem; letter-spacing: -0.01em; color: #fff;
}
.nav__logo sup { font-size: 0.5em; font-weight: 500; }
.nav__links { display: flex; gap: 2.25rem; }
.nav__link {
  position: relative; color: #fff;
  font-size: 0.95rem; font-weight: 500;
}
.nav__link::after {
  content: ""; position: absolute; left: 0; bottom: -4px;
  width: 100%; height: 1px; background: #fff;
  transform: scaleX(0); transform-origin: right center;
  transition: transform 0.45s var(--ease-out);
}
.nav__link:hover::after { transform: scaleX(1); transform-origin: left center; }
.nav__burger { display: none; width: 40px; height: 40px; position: relative; }
.nav__burger span {
  position: absolute; left: 8px; right: 8px; height: 2px; background: #fff;
  transition: transform 0.35s var(--ease-out), top 0.35s var(--ease-out);
}
.nav__burger span:nth-child(1) { top: 15px; }
.nav__burger span:nth-child(2) { top: 23px; }
.nav__burger.is-open span:nth-child(1) { top: 19px; transform: rotate(45deg); }
.nav__burger.is-open span:nth-child(2) { top: 19px; transform: rotate(-45deg); }

/* ---------- Mobile menu ---------- */
.menu {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 1rem;
  padding: 0 8vw;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.7s var(--ease-out);
  visibility: hidden;
}
.menu.is-open { clip-path: inset(0 0 0 0); visibility: visible; }
.menu__link {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.6rem, 11vw, 4.5rem); line-height: 1.1;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100dvh;
  display: flex; align-items: center;
  overflow: hidden;
}
.hero__canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 1;
}
.hero__content {
  position: relative; z-index: 3;
  width: 100%;
  padding: var(--nav-h) clamp(1.25rem, 4vw, 3rem) 2rem;
}
.hero__role {
  overflow: hidden;
  margin-bottom: clamp(0.75rem, 2vh, 1.5rem);
}
.hero__role span {
  display: inline-block;
  font-size: clamp(0.85rem, 1.4vw, 1.05rem);
  font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-dim);
}
.hero__title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(4.2rem, 15.5vw, 15rem);
  line-height: 0.92; letter-spacing: -0.03em;
  text-transform: uppercase;
  display: flex; flex-direction: column;
}
.hero__line { overflow: hidden; display: block; }
.hero__line--right { text-align: right; }
.hero__line-inner { display: inline-block; transform: translateY(110%); }
.hero__line-inner--outline {
  color: transparent;
  -webkit-text-stroke: 2px var(--ink);
}
.hero__meta {
  margin-top: clamp(1.25rem, 4vh, 2.5rem);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
}
.hero__meta p { color: var(--ink-dim); font-size: 0.95rem; max-width: 34ch; }
.hero__cta {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1rem; letter-spacing: 0.02em;
  padding: 0.9rem 2rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  transition: background 0.35s var(--ease-out), color 0.35s var(--ease-out), transform 0.15s;
  white-space: nowrap;
}
.hero__cta:hover { background: var(--ink); color: var(--bg); }
.hero__cta:active { transform: scale(0.98); }
.hero__portrait {
  position: absolute; z-index: 2;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: clamp(280px, 34vw, 520px);
  pointer-events: none;
}
.hero__portrait img {
  width: 100%;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
}

/* ---------- Marquee ---------- */
.marquee {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  padding: 1.1rem 0;
  background: var(--bg);
  position: relative; z-index: 3;
}
.marquee__track {
  display: flex; white-space: nowrap; will-change: transform;
}
.marquee__track span {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.3rem, 3vw, 2.2rem);
  text-transform: uppercase; letter-spacing: 0.02em;
  padding-right: 0.5em;
}

/* ---------- About ---------- */
.about { padding: clamp(6rem, 14vh, 10rem) clamp(1.25rem, 4vw, 3rem); }
.about__grid {
  display: grid; grid-template-columns: 5fr 7fr;
  gap: clamp(2rem, 6vw, 5rem);
  max-width: 1400px; margin: 0 auto;
  align-items: start;
}
.about__portrait {
  position: sticky; top: calc(var(--nav-h) + 2rem);
  background: var(--bg-soft);
  border-radius: 12px; overflow: hidden;
}
.about__portrait img { padding: 2rem 2rem 0; }
.about__heading {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1.12; letter-spacing: -0.015em;
  margin-bottom: 2rem;
}
.about__text { color: var(--ink-dim); max-width: 58ch; margin-bottom: 3rem; }
.about__stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  border-top: 1px solid var(--line);
  padding-top: 2rem; margin-bottom: 2.5rem;
}
.stat__num {
  display: block;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat__label { color: var(--ink-dim); font-size: 0.9rem; }
.about__tools { display: flex; gap: 0.75rem; }
.tool {
  font-family: var(--font-display); font-weight: 600; font-size: 0.9rem;
  width: 48px; height: 48px; border-radius: 10px;
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.3s, color 0.3s;
}
.tool:hover { background: var(--ink); color: var(--bg); }

/* ---------- Featured (horizontal scroll) ---------- */
.featured { position: relative; }
.featured__head {
  padding: clamp(3rem, 8vh, 6rem) clamp(1.25rem, 4vw, 3rem) 2rem;
}
.featured__heading {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(3rem, 9vw, 8rem);
  line-height: 1; letter-spacing: -0.03em; text-transform: uppercase;
}
.featured__wrap { overflow: hidden; }
.featured__track {
  display: flex; align-items: center;
  gap: clamp(1rem, 3vw, 2.5rem);
  padding: 0 clamp(1.25rem, 4vw, 3rem) 4rem;
  height: 100dvh;
  width: max-content;
}
.featured__item {
  position: relative;
  height: min(66vh, 660px);
  aspect-ratio: 4 / 5;
  flex: none;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg-soft);
  cursor: pointer;
}
.featured__item img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.7s var(--ease-out);
}
.featured__item:hover img { transform: scale(1.045); }
.featured__item figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 1.5rem 1.25rem 1rem;
  background: linear-gradient(to top, rgba(12,12,12,0.85), transparent);
  font-size: 0.9rem; font-weight: 500;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.4s, transform 0.4s;
}
.featured__item:hover figcaption { opacity: 1; transform: none; }

/* ---------- Categories list ---------- */
.cats { position: relative; padding: clamp(4rem, 10vh, 8rem) 0; }
.cats__list { border-top: 1px solid var(--line); }
.cats__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline; gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1.5rem, 4vh, 2.75rem) clamp(1.25rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.35s;
}
.cats__item:hover { background: var(--bg-soft); }
.cats__index {
  font-family: var(--font-display); font-weight: 500;
  color: var(--ink-dim); font-size: 1rem;
}
.cats__name {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.8rem, 5.5vw, 4.2rem);
  line-height: 1.05; letter-spacing: -0.02em;
  transition: transform 0.45s var(--ease-out);
}
.cats__item:hover .cats__name { transform: translateX(1.5rem); }
.cats__count { color: var(--ink-dim); font-size: 0.95rem; white-space: nowrap; }
.cats__preview {
  position: fixed; z-index: 5;
  width: min(320px, 26vw); aspect-ratio: 1;
  border-radius: 8px; overflow: hidden;
  pointer-events: none;
  opacity: 0; transform: scale(0.9);
  transition: opacity 0.3s, transform 0.3s;
  top: 0; left: 0;
}
.cats__preview.is-visible { opacity: 1; transform: scale(1); }
.cats__preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Gallery ---------- */
.gallery { padding: 2rem clamp(1.25rem, 4vw, 3rem) clamp(5rem, 12vh, 9rem); }
.gallery__filters {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.gallery__filter {
  font-weight: 500; font-size: 0.95rem;
  padding: 0.65rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.gallery__filter:hover { color: var(--ink); border-color: var(--ink); }
.gallery__filter.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  max-width: 1400px; margin: 0 auto;
}
.gallery__item {
  aspect-ratio: 4 / 5;
  border-radius: 8px; overflow: hidden;
  background: var(--bg-soft);
  cursor: pointer;
  position: relative;
}
.gallery__item img, .gallery__item video {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.6s var(--ease-out), opacity 0.5s;
  opacity: 0;
}
.gallery__item img.is-loaded, .gallery__item video.is-loaded { opacity: 1; }
.gallery__item:hover img, .gallery__item:hover video { transform: scale(1.04); }
.gallery__item--video::after {
  content: "▶";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #fff;
  background: rgba(12,12,12,0.35);
  pointer-events: none;
}
.gallery__more-wrap { text-align: center; margin-top: 3rem; }
.gallery__more {
  font-family: var(--font-display); font-weight: 600; font-size: 1rem;
  padding: 0.9rem 2.5rem;
  border: 1px solid var(--ink); border-radius: 999px;
  transition: background 0.3s, color 0.3s, transform 0.15s;
}
.gallery__more:hover { background: var(--ink); color: var(--bg); }
.gallery__more:active { transform: scale(0.98); }
.gallery__more[hidden] { display: none; }

/* ---------- Contact ---------- */
.contact {
  padding: clamp(6rem, 16vh, 12rem) clamp(1.25rem, 4vw, 3rem) 4rem;
  border-top: 1px solid var(--line);
  text-align: center;
}
.contact__kicker { color: var(--ink-dim); margin-bottom: 1.5rem; }
.contact__big {
  display: inline-flex; flex-direction: column;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(4.5rem, 17vw, 15rem);
  line-height: 0.95; letter-spacing: -0.03em;
  margin-bottom: clamp(3rem, 8vh, 5rem);
}
.contact__big-line { overflow: hidden; display: block; }
.contact__big-line--outline {
  color: transparent;
  -webkit-text-stroke: 2px var(--ink);
  transition: color 0.5s var(--ease-out);
}
.contact__big:hover .contact__big-line--outline { color: var(--ink); }
.contact__row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 2rem;
  max-width: 1400px; margin: 0 auto;
}
.contact__link {
  font-weight: 500; position: relative;
}
.contact__link::after {
  content: ""; position: absolute; left: 0; bottom: -3px;
  width: 100%; height: 1px; background: var(--ink);
  transform: scaleX(0); transform-origin: right center;
  transition: transform 0.45s var(--ease-out);
}
.contact__link:hover::after { transform: scaleX(1); transform-origin: left center; }
.contact__socials { display: flex; gap: 2rem; }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  padding: 1.5rem clamp(1.25rem, 4vw, 3rem);
  color: var(--ink-dim); font-size: 0.85rem;
  border-top: 1px solid var(--line);
}
.footer__top { color: var(--ink); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(8, 8, 8, 0.94);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity 0.35s, visibility 0.35s;
}
.lightbox.is-open { opacity: 1; visibility: visible; }
.lightbox__stage {
  max-width: min(88vw, 1100px); max-height: 84vh;
  display: flex; align-items: center; justify-content: center;
}
.lightbox__stage img, .lightbox__stage video {
  max-width: 100%; max-height: 84vh;
  object-fit: contain; border-radius: 6px;
}
.lightbox__close {
  position: absolute; top: 1.25rem; right: 1.5rem;
  font-size: 2.2rem; line-height: 1; z-index: 2;
  color: var(--ink);
  transition: transform 0.3s;
}
.lightbox__close:hover { transform: rotate(90deg); }
.lightbox__arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 1.8rem; padding: 1rem; z-index: 2;
  color: var(--ink); opacity: 0.7;
  transition: opacity 0.3s;
}
.lightbox__arrow:hover { opacity: 1; }
.lightbox__arrow--prev { left: 0.75rem; }
.lightbox__arrow--next { right: 0.75rem; }

/* ---------- Reveal helpers ---------- */
[data-reveal] { opacity: 0; transform: translateY(32px); }
[data-hero-fade] { opacity: 0; }
.split-line { display: block; overflow: hidden; }
.split-line > span { display: inline-block; transform: translateY(110%); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .about__grid { grid-template-columns: 1fr; }
  .about__portrait { position: static; max-width: 420px; }
  .gallery__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .nav__links { display: none; }
  .nav__burger { display: block; }
  .hero { flex-direction: column; justify-content: flex-end; }
  .hero__content { padding-top: calc(var(--nav-h) + 1.5rem); padding-bottom: 0; }
  .hero__portrait {
    position: static; transform: none;
    width: min(66vw, 320px);
    margin: 0.5rem auto 0;
  }
  .hero__title { font-size: clamp(3.4rem, 17vw, 6rem); }
  .featured__track { height: auto; padding-bottom: 2rem; }
  .featured__item { height: 72vw; }
  .cats__item { grid-template-columns: auto 1fr; }
  .cats__count { grid-column: 2; }
  .cats__preview { display: none; }
  .contact__row { justify-content: center; text-align: center; }
}

@media (max-width: 560px) {
  .gallery__grid { grid-template-columns: 1fr; }
  .about__stats { grid-template-columns: 1fr 1fr; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
  [data-reveal], [data-hero-fade] { opacity: 1; transform: none; }
  .hero__line-inner, .preloader__word, .split-line > span { transform: none; }
  .hero__canvas { display: none; }
}
