
/* ──────────────────────────────────────────────────────────
   Tokens
   ────────────────────────────────────────────────────────── */
:root {
  --bg:        #f4f1ea;          /* warm paper */
  --bg-deep:  #0c0b09;           /* footer black */
  --ink:       #0c0b09;
  --ink-soft:  #4a4842;
  --rule:      #d9d3c4;
  --accent:    #d8421a;          /* pop red, used sparingly */
  --paper:     #ece8dd;

  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --t-fast: 180ms;
  --t-med:  280ms;
  --t-slow: 420ms;

  --max:    min(1480px, 94vw);
  --gap:    clamp(14px, 1.5vw, 22px);
  --pad-x:  clamp(20px, 3vw, 48px);

  --font-display: 'Anton', 'Arial Narrow', sans-serif;
  --font-body:    'Geist', system-ui, -apple-system, sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
html {
  scroll-behavior: smooth;  /* native fallback; replaced by Lenis when ported to Grav */
}

body {
  cursor: none;  /* hidden in favor of custom cursor on desktop */
  position: relative;
}

@media (hover: none) {
  body { cursor: auto; }
}

a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
button { font: inherit; background: none; border: 0; color: inherit; cursor: none; }

/* ──────────────────────────────────────────────────────────
   Grain overlay — fights digital flatness
   ────────────────────────────────────────────────────────── */
.grain {
  position: fixed; inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

/* ──────────────────────────────────────────────────────────
   Custom cursor
   ────────────────────────────────────────────────────────── */
.cursor, .cursor-ring {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 1000;
  will-change: transform;
}
.cursor {
  width: 6px; height: 6px;
  background: var(--ink);
  border-radius: 50%;
  transform: translate3d(-50%, -50%, 0);
}
.cursor-ring {
  width: 32px; height: 32px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  transform: translate3d(-50%, -50%, 0);
  transition: width 280ms var(--ease-out),
              height 280ms var(--ease-out),
              border-color 280ms var(--ease-out),
              background 280ms var(--ease-out);
}
.cursor-ring.is-hover {
  width: 72px; height: 72px;
  background: var(--ink);
  mix-blend-mode: difference;
  border-color: transparent;
}
.cursor-ring.is-text {
  width: 6px; height: 6px;
  background: var(--ink);
  border-color: transparent;
}
@media (hover: none) {
  .cursor, .cursor-ring { display: none; }
}

/* ──────────────────────────────────────────────────────────
   Layout container
   ────────────────────────────────────────────────────────── */
.wrap {
  width: 100%;
  padding: 0 var(--pad-x);
}

/* ──────────────────────────────────────────────────────────
   Hero — massive display name
   ────────────────────────────────────────────────────────── */
.hero {
  padding-top: clamp(28px, 4vw, 56px);
}
.hero-name {
  font-family: var(--font-display);
  font-weight: 400;            /* Anton is single-weight, looks heaviest at 400 */
  font-size: clamp(72px, 18.6vw, 320px);
  line-height: 0.84;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  text-wrap: balance;
  margin-left: -0.04em;        /* optical alignment of capital letters */
}
.hero-name .word {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding-top: 0.3em;        /* headroom: Anton's caps extend above line-box at line-height < 1 */
  padding-bottom: 0.08em;    /* small safety below baseline */
  margin-top: -0.3em;        /* cancel the padding-top in layout flow */
  margin-right: 0.06em;
}
.hero-name .word:last-child { margin-right: 0; }
.hero-name .char {
  display: inline-block;
  will-change: transform;
}
/* Hide the whole hero until GSAP has positioned the chars below their masks.
   No transform here — GSAP must own the transform entirely (a CSS transform
   becomes a base layer GSAP won't overwrite, leaving text stuck offscreen). */
.pre-anim .hero-name {
  visibility: hidden;
}

/* ──────────────────────────────────────────────────────────
   Intro row — bio (left) + socials (right)
   ────────────────────────────────────────────────────────── */
.intro {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: clamp(24px, 4vw, 80px);
  align-items: end;
  padding: clamp(48px, 6vw, 96px) 0 clamp(32px, 3vw, 48px);
}
.bio {
  max-width: 56ch;
  font-size: clamp(15px, 1vw, 17px);
  color: var(--ink-soft);
  line-height: 1.55;
}
.bio strong { color: var(--ink); font-weight: 500; }
.bio .more {
  display: inline-block;
  margin-top: 14px;
  color: var(--ink);
  font-weight: 500;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
  transition: opacity var(--t-fast) var(--ease-out);
}
.bio .more:hover { opacity: 0.55; }

.socials {
  display: flex;
  gap: clamp(18px, 2.4vw, 36px);
  font-size: clamp(14px, 0.95vw, 16px);
  font-weight: 500;
  align-self: end;
}

/* ──────────────────────────────────────────────────────────
   Marquee-on-hover links (the Mastak signature)
   ────────────────────────────────────────────────────────── */
.mlink {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1em;
  line-height: 1;
  vertical-align: bottom;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
}
.mlink .track {
  display: block;
  transition: transform 420ms var(--ease-out);
  will-change: transform;
}
.mlink .row {
  display: block;
  line-height: 1;
}
.mlink:hover .track,
.mlink:focus-visible .track {
  transform: translateY(-50%);
}

/* ──────────────────────────────────────────────────────────
   Project grid
   ────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  border-top: 1px solid var(--rule);
  padding-top: var(--gap);
}
@media (max-width: 880px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: clamp(18px, 2vw, 28px);
  background: var(--paper);
  border-radius: 4px;
  overflow: hidden;
  transition: background var(--t-med) var(--ease-out);
  opacity: 0;
  transform: translateY(24px);
}
.card.is-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 700ms var(--ease-out),
              transform 700ms var(--ease-out),
              background var(--t-med) var(--ease-out);
}
.card-media {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 2px;
  background: #ddd6c5;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 900ms var(--ease-out), filter 600ms var(--ease-out);
  will-change: transform;
}
@media (hover: hover) and (pointer: fine) {
  .card:hover .card-media img {
    transform: scale(1.04);
  }
  .card:hover {
    background: #e6e0d0;
  }
}
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: clamp(14px, 1.6vw, 22px);
  gap: 12px;
}
.card-title {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: clamp(15px, 1vw, 17px);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.card-count {
  font-size: clamp(12px, 0.85vw, 14px);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────
   Load more button — magnetic
   ────────────────────────────────────────────────────────── */
.load-row {
  display: flex;
  justify-content: center;
  padding: clamp(40px, 6vw, 96px) 0;
}
.load-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.01em;
  background: transparent;
  transition: background var(--t-med) var(--ease-out),
              color var(--t-med) var(--ease-out),
              transform 380ms var(--ease-out);
  will-change: transform;
}
.load-btn:hover {
  background: var(--ink);
  color: var(--bg);
}

/* ──────────────────────────────────────────────────────────
   Footer — dark slab, massive CTA
   ────────────────────────────────────────────────────────── */
.footer {
  background: var(--bg-deep);
  color: var(--bg);
  padding: clamp(80px, 10vw, 180px) 0 clamp(32px, 3vw, 48px);
  margin-top: clamp(48px, 6vw, 96px);
}
.cta {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(58px, 11vw, 200px);
  line-height: 0.92;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  text-align: center;
  text-wrap: balance;
  margin-left: -0.02em;
  margin-right: -0.02em;
}
.cta .accent {
  color: var(--accent);
  font-style: normal;
}
.footer-socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(20px, 3vw, 48px);
  font-size: clamp(15px, 1.1vw, 18px);
  font-weight: 500;
  margin-top: clamp(48px, 6vw, 80px);
}
.footer-socials .mlink {
  border-bottom-color: var(--bg);
}
.copy {
  text-align: center;
  margin-top: clamp(60px, 8vw, 120px);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, 0.5);
}

