@font-face {
  font-family: "Ali Hand";
  src: url("/assets/fonts/AliHandwrittenArabic.otf") format("opentype");
  font-display: swap;
}

:root {
  /* colours lifted from the paintings */
  --paper: #ece3d1;
  --paper-2: #e3d8c2;
  --ink: #1d1813;
  --ink-soft: #4a4036;
  --red: #c9272b;
  --cobalt: #2c4ea3;
  --orange: #e48a24;
  --olive: #6f7a2b;
  --sky: #6ea2d4;
  --pink: #e07893;
  --night: #0d0b09;

  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --text: "Newsreader", Georgia, serif;
  --hand: "Ali Hand", "Geeza Pro", serif;

  --gutter: clamp(16px, 4vw, 56px);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
.still html, html.still { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 clamp(17px, 1.15vw + 10px, 21px)/1.5 var(--text);
  overflow-x: hidden;
}
/* paper tooth over everything */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .22 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}
img, video, canvas { display: block; max-width: 100%; }
a { color: inherit; }
[lang="ar"] { font-family: var(--hand); font-style: normal; }
.defs { position: absolute; width: 0; height: 0; }
.boil { filter: url(#boil); }
.still .boil { filter: none; }

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

/* ─── cursor trail ─── */
#trail {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 40;
  mix-blend-mode: multiply;
}

/* ─── top bar ─── */
.bar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--gutter);
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}
.bar a { pointer-events: auto; text-decoration: none; }
.mark { font-size: 34px; line-height: 1; }
.bar nav { display: flex; gap: clamp(12px, 2.2vw, 30px); font: 500 15px/1 var(--display); }
.bar nav a { position: relative; padding: 4px 0; }
.bar nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: currentColor; transform: scaleX(0); transform-origin: right;
  transition: transform .35s cubic-bezier(.6,.1,.2,1);
}
.bar nav a:hover::after { transform: scaleX(1); transform-origin: left; }
@media (max-width: 640px) {
  .bar nav a:nth-child(n+4) { display: none; }
}

/* ─── shared heads ─── */
.head {
  position: relative;
  display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
  margin: 0 0 clamp(28px, 4vw, 56px);
}
.head h2, .hello h2 {
  margin: 0;
  font: 800 clamp(48px, 8vw, 128px)/.9 var(--display);
  font-variation-settings: "wdth" 78, "opsz" 96;
  letter-spacing: -.035em;
}
.ar-label {
  font-size: clamp(30px, 4vw, 56px);
  color: var(--red);
  transform: rotate(-4deg) translateY(-.2em);
}
.scribble {
  position: absolute; left: -1%; bottom: -14px;
  width: min(520px, 70%); height: 26px;
  overflow: visible; z-index: -1;
  filter: url(#rough);
}
.scribble path {
  fill: none; stroke: var(--orange); stroke-width: 16; stroke-linecap: round;
  opacity: .85;
  stroke-dasharray: 700; stroke-dashoffset: 700;
  transition: stroke-dashoffset 1.1s cubic-bezier(.7,0,.2,1) .15s;
}
.in .scribble path, .still .scribble path { stroke-dashoffset: 0; }
#paper .scribble path { stroke: var(--sky); }
#code .scribble path { stroke: var(--pink); }

section { position: relative; padding: clamp(80px, 12vw, 180px) var(--gutter); }

/* ─── art figures: <img> is the truth, <canvas> paints it in ─── */
.art { position: relative; margin: 0; }
.art img { width: 100%; height: auto; }
.art canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.js .art img { opacity: 0; transition: opacity .6s; }
.js .art.done img { opacity: 1; }
.js .art.done canvas { opacity: 0; transition: opacity .6s .1s; }
.art.cut img { filter: drop-shadow(0 10px 14px rgba(40, 25, 10, .18)); }

/* ─── hero ─── */
.hero {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: 2vw;
  padding-top: 90px; padding-bottom: 90px;
  isolation: isolate;
}
.hero-paint { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.kicker { margin: 0 0 18px; font-style: italic; color: var(--ink-soft); }
.kicker span { font-style: normal; margin-left: .5em; font-size: 1.25em; color: var(--ink); }
.name {
  margin: 0;
  font: 800 clamp(84px, 15.5vw, 250px)/.8 var(--display);
  font-variation-settings: "wdth" 75, "opsz" 96;
  letter-spacing: -.045em;
  text-transform: uppercase;
}
.ar-name {
  margin: .1em 0 0;
  font-size: clamp(54px, 7.5vw, 120px);
  line-height: 1;
  color: var(--red);
  width: max-content;
  transform: rotate(-3deg);
}
.js .ar-name { clip-path: inset(0 0 0 100%); animation: write 1.6s cubic-bezier(.5,0,.2,1) 1.1s forwards; }
@keyframes write { to { clip-path: inset(0 0 0 0); } }  /* reveals right → left, the way it's written */
.lede { max-width: 30ch; margin: 28px 0 0; font-size: clamp(19px, 1.5vw + 8px, 26px); line-height: 1.35; }
.hero-face { width: min(100%, 640px); justify-self: center; transform-origin: 50% 80%; }
.cue {
  position: absolute; left: var(--gutter); bottom: 22px; margin: 0;
  font-size: 15px; font-style: italic; color: var(--ink-soft);
}
.cue span { display: inline-block; animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(5px); } }
.cue i { font-size: 1.3em; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 110px; }
  .hero-face { width: 82%; margin-top: 44px; }
}

