/* =========================================================
   Matthieu Ndiaye — Portfolio
   Design system + layout + motion-friendly styles
   ========================================================= */

/* ---------- Theme tokens ---------- */
:root {
  --bg: #0e0e0d;
  --fg: #f2efe6;
  --muted: #8c8a82;
  --line: rgba(242, 239, 230, 0.14);
  --accent: #8c9bab; /* steel — dark mode */

  --ff-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --ff-body: "Space Grotesk", system-ui, -apple-system, sans-serif;

  --maxw: 1440px;
  --pad: clamp(20px, 5vw, 80px);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.8s;
}

:root[data-theme="light"] {
  --bg: #f2efe6;
  --fg: #14130f;
  --muted: #6d6b62;
  --line: rgba(20, 19, 15, 0.16);
  --accent: #4f5e6c; /* steel — light mode */
}

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

html { -webkit-text-size-adjust: 100%; }

/* Lenis smooth scroll: html height auto, no scroll-behavior */
html.lenis,
html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ff-body);
  font-size: 17px;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background 0.6s var(--ease), color 0.6s var(--ease);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
ul { list-style: none; }

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

/* ---------- Typography ---------- */
.display {
  font-family: var(--ff-display);
  font-weight: 400;
  line-height: 0.96;
  letter-spacing: -0.025em;
}
h1.display { font-size: clamp(2.6rem, 9vw, 8rem); }
h2.display { font-size: clamp(2rem, 6vw, 5rem); }

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

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

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-inline: var(--pad); }
section { padding-block: clamp(60px, 12vh, 160px); }

/* ---------- Custom cursor ---------- */
.cursor {
  position: fixed;
  top: 0; left: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width 0.3s var(--ease), height 0.3s var(--ease), background 0.3s var(--ease);
  mix-blend-mode: difference;
}
.cursor.is-hover { width: 56px; height: 56px; background: var(--fg); }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ---------- Loader ---------- */
.loader {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 10000;
  display: grid; place-items: center;
}
.loader__count {
  font-family: var(--ff-display);
  font-size: clamp(3rem, 12vw, 9rem);
  font-weight: 500;
  letter-spacing: -0.03em;
}
body.loaded .loader { pointer-events: none; }

/* ---------- Page transition overlay ---------- */
.transition {
  position: fixed; inset: 0;
  background: var(--accent);
  z-index: 9998;
  transform: translateY(-100%); /* resting state = hidden above; failsafe if JS never runs */
  pointer-events: none;
}

/* ---------- Header ---------- */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px var(--pad);
  mix-blend-mode: difference;
  color: #f2efe6;
}
.header a, .header button { color: inherit; }
.brand { font-family: var(--ff-display); font-weight: 500; letter-spacing: -0.01em; font-size: 1.05rem; }
.nav { display: flex; gap: clamp(16px, 3vw, 40px); align-items: center; }
.nav a { font-size: 0.85rem; letter-spacing: 0.04em; position: relative; }
.nav a::after {
  content: ""; position: absolute; left: 0; bottom: -4px;
  width: 100%; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform 0.4s var(--ease);
}
.nav a:hover::after, .nav a[aria-current="page"]::after { transform: scaleX(1); transform-origin: left; }

