/* ==========================================================================
   Mohammed Alshoaiby — Portfolio
   Dark cinematic editorial. Type does the heavy lifting.
   ========================================================================== */

:root {
  --bg: #0a0a09;
  --bg-raised: #121110;
  --ink: #ece8e1;
  --ink-dim: #9b958b;
  --ink-faint: #565249;
  --accent: #c9a86a;
  --rule: rgba(236, 232, 225, 0.14);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(1.25rem, 4vw, 4rem);
  --section-pad: clamp(5rem, 12vh, 10rem);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

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

img, video, iframe { display: block; max-width: 100%; }

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

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

/* ---------- Typography helpers ---------- */
.micro {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.display {
  font-family: var(--serif);
  font-weight: 380;
  line-height: 0.98;
  letter-spacing: -0.015em;
}

/* ---------- Skip link ---------- */
.skip-link {
  /* Hidden via clip (not offscreen left: that widens the document in RTL) */
  position: absolute; top: 0; inset-inline-start: 0; z-index: 200;
  background: var(--accent); color: var(--bg); padding: 0.75rem 1.25rem;
  clip-path: inset(100%);
}
.skip-link:focus { clip-path: none; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem var(--gutter);
  transition: background 0.4s ease, backdrop-filter 0.4s ease;
}
.nav.is-scrolled {
  background: rgba(10, 10, 9, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav__brand { display: flex; align-items: center; gap: 0.7rem; }
.nav__brand img { width: 30px; height: 30px; }
.nav__brand span {
  font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase;
}
.nav__links { display: flex; gap: 1.75rem; list-style: none; }
.nav__links a {
  font-size: 0.75rem; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-dim);
  transition: color 0.25s ease;
  padding: 0.4rem 0;
}
.nav__links a:hover, .nav__links a:focus-visible { color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 var(--gutter) clamp(2.5rem, 7vh, 5rem);
  overflow: hidden;
}
.hero__media {
  position: absolute; inset: 0; z-index: 0;
}
.hero__media video,
.hero__media img {
  width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(0.25) contrast(1.04);
}
.hero__media::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(10,10,9,0.6) 0%, rgba(10,10,9,0.28) 40%, rgba(10,10,9,0.92) 100%);
}
.hero__content { position: relative; z-index: 1; }
.hero__kicker { margin-bottom: 1.2rem; color: var(--ink); opacity: 0.85; }
.hero__title {
  font-size: clamp(3rem, 11.5vw, 10.5rem);
  text-transform: uppercase;
  overflow: hidden;
}
.hero__title .line { display: block; }
.hero__sub {
  margin-top: 1.6rem;
  max-width: 34em;
  font-size: clamp(1rem, 1.4vw, 1.2rem);
  color: var(--ink-dim);
}
.hero__sub em { font-family: var(--serif); font-style: italic; color: var(--ink); }
.hero__scroll {
  position: absolute; right: var(--gutter); bottom: clamp(2.5rem, 7vh, 5rem);
  z-index: 1;
  color: var(--ink-dim);
  animation: drift 2.6s ease-in-out infinite;
}
.hero__scroll svg { width: 22px; height: 34px; display: block; }
@keyframes drift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(10px); }
}

/* ---------- Section scaffolding ---------- */
.section { padding: var(--section-pad) var(--gutter); }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 2rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.1rem;
  margin-bottom: clamp(2.5rem, 6vh, 5rem);
}
.section__title {
  font-size: clamp(2rem, 4.5vw, 3.75rem);
}
.section__count { color: var(--ink-faint); font-family: var(--serif); font-size: 1.1rem; }

/* ---------- Manifesto ---------- */
.manifesto { padding: var(--section-pad) var(--gutter); }
.manifesto p {
  font-family: var(--serif);
  font-weight: 360;
  font-size: clamp(1.5rem, 3.4vw, 2.9rem);
  line-height: 1.28;
  max-width: 24em;
}
.manifesto p + p { margin-top: 1.4em; }
.manifesto .dim { color: var(--ink-faint); }
.manifesto em { font-style: italic; color: var(--accent); }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem;
  margin-top: clamp(3rem, 8vh, 6rem);
  border-top: 1px solid var(--rule);
  padding-top: 2rem;
}
.stats div strong {
  display: block;
  font-family: var(--serif); font-weight: 380;
  font-size: clamp(1.9rem, 4vw, 3.4rem);
  line-height: 1;
}
.stats div span { display: block; margin-top: 0.6rem; }