/* ─── faces ─── */
.faces-text { columns: 2 300px; column-gap: 48px; max-width: 980px; }
.faces-text p { margin: 0 0 1em; break-inside: avoid; }
.face-wall {
  position: relative;
  height: clamp(700px, 78vw, 1200px);
  margin-top: 40px;
}
.face { position: absolute; }
.face figcaption {
  margin-top: 6px; font-style: italic; font-size: 15px; color: var(--ink-soft);
}
.face img { transition: transform .5s cubic-bezier(.3,1.6,.5,1); }
.face:hover img { transform: rotate(var(--tilt, 3deg)) scale(1.04); }
.f1 { left: 2%;  top: 6%;  width: 30%; --tilt: -4deg; }
.f2 { left: 38%; top: 0;   width: 22%; --tilt: 5deg; }
.f3 { left: 68%; top: 12%; width: 26%; --tilt: -3deg; }
.f4 { left: 26%; top: 54%; width: 17%; --tilt: 6deg; }
.f5 { left: 52%; top: 58%; width: 24%; transform: rotate(2.5deg); }
.f5 img { box-shadow: 0 14px 30px -12px rgba(40,25,10,.4); }
@media (max-width: 700px) {
  .face-wall { height: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 28px 18px; }
  .face { position: relative; inset: auto; width: auto; }
  .f3 { grid-row: span 2; }
}

/* ─── works wall ─── */
.paper { background: var(--paper-2); }
.paper-note { max-width: 46ch; margin: 0 0 56px; font-style: italic; color: var(--ink-soft); }
.wall {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(28px, 4vw, 64px) clamp(14px, 2vw, 32px);
  align-items: start;
}
.work {
  cursor: zoom-in;
  transform: translateY(var(--y, 0)) rotate(var(--r, 0deg));
}
.work .frame { position: relative; }
.work:not(.cut) .frame { padding: 0; box-shadow: 0 18px 30px -18px rgba(40,25,10,.55); }
.work.tape .frame::before {
  content: ""; position: absolute; z-index: 2;
  top: -12px; left: 50%; width: 92px; height: 26px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(240, 228, 196, .78);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.work figcaption { margin-top: 12px; font-size: 15px; line-height: 1.3; }
.work figcaption b { display: block; font: 600 17px/1.2 var(--display); font-variation-settings: "wdth" 85; }
.work figcaption span { font-style: italic; color: var(--ink-soft); }
.work img { transition: transform .45s cubic-bezier(.3,1.4,.5,1); }
.work:hover img { transform: scale(1.025) rotate(calc(var(--r, 0deg) * -.4)); }
.work:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 6px; }
@media (max-width: 760px) {
  .wall { grid-template-columns: 1fr 1fr; }
  .work { grid-column: auto !important; --y: 0 !important; }
  .work.wide { grid-column: 1 / -1 !important; }
}

