:root {
  --bg-main: #0d1117;
  --bg-surface: #141a23;
  --text-primary: #e6edf3;
  --text-secondary: #7d8999;
  --accent: #6889b5;
  --border: rgba(230, 237, 243, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ANIMACIÓN INTRO (LOOP CONTINUO SIN BLANCOS) */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background-color: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.intro-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-stack {
  position: relative;
  width: 340px;
  height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stack-item {
  position: absolute;
  opacity: 0;
  transform: translate(var(--x, 0px), var(--y, 0px)) scale(1.12) rotate(var(--rot, 0deg));
  transition: opacity 0.22s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.stack-item.photo {
  width: auto;
  height: auto;
  max-width: 390px;
  max-height: 410px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}

.stack-item.logo-final {
  width: 230px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.8));
}

.stack-item.visible {
  opacity: 1;
  transform: translate(var(--x, 0px), var(--y, 0px)) scale(1) rotate(var(--rot, 0deg));
}

/* HEADER Y FOOTER FIJOS ALINEADOS */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background-color: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  padding: 1.35rem max(4%, calc((100vw - 1400px) / 2 + 4%));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.nav-left { justify-self: start; }
.nav-center { justify-self: center; }
.nav-right { justify-self: end; }

.nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: monospace;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.2s ease;
}

.nav-btn:hover, .nav-btn.active { color: var(--text-primary); }

main {
  flex: 1;
  width: 100%;
  padding: 6.5rem max(4%, calc((100vw - 1400px) / 2 + 4%)) 6.5rem;
}

.section { display: none; }
.section.active { display: block; }

.index-bar {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 2.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* DISEÑO */
.editorial-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3rem 2rem;
}

.work-item { cursor: pointer; }

.work-img-wrap {
  aspect-ratio: 16 / 10;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 0.85rem;
}

.work-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.work-item:hover img { transform: scale(1.03); }

.work-meta {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
  font-size: 0.9rem;
}

.work-num { color: var(--text-secondary); margin-right: 0.75rem; font-family: monospace; }
.work-cat { color: var(--text-secondary); font-size: 0.82rem; }

/* VISTA INTERNA DE PROYECTO */
.back-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
  text-transform: none;
  cursor: pointer;
  padding: 0;
}

.back-btn:hover { color: var(--accent); }

.project-header {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 3rem;
  margin-bottom: 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.project-title-col h1 {
  font-size: 1.75rem;
  font-weight: 400;
  margin-top: 0.35rem;
}

.project-num-label {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent);
}

.project-desc-col p {
  color: var(--text-secondary);
  font-size: 0.98rem;
  line-height: 1.75;
  margin-bottom: 0.85rem;
}

.project-desc-col p:last-child { margin-bottom: 0; }

.project-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.75rem 1.5rem;
  align-items: start;
}

.detail-item { cursor: pointer; }

.detail-item img {
  width: 100%;
  max-height: 36vh;
  object-fit: contain;
  background-color: var(--bg-surface);
  display: block;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  transition: opacity 0.25s ease;
}

.detail-item:hover img { opacity: 0.88; }

.detail-num {
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* FOTOGRAFÍA */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem 1.5rem;
  align-items: start;
}

.photo-card { cursor: pointer; }
.photo-card .photo-caption {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: monospace;
  margin-bottom: 0.65rem;
}
.photo-card img { width: 100%; height: auto; display: block; border: 1px solid var(--border); }

.photo-masonry {
  column-count: 4;
  column-gap: 0.75rem;
}

.photo-masonry .detail-item {
  break-inside: avoid;
  margin-bottom: 0.75rem;
  cursor: pointer;
}

.photo-masonry .detail-item img {
  width: 100%;
  height: auto;
  max-height: none;
  background-color: transparent;
  border: none;
  display: block;
  margin-bottom: 0.3rem;
}

.photo-masonry .detail-num { display: none; }

/* AUDIOVISUAL */
.av-list { display: flex; flex-direction: column; gap: 3.5rem; }

.av-item {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 2.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 3rem;
}

