.page-portafolio {
  --pf-rojo: #99182a;
  --u: clamp(0.6px, calc(100vw / 1920), 1px);
  background: var(--crema);
}

.pf {
  position: relative;
  padding: calc(127 * var(--u)) 24px calc(140 * var(--u));
  background: linear-gradient(rgba(240, 235, 226, 0.6), rgba(240, 235, 226, 0.6)), url('../img/portafolio/papel.webp') center top / cover no-repeat, var(--crema);
  color: var(--vino);
  text-align: center;
  overflow: hidden;
}

.pf__head {
  max-width: calc(1040 * var(--u));
  margin: 0 auto;
}
.pf__title {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  font-weight: 400;
}
.pf__eyebrow {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: calc(35 * var(--u));
  line-height: 1.027;
  text-transform: uppercase;
  color: var(--vino);
}
.pf__script {
  margin-top: calc(21 * var(--u));
  font-family: var(--font-script);
  font-weight: 400;
  font-size: calc(200 * var(--u));
  line-height: 0.56;
  color: var(--pf-rojo);
  white-space: nowrap;
}
.pf__lead {
  max-width: calc(890 * var(--u));
  margin: calc(44 * var(--u)) auto 0;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: calc(25 * var(--u));
  line-height: 1.027;
  color: var(--vino);
}
.pf__lead strong { font-weight: 700; }

.pf__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: calc(43 * var(--u)) calc(98 * var(--u));
  max-width: calc(1017 * var(--u));
  margin: calc(106 * var(--u)) auto 0;
  padding: 0;
  list-style: none;
}
.pf__item {
  width: calc(459.37 * var(--u));
}
.pf__link {
  display: block;
  color: inherit;
  cursor: pointer;
}
.pf__link:focus-visible { outline: 2px solid var(--pf-rojo); outline-offset: 6px; border-radius: calc(20 * var(--u)); }
.pf__card { margin: 0; }
.pf__media {
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.6s var(--ease), box-shadow 0.6s var(--ease);
  will-change: transform;
  aspect-ratio: 459.37 / 415.98;
  border-radius: calc(20 * var(--u));
  overflow: hidden;
  background: rgba(63, 2, 10, 0.08);
}
.pf__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--ease);
}
.pf__pronto {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-weight: 500;
  font-style: italic;
  font-size: calc(18 * var(--u));
  line-height: 1.027;
  color: var(--crema);
}
.pf__caption {
  padding-top: calc(19 * var(--u));
}
.pf__name {
  margin: 0;
  font-family: var(--font-script);
  font-weight: 400;
  font-size: calc(70 * var(--u));
  line-height: 1.027;
  color: var(--pf-rojo);
}
.pf__phrase {
  margin: calc(-2 * var(--u)) 0 0;
  font-family: var(--font-body);
  font-weight: 500;
  font-style: italic;
  font-size: calc(18 * var(--u));
  line-height: 1.027;
  color: var(--vino);
}

@media (hover: hover) and (pointer: fine) {
  .pf__item:not(.pf__item--pronto):hover .pf__media { box-shadow: 0 18px 40px rgba(63, 2, 10, 0.16); }
  .pf__item.is-tilting .pf__media { transition: transform 0.12s linear, box-shadow 0.6s var(--ease); }
  .pf__item:not(.pf__item--pronto):hover .pf__media img { transform: scale(1.035); }
}

/* Entrada suave al hacer scroll */
.pf.is-anim .pf__head > *,
.pf.is-anim [data-pf-item] {
  opacity: 0;
  translate: 0 28px;
  transition: opacity 0.9s var(--ease), translate 0.9s var(--ease);
}
.pf.is-anim .pf__head.is-in > *,
.pf.is-anim [data-pf-item].is-in {
  opacity: 1;
  translate: 0 0;
}
.pf.is-anim .pf__head.is-in > :nth-child(2) { transition-delay: 0.15s; }
.pf.is-anim [data-pf-item].is-in:nth-child(even) { transition-delay: 0.12s; }

@media (max-width: 760px) {
  .pf {
    padding: 52px 20px 88px;
    background-size: auto, auto 100%;
  }
  .pf__head { max-width: 440px; }
  .pf__br { display: none; }
  .pf__eyebrow { font-size: 20px; }
  .pf__script {
    margin-top: 14px;
    font-size: clamp(58px, 18.5vw, 92px);
    line-height: 0.62;
  }
  .pf__lead {
    max-width: 400px;
    margin-top: 30px;
    font-size: 15px;
    line-height: 1.35;
  }
  .pf__grid {
    flex-direction: column;
    align-items: center;
    gap: 40px;
    max-width: none;
    margin-top: 52px;
  }
  .pf__item { width: min(100%, 420px); }
  .pf__media { border-radius: 16px; }
  .pf__pronto { font-size: 16px; }
  .pf__caption { padding-top: 14px; }
  .pf__name { font-size: 56px; line-height: 1; }
  .pf__phrase { margin-top: 0; font-size: 15px; }
}

