/* =========================================================
   Abdalrahman Saad — portfolio
   Monochrome gallery: black archive, warm grey project sheets.
   Only motion: tiles brighten on hover; video tiles play on hover.
   ========================================================= */

:root {
  --black: #0a0a0a;
  --white: #ecebe6;
  --grey: #85847f;
  --line: #262625;
  --tile: #141413;

  --paper: #c8c6bf;       /* project page sheet */
  --ink: #121211;
  --paper-line: #a6a49d;
  --paper-grey: #55544f;

  --serif: "Instrument Serif", "Times New Roman", Times, serif;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* header colours, swapped on project pages */
  --chrome-bg: var(--black);
  --chrome-fg: var(--white);
  --chrome-dim: var(--grey);
  --chrome-line: var(--line);

  color-scheme: dark;
}

body.page-project {
  --chrome-bg: var(--paper);
  --chrome-fg: var(--ink);
  --chrome-dim: var(--paper-grey);
  --chrome-line: var(--paper-line);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { background: var(--black); }
body {
  margin: 0;
  color: var(--white);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a:focus-visible, button:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

.gut {
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--chrome-bg); color: var(--chrome-fg);
  border-bottom: 1px solid var(--chrome-line);
}
.site-header .bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px 28px; flex-wrap: wrap; padding-block: 14px;
}
.brand { display: flex; align-items: center; gap: 22px; }
.back { font-size: 12px; }
.wordmark {
  font-weight: 700; font-size: 15px; line-height: .95;
  letter-spacing: -.01em; text-transform: uppercase;
}
.wordmark span { display: block; }
.tagline { font-size: 11px; line-height: 1.2; color: var(--chrome-dim); max-width: 9em; }
.site-nav { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 12px; }
.site-nav a { padding-bottom: 3px; border-bottom: 1px solid transparent; }
.site-nav a:hover { border-bottom-color: var(--chrome-dim); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--chrome-fg); }

/* ---------- archive: name intro ---------- */
.intro {
  position: relative; height: min(88vh, 860px); min-height: 540px;
  overflow: hidden; border-bottom: 1px solid var(--line);
}
.intro .name {
  margin: 0; font-family: var(--serif); font-weight: 400;
  line-height: .8; letter-spacing: -.035em;
  font-size: clamp(64px, 12.5vw, 200px);
  color: var(--white);
}
.intro .first, .intro .last { position: absolute; z-index: 2; display: block; }
.intro .first { left: max(20px, env(safe-area-inset-left, 0px)); top: 30%; }
.intro .last { right: max(20px, env(safe-area-inset-right, 0px)); top: 56%; }
.intro .role {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 2; font-size: 12px; white-space: nowrap;
}
.scatter { position: absolute; z-index: 1; margin: 0; overflow: hidden; background: var(--tile); }
.scatter img { display: block; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) brightness(.62); }
.s1 { width: 14%; aspect-ratio: 3/2; left: 40%; top: 8%;  transform: rotate(-2deg); }
.s2 { width: 15%; aspect-ratio: 3/2; left: 70%; top: 14%; transform: rotate(3deg); }
.s3 { width: 12%; aspect-ratio: 3/2; left: 10%; top: 9%;  transform: rotate(5deg); }
.s4 { width: 13%; aspect-ratio: 3/2; left: 4%;  top: 68%; transform: rotate(-4deg); }
.s5 { width: 12%; aspect-ratio: 3/2; left: 22%; top: 80%; transform: rotate(1deg); }
.s6 { width: 14%; aspect-ratio: 3/2; left: 46%; top: 74%; transform: rotate(-3deg); }
.s7 { width: 9%;  aspect-ratio: 1/1; left: 88%; top: 36%; transform: rotate(4deg); }
.intro .hint {
  position: absolute; left: max(20px, env(safe-area-inset-left, 0px)); bottom: 18px;
  font-size: 11px; color: var(--grey); text-transform: uppercase; letter-spacing: .04em;
}

