/* ─── VARIABLES ─── */
:root {
  --font-serif: 'Inter', sans-serif;
  --font-sans:  'DM Sans', sans-serif;
  --type-xs:    10px;
  --type-sm:    11px;
  --type-md:    14px;
  --type-lg:    18px;
  --type-xl:    clamp(28px, 4vw, 52px);
  --type-hero:  clamp(26px, 3.5vw, 44px);
  --tracking-wide:  0.2em;
  --tracking-wider: 0.3em;
  --tracking-tight: 0.04em;
  --op-primary:   1;
  --op-secondary: 0.65;
  --op-muted:     0.35;
  --op-faint:     0.2;
}

/* ─── BASE ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  background: #000; color: #fff;
  font-family: 'DM Sans', sans-serif;
  overflow-x: hidden; cursor: none;
}
a { color: inherit; text-decoration: none; }

/* ─── CURSOR ─── */
.cursor {
  width: 6px; height: 6px; background: #fff; border-radius: 50%;
  position: fixed; pointer-events: none; z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width 0.25s ease, height 0.25s ease, background 0.25s ease;
  top: -100px; left: -100px;
}
.cursor.hover {
  width: 22px; height: 22px; background: transparent;
  border: 1px solid rgba(255,255,255,0.7);
}

/* ─── NAV — base ─── */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; justify-content: space-between; align-items: center;
  padding: 28px 40px; mix-blend-mode: difference;
  transform: translateY(0); transition: transform 0.4s ease, opacity 0.4s ease;
}
nav.hidden { transform: translateY(-100%); opacity: 0; }

/* Nav — index / work */
nav .logo { font-size: var(--type-sm); font-weight: 400; letter-spacing: 0.2em; text-transform: uppercase; }
nav ul { list-style: none; display: flex; gap: 32px; }
nav ul li a { font-size: var(--type-sm); letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.6; transition: opacity 0.3s; }
nav ul li a:hover { opacity: 1; }

