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

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  background: #1a1a1a;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ── Hero ─────────────────────────────────────────────── */

.hero {
  position: sticky;
  top: 0;
  z-index: 0;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
}

.hero-text {
  font-family: 'Roboto', sans-serif;
  font-weight: 900;
  font-size: clamp(44px, 13vw, 192px);
  line-height: 0.88;
  color: #EDEAE5;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  max-width: 100%;
  /* Break long words (STORYTELLING) on narrow screens instead of overflowing */
  overflow-wrap: anywhere;
  hyphens: auto;
  will-change: transform, opacity;
  position: relative;
  transition: filter 3s ease;
}

.hero-text:hover {
  filter: blur(1.5rem);
}

.hero-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.hero-timecode {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: 0.1em;
  color: #EDEAE5;
  background: rgba(18, 18, 18, 0.72);
  padding: 6px 16px;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}

.hero-timecode.is-active {
  opacity: 1;
}

.hero-role {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(0.7rem, 1.2vw, 1rem);
  letter-spacing: 0.2em;
  color: #EDEAE5;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}

.hero-timecode.is-active + .hero-role {
  opacity: 1;
}

.hero-terms {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.hero-term {
  position: absolute;
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(0.7rem, 1.2vw, 1rem);
  letter-spacing: 0.2em;
  color: #F0A202;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.hero-term.is-visible {
  opacity: 1;
}

.hero-text::before,
.hero-text::after {
  content: "CREATIVE\A TECH\AD NOLOGY";
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  hyphens: auto;
  position: absolute;
  top: 0;
  width: 100%;
  text-align: center;
  pointer-events: none;
}

.hero-text::before {
  left: -2px;
  animation: hero-glitch-1 2.5s infinite;
}

.hero-text::after {
  left: 2px;
  animation: hero-glitch-2 2.5s infinite;
  animation-delay: 0.15s;
}

@keyframes hero-glitch-1 {
  0%,  70% { clip: rect(0, 0, 0, 0); }
  74%       { clip: rect(42px,  9999px, 58px,  0); }
  79%       { clip: rect(182px, 9999px, 199px, 0); }
  84%       { clip: rect(14px,  9999px, 27px,  0); }
  89%       { clip: rect(267px, 9999px, 285px, 0); }
  94%       { clip: rect(95px,  9999px, 114px, 0); }
  99%       { clip: rect(61px,  9999px, 79px,  0); }
  100%      { clip: rect(0, 0, 0, 0); }
}

@keyframes hero-glitch-2 {
  0%,  70% { clip: rect(0, 0, 0, 0); }
  74%       { clip: rect(127px, 9999px, 141px, 0); }
  79%       { clip: rect(53px,  9999px, 68px,  0); }
  84%       { clip: rect(241px, 9999px, 258px, 0); }
  89%       { clip: rect(88px,  9999px, 104px, 0); }
  94%       { clip: rect(174px, 9999px, 192px, 0); }
  99%       { clip: rect(76px,  9999px, 91px,  0); }
  100%      { clip: rect(0, 0, 0, 0); }
}

/* ── Nav ──────────────────────────────────────────────── */

nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 90px;
  padding: 0 24px 0 80px;
  background: rgba(1, 1, 1, 0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nav-logo-link {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: block;
  line-height: 0;
}

.nav-logo {
  width: 150px;
  height: auto;
  display: block;
}

.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
}

.nav-links a {
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: rgba(255, 255, 255, 0.8);
}

.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  z-index: 101;
}

.nav-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: rgba(255, 255, 255, 0.6);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

nav.menu-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
nav.menu-open .nav-hamburger span:nth-child(2) { opacity: 0; }
nav.menu-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Main layout ──────────────────────────────────────── */

main {
  position: relative;
  z-index: 1;
  background: #1a1a1a;
  border-radius: 20px 20px 0 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px 48px;
}

/* ── Cards grid (projects) ────────────────────────────── */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* ── Card ─────────────────────────────────────────────── */

.card {
  width: min(1280px, 100%);
  background: #EDEAE5;
  border-radius: 13px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  translate: 0 60px;
  opacity: 0;
  transition: translate 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.card.is-visible {
  translate: 0 0;
  opacity: 1;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}

/* ── Card header ──────────────────────────────────────── */

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 54px;
  border-bottom: 0.25px solid #3D3D3D;
}

.card-year,
.card-category {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: #3D3D3D;
}

/* ── Card title row ───────────────────────────────────── */

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 54px 18px;
}

