/* =========================================================
   Sección «Menos bla, bla, bla. Más verlo.» — carrusel de piezas
   ========================================================= */

.work {
  --work-bg: #0e0c09;
  --card-w: clamp(150px, 13.6vw, 270px);
  --card-gap: clamp(8px, .8vw, 14px);
  --card-radius: 14px;

  position: relative;
  overflow: hidden;
  background: var(--work-bg);
  color: var(--cream);
  padding-block: clamp(80px, 10vw, 150px) clamp(48px, 6vw, 88px);
}

.work__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(20px, 2.4vw, 32px);
  padding-inline: var(--gutter);
  text-align: center;
}

.work__eyebrow {
  display: inline-flex;
  align-items: center;
  margin: 0;
  border: 1px solid rgba(245, 239, 227, .22);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.work__eyebrow span { padding: .7em 1.2em; }
.work__eyebrow span + span {
  border-left: 1px solid rgba(245, 239, 227, .22);
  color: var(--yellow);
}

.work__title {
  margin: 0;
  max-width: 13ch;
  font-size: clamp(44px, 7vw, 112px);
  font-weight: 800;
  line-height: .96;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.work__title span { display: block; color: var(--yellow); }

.work__note {
  margin: clamp(24px, 3vw, 36px) 0 0;
  padding-inline: var(--gutter);
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: rgba(245, 239, 227, .45);
}

/* ---------- Pestañas ---------- */
/* Todas del mismo ancho (el de la más larga), centradas en una fila */
.work__tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  margin: clamp(36px, 4.4vw, 60px) auto 0;
  padding-inline: var(--gutter);
}
.work__tab {
  flex: none;
  margin: 0;
  padding: .85em 1.4em;
  border: 1px solid rgba(245, 239, 227, .22);
  border-radius: 999px;
  background: none;
  color: var(--cream);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.work__tab:hover { border-color: var(--yellow); }
.work__tab:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
.work__tab[aria-selected="true"] {
  border-color: var(--yellow);
  background: var(--yellow);
  color: var(--work-bg);
  cursor: default;
}

/* ---------- Carrusel ---------- */
.reel {
  position: relative;
  margin-top: clamp(20px, 2.6vw, 36px);
  padding-block: 18px;            /* aire para la tarjeta destacada */
  overflow: hidden;
  touch-action: pan-y;            /* el gesto vertical sigue desplazando la página */
  user-select: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent);
}

.reel__track {
  display: flex;
  transition: opacity .2s ease;
  gap: var(--card-gap);
  align-items: center;
  width: max-content;
  will-change: transform;
}

.reel__card {
  position: relative;
  flex: none;
  width: var(--card-w);
  aspect-ratio: 9 / 16;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: #1c1914;
  isolation: isolate;
  transition: transform .45s var(--ease-out), box-shadow .3s ease;
}

.reel__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s var(--ease-out);
  pointer-events: none;
}

.reel__video {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.reel__video--horizontal { object-fit: contain; }

/* Cambio de pestaña: fundido breve */
.reel.is-swapping .reel__track { opacity: 0; }

/* Pieza horizontal: misma altura que las verticales, proporción 16:9 */
.reel__card--horizontal {
  width: calc(var(--card-w) * 256 / 81);
  aspect-ratio: 16 / 9;
}

/* Pieza cuadrada (diseño, packaging…): misma altura que las verticales */
.reel__card--cuadrado {
  width: calc(var(--card-w) * 16 / 9);
  aspect-ratio: 1 / 1;
}

/* Imagen: se muestra tal cual, sin reproducción */
.reel__card--imagen { cursor: default; }

/* Pestaña sin trabajos todavía: aviso a la altura de una tarjeta */
.reel.is-empty .reel__track {
  width: auto;
  justify-content: center;
  min-height: calc(var(--card-w) * 16 / 9);
}
.reel__empty {
  margin: 0;
  padding-inline: var(--gutter);
  text-align: center;
  font-size: clamp(16px, 1.4vw, 20px);
  font-weight: 500;
  color: rgba(245, 239, 227, .55);
}

/* Botón que cubre la tarjeta: selecciona la pieza */
.reel__hit {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: none;
  cursor: pointer;
}
.reel__hit:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; }

