/* =========================================================
   ENZO OLIVEIRA — Portfolio
   Design system: ink-black / emerald / cream, condensed display
   ========================================================= */

:root {
  /* Color — semantic tokens */
  --ink:        #050605;
  --ink-2:      #0b0d0b;
  --ink-3:      #12140f;
  --cream:      #f2eee3;
  --cream-dim:  rgba(242, 238, 227, 0.62);
  --cream-faint:rgba(242, 238, 227, 0.34);
  --emerald:    #22e58a;
  --emerald-deep:#0e9c5b;
  --emerald-glow: rgba(34, 229, 138, 0.35);
  --line:       rgba(242, 238, 227, 0.12);

  /* Type */
  --font-display: "Anton", "Arial Narrow", sans-serif;
  --font-body: "Space Grotesk", system-ui, -apple-system, sans-serif;

  /* Spacing rhythm (8pt) */
  --sp-1: 8px;  --sp-2: 16px; --sp-3: 24px; --sp-4: 32px;
  --sp-5: 48px; --sp-6: 64px; --sp-7: 96px; --sp-8: 128px;

  --container: 1360px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-nav: 100;
  --z-grain: 900;
  --z-preloader: 1000;
}

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

html { -webkit-text-size-adjust: 100%; scrollbar-width: none; -ms-overflow-style: none; }
/* Lenis drives scrolling — hide native scrollbar so canvases cover full-bleed (no right-edge gap) */
html::-webkit-scrollbar, body::-webkit-scrollbar { width: 0; height: 0; display: none; }

body {
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

a { color: inherit; text-decoration: none; }
img, video, canvas { display: block; max-width: 100%; }
ol, ul { list-style: none; }

::selection { background: var(--emerald); color: var(--ink); }

/* ---------- Shared ---------- */
.eyebrow {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--emerald);
}

/* ---------- Film grain ---------- */
.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.045;
  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.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 0.6s steps(2) infinite;
}
@keyframes grainShift {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-2%, 1%); }
  100% { transform: translate(1%, -2%); }
}

/* ---------- Preloader ---------- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: var(--z-preloader);
  background: var(--ink);
  display: grid;
  place-items: center;
  transition: opacity 0.7s var(--ease), visibility 0.7s var(--ease);
}
.preloader.is-done { opacity: 0; visibility: hidden; }
.preloader__inner { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); width: min(320px, 70vw); }
.preloader__mark { font-family: var(--font-display); font-size: 44px; letter-spacing: 0.06em; color: var(--cream); }
.preloader__bar { width: 100%; height: 2px; background: var(--line); overflow: hidden; }
.preloader__bar span { display: block; height: 100%; width: 0%; background: var(--emerald); transition: width 0.2s linear; }
.preloader__pct { font-size: 12px; letter-spacing: 0.2em; color: var(--cream-dim); font-variant-numeric: tabular-nums; }

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) clamp(var(--sp-3), 5vw, var(--sp-6));
  transition: padding 0.4s var(--ease);
  background: transparent;
}
/* Transparent nav — never paints a bar over the footage. Text-shadow keeps it legible. */
.nav__brand, .nav__cta { text-shadow: 0 1px 16px rgba(5, 6, 5, 0.7); }
.nav.is-scrolled {
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-2);
}
.nav__brand { display: flex; align-items: center; gap: var(--sp-2); }
.nav__mark {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  padding: 4px 8px 2px;
  line-height: 1;
}
.nav__name { font-size: 14px; font-weight: 500; letter-spacing: 0.02em; color: var(--cream-dim); }
.nav__cta {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em;
  padding: 11px 20px;
  border: 1px solid var(--emerald);
  border-radius: 100px;
  color: var(--cream);
  transition: background 0.3s var(--ease), color 0.3s var(--ease), transform 0.3s var(--ease);
}
.nav__cta:hover { background: var(--emerald); color: var(--ink); transform: translateY(-1px); }
.nav__cta-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 10px var(--emerald-glow); }
.nav__cta:hover .nav__cta-dot { background: var(--ink); box-shadow: none; }

