$(document).ready(function () {
    var categoryLanding = $('.category-landing'),
        cardContentWrap = $('.card__content-wrap'),
        cardInner = $('.card__inner'),
        middleWidth = 1200,
        smallWidth = 767,
        clampTexts = $('.card__descr'),
        title = $('.card__title');

    if (categoryLanding.length) {

        function init() {
            var clampExtras = clampTexts.closest(categoryLanding).find(title),
                clampRows, clampFullRows,
                arr = Wick.Clamping.variableArray(clampExtras);

            if ($(window).width() < smallWidth ) {
                clampRows = 5;
                clampFullRows = 6;
            } else if ( $(window).width() < middleWidth){
                clampRows = 5;
                clampFullRows = 5;
            } else {
                clampRows = 4;
                clampFullRows = 6;
            }

            Wick.Clamping.flush(clampTexts);
            Wick.Clamping.clampAll(clampTexts, {id: 'one', lines: clampRows, variableLines: arr, additionalLines: clampFullRows});
        }

        init();

        $(window).on('resize', _.debounce(function () {
            cardInner.removeClass("full-height");
            cardContentWrap.removeClass("change-card");
            init();
        }, 250));
    }
});

