/* Index-only: phantom curtain + gallery lightbox + highlight backgrounds */
#curtainOverlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
}

#curtainOverlay.active {
  display: flex !important;
  visibility: visible !important;
}

#videoContainer {
  position: relative;
  z-index: 100000;
  width: min(980px, 92vw);
  background: #000;
  padding: 16px;
  border-radius: 12px;
}

#phantomVideo {
  width: 100%;
  max-height: 74vh;
  border-radius: 10px;
  display: block;
}

.curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50vw;
  z-index: 100002;
  pointer-events: none;
}

.curtain-left { left: 0; }
.curtain-right { right: 0; }

.curtain-layer {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, #960000 0, #690000 14px, #a50000 28px);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.55);
}

#curtainOverlay.active .curtain-left .layer-1 { animation: openL 2s ease forwards; }
#curtainOverlay.active .curtain-right .layer-1 { animation: openR 2s ease forwards; }

@keyframes openL { to { transform: translateX(-105%); } }
@keyframes openR { to { transform: translateX(105%); } }

#closeCurtain {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 100003;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  font-size: 1.5rem;
}

#gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(10, 10, 10, 0.98);
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s;
}

#gallery-lightbox.active {
  display: flex;
  opacity: 1;
  cursor: default;
}

/* Cursor nativo en lightbox (el custom queda detrás del overlay) */
body.fand-ui.has-custom-cursor.fand-lightbox-open {
  cursor: auto;
}

body.fand-ui.has-custom-cursor.fand-lightbox-open .fand-cursor {
  opacity: 0;
  visibility: hidden;
}

#gallery-lightbox.active button,
#gallery-lightbox.active .lightbox-thumb {
  cursor: pointer;
}

.lightbox-main-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 20px 60px;
}

.lightbox-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
}

.lightbox-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-close { top: 16px; right: 16px; background: var(--fand-accent); }

.lightbox-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fand-accent);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.875rem;
}

.lightbox-thumbnails {
  display: flex;
  gap: 8px;
  padding: 12px;
  overflow-x: auto;
  justify-content: center;
}

.lightbox-thumb {
  width: 90px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  opacity: 0.5;
  cursor: pointer;
  border: 2px solid transparent;
}

.lightbox-thumb.active {
  opacity: 1;
  border-color: var(--fand-accent-neon);
}

/* Highlight blocks con fondos originales */
.fand-highlight {
  position: relative;
  overflow: hidden;
  padding: clamp(2.5rem, 5vw, 4rem);
  border-radius: var(--fand-radius);
  margin-bottom: 1.5rem;
  background-color: #111;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  color: #fff;
}

.fand-highlight::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 0;
}

.fand-highlight__inner {
  position: relative;
  z-index: 1;
}

.fand-highlight__grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 38%);
  grid-template-areas: "content media";
  gap: 2rem;
  align-items: center;
}

.fand-highlight__content {
  grid-area: content;
  min-width: 0;
}

.fand-highlight-media {
  grid-area: media;
}

@media (max-width: 768px) {
  .fand-highlight {
    padding: 1.5rem 1.25rem;
  }

  .fand-highlight__grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "media"
      "content";
    gap: 1.25rem;
    align-items: start;
  }

  .fand-highlight-media--logo {
    justify-content: flex-start;
    align-items: flex-start;
  }

  .fand-highlight-media img.nasa-logo {
    max-width: min(148px, 52vw);
    max-height: 3.25rem;
    width: auto;
  }

  .fand-highlight-media img.expo-logo {
    max-width: min(112px, 40vw);
    max-height: 2.75rem;
  }

  .fand-highlight .fand-display-lg {
    font-size: clamp(1.45rem, 6vw, 2rem);
    line-height: 1.1;
  }

  .fand-highlight-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    margin-top: 1rem;
  }

  .fand-highlight-actions .fand-btn {
    width: 100%;
    justify-content: center;
  }
}

.fand-highlight .fand-display-lg,
.fand-highlight h2,
.fand-highlight h3 {
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.45);
}

.fand-highlight .fand-lead,
.fand-highlight p {
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}

