/* ==========================================================================
   Manel Benyoucef — portfolio
   Single stylesheet, no preprocessor, no framework.

   Contents
     1.  Design tokens
     2.  Reset & base
     3.  Typography
     4.  Layout primitives
     5.  Reveal animations
     6.  Buttons & icon buttons
     7.  Header / nav / language switch
     8.  Hero + 3D constellation
     9.  Sections (shared)
     10. About + timeline
     11. Work gallery (3D)
     12. Expertise cards
     13. Certifications + education
     14. Lightbox
     15. Contact + footer
     16. Responsive
     17. Reduced motion & print
   ========================================================================== */

/* 1. Design tokens ------------------------------------------------------- */
:root {
  /* Surfaces — deep maroon-black with a red undertone. */
  --ink-900: #0d0308;
  --ink-800: #1a0710;
  --ink-700: #260a16;
  --ink-600: #330d1c;
  --ink-500: #431224;

  /* Ink on dark. */
  --text:      #ece9e4;
  --text-soft: #bea9b1;
  --text-dim:  #8c727c;

  /* Crimson accent — from Manel's colour palette. */
  --accent:      #c50337;
  --accent-soft: #ffa1bc;
  --accent-deep: #9f0430;
  --on-accent:   #fffbff;
  --plum:        #400020;

  --line:        rgba(236, 233, 228, 0.10);
  --line-strong: rgba(236, 233, 228, 0.20);

  /* Type. Zero webfont requests: a serif display paired with the platform
     UI sans reads as designed while costing nothing on mobile data. */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino,
                  "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  /* Fluid type scale, 360px → 1440px viewports.
     xs/sm carry the eyebrows, tags and meta lines. They are uppercase and
     letterspaced, which reads smaller than the nominal size, so the floor
     is 13px rather than the 12px the scale would otherwise suggest. */
  --fs-xs:   clamp(0.8125rem, 0.795rem + 0.08vw, 0.875rem);
  --fs-sm:   clamp(0.875rem,  0.855rem + 0.09vw, 0.9375rem);
  --fs-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1.0625rem);
  --fs-lg:   clamp(1.0625rem, 1rem + 0.4vw, 1.25rem);
  --fs-xl:   clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --fs-2xl:  clamp(1.75rem, 1.4rem + 1.6vw, 2.75rem);
  --fs-3xl:  clamp(2.5rem, 1.6rem + 4.2vw, 5.5rem);
  --fs-4xl:  clamp(3.25rem, 1.4rem + 8vw, 8.5rem);

  /* Spacing — 4px base. */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-5: 1.5rem;   --sp-6: 2rem;
  --sp-7: 3rem;     --sp-8: 4rem;     --sp-9: 6rem;
  --sp-10: 8rem;

  --shell:   78rem;
  --radius:  14px;
  --radius-lg: 22px;

  --ease:      cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur:       0.45s;
  --dur-slow:  0.9s;

  --header-h: 4.5rem;
}

/* 2. Reset & base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchors clear the fixed header. */
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  min-height: 100svh;
  background-color: var(--ink-900);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
svg { width: 100%; height: 100%; }

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

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

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

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

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

/* Body scroll lock while a modal or the mobile menu is open. */
body.is-locked { overflow: hidden; }

/* 3. Typography ---------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p { text-wrap: pretty; }

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

.skip-link {
  position: fixed;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: 200;
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-sm);
  font-weight: 600;
  border-radius: 8px;
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus { transform: translateY(0); }

/* 4. Layout primitives --------------------------------------------------- */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
}

.section {
  position: relative;
  padding-block: clamp(4rem, 9vw, var(--sp-10));
}

/* Hairline between sections, inset so it reads as a drawn rule. */
.section + .section::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: clamp(1.25rem, 4vw, 3rem);
  height: 1px;
  background: linear-gradient(90deg,
    transparent, var(--line) 18%, var(--line) 82%, transparent);
}

/* 5. Reveal animations ---------------------------------------------------
   Scoped to `.js`: without JavaScript nothing would ever add .is-visible,
   so the content must never start hidden in the first place. The inline
   script in <head> sets this class before first paint. */
.js .reveal {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
  will-change: opacity, transform;
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* 6. Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0.8125rem 1.625rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
  transition:
    background-color 0.3s var(--ease),
    color 0.3s var(--ease),
    border-color 0.3s var(--ease),
    transform 0.3s var(--ease);
}
.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn--ghost {
  border-color: var(--line-strong);
  color: var(--text);
}