.reel__tag {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  padding: .55em 1em;
  border-radius: 999px;
  background: rgba(14, 12, 9, .55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--cream);
  pointer-events: none;
}
/* Trabajo destacado (p. ej. Clinicool o ControlTV): etiqueta en amarillo */
.reel__card--destacado .reel__tag {
  background: var(--yellow);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  color: var(--work-bg);
}

.reel__title {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  margin: 0;
  padding: 48px 14px 14px;
  background: linear-gradient(to top, rgba(14, 12, 9, .7), transparent);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--cream);
  pointer-events: none;
  transition: opacity .3s ease;
}
.reel__desc {
  display: block;
  margin-top: .35em;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: rgba(245, 239, 227, .75);
}

/* Capa que oscurece */
.reel__card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(14, 12, 9, .74);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}

@media (hover: hover) and (pointer: fine) {
  .reel:not(.is-active) .reel__card:hover .reel__poster { transform: scale(1.04); }
}

/* ---------- Pieza seleccionada ---------- */
.reel.is-active .reel__card::after { opacity: 1; }
.reel.is-active .reel__card.is-current::after { opacity: 0; }
.reel__card.is-current {
  z-index: 2;
  transform: scale(1.04);
  box-shadow: 0 0 0 2px var(--yellow), 0 24px 60px rgba(0, 0, 0, .55);
}
.reel__card.is-current .reel__title { opacity: 0; }
.reel__card.is-current .reel__hit { cursor: default; }

.reel__controls {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
}
.reel__card.is-current .reel__controls { opacity: 1; }
.reel__card.is-current .reel__controls > * { pointer-events: auto; }

.reel__btn {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: .6em;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(245, 239, 227, .28);
  border-radius: 999px;
  background: rgba(14, 12, 9, .6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--cream);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}
.reel__btn:hover { background: rgba(14, 12, 9, .85); border-color: var(--yellow); }
.reel__btn:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.reel__btn svg { width: 12px; height: 12px; fill: currentColor; flex: none; }

.reel__btn--play { left: 12px; bottom: 22px; }
.reel__btn--sound { right: 12px; bottom: 22px; }
.reel__btn--close,
.reel__btn--play {
  width: 34px;
  padding: 0;
  justify-content: center;
}
.reel__btn--close { top: 10px; right: 10px; }
.reel__btn--close svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }

.reel__progress {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  height: 2px;
  border-radius: 2px;
  background: rgba(245, 239, 227, .25);
  overflow: hidden;
}
.reel__progress span {
  display: block;
  height: 100%;
  background: var(--yellow);
  transform-origin: left;
  transform: scaleX(0);
}

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .work { --card-w: 44vw; --card-gap: 8px; --card-radius: 12px; }
  .work__eyebrow { font-size: 10px; letter-spacing: .18em; }
  /* Cuatro pestañas en dos filas de dos, del mismo ancho: sin cortes ni desplazamiento lateral */
  .work__tabs {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: auto;
    max-width: 440px;
  }
  .work__tab { font-size: 11px; letter-spacing: .12em; padding: 1em .8em; }
  .reel { -webkit-mask-image: none; mask-image: none; }
  .reel__title { font-size: 13px; padding: 40px 12px 12px; }
  .reel__tag { top: 10px; left: 10px; font-size: 9px; }
  .reel__btn { min-height: 32px; padding: 0 11px; font-size: 9px; letter-spacing: .14em; }
  .reel__btn--close, .reel__btn--play { width: 32px; padding: 0; }
  .reel__card.is-current { transform: scale(1.03); }
  /* En móvil no cabe a la altura de las verticales: ocupa casi todo el ancho */
  .reel__card--horizontal { width: calc(100vw - 2 * var(--gutter)); }
  .reel__card--horizontal.is-current { transform: scale(1.015); }
  .reel__card--cuadrado { width: min(calc(var(--card-w) * 16 / 9), calc(100vw - 2 * var(--gutter))); }
  .reel__desc { font-size: 11px; }
}

/* ---------- Movimiento reducido: sin desplazamiento automático ---------- */
.reel.is-static {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-mask-image: none;
  mask-image: none;
  touch-action: auto;
}
.reel.is-static::-webkit-scrollbar { display: none; }
.reel.is-static .reel__track { padding-inline: var(--gutter); }
.reel.is-static .reel__card { scroll-snap-align: center; }

@media (prefers-reduced-motion: reduce) {
  .reel__card, .reel__poster, .reel__card::after, .reel__track { transition: none; }
  .reel__card.is-current { transform: none; }
}