.fand-highlight .fand-eyebrow {
  color: rgba(255, 255, 255, 0.9);
}

.fand-highlight .fand-btn--ghost {
  border-color: rgba(255, 255, 255, 0.65);
  color: #fff;
}

.fand-highlight .fand-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
}

.fand-highlight--fantasma {
  background-image: url("../images/fondo_boton_fantasma.png");
}

.fand-highlight--fantasma::before {
  background: rgba(0, 0, 0, 0.2);
}

.fand-highlight--nasa {
  background-image: url("../images/fondo_boton_nasa.svg");
}

.fand-highlight--nasa::before {
  background: rgba(0, 0, 0, 0.25);
}

.fand-highlight--expotic {
  background-color: #020420;
  background-image:
    linear-gradient(rgba(60, 10, 120, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 10, 120, 0.15) 1px, transparent 1px);
  background-size: 40px 40px;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.5);
}

.fand-highlight--expotic::before {
  background: transparent;
}

.fand-highlight--expotic .fand-highlight-glow-a,
.fand-highlight--expotic .fand-highlight-glow-b {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
}

.fand-highlight--expotic .fand-highlight-glow-a {
  top: -20%;
  left: -10%;
  width: 50%;
  height: 140%;
  background: radial-gradient(ellipse at center, rgba(180, 0, 180, 0.25), transparent 70%);
}

.fand-highlight--expotic .fand-highlight-glow-b {
  bottom: -20%;
  right: -10%;
  width: 50%;
  height: 140%;
  background: radial-gradient(ellipse at center, rgba(0, 100, 255, 0.15), transparent 70%);
}

.fand-highlight-media {
  display: flex;
  align-items: center;
  justify-content: center;
}

.fand-highlight-media--logo {
  justify-content: center;
}

.fand-highlight-media img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

.fand-highlight-media img.nasa-logo {
  width: 100%;
  max-width: min(320px, 100%);
  height: auto;
  object-fit: contain;
}

.fand-highlight-media img.expo-logo {
  width: 100%;
  max-width: min(300px, 100%);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(100, 50, 255, 0.4));
}

.fand-highlight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.fand-highlight-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  line-height: 1.7;
}

.fand-highlight-list li {
  position: relative;
  padding-left: 1rem;
}

.fand-highlight-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: rgba(255, 255, 255, 0.85);
}

/* Stack cards — scroll (home) */
body.fand-ui {
  --fand-stack-stick: calc(var(--fand-nav-h) + 1.25rem);
}

.fand-stack-cards {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: clamp(2rem, 5vw, 3rem);
  padding-bottom: clamp(4rem, 18vh, 8rem);
}

.fand-stack-card {
  position: sticky;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7rem, 22%);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "head index"
    "desc decor"
    "cta decor";
  gap: 0 1.75rem;
  align-content: start;
  min-height: clamp(22rem, 62vh, 28rem);
  margin-bottom: clamp(1.75rem, 4vh, 2.75rem);
  padding: clamp(1.75rem, 4vw, 2.75rem);
  border-radius: 1.35rem;
  border: 1px solid var(--fand-border);
  box-shadow: 0 24px 60px rgba(12, 12, 18, 0.12);
  transform-origin: center top;
  will-change: transform;
  overflow: hidden;
}

.fand-stack-card:nth-child(1) {
  top: var(--fand-stack-stick);
  z-index: 1;
}

.fand-stack-card:nth-child(2) {
  top: calc(var(--fand-stack-stick) + 0.85rem);
  z-index: 2;
}

.fand-stack-card:nth-child(3) {
  top: calc(var(--fand-stack-stick) + 1.7rem);
  z-index: 3;
}

.fand-stack-card:nth-child(4) {
  top: calc(var(--fand-stack-stick) + 2.55rem);
  z-index: 4;
}

.fand-stack-card:nth-child(5) {
  top: calc(var(--fand-stack-stick) + 3.4rem);
  z-index: 5;
}

.fand-stack-card:nth-child(6) {
  top: calc(var(--fand-stack-stick) + 4.25rem);
  z-index: 6;
}