@media (hover: hover) {
  /* On hover the fill inverts to the pale pink, so the text flips dark. */
  .btn--primary:hover { background: var(--accent-soft); color: var(--ink-900); transform: translateY(-2px); }
  .btn--ghost:hover   { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
}
.btn:active { transform: translateY(0); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.6875rem;
  color: var(--text-soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease),
              background-color 0.25s var(--ease);
}
@media (hover: hover) {
  .icon-btn:hover { color: var(--accent); border-color: var(--accent); }
}
.icon-btn[disabled] { opacity: 0.3; cursor: not-allowed; }

/* 7. Header -------------------------------------------------------------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  transition: background-color 0.4s var(--ease), border-color 0.4s var(--ease),
              backdrop-filter 0.4s var(--ease);
  border-bottom: 1px solid transparent;
}
.site-header.is-stuck {
  background: rgba(7, 8, 11, 0.72);
  border-bottom-color: var(--line);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}
/* Backdrop-filter is unsupported on some Android WebViews — fall back to a
   solid bar rather than an unreadable transparent one. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header.is-stuck { background: rgba(7, 8, 11, 0.96); }
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.brand { display: flex; align-items: center; gap: 0.625rem; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 7px;
}
.brand__name {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
}

.nav__list { display: flex; gap: clamp(1rem, 2.4vw, 2.25rem); }
.nav__link {
  position: relative;
  font-size: var(--fs-sm);
  color: var(--text-soft);
  padding-block: var(--sp-2);
  transition: color 0.25s var(--ease);
}
.nav__link::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0.25rem;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}
@media (hover: hover) { .nav__link:hover { color: var(--text); } }
.nav__link:hover::after,
.nav__link.is-current::after { transform: scaleX(1); }
.nav__link.is-current { color: var(--text); }

.header-actions { display: flex; align-items: center; gap: var(--sp-3); }

.lang {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.lang__btn {
  padding: 0.25rem 0.6875rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-radius: 999px;
  transition: color 0.25s var(--ease), background-color 0.25s var(--ease);
}
.lang__btn.is-active { color: var(--on-accent); background: var(--accent); }
@media (hover: hover) {
  .lang__btn:not(.is-active):hover { color: var(--text); }
}

.menu-toggle {
  display: none;
  width: 2.5rem; height: 2.5rem;
  place-items: center;
  gap: 5px;
  grid-auto-flow: row;
}
.menu-toggle__bar {
  width: 18px; height: 1.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.35s var(--ease), opacity 0.2s var(--ease);
}
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:first-child {
  transform: translateY(3.25px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:last-child {
  transform: translateY(-3.25px) rotate(-45deg);
}

/* 8. Hero ---------------------------------------------------------------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding-block: calc(var(--header-h) + 2rem) var(--sp-8);
  overflow: hidden;
  isolation: isolate;
  /* The gradient is the real background. The canvas paints over it when
     WebGL is available; when it isn't, this is what visitors see and it
     still looks intentional. */
  background:
    radial-gradient(90% 70% at 72% 18%, rgba(197, 3, 55, 0.18), transparent 62%),
    radial-gradient(70% 60% at 18% 78%, rgba(64, 0, 32, 0.9), transparent 65%),
    linear-gradient(170deg, #0f040b 0%, var(--ink-900) 55%, #0b0207 100%);
}

.hero__canvas {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.2s var(--ease-out);
}
.hero__canvas.is-ready { opacity: 1; }

/* Fine film grain, drawn as an inline SVG so it costs no extra request.
   It hides gradient banding on 8-bit panels. */
.hero__grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* Fade the hero into the next section instead of cutting hard. */
.hero::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 22vh;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--ink-900));
}

.hero__inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 4.5rem);
  width: 100%;
}

.hero__copy { max-width: 34rem; }

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: var(--sp-5);
}
.hero__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(197, 3, 55, 0.6);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(197, 3, 55, 0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(197, 3, 55, 0); }
  100% { box-shadow: 0 0 0 0 rgba(197, 3, 55, 0); }
}