/* =========================================================
   Caso individual del portafolio
   ========================================================= */
.caso {
  padding-top: calc(134 * var(--u));
  padding-bottom: calc(135 * var(--u));
}
.caso__title {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  font-weight: 400;
}
.caso__eyebrow {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: calc(35 * var(--u));
  line-height: 1.027;
  text-transform: uppercase;
  color: var(--vino);
}
.caso__sub {
  margin-top: calc(28 * var(--u));
  font-family: var(--font-body);
  font-weight: 500;
  font-style: italic;
  font-size: calc(35 * var(--u));
  line-height: 1.027;
  color: var(--pf-rojo);
}
.caso__slider {
  display: grid;
  grid-template-columns: 44px minmax(0, calc(1064 * var(--u))) 44px;
  align-items: center;
  justify-content: center;
  column-gap: calc(33 * var(--u));
  margin-top: calc(47 * var(--u));
}
.caso__slider[data-single] { grid-template-columns: minmax(0, calc(1064 * var(--u))); }
.caso__frame {
  position: relative;
  aspect-ratio: 1063.46 / 593.56;
  overflow: hidden;
  background: rgba(63, 2, 10, 0.08);
  touch-action: pan-y;
}
.caso__track {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.caso__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.7s var(--ease), visibility 0s linear 0.7s;
}
.caso__slide.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.7s var(--ease), visibility 0s;
}
.caso__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.caso__frame[data-lb-open] { cursor: zoom-in; -webkit-tap-highlight-color: transparent; }
.caso__frame[data-lb-open]:focus-visible { outline: 2px solid var(--pf-rojo); outline-offset: 4px; }
.caso__zoom {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px 7px 10px;
  border-radius: var(--radius-pill);
  background: rgba(12, 9, 10, 0.62);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--crema);
  pointer-events: none;
}
.caso__zoom svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}
@media (hover: hover) and (pointer: fine) {
  .caso__zoom {
    top: 0;
    left: 0;
    right: auto;
    bottom: auto;
    padding: 8px 16px 8px 12px;
    font-size: 13px;
    opacity: 0;
    transform: translate(var(--zx, 50%), var(--zy, 50%)) translate(16px, 14px) scale(0.9);
    transition: opacity 0.25s var(--ease), transform 0.12s linear;
  }
  .caso__frame.is-hover .caso__zoom {
    opacity: 1;
    transform: translate(var(--zx, 50%), var(--zy, 50%)) translate(16px, 14px);
  }
}

.caso__arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(12, 9, 10, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14), inset 0 0 0 2px rgba(255, 255, 255, 0.16);
  color: var(--crema);
  cursor: pointer;
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}
.caso__arrow[hidden] { display: none; }
.caso__arrow svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--ease);
}
.caso__arrow:hover,
.caso__arrow:focus-visible { background: rgba(14, 10, 11, 0.9); }
.caso__arrow--prev:hover svg { transform: translateX(-2px); }
.caso__arrow--next:hover svg { transform: translateX(2px); }
.caso__arrow:focus-visible { outline: 2px solid var(--pf-rojo); outline-offset: 3px; }
.caso__story {
  max-width: calc(1010 * var(--u));
  margin: calc(53 * var(--u)) auto 0;
}
.caso__frase {
  margin: 0;
  font-family: var(--font-script);
  font-weight: 400;
  font-size: calc(100 * var(--u));
  line-height: 0.56;
  color: var(--pf-rojo);
}
.caso__frase + .caso__text { margin-top: calc(47 * var(--u)); }
.caso__text {
  margin: 1.027em 0 0;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: calc(25 * var(--u));
  line-height: 1.027;
  color: var(--vino);
}

.caso__nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: calc(40 * var(--u));
  max-width: calc(1205 * var(--u));
  margin: calc(110 * var(--u)) auto 0;
  padding-top: calc(56 * var(--u));
  border-top: 1px solid rgba(63, 2, 10, 0.18);
}
.caso__nav-link {
  display: flex;
  flex-direction: column;
  gap: calc(14 * var(--u));
  color: var(--vino);
  text-decoration: none;
}
.caso__nav-link--prev { align-items: flex-start; }
.caso__nav-link--next { align-items: flex-end; }
.caso__nav-name {
  font-family: var(--font-script);
  font-size: calc(70 * var(--u));
  line-height: 0.8;
  color: var(--pf-rojo);
  transition: transform 0.4s var(--ease);
}
.caso__nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.32);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: inset 0 0 0 1px rgba(63, 2, 10, 0.14), 0 2px 10px rgba(63, 2, 10, 0.05);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--vino);
  white-space: nowrap;
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}
.caso__nav-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--ease);
}
.caso__nav-all {
  align-self: center;
  margin-bottom: 10px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: max(13px, calc(17 * var(--u)));
  color: var(--vino);
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-color: rgba(63, 2, 10, 0.35);
  transition: color 0.3s var(--ease), text-decoration-color 0.3s var(--ease);
}
.caso__nav-all:hover,
.caso__nav-all:focus-visible { color: var(--pf-rojo); text-decoration-color: currentColor; }
.caso__nav-link:hover .caso__nav-btn,
.caso__nav-link:focus-visible .caso__nav-btn { background: rgba(255, 255, 255, 0.6); box-shadow: inset 0 0 0 1px rgba(63, 2, 10, 0.24), 0 4px 14px rgba(63, 2, 10, 0.08); }
.caso__nav-link--prev:hover .caso__nav-btn svg { transform: translateX(-4px); }
.caso__nav-link--next:hover .caso__nav-btn svg { transform: translateX(4px); }
.caso__nav-link:focus-visible { outline: none; }
.caso__nav-link:focus-visible .caso__nav-btn { outline: 2px solid var(--pf-rojo); outline-offset: 3px; }