/* ─── ma fi shi ─── */
.mafishi {
  background: var(--night);
  color: #efe6d3;
}
.mafishi ::selection { background: var(--red); color: #fff; }
.game-head { text-align: center; margin-bottom: clamp(50px, 7vw, 100px); }
.game-title { width: min(720px, 90%); margin: 0 auto; }
.game-sub { margin: 10px 0 0; font-style: italic; color: #b7ab95; }
.game-sub b { font: 700 1.1em var(--display); font-style: normal; color: #efe6d3; }
.game-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 300px);
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
  max-width: 1300px; margin: 0 auto;
}
.game-intro blockquote { margin: 0; font-size: clamp(22px, 1.6vw + 10px, 32px); line-height: 1.3; }
.game-intro blockquote p { margin: 0; }
.game-intro blockquote p::first-letter { color: var(--orange); }
.game-intro > p { margin: 0; color: #cfc4ae; }
.reel { margin: 0; }
.reel video { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; background: #1a1612; border-radius: 3px; }
.reel figcaption { margin-top: 8px; font-size: 14px; font-style: italic; color: #8f846f; }
@media (max-width: 960px) {
  .game-intro { grid-template-columns: 1fr; }
  .reel { max-width: 320px; }
}

.blackout {
  position: relative;
  margin: clamp(80px, 10vw, 150px) calc(var(--gutter) * -1) 0;
  overflow: hidden;
  touch-action: pan-y;
  --x: 50%; --y: 50%; --r: 220px;
}
.stills { display: grid; grid-template-columns: repeat(6, 1fr); }
.stills img { width: 100%; aspect-ratio: 9 / 15; object-fit: cover; }
.dark {
  position: absolute; inset: 0;
  background: var(--night);
  -webkit-mask-image: radial-gradient(circle var(--r) at var(--x) var(--y), transparent 0, transparent 30%, rgba(0,0,0,.75) 72%, #000 100%);
          mask-image: radial-gradient(circle var(--r) at var(--x) var(--y), transparent 0, transparent 30%, rgba(0,0,0,.75) 72%, #000 100%);
}
.still .dark { opacity: .35; -webkit-mask-image: none; mask-image: none; }
.blackout-label {
  position: absolute; left: var(--gutter); bottom: 18px; margin: 0;
  font-style: italic; color: #8f846f; pointer-events: none;
}
.blackout-label span { color: #efe6d3; font-style: normal; font-family: var(--display); font-weight: 700; }
@media (max-width: 700px) {
  .stills { grid-template-columns: repeat(3, 1fr); }
}

.under { max-width: 1100px; margin: clamp(70px, 9vw, 130px) auto 0; }
.under h3 {
  margin: 0 0 24px;
  font: 700 clamp(26px, 2.6vw, 38px)/1 var(--display);
  font-variation-settings: "wdth" 85;
}
.under ul { list-style: none; padding: 0; margin: 0; columns: 2 320px; column-gap: 56px; }
.under li { break-inside: avoid; margin: 0 0 20px; color: #cfc4ae; }
.under li b { color: #efe6d3; font-weight: 500; }
.follow {
  display: inline-block; margin-top: 26px;
  font: 600 20px/1 var(--display);
  color: var(--orange); text-decoration: none;
  border-bottom: 2px solid currentColor; padding-bottom: 6px;
}
.follow span { display: inline-block; transition: transform .3s; }
.follow:hover span { transform: translateX(6px); }

/* ─── code ─── */
.projects { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.projects li { border-bottom: 1px solid rgba(29,24,19,.25); }
.projects a {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) auto;
  gap: 20px; align-items: baseline;
  padding: 22px 4px;
  text-decoration: none;
  isolation: isolate;
}
.projects a::before {
  /* a pastel swipe behind the row on hover */
  content: ""; position: absolute; inset: 8px -8px; z-index: -1;
  background: var(--pink);
  filter: url(#rough);
  opacity: .8;
  clip-path: inset(0 100% 0 0);
  transition: clip-path .5s cubic-bezier(.6,.1,.2,1);
}
.projects li:nth-child(2) a::before { background: var(--sky); }
.projects li:nth-child(3) a::before { background: var(--orange); }
.projects li:nth-child(4) a::before { background: #b9c26a; }
.projects a:hover::before, .projects a:focus-visible::before { clip-path: inset(0 0 0 0); }
.p-name { font: 700 clamp(24px, 2.6vw, 40px)/1.05 var(--display); font-variation-settings: "wdth" 82; letter-spacing: -.02em; }
.p-what { font-style: italic; color: var(--ink-soft); }
.p-year { font: 500 15px/1 var(--display); }
@media (max-width: 700px) {
  .projects a { grid-template-columns: 1fr auto; }
  .p-what { grid-column: 1 / -1; grid-row: 2; }
}

/* ─── hello ─── */
.hello { text-align: center; padding-bottom: 40px; isolation: isolate; overflow: hidden; }
.hello-paint { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.hello-ar { margin: 0; font-size: clamp(70px, 11vw, 170px); line-height: 1; color: var(--red); }
.hello h2 { font-size: clamp(60px, 11vw, 180px); }
.links { list-style: none; padding: 0; margin: 50px 0 120px; display: flex; justify-content: center; gap: clamp(20px, 5vw, 80px); flex-wrap: wrap; }
.links a { font: 700 clamp(22px, 2.4vw, 32px)/1 var(--display); text-decoration: none; }
.links a span { display: block; margin-top: 8px; font: italic 400 16px var(--text); color: var(--ink-soft); }
.links a:hover { color: var(--cobalt); }
.hello footer { font-size: 14px; font-style: italic; color: var(--ink-soft); }

/* ─── lightbox ─── */
#lightbox {
  border: 0; padding: 0; background: transparent;
  max-width: min(92vw, 1100px); max-height: 92vh;
  overflow: visible;
}
#lightbox::backdrop { background: rgba(236, 227, 209, .94); }
#lightbox img { max-width: min(92vw, 1100px); max-height: 80vh; width: auto; margin: 0 auto; box-shadow: 0 30px 60px -20px rgba(40,25,10,.5); }
#lightbox .lb-cap { text-align: center; margin: 14px 0 0; color: var(--ink); }
#lightbox .lb-cap b { font-family: var(--display); }
.lb-close {
  position: fixed; top: 16px; right: 20px;
  width: 48px; height: 48px; border: 0; background: none;
  font: 300 44px/1 var(--display); color: var(--ink); cursor: pointer;
}
#lightbox[open] img { animation: lb-in .45s cubic-bezier(.3,1.3,.5,1); }
@keyframes lb-in { from { transform: scale(.94) rotate(-1.5deg); opacity: 0; } }
.js .work:not(.done) .frame { box-shadow: none; }
.js .work:not(.done) .frame::before { opacity: 0; }
.work .frame::before { transition: opacity .5s .3s; }