.fand-stack-card:last-child {
  margin-bottom: 0;
}

.fand-stack-card--light {
  background: #ececee;
  color: var(--fand-text);
  border-color: rgba(0, 0, 0, 0.06);
}

.fand-stack-card--dark {
  background: #101014;
  color: #f5f5f7;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.35);
}

.fand-stack-card__head {
  grid-area: head;
  display: contents;
}

.fand-stack-card__title {
  grid-area: head;
  align-self: start;
  margin: 0;
  font-family: var(--fand-display);
  font-size: clamp(1.65rem, 3.8vw, 2.35rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.03em;
  max-width: 16ch;
}

.fand-stack-card__index {
  grid-area: index;
  justify-self: end;
  align-self: start;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.55;
}

.fand-stack-card--dark .fand-stack-card__index {
  opacity: 0.65;
}

.fand-stack-card__desc {
  grid-area: desc;
  margin: clamp(1.25rem, 3vh, 1.75rem) 0 0;
  max-width: 42rem;
  font-size: clamp(0.95rem, 1.8vw, 1.0625rem);
  line-height: 1.65;
  color: var(--fand-text-muted);
}

.fand-stack-card--dark .fand-stack-card__desc {
  color: rgba(245, 245, 247, 0.78);
}

.fand-stack-card__cta {
  grid-area: cta;
  align-self: end;
  margin-top: clamp(1.5rem, 4vh, 2.25rem);
  width: fit-content;
  pointer-events: auto;
}

.fand-stack-card__cta.fand-btn--primary {
  color: var(--fand-on-accent);
}

.fand-stack-card__cta .fa-arrow-right {
  font-size: 0.85em;
  transition: transform 0.25s var(--fand-ease);
}

.fand-stack-card__cta:hover .fa-arrow-right {
  transform: translateX(3px);
}

.fand-stack-card__decor {
  grid-area: decor;
  align-self: end;
  justify-self: end;
  width: 100%;
  max-width: 11rem;
  aspect-ratio: 1;
  opacity: 0.55;
  background:
    linear-gradient(155deg, transparent 42%, rgba(228, 6, 140, 0.35) 42%, rgba(228, 6, 140, 0.12) 58%, transparent 58%),
    linear-gradient(25deg, transparent 38%, rgba(0, 184, 169, 0.28) 38%, rgba(0, 184, 169, 0.1) 52%, transparent 52%),
    linear-gradient(-15deg, transparent 45%, rgba(99, 102, 241, 0.25) 45%, rgba(99, 102, 241, 0.08) 60%, transparent 60%);
  mask-image: radial-gradient(circle at 70% 80%, #000 20%, transparent 72%);
}

.fand-stack-card--dark .fand-stack-card__decor {
  opacity: 0.85;
  background:
    linear-gradient(155deg, transparent 40%, rgba(99, 102, 241, 0.55) 40%, rgba(99, 102, 241, 0.2) 58%, transparent 58%),
    linear-gradient(25deg, transparent 36%, rgba(228, 6, 140, 0.45) 36%, rgba(228, 6, 140, 0.15) 54%, transparent 54%),
    linear-gradient(-10deg, transparent 44%, rgba(0, 184, 169, 0.35) 44%, rgba(0, 184, 169, 0.12) 62%, transparent 62%);
}

.fand-stack-cards:not(:has(.fand-stack-card__cta)) .fand-stack-card {
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "head index"
    "desc decor";
}

@media (max-width: 768px) {
  .fand-stack-card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "desc"
      "cta"
      "decor";
    min-height: clamp(18rem, 52vh, 24rem);
    padding: 1.5rem 1.35rem 1.75rem;
  }

  .fand-stack-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    grid-area: head;
  }

  .fand-stack-card__title {
    max-width: none;
    grid-area: unset;
  }

  .fand-stack-card__index {
    flex-shrink: 0;
    font-size: 1.125rem;
    grid-area: unset;
  }

  .fand-stack-card__decor {
    max-width: 8rem;
    margin-top: 0.5rem;
    justify-self: start;
  }

  .fand-stack-card:nth-child(n) {
    top: calc(var(--fand-stack-stick) + (var(--stack-offset, 0) * 0.55rem));
  }

  .fand-stack-card:nth-child(1) {
    --stack-offset: 0;
  }
  .fand-stack-card:nth-child(2) {
    --stack-offset: 1;
  }
  .fand-stack-card:nth-child(3) {
    --stack-offset: 2;
  }
  .fand-stack-card:nth-child(4) {
    --stack-offset: 3;
  }
  .fand-stack-card:nth-child(5) {
    --stack-offset: 4;
  }
  .fand-stack-card:nth-child(6) {
    --stack-offset: 5;
  }
}