.card-title {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(20px, 2.35vw, 30px);
  font-weight: 700;
  color: #000000;
  line-height: 1;
}

.card-arrow {
  font-size: clamp(22px, 3.1vw, 40px);
  color: #000000;
  line-height: 1;
  flex-shrink: 0;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.card:hover .card-arrow {
  transform: translateX(4px);
}

/* ── Card media ───────────────────────────────────────── */

.card-media {
  margin: 0 54px 51px;
  background: #D9D9D9;
  aspect-ratio: 2 / 1;
  overflow: hidden;
}

.card-media--wide {
  aspect-ratio: 1500 / 776;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.card:hover .card-media img {
  transform: scale(1.03);
}

/* ── Card body (text content) ─────────────────────────── */

.card-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 54px 24px;
}

.card-body p {
  font-size: 15px;
  color: #4a4a4a;
  line-height: 1.65;
}

/* ── Stacking cards ───────────────────────────────────── */

.card-swap-slot {
  position: relative;
  width: min(1280px, 100%);
  height: 636vh;
}

.card-swap-slot .card {
  position: sticky;
  top: 110px;
  translate: 0 0;
  /* JS drives transform/opacity/filter and transform-origin per phase — skip
     those transitions to avoid lag */
  transition: box-shadow 0.25s ease;
  backface-visibility: hidden;
  will-change: transform, opacity, filter;
}

.card--a { z-index: 1; }
.card--b { z-index: 2; }
.card--c { z-index: 3; }
.card--d { z-index: 4; }
.card--e { z-index: 5; }

/* ── Project card (Figma "Cards") ─────────────────────── */
/* Sizes are Figma px at a 1275px-wide card, expressed in cqw so the whole
   card scales proportionally: 1px ≈ 0.0784cqw */

.card-swap-slot .card {
  container: pcard / inline-size;
  padding: 0 4.15% 2.2%;   /* % of the slot = card width (cqw would not refer to the card itself) */
}

/* Grain texture over the whole card */
.card-swap-slot .card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.35;
  mix-blend-mode: multiply;
}

.card-label {
  padding: 1.9cqw 0 1.11cqw;
  border-bottom: 0.5px solid #3D3D3D;
  font-family: 'Space Mono', monospace;
  font-size: max(12px, 1.57cqw);
  line-height: 1.48;
  text-transform: uppercase;
  color: #3D3D3D;
}

.card-panel {
  display: grid;
  grid-template-columns: minmax(0, 641fr) minmax(0, 527fr);
  height: 45cqw;
  margin-top: 3.54cqw;
  background: #D9D9D9;
  overflow: hidden;
}

.card-info {
  position: relative;
  min-width: 0;
}

.card-heading {
  padding: calc(var(--title-top, 27.48) * 0.0784cqw) 0 0 3.89cqw;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: calc(var(--title-size) * 0.0784cqw);
  line-height: calc(var(--title-lh) * 0.0784cqw);
  text-transform: uppercase;
  color: #1E1E1E;
  max-width: 50.31cqw;          /* Figma text box 591.8px + left padding */
  overflow-wrap: anywhere;
}

/* Vertical rule with year/category on top and the description at the bottom */
.card-details {
  position: absolute;
  top: 23.72cqw;
  bottom: 0;
  left: 4.58cqw;
  width: 24.8cqw;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5cqw;
  padding: 0 0 2.34cqw 1.25cqw;
  border-left: 1px solid #1E1E1E;
}

.card-details--grouped {
  justify-content: flex-end;
  gap: 2.6cqw;
}

.card-meta {
  display: flex;
  flex-direction: column;
  margin-top: -0.4cqw;
}

