/*!
 * Copyright (C) 2023 StApps
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

@mixin ion-content-parallax(
  $parallax-background: var(--ion-color-primary),
  $background: var(--ion-background-color),
  $parallax-strength: 2,
  $overscroll-padding: 720px,
  $content-size: 230px
) {
  &::part(background) {
    background: $background;
  }
  &::part(scroll) {
    perspective: 2px;
    perspective-origin: center top;
  }
  > div {
    transform-style: preserve-3d;
    position: relative;

    &::after {
      content: ' ';
      position: absolute;
      top: 0;
      right: 0;
      left: 0;

      $height: calc($content-size + $overscroll-padding);
      $translateY: calc($overscroll-padding * $parallax-strength);
      $translateZ: calc(-1px * $parallax-strength);
      $transform-origin: calc($parallax-strength * $parallax-strength * $overscroll-padding);

      height: $height;
      width: 150%;
      transform-origin: 50% $transform-origin;
      transform: translate3d(0px, $translateY, $translateZ) scale($parallax-strength);
      z-index: -1;

      background: $parallax-background;
    }
  }
}
