@font-face {
  font-family: "Provicali";
  src: url("assets/Provicali.otf") format("opentype");
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --mute: #8a8a8a;
  --line: rgba(0, 0, 0, .1);
  --red: #ff2a1f;
  --dvd: #ffffff;
  --gut: clamp(16px, 2.6vw, 40px);
  --top-h: 72px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --display: "Provicali", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --sans: "Cormorant Garamond", "Cormorant", Garamond, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 300;
  line-height: 1.6;
  letter-spacing: .14em;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.is-home { background: #000; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }
#app:focus { outline: none; }

/* Protección de fotos */
.protect img, img.protect {
  -webkit-user-select: none; user-select: none;
  -webkit-user-drag: none; -webkit-touch-callout: none;
}

.dvd-mask {
  background: currentColor;
  -webkit-mask: var(--dvd-mask) center / contain no-repeat;
          mask: var(--dvd-mask) center / contain no-repeat;
}

/* ---------- Boot ---------- */
#boot {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: grid; place-content: center; justify-items: center; gap: 22px;
  transition: opacity .6s var(--ease), visibility .6s;
}
#boot.done { opacity: 0; visibility: hidden; }
#boot.done .boot-logo { width: min(120px, 32vw); aspect-ratio: 900 / 546; }

/* ---------- Header (páginas internas) ---------- */
.top {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-h);
  padding: env(safe-area-inset-top) var(--gut) 0;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.brand { display: block; }
.brand-logo { display: block; width: 64px; aspect-ratio: 900 / 546; color: var(--fg); transition: transform .5s var(--ease); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.06); }
.nav { display: flex; gap: clamp(16px, 3vw, 44px); }
.nav a { position: relative; padding: 6px 0; color: var(--mute); transition: color .2s; }
.nav a:hover, .nav a.on { color: var(--fg); }
body.is-home .top { display: none; }

/* ---------- View transitions ---------- */
.view { animation: viewIn .6s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Home ---------- */
.home { position: fixed; inset: 0; overflow: hidden; background: #000; color: #fff; }
.reel { position: absolute; inset: 0; display: block; }
.reel img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%;
  visibility: hidden;
}
.reel img.prev { visibility: visible; z-index: 1; }
.reel img.on { visibility: visible; z-index: 2; }
.home::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.2), rgba(0,0,0,0) 60%), rgba(0,0,0,.32);
}
.home-hit { position: absolute; inset: 0; z-index: 2; }
.home-center {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 0 var(--gut);
}
.home-name {
  margin: 0; white-space: nowrap; text-align: center; pointer-events: none;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(17px, 2.9vw, 46px);
  line-height: 1; letter-spacing: .02em; text-transform: uppercase;
  color: #fff; text-shadow: 0 1px 24px rgba(0,0,0,.18);
  animation: viewIn 1s var(--ease) both;
}

.home-ig {
  position: absolute; z-index: 4; left: 50%; transform: translateX(-50%);
  bottom: calc(clamp(22px, 5vh, 44px) + env(safe-area-inset-bottom));
  display: inline-flex; padding: 10px; color: #fff; opacity: .9; transition: opacity .2s;
  animation: viewIn 1s var(--ease) both; animation-delay: .3s;
}
.home-ig:hover { opacity: 1; }
.home-ig svg { width: 22px; height: 22px; }
body.is-home.cursor-on .home-ig { cursor: pointer; }

/* DVD bounce */
.bouncer {
  position: absolute; z-index: 2; top: 0; left: 0;
  width: clamp(70px, 8vw, 130px); aspect-ratio: 900 / 546;
  color: var(--dvd);
  mix-blend-mode: difference;
  will-change: transform;
  pointer-events: none;
  transition: color .25s;
}
.corner-flash {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: grid; place-items: center;
  font-family: var(--display); font-size: clamp(40px, 10vw, 160px); color: var(--dvd);
  mix-blend-mode: difference; opacity: 0;
}
.corner-flash.go { animation: cornerGo 1.6s var(--ease); }
@keyframes cornerGo { 0% { opacity: 0; transform: scale(.6) rotate(-6deg); } 15% { opacity: 1; transform: scale(1.05) rotate(2deg); } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(1.1); } }

/* ---------- Páginas internas ---------- */
.page { padding: clamp(28px, 6vh, 64px) var(--gut) clamp(60px, 10vh, 120px); min-height: calc(100vh - var(--top-h)); }
.page-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px;
  margin-bottom: clamp(22px, 4vh, 40px);
}
.page-title {
  margin: 0; font-family: var(--display); font-weight: 400; text-transform: uppercase;
  font-size: clamp(20px, 2.2vw, 30px); line-height: 1; letter-spacing: .02em;
}
.page-title sup { display: none; }
.page-desc { margin: 0; color: var(--mute); }
.page-desc .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin-right: 8px; vertical-align: 1px; }
.back { color: var(--mute); }
.back:hover { color: var(--fg); }

/* ---------- Justified gallery ---------- */
.jg { display: flex; flex-direction: column; gap: var(--jg-gap, 12px); }
.jg-row { display: flex; gap: var(--jg-gap, 12px); }
.jg-item {
  position: relative; display: block; overflow: hidden; background: #f1f1f1;
  flex: var(--ar) 1 0; aspect-ratio: var(--ar); min-width: 0;
}
.jg-row.last .jg-item { flex: 0 0 var(--lw); }
.jg-item img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .6s var(--ease), transform 1s var(--ease);
}
.jg-item img.ld { opacity: 1; }
.jg-ph { cursor: zoom-in; }