/* ──────────────────────────────────────────────────────────
   Reveal helpers (used by GSAP)
   ────────────────────────────────────────────────────────── */
.r-mask {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding-top: 0.3em;
  padding-bottom: 0.08em;
  margin-top: -0.3em;
}
.r-mask > .r-inner {
  display: inline-block;
  will-change: transform;
}
/* Same approach as hero — hide the CTA until GSAP positions the lines. */
.pre-anim .cta {
  visibility: hidden;
}

.fade-up {
  /* visible by default; only hidden when JS is confirmed ready */
}
.pre-anim .fade-up {
  opacity: 0;   /* opacity only — no transform base for GSAP to trip over */
}

/* ──────────────────────────────────────────────────────────
   Reduced motion
   ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .hero-name .char { transform: translateY(0); }
  .card { opacity: 1; transform: none; }
  .r-mask > .r-inner { transform: none; }
  .fade-up { opacity: 1; transform: none; }
  body { cursor: auto; }
  .cursor, .cursor-ring { display: none; }
}

/* ──────────────────────────────────────────────────────────
   Touch / small screens — disable cursor, simplify
   ────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  body { cursor: auto; }
  .cursor, .cursor-ring { display: none; }
  button { cursor: pointer; }
  a { cursor: pointer; }
  .intro {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .socials { flex-wrap: wrap; gap: 18px; }
}

/* ════════════════════════════════════════════════
   PORTFOLIO DETAIL PAGE  (item.php)
   ════════════════════════════════════════════════ */