/* ---------- archive: wall + index ---------- */
.archive { display: grid; grid-template-columns: minmax(0, 1fr) 260px; }
.sections { padding: 0 max(20px, env(safe-area-inset-left, 0px)) 40px; min-width: 0; }
.work-section { padding-top: 56px; }
.work-section[hidden] { display: none; }
.section-head {
  display: flex; align-items: baseline; gap: 8px 20px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid var(--line);
}
.section-head h2 {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: clamp(40px, 5vw, 72px); line-height: .9; letter-spacing: -.02em;
}
.section-head .sub { font-size: 12px; color: var(--grey); }
.section-head .n { margin-left: auto; font-size: 12px; color: var(--grey); font-variant-numeric: tabular-nums; }
.wall { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.tile {
  display: block; position: relative; aspect-ratio: 16/10; overflow: hidden;
  background: var(--tile); border-radius: 3px;
}
.tile.wide { grid-column: span 2; aspect-ratio: auto; }
.tile.wide img { position: absolute; inset: 0; }
.tile .play {
  position: absolute; left: 12px; bottom: 10px; font-size: 10px; color: var(--white);
  opacity: .75; pointer-events: none;
}
.tile[hidden] { display: none; }
.tile img, .tile video {
  display: block; width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(1) brightness(.6); transition: filter .2s ease;
}
.tile:hover img, .tile:hover video, .tile:focus-visible img, .tile:focus-visible video,
.tile.is-on img, .tile.is-on video { filter: grayscale(1) brightness(1); }

.placeholder-grid {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: var(--grey); font-size: 11px;
  background-image:
    linear-gradient(#222221 1px, transparent 1px),
    linear-gradient(90deg, #222221 1px, transparent 1px);
  background-size: 24px 24px;
}
.tile:hover .placeholder-grid, .tile.is-on .placeholder-grid { color: var(--white); }

.index { border-left: 1px solid var(--line); padding: 28px max(20px, env(safe-area-inset-right, 0px)) 40px 18px; }
.index ol { list-style: none; margin: 0; padding: 0; position: sticky; top: 84px; }
.index li[hidden] { display: none; }
.index li.group { font-size: 11px; color: var(--white); padding: 14px 0 4px; }
.index li.group:first-child { padding-top: 0; }
.index a { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; padding-block: 4px; color: var(--grey); }
.index a:hover, .index a.is-on { color: var(--white); }
.index .yr { font-variant-numeric: tabular-nums; white-space: nowrap; }

.bottombar {
  position: sticky; bottom: 0; z-index: 10;
  background: linear-gradient(to top, var(--black) 62%, rgba(10, 10, 10, 0));
  padding-top: 30px; padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}
.bottombar .now { text-align: center; font-size: 12px; min-height: 18px; margin-bottom: 8px; }
.bottombar .row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.bottombar .left { font-size: 11px; color: var(--grey); text-transform: uppercase; letter-spacing: .04em; }
.filters { display: flex; gap: 18px; font-size: 12px; flex-wrap: wrap; justify-content: center; }
.filters button { color: var(--grey); padding-bottom: 3px; border-bottom: 1px solid transparent; }
.filters button:hover { color: var(--white); }
.filters button[aria-pressed="true"] { color: var(--white); border-bottom-color: var(--white); }
.bottombar .count { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- project pages ---------- */
.sheet { background: var(--paper); color: var(--ink); }
.meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 24px; margin: 0; padding-top: 22px; }
.meta div { padding-block: 10px; border-bottom: 1px solid var(--paper-line); }
.meta dt { font-size: 11px; color: var(--paper-grey); margin: 0 0 3px; }
.meta dd { margin: 0; font-size: 13px; }
.ptitle {
  margin: 0; padding-block: 64px 36px;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(60px, 11vw, 176px); line-height: .86; letter-spacing: -.035em;
  text-wrap: balance;
}
.lede { margin: 0; padding-bottom: 40px; font-size: 17px; line-height: 1.45; max-width: 44ch; }

.plate { background: var(--black); padding-block: 24px; }
.plate .frame { max-width: 1400px; margin: 0 auto; }
.plate img, .plate video { display: block; width: 100%; height: auto; }
.plate.pair .frame { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.plate.pair img { aspect-ratio: 4/3; object-fit: cover; }
.plate .placeholder-grid { position: relative; aspect-ratio: 2.39/1; font-size: 12px; background-size: 28px 28px; }

.section {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 12px 40px; padding-block: 72px; border-bottom: 1px solid var(--paper-line);
}
.section:last-of-type { border-bottom: 0; }
.section h2 { margin: 0; font-size: 12px; font-weight: 400; padding-left: 22%; }
.section .txt { font-family: var(--serif); font-size: 22px; line-height: 1.35; max-width: 30em; }
.section .txt p { margin: 0; }
.section .txt p + p { margin-top: 14px; }
.params { display: grid; max-width: 420px; margin: 0; font-family: var(--sans); font-size: 13px; }
.params div { display: flex; justify-content: space-between; gap: 16px; padding-block: 8px; border-bottom: 1px solid var(--paper-line); }
.params dt, .params dd { margin: 0; }
.params dd { color: var(--paper-grey); }
.draft { display: block; margin-top: 14px; font-family: var(--sans); font-size: 11px; color: var(--paper-grey); }
.next-project {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap;
  padding-block: 28px 40px; border-top: 1px solid var(--paper-line);
}
.next-project span { font-size: 12px; color: var(--paper-grey); }
.next-project a { font-family: var(--serif); font-size: 34px; line-height: 1; }
.next-project a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }

/* ---------- about & notes ---------- */
.bigname { padding-block: 64px 40px; border-bottom: 1px solid var(--line); overflow: hidden; }
.bigname .portrait { width: min(300px, 56vw); aspect-ratio: 1/1; margin: 0 auto; overflow: hidden; background: var(--tile); }
.bigname .portrait img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) brightness(.85); }
.bigname h1 {
  margin: -56px 0 0; position: relative;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(64px, 12.5vw, 200px); line-height: .8; letter-spacing: -.035em;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 24px;
}
.bigname h1 span:last-child { margin-top: .62em; margin-left: auto; }

.pagehead { padding-block: 72px 48px; border-bottom: 1px solid var(--line); }
.pagehead h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(64px, 11vw, 160px); line-height: .86; letter-spacing: -.03em; }