/* Tiles de proyecto (hover = nombre) */
.tile-ov {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center; text-align: center; padding: 16px;
  background: rgba(0,0,0,.38); color: #fff;
  opacity: 0; transition: opacity .3s var(--ease);
}
.tile-ov h3 { margin: 0; font-family: var(--sans); font-weight: 300; font-size: clamp(15px, 1.3vw, 19px); line-height: 1.2; letter-spacing: .22em; }
.tile-ov p { margin: 8px 0 0; font-size: 10px; letter-spacing: .2em; opacity: .85; }
.tile .red { position: absolute; z-index: 3; top: 10px; left: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
@media (hover: hover) {
  .tile:hover .tile-ov, .tile:focus-visible .tile-ov { opacity: 1; }
  .tile:hover img.ld { transform: scale(1.03); }
}
@media (hover: none) {
  .tile-ov { opacity: 1; place-items: end start; text-align: left; padding: 10px; background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0) 50%); }
  .tile-ov h3 { font-size: 14px; }
  .tile-ov p { display: none; }
}

/* ---------- Proyecto ---------- */
.proj-head { display: grid; gap: 10px; margin-bottom: clamp(22px, 4vh, 40px); }
.proj-meta { display: flex; flex-wrap: wrap; gap: 6px 26px; color: var(--mute); }
.proj-meta b { font-weight: 400; color: var(--fg); }
.next-row { display: flex; justify-content: space-between; gap: 16px; margin-top: clamp(36px, 7vh, 80px); padding-top: 18px; border-top: 1px solid var(--line); }
.next-row a:hover { color: var(--mute); }

/* ---------- Footer ---------- */
.foot {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 24px var(--gut) calc(24px + env(safe-area-inset-bottom)); color: var(--mute); font-size: 12px;
}
.foot a:hover { color: var(--fg); }
.foot-ig { display: inline-flex; padding: 4px; margin: -4px; }
body.is-home .foot { display: none; }

/* ---------- Lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 60; background: #fff; color: var(--fg); }
.lb[hidden] { display: none; }
.lb-stage { position: absolute; inset: 64px clamp(12px, 7vw, 110px) 64px; }
.lb-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .35s var(--ease); }
.lb-stage img.ld { opacity: 1; }
.lb-load { position: absolute; left: 50%; top: 50%; width: 70px; aspect-ratio: 900/546; margin: -21px 0 0 -35px; opacity: 0; }
.lb-stage.loading .lb-load { opacity: 1; }
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
.lb-btn { position: absolute; top: 50%; transform: translateY(-50%); font-size: 18px; padding: 18px; color: var(--mute); }
.lb-btn:hover { color: var(--fg); }
.lb-prev { left: 4px; } .lb-next { right: 4px; }
.lb-close { position: absolute; top: calc(22px + env(safe-area-inset-top)); right: var(--gut); padding: 6px 0; }
.lb-meta { position: absolute; left: var(--gut); right: var(--gut); bottom: calc(22px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; color: var(--mute); }

/* ---------- Loader DVD ---------- */
#loader {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: grid; place-items: center;
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
}
#loader.on { opacity: 1; visibility: visible; transition: none; }
.loader-logo { width: min(110px, 30vw); aspect-ratio: 900 / 546; }

/* ---------- Screensaver ---------- */
#saver { position: fixed; inset: 0; z-index: 90; background: #000; opacity: 0; visibility: hidden; transition: opacity .8s, visibility .8s; }
#saver.on { opacity: 1; visibility: visible; }
.saver-logo { position: absolute; top: 0; left: 0; width: clamp(110px, 14vw, 220px); aspect-ratio: 900/546; color: var(--dvd); will-change: transform; transition: color .2s; }
.saver-hint { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: #555; }

/* ---------- Cursor: mini logo DVD ---------- */
#cursor { position: fixed; top: 0; left: 0; z-index: 80; pointer-events: none; display: none; mix-blend-mode: difference; }
#cursor span {
  display: block; width: 34px; aspect-ratio: 900 / 546; margin: -10px 0 0 -17px;
  color: #fff; transition: width .35s var(--ease), margin .35s var(--ease);
}
#cursor.big span { width: 54px; margin: -16px 0 0 -27px; }
@media (hover: hover) and (pointer: fine) {
  #cursor { display: block; }
  body.cursor-on, body.cursor-on a, body.cursor-on button { cursor: none; }
  body.is-home #cursor { display: none; }
  body.is-home.cursor-on, body.is-home.cursor-on a { cursor: auto; }
  body.is-home.cursor-on .home-hit { cursor: pointer; }
}

/* ---------- Grain (solo home) ---------- */
.grain {
  position: fixed; inset: -50%; z-index: 4; pointer-events: none; opacity: .06; display: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1s steps(6) infinite;
}
body.is-home .grain { display: block; }
@keyframes grain {
  0% { transform: translate(0,0) } 20% { transform: translate(-3%,2%) } 40% { transform: translate(2%,-3%) }
  60% { transform: translate(-2%,-1%) } 80% { transform: translate(3%,3%) } 100% { transform: translate(0,0) }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  :root { --top-h: 60px; }
  .brand-logo { width: 54px; }
}
@media (max-width: 600px) {
  .nav { gap: 14px; }
  .lb-btn { display: none; }
  .lb-stage { inset: 64px 0 64px; }
  .home-name { font-size: 5.6vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .grain { display: none !important; }
}
