/*
 *  Copyright 2016 Adobe Systems Incorporated
 *
 *  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.
 */

@import (reference) "/apps/weretail/clientlibs/common/variables.less";
@import (reference) "/apps/weretail/clientlibs/clientlib-site/less/grid.less";

.we-product-grid-container {
    .foundation-ordered-list-container {
        padding-left: 0;
        list-style: none;
        font-size: 0;
        width: 100%;
        margin: 0px;
        text-align: left;
    }

    .foundation-list-item {
        display: inline-block;
        vertical-align: bottom;
        margin: 0;
        padding: 0;
        font-size: @font-size-base;
    }

    &-mobilePagination {
        text-align: center;

        a {
            text-indent: -99999px;
            margin: 0 1rem;
            display: inline-block;
            text-decoration: none;
            border-radius: 50%;
            border: 1px solid @brand-primary;
            width: 15px;
            height: 15px;
            cursor: pointer;

            &.active {
                background-color: @brand-primary;
            }
        }
    }
    .foundation-list-item {
        width: percentage(@max_col/6/@max_col);
    }
    
    &.aem-GridColumn--default--10 {
        .foundation-list-item {
            width: percentage(@max_col/5/@max_col);

            @media (max-width: @screen-sm-max) {
                width: percentage(@max_col/2/@max_col);
            }
        }
    }

    .pagination {
        display: none;
    }
}

.generate-mobile-pagination(@itemsPerPage, @pages, @i: 0) when (@i <= @pages) {

    &[data-page="@{i}"] {
        .foundation-ordered-list-container {
            left: @i * -100vw;
        }
    }

    .generate-mobile-pagination(@itemsPerPage, @pages, (@i + 1));
}

//== Mobile pagination
@media (max-width: @screen-sm-max) {
    .we-product-grid-container {

        max-width: 100vw;
        overflow: hidden;

        ol.foundation-ordered-list-container {
            .foundation-list-item {
                width: 50%;
            }
        }

        ul.foundation-ordered-list-container {
            left: 0;
            width: 100%;
            overflow: hidden;
            position: relative;
            font-size: @font-size-base;
            margin: 0 (@grid-gutter-width/-2);
            text-align: center;

            transition: left .25s;

            .foundation-list-item {
                width: 150px;
                float: none;
                display: inline-block;
                clear: none;
            }
        }

        .generate-mobile-pagination(2, 5);
    }
}