.card-details .card-year,
.card-details .card-category {
  font-size: max(10px, 0.94cqw);
  line-height: 1.48;
  text-transform: uppercase;
}

.card-desc {
  display: flex;
  flex-direction: column;
  gap: 1.3em;
  font-family: 'Inter', sans-serif;
  font-size: max(11px, 1.1cqw);
  line-height: 1.21;
  color: #1E1E1E;
}

.card-cover {
  overflow: hidden;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

/* XR: Figma places the 1065×622 photo 527px left / 11px up inside the
   527×574 cover slot, so the person on the right half is in view */
.card-cover--xr {
  position: relative;
}

.card-cover--xr img {
  position: absolute;
  left: -100.12%;
  top: -1.93%;
  width: 202.13%;
  height: 108.38%;
}

.card:hover .card-cover img {
  transform: scale(1.03);
}

/* Narrow cards: stack text above the photo */
@container pcard (max-width: 700px) {
  .card-panel {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .card-heading {
    padding: 6cqw 6cqw 0;
    font-size: max(11cqw, calc(var(--title-size) * 0.1cqw));
    line-height: 1;
    max-width: none;
  }

  .card-details,
  .card-details--grouped {
    position: static;
    width: auto;
    margin: 6cqw 6cqw 0;
    padding: 0 0 6cqw 3cqw;
    gap: 4cqw;
    justify-content: flex-start;
  }

  .card-details .card-year,
  .card-details .card-category {
    font-size: 11px;
  }

  .card-desc {
    font-size: 14px;
  }

  .card-cover {
    aspect-ratio: 4 / 3;
  }

  .card-cover--xr img {
    position: static;
    width: 100%;
    height: 100%;
    object-position: 100% 50%;
  }
}

/* ── About scene (scroll track + sticky stage) ────────── */
/* head-scene.js drives the head spin and the head/text slide from scroll position */

.about-scene {
  position: relative;
  z-index: 6;               /* above the stacked cards (.card--a…e) */
  width: 100%;
  height: 200dvh;
  /* Overlap the end of .card-swap-slot so the head starts spinning in while
     the last card is still tilting away */
  margin-top: -50dvh;
  pointer-events: none;     /* transparent stage must not block the last card */
  /* Head + text sit vertically centered in the stage, leaving empty space below
     them; pull the footer up into that space (~280px = half the content + air) */
  margin-bottom: min(0px, calc(280px - 50dvh));
}

.about-stage {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
}

#head-canvas-container {
  grid-area: 1 / 1;
  width: min(1280px, 100%);
  height: min(700px, 90dvh);
  overflow: hidden;
  will-change: transform;
}

#head-canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── About card (hero variant) ────────────────────────── */

#about {
  position: absolute;
  right: 6vw;
  top: 50%;
  width: min(44vw, 560px);
  background: transparent;  /* inherit main's background so the section blends in */
  cursor: default;
  text-align: left;
  translate: none;          /* opacity/transform are scroll-driven by head-scene.js */
  transition: none;
  will-change: transform, opacity;
}

#about:hover {
  transform: none;
  box-shadow: none;
}

#about .card-header {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

#about .card-year,
#about .card-category {
  color: rgba(237, 234, 229, 0.45);
}

#about .card-title-row {
  padding: 16px 0 48px;
  justify-content: flex-start;
}

#about .card-title {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 600;
  font-size: 80px;
  line-height: 0.88;
  color: #EDEAE5;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  text-align: left;
}

#about .card-body {
  text-align: left;
  padding: 0 0 48px;
}

#about .card-body p {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: rgba(237, 234, 229, 0.55);
  font-size: clamp(14px, 0.6vw + 11px, 18px);
  max-width: 420px;         /* just wider than the "ABOUT ME" title (~370px at 80px) */
  margin-inline: 0;
  text-wrap: balance;       /* even line lengths, no orphan words */
}