.hero__title {
  font-size: var(--fs-4xl);
  line-height: 0.92;
  letter-spacing: -0.035em;
  margin-bottom: var(--sp-4);
}
.hero__line { display: block; }
.hero__line--accent {
  color: transparent;
  background: linear-gradient(100deg, var(--accent-soft) 8%, var(--accent) 48%, var(--accent-deep) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  font-style: italic;
  padding-inline-end: 0.08em; /* room for the italic overhang */
}

.hero__role {
  font-size: var(--fs-xl);
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: var(--sp-4);
}

.hero__lede {
  font-size: var(--fs-lg);
  color: var(--text-soft);
  max-width: 30rem;
  margin-bottom: var(--sp-6);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-7);
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1.5rem, 4vw, 3rem);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
}
.stat__label {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}
.stat__value {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  color: var(--accent);
  margin-inline-start: 0;
}

/* --- Constellation ------------------------------------------------------ */
.constellation {
  position: relative;
  height: min(34rem, 62svh);
  perspective: 1000px;
  perspective-origin: 50% 45%;
}
.constellation__stage {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  /* JS writes --rx / --ry from pointer position and --pz from scroll. */
  transform:
    translate3d(0, var(--py, 0px), var(--pz, 0px))
    rotateX(var(--rx, 0deg))
    rotateY(var(--ry, 0deg));
  transition: transform 0.5s var(--ease-out);
}
.constellation__stage.is-tracking { transition: none; }

.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: var(--radius);
  border: 1px solid rgba(236, 233, 228, 0.14);
  background: rgba(23, 27, 38, 0.55);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  backdrop-filter: blur(10px) saturate(130%);
  box-shadow:
    0 24px 60px -24px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  /* --tx/--ty are set from data-x/data-y (in %), --tz from data-depth (px).
     Each panel also gets its own float animation offset. */
  transform:
    translate3d(-50%, -50%, 0)
    translate3d(var(--tx, 0), var(--ty, 0), var(--tz, 0px));
  animation: float 12s var(--ease) infinite alternate;
  animation-delay: var(--float-delay, 0s);
}
@keyframes float {
  from { margin-top: -8px; }
  to   { margin-top: 8px; }
}

.panel--img {
  width: clamp(9rem, 17vw, 13.5rem);
  aspect-ratio: 1.414;
  padding: 0;
}
.panel--img img { width: 100%; height: 100%; object-fit: cover; opacity: 0.9; }

.panel--photo {
  width: clamp(7rem, 12vw, 9.5rem);
  aspect-ratio: 0.82;
}
.panel__monogram {
  display: grid;
  place-items: center;
  height: 100%;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  letter-spacing: 0.04em;
  color: var(--accent);
  background:
    radial-gradient(120% 100% at 30% 12%, rgba(197, 3, 55, 0.22), transparent 62%);
}

.panel--tag {
  padding: 0.6875rem 1.125rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  border-radius: 999px;
}
.panel--tag-alt { color: var(--accent); border-color: rgba(197, 3, 55, 0.35); }

.panel--stat {
  padding: var(--sp-4) var(--sp-5);
  text-align: center;
}
.panel--stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 400;
  color: var(--accent);
  line-height: 1;
}
.panel--stat span {
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: clamp(1.25rem, 3vh, 2.25rem);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: color 0.3s var(--ease);
}
@media (hover: hover) { .scroll-cue:hover { color: var(--accent); } }
.scroll-cue__line {
  width: 1px; height: 2.75rem;
  background: linear-gradient(to bottom, transparent, var(--line-strong) 40%, var(--accent));
  transform-origin: top;
  animation: cue 2.4s var(--ease) infinite;
}
@keyframes cue {
  0%, 100% { transform: scaleY(0.35); opacity: 0.4; }
  50%      { transform: scaleY(1);    opacity: 1; }
}

/* 9. Sections ------------------------------------------------------------ */
.section__head { margin-bottom: clamp(2.5rem, 5vw, 4rem); max-width: 46rem; }

.section__index {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-bottom: var(--sp-3);
}
.section__title {
  font-size: var(--fs-2xl);
  margin-bottom: var(--sp-3);
}
.section__sub {
  font-size: var(--fs-lg);
  color: var(--text-soft);
  max-width: 40rem;
}

