.hero-memory-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.45rem, 1.2vw, 0.75rem);
  width: 100%;
  margin: 0 0 clamp(0.8rem, 1.8vw, 1.25rem);
  align-self: start;
  position: relative;
  z-index: 8;
}

#inicio.hero {
  align-items: start;
  grid-template-rows: auto auto;
}

#inicio .hero-copy {
  grid-column: 1;
  grid-row: 1 / span 2;
}

#inicio .hero-memory-gallery {
  grid-column: 2;
  grid-row: 1;
}

#inicio .hero-landscape {
  grid-column: 2;
  grid-row: 2;
  min-height: clamp(390px, 38vw, 510px);
}

.hero-memory-tile {
  aspect-ratio: 1;
  overflow: hidden;
  display: block;
  padding: 0;
  border: 1px solid rgba(151, 111, 39, 0.42);
  background: #e9e1d1;
  box-shadow: 0 0.75rem 1.8rem rgba(13, 51, 45, 0.13);
  cursor: zoom-in;
}

.hero-memory-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease, filter 180ms ease;
}

.hero-memory-tile:hover img,
.hero-memory-tile:focus-visible img {
  filter: brightness(1.035);
}

.hero-memory-tile:focus-visible {
  outline: 3px solid #b6812c;
  outline-offset: 3px;
}

.hero-memory-lightbox {
  position: fixed;
  inset: 0;
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: clamp(1rem, 4vw, 3rem);
  border: 0;
  background: transparent;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
}

.hero-memory-lightbox[open] {
  display: grid;
  place-items: center;
}

.hero-memory-lightbox::backdrop {
  background: rgba(5, 24, 21, 0.92);
  backdrop-filter: blur(4px);
}

.hero-memory-lightbox > img {
  display: block;
  max-width: min(92vw, 1100px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.52);
}

.hero-memory-lightbox-close {
  position: fixed;
  z-index: 2;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  background: rgba(7, 39, 34, 0.88);
  color: #fff;
  font: 300 2rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.hero-memory-lightbox-nav {
  position: fixed;
  z-index: 2;
  top: 50%;
  display: grid;
  place-items: center;
  width: clamp(3rem, 5vw, 4rem);
  height: clamp(3rem, 5vw, 4rem);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(3, 20, 18, 0.9);
  color: #fff;
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.38);
  transform: translateY(-50%);
  cursor: pointer;
}

.hero-memory-lightbox-nav:hover,
.hero-memory-lightbox-nav:focus-visible {
  background: #000;
  outline: 3px solid rgba(255, 255, 255, 0.88);
  outline-offset: 3px;
}

.hero-memory-lightbox-nav span {
  display: block;
  margin-top: -0.12em;
  font: 300 clamp(2.7rem, 5vw, 4rem)/0.62 Georgia, serif;
}

.hero-memory-lightbox-previous {
  left: max(0.75rem, env(safe-area-inset-left));
}

.hero-memory-lightbox-next {
  right: max(0.75rem, env(safe-area-inset-right));
}

.hero-memory-lightbox-counter {
  position: fixed;
  z-index: 2;
  bottom: max(0.8rem, env(safe-area-inset-bottom));
  left: 50%;
  margin: 0;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(3, 20, 18, 0.82);
  color: #fff;
  font: 600 0.78rem/1 system-ui, sans-serif;
  letter-spacing: 0.12em;
  transform: translateX(-50%);
}

@media (max-width: 900px) {
  #inicio.hero {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  #inicio .hero-copy {
    grid-column: 1;
    grid-row: 1;
  }

  #inicio .hero-memory-gallery {
    width: 100%;
    margin: clamp(1.25rem, 5vw, 2rem) 0 0;
  }

  #inicio .hero-landscape {
    grid-column: 1;
    grid-row: 2;
  }
}

@media (max-width: 540px) {
  .hero-memory-gallery {
    gap: 0.45rem;
    margin-top: 1.35rem;
  }

  .hero-memory-tile {
    box-shadow: 0 0.5rem 1.2rem rgba(13, 51, 45, 0.12);
  }

  .hero-memory-lightbox {
    padding: 0.75rem;
  }

  .hero-memory-lightbox > img {
    max-width: 96vw;
    max-height: 82vh;
  }

  .hero-memory-lightbox-nav {
    top: auto;
    bottom: max(1rem, env(safe-area-inset-bottom));
    width: 3rem;
    height: 3rem;
    transform: none;
  }

  .hero-memory-lightbox-previous {
    left: max(1rem, env(safe-area-inset-left));
  }

  .hero-memory-lightbox-next {
    right: max(1rem, env(safe-area-inset-right));
  }

  .hero-memory-lightbox-counter {
    bottom: max(1.9rem, calc(env(safe-area-inset-bottom) + 0.9rem));
  }
}

/* Rendered with the page: no load event, DOM insertion or fade-in delay. */
#inicio .hero-gallery-mobile { display: none; }
@media (max-width: 900px) {
  #inicio .hero-gallery-desktop { display: none; }
  #inicio .hero-gallery-mobile { display: grid; }
}

/* Keep the emblem in normal flow and reserve a separate band for the hills.
   The panel can grow with enlarged text instead of moving words onto a peak. */
#inicio .hero-landscape{display:grid;place-items:center;padding:3.25rem 1rem 8.25rem;min-height:390px}
#inicio .hero-emblem{position:relative;inset:auto;transform:none;max-width:100%;margin:0}
#inicio .hero-emblem p{margin:2.5rem 0 0;font-size:.75rem;line-height:1.65;letter-spacing:.18em}
#inicio .hero-landscape .mountain{height:6.5rem;bottom:0;pointer-events:none}
#inicio .hero-landscape .mountain-two{height:4.7rem;bottom:-.25rem}
@media(max-width:540px){#inicio .hero-landscape{padding:3.25rem 1rem 8.25rem}#inicio .hero-emblem p{font-size:.7rem;letter-spacing:.16em}}
