:root {
  --chapter-extra: clamp(12px, 2.6svh, 26px);
  --chapter-height: calc(100svh + var(--chapter-extra));
  --earth-seam: #211813;
  --footer-surface: #151310;
}

.screen {
  min-height: 0;
  height: var(--chapter-height);
  grid-template-rows: minmax(0, 1fr);
  --entry-edge: var(--earth-seam);
  --exit-edge: var(--earth-seam);
  --entry-fade: clamp(30px, 8svh, 86px);
  --exit-fade: clamp(28px, 7svh, 80px);
}

.screen::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--entry-edge),
    transparent var(--entry-fade),
    transparent calc(100% - var(--exit-fade)),
    var(--exit-edge)
  );
}

.hero, .story, .event { --entry-edge: transparent; --exit-edge: transparent; }
.career { --entry-edge: transparent; --exit-edge: #182126; }
.films { --entry-edge: #182126; --exit-edge: #27211c; }
.gallery { --entry-edge: #27211c; --exit-edge: transparent; }
.contact { --entry-edge: transparent; --exit-edge: var(--footer-surface); }

.chapter-inner { position: relative; z-index: 1; min-height: 0; }
.hero-copy { z-index: 1; margin-block-end: var(--chapter-extra); }
.story-art, .career-art, .contact-art { inset: 0; height: 100%; }

/* Fade the incoming photograph over the preceding edge at its natural luminance. */
.story, .career, .event, .contact {
  overflow: visible;
  --join-size: clamp(24px, 5.8svh, 58px);
}
.story { --join-image: url("media/historia.webp"); --photo-position: 57% 0; --join-size: clamp(23px, 4.9svh, 55px); }
.career { --join-image: url("media/trayectoria.webp"); --photo-position: 60% 0; --join-size: clamp(20px, 4.2svh, 48px); }
.event { --photo-position: 52% 52%; --join-size: clamp(13px, 3svh, 34px); }
.contact { --join-image: url("media/contacto.webp"); --photo-position: 55% 0; --join-size: clamp(18px, 4.2svh, 44px); }
:is(.story-art, .career-art, .contact-art) { clip-path: inset(calc(-1 * var(--join-size)) 0 0); }
.site-footer { background-color: var(--footer-surface); }
:is(.story, .career, .event, .contact) > .backdrop img { object-position: var(--photo-position); }

:is(.story-art, .career-art, .contact-art)::before {
  --sample: calc(var(--join-size) / 2);
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--photo-shade), var(--join-image) var(--photo-position) / cover no-repeat;
  transform: scaleY(-2);
  transform-origin: top;
  clip-path: inset(0 0 calc(100% - var(--sample)));
  mask-image: linear-gradient(to bottom, #000, #000d calc(var(--sample) * .24), #0005 calc(var(--sample) * .68), transparent var(--sample));
}

.event-art {
  inset-block-start: calc(-1 * var(--join-size));
  height: calc(100% + var(--join-size));
  pointer-events: none;
  mask-image: linear-gradient(to bottom, transparent, #0005 calc(var(--join-size) * .32), #000d calc(var(--join-size) * .76), #000 var(--join-size));
}

@media (min-width: 761px) and (aspect-ratio > 1/1) {
  /* The helmet reaches the trim on widescreen. Carry its sky through the join. */
  .career {
    --career-sky: linear-gradient(90deg, #7586a3, #8195b4 30%, #94a8c8 50%, #adb9d4 71%, #b4bfd8 84%, #aeb9d3);
  }
  .career-art::before {
    background: var(--photo-shade), var(--career-sky);
  }
  .career-art::after {
    content: "";
    position: absolute;
    pointer-events: none;
    inset: 0;
    background: var(--career-sky);
    mask-image: linear-gradient(to bottom, #000, #0009 13px, transparent clamp(24px, 4svh, 42px));
  }
}

@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .story, .career, .contact { --photo-position: 50% 0; }
  .story { --join-image: url("media/historia-movil.webp"); }
  .career { --join-image: url("media/trayectoria-movil.webp"); }
  .contact { --join-image: url("media/contacto-movil.webp"); }
  .event { --photo-position: 58% 49%; }
}

/* The warm and cool underlays carry the photographic palette through the grids. */
.films {
  background: radial-gradient(ellipse at 18% 11%, #24454e, transparent 61%),
    radial-gradient(ellipse at 89% 88%, #392820, transparent 56%), #171818;
}
.gallery { background: #231c18; }
.gallery-atmosphere { opacity: .35; }
.gallery-atmosphere img { object-position: 50% 63%; filter: sepia(.45) brightness(.55); }
.gallery-grid { min-height: 0; }
.films-layout, .gallery-grid {
  padding-block: calc(var(--scrolled-header) + 14px) clamp(14px, 3svh, 34px);
}
.film-feature { min-height: 0; }
.more-films { min-height: 0; grid-template-rows: repeat(2, minmax(0, 1fr)) auto; }
.film-feature, .film-card, .photo-open {
  box-shadow: 0 10px 28px #0b08073d;
}
.photo-open { border: 1px solid #ffdfa32e; border-radius: 3px; }

.site-header.is-scrolled {
  background: linear-gradient(#141413fa, #141413e0 57%, #14141349);
  box-shadow: none;
}
.site-header::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, #a65637, #ffcf96);
  transform: scaleX(var(--reading-progress, 0));
  transform-origin: left;
  pointer-events: none;
}
.site-header:not(.is-scrolled)::after { visibility: hidden; }

.button-youtube, .film-youtube .card-play {
  --youtube-mark: #cb0d32;
  color: #fff;
  background: linear-gradient(135deg, #d10f36, #b40927);
  border-color: #ff6a7b7a;
  box-shadow: inset 0 1px #fff3, 0 4px 13px #8b051d47;
}
.button-youtube:is(:hover, :focus-visible), .film-youtube:is(:hover, :focus-visible) .card-play {
  --youtube-mark: #d60d36;
  color: #fff;
  background: #d60d36;
  border-color: #ff8da2;
}
.button-instagram {
  color: #fff;
  background: linear-gradient(118deg, #5c29a4, #a31f75 51%, #a33523);
  border-color: #ff94b277;
  box-shadow: inset 0 1px #fff3, 0 4px 13px #40062655;
}
.button-instagram:is(:hover, :focus-visible) {
  background: linear-gradient(118deg, #7234b7, #b42179 52%, #a94025);
  border-color: #ffc096;
}
.developer-credit nav .studio-instagram .icon { color: #f893bf; }
.developer-credit nav .studio-instagram:hover { color: #ffc8e0; }

@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .screen { --entry-fade: clamp(29px, 7svh, 64px); --exit-fade: clamp(24px, 5.5svh, 58px); }
  .site-header.is-scrolled { background: linear-gradient(#141413fa 5%, #141413df 60%, #14141324); }
  .films-layout { grid-template-rows: minmax(0, 1fr) auto; }
  .more-films { grid-template-rows: clamp(90px, 17svh, 210px) auto; }
}

@media (max-width: 760px) and (max-height: 540px) {
  .screen { --entry-fade: 34px; --exit-fade: 25px; }
  .films-layout, .more-films { gap: 8px; }
  .more-films { grid-template-rows: minmax(88px, 18svh) auto; }
  .film-feature-copy { padding: 12px; gap: 7px; }
  .film-feature h3 { font-size: clamp(25px, 7vw, 39px); }
  .films .button { min-height: 37px; }
}

@media (max-height: 505px) and (min-width: 540px) and (min-aspect-ratio: 5/4) {
  .story, .career, .contact { align-items: center; }
  .chapter-inner { padding-block: calc(var(--header) + 6px) 13px; }
  .story-art img, .career-art img, .contact-art img { object-position: center 0; }
  .story, .career, .contact {
    --photo-shade: linear-gradient(90deg, #141313fa, #141313cc 31%, #14131366 56%, transparent 84%);
    --photo-position: center 0;
  }
  .story-copy, .contact-copy { gap: 10px; }
  .story-copy > p:not(.editorial-line), .contact-copy > p:not(.editorial-line) {
    max-width: min(49%, 36ch);
    font-size: clamp(13px, 3.7svh, 16px);
    line-height: 1.38;
  }
  .editorial-line, .event h2 { font-size: clamp(29px, 9.5svh, 53px); }
  .career-copy { align-self: center; }
  .timeline { width: min(67%, 515px); }
  .timeline li { grid-template-columns: 50px 1fr; padding-block: clamp(4px, 1.5svh, 8px); }
  .timeline h3 { font-size: clamp(14px, 4.55svh, 21px); }
  .timeline p { font-size: clamp(11px, 3.35svh, 14px); }
  .films-layout { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .more-films { grid-template-columns: 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)) auto; }
  .film-card-copy { padding-right: 34px; }
  .film-card-copy > span { font-size: 11px; }
  .card-play { top: auto; bottom: 6px; right: 6px; }
  .gallery-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  .gallery-lead { grid-area: 1 / 1 / 3 / 8; }
  .gallery-woods { grid-area: 1 / 8 / 2 / 13; }
  .gallery-mountain { grid-area: 2 / 8 / 3 / 11; }
  .gallery-air { grid-area: 2 / 11 / 3 / 13; }
}

@media (prefers-reduced-motion: no-preference) {
  .is-entering .story-copy > *, .is-entering .timeline li,
  .is-entering .event-copy > *, .is-entering .contact-copy > *,
  .is-entering .film-feature, .is-entering .more-films > *, .is-entering .photo-open {
    animation: chapter-arrival .64s cubic-bezier(.2,.72,.27,1) both;
    animation-delay: calc(var(--arrival-order, 0) * 46ms);
  }
  .is-entering :nth-child(2) { --arrival-order: 1; }
  .is-entering :nth-child(3) { --arrival-order: 2; }
  .is-entering :nth-child(4) { --arrival-order: 3; }
  .is-entering :nth-child(5) { --arrival-order: 4; }
  .screen:focus-within :is(.chapter-inner > *, .timeline li, .more-films > *) { animation: none; }
}

@keyframes chapter-arrival {
  from { opacity: .55; translate: 0 17px; }
  to { opacity: 1; translate: 0 0; }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .gallery-grid { perspective: 950px; }
  .photo-open {
    transform: rotateX(var(--rotate-x, 0deg)) rotateY(var(--rotate-y, 0deg));
    transition: transform .28s cubic-bezier(.2,.7,.2,1), box-shadow .26s;
  }
  .photo-open:hover { z-index: 2; box-shadow: 0 16px 35px #0b080877; }
}
