/* A masked overlay between the photograph and the editorial content. */
.bruma {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  --bruma-banco: .62;
  --bruma-hilo: .47;
  --bruma-mascara: linear-gradient(160deg, #000b, black 48%, #000d 66%, #0003 86%, transparent);
  /* A feathered opening preserves the dark outline of the climber. */
  --bruma-silueta: radial-gradient(ellipse 15% 36% at 23% 29%, #0001 12%, #0006 43%, black 100%);
  -webkit-mask-image: var(--bruma-mascara), var(--bruma-silueta);
  -webkit-mask-composite: source-in;
  mask-image: var(--bruma-mascara), var(--bruma-silueta);
  mask-composite: intersect;
}

.bruma:not([data-bruma-lista])::before,
.bruma:not([data-bruma-lista])::after { content: none; }

.bruma[data-bruma-lista] {
  visibility: visible;
}

.bruma[data-bruma="estatica"] {
  visibility: hidden;
}

.bruma::before,
.bruma::after {
  content: "";
  position: absolute;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
  animation-fill-mode: both;
  animation-play-state: paused;
}

.bruma::before {
  inset: -18% -12% 22% -20%;
  background-image: url("assets/bruma-plano.webp");
  opacity: var(--bruma-banco);
  animation-name: bruma-estrato-fondo;
  animation-duration: 16s;
  animation-delay: -3s;
}

.bruma::after {
  inset: -4% -19% 0% -8%;
  background-image: url("assets/bruma-filamento.webp");
  opacity: var(--bruma-hilo);
  animation-name: bruma-estrato-frente;
  animation-duration: 12s;
  animation-delay: -7s;
}

.bruma[data-bruma-activa="true"]::before,
.bruma[data-bruma-activa="true"]::after {
  animation-play-state: running;
}

@keyframes bruma-estrato-fondo {
  from { transform: translate(-7%, 3%) rotate(-2deg); }
  to   { transform: translate(8%, -4%) rotate(1deg); }
}
@keyframes bruma-estrato-frente {
  from { transform: translate(7%, 1%) scale(1.04); }
  to   { transform: translate(-8%, -7%) scale(.99); }
}

/* Wind concentrates the long ribbons into the open pass. */
.bruma[data-bruma="lateral"] {
  --bruma-banco: .38;
  --bruma-hilo: .90;
  --bruma-mascara: linear-gradient(155deg, #0005 2%, black 40%, black 61%, transparent 79%);
}
.bruma[data-bruma="lateral"]::before,
.bruma[data-bruma="lateral"]::after {
  animation-direction: normal;
  animation-timing-function: linear;
}
.bruma[data-bruma="lateral"]::before {
  --cresta: var(--bruma-banco);
  inset: -5% -32% 27% -27%;
  animation-name: bruma-viento;
  animation-duration: 10s;
  animation-delay: -3s;
}
.bruma[data-bruma="lateral"]::after {
  --cresta: var(--bruma-hilo);
  inset: 7% -32% 11% -23%;
  animation-name: bruma-viento;
  animation-duration: 8s;
  animation-delay: -5s;
}
@keyframes bruma-viento {
  0%   { transform: translate(-15%, 4%) rotate(3deg); opacity: 0; }
  19%, 77% { opacity: var(--cresta); }
  100% { transform: translate(15%, -5%) rotate(1deg); opacity: 0; }
}

/* A lower bank rises and settles over the slope. */
.bruma[data-bruma="rasante"] {
  --bruma-banco: .87;
  --bruma-hilo: .58;
  --bruma-mascara: linear-gradient(to bottom, transparent 26%, #0006 42%, black 72%, #000a);
}
.bruma[data-bruma="rasante"]::before {
  inset: 30% -14% -18% -12%;
  animation-name: bruma-inversion;
  animation-duration: 14s;
  animation-delay: -2s;
}
.bruma[data-bruma="rasante"]::after {
  inset: 31% -18% -22% -18%;
  animation-name: bruma-inversion;
  animation-duration: 11s;
  animation-direction: alternate-reverse;
  animation-delay: -6s;
}
@keyframes bruma-inversion {
  from { transform: translate(-5%, 9%) rotate(8deg); }
  to   { transform: translate(5%, -8%) rotate(5deg); }
}

/* A single viewport-sized atmosphere travels through every photograph in main. */
#contenido {
  position: relative;
  isolation: isolate;
  background: #1d1d1f;
}

/* Keep pictures, shading and copy in a shared stacking context. */
#contenido .scene {
  isolation: auto;
  background: transparent;
}
#contenido .landscape { z-index: -4; }
#contenido .scene::after { z-index: -3; }

.atmosfera {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.bruma-recorrido {
  position: sticky;
  inset: auto;
  top: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  contain: paint;
  --bruma-banco: .52;
  --bruma-hilo: .57;
  --bruma-mascara: linear-gradient(160deg, #000a, black 38%, black 75%, #000b);
  --bruma-silueta: radial-gradient(ellipse 25% 49% at 20% 40%, #0006, #000c 58%, black);
  --progreso-bruma: 0%;
}

.bruma-recorrido[data-bruma="estratos"]::before {
  inset: -17% -9% 1% -18%;
  translate: calc(var(--progreso-bruma) * .12) calc(var(--progreso-bruma) * -.12);
  animation-name: ascenso-bruma-fondo;
  animation-duration: 21s;
  animation-delay: -4s;
}
.bruma-recorrido[data-bruma="estratos"]::after {
  inset: 4% -16% -15% -10%;
  translate: calc(var(--progreso-bruma) * -.15) calc(var(--progreso-bruma) * -.19);
  animation-name: ascenso-bruma-frente;
  animation-duration: 15s;
  animation-delay: -6s;
}
@keyframes ascenso-bruma-fondo {
  0%   { transform: translate(-5%, 1.5%) rotate(-2deg) scale(1.02); }
  46%  { transform: translate(1%, -2.5%) rotate(1deg) scale(.99); }
  100% { transform: translate(8%, -1%) rotate(2deg) scale(1.04); }
}
@keyframes ascenso-bruma-frente {
  0%   { transform: translate(6%, 2%) rotate(2deg) scale(1.01); }
  55%  { transform: translate(-2%, -3%) rotate(-1deg) scale(1.04); }
  100% { transform: translate(-7%, -8%) rotate(-2deg) scale(.98); }
}

/* A sticky control remains within the recorrido and clear of the altitude line. */
.control-atmosfera {
  position: absolute;
  inset: 0 0 max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 6;
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.control-atmosfera .motion-control {
  position: sticky;
  top: calc(100vh - 60px - env(safe-area-inset-bottom, 0px));
  top: calc(100dvh - 60px - env(safe-area-inset-bottom, 0px));
  display: flex;
  width: max-content;
  margin: 0 0 0 auto;
  pointer-events: auto;
  background: #101013ed;
  border-color: #ffffff7a;
  box-shadow: 0 2px 11px #0006;
}
.control-atmosfera .motion-control::before {
  content: "";
  width: 8px;
  height: 10px;
  border-inline: 2px solid currentColor;
  box-sizing: border-box;
}
.control-atmosfera .motion-control[data-bruma-pausada="true"]::before {
  width: 0;
  height: 0;
  border: 0;
  border-left: 8px solid currentColor;
  border-block: 5px solid transparent;
}
@media (max-width: 850px) {
  .control-atmosfera { padding-right: max(53px, calc(env(safe-area-inset-right, 0px) + 44px)); }
  .control-atmosfera .motion-control { width: 44px; padding: 0; justify-content: center; }
  .control-atmosfera .motion-control [data-bruma-label] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
@media print {
  .control-atmosfera, .atmosfera { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bruma[data-bruma-lista] { visibility: hidden; }
  .bruma::before, .bruma::after { content: none; animation: none; }
}
@media print {
  .bruma, [data-bruma-toggle] { display: none; }
}