/* 10. About + timeline --------------------------------------------------- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(2.5rem, 6vw, 5rem);
  align-items: start;
}

.about__lede {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  line-height: 1.4;
  color: var(--text);
  margin-bottom: var(--sp-5);
}
.about__body p + p { margin-top: var(--sp-4); color: var(--text-soft); }

.about__langs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-6);
}
.lang-chip {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4375rem 0.875rem;
  font-size: var(--fs-sm);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.lang-chip__name { color: var(--text); }
.lang-chip__level { color: var(--text-dim); font-size: var(--fs-xs); }

.timeline { position: relative; padding-inline-start: var(--sp-5); }
.timeline::before {
  content: "";
  position: absolute;
  inset-block: 0.5rem 0.5rem;
  inset-inline-start: 0;
  width: 1px;
  background: linear-gradient(to bottom, var(--accent), var(--line) 30%, transparent);
}
.timeline__item { position: relative; padding-bottom: var(--sp-6); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: "";
  position: absolute;
  top: 0.55rem;
  inset-inline-start: calc(var(--sp-5) * -1);
  width: 7px; height: 7px;
  margin-inline-start: -3px;
  border-radius: 50%;
  background: var(--ink-900);
  border: 1px solid var(--accent);
}
.timeline__item:first-child::before { background: var(--accent); }

.timeline__date {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.375rem;
}
.timeline__role { font-size: var(--fs-lg); margin-bottom: 0.125rem; }
.timeline__org { font-size: var(--fs-sm); color: var(--accent); margin-bottom: 0.375rem; }
.timeline__note { font-size: var(--fs-sm); color: var(--text-dim); }

/* 11. Work gallery ------------------------------------------------------- */
.section--work { padding-inline: 0; }
.section--work > .shell { margin-bottom: clamp(2rem, 4vw, 3rem); }

.gallery { position: relative; }

.gallery__viewport {
  position: relative;
  padding-block: clamp(1.5rem, 4vw, 3rem);
  padding-inline: max(calc((100vw - var(--shell)) / 2), clamp(1.25rem, 4vw, 3rem));
  overflow: hidden;
  perspective: 1400px;
  perspective-origin: 50% 50%;
  cursor: grab;
  /* Vertical scrolling stays native; horizontal drags belong to us. */
  touch-action: pan-y;
}
.gallery__viewport.is-dragging { cursor: grabbing; }
.gallery__viewport:focus-visible { outline-offset: -3px; }

.gallery__track {
  display: flex;
  gap: clamp(1rem, 2.5vw, 2rem);
  transform-style: preserve-3d;
  transform: translate3d(var(--shift, 0px), 0, 0);
  will-change: transform;
}
.gallery__track.is-settling { transition: transform 0.6s var(--ease-out); }

.project {
  flex: 0 0 auto;
  width: clamp(16rem, 27vw, 22rem);
  transform-style: preserve-3d;
  /* --a is the item's signed distance from viewport centre, set by JS. */
  transform: rotateY(calc(var(--a, 0) * -14deg))
             translate3d(0, 0, calc(var(--az, 0) * -1px));
  transition: transform 0.5s var(--ease-out), opacity 0.5s var(--ease-out);
}
/* While a finger or cursor is down, the pose is recomputed every frame.
   Leaving the transition on would make each card chase its own last value,
   which reads as a laggy smear rather than a direct drag. */
.gallery__viewport.is-dragging .project { transition: none; }

.project__inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: clamp(1.25rem, 2.4vw, 1.875rem);
  min-height: clamp(20rem, 34vw, 26rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(158deg, rgba(33, 38, 47, 0.82), rgba(11, 13, 19, 0.9));
  box-shadow: 0 30px 70px -34px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  transition: border-color 0.4s var(--ease);
}
.project__inner::after {
  /* Sheen that tracks the rotation, sells the 3D. */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg,
    rgba(255, 255, 255, 0.07) 0%, transparent 42%, transparent 60%,
    rgba(0, 0, 0, 0.22) 100%);
  opacity: calc(0.35 + (var(--a, 0) * 0.35));
}
.project.is-active .project__inner { border-color: rgba(197, 3, 55, 0.4); }

.project__media {
  position: relative;
  aspect-ratio: 4 / 3;
  margin: calc(clamp(1.25rem, 2.4vw, 1.875rem) * -1);
  margin-bottom: var(--sp-5);
  background: var(--ink-700);
  overflow: hidden;
}
.project__media img { width: 100%; height: 100%; object-fit: cover; }

/* Typographic stand-in for projects without artwork yet. */
.project__media--type {
  display: grid;
  place-items: center;
  background:
    radial-gradient(110% 90% at 28% 16%, rgba(197, 3, 55, 0.14), transparent 60%),
    linear-gradient(160deg, var(--ink-600), var(--ink-800));
}
.project__initials {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 6vw, 4rem);
  color: rgba(236, 233, 228, 0.12);
  letter-spacing: 0.06em;
}