/* Column is narrower than the manual line breaks assume — let text flow */
#about .card-body br {
  display: none;
}

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 900px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  /* Nav */
  nav {
    padding: 0 20px;
    height: 70px;
  }

  .nav-hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(1, 1, 1, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 48px;
    gap: 16px;
    list-style: none;
    z-index: 99;
  }

  nav.menu-open .nav-links {
    display: flex;
  }

  .nav-links a {
    font-size: 28px;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(0, 0, 0, 0.6);
    padding: 16px 48px;
    border-radius: 8px;
  }

  /* Main */
  main {
    padding: 24px 12px 48px;
    gap: 8px;
  }

  /* Cards: minder padding aan de randen */
  .card-header      { padding: 8px 20px; }
  .card-title-row   { padding: 10px 20px 14px; }
  .card-media       { margin: 0 20px 24px; }
  .card-body        { padding: 0 20px 20px; }

  /* About */
  #about .card-title {
    font-size: clamp(40px, 12vw, 72px);
  }

  .about-scene {
    margin-bottom: 0;       /* text already sits at the bottom of the stage */
  }

  #about {
    left: 20px;
    right: 20px;
    top: auto;
    bottom: 8dvh;
    width: auto;
  }

  #about .card-title-row {
    padding: 12px 0 24px;
  }

  #about .card-body {
    padding-bottom: 0;
  }

  #head-canvas-container {
    height: 400px;
  }

  /* Cards grid */
  .cards-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* ── Footer ───────────────────────────────────────────── */

.site-footer {
  position: relative;
  z-index: 2;               /* paint over main's empty bottom (see .about-scene) */
  display: flex;
  justify-content: center;
  gap: 28px;
  padding: 48px 24px;
  background: #232323;
}

.site-footer a {
  display: block;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.site-footer a:hover {
  opacity: 1;
}

.site-footer img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: invert(1);
}

/* ── Modal ────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal.is-open {
  opacity: 1;
  pointer-events: all;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(18, 18, 18, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: #EDEAE5;
  border-radius: 16px;
  width: min(960px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  padding: 48px 54px;
  translate: 0 24px;
  transition: translate 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.is-open .modal-content {
  translate: 0 0;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: #3D3D3D;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.15s ease;
}

.modal-close:hover { color: #000; }

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1.75fr;
  gap: 48px;
  align-items: start;
}

.modal-meta {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #3D3D3D;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.modal-title {
  font-family: 'Roboto', sans-serif;
  font-size: clamp(24px, 3.5vw, 42px);
  font-weight: 400;
  color: #000;
  line-height: 1;
  margin-bottom: 28px;
  border-bottom: 0.25px solid #cac7bf;
  padding-bottom: 28px;
}

.modal-text p {
  font-size: 14px;
  color: #4a4a4a;
  line-height: 1.75;
  margin-bottom: 14px;
}

.modal-text p:last-child { margin-bottom: 0; }

.modal-text a {
  color: #1a1a1a;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.modal-text a:hover { opacity: 0.6; }

.modal-images {
  position: relative;
  align-self: center;
}

.modal-carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  border-radius: 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.modal-carousel-track::-webkit-scrollbar {
  display: none;
}

.modal-image {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 16 / 9;
  scroll-snap-align: start;
  overflow: hidden;
  background: repeating-linear-gradient(
    -45deg,
    #d0cfcb 0px, #d0cfcb 6px,
    #c4c1bb 6px, #c4c1bb 12px
  );
}

.modal-image--portrait {
  aspect-ratio: 3 / 4;
}

.modal-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-image video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.modal-carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.55);
  color: #EDEAE5;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.modal-carousel-arrow:hover {
  background: rgba(20, 20, 20, 0.8);
}

.modal-carousel-arrow--prev { left: 12px; }
.modal-carousel-arrow--next { right: 12px; }

.modal-carousel-dots {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}

.modal-carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(237, 234, 229, 0.5);
  cursor: pointer;
  transition: background 0.2s ease;
}

.modal-carousel-dot.is-active {
  background: #EDEAE5;
}

@media (max-width: 680px) {
  .modal-content { padding: 32px 24px; }

  .modal-body {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}