/* ---------- Featured work ---------- */
.case {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2rem, 5vw, 5rem);
  padding: clamp(3rem, 8vh, 6rem) 0;
  border-top: 1px solid var(--rule);
  align-items: start;
}
.case:first-of-type { border-top: 0; padding-top: 0; }
.case__index {
  font-family: var(--serif); font-style: italic;
  color: var(--ink-faint); font-size: 1.05rem;
  margin-bottom: 1.4rem;
}
.case__client { margin-bottom: 0.5rem; color: var(--accent); }
.case__title {
  font-size: clamp(1.9rem, 3.6vw, 3.2rem);
  margin-bottom: 1.4rem;
}
.case__body { color: var(--ink-dim); max-width: 36em; }
.case__body p + p { margin-top: 1em; }
.case__body strong { color: var(--ink); font-weight: 500; }
.case__meta {
  margin-top: 1.6rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem;
  color: var(--ink-faint); font-size: 0.75rem;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.case__link {
  display: inline-block; margin-top: 1.5rem;
  font-size: 0.8125rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 0.2rem;
  transition: color 0.25s ease;
}
.case__link:hover { color: var(--accent); }

/* ---------- Video facade (click-to-play embeds) ---------- */
.player {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-raised);
  overflow: hidden;
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player__btn {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; padding: 0; cursor: pointer;
  background-size: cover; background-position: center;
  filter: grayscale(0.35) contrast(1.02);
  transition: filter 0.4s ease, transform 0.6s ease;
}
.player__btn:hover, .player__btn:focus-visible { filter: grayscale(0) contrast(1.04); }
.player__btn::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(10, 10, 9, 0.25);
  transition: background 0.4s ease;
}
.player__btn:hover::after { background: rgba(10, 10, 9, 0.08); }
.player__btn .play {
  position: absolute; z-index: 1;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: clamp(58px, 7vw, 84px); height: clamp(58px, 7vw, 84px);
  border-radius: 50%;
  border: 1px solid rgba(236, 232, 225, 0.85);
  display: grid; place-items: center;
  backdrop-filter: blur(4px);
  transition: transform 0.3s ease, background 0.3s ease;
}
.player__btn:hover .play { transform: translate(-50%, -50%) scale(1.08); background: rgba(236,232,225,0.12); }
.player__btn .play svg { width: 30%; margin-left: 8%; fill: var(--ink); }

/* ---------- Film index ---------- */
.films__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 2.4rem 1.6rem;
}
.film .player { margin-bottom: 0.9rem; }
.film__client { color: var(--accent); margin-bottom: 0.25rem; }
.film__title { font-family: var(--serif); font-weight: 420; font-size: 1.2rem; line-height: 1.25; }
.film__meta { color: var(--ink-faint); font-size: 0.78rem; margin-top: 0.3rem; }

/* ---------- Clients marquee ---------- */
.clients { padding: var(--section-pad) 0; overflow: hidden; }
.clients .micro { padding: 0 var(--gutter); display: block; margin-bottom: 2.6rem; }
.marquee { display: flex; overflow: hidden; user-select: none; }
.marquee__track {
  display: flex; align-items: center; gap: clamp(3rem, 6vw, 5.5rem);
  padding-right: clamp(3rem, 6vw, 5.5rem);
  flex-shrink: 0;
  animation: marquee 48s linear infinite;
}
.marquee:hover .marquee__track { animation-play-state: paused; }
.marquee img {
  height: clamp(26px, 3.2vw, 40px); width: auto;
  opacity: 0.55;
  transition: opacity 0.3s ease;
}
.marquee img:hover { opacity: 1; }
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

/* ---------- About ---------- */
.about__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2.5rem, 6vw, 6rem);
  align-items: start;
}
.about__photo { position: sticky; top: 6rem; }
.about__photo img { width: 100%; filter: grayscale(1) contrast(1.05); }
.about__photo figcaption { margin-top: 0.8rem; color: var(--ink-faint); font-size: 0.78rem; }
.about__bio p {
  font-size: clamp(1.05rem, 1.5vw, 1.25rem);
  color: var(--ink-dim);
  max-width: 36em;
}
.about__bio p + p { margin-top: 1.2em; }
.about__bio strong { color: var(--ink); font-weight: 500; }
.about__bio a { border-bottom: 1px solid var(--accent); transition: color 0.25s; }
.about__bio a:hover { color: var(--accent); }

