// /**
//  * Copyright © 2015 Magento. All rights reserved.
//  * See COPYING.txt for license details.
//  */

//
//  Variables
//  _____________________________________________

@checkout-shipping-address__max-width: 500px;
@checkout-shipping-address__margin-top: 28px;

@checkout-shipping-item-icon__background-color: @checkout-shipping-item__active__border-color;
@checkout-shipping-item-icon__color: @color-white;
@checkout-shipping-item-icon__content: @icon-checkmark;

@checkout-shipping-item__border: 2px solid transparent;
@checkout-shipping-item__line-height: 30px;
@checkout-shipping-item__margin: 0 0 @indent__base;
@checkout-shipping-item__padding: @indent__base (@indent__l + 5px) @indent__base @indent__base;
@checkout-shipping-item__transition: .3s border-color;
@checkout-shipping-item__width: 100%/3;
@checkout-shipping-item-tablet__width: 100%/2;
@checkout-shipping-item-mobile__width: 100%;
@checkout-shipping-item__active__border-color: @color-orange-red1;

@checkout-shipping-item-icon__selected__height: 27px;
@checkout-shipping-item-icon__selected__width: 29px;

@checkout-shipping-item-mobile__padding: 0 0 15px;
@checkout-shipping-item-mobile__margin: @checkout-shipping-item-mobile__padding;
@checkout-shipping-item-mobile__active__padding: 15px (@indent__l + 5px) 15px 18px;

@checkout-shipping-item-before__border-color: @color-gray80;
@checkout-shipping-item-before__height: calc(~"100% - 20px");

@checkout-shipping-method__border: @checkout-step-title__border;
@checkout-shipping-method__padding: @indent__base;

//
//  Common
//  _____________________________________________

& when (@media-common = true) {

    .opc-wrapper {

        //
        //  Shipping Address
        //  ---------------------------------------------

        .form-login,
        .form-shipping-address {
            .lib-css(margin-top, @checkout-shipping-address__margin-top);
            .lib-css(margin-bottom, @checkout-shipping-address__margin-top);
            .fieldset {
                .field {
                    .label {
                        font-weight: @font-weight__regular;
                    }
                }
                .note {
                    font-size: @font-size__base;
                    margin-top: @indent__s;
                }
            }
        }

        .shipping-address-items {
            font-size: 0;
        }

        .shipping-address-item {
            &:extend(.abs-add-box-sizing all);
            .lib-css(border, @checkout-shipping-item__border);
            .lib-css(font-size, @font-size__base);
            .lib-css(line-height, @checkout-shipping-item__line-height);
            .lib-css(margin, @checkout-shipping-item__margin);
            .lib-css(padding, @checkout-shipping-item__padding);
            .lib-css(transition, @checkout-shipping-item__transition);
            .lib-css(width, @checkout-shipping-item-tablet__width);
            display: inline-block;
            position: relative;
            vertical-align: top;
            word-wrap: break-word;

            &.selected-item {
                .lib-css(border-color, @checkout-shipping-item__active__border-color);

                &:after {
                    .lib-css(background, @checkout-shipping-item-icon__background-color);
                    .lib-css(color, @checkout-shipping-item-icon__color);
                    .lib-css(content, @checkout-shipping-item-icon__content);
                    .lib-css(font-family, @icons__font-name);
                    .lib-css(height, @checkout-shipping-item-icon__selected__height);
                    .lib-css(width, @checkout-shipping-item-icon__selected__width);
                    font-size: 19px;
                    line-height: 21px;
                    padding-top: 2px;
                    position: absolute;
                    right: 0;
                    text-align: center;
                    top: 0;
                }

                .action-select-shipping-item {
                    &:extend(.abs-no-display-s all);
                    visibility: hidden;
                }
            }
        }

        .field {
            &.addresses {
                &:extend(.abs-add-clearfix all);
            }
        }

        .action-show-popup {
            margin: 0 0 @indent__base;
            > span {
                &:before {
                    content: '+';
                    padding-right: @indent__xs;
                }
            }
        }

        .action-select-shipping-item {
            float: right;
            margin: @indent__base 0 0;
        }

        .edit-address-link {
            &:extend(.abs-action-button-as-link all);
            display: block;
            float: left;
            margin: 26px 5px 0 0;
        }
    }

    //
    //  Shipping Methods
    //  ---------------------------------------------

    .checkout-shipping-method {
        .step-title {
            margin-bottom: 0;
        }
        .no-quotes-block {
            margin: @indent__base 0;
        }
    }

    .methods-shipping {
        .actions-toolbar {
            .action {
                &.primary {
                    &:extend(.abs-button-l all);
                    margin: @indent__base 0 0;
                }
            }
        }
    }

    .table-checkout-shipping-method {
        thead {
            th {
                display: none;
                font-weight: 600;
            }
        }
        tbody {
            td {
                .lib-css(border-top, @checkout-shipping-method__border);
                .lib-css(padding-bottom, @checkout-shipping-method__padding);
                .lib-css(padding-top, @checkout-shipping-method__padding);
                &:first-child {
                    padding-left: 0;
                    padding-right: 0;
                    width: 20px;
                }
            }
            tr {
                &:first-child {
                    td {
                        border-top: none;
                    }
                }
            }
            .col-price {
                font-weight: @font-weight__semibold;
            }
            .row-error {
                td {
                    border-top: none;
                    padding-bottom: @indent__s;
                    padding-top: 0;
                }
            }
        }
    }
}