@media (max-width: 640px) {
  .nav__name { display: none; }
  .nav__cta { padding: 9px 14px; font-size: 12px; }
}

/* ---------- HERO ---------- */
.hero { position: relative; height: 320vh; }
.hero__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--ink);
  isolation: isolate;
}
.hero__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero__vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 42%, transparent 40%, rgba(5,6,5,0.55) 78%, rgba(5,6,5,0.92) 100%),
    linear-gradient(to bottom, rgba(5,6,5,0.35) 0%, transparent 22%, transparent 68%, rgba(5,6,5,0.85) 100%);
}
.hero__copy {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 0 var(--sp-3);
  pointer-events: none;
  will-change: transform, opacity;
}
.hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--cream);
  font-size: clamp(64px, 16vw, 260px);
  text-shadow: 0 8px 60px rgba(5,6,5,0.6);
}
.hero__line { display: block; }
.hero__line .char { display: inline-block; will-change: transform, opacity; }
/* Reveal is an enhancement layered on top of a visible default — text can never stay hidden.
   No overflow mask, so nothing is ever clipped. */
.hero__copy.is-revealed .hero__line .char { animation: riseIn 0.9s var(--ease) both; }
@keyframes riseIn {
  from { opacity: 0; transform: translateY(0.55em); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero__subtitle {
  margin-top: var(--sp-3);
  font-size: clamp(15px, 2vw, 21px);
  font-weight: 400;
  color: var(--cream-dim);
  max-width: 30ch;
  margin-inline: auto;
}
.hero__copy.is-revealed .hero__subtitle { animation: fadeIn 0.9s var(--ease) 0.7s both; }
.hero__scrollcue {
  position: absolute;
  bottom: var(--sp-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--cream-faint);
}
.hero__scrollcue-line { width: 1px; height: 46px; background: linear-gradient(var(--emerald), transparent); animation: cueDrop 1.8s var(--ease) infinite; transform-origin: top; }
@keyframes cueDrop { 0%,100% { transform: scaleY(0.35); opacity: 0.4; } 50% { transform: scaleY(1); opacity: 1; } }

/* ---------- STATS ---------- */
.stats {
  position: relative;
  z-index: 4;
  background: var(--ink);
  padding: clamp(var(--sp-6), 10vw, var(--sp-8)) clamp(var(--sp-3), 5vw, var(--sp-6));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stats__grid {
  max-width: var(--container);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}
.stat { display: flex; flex-direction: column; gap: var(--sp-1); border-left: 1px solid var(--line); padding-left: var(--sp-3); }
.stat__num {
  font-family: var(--font-display);
  font-size: clamp(48px, 8vw, 108px);
  line-height: 0.9;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}
.stat__num .u { color: var(--emerald); }
.stat__label { font-size: 13px; letter-spacing: 0.02em; color: var(--cream-dim); max-width: 18ch; }

@media (max-width: 860px) {
  .stats__grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-5) var(--sp-3); }
}
@media (max-width: 460px) {
  .stats__grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- PILLARS ---------- */
.pillars { position: relative; height: 340vh; }
.pillars__sticky {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  background: var(--ink);
  isolation: isolate;
}
/* Scroll-scrub canvases (hero / builder / closer).
   Solid ink background only — the canvas draws opaque frames on top. No poster image:
   a photographic background can bleed through as a "ghost photo" during scroll repaints. */
.scrub-canvas { position: absolute; inset: 0; width: 100%; height: 100%; background: var(--ink); }
.scrub-canvas--builder { background: var(--ink); }
.scrub-canvas--closer  { background: var(--ink); }
.pillars__scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(to right, rgba(5,6,5,0.94) 0%, rgba(5,6,5,0.72) 42%, rgba(5,6,5,0.28) 100%),
    linear-gradient(to top, rgba(5,6,5,0.8), transparent 60%);
}
.pillars__head {
  position: absolute;
  top: clamp(var(--sp-6), 12vh, var(--sp-8));
  left: clamp(var(--sp-3), 6vw, var(--sp-8));
  z-index: 3;
}
.pillars__list {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(var(--sp-3), 6vw, var(--sp-8));
  display: grid;
}
.pillar {
  grid-area: 1 / 1;
  max-width: 660px;
  opacity: 0;
  will-change: transform, opacity;
}
.pillar__index {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--emerald);
  margin-bottom: var(--sp-2);
}
.pillar__title {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 0.92;
  font-size: clamp(44px, 8.5vw, 128px);
  color: var(--cream);
  margin-bottom: var(--sp-3);
}
.pillar__text { font-size: clamp(16px, 2.2vw, 24px); color: var(--cream-dim); max-width: 34ch; }

