/* ============================================================================
   06-COMPONENTS -> #MEDIA-LIBRARY
   ========================================================================= */

/**
 * 
 */


//
// SCSS imports
//

@use '../01-settings' as *;
@use '../02-tools' as *;


/**
 * Media
 */

.media {
    --media-bg: var(--bg-primary);
    --media-border-color: var(--border-color-secondary);
    --media-border-width: var(--border-width);
    --media-padding-x: var(--card-padding-x);
    --media-padding-y: var(--card-padding-y);
    --media-sidebar-bg: var(--bg-secondary);
    --media-item-bg: var(--bg-tertiary);
    --media-item-border-color: var(--border-color-secondary);
    --media-item-border-radius: var(--rounded-xs);
    --media-item-border-width: var(--border-width);
    --media-item-hover-border-color: var(--border-color-highlight);
    --media-item-active-border-color: var(--border-color-highlight);

    background-color: var(--bg-primary);
    height: 100%;
    min-height: 100%;
    overflow: hidden;

    &[data-view=modal] {
        border: 0;
    }

    @include media-breakpoint-up('md') {
        display: grid;
        grid-template-rows: 1;
        grid-template-columns: 1fr 20rem;
    }
}


/**
 * Media sidebar
 */

.media__sidebar {
    background-color: var(--media-sidebar-bg);
    border-left: var(--media-border-width) solid var(--media-border-color);
    overflow-y: auto;

    @include media-breakpoint-down('md') {
        display: none;
    }
}


/**
 * Media sidebar section
 */

.media__sidebar-section {
    display: flex;
    flex-direction: column;
    padding: var(--media-padding-y) var(--media-padding-x);

    & > * + * {
        margin-top: var(--space-3);
    }

    & + & {
        border-top: var(--media-border-width) solid var(--media-border-color);
    }
}


/**
 * Media library
 */

.media__library {
    height: 100%;
    overflow: auto;
    padding: var(--media-padding-y) var(--media-padding-x);
}


/**
 * Media library items
 */

.media__library-items {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    position: relative;
    width: 100%;
    
    @include media-breakpoint-up('md') {
        grid-column-gap: var(--space-4);
        grid-row-gap: var(--space-6);
    }
}


/**
 * Media library item
 *
 * 1. Set 'pointer-events' to 'none' to avoid interference with click events.
 */

.media-library__item {
    @include transition(('border-color', 'background-color'), var(--duration-md));
    border: var(--media-border-width) solid var(--media-border-color);
    border: var(--media-item-border-width) solid var(--media-item-border-color);
    border-radius: var(--media-item-border-radius);
    cursor: pointer;
    overflow: hidden;
    padding: var(--space-2);
    position: relative;

    &:hover {
        background-color: var(--bg-secondary);
        border-color: var(--color-primary-600);
    }

    & > * {
        pointer-events: none; // [1]
    }
}


/**
 * Media library item inner
 */

.media-library__item-preview {
    background-color: var(--media-item-bg);
    position: relative;

    &::after {
        content: '';
        display: block;
        padding-bottom: 100%;
    }
}


/**
 * Media library item preview
 */

.media-library__item-preview-inner {
    align-items: center;
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
    left: 0;
    padding: var(--space-2);
    position: absolute;
    top: 0;
    width: 100%;
}


/**
 * Media library item thumbnail
 */

.media-library__item-preview-thumbnail {
    display: block;
    height: auto;
    max-height: 100%;
    max-width: 100%;
}


/**
 * Media library item preview
 */

.media-library__item-description {
    color: var(--text-color-tertiary);
    margin-top: var(--space-2);
}




/* MODIFIERS
   ========================================================================= */

/**
 * Selected media library item
 */

.media-library__item[data-selected=true] {
    background-color: var(--bg-secondary);
    border-color: var(--color-primary-600);

    &::before {
        background-color: var(--color-primary-600);
    }

    &::after {
        opacity: 1;
    }
}