.dsec {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 12px 40px; padding-block: 64px; border-bottom: 1px solid var(--line);
}
.dsec h2 { margin: 0; font-size: 12px; font-weight: 400; }
.dsec .txt { font-family: var(--serif); font-size: 22px; line-height: 1.38; max-width: 30em; }
.dsec .txt.lead { font-size: clamp(24px, 2.6vw, 32px); line-height: 1.25; }
.dsec .txt p { margin: 0; }
.dsec .txt p + p { margin-top: 16px; }
.dsec .draft { color: var(--grey); }

.rows { max-width: 34em; font-size: 13px; }
.rows > div {
  display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 16px;
  padding-block: 11px; border-bottom: 1px solid var(--line); align-items: baseline;
}
.rows > div:first-child { border-top: 1px solid var(--line); }
.rows .k { color: var(--grey); }
.rows .v2 { color: var(--grey); text-align: right; }
.rows a:hover { text-decoration: underline; text-underline-offset: 4px; }
.copy { font-size: 11px; border: 1px solid var(--line); padding: 3px 10px; }
.copy:hover { border-color: var(--grey); }

.note {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 16px 40px; padding-block: 48px; border-bottom: 1px solid var(--line);
}
.note .thumb { position: relative; aspect-ratio: 3/2; max-width: 360px; overflow: hidden; background: var(--tile); border-radius: 3px; }
.note .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) brightness(.8); }
.note .k { display: block; font-size: 12px; color: var(--grey); margin-bottom: 12px; }
.note h2 { margin: 0 0 12px; font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.05; letter-spacing: -.01em; }
.note p { margin: 0; font-family: var(--serif); font-size: 20px; line-height: 1.38; max-width: 30em; color: #cfcdc7; }

/* ---------- drawings ---------- */
.drawings { columns: 3 280px; column-gap: 24px; padding-top: 40px; padding-bottom: 72px; }
.drawing { break-inside: avoid; margin: 0 0 32px; }
.drawing .open { display: block; width: 100%; cursor: zoom-in; background: var(--tile); border-radius: 3px; overflow: hidden; }
.drawing img { display: block; width: 100%; height: auto; filter: brightness(.82); transition: filter .2s ease; }
.drawing .open:hover img, .drawing .open:focus-visible img { filter: brightness(1); }
.drawing figcaption { display: flex; justify-content: space-between; gap: 12px; padding-top: 10px; font-size: 12px; }
.drawing .tag { color: var(--grey); text-align: right; }

.viewer { border: 0; padding: 0; background: transparent; max-width: 94vw; max-height: 94vh; color: var(--white); }
.viewer::backdrop { background: rgba(10, 10, 10, .94); }
.viewer img[hidden], .viewer video[hidden] { display: none; }
.viewer video { display: block; max-width: 94vw; max-height: calc(94vh - 44px); width: auto; margin: 0 auto; background: #000; }
.viewer img { display: block; max-width: 94vw; max-height: calc(94vh - 44px); width: auto; height: auto; margin: 0 auto; }
.viewer-bar { display: flex; justify-content: space-between; gap: 16px; padding-top: 12px; font-size: 12px; }
.viewer-bar button { border-bottom: 1px solid var(--grey); padding-bottom: 2px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); }
.site-footer .bar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 20px; font-size: 11px; color: var(--grey); }
body.page-project .site-footer { background: var(--paper); border-top-color: var(--paper-line); }
body.page-project .site-footer .bar { color: var(--paper-grey); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .archive { grid-template-columns: minmax(0, 1fr); }
  .index { display: none; }
  .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile.wide { grid-column: 1 / -1; aspect-ratio: 16/8; }
}
@media (max-width: 700px) {
  .tagline { display: none; }
  .intro {
    height: auto; min-height: 0; padding-block: 140px 120px;
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
  }
  .intro .name { font-size: 12.5vw; }
  .intro .first, .intro .last { position: relative; left: auto; right: auto; top: auto; }
  .intro .last { text-align: right; margin-top: .15em; }
  .intro .role { position: relative; left: auto; top: auto; transform: none; display: block; margin-top: 22px; }
  .s1, .s3, .s5, .s7 { display: none; }
  .s2 { left: 58%; top: 3%; width: 36%; }
  .s4 { left: 4%; top: 5%; width: 32%; }
  .s6 { left: 52%; top: auto; bottom: 30px; width: 38%; }
  .wall { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tile.wide { aspect-ratio: 16/10; }
  .work-section { padding-top: 40px; }
  .bottombar .row { grid-template-columns: 1fr auto; }
  .bottombar .left { display: none; }
  .filters { justify-content: flex-start; }
  .meta { grid-template-columns: minmax(0, 1fr); }
  .section, .dsec, .note { grid-template-columns: minmax(0, 1fr); padding-block: 44px; }
  .section h2 { padding-left: 0; }
  .plate.pair .frame { grid-template-columns: 1fr; gap: 12px; }
  .rows > div { grid-template-columns: 90px minmax(0, 1fr); }
  .rows .v2 { grid-column: 2; text-align: left; }
  .bigname h1 { margin-top: -28px; font-size: 12.5vw; }
}
@media (prefers-reduced-motion: reduce) {
  .tile img, .tile video, .drawing img { transition: none; }
}

/* =========================================================
   Intro animation (homepage hero)
   1. Load-in: images fade in and come into focus one after another;
      the name is revealed top to bottom.
   2. Depth: each image has a --depth (0 = far, 1 = near). Far images
      are dimmer and move less.
   3. Mouse + scroll parallax is driven by intro-preview.js.
   Everything is off for visitors who prefer reduced motion.
   ========================================================= */

.scatter { --depth: .6; --delay: 0s; will-change: translate; background: transparent; }
.s1 { --depth: .6;  --delay: .16s; }
.s2 { --depth: .35; --delay: .32s; }
.s3 { --depth: 1;   --delay: 0s;   }
.s4 { --depth: .8;  --delay: .24s; }
.s5 { --depth: .5;  --delay: .40s; }
.s6 { --depth: .9;  --delay: .08s; }
.s7 { --depth: .3;  --delay: .48s; }

/* Extra images (6 more: 3 x 3D, 3 x illustrations). Illustrations are
   portrait, smaller and set further back so the 3D work leads. */
.s8  { width: 7%;  left: 57%; top: 4%;  transform: rotate(3deg);  --depth: .4;  --delay: .56s; }
.s9  { width: 11%; aspect-ratio: 3/2; left: 64%; top: 80%; transform: rotate(-2deg); --depth: .7;  --delay: .20s; }
.s10 { width: 9%;  aspect-ratio: 3/2; left: 27%; top: 55%; transform: rotate(4deg);  --depth: .55; --delay: .36s; }
.s11 { width: 6%;  left: 26%; top: 2%;  transform: rotate(-4deg); --depth: .3;  --delay: .64s; }
.s12 { width: 9%;  aspect-ratio: 3/2; left: 87%; top: 5%;  transform: rotate(2deg);  --depth: .45; --delay: .44s; }
.s13 { width: 7%;  left: 68%; top: 38%; transform: rotate(-3deg); --depth: .5;  --delay: .52s; }
.scatter.portrait { aspect-ratio: 3/4; }
/* Drawings are on white paper, so they get extra dimming to sit behind the 3D work. */
.scatter.portrait img { filter: grayscale(1) brightness(calc(.22 + var(--depth) * .32)); }

/* Phones: keep the hero clean, extra images hidden. */
@media (max-width: 700px) {
  .s8, .s9, .s10, .s11, .s12, .s13 { display: none; }
}

/* Far images sit back: dimmer. Near images are brighter. */
.scatter img { filter: grayscale(1) brightness(calc(.38 + var(--depth) * .34)); }

/* ---- Load-in (only when the script has added .intro-anim) ---- */
html.intro-anim .scatter {
  animation: scatter-in 1.4s cubic-bezier(.2, .7, .2, 1) backwards;
  animation-delay: var(--delay);
}
@keyframes scatter-in {
  from { opacity: 0; scale: 1.08; filter: blur(10px); }
  to   { opacity: 1; scale: 1;    filter: blur(0); }
}

html.intro-anim .intro .name .first,
html.intro-anim .intro .name .last {
  animation: name-in 1.1s cubic-bezier(.2, .7, .2, 1) backwards;
}
html.intro-anim .intro .name .first { animation-delay: .2s; }
html.intro-anim .intro .name .last  { animation-delay: .38s; }
@keyframes name-in {
  from { opacity: 0; clip-path: inset(0 0 100% 0); translate: 0 .18em; }
  to   { opacity: 1; clip-path: inset(0 0 -20% 0);  translate: 0 0; }
}

html.intro-anim .intro .role,
html.intro-anim .intro .hint {
  animation: fade-in .9s ease backwards;
  animation-delay: .95s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.intro .name .first, .intro .name .last { will-change: translate; }

@media (prefers-reduced-motion: reduce) {
  html.intro-anim .scatter,
  html.intro-anim .intro .name .first,
  html.intro-anim .intro .name .last,
  html.intro-anim .intro .role,
  html.intro-anim .intro .hint { animation: none; }
}
