/* =========================================================
   PROYECTOS — STACK CARDS ESTILO PÓSTER
   - Media a sangre en blanco y negro (color al hover / activo)
   - Barra de etiquetas arriba, título gigante abajo
   - Apilado sticky: cada fila se queda fija y la siguiente
     la cubre; la tapada se reduce y oscurece (--cover, JS)
========================================================= */

.sc {
  --sc-stick: clamp(76px, 4vw + 48px, 108px); /* debajo del menú fijo */
  --sc-step: 14px; /* desfase entre cartas apiladas */
  --sc-radius: 0px;
  --sc-text: #ffffff; /* el texto va sobre imagen: siempre claro */

  position: relative;
  z-index: 2;
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* ---------- Grid ---------- */

.sc-grid {
  list-style: none;
  margin: 0;
  padding: 0 var(--ozz-pad) clamp(24px, 4vh, 56px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: clamp(16px, 3vw, 36px);
  column-gap: var(--ozz-gutter);
}

.sc-panel {
  --row: var(--i, 0);
  position: sticky;
  top: calc(var(--sc-stick) + var(--row) * var(--sc-step));
  align-self: start;
}

@media (min-width: 900px) {
  .sc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* Solo PC: más separación vertical entre filas (0-1 y 2-3) para que la
       segunda fila tarde más en cubrir a la primera al hacer scroll.
       ≈ 10% del alto de la pantalla. */
    row-gap: clamp(60px, 10vh, 120px);
  }

  /* fila = índice de fila del grid (2 columnas) */
  .sc-panel:nth-child(-n + 2) { --row: 0; }
  .sc-panel:nth-child(n + 3):nth-child(-n + 4) { --row: 1; }
  .sc-panel:nth-child(n + 5):nth-child(-n + 6) { --row: 2; }
  .sc-panel:nth-child(n + 7):nth-child(-n + 8) { --row: 3; }
  .sc-panel:nth-child(n + 9) { --row: 4; }
}

/* ---------- Tarjeta ---------- */

.sc-card {
  --cover: 0;

  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: calc(100svh - var(--sc-stick) - var(--row) * var(--sc-step) - 24px);
  min-height: 300px;
  overflow: hidden;
  isolation: isolate;
  container-type: inline-size;
  border-radius: var(--sc-radius);
  background: #0b0b0b;
  color: var(--sc-text);
  text-decoration: none;
  transform-origin: 50% 0;
  transform: scale(calc(1 - var(--cover) * 0.06));
  will-change: transform;
}

.sc-card:focus-visible {
  outline: 2px solid var(--color-orange);
  outline-offset: -4px;
}

/* Media (poster + video) */
.sc-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #0b0b0b;
  /* Escritorio: video a color. El B/N solo se aplica en táctil (ver abajo) */
  filter: none;
  transform: scale(1.001);
  transition:
    filter 0.8s ease,
    transform 1.4s var(--ozz-ease);
}

.sc-media img,
.sc-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.sc-media video {
  opacity: 0;
  transition: opacity 0.7s ease;
}

.sc-media.is-playing video {
  opacity: 1;
}

/* Viñeta para legibilidad (arriba y abajo, como el póster) */
.sc-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 22%),
    linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0) 45%);
}

/* Sombra al quedar tapada por la siguiente fila */
.sc-shade {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #000;
  opacity: calc(var(--cover) * 0.72);
  pointer-events: none;
}

/* ---------- Barra superior ---------- */

.sc-top {
  position: absolute;
  z-index: 2;
  top: clamp(12px, 3.2cqi, 22px);
  left: clamp(14px, 3.6cqi, 26px);
  right: clamp(14px, 3.6cqi, 26px);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: clamp(0.85rem, 2.6cqi, 1.25rem);
}

.sc-top span {
  flex: 1 1 0;
  min-width: 0;
}

.sc-top span:nth-child(2) {
  text-align: center;
}

.sc-top span:last-child {
  text-align: right;
}

/* Tarjetas angostas: solo disciplina + índice para no partir líneas */
@container (max-width: 440px) {
  .sc-top span:first-child {
    display: none;
  }

  .sc-top span:nth-child(2) {
    text-align: left;
  }
}

/* ---------- Pie: descripción + título ---------- */