.project__tag {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}
.project__title { font-size: var(--fs-xl); margin-bottom: 0.25rem; }
.project__role { font-size: var(--fs-sm); color: var(--text-soft); margin-bottom: var(--sp-3); }
.project__summary { font-size: var(--fs-sm); color: var(--text-dim); }
.project__year {
  margin-top: auto;
  padding-top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.gallery__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}
.gallery__hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.gallery__hint-icon { color: var(--accent); font-size: 1rem; }
.gallery__buttons { display: flex; gap: var(--sp-2); }

/* 12. Expertise cards ---------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}
.card {
  position: relative;
  padding: clamp(1.5rem, 2.6vw, 2.125rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(23, 27, 38, 0.5), rgba(11, 13, 19, 0.5));
  transition: border-color 0.4s var(--ease), transform 0.4s var(--ease),
              background-color 0.4s var(--ease);
}
@media (hover: hover) {
  .card:hover {
    border-color: rgba(197, 3, 55, 0.32);
    transform: translateY(-4px);
  }
}
.card__num {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: var(--sp-4);
}
.card__title { font-size: var(--fs-lg); margin-bottom: var(--sp-2); }
.card__text { font-size: var(--fs-sm); color: var(--text-soft); margin-bottom: var(--sp-4); }
.card__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* 13. Certifications ----------------------------------------------------- */
.cert-group { margin-bottom: clamp(2.5rem, 5vw, 3.75rem); }
.cert-group:last-child { margin-bottom: 0; }

.cert-group__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.cert-group__label {
  font-size: var(--fs-lg);
  font-family: var(--font-display);
}
.cert-group__count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--accent);
  letter-spacing: 0.12em;
}
.cert-group__note {
  flex-basis: 100%;
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: clamp(0.875rem, 1.8vw, 1.375rem);
}