.controls { display: flex; gap: 14px; align-items: center; }
.ctrl {
  font-size: 0.78rem; letter-spacing: 0.06em; line-height: 1;
  background: none; border: none; border-radius: 0; padding: 0;
}
a.ctrl { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
a.ctrl:hover { color: var(--accent); }
.lang-btn span { opacity: 0.4; }
.lang-btn span.active { opacity: 1; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

@media (max-width: 640px) {
  .nav { gap: 14px; }
  .nav a span.full { display: none; }
}

/* ---------- Hero ---------- */
.hero { min-height: 100svh; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: clamp(40px, 8vh, 90px); }
.hero h1 { overflow: hidden; }
.hero h1 .line { display: block; }
.hero__meta { display: flex; flex-wrap: wrap; gap: 24px 60px; margin-top: clamp(24px, 4vh, 48px); border-top: 1px solid var(--line); padding-top: 22px; }
.hero__meta p { max-width: 46ch; }
.hero__meta-side { display: flex; flex-direction: column; gap: 10px; }
.location { display: inline-flex; align-items: center; gap: 7px; }
.location svg { opacity: 0.75; }

/* ---------- Marquee ---------- */
.marquee { overflow: hidden; border-block: 1px solid var(--line); padding-block: 18px; white-space: nowrap; }
.marquee__inner { display: inline-flex; gap: 40px; will-change: transform; }
.marquee__inner span { font-family: var(--ff-display); font-size: clamp(1.4rem, 4vw, 3rem); font-weight: 500; letter-spacing: -0.01em; }
.marquee__inner span::after { content: "—"; margin-left: 40px; color: var(--accent); }

/* ---------- Work grid ---------- */
.work-head { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; margin-bottom: clamp(30px, 5vh, 60px); }
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(16px, 2vw, 32px);
}
.card { grid-column: span 6; cursor: pointer; }
.card:nth-child(4n + 1), .card:nth-child(4n) { grid-column: span 6; }
.card__media {
  position: relative; overflow: hidden;
  aspect-ratio: 4 / 5; background: var(--line);
}
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.9s var(--ease), filter 0.6s var(--ease); }
.card:hover .card__media img { transform: scale(1.05); }
.card__placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-family: var(--ff-display); font-size: 0.9rem; letter-spacing: 0.1em;
  text-transform: uppercase;
}
.card__foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; gap: 16px; }
.card__title { font-family: var(--ff-display); font-weight: 400; font-size: 1.25rem; letter-spacing: -0.015em; }
.card__type { color: var(--muted); font-size: 0.85rem; }
.card__year { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 760px) {
  .card, .card:nth-child(4n + 1), .card:nth-child(4n) { grid-column: span 12; }
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(8, 8, 7, 0.96);
  display: none; flex-direction: column;
  opacity: 0;
}
.lightbox.open { display: flex; }
.lightbox__bar { display: flex; justify-content: space-between; align-items: center; padding: 22px var(--pad); color: #f2efe6; }
.lightbox__title { font-family: var(--ff-display); font-size: 1.2rem; font-weight: 400; letter-spacing: -0.01em; }
.lightbox__close { font-size: 0.85rem; letter-spacing: 0.1em; text-transform: uppercase; }
.lightbox__stage { flex: 1; display: flex; align-items: center; justify-content: center; gap: 20px; padding: 0 var(--pad) 20px; min-height: 0; }
.lightbox__img { aspect-ratio: 4 / 5; height: min(68vh, 108vw); width: auto; object-fit: cover; background: #000; display: block; }
.lightbox__placeholder { width: min(700px, 80vw); aspect-ratio: 4/5; background: #1a1a18; display: grid; place-items: center; color: #6d6b62; font-family: var(--ff-display); letter-spacing: 0.1em; }
.lightbox__nav { color: #f2efe6; font-size: 2rem; padding: 12px; opacity: 0.7; transition: opacity 0.3s; flex: none; }
.lightbox__nav:hover { opacity: 1; }
.lightbox__foot { padding: 0 var(--pad) 26px; }
.lightbox__desc { color: #c9c6bd; max-width: 760px; margin: 0 auto 14px; text-align: center; font-size: 0.95rem; line-height: 1.55; }
.lightbox__role { color: #8c8a82; max-width: 760px; margin: -4px auto 14px; text-align: center; font-size: 0.85rem; line-height: 1.5; }
.lightbox__role:empty { display: none; }
.lightbox__meta { display: flex; align-items: center; justify-content: center; gap: 18px; color: #8c8a82; font-size: 0.85rem; letter-spacing: 0.08em; }
.lightbox__insta { color: #c9c6bd; text-decoration: underline; text-underline-offset: 3px; }
.lightbox__insta:hover { color: #fff; }
.lightbox__insta[hidden] { display: none; }

/* ---------- Timeline (Experience) ---------- */
.timeline { border-top: 1px solid var(--line); }
.tl-item {
  display: grid; grid-template-columns: 140px 1fr; gap: clamp(16px, 4vw, 60px);
  padding-block: clamp(28px, 5vh, 48px); border-bottom: 1px solid var(--line);
  align-items: start;
}
.tl-item__date { color: var(--muted); font-size: 0.9rem; padding-top: 6px; }
.tl-item__company { font-family: var(--ff-display); font-size: clamp(1.5rem, 3.4vw, 2.5rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.04; }
.tl-item__role { color: var(--accent); margin-top: 6px; font-size: 1rem; letter-spacing: 0.01em; }
.tl-item__desc { color: var(--muted); margin-top: 14px; max-width: 60ch; }
.tl-item__tags { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 16px; }
.tag { font-size: 0.75rem; letter-spacing: 0.04em; color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; text-decoration-thickness: 1px; }
@media (max-width: 640px) { .tl-item { grid-template-columns: 1fr; gap: 6px; } }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 30px; }
.skills h3 { font-family: var(--ff-display); font-size: 1.1rem; margin-bottom: 14px; }
.skills li { color: var(--muted); padding-block: 6px; border-bottom: 1px solid var(--line); }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(30px, 6vw, 90px); align-items: start; }
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; } }
.bio p { font-size: clamp(1.1rem, 2.2vw, 1.5rem); line-height: 1.5; margin-bottom: 1.2em; }
.about-portrait { position: sticky; top: 100px; aspect-ratio: 4/5; background: var(--line); display: grid; place-items: center; color: var(--muted); font-family: var(--ff-display); letter-spacing: 0.1em; overflow: hidden; }
.about-portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Contact ---------- */
.contact a.big { font-family: var(--ff-display); font-size: clamp(1.5rem, 7vw, 6rem); font-weight: 400; letter-spacing: -0.025em; line-height: 1.05; display: block; max-width: 100%; overflow-wrap: anywhere; }
.contact a.big:hover { color: var(--accent); }
.socials { display: flex; gap: 30px; flex-wrap: wrap; margin-top: 40px; }
.socials a { color: var(--muted); position: relative; }
.socials a:hover { color: var(--fg); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding-block: 40px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 0.85rem; }

/* ---------- Reveal animation defaults (used by JS / fallback) ---------- */
[data-reveal] { opacity: 0; transform: translateY(40px); }
.no-js [data-reveal] { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1 !important; transform: none !important; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
