/*
 * ayoubchahid.com. One stylesheet, no framework, no build step.
 * Look: modelled on davidlng.com (black, DM Sans, small light type, white/grey contrast, thin dividers).
 */

@font-face {
  font-family: "DM Sans";
  src: url("../fonts/dm-sans-latin.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #000;
  --text: #fff;
  --muted: #808080;
  --faint: #4d4d4d;
  --line: #262626;
  --frame: #2e2e2e;
  --frame-hover: #4a4a4a;
  --card-bg: #050505;
  --plate: #ffcc00;          /* UK plate yellow, the same as the Regish logo */
  --plate-soft: rgba(255, 204, 0, .45);
  --on-plate: #000;          /* text on a --plate button */
  --plate-fill: var(--plate); /* button background; a theme can make it darker than the text colour */

  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --gutter: clamp(20px, 7vw, 100px);
  --edge: clamp(20px, 4.2vw, 60px);
  --max: 1240px;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

p, h1, h2, h3, ul, dl, dd, figure { margin: 0; padding: 0; }
ul { list-style: none; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { font-weight: 400; }

a { color: inherit; text-decoration: none; transition: color .2s ease, opacity .2s ease; }
a:hover { opacity: .7; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 2px; }

::selection { background: #fff; color: #000; }

.hi { color: var(--text); }

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 20;
  padding: 8px 12px; background: var(--text); color: var(--bg); font-size: 13px; border-radius: 4px;
}
.skip:focus { top: 12px; }

/* ---------- header ---------- */

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px var(--edge);
  font-size: 13px;
  background: linear-gradient(var(--bg) 60%, rgba(0, 0, 0, 0));
}
.top__name { color: #d9d9d9; text-transform: lowercase; }
.top__nav { display: flex; gap: 20px; }
.top__nav a { color: #d9d9d9; }

/* ---------- page column ---------- */

main {
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter) 120px;
}

.block {
  border-top: 1px solid var(--line);
  padding: 48px 0 32px;
}

/* ---------- hero ---------- */

.hero {
  padding: clamp(110px, 14vw, 200px) 0 clamp(100px, 13vw, 180px);
}
.hero__intro {
  max-width: 470px;
  font-size: 24px;
  line-height: 1.4;
  color: var(--muted);
  letter-spacing: -0.005em;
}
.hero__sub {
  margin-top: 8px;
  max-width: 470px;
  font-size: 12px;
  color: var(--muted);
}
.hero__sub a { color: var(--text); }

.hero--project { padding-bottom: clamp(80px, 9vw, 120px); }
.hero__label {
  font-size: 22px;
  color: var(--muted);
  margin-bottom: 20px;
}
.hero__lead {
  max-width: 620px;
  font-size: 24px;
  line-height: 1.4;
  color: #cfcfcf;
}
.hero__lead p + p { margin-top: 14px; }
.hero__lead a, .hero__note a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.hero__note a { color: var(--plate); text-decoration-color: var(--plate-soft); }
/* A project intro with a picture: text on the left, picture on the right (stacked on phones). */
.hero--with-media { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 48px; align-items: center; }
.hero--with-media .hero__media { margin-top: 0; }
.hero__media--portrait img { max-height: 78vh; object-fit: cover; object-position: center 70%; }
.hero__media { margin-top: 48px; border: 1px solid var(--frame); border-radius: var(--radius); overflow: hidden; background: var(--card-bg); }
.hero__media img { width: 100%; }
.hero__media picture { display: contents; }
.hero__note {
  margin-top: 18px;
  max-width: 620px;
  font-size: 16px;
  color: var(--faint);
}

/* ---------- work ---------- */

.block__title {
  font-size: 18px;
  margin-bottom: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.card__link { display: block; }
.card__link:hover { opacity: 1; }
.card__frame {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1.68;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
  transition: border-color .3s ease;
}
.card__logo {
  width: 52%;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1);
}
.card__text {
  font-size: clamp(22px, 2.6vw, 34px);
  letter-spacing: -0.02em;
  color: #d9d9d9;
  text-align: center;
  padding: 0 8%;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1);
}
.card__link:hover .card__text { transform: scale(1.03); }
svg.card__logo { height: auto; }
.card__logo--square { width: auto; height: 46%; }
.choice__logo img.choice__logo--square { width: auto; height: 70%; }
.card__link:hover .card__frame { border-color: var(--frame-hover); }
.card__link:hover .card__logo { transform: scale(1.03); }
.card__label {
  display: block;
  margin-top: 12px;
  font-size: 16px;
  color: var(--muted);
  transition: color .2s ease;
}
.card__link:hover .card__label { color: var(--text); }

/* ---------- about + experience ---------- */

.about__bio { max-width: 440px; }
.about__bio p + p { margin-top: 12px; }
.about__bio a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }

.timeline { margin-top: 26px; display: grid; gap: 16px; }
.timeline li { display: grid; }
.timeline__name { font-size: 13px; }
.timeline__role { font-size: 12px; color: #bdbdbd; }
.timeline__dates { font-size: 12px; color: var(--muted); }

/* ---------- contact ---------- */

.contact__email { font-size: 16px; }
.contact__links { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 24px; font-size: 13px; }

/* ---------- case-study rows ---------- */

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px 48px;
  align-items: center;
  padding: 40px 0;
}
.row__text { max-width: 470px; }
.row__title { font-size: 22px; margin-bottom: 8px; }
.row__text p { color: #a6a6a6; }
.row__text p + p { margin-top: 18px; }
.row__text a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.row__text .row__foot { margin-top: 26px; color: #cfcfcf; }
.row__list { margin: 18px 0 0; display: grid; gap: 10px; }
.row__list li { position: relative; padding-left: 18px; color: #a6a6a6; }
.row__list li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 1px; background: var(--muted); }
.row__list + p { margin-top: 18px; }

/* A row with no picture: the text takes a wider single column. */
.row--text { grid-template-columns: minmax(0, 1fr); }
.row--text .row__text { max-width: 680px; }

.row__media {
  aspect-ratio: 1.42;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
}
.row__media img { width: 100%; height: 100%; }
.row__media picture { display: contents; }
.row__media-link { display: block; width: 100%; height: 100%; }
.row__media-link:hover { opacity: .85; }

/* A call to action styled like a small UK number plate, as on Regish. */
.row__text .row__cta {
  display: inline-block;
  margin-top: 26px;
  padding: 9px 18px;
  background: var(--plate-fill);
  color: var(--on-plate);
  font-weight: 600;
  border-radius: 4px;
  text-decoration: none;
}
.row__text .row__cta:hover { opacity: .85; }
.row__media--cover img { object-fit: cover; object-position: top left; }
.row__media--video { padding: 24px; display: flex; justify-content: center; }
.row__media--video video { height: 100%; width: auto; max-width: 100%; border-radius: 4px; background: #000; }
.row__media--contain { padding: 24px; display: flex; justify-content: center; }
.row__media--contain img { width: auto; height: 100%; object-fit: contain; border-radius: 4px; }

.row__media--stats { display: flex; align-items: center; padding: 32px clamp(20px, 4vw, 48px); }
.stats { display: grid; gap: 22px; width: 100%; }
.stats__item { display: flex; flex-direction: column-reverse; border-top: 1px solid var(--line); padding-top: 14px; }
.stats__item:first-child { border-top: 0; padding-top: 0; }
.stats dd { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.1; letter-spacing: -0.02em; }
.stats dt { margin-top: 4px; font-size: 13px; color: var(--muted); }

/* A screenshot shown whole, at its own shape (nothing cropped). */
.row__media--full { aspect-ratio: auto; }
.row__media--full img { height: auto; }

/* A small table in the right-hand panel. */
.row__media--table { display: flex; align-items: center; padding: 28px clamp(18px, 3.4vw, 40px); }
.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid-table caption { caption-side: top; text-align: left; font-size: 13px; color: var(--muted); padding-bottom: 14px; }
.grid-table th { font-weight: 400; font-size: 12px; color: var(--muted); text-align: left; padding: 0 0 10px 14px; vertical-align: bottom; }
.grid-table td { text-align: left; padding: 12px 0 12px 14px; border-top: 1px solid var(--line); color: #a6a6a6; vertical-align: top; }
.grid-table th:first-child, .grid-table td:first-child { padding-left: 0; }
.grid-table td:first-child { color: var(--text); }
.grid-table--num th, .grid-table--num td { text-align: right; font-variant-numeric: tabular-nums; }
.grid-table--num th:first-child, .grid-table--num td:first-child { text-align: left; }
.grid-table--num td { color: #cfcfcf; }
.row__media--table .grid-table td { padding-block: 14px; }
.row__media--table .grid-table td:last-child { color: var(--plate); font-size: clamp(16px, 1.6vw, 20px); letter-spacing: -0.01em; }

/* A table inside the text (technical page). Scrolls sideways on a narrow phone instead of squashing. */
.row__table { margin-top: 22px; overflow-x: auto; }
.row__table + .row__table { margin-top: 30px; }
.row__table + p { margin-top: 22px; }
.row__list + .row__table { margin-top: 26px; }
.row__table .grid-table { min-width: 460px; font-size: 13.5px; }
.row__table code, .row__text code { font-size: .92em; }

/* An article page: each section is one wide column. */
.row--wide .row__text { max-width: 860px; }

/* Several numbers side by side in the stats panel. */
.stats__row { flex-direction: row; gap: 20px; }
.stats__cell { display: flex; flex-direction: column-reverse; flex: 1 1 0; min-width: 0; }

/* The small note at the end of a case study. */
.outro { padding: 40px 0 8px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.outro p + p { margin-top: 10px; }
.outro a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }

/* Before/after pictures: two per line, click to open full size. */
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 20px; }
.gallery__frame { display: block; aspect-ratio: 16 / 9; border: 1px solid var(--frame); border-radius: var(--radius); overflow: hidden; background: #fff; }
.gallery__frame:hover { opacity: .9; border-color: var(--frame-hover); }
.gallery__frame img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.gallery figcaption { margin-top: 10px; font-size: 13px; color: var(--muted); }

/* Bar charts (drawn as SVG on the server): before in dim grey, after in plate yellow, values in text ink. */
.chart { margin-top: 26px; }
.chart + .chart { margin-top: 34px; }
.chart__caption { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.chart__legend { display: flex; gap: 18px; font-size: 12px; color: #a6a6a6; margin-bottom: 12px; }
.chart__key::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart__key--0::before { background: #5a5a5a; }
.chart__key--1::before { background: var(--plate); }
.chart__row { display: grid; grid-template-columns: minmax(0, 15em) minmax(0, 1fr) 7.5em; gap: 14px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.chart__row:first-of-type { border-top: 0; }
.chart__label { font-size: 13.5px; color: var(--text); }
.chart__bars { display: block; overflow: visible; }
.chart__bar--0 { fill: #5a5a5a; }
.chart__bar--1 { fill: var(--plate); }
.chart__bar:hover { opacity: .8; }
.chart__vals { display: grid; gap: 4px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chart__val--0 { color: #a6a6a6; }
.chart__val--1 { color: var(--text); }

/* The picture viewer: nearly full screen, dark backdrop, cross top right. */
.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: transparent; color: var(--text);
  display: none;
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; animation: fade-in .2s ease; }
.lightbox::backdrop { background: rgba(0, 0, 0, .88); backdrop-filter: blur(4px); }
.lightbox__figure { display: flex; flex-direction: column; align-items: center; max-width: 94vw; }
.lightbox__img {
  display: block; max-width: 94vw; max-height: 86vh; width: auto; height: auto;
  border-radius: 6px; background: #fff; cursor: default;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.lightbox__caption { margin-top: 12px; font-size: 13px; color: #bdbdbd; text-align: center; }
.lightbox__close {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 1;
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer;
}
.lightbox__close:hover { background: rgba(255, 255, 255, .22); }
html:has(.lightbox[open]) { overflow: hidden; }
.gallery__frame { cursor: zoom-in; }

/* ---------- languages: hover shows the flag ---------- */

.lang {
  position: relative;
  display: inline-block;
  color: var(--text);
  cursor: default;
  transition: transform .25s cubic-bezier(.2, .7, .2, 1);
}
/* The flag sits behind the word without changing the layout, so the words around it don't move. */
.lang::before {
  content: "";
  position: absolute;
  inset: -1px -3px;
  z-index: -1;
  border-radius: 4px;
  background: center / cover no-repeat;
  opacity: 0;
  transition: opacity .2s ease;
}
.lang:hover, .lang:focus-visible {
  z-index: 1;
  transform: scale(1.08);
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, .95), 0 1px 2px rgba(0, 0, 0, .95);
  outline: none;
}
.lang:hover::before, .lang:focus-visible::before { opacity: 1; }
.lang--gb::before { background-image: url("../img/flags/gb.svg"); }
.lang--fr::before { background-image: url("../img/flags/fr.svg"); }
.lang--it::before { background-image: url("../img/flags/it.svg"); }
.lang--ma::before { background-image: url("../img/flags/ma.svg"); }
.lang-sep { position: relative; z-index: 2; }
.about__bio p { isolation: isolate; }

/* ---------- the pop-up on a Work card ---------- */

.choice {
  width: min(460px, calc(100% - 32px));
  max-width: none;
  padding: 0;
  border: 1px solid var(--frame);
  border-radius: 12px;
  background: #0a0a0a;
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.choice[open] { animation: choice-in .28s cubic-bezier(.2, .7, .2, 1); }
.choice::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(6px); }
.choice[open]::backdrop { animation: fade-in .28s ease; }
html:has(.choice[open]) { overflow: hidden; }

.choice__box { position: relative; padding: 28px 28px 26px; }
.choice__box:focus { outline: none; }
.choice__close {
  position: absolute; top: 12px; right: 12px;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.choice__close:hover { background: #1c1c1c; color: var(--text); }
.choice__logo {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 2.4;
  margin: 18px 0 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-bg);
}
.choice__logo img { width: 58%; }
.choice__title { font-size: 22px; }
.choice__text { margin-top: 6px; color: #a6a6a6; }
.choice__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }

.btn {
  display: flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 14px;
  border-radius: 6px;
  gap: 6px;
  font-size: 15px; font-weight: 600; text-align: center;
}
.btn:hover { opacity: .85; }
.btn--light { background: var(--text); color: #000; }
.btn--plate { background: var(--plate-fill); color: var(--on-plate); }

/* The Final Project pages and pop-up use Cardiff University red instead of plate yellow, for links,
   buttons, numbers and chart bars. */
.accent-cardiff { --plate: #d73749; --plate-soft: rgba(215, 55, 73, .55); --on-plate: #fff; }
/* Reborn 4x4: Land Rover Pastel Green (LRC005). Land Rover only gives a paint code, so #A8BB9D is a
   screen approximation. It's light, so it works for text and, like the yellow, takes black text on buttons. */
.accent-reborn { --plate: #a8bb9d; --plate-soft: rgba(168, 187, 157, .5); --on-plate: #000; }

/* Every project page uses its accent the same way (plate yellow by default, Cardiff red on the Final
   Project): links, stat numbers, the last column of number tables, buttons and chart bars. */
.row__text a, .hero__lead a, .hero__note a, .outro a { color: var(--plate); text-decoration-color: var(--plate-soft); }
.stats dd, .grid-table--num td:last-child { color: var(--plate); }

@keyframes choice-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- reveal on scroll (only when JS runs; see early.js / site.js) ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .8s cubic-bezier(.2, .7, .2, 1), transform .8s cubic-bezier(.2, .7, .2, 1);
}
.js .reveal.in { opacity: 1; transform: none; }
.cards .reveal:nth-child(2) { transition-delay: .08s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  * { transition: none !important; }
  .choice[open], .choice[open]::backdrop, .lightbox[open] { animation: none; }
  .lang:hover, .lang:focus-visible { transform: none; }
}

/* ---------- tablet and phone ---------- */

@media (max-width: 809px) {
  /* A picture with a phone version: shown whole, as a phone screenshot, on phones. */
  .row__media--has-mobile { aspect-ratio: auto; padding: 20px; display: flex; justify-content: center; }
  .row__media--has-mobile img, .row__media--has-mobile .row__media-link { width: auto; height: auto; max-width: 100%; max-height: 70vh; border-radius: 4px; }
  .row__media--has-mobile .row__media-link { display: flex; justify-content: center; }
  .hero--with-media { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .hero__media--has-mobile { padding: 20px; display: flex; justify-content: center; }
  .hero__media--has-mobile img { width: auto; max-width: 100%; max-height: 70vh; border-radius: 4px; }
  .top__extra { display: none; }
  .row { grid-template-columns: minmax(0, 1fr); padding: 36px 0; }
  .row__text { max-width: none; }
  .row__media--contain, .row__media--video { aspect-ratio: 1; }
}

@media (max-width: 520px) {
  .cards { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .hero__intro, .hero__lead { font-size: 22px; }
  .block { padding: 40px 0 28px; }
  .choice__actions { grid-template-columns: minmax(0, 1fr); }
  .gallery { grid-template-columns: minmax(0, 1fr); }
  .chart__row { grid-template-columns: minmax(0, 1fr) 6.5em; }
  .chart__label { grid-column: 1 / -1; }
}
.stats__row dd { font-size: clamp(20px, 2.4vw, 30px); }
