:root {
  --agentur-phase: 1800ms;
  --agentur-quadrat: min(58.67vmin, calc(18.67vw + 18.67vh));
  --agentur-kurve: cubic-bezier(.45, 0, .25, 1);
}

/* Der Schatten färbt die Fläche außerhalb des Quadrats blau.
   In der transparenten Mitte ist die tatsächliche Seite zu sehen. */
html[data-agentur-phase]::after {
  content: "";
  position: fixed;
  inset: 0;
  margin: auto;
  width: var(--agentur-quadrat);
  height: var(--agentur-quadrat);
  border-radius: 26%;
  background-color: var(--color-form-yellow);
  box-shadow: 0 0 0 150vmax var(--color-brand);
  z-index: 2147483647;
  pointer-events: auto;
}

html[data-agentur-phase="aus"] #tm-mobile {
  visibility: hidden;
}

html[data-agentur-phase="aus"]::after {
  animation: agentur-schliessen var(--agentur-phase) var(--agentur-kurve) both;
}

html[data-agentur-phase="ein"]::after {
  animation: agentur-oeffnen var(--agentur-phase) var(--agentur-kurve) both;
}

html[data-agentur-phase] .tm-page {
  transform-origin: 50% var(--agentur-mitte, 50vh);
}

html[data-agentur-phase="aus"] .tm-page {
  animation: agentur-verkleinern var(--agentur-phase) var(--agentur-kurve) both;
}

html[data-agentur-phase="ein"] .tm-page {
  animation: agentur-vergroessern var(--agentur-phase) var(--agentur-kurve) both;
}

@keyframes agentur-schliessen {
  0% { width: 100%; height: 100%; border-radius: 0; background-color: transparent; }
  64% { width: var(--agentur-quadrat); height: var(--agentur-quadrat); border-radius: 26%; background-color: transparent; }
  86%, 100% { background-color: var(--color-form-yellow); }
}

@keyframes agentur-oeffnen {
  0%, 10% { background-color: var(--color-form-yellow); }
  36% { width: var(--agentur-quadrat); height: var(--agentur-quadrat); border-radius: 26%; background-color: transparent; }
  100% { width: 100%; height: 100%; border-radius: 0; background-color: transparent; }
}

@keyframes agentur-verkleinern {
  0% { transform: scale(1); }
  64%, 100% { transform: scale(var(--agentur-zoom)); }
}

@keyframes agentur-vergroessern {
  0%, 36% { transform: scale(var(--agentur-zoom)); }
  100% { transform: scale(1); }
}
