/* ==========================================================================
   Marwane EL MOUFAOUED · Portfolio
   Mobile-first. Breakpoints: 640px, 768px, 900px, 1024px, 1280px.
   ========================================================================== */

:root {
  --bg: #0a0f1a;
  --bg-elev: #0f1624;
  --line: #1c2638;
  --border: #34435c;
  --text: #e6edf7;
  --muted: #95a3ba;
  --accent: #3b9eff;
  --accent-soft: rgba(59, 158, 255, 0.14);
  --accent-light: #bfe1ff;
  --cool: #2346d8;

  --font: "Fira Code", ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo,
    Consolas, "Liberation Mono", monospace;
  --display: "Anton", Impact, "Arial Narrow Bold", sans-serif;

  --container: 1080px;
  --gutter: clamp(1rem, 5vw, 2rem);
  --header-h: 64px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  /* hover zoom: same speed and easing on the way in and out */
  --zoom: 0.35s var(--ease);

  color-scheme: dark;
}

/* ---------- Base ---------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Background grid ---------- */

/* --grid-cell is read by js/main.js so the trail lines up with the lines. */
.bg-grid {
  --grid-cell: 44px;
  --grid-line: rgba(255, 255, 255, 0.04);

  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-cell) var(--grid-cell);
  /* brighter towards the top centre, fading out to the edges for depth */
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 25%, #000 35%, rgba(0, 0, 0, 0.3) 100%);
  mask-image: radial-gradient(ellipse 85% 75% at 50% 25%, #000 35%, rgba(0, 0, 0, 0.3) 100%);
}

.bg-grid__trail {
  display: block;
  width: 100%;
  height: 100%;
}

/* Soft light under the mouse; js/main.js moves it with a transform. */
.cursor-light {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 640px;
  height: 640px;
  margin: -320px 0 0 -320px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(59, 158, 255, 0.1), rgba(35, 70, 216, 0.04) 55%, transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
}

.cursor-light.is-on {
  opacity: 1;
}

h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

svg text {
  font-family: var(--font);
}

strong {
  font-weight: 600;
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.accent {
  color: var(--accent);
}

.nowrap {
  white-space: nowrap;
}

.sprite {
  position: absolute;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Buttons ---------- */

/* `translate` is set by js/main.js: buttons lean towards the mouse. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  font-weight: 500;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.3s, scale var(--zoom), translate 0.4s var(--ease);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--muted);
}

.btn--accent {
  border-color: var(--accent);
}

.btn--accent:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 28px rgba(59, 158, 255, 0.35);
}

.btn--sm {
  min-height: 40px;
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
}

/* ---------- Header ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 15, 26, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.header.is-scrolled,
.nav-open .header {
  border-bottom-color: var(--line);
}

/* reading progress; js/main.js sets --scroll (0..1) */
.header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--cool), var(--accent), var(--accent-light));
  transform-origin: 0 50%;
  scale: var(--scroll, 0) 1;
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  font-weight: 700;
}

.brand__mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}

.nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  transition: color 0.2s;
}

.nav__link:hover,
.nav__link.is-active {
  color: var(--text);
}

.nav-toggle {
  display: none;
}

/* Small screens: the nav becomes a full-height panel under the header.
   Only when JS is available; without it the links simply wrap. */
@media (max-width: 767.98px) {
  .js .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    width: 44px;
    height: 44px;
    margin-right: -6px;
    padding: 0 6px;
    background: none;
    border: 0;
    color: var(--text);
    cursor: pointer;
  }

  .nav-toggle__bar {
    display: block;
    width: 26px;
    height: 2px;
    background: currentColor;
    transition: transform 0.25s, width 0.25s;
  }

  .nav-toggle__bar:last-child {
    width: 18px;
  }

  .nav-open .nav-toggle__bar:nth-child(2) {
    transform: translateY(4px) rotate(45deg);
  }

  .nav-open .nav-toggle__bar:last-child {
    width: 26px;
    transform: translateY(-4px) rotate(-45deg);
  }

  .js .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    padding: 1.5rem var(--gutter) 2rem;
    background: var(--bg);
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0s 0.2s;
  }

  .js .nav-open .nav {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
  }

  .js .nav__list {
    flex-direction: column;
    gap: 0.25rem;
  }

  .js .nav__link {
    width: 100%;
    min-height: 56px;
    font-size: 1.5rem;
    font-weight: 500;
  }

  .js body.nav-open {
    overflow: hidden;
  }

  html:not(.js) .header__inner {
    flex-wrap: wrap;
    padding-block: 0.5rem;
  }
}

