/**
 *
 * @ai-apps/angular v2.152.0 | _pagination-nav.scss
 *
 * Copyright 2014, 2023 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

//-----------------------------
// Pagination Nav
//-----------------------------

@import '../../globals/scss/colors';
@import '../../globals/scss/vars';
@import '../../globals/scss/theme';
@import '../../globals/scss/typography';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
@import '../../globals/scss/css--reset';

/// Pseudo underline
/// @access private
/// @group pagination-nav
@mixin pseudo-underline() {
  &:not(.#{$prefix}--pagination-nav__page--direction) {
    &::after {
      position: absolute;
      bottom: 0;
      left: 50%;
      display: block;
      width: 0;
      height: $carbon--spacing-02;
      background-color: $interactive-01;
      content: '';
      opacity: 0;
      transition: width $duration--fast-02 motion(standard, productive);
    }
  }

  .#{$prefix}--pagination-nav__page--active + &::after,
  &.#{$prefix}--pagination-nav__page--active::after {
    left: calc(50% - #{$carbon--spacing-05 / 2});
    width: $carbon--spacing-05;
    opacity: 1;
  }
}

/// Pagination nav base styles
/// @access private
/// @group pagination-nav
/// @param {Color} $text-color [$text-02]
/// @param {Color} $text-color-active [$text-02]
/// @param {Color} $background-color-hover [$hover-ui]
/// @param {Color} $background-color-active [initial]
/// @param {Number} $font-weight [400]
/// @param {Number} $item-padding [0]
/// @param {Number} $button-min-width [$carbon--spacing-09]
/// @param {Value} $button-padding [1.0625rem $carbon--spacing-02]
/// @param {Number} $button-direction-size [$carbon--spacing-09]
/// @param {Number} $select-icon-top-position [$carbon--spacing-05]
/// @param {Number} $select-icon-left-position [$carbon--spacing-05]
@mixin pagination-nav(
  $text-color: $text-02,
  $text-color-active: $text-02,
  $background-color-hover: $hover-ui,
  $background-color-active: initial,
  $font-weight: 400,
  $item-padding: 0,
  $button-min-width: $carbon--spacing-09,
  $button-padding: 1.0625rem $carbon--spacing-02,
  $button-direction-size: $carbon--spacing-09,
  $select-icon-top-position: $carbon--spacing-05,
  $select-icon-left-position: $carbon--spacing-05
) {
  .#{$prefix}--pagination-nav {
    @include reset;
    @include type-style('body-short-01');

    line-height: 0;
  }

  .#{$prefix}--pagination-nav__list {
    display: flex;
    align-items: center;
    list-style: none;
  }

  .#{$prefix}--pagination-nav__list-item {
    padding: $item-padding;

    &:first-child {
      padding-left: 0;
    }

    &:last-child {
      padding-right: 0;
    }
  }

  .#{$prefix}--pagination-nav__page {
    @include type-style('body-short-01');
    @include button-reset($width: false);

    position: relative;
    display: block;
    min-width: $button-min-width;
    padding: $button-padding;
    border-radius: 0;
    color: $text-color;
    font-weight: $font-weight;
    line-height: 1;
    outline: 0;
    text-align: center;
    text-decoration: none;
    transition: background-color $duration--fast-02 motion(standard, productive),
      color $duration--fast-02 motion(standard, productive);
    user-select: none;

    &:hover {
      background-color: $background-color-hover;
      color: $text-color;
    }

    &:focus {
      @include focus-outline('outline');
    }

    &:disabled,
    &.#{$prefix}--pagination-nav__page--disabled {
      background: none;
      color: rgba($text-color, 0.5);
      outline: none;
      pointer-events: none;
    }

    @include pseudo-underline();

    &.#{$prefix}--pagination-nav__page--active {
      background-color: $background-color-active;
      color: $text-color-active;
      font-weight: 600;
    }

    .#{$prefix}--pagination-nav__icon {
      fill: currentColor;
      pointer-events: none;
    }
  }

  .#{$prefix}--pagination-nav__page--direction {
    display: flex;
    width: $button-direction-size;
    height: $button-direction-size;
    align-items: center;
    justify-content: center;
    line-height: 0;
  }

  .#{$prefix}--pagination-nav__select {
    position: relative;
  }

  .#{$prefix}--pagination-nav__page--select {
    max-height: $button-min-width;
    appearance: none;
    text-indent: calc(50% - 4.5px);
    // Override some Firefox user-agent styles
    @-moz-document url-prefix() {
      text-indent: 0;
    }
  }

  .#{$prefix}--pagination-nav__select-icon-wrapper {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;

    @include pseudo-underline();

    .#{$prefix}--pagination-nav__page--active + & {
      .#{$prefix}--pagination-nav__select-icon {
        display: none;
      }
    }
  }

  .#{$prefix}--pagination-nav__select-icon {
    position: absolute;
    top: calc(50% - #{$select-icon-top-position / 2});
    left: calc(50% - #{$select-icon-top-position / 2});
    pointer-events: none;
  }

  .#{$prefix}--pagination-nav__accessibility-label {
    @include hidden();
  }
}

@include exports('pagination-nav') {
  @include pagination-nav;
}