.sc-foot {
  position: absolute;
  z-index: 2;
  left: clamp(14px, 3.6cqi, 26px);
  right: clamp(14px, 3.6cqi, 26px);
  bottom: clamp(10px, 2.6cqi, 20px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2cqi, 16px);
}

.sc-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.sc-name {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 15cqi, 10rem);
  font-weight: 400;
  line-height: 0.84;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  color: var(--sc-text);
  text-wrap: balance;
}

.sc-sector {
  flex: 0 1 auto;
  max-width: 34%;
  padding-bottom: 0.3em;
  text-align: right;
  font-size: clamp(0.85rem, 2.6cqi, 1.25rem);
}

.sc-desc {
  margin: 0;
  max-width: 44ch;
  font-family: var(--font-paragraph-light);
  font-size: clamp(0.85rem, 2.4cqi, 1.1rem);
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.86);
}

/* En dispositivos con mouse la descripción aparece al hover */
@media (hover: hover) and (pointer: fine) {
  .sc-desc {
    max-height: 0;
    opacity: 0;
    transform: translateY(12px);
    overflow: hidden;
    transition:
      max-height 0.6s var(--ozz-ease),
      opacity 0.4s ease,
      transform 0.6s var(--ozz-ease);
  }

  .sc-card:hover .sc-desc,
  .sc-card:focus-visible .sc-desc {
    max-height: 7em;
    opacity: 1;
    transform: none;
  }

  .sc-card:hover .sc-media,
  .sc-card:focus-visible .sc-media {
    transform: scale(1.04);
  }
}

/* Celular / táctil: blanco y negro que pasa a color cuando la
   tarjeta está activa (centro de la pantalla) */
@media (hover: none), (pointer: coarse) {
  .sc-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .sc-media {
    filter: grayscale(1) contrast(1.08) brightness(0.8);
  }

  .sc-panel.is-active .sc-media {
    filter: grayscale(0) contrast(1) brightness(0.9);
  }
}

/* ---------- Entrada (solo si el JS está activo) ---------- */

.sc.sc-ready .sc-card {
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.1s var(--ozz-ease);
}

.sc.sc-ready .sc-panel:not(.is-revealed) .sc-card {
  clip-path: inset(14% 0 0 0);
}

.sc.sc-ready .sc-panel:not(.is-revealed) .sc-media {
  transform: scale(1.18);
}

.sc.sc-ready .sc-top,
.sc.sc-ready .sc-foot {
  transition:
    opacity 0.8s ease 0.25s,
    transform 1s var(--ozz-ease) 0.25s;
}

.sc.sc-ready .sc-panel:not(.is-revealed) .sc-top,
.sc.sc-ready .sc-panel:not(.is-revealed) .sc-foot {
  opacity: 0;
  transform: translateY(18px);
}

/* ---------- Móvil ---------- */

@media (max-width: 899px) {
  .sc {
    --sc-step: 10px;
  }

  .sc-card {
    min-height: 0;
  }

  .sc-sector {
    max-width: 42%;
  }
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
  .sc-card {
    transform: none;
  }

  .sc-shade {
    display: none;
  }

  .sc.sc-ready .sc-card,
  .sc.sc-ready .sc-media,
  .sc.sc-ready .sc-top,
  .sc.sc-ready .sc-foot {
    transition: none;
    clip-path: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

/* ---------- Tooltip flotante OZZ (TooltipStackCards*.js) ---------- */

.ozz-tt-tooltip {
  position: fixed;
  display: flex;
  left: var(--ozz-tt-left, 12px);
  top: var(--ozz-tt-top, 12px);
  z-index: 5;
  width: max-content;
  padding: 10px 18px 8px;
  box-sizing: border-box;
  pointer-events: none;
  background: var(--color-text);
  color: var(--color-bg);
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
  opacity: 0;
  transition:
    opacity 140ms linear,
    transform 80ms linear;
  transform-origin: left top;
  transform: translate(
    var(--ozz-tt-offset-x, 12px),
    var(--ozz-tt-offset-y, 12px)
  );
}

.ozz-tt-tooltip.ozz-tt-visible {
  opacity: 1;
}

@media (hover: none) and (pointer: coarse) {
  .ozz-tt-tooltip {
    display: none !important;
  }
}

/* Celular: sin descripción en las tarjetas de proyectos */
@media (max-width: 899px) {
  .sc-desc {
    display: none !important;
  }
}
