/* Helvetica-style typeface: TeX Gyre Heros (free, GUST Font License, see /fonts) */
@font-face { font-family: "Heros"; font-weight: 400; font-display: swap; src: url("/fonts/texgyreheros-regular.woff2") format("woff2"); }
@font-face { font-family: "Heros"; font-weight: 700; font-display: swap; src: url("/fonts/texgyreheros-bold.woff2") format("woff2"); }

/* Photocopy paper, black toner, one blue ink */
:root {
  --paper: #e4e3dd;
  --ink: #151514;
  --muted: #6c6b66;
  --rule: #c9c8c1;
  --blue: #2443a0;
  --display: "Heros", "Helvetica Neue", Helvetica, Arial, "IBM Plex Sans Arabic", sans-serif;
  --grain: 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='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1d1d1b;
    --ink: #e9e7e0;
    --muted: #8f8d86;
    --rule: #3a3a37;
    --blue: #a3b5f7;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.45;
}
/* the photocopy grain sits on top of everything, very lightly */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--grain);
  opacity: 0.28;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 50;
}
@media (prefers-color-scheme: dark) { body::after { mix-blend-mode: screen; opacity: 0.12; } }

[lang="ar"] { font-family: "IBM Plex Sans Arabic", sans-serif; line-height: 1.8; }

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--blue); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.page { position: relative; z-index: 1; padding: 1.4rem 2rem 5rem; }

/* Side column: name and menu */
.page {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 4rem;
}
.side {
  position: sticky;
  top: 1.4rem;
  align-self: start;
}
.side p { margin: 0; }
.name { font-weight: 700; display: inline-block; }
.tagline { color: var(--muted); margin-top: 0.3rem !important; }
nav[aria-label="Main"] { margin-top: 2rem; display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; }
nav[aria-label="Main"] > a[aria-current="page"] { background: var(--ink); color: var(--paper); padding: 0 0.3em; margin: 0 -0.3em; }
.side-projects { list-style: none; margin: 0.25rem 0 0.6rem; padding: 0 0 0 1.25rem; }
.side-projects li { margin: 0 0 0.1rem; }
.side-projects a { color: var(--muted); }
.side-projects a:hover, .side-projects a[aria-current="page"] { color: var(--blue); }
.contact { margin-top: 2rem !important; color: var(--muted); }
.contact a { color: var(--muted); }
.contact a:hover { color: var(--blue); }

/* Projects page: titles grouped by year */
.projects { max-width: 48rem; }
.year-group {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0 1rem;
  padding: 0.55rem 0 0.7rem;
  border-top: 1px solid var(--rule);
}
.year-group:last-child { border-bottom: 1px solid var(--rule); }
.year { margin: 0.35rem 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.projects ul { list-style: none; margin: 0; padding: 0; }
.projects li a {
  display: inline-block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  padding: 0.05rem 0;
}
.projects li a:hover { color: var(--blue); }

/* the small photo that follows the pointer */
.hover-photo {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: auto;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  filter: grayscale(1) contrast(1.2);
  mix-blend-mode: multiply;
  transition: opacity 0.15s;
}
.hover-photo.on { opacity: 1; }
.hover-photo:not([src]) { display: none; }
@media (prefers-color-scheme: dark) { .hover-photo { mix-blend-mode: normal; } }

/* Homepage: photo grid, printed like a two-colour risograph.
   Each photo is two ink layers (blue and pink) slightly out of register;
   on hover they slide into place and the real photo shows through. */
:root { --ink-blue: #2f5bb7; --ink-pink: #ff4fa3; }
.grid { list-style: none; margin: 0; padding: 0; columns: 3 15rem; column-gap: 2.25rem; }
.grid li { break-inside: avoid; margin: 0 0 2.75rem; }
.grid li:nth-child(3n+2) { padding: 0 10%; }
.grid li:nth-child(4n+3) { padding-left: 22%; }
.riso { position: relative; display: block; isolation: isolate; }
.riso > img { display: block; width: 100%; height: auto; opacity: 0; transition: opacity 0.35s; }
.ink { position: absolute; inset: 0; mix-blend-mode: multiply; transition: transform 0.35s ease, opacity 0.35s; }
.ink img { display: block; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.35) brightness(1.08); mix-blend-mode: screen; }
.ink-blue { background: var(--ink-blue); transform: translate(-3px, 2px); }
.ink-pink { background: var(--ink-pink); transform: translate(4px, -3px); }
.grid a:hover .ink, .grid a:focus-visible .ink { transform: none; opacity: 0; }
.grid a:hover .riso > img, .grid a:focus-visible .riso > img { opacity: 1; }
.cap { display: block; margin-top: 0.6rem; color: var(--muted); font-weight: 400; }
.cap span { font-family: var(--display); font-weight: 700; letter-spacing: -0.03em; font-size: 1.3rem; color: var(--ink); margin-right: 0.3em; }
.grid a:hover .cap span { color: var(--blue); }

/* Background video, treated like a photocopy */
.bg-video { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg-video video {
  width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(1) contrast(1.35) brightness(1.1);
  mix-blend-mode: multiply;
  opacity: 0.5;
}
@media (prefers-color-scheme: dark) { .bg-video video { mix-blend-mode: normal; opacity: 0.3; } }

/* Project, post and about pages */
.entry h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.2rem, 4.5vw, 4rem);
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0 0 0.4rem;
  max-width: 18ch;
}
.meta { color: var(--muted); margin: 0 0 2.5rem; }
.text {
  max-width: 36rem;
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1.5;
  letter-spacing: -0.01em;
}
.text p { margin: 0 0 0.9em; }
.text a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.text h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2.8rem 0 0.6rem;
}
.text ul { list-style: none; padding: 0; margin: 0; }
.text li { margin: 0 0 0.25rem; }
.text img { max-width: 100%; height: auto; }

.images { margin-top: 3rem; display: grid; gap: 1.5rem; max-width: 60rem; }
.images img { display: block; width: 100%; height: auto; }

.back { margin-top: 3.5rem; }
.back a { color: var(--muted); }
.back a:hover { color: var(--blue); }

/* Blog list */
.list { list-style: none; margin: 0; padding: 0; max-width: 60rem; }
.list li { border-top: 1px solid var(--rule); }
.list li:last-child { border-bottom: 1px solid var(--rule); }
.list a { display: flex; justify-content: space-between; align-items: baseline; gap: 2rem; padding: 0.55rem 0; }
.list .t { font-family: var(--display); font-weight: 700; letter-spacing: -0.03em; font-size: 1.8rem; line-height: 1.1; }
.list .y { color: var(--muted); white-space: nowrap; }
.list a:hover .t { color: var(--blue); }

@media (max-width: 760px) {
  .page { grid-template-columns: 1fr; gap: 2.25rem; padding: 1.1rem 1.1rem 4rem; }
  .side { position: static; }
  nav[aria-label="Main"] { margin-top: 1rem; flex-direction: row; flex-wrap: wrap; gap: 0.2rem 1.1rem; }
  .side-projects { display: none; } /* on phones the Projects page itself is the list */
  .contact { margin-top: 1rem !important; }
  .year-group { grid-template-columns: 3.2rem 1fr; gap: 0 0.6rem; }
  .text { font-size: 1.1rem; }
  .grid li:nth-child(n) { padding: 0; }
  .list a { flex-direction: column; gap: 0.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hover-photo, .riso > img, .ink { transition: none; }
}
