/* Khaled Deef · Motion Graphics Designer */
:root {
  --bg: #ffffff;
  --paper: #f6f5f2;
  --ink: #111111;
  --ink-2: #4a4a48;
  --ink-3: #8a8a86;
  --line: #e6e4df;
  --accent: #ff4a1c;
  --accent-soft: #ffe7df;
  --blue: #2f5bff;
  --green: #17a673;
  --yellow: #f5b400;
  --display: "Bricolage Grotesque", "Readex Pro", system-ui, sans-serif;
  --body: "Figtree", "Readex Pro", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --wrap: min(1240px, 100% - 48px);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

[lang="ar"] {
  --display: "Readex Pro", system-ui, sans-serif;
  --body: "Readex Pro", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.wrap { width: var(--wrap); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset-inline: 0; top: 0; z-index: 50;
  transition: background .3s, box-shadow .3s;
}
.nav.scrolled { background: rgba(255,255,255,.88); backdrop-filter: blur(12px); box-shadow: 0 1px 0 var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 18px/1 var(--display); letter-spacing: -.01em; }
.brand .kf { width: 12px; height: 12px; background: var(--accent); transform: rotate(45deg); border-radius: 2px; }
.nav nav { display: flex; align-items: center; gap: 28px; font-size: 15px; font-weight: 500; }
.nav nav a { color: var(--ink-2); transition: color .2s; }
.nav nav a:hover { color: var(--ink); }
.lang {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  font-size: 14px; font-weight: 600; transition: border-color .2s, background .2s;
}
.lang:hover { border-color: var(--ink); }
.lang [lang="ar"] { font-family: "Readex Pro", sans-serif; }

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh; min-height: 100svh;
  display: grid; grid-template-rows: 1fr auto;
  padding-top: 68px; position: relative; overflow: hidden;
}
.hero-main {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px 48px;
  align-content: center; padding-block: 32px 24px;
}
.hero h1 {
  grid-column: 1 / -1; margin: 0;
  font: 800 clamp(64px, 12.6vw, 196px)/.9 var(--display);
  letter-spacing: -.045em; white-space: nowrap;
}
[lang="ar"] .hero h1 { letter-spacing: 0; line-height: 1.15; font-weight: 700; font-size: clamp(64px, 12vw, 180px); }
.hero h1 .ch { display: inline-block; opacity: 0; transform: translateY(.35em); animation: rise .9s var(--ease) forwards; }
.hero h1 .dot { color: var(--accent); }
@keyframes rise { to { opacity: 1; transform: none; } }

.hero-copy { align-self: start; max-width: 520px; opacity: 0; animation: fade .8s .55s var(--ease) forwards; }
.role {
  display: inline-flex; align-items: center; gap: 10px;
  font: 600 15px/1 var(--body); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-2);
}
[lang="ar"] .role { letter-spacing: 0; text-transform: none; font-size: 17px; }
.role::before { content: ""; width: 28px; height: 2px; background: var(--accent); }
.lede { font-size: clamp(18px, 1.6vw, 21px); line-height: 1.55; color: var(--ink-2); margin: 18px 0 26px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.button {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-radius: 999px; border: 1px solid var(--ink);
  font-weight: 600; font-size: 16px; transition: transform .25s var(--ease), background .2s, color .2s;
}
.button:hover { transform: translateY(-2px); }
.button-dark { background: var(--ink); color: #fff; }
.button-dark:hover { background: var(--accent); border-color: var(--accent); }
.button svg { width: 16px; height: 16px; }
.status { display: flex; align-items: center; gap: 10px; margin-top: 22px; font-size: 14px; color: var(--ink-3); }
.status .rec { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(23,166,115,.5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(23,166,115,0); } 100% { box-shadow: 0 0 0 0 rgba(23,166,115,0); } }
@keyframes fade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Graph editor art */
.graph {
  position: relative; align-self: stretch; min-height: 300px; margin: 0;
  border: 1px solid var(--line); border-radius: 18px; background: var(--paper);
  opacity: 0; animation: fade .9s .75s var(--ease) forwards; overflow: hidden;
}
.graph-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  font: 500 12px/1 var(--mono); color: var(--ink-3); direction: ltr; white-space: nowrap; gap: 12px;
}
.graph-head .dots { display: flex; gap: 6px; }
.graph-head .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.graph svg { display: block; width: 100%; height: calc(100% - 38px); direction: ltr; }
.graph .grid line { stroke: #e9e7e2; stroke-width: 1; }
.graph .curve { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 900; stroke-dashoffset: 900; animation: draw 1.6s 1s var(--ease) forwards; }
.graph .curve-ghost { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 6; opacity: .5; }
.graph .handle { stroke: var(--blue); stroke-width: 1.5; }
.graph .handle-dot { fill: #fff; stroke: var(--blue); stroke-width: 2; }
.graph .key { fill: var(--accent); }
.graph .label { font: 500 11px var(--mono); fill: var(--ink-3); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.graph .ball {
  offset-path: path("M60 250 C 200 250, 230 70, 380 70 S 520 190, 560 190");
  offset-rotate: 0deg;
  animation: travel 3.6s 2.2s cubic-bezier(.65, 0, .35, 1) infinite alternate both;
}
@keyframes travel { from { offset-distance: 0%; } to { offset-distance: 100%; } }

/* Timeline strip */
.timeline {
  border-top: 1px solid var(--line); background: #fff; position: relative;
  opacity: 0; animation: fade .8s 1s var(--ease) forwards; direction: ltr;
}
.tl-inner { --namew: 150px; position: relative; display: grid; grid-template-columns: var(--namew) 1fr; font: 500 12px/1 var(--mono); color: var(--ink-3); }
.tl-ruler, .tl-row { display: contents; }
.tl-name { padding: 9px 0; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-name b { color: var(--ink); font-weight: 600; }
.tl-track { position: relative; border-bottom: 1px solid var(--line); }
.tl-ticks { background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 10%); }
.tl-ticks span { position: absolute; top: 9px; font-size: 11px; }
.bar { position: absolute; top: 7px; bottom: 7px; border-radius: 4px; opacity: .9; }
.bar::before, .bar::after { content: ""; position: absolute; top: 50%; width: 9px; height: 9px; background: #fff; border: 2px solid var(--ink); transform: translate(-50%, -50%) rotate(45deg); }
.bar::before { left: 0; }
.bar::after { left: 100%; }
.tl-overlay { position: absolute; top: 0; bottom: 0; left: var(--namew); right: 0; pointer-events: none; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; left: 0; will-change: transform; }
.playhead::before { content: ""; position: absolute; top: 0; left: -6px; border: 7px solid transparent; border-top: 9px solid var(--accent); }
.tc { color: var(--accent); font-weight: 600; }

/* ---------- Sections ---------- */
.section { padding-block: clamp(80px, 11vw, 140px); }
.section + .section { padding-top: 0; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 13px/1 var(--mono); color: var(--ink-3); direction: ltr;
}
.eyebrow::before { content: ""; width: 9px; height: 9px; background: var(--accent); transform: rotate(45deg); border-radius: 1px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 32px; margin-bottom: 40px; flex-wrap: wrap; }
.section-head h2 { margin: 12px 0 0; font: 700 clamp(36px, 5vw, 64px)/1 var(--display); letter-spacing: -.035em; }
[lang="ar"] .section-head h2 { letter-spacing: 0; line-height: 1.25; }
.section-head p { max-width: 420px; color: var(--ink-2); margin: 0; }

.reveal { opacity: 0; transform: translateY(24px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Work ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px 24px; }
.card { display: block; cursor: pointer; }
.card.featured { grid-column: span 2; grid-row: span 2; }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: var(--paper); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.card:hover .thumb img { transform: scale(1.05); }
.thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.35)); }
.play {
  position: absolute; z-index: 2; inset-inline-start: 16px; bottom: 16px;
  width: 52px; height: 52px; border-radius: 50%; background: #fff; display: grid; place-items: center;
  transition: transform .35s var(--ease), background .25s;
}
.featured .play { width: 72px; height: 72px; }
.play svg { width: 20px; height: 20px; fill: var(--ink); margin-inline-start: 3px; transition: fill .25s; }
[dir="rtl"] .play svg { transform: none; }
.card:hover .play { transform: scale(1.1); background: var(--accent); }
.card:hover .play svg { fill: #fff; }
.dur {
  position: absolute; z-index: 2; inset-inline-end: 12px; bottom: 14px;
  font: 600 12px/1 var(--mono); color: #fff; background: rgba(0,0,0,.55); padding: 6px 8px; border-radius: 6px; direction: ltr;
}
.card-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; align-items: baseline; }
.card-title { margin: 0; font: 600 19px/1.3 var(--display); letter-spacing: -.01em; }
.featured .card-title { font-size: clamp(22px, 2.4vw, 30px); }
[lang="ar"] .card-title { letter-spacing: 0; }
.card-sub { margin: 4px 0 0; font-size: 15px; color: var(--ink-3); }
.tag {
  flex: none; font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em;
  padding: 6px 9px; border-radius: 999px; background: var(--accent-soft); color: #b8320f; white-space: nowrap;
}
[lang="ar"] .tag { font-family: var(--body); letter-spacing: 0; font-size: 12px; text-transform: none; }
.tag.alt { background: #e6ecff; color: #1d3fc4; }

/* ---------- Career ---------- */
.career { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; direction: ltr; }
.career-ruler, .career-row { display: grid; grid-template-columns: 300px 1fr; }
.career-ruler { background: var(--paper); border-bottom: 1px solid var(--line); font: 500 12px/1 var(--mono); color: var(--ink-3); }
.career-ruler > div:first-child { padding: 14px 20px; }
.years { position: relative; display: grid; grid-template-columns: repeat(10, 1fr); }
.years span { padding: 14px 0 14px 8px; border-inline-start: 1px solid var(--line); }
.career-row { border-bottom: 1px solid var(--line); }
.career-row:last-child { border-bottom: 0; }
.career-info { padding: 18px 20px; }
.career-info h3 { margin: 0; font: 600 18px/1.25 var(--display); }
.career-info p { margin: 4px 0 0; font-size: 14px; color: var(--ink-3); }
.career-years { display: none; font: 600 12px/1 var(--mono); color: var(--ink); margin-top: 8px; direction: ltr; }
.career-track { position: relative; background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 10%); }
.career-bar {
  position: absolute; top: 50%; height: 34px; transform: translateY(-50%) scaleX(0); transform-origin: left;
  border-radius: 6px; display: flex; align-items: center; padding-inline: 12px;
  font: 600 12px/1 var(--mono); color: #fff; white-space: nowrap;
  transition: transform 1.1s var(--ease);
}
.career.in .career-bar { transform: translateY(-50%) scaleX(1); }
.career-bar::before, .career-bar::after { content: ""; position: absolute; top: 50%; width: 10px; height: 10px; background: #fff; border: 2px solid var(--ink); transform: translate(-50%, -50%) rotate(45deg); }
.career-bar::before { left: 0; }
.career-bar::after { left: 100%; }
[dir="rtl"] .career-info { direction: rtl; text-align: right; }

/* ---------- Clients ---------- */
.clients { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); border-top: 1px solid var(--line); border-inline-start: 1px solid var(--line); list-style: none; padding: 0; margin: 0; }
.client {
  border-bottom: 1px solid var(--line); border-inline-end: 1px solid var(--line);
  padding: 26px 18px 18px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center;
  transition: background .3s;
}
.client:hover { background: var(--paper); }
.logo { height: 64px; width: 100%; display: grid; place-items: center; }
.logo img { max-height: 64px; max-width: 150px; object-fit: contain; filter: grayscale(1); opacity: .75; transition: filter .35s, opacity .35s; }
.logo img.wide { max-height: 34px; }
.client:hover .logo img { filter: none; opacity: 1; }
.wordmark { font: 800 20px/1.1 var(--display); letter-spacing: -.02em; color: var(--ink-2); }
.wordmark.ar { font-family: "Readex Pro", sans-serif; letter-spacing: 0; font-weight: 700; }
.client-name { font-size: 14px; line-height: 1.35; color: var(--ink-2); }
.client-type { display: block; font: 500 11px/1 var(--mono); color: var(--ink-3); margin-top: 6px; text-transform: uppercase; letter-spacing: .06em; }
[lang="ar"] .client-type { font-family: var(--body); letter-spacing: 0; text-transform: none; font-size: 12px; }

/* ---------- Services ---------- */
.services { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0; border-top: 1px solid var(--ink); }
.services > div { padding: 28px 28px 32px 0; border-bottom: 1px solid var(--line); }
[dir="rtl"] .services > div { padding: 28px 0 32px 28px; }
.services dt { display: flex; align-items: center; gap: 12px; font: 600 20px/1.3 var(--display); }
.services dt span { font: 500 12px/1 var(--mono); color: var(--accent); }
.services dd { margin: 10px 0 0; color: var(--ink-2); font-size: 16px; }

/* ---------- Tools ---------- */
.tools { display: flex; flex-wrap: wrap; gap: 12px; }
.tool {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px 14px 14px; border: 1px solid var(--line); border-radius: 14px;
}
[dir="rtl"] .tool { padding: 14px 14px 14px 20px; }
.tool i { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font: 700 16px/1 var(--display); font-style: normal; direction: ltr; }
.tool b { display: block; font-weight: 600; }
.tool small { color: var(--ink-3); font-size: 14px; }

/* ---------- Contact ---------- */
.contact { background: var(--ink); color: #fff; border-radius: 28px; padding: clamp(40px, 7vw, 96px); position: relative; overflow: hidden; }
.contact h2 { margin: 16px 0 18px; font: 800 clamp(40px, 7vw, 104px)/.95 var(--display); letter-spacing: -.045em; max-width: 12ch; }
[lang="ar"] .contact h2 { letter-spacing: 0; line-height: 1.2; }
.contact h2 em { font-style: normal; color: var(--accent); }
.contact p { color: #b7b7b3; max-width: 520px; margin: 0 0 32px; }
.contact .eyebrow { color: #9a9a96; }
.contact .button { border-color: #fff; }
.contact .button-dark { background: #fff; color: var(--ink); }
.contact .button-dark:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.contact-list { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 36px; font-size: 15px; color: #b7b7b3; }
.contact-list a:hover { color: #fff; }
.contact-art { position: absolute; inset-inline-end: -40px; bottom: -40px; width: 380px; opacity: .9; pointer-events: none; direction: ltr; }
[dir="rtl"] .contact-art { transform: scaleX(-1); }
.contact-art path { fill: none; stroke: var(--accent); stroke-width: 3; }
.contact-art .k { fill: var(--accent); }

footer { padding-block: 36px 48px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--ink-3); }

/* ---------- Player ---------- */
dialog.player {
  width: min(1100px, 94vw); max-width: none; padding: 0; border: 0; background: transparent; overflow: visible;
}
dialog.player::backdrop { background: rgba(10,10,10,.88); backdrop-filter: blur(4px); }
.player-frame { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 14px; overflow: hidden; }
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 4px 0; color: #fff; }
.player-title { font: 600 17px/1.3 var(--display); }
.player-links { display: flex; gap: 10px; flex: none; }
.player-links a, .player-links button { border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 8px 14px; font-size: 14px; color: #fff; }
.player-links a:hover, .player-links button:hover { background: #fff; color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .card.featured { grid-row: auto; }
  .services { grid-template-columns: repeat(2, 1fr); }
  .career-ruler, .career-row { grid-template-columns: 220px 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  :root { --wrap: calc(100% - 36px); }
  .nav nav a:not(.lang) { display: none; }
  .hero-main { grid-template-columns: 1fr; padding-block: 20px; }
  .hero h1 { font-size: clamp(48px, 15.5vw, 120px); }
  [lang="ar"] .hero h1 { font-size: clamp(48px, 15vw, 120px); }
  .graph { min-height: 230px; order: 3; }
  .graph-head span:last-child { display: none; }
  .tl-ticks span:nth-child(even) { display: none; }
  .featured .play { width: 56px; height: 56px; }
  .career-years { display: block; }
  .career-bar { font-size: 0; padding: 0; height: 14px; }
  .career-track { height: 40px; }
  .tl-inner { --namew: 96px; }
  .tl-row:nth-of-type(n+4) { display: none; }
  .grid { grid-template-columns: 1fr; gap: 32px; }
  .card.featured { grid-column: auto; }
  .services { grid-template-columns: 1fr; }
  .services > div, [dir="rtl"] .services > div { padding: 22px 0; }
  .career { border: 0; border-radius: 0; }
  .career-ruler { display: none; }
  .career-row { grid-template-columns: 1fr; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; }
  .career-row:last-child { border-bottom: 1px solid var(--line); }
  .clients { grid-template-columns: repeat(2, 1fr); }
  .client { padding: 22px 12px 16px; }
  .contact { border-radius: 20px; }
  .contact-art { width: 220px; opacity: .5; }
  .contact .actions .button { flex: 1 1 100%; justify-content: center; }

  dialog.player { width: 100vw; height: 100dvh; max-height: none; margin: 0; }
  dialog.player[open] { display: flex; flex-direction: column; justify-content: center; background: #000; }
  dialog.player::backdrop { background: #000; }
  .player-frame { border-radius: 0; }
  .player-bar { padding: 14px 16px; flex-direction: column; align-items: stretch; }
  .player-links { justify-content: stretch; }
  .player-links > * { flex: 1; text-align: center; padding: 12px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  dialog.player { width: 100vw; height: 100dvh; max-height: none; margin: 0; background: #000; }
  dialog.player[open] { display: flex; flex-direction: column; justify-content: center; align-items: center; }
  .player-frame { height: 100dvh; width: auto; border-radius: 0; }
  .player-bar { position: absolute; top: 8px; inset-inline-end: 8px; padding: 0; }
  .player-title, .player-links a { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .hero h1 .ch, .hero-copy, .graph, .timeline { opacity: 1; transform: none; }
  .graph .curve { stroke-dashoffset: 0; }
  .graph .ball { animation: none; offset-distance: 60%; }
  .reveal { opacity: 1; transform: none; }
}