/* ---------- Social rail (wide screens) ---------- */

.rail {
  display: none;
}

@media (min-width: 1280px) {
  .rail {
    position: fixed;
    top: 0;
    left: 1.5rem;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--muted);
  }

  .rail__line {
    width: 1px;
    height: 150px;
    margin-bottom: 0.5rem;
    background: var(--border);
  }

  .rail a {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    transition: color 0.2s;
  }

  .rail a:hover {
    color: var(--accent);
  }

  .rail svg {
    width: 20px;
    height: 20px;
  }
}

/* ---------- Hero ---------- */

/* A real 3D scene: the giant name, the portrait and two layers of light dust
   sit at different depths (translateZ) and the whole scene tilts towards the
   mouse. js/main.js drives --mx/--my (pointer, -1..1), --exit (how far the
   hero has scrolled away, 0..1) and --fs-first/--fs-last (name sizes).
   On small screens the stage sits above the text; from 1280px the text
   flanks the portrait over a full-screen stage. */
.hero {
  --mx: 0;
  --my: 0;
  --exit: 0;
  --pw: min(86vw, 440px); /* portrait width */

  position: relative;
}

.hero__stage {
  position: relative;
  height: calc(var(--pw) * 1.153 + clamp(2rem, 9vw, 4.5rem));
  perspective: 1000px;
}