//
//  Mobile
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) {
    .opc-wrapper {
        .form-login,
        .form-shipping-address,
        .methods-shipping {
            .lib-css(background, @checkout-step-content-mobile__background);
            .lib-css(margin, @checkout-step-content-mobile__margin);
            .lib-css(padding, @indent__base @checkout-step-content-mobile__margin-s);
        }

        .form-login {
            + .form-shipping-address {
                .lib-css(margin-top, -(@checkout-step-content-mobile__margin-s));
            }
        }

        .shipping-address-item {
            .lib-css(border-bottom, 1px solid @checkout-shipping-item-before__border-color);
            .lib-css(margin, @checkout-shipping-item-mobile__margin);
            .lib-css(padding, @checkout-shipping-item-mobile__padding);
            .lib-css(width, @checkout-shipping-item-mobile__width);
            &.selected-item {
                .lib-css(padding, @checkout-shipping-item-mobile__active__padding);
                border-bottom-width: 2px;

                .edit-address-link {
                    .lib-css(right, @checkout-shipping-item-icon__selected__width + @indent__s);
                }
            }
        }

        .action-select-shipping-item {
            float: none;
            margin-top: @indent__s;
            width: 100%;
        }

        .action-show-popup {
            width: 100%;
        }

        .methods-shipping {
            .lib-css(border-bottom, @checkout-step-title__border);
            padding-top: @indent__l;
        }

        .edit-address-link {
            .lib-icon-font(
                @icon-edit,
                @_icon-font-size: 18px,
                @_icon-font-line-height: 20px,
                @_icon-font-text-hide: true,
                @_icon-font-color: @minicart-icons-color,
                @_icon-font-color-hover: @primary__color,
                @_icon-font-color-active: @minicart-icons-color
            );
            margin: 0;
            position: absolute;
            right: 0;
            top: 5px;
        }
    }
}

//
//  Desktop
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
    .checkout-shipping-method {
        .actions-toolbar {
            > .primary {
                float: right;
            }
            .action {
                &.primary {
                    margin: 0;
                }
            }
        }
    }
    .opc-wrapper {
        .form-login,
        .form-shipping-address {
            .lib-css(max-width, @checkout-shipping-address__max-width);
        }

        .form-login {
            .lib-css(border-bottom, @checkout-step-title__border);
            padding-bottom: @indent__base;
        }
    }
    .table-checkout-shipping-method {
        width: auto;
    }
}

.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__l) {
    .opc-wrapper {
        .shipping-address-item {
            .lib-css(width, @checkout-shipping-item__width);

            &:before {
                .lib-css(background, @checkout-shipping-item-before__border-color);
                .lib-css(height, @checkout-shipping-item-before__height);
                content: '';
                left: 0;
                position: absolute;
                top: 0;
                width: 1px;
            }

            &:nth-child(3n+1) {
                &:before {
                    display: none;
                }
            }

            &.selected-item {
                &:before {
                    display: none;
                }

                + .shipping-address-item {
                    &:before {
                        display: none;
                    }
                }
            }
        }
    }
    .table-checkout-shipping-method {
        min-width: 500px;
    }
}