.cert {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-800);
  overflow: hidden;
  transition: border-color 0.35s var(--ease), transform 0.35s var(--ease);
}
@media (hover: hover) {
  .cert:hover { border-color: rgba(197, 3, 55, 0.4); transform: translateY(-3px); }
  .cert:hover .cert__img { transform: scale(1.04); }
}
.cert__frame {
  position: relative;
  aspect-ratio: 1.414;
  overflow: hidden;
  background: var(--ink-700);
}
.cert__img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: transform 0.7s var(--ease-out);
}
.cert__zoom {
  position: absolute;
  right: 0.625rem; bottom: 0.625rem;
  display: grid;
  place-items: center;
  width: 1.875rem; height: 1.875rem;
  font-size: 0.875rem;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
@media (hover: hover) {
  .cert:hover .cert__zoom, .cert:focus-visible .cert__zoom { opacity: 1; transform: none; }
}
.cert__body { padding: var(--sp-4); display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.cert__title { font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 600; line-height: 1.35; letter-spacing: 0; }
.cert__issuer { font-size: var(--fs-xs); color: var(--text-soft); }
.cert__year {
  margin-top: auto;
  padding-top: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.cert-education { margin-top: clamp(3rem, 6vw, 4.5rem); max-width: none; }
.cert-education__title { font-size: var(--fs-xl); margin-bottom: var(--sp-5); }
.edu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: clamp(1rem, 2vw, 1.75rem);
}
.edu__item { padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.edu__date {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.edu__degree { font-size: var(--fs-base); margin-bottom: 0.125rem; }
.edu__org { font-size: var(--fs-sm); color: var(--text-dim); }

/* 14. Lightbox ----------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2.5rem);
}
.lightbox[hidden] { display: none; }

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 7, 0.88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.lightbox.is-open .lightbox__backdrop { opacity: 1; }

.lightbox__panel {
  position: relative;
  width: min(60rem, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  opacity: 0;
  transform: scale(0.97) translateY(12px);
  transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}
.lightbox.is-open .lightbox__panel { opacity: 1; transform: none; }

.lightbox__close {
  position: absolute;
  top: calc(var(--sp-4) * -1);
  inset-inline-end: 0;
  width: 2.5rem; height: 2.5rem;
  padding: 0.5625rem;
  color: var(--text-soft);
  transform: translateY(-100%);
  transition: color 0.25s var(--ease);
}
@media (hover: hover) { .lightbox__close:hover { color: var(--accent); } }

.lightbox__figure {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ink-800);
  border: 1px solid var(--line);
}
.lightbox__img {
  width: 100%;
  max-height: 66svh;
  object-fit: contain;
  background: #fff;
}
.lightbox__caption { padding: var(--sp-4) var(--sp-5); }
.lightbox__title { font-family: var(--font-sans); font-size: var(--fs-base); font-weight: 600; letter-spacing: 0; margin-bottom: 0.125rem; }
.lightbox__issuer { font-size: var(--fs-sm); color: var(--text-dim); }

.lightbox__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
}
.lightbox__count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  color: var(--text-dim);
  min-width: 5rem;
  text-align: center;
}

/* 15. Contact + footer --------------------------------------------------- */
.section--contact { text-align: center; }
.contact { max-width: 42rem; margin-inline: auto; }
.contact .section__index { margin-bottom: var(--sp-4); }
.contact__title { font-size: var(--fs-2xl); margin-bottom: var(--sp-4); }
.contact__lede { font-size: var(--fs-lg); color: var(--text-soft); margin-bottom: var(--sp-6); }

.contact__mail {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 1rem + 1.6vw, 2.25rem);
  color: var(--accent);
  letter-spacing: -0.01em;
  word-break: break-word;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.45s var(--ease);
}
@media (hover: hover) { .contact__mail:hover { background-size: 100% 1px; } }

.contact__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}
.contact__links:empty { display: none; }

.contact__loc {
  margin-top: var(--sp-6);
  font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.site-footer {
  padding-block: var(--sp-5);
  border-top: 1px solid var(--line);
}
.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
/* "Back to top" is a 12px line of text, which gives it a ~20px hit box —
   under the 24px WCAG 2.2 (2.5.8) minimum. Padding brings the target up
   without changing how it looks; the negative margin keeps the footer
   height unchanged. */
.site-footer__top {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding-inline: var(--sp-2);
  margin-inline: calc(var(--sp-2) * -1);
  transition: color 0.25s var(--ease);
}
@media (hover: hover) { .site-footer__top:hover { color: var(--accent); } }

/* 16. Responsive --------------------------------------------------------- */
@media (max-width: 62rem) {
  .hero__inner { grid-template-columns: 1fr; }
  .constellation { display: none; } /* the copy is the hero on small screens */
  .about { grid-template-columns: 1fr; }
}

@media (max-width: 48rem) {
  :root { --header-h: 4rem; }

  .brand__name { display: none; }
  .menu-toggle { display: grid; }

  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    background: rgba(7, 8, 11, 0.97);
    border-bottom: 1px solid var(--line);
    padding: var(--sp-4) clamp(1.25rem, 4vw, 3rem) var(--sp-5);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s var(--ease), transform 0.28s var(--ease),
                visibility 0s linear 0.28s;
  }
  .nav.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }
  .nav__list { flex-direction: column; gap: 0; }
  .nav__link {
    display: block;
    padding-block: var(--sp-3);
    font-size: var(--fs-lg);
    border-bottom: 1px solid var(--line);
  }
  .nav__link::after { display: none; }

  .hero { min-height: auto; padding-block: calc(var(--header-h) + 4rem) var(--sp-9); }
  .hero__stats { gap: var(--sp-5); }
  .scroll-cue { display: none; }

  .gallery__viewport { perspective: 900px; }
  .project { width: min(78vw, 20rem); }
  .gallery__controls { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .gallery__buttons { justify-content: center; }

  .lightbox__close { position: static; transform: none; align-self: flex-end; }
  .lightbox__img { max-height: 54svh; }
}

@media (max-width: 30rem) {
  .hero__actions .btn { flex: 1 1 auto; }
}

/* 17. Reduced motion & print --------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  /* Specificity must beat `.js .reveal`, which is where the hidden state
     lives — a bare `.reveal` here would lose and leave content invisible. */
  .js .reveal { opacity: 1; transform: none; }
  .panel { animation: none; }
  .constellation__stage { transform: none; }
  .project { transform: none; }
}

@media print {
  .site-header, .scroll-cue, .gallery__controls, .lightbox,
  .hero__canvas, .hero__grain, .constellation, .skip-link { display: none !important; }

  :root { --text: #111; --text-soft: #333; --text-dim: #555; --accent: #9f0430; }
  body { background: #fff; color: #111; }
  .section { padding-block: 1.5rem; break-inside: avoid; }
  .cert, .card, .project__inner { border-color: #ccc; background: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.75em; color: #555; }
}

