/* --------------------------------

File#: _1_responsive-sidebar
Title: Responsive Sidebar
Descr: Responsive sidebar container
Usage: codyhouse.co/license

-------------------------------- */

.sidebar {
    position: relative;
}

.sidebar__header {
    @apply px-5 py-3 text-white bg-primary-900 z-2 lg:px-8 lg:py-5;
}

.sidebar__panel {
    background-color: #ebebeb;
    height: 100%;
    max-height: 100%;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.sidebar--static .sidebar__panel {
    position: fixed;
    top: var(--top-bar-height);
    left: 0;
    width: 100%;
    max-width: 15rem;
    max-height: calc(100vh - var(--top-bar-height));
}

/* mobile version only (--default) 👇 */
.sidebar:not(.sidebar--static) {
    position: fixed;
    top: 0;
    left: 0;
    @apply z-10;
    width: 100%;
    height: 100%;
    visibility: hidden;
    transition: visibility 0s 0.3s;
}

.sidebar:not(.sidebar--static)::after {
    /* overlay layer */
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    @apply bg-neutral-900/75;
    transition: background-color 0.3s;
    z-index: 1;
}

.sidebar:not(.sidebar--static) .sidebar__panel {
    /* content */
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    max-width: 380px;
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%);
    transition: box-shadow 0.3s, -webkit-transform 0.3s;
    transition: box-shadow 0.3s, transform 0.3s;
    transition: box-shadow 0.3s, transform 0.3s, -webkit-transform 0.3s;
}

.sidebar:not(.sidebar--static).sidebar--right-on-mobile .sidebar__panel {
    left: auto;
    right: 0;
    -webkit-transform: translateX(100%);
    transform: translateX(100%);
}

.sidebar:not(.sidebar--static).sidebar--is-visible {
    visibility: visible;
    transition: none;
}

.sidebar:not(.sidebar--static).sidebar--is-visible::after {
    @apply bg-gray-900/[.85];
}

.sidebar:not(.sidebar--static).sidebar--is-visible .sidebar__panel {
    transform: translateX(0);
    @apply shadow-md;
}

/* end mobile version */
.sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
}

.sidebar__close-btn {
    --size: 32px;
    width: var(--size);
    height: var(--size);
    display: flex;
    border-radius: 50%;
    @apply bg-white;
    @apply shadow-md;
    transition: 0.2s;
    flex-shrink: 0;
}

.sidebar__close-btn .icon {
    display: block;
    margin: auto;
}

.sidebar__close-btn:hover {
    @apply bg-white;
    @apply shadow-lg;
}

/* desktop version only (--static) 👇 */
.sidebar--static {
    flex-shrink: 0;
    flex-grow: 1;
}

.sidebar--static .sidebar__header {
    display: none;
}

.sidebar--sticky-on-desktop {
    position: sticky;
    @apply top-3 lg:top-5;
    max-height: calc(100vh - 0.75rem);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 64rem) {
    .sidebar--sticky-on-desktop {
        max-height: calc(100vh - 1.125rem);
    }
}

/* end desktop version */
.sidebar, .sidebar-loaded\:show {
    opacity: 0;
    /* hide sidebar - or other elements using the .sidebar-loaded:show class - while it is initialized in JS */
}

.sidebar--loaded {
    opacity: 1;
}

/* detect when the sidebar needs to switch from the mobile layout to a static one - used in JS */
[class*=sidebar--static]::before {
    display: none;
}

.sidebar--static::before {
    content: "static";
}

.sidebar--static\@xs::before {
    content: "mobile";
}

@media (min-width: 32rem) {
    .sidebar--static\@xs::before {
        content: "static";
    }
}

.sidebar--static\@sm::before {
    content: "mobile";
}

@media (min-width: 48rem) {
    .sidebar--static\@sm::before {
        content: "static";
    }
}

.sidebar--static\@md::before {
    content: "mobile";
}

@media (min-width: 64rem) {
    .sidebar--static\@md::before {
        content: "static";
    }
}

.sidebar--static\@lg::before {
    content: "mobile";
}

@media (min-width: 80rem) {
    .sidebar--static\@lg::before {
        content: "static";
    }
}

.sidebar--static\@xl::before {
    content: "mobile";
}

@media (min-width: 90rem) {
    .sidebar--static\@xl::before {
        content: "static";
    }
}