/* ---------- Tarjetas de imagen: se amplían al pulsarlas ---------- */
.reel__card--imagen .reel__hit { cursor: zoom-in; }
.reel__zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(14, 12, 9, .55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--cream);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s var(--ease-out);
}
.reel__zoom svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) {
  .reel__zoom { opacity: 0; transform: scale(.85); }
  .reel__card:hover .reel__zoom,
  .reel__hit:focus-visible ~ .reel__zoom { opacity: 1; transform: none; }
}

/* ---------- Visor a pantalla completa ---------- */
html.visor-abierto { overflow: hidden; }

.visor {
  --dx: 0px;
  --dy: 0px;
  --pull: 0;
  --side: clamp(64px, 7vw, 104px);   /* calle lateral para las flechas */

  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 9, 7, calc(.95 - var(--pull) * .6));
  color: var(--cream);
  font-family: var(--font);
  overscroll-behavior: contain;
  touch-action: pinch-zoom;           /* el dedo desliza; dos dedos siguen haciendo zoom */
}
.visor.is-zoomed { touch-action: auto; }
.visor[open] { animation: visor-open .28s var(--ease-out); }
.visor::backdrop { background: transparent; }

.visor__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 1.6vw, 22px);
  height: 100%;
  margin: 0;
  padding: max(72px, env(safe-area-inset-top)) var(--side) max(24px, env(safe-area-inset-bottom));
}
.visor__stage {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.visor__img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  background: #1b1813;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  transform: translate3d(var(--dx), var(--dy), 0) scale(calc(1 - var(--pull) * .12));
  transition: transform .32s var(--ease-out);
  user-select: none;
  -webkit-user-drag: none;
}
.visor.is-dragging .visor__img { transition: none; }
.visor__img.is-in { animation: visor-swap .32s var(--ease-out); }

.visor__caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 12px;
  max-width: 60ch;
  text-align: center;
  opacity: calc(1 - var(--pull) * 2);
}
.visor__tag {
  padding: .55em 1em;
  border-radius: 999px;
  border: 1px solid rgba(245, 239, 227, .28);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.visor__tag.is-destacado { background: var(--yellow); border-color: var(--yellow); color: var(--work-bg, #0e0c09); }
.visor__tag[hidden], .visor__desc[hidden] { display: none; }
.visor__name { font-size: clamp(16px, 1.3vw, 19px); font-weight: 600; letter-spacing: -.01em; }
.visor__desc { flex-basis: 100%; color: var(--cream-dim); font-size: 14px; line-height: 1.4; }
.visor__count { color: var(--cream-dim); font-size: 12px; font-variant-numeric: tabular-nums; letter-spacing: .08em; }

.visor__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(245, 239, 227, .28);
  border-radius: 999px;
  background: rgba(14, 12, 9, .6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--cream);
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease;
}
.visor__btn:hover { background: rgba(14, 12, 9, .9); border-color: var(--yellow); }
.visor__btn:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
.visor__btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.visor__btn--close { top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); }
.visor__btn--prev,
.visor__btn--next { top: 50%; margin-top: -24px; }
.visor__btn--prev { left: max(16px, env(safe-area-inset-left)); }
.visor__btn--next { right: max(16px, env(safe-area-inset-right)); }
.visor.is-single .visor__btn--prev,
.visor.is-single .visor__btn--next { display: none; }

@keyframes visor-open { from { opacity: 0; } }
@keyframes visor-swap { from { opacity: 0; transform: translate3d(var(--from, 0px), 0, 0) scale(.97); } }

/* Móvil: la imagen ocupa todo el ancho; las flechas bajan junto al pie */
@media (max-width: 760px) {
  .visor { --side: 0px; }
  .visor__figure { padding: max(68px, env(safe-area-inset-top)) 0 max(18px, env(safe-area-inset-bottom)); gap: 14px; }
  .visor__img { border-radius: 0; }
  .visor__caption { min-height: 44px; padding-inline: 68px; gap: 4px 10px; }
  .visor__desc { font-size: 13px; }
  .visor__btn { width: 44px; height: 44px; }
  .visor__btn--prev,
  .visor__btn--next { top: auto; margin-top: 0; bottom: max(18px, env(safe-area-inset-bottom)); }
  .visor__btn--prev { left: 12px; }
  .visor__btn--next { right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .visor[open], .visor__img.is-in { animation: none; }
  .visor__img, .reel__zoom { transition: none; }
}
