{% assign catalog_courses = courses.in_catalog %}

{% include "header" %}

<div class="row subpage-intro">
    <div class="color-layer"></div>
    <div class="col-xs-12 col-sm-9 col-md-6" style="margin:auto;">
       <div class="subpage-intro-content-wrapper">
        <div class="subpage-intro-title">{{catalog.headline}}</div>
        <div class="subpage-intro-divider"></div>
        <div class="subpage-intro-subtitle">{{catalog.subheadline}}</div>
       </div>
    </div>
</div>
<div class="content-disclaimer np-subpage-container">The content you access on this website is intended for Healthcare Professionals practicing in the U.S. and is consistent with U.S. labeling.</div>
<main class="np-main np-catalog np-subpage-container np-max-width">
    <a class="mobile-filter-link np-hidden-desktop">Filter by Topic <i class="fas fa-filter"></i></a>
    <div class="np-hidden-desktop mobile-filter-sidebar"> 
        <i class="fal fa-times"></i>      
        {% include 'category_filter_sidebar', catalog_courses: catalog_courses %}
    </div>
    <div class="row np-flex-center">
        <div class="col-xs-12 col-sm-3 np-hidden-mobile">
            {% include 'category_filter_sidebar', catalog_courses: catalog_courses %}
        </div>

        <div class="col-xs-12 col-sm-9">
            {% include "courses_catalog" %}
        </div>
    </div>
</main>
{% include "footer" %}

<style>  
.subpage-intro {
    position:relative;
    background: url(https://s3.amazonaws.com/static.northpass.com/J%26J/homepage_banner_all_content.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    padding: 64px 16px;
    margin: 0;
}

.color-layer {
    background-color: rgba(51, 51, 51, 0.5);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.subpage-intro-content-wrapper {
    text-align:center;
    color: #fff;
    position: relative;
    font-size: 18px;
}

.subpage-intro-title {
       font-size: 32px;
           line-height: normal;
    text-transform: uppercase;
    font-weight: 900;
}

.subpage-intro-divider {
    height: 5px;
    margin: 16px auto;
    width:100px;
    background-color:#cc0033;
}

.np-catalog {
    padding-top:80px;
}

.category-hidden {
    display: none;
  }

.mobile-filter-link {
    margin-bottom: 32px;
    display: inline-block;
    text-decoration: none;
    color:  #009999;
    text-decoration: underline;
}

.mobile-filter-sidebar {
    position: fixed;
    left: 0;
    background-color: #fff;
    height: 100vh;
    top: 0;
    padding: 60px 32px;
    width: 100%;
    max-width: 300px;
    transform: translateX(-300px);
    transition: transform 0.3s;
    z-index: 20;
    overflow-y: scroll;
}

.mobile-filter-sidebar.sidebar-open {
    transform: translateX(0);
}

.mobile-filter-sidebar i.fa-times {
    position: relative;
    float: right;
    top: -30px;
    font-size: 25px;
}

  @media (min-width:768px) {
    .subpage-intro {
        min-height:400px;
    }
    .subpage-intro-content-wrapper {
        font-size: 20px;
    }

    .subpage-intro-title {
        font-size: 50px;
    }
}
</style>

<script>
 /* convert values to same format */
  $('[data-category]').each(function(){
    $(this).attr('data-category', $(this).attr('data-category').replaceAll(' ', '').replaceAll('+', ' ').toLowerCase());
  });

  /* add action to filters on click */
  $('.filter-element-category:not(.has-sub-categories)').click(function(){
    filterCatalogCourses($(this))
  });

  $('.filter-item-sub-category').click(function(){
    filterCatalogCourses($(this))
  });

    $('.has-sub-categories .top-level-filter').click(function() {
        $(this).parent().toggleClass('filter-open')
    })

    function filterCatalogCourses(elmnt) {
        const selectedCategory = elmnt.data('category')

        $('.category-selected').removeClass('category-selected');
        elmnt.addClass('category-selected');

        if (selectedCategory == 'all') {
            $('.catalog-card').removeClass('category-hidden');
        } else {
            $('.catalog-card').removeClass('category-hidden');
            /* hides all cards without selected category if the 'All' wasn't selected */
            $('.catalog-card').each(function(index, card) {            
                $(`.catalog-card:not([data-category*="${selectedCategory}"])`).addClass('category-hidden')
            })
        }
    }

    $(".mobile-filter-link").click(function() {
        $(".mobile-filter-sidebar").addClass("sidebar-open")
    })

    $(".mobile-filter-sidebar i.fa-times").click(function() {
        $(".mobile-filter-sidebar").removeClass("sidebar-open")
    })
</script>