.lb {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #0e0809;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--crema);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.lb[hidden] { display: none; }
.lb.is-open { opacity: 1; }
.lb__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 6px 24px;
}
.lb__count {
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(238, 236, 223, 0.75);
}
.lb__close,
.lb__arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  color: var(--crema);
  cursor: pointer;
  transition: background 0.3s var(--ease);
}
.lb__close:hover,
.lb__arrow:hover,
.lb__close:focus-visible,
.lb__arrow:focus-visible { background: rgba(255, 255, 255, 0.22); }
.lb__close:focus-visible,
.lb__arrow:focus-visible,
.lb__thumb:focus-visible { outline: 2px solid var(--crema); outline-offset: 3px; }
.lb__close svg,
.lb__arrow svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lb__stage {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 20px;
  padding: 8px 24px;
  min-height: 0;
  touch-action: none;
}
.lb__img {
  grid-column: 2;
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform: scale(0.97);
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease);
}
.lb.is-open .lb__img { transform: none; }
.lb__img.is-changing { opacity: 0.35; }
.lb__thumbs {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 12px 24px 20px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: safe center;
}
.lb__thumbs::-webkit-scrollbar { display: none; }
.lb__thumbs li { flex: none; }
.lb__thumb {
  display: block;
  width: 112px;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  opacity: 0.45;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: opacity 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.lb__thumb:hover { opacity: 0.8; }
.lb__thumb.is-active { opacity: 1; box-shadow: 0 0 0 2px var(--crema); }
.lb__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 760px) {
  .caso { padding: 48px 20px 76px; }
  .caso__eyebrow { font-size: 16px; letter-spacing: 0.02em; }
  .caso__sub { margin-top: 12px; font-size: 19px; }
  .caso__slider,
  .caso__slider[data-single] {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "frame frame" "prev next";
    row-gap: 16px;
    column-gap: 18px;
    margin: 28px -20px 0;
  }
  .caso__frame { grid-area: frame; }
  .caso__zoom { right: 10px; bottom: 10px; font-size: 11px; padding: 6px 11px 6px 9px; }
  .lb__bar { padding: 10px 10px 4px 18px; }
  .lb__stage {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "img img" "prev next";
    gap: 14px 18px;
    padding: 0 0 4px;
  }
  .lb__img { grid-area: img; }
  .lb__arrow--prev { grid-area: prev; justify-self: end; }
  .lb__arrow--next { grid-area: next; justify-self: start; }
  .lb__thumbs { gap: 8px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); justify-content: flex-start; }
  .lb__thumb { width: 76px; border-radius: 4px; }
  .caso__arrow--prev { grid-area: prev; justify-self: end; }
  .caso__arrow--next { grid-area: next; justify-self: start; }
  .caso__story { margin-top: 40px; max-width: 440px; }
  .caso__frase { font-size: clamp(44px, 13vw, 60px); line-height: 0.8; }
  .caso__frase + .caso__text { margin-top: 22px; }
  .caso__text { font-size: 15px; line-height: 1.4; }
  .caso__nav {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "prev next" "all all";
    gap: 28px 12px;
    margin-top: 56px;
    padding-top: 36px;
  }
  .caso__nav-link--prev { grid-area: prev; }
  .caso__nav-link--next { grid-area: next; }
  .caso__nav-all { grid-area: all; justify-self: center; margin: 0; }
  .caso__nav-name { font-size: 40px; }
  .caso__nav-link { gap: 10px; }
  .caso__nav-btn { height: 36px; padding: 0 15px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .caso__slide, .caso__slide.is-active { transition: none; }
  .lb, .lb__img, .lb__thumb, .caso__zoom { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pf.is-anim .pf__head > *,
  .pf.is-anim [data-pf-item] { opacity: 1; translate: none; transition: none; }
  .pf__media img { transition: none; }
  .pf__media { transform: none; }
}