.scene {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(calc(var(--my) * -5deg)) rotateY(calc(var(--mx) * 8deg));
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Depth: translateZ moves a layer back or forward, the scale cancels the
   perspective shrink (1 - z / 1000px) so it keeps its size when at rest. */
.layer--aurora {
  inset: -25% -15%;
  transform: translateZ(-500px) scale(1.5);
}

.layer--dust-back {
  display: block;
  width: 100%;
  height: 100%;
  transform: translateZ(-300px) scale(1.3);
}

.layer--name {
  top: clamp(1rem, 6vw, 3rem);
  bottom: auto;
  transform: translateZ(-200px) scale(1.2);
}

.layer--portrait {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.layer--dust-front {
  display: block;
  width: 100%;
  height: 100%;
  transform: translateZ(140px) scale(0.86);
}

/* Aurora: three slow coloured lights drifting behind everything */
.layer--aurora span {
  position: absolute;
  border-radius: 50%;
}

.layer--aurora span:nth-child(1) {
  top: 8%;
  left: 22%;
  width: 56%;
  height: 62%;
  background: radial-gradient(closest-side, rgba(59, 158, 255, 0.42), transparent);
}

.layer--aurora span:nth-child(2) {
  top: 28%;
  left: 2%;
  width: 46%;
  height: 56%;
  background: radial-gradient(closest-side, rgba(35, 70, 216, 0.26), transparent);
}

.layer--aurora span:nth-child(3) {
  top: 14%;
  right: 4%;
  width: 40%;
  height: 50%;
  background: radial-gradient(closest-side, rgba(191, 225, 255, 0.16), transparent);
}

/* Giant name. The back copy is dark; js/main.js clones it into .name--lit,
   bright letters only visible inside a spotlight that follows the mouse. */
.name {
  font-family: var(--display);
  font-weight: 400;
  line-height: 0.88;
  text-transform: uppercase;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.name__row {
  display: block;
  width: max-content;
  margin-inline: auto;
  perspective: 700px;
}

.name__row--first {
  font-size: var(--fs-first, 22vw);
}

.name__row--last {
  margin-top: 0.08em;
  font-size: var(--fs-last, 13vw);
}

.name .char {
  display: inline-block;
  transform-origin: 50% 100%;
}

/* letters are painted one by one so each can move on its own */
.name--back .name__row--first:not(.is-split),
.name--back .name__row--first .char {
  color: transparent;
  background-image: linear-gradient(180deg, #2c3a55 0%, #172033 55%, #0d1320 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.name--back .name__row--last {
  color: transparent;
  -webkit-text-stroke: 1px rgba(232, 234, 240, 0.2);
}

.name--lit {
  position: absolute;
  inset: 0;
  -webkit-mask-image: radial-gradient(ellipse 30% 85% at calc(50% + var(--mx) * 55%) calc(30% + var(--my) * 50%),
      #000, rgba(0, 0, 0, 0.45) 40%, transparent);
  mask-image: radial-gradient(ellipse 30% 85% at calc(50% + var(--mx) * 55%) calc(30% + var(--my) * 50%),
      #000, rgba(0, 0, 0, 0.45) 40%, transparent);
}

.name--lit .name__row--first .char {
  color: transparent;
  background-image: linear-gradient(180deg, #fff 0%, var(--accent-light) 30%, var(--accent) 72%, var(--cool) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.name--lit .name__row--last {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--accent-light);
}

/* Portrait: a halo and a rim light (SVG filters #f-glow / #f-rim in index.html)
   peek out from behind the cutout on the side of the light. */
.portrait {
  position: relative;
  width: var(--pw);
  transform-origin: 50% 100%;
}

/* light behind the head */
.portrait::before {
  content: "";
  position: absolute;
  top: -12%;
  left: 5%;
  right: 5%;
  height: 70%;
  background: radial-gradient(closest-side, rgba(191, 225, 255, 0.26), rgba(59, 158, 255, 0.14) 55%, transparent);
}

.portrait img {
  display: block;
  width: 100%;
  height: auto;
  /* the cutout ends with a straight edge: fade it into the page */
  -webkit-mask-image: linear-gradient(#000 74%, transparent 97%);
  mask-image: linear-gradient(#000 74%, transparent 97%);
}

.portrait__photo {
  position: relative;
  display: block;
}

/* the light copies fade out before the photo does, or they would show
   through its transparent bottom */
.portrait .portrait__glow,
.portrait .portrait__rim {
  position: absolute;
  top: 0;
  left: 0;
  -webkit-mask-image: linear-gradient(#000 45%, transparent 72%);
  mask-image: linear-gradient(#000 45%, transparent 72%);
  will-change: translate;
}

.portrait__glow {
  filter: url(#f-glow);
  opacity: 0.6;
  scale: 1.02;
  translate: calc(var(--mx) * 30px) calc(var(--my) * 20px);
}

.portrait__rim {
  filter: url(#f-rim);
  opacity: 0.75;
  translate: calc(var(--mx) * 5px) calc(var(--my) * 4px);
}

/* Text */
.hero__content {
  position: relative;
  padding-bottom: clamp(3rem, 8vw, 5rem);
  text-shadow: 0 1px 18px rgba(10, 15, 26, 0.9);
}

.hero__text {
  max-width: 36rem;
}

.hero__hello {
  color: var(--muted);
  font-size: 1.05rem;
}

.hero__title {
  margin-top: 0.25rem;
  font-size: clamp(1.75rem, 1.1rem + 3.2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.hero__role {
  margin-top: 0.75rem;
  font-size: clamp(1.05rem, 0.9rem + 0.8vw, 1.35rem);
  font-weight: 500;
  line-height: 1.45;
}

.hero__lead {
  max-width: 34rem;
  margin-top: 1.5rem;
  color: var(--muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.hero__aside {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-top: 2.5rem;
}

.scroll-cue {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.scroll-cue:hover {
  color: var(--text);
}

.scroll-cue__line {
  position: relative;
  width: 1px;
  height: 2.75rem;
  overflow: hidden;
  background: var(--border);
}

.scroll-cue__line::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 40%;
  background: var(--accent);
  translate: 0 -100%;
}

@media (min-width: 1280px) {
  .hero {
    --pw: min(40vw, (100svh - var(--header-h)) * 0.76, 640px);

    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: max(640px, 100svh - var(--header-h));
  }

  .hero__stage {
    position: absolute;
    inset: 0;
    height: auto;
  }

  .layer--name {
    top: 7%;
  }

  .hero__content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--pw) minmax(0, 1fr);
    align-items: end;
    max-width: none;
    padding-inline: clamp(4.5rem, 5vw, 6rem);
    padding-bottom: clamp(2.5rem, 7vh, 4.5rem);
  }

  .hero__text {
    padding-right: 1.5rem;
  }

  .hero__title {
    font-size: clamp(1.75rem, 0.6rem + 1.6vw, 2.4rem);
  }

  .hero__lead {
    font-size: 0.9375rem;
  }

  .hero__aside {
    grid-column: 3;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    margin-top: 0;
    padding-left: 1.5rem;
  }
}

/* ---------- Band ---------- */

/* Two crossed keyword strips over the bottom of the hero. js/main.js sets
   --progress (-1..1) while the band crosses the viewport, and repeats the
   track text so the strips never run out. */
.band {
  --progress: 0;

  position: relative;
  z-index: 2;
  height: clamp(8rem, 18vw, 13rem);
  margin-top: clamp(-3rem, -4vw, -1.5rem);
  pointer-events: none;
}

.band__strip {
  position: absolute;
  top: 50%;
  left: -10vw;
  width: 120vw;
  padding-block: clamp(0.45rem, 1vw, 0.8rem);
  overflow: hidden;
  font-family: var(--display);
  font-size: clamp(1.4rem, 3vw, 2.5rem);
  line-height: 1.15;
  text-transform: uppercase;
  white-space: nowrap;
}

.band__strip--a {
  z-index: 1;
  translate: 0 -50%;
  rotate: -4deg;
  background: linear-gradient(90deg, var(--accent), var(--accent-light) 50%, var(--accent));
  color: var(--bg);
  box-shadow: 0 0 70px rgba(59, 158, 255, 0.35);
}

.band__strip--b {
  translate: 0 -50%;
  rotate: 3deg;
  background: var(--bg-elev);
  border-block: 1px solid var(--border);
  color: transparent;
  -webkit-text-stroke: 1px var(--muted);
}

.band__track {
  width: max-content;
  translate: calc(-20% + var(--progress) * -12%) 0;
}

.band__strip--b .band__track {
  translate: calc(-20% + var(--progress) * 12%) 0;
}

.band__track span {
  display: inline-block;
  margin-inline: 0.35em;
  font-family: var(--font);
  font-size: 0.6em;
  vertical-align: 0.2em;
}

.band__strip--b .band__track span {
  color: var(--accent);
  -webkit-text-stroke: 0;
}

/* ---------- Sections ---------- */

.section {
  position: relative;
  padding-block: clamp(2.5rem, 7vw, 4.5rem);
}

.section > .container {
  position: relative;
}

/* Huge outlined word behind the title; slides sideways with the scroll
   (--progress, set by js/main.js on the section). */
.section__ghost {
  position: absolute;
  top: clamp(0rem, 1.5vw, 1.25rem);
  left: 0;
  font-family: var(--display);
  font-size: clamp(5rem, 19vw, 17rem);
  line-height: 0.8;
  text-transform: uppercase;
  white-space: nowrap;
  color: transparent;
  -webkit-text-stroke: 1px rgba(232, 234, 240, 0.07);
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.section__ghost--alt {
  left: auto;
  right: 0;
}

.section__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: clamp(1.75rem, 4vw, 3rem);
}

.section__title {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  font-weight: 500;
  line-height: 1.2;
}

.section__title::after {
  content: "";
  flex: 0 1 clamp(3rem, 30vw, 22rem);
  height: 1px;
  margin-left: 1rem;
  background: linear-gradient(90deg, var(--accent), transparent);
  transform-origin: 0 50%;
}

.section__more {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-weight: 500;
  white-space: nowrap;
}

.section__more:hover {
  color: var(--accent);
}

/* ---------- Projects ---------- */

.projects {
  display: grid;
  gap: 1rem;
  perspective: 1400px;
}

.project {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: border-color 0.2s, scale var(--zoom);
}

.project:hover {
  border-color: var(--accent);
}

.project__thumb {
  display: block;
  aspect-ratio: 2 / 1;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.project__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: scale var(--zoom);
}

/* logos keep their proportions, centred with breathing room */
.project__thumb--logo img {
  padding: 12% 10%;
  object-fit: contain;
}

.project__stack {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.project__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.project__title {
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.3;
}

/* The title link stretches over the whole card, making the card clickable. */
.project__title a {
  transition: color 0.2s;
}

.project__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.project:hover .project__title a {
  color: var(--accent);
}

.project__title a:focus-visible {
  outline: none;
}

.project__title a:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.project__subtitle {
  margin-top: 0.35rem;
  color: var(--accent);
  font-size: 0.875rem;
  line-height: 1.5;
}

.project__desc {
  margin-top: 0.85rem;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Live / Code buttons sit above the stretched card link. */
.project__links {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: auto;
}

@media (min-width: 640px) {
  .projects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tablet: the third card spans the full row */
@media (min-width: 640px) and (max-width: 1023.98px) {
  .project:last-child {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .projects {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- Skills ---------- */

.skills {
  display: grid;
  gap: 1rem;
  perspective: 1400px;
}

.skill {
  background: var(--bg);
  border: 1px solid var(--border);
  transition: border-color 0.2s, scale var(--zoom);
}

.skill__title {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  font-weight: 600;
}

.skill__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem;
}

.skill__list li {
  padding: 0.2rem 0.6rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
  transition: border-color 0.2s, color 0.2s, scale var(--zoom);
}

@media (min-width: 600px) {
  .skills {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .skills {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---------- About ---------- */

.about {
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
  perspective: 1400px;
}

.about__text {
  color: var(--muted);
}

.about__text p + p {
  margin-top: 1.25rem;
}

.qualities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.qualities li {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent);
  color: var(--text);
  font-weight: 500;
  transition: background-color 0.2s, scale var(--zoom);
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  transition: border-color 0.2s, scale var(--zoom);
}

.card__name {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
}

.facts {
  padding: 0.5rem 0.85rem;
}

.facts > div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0;
  font-size: 0.9375rem;
}

.facts > div + div {
  border-top: 1px dashed var(--line);
}

.facts dt {
  color: var(--accent);
}

.facts dt::after {
  content: ":";
  color: var(--muted);
}

@media (min-width: 900px) {
  .about {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  }
}

/* ---------- Contacts ---------- */

.contact {
  display: grid;
  gap: 2rem;
  align-items: start;
  perspective: 1400px;
}

.contact__text {
  max-width: 32rem;
  color: var(--muted);
}

.contact__card {
  padding: 1rem;
}

.contact__title {
  font-size: 1rem;
  font-weight: 600;
}

.contact__list {
  margin-top: 0.75rem;
}

.contact__list li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  column-gap: 0.75rem;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.contact__list svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.contact__list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 0;
  overflow-wrap: anywhere;
  transition: color 0.2s;
}

.contact__list a:hover {
  color: var(--accent);
}

.copy {
  grid-column: 2;
  justify-self: start;
  margin-bottom: 0.5rem;
  min-width: 4.75rem;
  min-height: 40px;
  padding: 0.15rem 0.6rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.copy:hover,
.copy.is-done {
  border-color: var(--accent);
  color: var(--accent);
}

html:not(.js) .copy {
  display: none;
}

@media (min-width: 480px) {
  .contact__list li {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }

  .copy {
    grid-column: 3;
    margin-bottom: 0;
  }
}

@media (min-width: 800px) {
  .contact {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3rem;
  }

  .contact__card {
    min-width: 24rem;
  }
}

/* ---------- Footer ---------- */

.footer {
  margin-top: clamp(2rem, 6vw, 4rem);
  padding-block: 2rem 1.5rem;
  border-top: 1px solid var(--border);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem 3rem;
}

.footer__brand p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.footer__heading {
  font-size: 1.25rem;
  font-weight: 500;
}

.footer__media ul {
  display: flex;
  gap: 0.25rem;
  margin: 0.25rem 0 0 -10px;
}

.footer__media a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--muted);
  transition: color 0.2s;
}

.footer__media a:hover {
  color: var(--accent);
}

.footer__media svg {
  width: 22px;
  height: 22px;
}

.footer__copy {
  margin-top: 2rem;
  padding-inline: var(--gutter);
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

/* ---------- Hover zoom ---------- */

/* Only with a real mouse (on touch screens :hover sticks after a tap) and when
   the visitor has not asked for reduced motion. Uses `scale`, not `transform`,
   so it does not fight the tilt or the .reveal entrance. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .brand__mark,
  .rail svg,
  .footer__media svg,
  .contact__list svg {
    transition: scale var(--zoom), color 0.2s;
  }

  /* small logos */
  .brand:hover .brand__mark,
  .rail a:hover svg,
  .footer__media a:hover svg {
    scale: 1.25;
  }

  .contact__list li:hover svg {
    scale: 1.2;
    color: var(--accent);
  }

  .btn:hover {
    scale: 1.05;
  }

  .btn:active {
    scale: 0.97;
  }

  /* projects: the card grows, its picture grows a bit more inside the frame */
  .project:hover {
    z-index: 1;
    scale: 1.03;
  }

  .project:hover .project__thumb img {
    scale: 1.08;
  }

  .skill:hover,
  .card:hover {
    border-color: var(--accent);
    scale: 1.02;
  }

  .skill__list li:hover {
    border-color: var(--accent);
    color: var(--text);
    scale: 1.1;
  }

  .qualities li:hover {
    background: var(--accent-soft);
    scale: 1.1;
  }
}

/* ---------- Tilt ---------- */

/* [data-tilt] cards lean towards the mouse (--rx/--ry) with a glare under it
   (--gx/--gy), set by js/main.js. The buttons and the picture float above the
   card so they move with more depth. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  [data-tilt] {
    position: relative;
    transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  }

  [data-tilt].is-tilting {
    --tilt-speed: 0.12s;
  }

  [data-tilt]::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, 0.13), transparent 45%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s;
  }

  [data-tilt].is-tilting::before {
    opacity: 1;
  }

  [data-tilt].is-tilting {
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7), 0 0 40px -10px rgba(59, 158, 255, 0.35);
  }

  .project,
  .project__body {
    transform-style: preserve-3d;
  }

  .project__thumb {
    transform: translateZ(16px);
  }

  .project__links {
    transform: translateZ(36px);
  }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {

  /* Hero intro: hidden until js/main.js has sized the name (.is-ready) */
  .js:not(.is-ready) .layer--name,
  .js:not(.is-ready) .intro {
    opacity: 0;
  }

  .js.is-ready .name .char {
    animation: char-in 1.2s var(--ease) backwards;
    animation-delay: calc(0.15s + var(--i) * 0.055s);
  }

  .js.is-ready .name__row--last .char {
    animation-delay: calc(0.45s + var(--i) * 0.035s);
  }

  .js.is-ready .intro {
    animation: rise-in 0.9s var(--ease) backwards;
    animation-delay: var(--delay, 0s);
  }

  .js.is-ready .portrait.intro {
    animation-name: portrait-in;
    animation-duration: 1.4s;
  }

  .js.is-ready .layer--aurora {
    animation: fade-in 2.4s ease-out backwards;
  }

  .layer--aurora span:nth-child(1) {
    animation: drift-a 16s ease-in-out infinite alternate;
  }

  .layer--aurora span:nth-child(2) {
    animation: drift-b 21s ease-in-out infinite alternate;
  }

  .layer--aurora span:nth-child(3) {
    animation: drift-c 26s ease-in-out infinite alternate;
  }

  .scroll-cue__line::after {
    animation: cue 2s var(--ease) infinite;
  }

  /* Hero exit on scroll: the scene lags behind, the letters spread apart in
     an arc, the portrait comes closer and (on wide screens, where it sits
     over the scene) the text drifts up and fades. */
  .scene {
    translate: 0 calc(var(--exit) * 22%);
  }

  .name .char {
    translate: calc(var(--d, 0) * var(--exit) * 0.32em) calc(var(--d, 0) * var(--d, 0) * var(--exit) * -0.025em);
  }

  .portrait {
    scale: calc(1 + var(--exit) * 0.12);
  }

  @media (min-width: 1280px) {
    .hero__content {
      translate: 0 calc(var(--exit) * -4rem);
      opacity: calc(1 - var(--exit) * 1.6);
    }
  }

  /* Ghost words slide in opposite directions */
  .section__ghost {
    translate: calc(var(--progress, 0) * -12vw + 4vw) 0;
  }

  .section__ghost--alt {
    translate: calc(var(--progress, 0) * 12vw - 4vw) 0;
  }

  /* Scroll reveals; project and skill cards also flip up in 3D */
  .js .reveal {
    opacity: 0;
    translate: 0 2.5rem;
    transition:
      opacity 0.8s ease-out var(--delay, 0s),
      translate 1s var(--ease) var(--delay, 0s),
      rotate 1s var(--ease) var(--delay, 0s),
      transform var(--tilt-speed, 0.6s) var(--ease),
      box-shadow 0.4s,
      border-color 0.2s,
      scale var(--zoom);
  }

  .js .project.reveal:not(.is-visible),
  .js .skill.reveal:not(.is-visible) {
    rotate: x 30deg;
  }

  .js .reveal.is-visible {
    opacity: 1;
    translate: none;
    rotate: none;
  }

  .js .reveal:nth-child(2) {
    --delay: 0.12s;
  }

  .js .reveal:nth-child(3) {
    --delay: 0.24s;
  }

  .js .reveal:nth-child(4) {
    --delay: 0.36s;
  }

  /* the title underline draws itself */
  .js .section__head.reveal .section__title::after {
    transition: scale 1.2s var(--ease) 0.25s;
  }

  .js .section__head.reveal:not(.is-visible) .section__title::after {
    scale: 0 1;
  }

  /* skill chips pop in one after the other */
  .js .skill.reveal .skill__list li {
    --chip-delay: calc(var(--delay, 0s) + 0.35s + var(--n, 0) * 0.07s);

    transition:
      opacity 0.5s ease-out var(--chip-delay),
      translate 0.6s var(--ease) var(--chip-delay),
      border-color 0.2s,
      color 0.2s,
      scale var(--zoom);
  }

  .js .skill.reveal:not(.is-visible) .skill__list li {
    opacity: 0;
    translate: 0 0.75rem;
  }

  .skill__list li:nth-child(2) {
    --n: 1;
  }

  .skill__list li:nth-child(3) {
    --n: 2;
  }

  .skill__list li:nth-child(4) {
    --n: 3;
  }

  .skill__list li:nth-child(5) {
    --n: 4;
  }

  .skill__list li:nth-child(6) {
    --n: 5;
  }
}

@keyframes char-in {
  from {
    opacity: 0;
    transform: translateY(0.45em) rotateX(-80deg);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(1.5rem);
  }
}

@keyframes portrait-in {
  from {
    opacity: 0;
    transform: translateY(6%) scale(0.94);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes drift-a {
  to {
    transform: translate(10%, 8%) scale(1.15);
  }
}

@keyframes drift-b {
  to {
    transform: translate(22%, -12%) scale(1.2);
  }
}

@keyframes drift-c {
  to {
    transform: translate(-18%, 14%) scale(0.9);
  }
}

@keyframes cue {
  to {
    translate: 0 260%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Print ---------- */

@media print {
  .bg-grid,
  .cursor-light,
  .header,
  .rail,
  .nav-toggle,
  .copy,
  .layer--aurora,
  .dust,
  .name--lit,
  .band,
  .section__ghost,
  .scroll-cue {
    display: none !important;
  }

  .js .reveal,
  .js .intro,
  .js .layer--name {
    opacity: 1 !important;
    transform: none !important;
    translate: none !important;
    rotate: none !important;
  }
}