/* progress rail */
.pillars__rail {
  position: absolute;
  right: clamp(var(--sp-3), 5vw, var(--sp-6));
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex; flex-direction: column; gap: 14px;
}
.pillars__rail span { width: 2px; height: 34px; background: var(--line); transition: background 0.4s var(--ease); }
.pillars__rail span.is-active { background: var(--emerald); }
@media (max-width: 680px) { .pillars__rail { display: none; } .pillar__text { max-width: none; } }

/* ---------- WORK (Closer scrub + 2x2 cards below hero pose) ---------- */
.work { position: relative; height: 380vh; }
.work__sticky {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  background: var(--ink);
  isolation: isolate;
}
.work__scrim {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(5,6,5,0.5) 0%, transparent 18%, transparent 40%, rgba(5,6,5,0.8) 70%, var(--ink) 100%);
}
.work__head {
  position: absolute;
  top: clamp(var(--sp-6), 13vh, var(--sp-8));
  left: 0; right: 0;
  z-index: 3;
  text-align: center;
  padding: 0 var(--sp-3);
}
.work__heading {
  margin-top: var(--sp-2);
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 0.94;
  font-size: clamp(30px, 5vw, 72px);
  color: var(--cream);
  max-width: 18ch;
  margin-inline: auto;
}
/* cards sit in the lower band, below the waist-up hero pose */
.work__cards {
  position: absolute;
  left: 50%;
  bottom: clamp(var(--sp-4), 6vh, var(--sp-6));
  transform: translateX(-50%);
  z-index: 4;
  width: min(940px, 92vw);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}
.card {
  position: relative;
  display: flex; flex-direction: column;
  gap: 6px;
  padding: clamp(var(--sp-2), 2.2vw, var(--sp-3));
  min-height: 124px;
  background: rgba(9, 11, 9, 0.66);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.5s var(--ease), border-color 0.5s var(--ease), background 0.5s var(--ease);
  will-change: transform, opacity;
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 120%, var(--emerald-glow), transparent 60%);
  opacity: 0; transition: opacity 0.5s var(--ease);
  pointer-events: none;
}
.card:hover { transform: translateY(-6px); border-color: var(--emerald); background: rgba(14, 18, 13, 0.8); }
.card:hover::after { opacity: 1; }
.card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); }
.card__idx { font-family: var(--font-display); font-size: 18px; color: var(--cream-faint); }
.card__tag { font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--emerald); text-align: right; }
.card__name {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  font-size: clamp(24px, 3vw, 40px);
  line-height: 0.98;
  color: var(--cream);
  margin-top: 2px;
}
.card__desc { font-size: 13px; line-height: 1.45; color: var(--cream-dim); }
.card__arrow {
  position: absolute;
  bottom: clamp(var(--sp-2), 2.2vw, var(--sp-3));
  right: clamp(var(--sp-2), 2.2vw, var(--sp-3));
  font-size: 20px; color: var(--emerald);
  transform: translateX(-6px); opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
}
.card:hover .card__arrow { transform: translateX(0); opacity: 1; }

/* Mobile: keep the desktop pinned scrub. Cards stay in the lower band,
   tightened to fit narrow viewports. */