/* ── Top bar: back link ── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: clamp(20px, 3vw, 36px) 0;
  font-size: clamp(14px, 0.95vw, 16px); font-weight: 500;
}
.back { display: inline-flex; align-items: center; gap: 8px; }
.back .arrow { transition: transform var(--t-med) var(--ease-out); }
.back:hover .arrow { transform: translateX(-5px); }

/* ── Hero ── */
.po-hero { padding-top: clamp(20px, 4vw, 56px); }
.po-title {
  font-family: var(--font-display);
  font-size: clamp(56px, 13vw, 220px);
  line-height: 0.86; letter-spacing: -0.035em; text-transform: uppercase;
  text-wrap: balance; margin-left: -0.04em;
}
.po-title .word {
  display: inline-block; overflow: hidden; vertical-align: bottom;
  padding-top: 0.3em; padding-bottom: 0.08em; margin-top: -0.3em; margin-right: 0.06em;
}
.po-title .char { display: inline-block; will-change: transform; }
.pre-anim .po-title { visibility: hidden; }

.po-sub {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 16px;
  border-top: 1px solid var(--rule);
  margin-top: clamp(28px, 4vw, 56px);
  padding-top: clamp(16px, 1.6vw, 22px);
  font-size: clamp(14px, 1vw, 17px); color: var(--ink-soft);
}
.po-sub .scroll-hint { display: inline-flex; align-items: center; gap: 8px; }
.po-sub .scroll-hint .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.8s var(--ease-out) infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }

/* ── Feature image ── */
.po-feature {
  margin-top: clamp(28px, 4vw, 56px);
  aspect-ratio: 16 / 9; overflow: hidden; border-radius: 4px; background: var(--paper);
}
.po-feature img { width: 100%; height: 100%; object-fit: cover; }

/* ── Body: credits + description ── */
.po-body {
  display: grid; grid-template-columns: minmax(220px, 320px) 1fr;
  gap: clamp(32px, 6vw, 96px);
  padding: clamp(56px, 8vw, 120px) 0;
}
@media (max-width: 820px) { .po-body { grid-template-columns: 1fr; gap: clamp(32px, 5vw, 48px); } }

.credits { display: flex; flex-direction: column; gap: clamp(16px, 1.6vw, 22px); }
.credit-row { display: flex; flex-direction: column; gap: 3px; }
.credit-label { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.credit-value { font-size: clamp(15px, 1vw, 17px); font-weight: 500; }
.credit-value a { border-bottom: 1px solid var(--ink); padding-bottom: 1px; transition: opacity var(--t-fast) var(--ease-out); }
.credit-value a:hover { opacity: 0.55; }

.description { font-size: clamp(16px, 1.15vw, 19px); line-height: 1.62; color: var(--ink-soft); max-width: 62ch; }
.description p { margin-bottom: 1.1em; }
.description p strong, .description p b { color: var(--ink); font-weight: 500; }
.po-quote {
  margin: clamp(28px, 3vw, 44px) 0;
  padding-left: clamp(18px, 2vw, 28px);
  border-left: 2px solid var(--accent);
  font-family: var(--font-body); font-weight: 500;
  font-size: clamp(18px, 1.5vw, 24px); line-height: 1.4; color: var(--ink);
}
.po-quote cite { display: block; margin-top: 12px; font-style: normal; font-weight: 400; font-size: 14px; color: var(--ink-soft); }

/* ── Visuals stack ── */
.po-visuals { display: flex; flex-direction: column; gap: clamp(14px, 2vw, 28px); }
.po-visual { overflow: hidden; border-radius: 4px; background: var(--paper); }
.po-visual img {
  width: 100%; height: auto; display: block;
  opacity: 0; transform: scale(1.06);
}
.po-visual img.is-in {
  opacity: 1; transform: scale(1);
  transition: opacity 900ms var(--ease-out), transform 1200ms var(--ease-out);
}

/* ── Next project ── */
.po-next {
  display: block; border-top: 1px solid var(--rule);
  margin-top: clamp(56px, 8vw, 120px); padding: clamp(40px, 6vw, 80px) 0;
}
.po-next .next-label { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 12px; }
.po-next .next-title {
  font-family: var(--font-display);
  font-size: clamp(48px, 9vw, 160px); line-height: 0.9; letter-spacing: -0.03em;
  text-transform: uppercase; transition: color var(--t-med) var(--ease-out);
  display: inline-flex; align-items: center; gap: 0.2em;
}
.po-next:hover .next-title { color: var(--accent); }
.po-next .next-title .arrow { font-size: 0.5em; transition: transform var(--t-med) var(--ease-out); }
.po-next:hover .next-title .arrow { transform: translateX(0.2em); }

/* Markdown blockquotes inside the description render as the pulled quote */
.description blockquote {
  margin: clamp(28px, 3vw, 44px) 0;
  padding-left: clamp(18px, 2vw, 28px);
  border-left: 2px solid var(--accent);
  font-weight: 500;
  font-size: clamp(18px, 1.5vw, 24px);
  line-height: 1.4;
  color: var(--ink);
}
.description blockquote p { margin-bottom: 0.4em; }
.description blockquote p:last-child { margin-bottom: 0; }
.description h2, .description h3 {
  font-family: var(--font-body);
  color: var(--ink);
  font-weight: 600;
  margin: 1.4em 0 0.5em;
  letter-spacing: -0.01em;
}
.description a { border-bottom: 1px solid currentColor; }