.cv { margin-top: clamp(3rem, 7vh, 5rem); }
.cv h3 { margin-bottom: 1.4rem; }
.cv ol { list-style: none; }
.cv li {
  display: grid; grid-template-columns: 7.5rem 1fr auto; gap: 1rem;
  padding: 0.95rem 0;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}
.cv li span:first-child { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.cv li span:nth-child(2) strong { font-weight: 500; }
.cv li span:nth-child(2) em { color: var(--ink-dim); font-style: normal; }
.cv li span:last-child { color: var(--ink-dim); text-align: right; }
.cv + .cv { margin-top: 2.6rem; }

/* ---------- Contact ---------- */
.contact { text-align: left; }
.contact__lede {
  font-family: var(--serif); font-size: clamp(1.3rem, 2.4vw, 2rem);
  color: var(--ink-dim); max-width: 26em; margin-bottom: clamp(2.5rem, 6vh, 4.5rem);
}
.contact__email {
  display: inline-block;
  font-family: var(--serif); font-weight: 380;
  font-size: clamp(2rem, 7.2vw, 6.5rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  border-bottom: 2px solid var(--rule);
  transition: border-color 0.3s ease, color 0.3s ease;
  word-break: break-all;
}
.contact__email:hover { border-color: var(--accent); color: var(--accent); }
.contact__channels {
  margin-top: clamp(2.5rem, 6vh, 4rem);
  display: flex; flex-wrap: wrap; gap: 1rem 3rem;
}
.contact__channels a {
  display: inline-flex; align-items: baseline; gap: 0.7rem;
  font-size: 1rem; color: var(--ink-dim);
  transition: color 0.25s ease;
}
.contact__channels a:hover { color: var(--ink); }
.contact__channels .micro { color: var(--ink-faint); }

/* ---------- Footer ---------- */
.footer {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
  padding: 2rem var(--gutter) 2.6rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint); font-size: 0.8rem;
}
.footer img { width: 22px; height: 22px; opacity: 0.7; }

/* ---------- Reveal animations (JS adds .is-visible) ---------- */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.reveal.is-visible { opacity: 1; transform: none; }
.reveal-stagger > * { opacity: 0; transform: translateY(24px); transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1); }
.reveal-stagger.is-visible > * { opacity: 1; transform: none; }
.reveal-stagger.is-visible > *:nth-child(2) { transition-delay: 0.08s; }
.reveal-stagger.is-visible > *:nth-child(3) { transition-delay: 0.16s; }
.reveal-stagger.is-visible > *:nth-child(4) { transition-delay: 0.24s; }
.reveal-stagger.is-visible > *:nth-child(5) { transition-delay: 0.32s; }
.reveal-stagger.is-visible > *:nth-child(6) { transition-delay: 0.4s; }