.av-frame { position: relative; padding-bottom: 56.25%; height: 0; background: #000; border: 1px solid var(--border); }
.av-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.av-num { font-family: monospace; font-size: 0.82rem; color: var(--accent); display: block; margin-bottom: 0.5rem; }
.av-info h2 { font-size: 1.3rem; font-weight: 400; margin-bottom: 0.75rem; }
.av-info p { color: var(--text-secondary); font-size: 0.92rem; margin-bottom: 1.5rem; }
.av-credits { border-top: 1px solid var(--border); padding-top: 0.75rem; font-size: 0.82rem; color: var(--text-secondary); display: flex; justify-content: space-between; }

/* CONTACTO */
.contact-top-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: stretch;
  margin-bottom: 3.5rem;
}

.bio-photo {
  width: 240px;
  height: 100%;
  max-height: 280px;
  object-fit: cover;
  object-position: center top;
  border: 1px solid var(--border);
  display: block;
}

.links-column {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-self: start;
}

.contact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.92rem;
}


.contact-row:hover { background-color: var(--bg-surface); }
.contact-row .arrow { color: var(--accent); font-family: monospace; }

.bio-column {
  max-width: 780px;
}

.bio-column h2 {
  font-size: 1.35rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

.bio-column p {
  color: var(--text-secondary);
  font-size: 0.98rem;
  line-height: 1.75;
  margin-bottom: 1rem;
}



/* PREVISUALIZADOR LIGHTBOX */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 14, 19, 0.96);
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem 4%;
}
.lightbox.open { display: flex; }
.lb-top, .lb-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; }
.lb-stage img { max-width: 100%; max-height: 75vh; object-fit: contain; border: 1px solid var(--border); }
.lb-close { background: none; border: 1px solid var(--border); color: var(--text-primary); padding: 0.4rem 0.8rem; cursor: pointer; }

.lb-controls {
  display: flex;
  gap: 1.5rem;
}

.lb-nav {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #ffffff !important;
  font-size: 1.35rem;
  padding: 0.25rem;
  cursor: pointer;
  line-height: 1;
  user-select: none;
  transition: opacity 0.2s ease;
}

.lb-nav:hover { opacity: 0.7; }

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background-color: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  padding: 1.35rem max(4%, calc((100vw - 1400px) / 2 + 4%));
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

@media (max-width: 1000px) {
  .photo-masonry { column-count: 3; }
}

@media (max-width: 850px) {
  .editorial-grid, .av-item, .contact-grid, .project-header, .project-detail-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 650px) {
  .photo-masonry { column-count: 2; }
}
.av-frame.av-placeholder {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
}

.av-frame.av-placeholder span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}
/* FILMOGRAFÍA EN AUDIOVISUAL */
.filmography-section {
  margin-top: 3rem;
}

.filmography-title {
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 2rem;
}

.filmography-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 3rem 4rem;
  align-items: start;
}

.filmography-side {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.filmography-group h3 {
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.filmography-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.filmography-list {
  list-style: none;
  border-top: 1px solid var(--border);
}

.filmography-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.filmography-list li span {
  color: var(--text-primary);
}

@media (max-width: 650px) {
  header {
    display: flex;
    justify-content: space-between;
  }

  .intro-stack {
    width: 240px;
    height: 300px;
  }

  .stack-item.photo {
    max-width: 210px;
    max-height: 230px;
  }

  .stack-item.logo-final {
    width: 155px;
  }

  .stack-item {
    transform: translate(calc(var(--x, 0px) * 0.48), calc(var(--y, 0px) * 0.65)) scale(1.12) rotate(var(--rot, 0deg));
  }

  .stack-item.visible {
    transform: translate(calc(var(--x, 0px) * 0.48), calc(var(--y, 0px) * 0.65)) scale(1) rotate(var(--rot, 0deg));
  }
}
@media (max-width: 650px) {
  #contacto.section.active { display: flex; flex-direction: column; }
  #contacto .index-bar { order: 1; }
  #contacto .contact-top-block { display: contents; }
  #contacto .bio-photo { order: 2; width: 100%; max-width: 260px; height: auto; max-height: none; margin-bottom: 2rem; }
  #contacto .bio-column { order: 3; margin-bottom: 2.5rem; }
  #contacto .links-column { order: 4; width: 100%; align-self: stretch; }
  #contacto .contact-row { width: 100%; padding: 0.95rem 0; }
  #contacto .link-detail { display: none; }
}