.fand-project-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .fand-project-grid {
    grid-template-columns: 1fr;
  }
}

.fand-project-card {
  border: 1px solid var(--fand-border);
  border-radius: var(--fand-radius);
  overflow: hidden;
  background: var(--fand-surface);
  cursor: pointer;
}

.fand-project-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.fand-project-card .body {
  padding: 1rem 1.25rem;
}

/* Home hero: titular animado */
.fand-hero-title-words {
  display: inline;
}

.fand-hero-word {
  display: inline-block;
  white-space: nowrap;
  will-change: transform, opacity;
}

.fand-hero-type-line {
  display: inline;
}

.fand-hero-type {
  color: var(--fand-accent);
  font-weight: 800;
}

.fand-hero-title,
.fand-hero-title-words {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.fand-hero-letter--accent {
  color: var(--fand-accent);
}

.fand-hero-caret {
  display: inline-block;
  width: 0.06em;
  min-width: 3px;
  height: 0.85em;
  margin-left: 0.06em;
  vertical-align: -0.05em;
  background: var(--fand-accent);
  animation: fand-hero-caret-blink 0.85s step-end infinite;
}

.fand-hero-caret.is-done {
  animation: none;
  opacity: 0;
}

@keyframes fand-hero-caret-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fand-hero-caret {
    display: none;
  }
}

/* Home hero — mobile: titular arriba, altura acotada (no pantalla completa) */
@media (max-width: 991px) {
  body.fand-ui[data-page="home"] {
    --fand-hero-visible-h: auto;
  }

  body.fand-ui[data-page="home"] .fand-hero-scroll {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  body.fand-ui[data-page="home"] .fand-hero-pin {
    position: relative;
    top: auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .fand-hero-chapters {
    justify-content: flex-start;
    align-items: flex-start;
    height: auto;
    min-height: 0;
    padding-top: clamp(0.75rem, 3vh, 1.25rem);
    padding-bottom: clamp(0.5rem, 2vh, 1rem);
    padding-inline: var(--fand-gutter);
    overflow: visible;
  }

  .fand-chapter {
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  .fand-chapter.is-active {
    transform: none;
  }

  .fand-hero-title,
  .fand-hero-title-words {
    max-width: 100%;
    overflow-wrap: normal;
    word-break: normal;
    word-wrap: normal;
    hyphens: none;
  }

  .fand-hero-word {
    transform: none !important;
    white-space: nowrap;
  }

  .fand-chapter .fand-eyebrow {
    font-size: 0.6875rem;
    letter-spacing: 0.14em;
    margin-bottom: 0.875rem;
  }

  .fand-chapter h2,
  .fand-chapter .fand-hero-title {
    font-size: clamp(2.125rem, 10.2vw, 2.875rem);
    line-height: 1.12;
    letter-spacing: -0.035em;
    font-weight: 700;
    max-width: none;
    margin-bottom: 0;
  }

  .fand-chapter > p:not(.fand-eyebrow) {
    margin-top: clamp(1.125rem, 3.5vh, 1.625rem);
    font-size: clamp(0.9375rem, 3.8vw, 1.0625rem);
    line-height: 1.55;
    max-width: 22em;
    color: var(--fand-text-muted);
  }
}

@media (max-width: 480px) {
  .fand-chapter h2,
  .fand-chapter .fand-hero-title {
    font-size: clamp(2rem, 9.8vw, 2.625rem);
    line-height: 1.14;
  }
}