@media (max-width: 780px) {
  .work__cards { width: 96vw; gap: 10px; }
  .card { min-height: 96px; padding: 12px; }
  .card__desc { font-size: 11.5px; line-height: 1.35; }
  .card__name { font-size: clamp(18px, 5.5vw, 24px); }
  .card__tag { font-size: 9px; letter-spacing: 0.1em; }
  .card__arrow { display: none; }
}

/* ---------- FINALE ---------- */
.finale { position: relative; background: var(--ink); }
.finale__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(var(--sp-8), 18vw, 220px) clamp(var(--sp-3), 5vw, var(--sp-6)) clamp(var(--sp-7), 12vw, var(--sp-8));
  text-align: center;
}
.finale__heading {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 1.02;
  font-size: clamp(38px, 7.5vw, 130px);
  color: var(--cream);
  max-width: 18ch;
  margin: 0 auto clamp(var(--sp-5), 6vw, var(--sp-7));
}
.finale__heading .word { display: inline-block; }
.finale__heading .word > span { display: inline-block; will-change: transform, opacity; }
/* visible by default; reveal is enhancement (no mask → last line never clipped/hidden) */
.finale__heading.is-revealed .word > span { animation: riseIn 0.85s var(--ease) both; }
.finale__actions { display: flex; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 600; letter-spacing: 0.03em;
  padding: 17px 30px;
  border-radius: 100px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.btn--primary { background: var(--emerald); color: var(--ink); box-shadow: 0 10px 40px -12px var(--emerald-glow); }
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 16px 50px -10px var(--emerald-glow); }
.btn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.btn--ghost { border-color: var(--line); color: var(--cream); }
.btn--ghost:hover { border-color: var(--cream); transform: translateY(-2px); }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(var(--sp-5), 6vw, var(--sp-6)) clamp(var(--sp-3), 5vw, var(--sp-6));
  display: flex; flex-wrap: wrap; gap: var(--sp-4);
  align-items: center; justify-content: space-between;
}
.footer__brand { display: flex; align-items: center; gap: var(--sp-2); }
.footer__mark { font-family: var(--font-display); font-size: 24px; border: 1px solid var(--line); padding: 4px 8px 2px; line-height: 1; }
.footer__tag { font-size: 13px; color: var(--cream-dim); }
.footer__contact { display: flex; flex-direction: column; gap: 6px; }
.footer__link { font-size: 15px; color: var(--cream-dim); transition: color 0.3s var(--ease); }
.footer__link strong { color: var(--cream); font-weight: 600; }
.footer__link:hover { color: var(--emerald); }
.footer__copy { width: 100%; font-size: 12px; color: var(--cream-faint); letter-spacing: 0.04em; }

@media (max-width: 640px) { .footer { flex-direction: column; align-items: flex-start; } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .grain, .hero__scrollcue-line { animation: none; }
  .hero { height: auto; }
  .hero__sticky { position: relative; height: 100vh; }
  .pillars { height: auto; }
  .pillars__sticky { position: relative; min-height: 100vh; height: auto; padding: var(--sp-8) 0; }
  .pillar { position: relative; opacity: 1 !important; transform: none !important; margin-bottom: var(--sp-6); }
  .pillars__list { grid-auto-flow: row; }
  .hero__line .char, .finale__heading .word > span,
  .hero__copy.is-revealed .hero__line .char,
  .hero__copy.is-revealed .hero__subtitle,
  .finale__heading.is-revealed .word > span { animation: none !important; transform: none !important; opacity: 1 !important; }

  /* Work: unpin, static figure, cards below */
  .work { height: auto; }
  .work__sticky { position: relative; height: auto; }
  .scrub-canvas--closer { position: relative; height: 70vh; }
  .work__scrim { height: 70vh; inset: 0 0 auto 0; }
  .work__cards {
    position: relative; left: auto; bottom: auto; transform: none;
    width: min(940px, 92vw); margin: 0 auto;
    padding: var(--sp-5) var(--sp-3) var(--sp-7);
  }
  .card { opacity: 1 !important; transform: none !important; }

  * { scroll-behavior: auto !important; }
}