/* ---------- Intro / language choice ---------- */
.intro {
  position: fixed; inset: 0; z-index: 150;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  background:
    radial-gradient(ellipse at center, rgba(10,10,9,0.78) 0%, rgba(10,10,9,0.94) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 1;
  transition: opacity 0.7s ease;
}
.intro.is-leaving { opacity: 0; pointer-events: none; }
.intro.is-hidden { display: none; }
.intro__inner { padding: 0 var(--gutter); animation: intro-rise 1.1s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes intro-rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
.intro__emblem { width: 56px; height: 56px; margin: 0 auto 1.6rem; }
.intro__name {
  font-family: var(--serif); font-weight: 380;
  font-size: clamp(1.3rem, 2.6vw, 2rem);
  margin-bottom: 0.8rem;
}
.intro__sep { color: var(--ink-faint); }
.intro__prompt { margin-bottom: 2.2rem; letter-spacing: 0.18em; }
.intro__prompt [lang="ar"] { letter-spacing: 0; }
.intro__choices { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.intro__btn {
  appearance: none; cursor: pointer;
  background: transparent; color: var(--ink);
  border: 1px solid rgba(236, 232, 225, 0.45);
  padding: 0.95rem 2.6rem;
  font-size: 1.05rem; font-family: var(--sans);
  min-width: 11rem;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
/* Arabic inside the intro gets the Arabic display face (Amiri is loaded by both pages) */
.intro__name [lang="ar"],
.intro__prompt [lang="ar"],
.intro__btn[lang="ar"] { font-family: "Amiri", var(--serif); }
.intro__name [lang="ar"] { font-size: 1.08em; }
.intro__prompt [lang="ar"] { font-size: 1.25em; letter-spacing: 0; }
.intro__btn:hover, .intro__btn:focus-visible {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}

/* ---------- Arabic (RTL) overrides — applied via <html lang="ar"> ---------- */
/* Redefine the type variables so every serif/sans moment resolves to the Arabic pair. */
html[lang="ar"] {
  --serif: "Amiri", Georgia, serif;
  --sans: "IBM Plex Sans Arabic", -apple-system, "Segoe UI", sans-serif;
}

/* Pure-white, fully opaque kicker on the Arabic hero
   (site text is warm ivory #ece8e1 by design; at small sizes over colorful
   footage it reads gold, so the AR kicker gets true white instead) */
html[lang="ar"] .hero__kicker { color: #fff; opacity: 1; }

/* Arabic sets taller: no tight display leading, no letter-spacing (it breaks ligatures), no italics. */
html[lang="ar"] .display { line-height: 1.3; letter-spacing: 0; }
html[lang="ar"] .hero__title {
  font-size: clamp(2.7rem, 10vw, 9rem);
  text-transform: none;
  overflow: visible; /* the EN line-reveal clip cuts Arabic descender dots */
  line-height: 1.02;  /* tight stack; descenders stay safe thanks to visible overflow */
  margin-bottom: 0.3em; /* room for the deep ي descender so it clears the intro paragraph */
}
html[lang="ar"] .micro,
html[lang="ar"] .nav__links a,
html[lang="ar"] .nav__brand span,
html[lang="ar"] .case__meta,
html[lang="ar"] .case__link { letter-spacing: 0; }
html[lang="ar"] em { font-style: normal; color: var(--accent); }
html[lang="ar"] .case__index { font-style: normal; }
html[lang="ar"] .manifesto p { line-height: 1.55; }
html[lang="ar"] .hero__sub,
html[lang="ar"] .case__body,
html[lang="ar"] .about__bio p,
html[lang="ar"] .contact__lede { line-height: 1.85; }
html[lang="ar"] .contact__email { font-size: clamp(1.8rem, 6vw, 5.5rem); }
/* Arabic contact: everything right-aligned except the email, which reads LTR
   and is pinned to the left edge as its own row */
html[dir="rtl"] .contact { text-align: right; }
html[dir="rtl"] .contact__emailrow { text-align: left; }

/* Keep Latin-script fragments (phone, email, brand names) readable inside RTL text */
html[lang="ar"] [dir="ltr"] { unicode-bidi: embed; }

/* RTL flips handled by flex/grid auto-mirroring; the few absolutes: */
html[dir="rtl"] .hero__scroll { right: auto; left: var(--gutter); }
/* Keep the logo marquee LTR: in RTL its overflowing track expands the document
   and shifts the whole page. Logos have no reading direction anyway. */
html[dir="rtl"] .marquee { direction: ltr; }
html[dir="rtl"] { overflow-x: clip; }
html[dir="rtl"] .cv li span:last-child { text-align: left; }
@media (max-width: 860px) {
  html[dir="rtl"] .cv li span:last-child { text-align: right; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
  .reveal, .reveal-stagger > * { opacity: 1; transform: none; }
  .hero__scroll { animation: none; }
  .marquee__track { animation: none; flex-wrap: wrap; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .nav__links { gap: 1.1rem; }
  .nav__brand span { display: none; }
  .case { grid-template-columns: 1fr; gap: 1.8rem; }
  .case__text { order: 2; }
  .case .player { order: 1; }
  .about__grid { grid-template-columns: 1fr; }
  .about__photo { position: static; max-width: 420px; }
  .cv li { grid-template-columns: 5.2rem 1fr; }
  .cv li span:last-child { grid-column: 2; text-align: left; font-size: 0.82rem; }
  .stats { grid-template-columns: 1fr; gap: 1.6rem; }
  .hero__scroll { display: none; }
}