/* Nav — project pages */
nav .nav-left { display: flex; gap: 32px; align-items: center; }
nav .back-link { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.5; transition: opacity 0.3s; color: #fff; }
nav .back-link:hover { opacity: 1; }
nav .nav-title { font-size: 11px; font-weight: 400; letter-spacing: 0.2em; text-transform: uppercase; }
nav .nav-right { display: flex; gap: 32px; }
nav .nav-right a { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.6; transition: opacity 0.3s; }
nav .nav-right a:hover { opacity: 1; }
nav .nav-center { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; }
nav .nav-center a, nav .nav-center span { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; white-space: nowrap; }
nav .nav-center a { opacity: 0.6; transition: opacity 0.3s; color: #fff; }
nav .nav-center a:hover { opacity: 1; }
nav .nav-center .nav-sep { opacity: 0.25; }
nav .nav-center .nav-off { opacity: 0.18; }

/* ─── OVERLAY PAGES ─── */
.overlay-page {
  display: none; position: fixed; top: 0; bottom: 0; left: 0;
  width: min(720px, 95vw);
  background: rgba(0,0,0,0.4); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 500;
  overflow-y: auto; animation: slideIn 0.4s ease;
  border-right: 1px solid rgba(255,255,255,0.07);
}
.overlay-page.open { display: block; }
@keyframes slideIn { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.overlay-backdrop { display: none; position: fixed; inset: 0; z-index: 499; cursor: none; }
.overlay-backdrop.active { display: block; }
.close-page {
  position: fixed; top: 28px; left: 40px;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  opacity: 0.5; cursor: none; transition: opacity 0.3s; z-index: 600;
}
.close-page:hover { opacity: 1; }
.section-label {
  font-size: var(--type-xs); letter-spacing: 0.35em; text-transform: uppercase;
  opacity: 0.35; margin-bottom: 48px; display: block;
}
.social-links { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 40px; }
.social-links .section-label { margin-bottom: 24px; }
.social-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05); opacity: 0.5;
  transition: opacity 0.3s; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
}
.social-item:hover { opacity: 1; }
.social-item svg { width: 15px; height: 15px; fill: #fff; flex-shrink: 0; }

/* ─── PROJECT PAGES ─── */
.project-wrap { display: flex; align-items: flex-start; padding-bottom: 56px; }
.col-left { width: 50%; padding: 100px 20px 56px 40px; display: flex; flex-direction: column; gap: 28px; }
.col-right { width: 50%; padding: 100px 40px 56px 20px; display: flex; flex-direction: column; gap: 28px; }

.project-title {
  font-family: 'Inter', sans-serif;
  font-size: clamp(40px, 5.5vw, 72px);
  font-weight: 700; letter-spacing: 0.01em; line-height: 1; margin-bottom: 8px;
}
.project-label { font-size: 10px; letter-spacing: 0.32em; text-transform: uppercase; opacity: 0.3; margin-bottom: 20px; display: block; }
.text-block { font-size: 14px; line-height: 1.9; opacity: 0.6; font-weight: 300; }

.photo-wrap { position: relative; overflow: hidden; border-radius: 3px; }
.photo-wrap img {
  width: 100%; height: 38vh; display: block; object-fit: cover;
  filter: contrast(1.02) saturate(0.95);
  transform: scale(1.04); transition: transform 0.7s ease;
}
.photo-wrap:hover img { transform: scale(1.08); }
.photo-wrap::after {
  content: ''; position: absolute; inset: 0; border-radius: 3px;
  box-shadow: inset 0 0 70px rgba(0,0,0,0.5); pointer-events: none; z-index: 1;
}

.video-block { position: relative; overflow: hidden; border-radius: 3px; cursor: none; }
.video-block video { width: 100%; height: auto; display: block; transform: scale(1); transition: transform 0.7s ease; }
.video-block::after {
  content: ''; position: absolute; inset: 0; border-radius: 3px;
  box-shadow: inset 0 0 70px rgba(0,0,0,0.45); pointer-events: none; z-index: 2;
}
.play-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.75; transition: opacity 0.35s ease;
}
.video-block:hover .play-overlay { opacity: 1; }
.play-btn {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid rgba(255,255,255,0.65); padding: 11px 26px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase;
  color: #fff; background: rgba(0,0,0,0.25); backdrop-filter: blur(6px);
  cursor: none; transition: background 0.2s ease;
}
.play-btn:hover { background: rgba(255,255,255,0.08); }
.play-btn svg { width: 11px; height: 11px; fill: #fff; }

.video-inline { position: relative; overflow: hidden; border-radius: 3px; }
.video-inline video {
  width: 100%; height: 38vh; object-fit: cover; display: block;
  transform: scale(1.04); transition: transform 0.7s ease;
}
.video-inline:hover video { transform: scale(1.08); }
.video-inline::after {
  content: ''; position: absolute; inset: 0; border-radius: 3px;
  box-shadow: inset 0 0 70px rgba(0,0,0,0.45); pointer-events: none; z-index: 1;
}

.credits-block { padding-top: 0; }
.credit-line { font-size: 11px; line-height: 1.8; letter-spacing: 0.02em; color: rgba(255,255,255,0.4); }
.credit-line strong { font-weight: 700; color: #fff; font-size: 11px; }

/* ─── CREDITS SOTA LA FOTO ─── */
.credits-scene { display: flex; flex-direction: column; cursor: pointer; }
.cs-photo-wrap { position: relative; flex-shrink: 0; }
.cs-photo { width: 100%; display: block; }
.cs-veil { display: none; }
.cs-hint { position: static; display: flex; align-items: center; gap: 12px; padding: 18px 0 0; opacity: 1; transition: opacity .4s ease; pointer-events: none; }
.cs-hint-sep { flex: 1; height: 1px; background: rgba(255,255,255,.18); }
.cs-hint-label { font-size: 10.5px; letter-spacing: .19em; text-transform: uppercase; color: rgba(255,255,255,.45); font-family: 'DM Sans',sans-serif; font-weight: 300; white-space: nowrap; }
.cs-credits { position: static; width: 100%; max-height: 0; overflow: hidden; opacity: 0; transition: max-height .6s cubic-bezier(.4,0,.2,1), opacity .4s ease; padding: 0; }
.credits-scene.credits-open .cs-credits { max-height: 1200px; opacity: 1; padding: 12px 0 8px; }
.credits-scene.credits-open .cs-hint { opacity: 0.3; }
.credit-item { display: flex; align-items: center; gap: 12px; padding: 5px 0; border-top: 1px solid rgba(255,255,255,.07); }
.credit-item:first-child { border-top: none; }
.cr-role { font-size: 10.5px; letter-spacing: .19em; text-transform: uppercase; color: rgba(255,255,255,.38); font-family: 'DM Sans',sans-serif; font-weight: 300; flex-shrink: 0; }
.cr-sep { flex: 1; height: 1px; background: rgba(255,255,255,.15); }
.cr-name { font-size: 14px; font-weight: 300; letter-spacing: .04em; color: rgba(255,255,255,.82); font-family: 'DM Sans',sans-serif; white-space: nowrap; }
.vimeo-link {
  display: inline-block; margin-top: 14px;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  opacity: 0.45; transition: opacity 0.3s; color: #fff;
}
.vimeo-link:hover { opacity: 1; }

/* ─── LIGHTBOX ─── */
.vl {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.96); z-index: 1000;
  align-items: center; justify-content: center; flex-direction: column;
}
.vl.open { display: flex; }
.vl-inner { position: relative; width: 88vw; max-width: 1100px; }
.vl-iframe-wrap { position: relative; padding-bottom: 56.25%; height: 0; border-radius: 2px; overflow: hidden; }
.vl-iframe-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
.vl-close {
  position: fixed; top: 28px; left: 40px;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  opacity: 0.5; cursor: none; transition: opacity 0.3s;
  background: none; border: none; color: #fff; font-family: 'DM Sans', sans-serif;
}
.vl-close:hover { opacity: 1; }

/* ─── REVEAL ON SCROLL ─── */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ─── GRAIN ─── */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9998;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  mix-blend-mode: overlay;
  animation: grainMove 0.8s steps(1) infinite;
}
@keyframes grainMove {
  0%   { background-position: 0 0; }
  20%  { background-position: -50px -25px; }
  40%  { background-position: -100px -50px; }
  60%  { background-position: 25px -75px; }
  80%  { background-position: -75px 50px; }
  100% { background-position: 50px 25px; }
}

/* ─── PAGE TRANSITION ─── */
body { animation: pageIn 0.5s ease forwards; }
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── FOOTER ─── */
footer {
  text-align: center; padding: 48px 40px;
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  opacity: 0.2; font-family: 'DM Sans', sans-serif;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  nav { padding: 16px 24px; flex-wrap: wrap; height: auto; }
  nav .nav-title { display: none; }
  nav .nav-left { flex: 1; }
  nav .nav-center { position: static; transform: none; width: 100%; justify-content: center; order: 3; padding-top: 10px; }
  .project-wrap { flex-direction: column; align-items: stretch; gap: 28px; }
  .col-left, .col-right { display: contents; }
  .col-left > *, .col-right > * { margin: 0 24px; }
  .col-left > *:first-child { order: 1; padding-top: 100px; }
  .col-right > *:first-child { order: 2; }
  .col-left > .credits-block { order: 3; }
  .col-left > *:not(:first-child):not(.credits-block),
  .col-right > *:not(:first-child) { order: 10; }
  .project-title { font-size: clamp(26px, 8vw, 32px); }
  .photo-wrap img { height: auto; }
  .credits-scene { cursor: pointer; }

  /* Info panel — apilat verticalment */
  .overlay-page > div { flex-direction: column !important; height: auto !important; overflow: visible !important; }
  .overlay-page > div > div:first-child { flex: none !important; height: 55vw !important; min-height: 180px; max-height: 260px; }
  .overlay-page > div > div:last-child { padding: 28px 24px 48px !important; overflow: visible !important; }
}

/* ─── CURSOR — ocultar en dispositius tàctils ─── */
@media (hover: none) and (pointer: coarse) {
  .cursor { display: none; }
  html, body { cursor: auto; }
}

/* ─── DASH SEPARATOR ─── */
.dash { font-size: 0.65em; opacity: 0.45; }

/* ─── REDUCED MOTION ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  body::after {
    animation-duration: 0.8s !important;
    animation-iteration-count: infinite !important;
  }
}
