/*
 * LXS Anura – UIkit look for the brix Anura web components.
 * Only official hooks are used: CSS custom properties and ::part(). The brix code stays untouched.
 * Colours/fonts default to the LANXESS style; the child theme may override the --lxs-anura-* variables
 * with the YOOtheme style values (see templates/yootheme_lxs/less/anura.less).
 */

/* :where() keeps the specificity at 0, so the values from the YOOtheme style (child theme) always win. */
:where(:root) {
    --lxs-anura-primary-hover: #a4001c;
    --lxs-anura-color: #343434;
    --lxs-anura-emphasis: #343434;
    --lxs-anura-muted: #8c8c8c;
    --lxs-anura-border: #e5e5e5;
    --lxs-anura-background: #fff;
    --lxs-anura-muted-background: #f4f4f4;
    --lxs-anura-overlay: rgba(0, 0, 0, 0.6);
    --lxs-anura-title-background: #000;
    --lxs-anura-overlay-strong: rgba(0, 0, 0, 0.78);
    --lxs-anura-radius: 0;
    --lxs-anura-gutter: 15px;
    --lxs-anura-input-height: 40px;
    --lxs-anura-font-size-small: 0.875rem;
    --lxs-anura-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);

    /* Anura's own global variables */
    --button-color: var(--lxs-anura-primary);
    --button-font-color: #fff;
    --selected-color: var(--lxs-anura-primary);
    --border-color: var(--lxs-anura-border);
    --border-radius: var(--lxs-anura-radius);
    --counter-color: var(--lxs-anura-muted);
    --background-color: var(--lxs-anura-background);
}

/* ========================================================================
   Gallery grid
   Default: as many columns as tiles of --lxs-anura-tile-width fit into the gallery's own width, so it
   works in any YOOtheme column. Optional fixed columns per breakpoint (columns="1,2,3,4,4", class
   lxs-anura-cols) like the YOOtheme grid settings. Values come as CSS variables from the Renderer.
 ========================================================================== */

anura-gallery.lxs-anura-gallery {
    display: block;
    --lxs-anura-tile-width: 260px;
}

anura-gallery.lxs-anura-gallery::part(asset-container) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--lxs-anura-tile-width)), 1fr));
    gap: var(--lxs-anura-gutter);
    justify-content: stretch;
}

anura-gallery.lxs-anura-cols { --lxs-anura-cols: var(--lxs-anura-cols-default, 1); }

@media (min-width: 640px) {
    anura-gallery.lxs-anura-cols { --lxs-anura-cols: var(--lxs-anura-cols-s, 1); }
}

@media (min-width: 960px) {
    anura-gallery.lxs-anura-cols { --lxs-anura-cols: var(--lxs-anura-cols-m, 1); }
}

@media (min-width: 1200px) {
    anura-gallery.lxs-anura-cols { --lxs-anura-cols: var(--lxs-anura-cols-l, 1); }
}

@media (min-width: 1600px) {
    anura-gallery.lxs-anura-cols { --lxs-anura-cols: var(--lxs-anura-cols-xl, 1); }
}

anura-gallery.lxs-anura-cols::part(asset-container) {
    grid-template-columns: repeat(var(--lxs-anura-cols), minmax(0, 1fr));
}

/* ========================================================================
   Tile (like a uk-inline image with uk-overlay at the bottom)
 ========================================================================== */

anura-gallery.lxs-anura-gallery::part(anura-asset) {
    width: auto;
    height: auto;
    overflow: hidden;
    border-radius: var(--lxs-anura-radius);
    background: var(--lxs-anura-muted-background);
    /* Anura draws a light 1px border around the hover slot; it would show through the overlay as a grey line. */
    --thumbnail-border-color: transparent;
}

/* Title bar turns solid while hovering, the description sits above it with the normal overlay. */
anura-gallery.lxs-anura-gallery::part(anura-asset):hover {
    --lxs-anura-title-bg: var(--lxs-anura-title-background);
}

anura-gallery.lxs-anura-gallery::part(asset-figure) {
    position: relative;
    height: auto;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

anura-gallery.lxs-anura-gallery::part(asset-thumbnail) {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 0;
    border-radius: 0;
}

anura-gallery.lxs-anura-gallery::part(asset-title) {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    height: auto;
    margin: 0;
    padding: 10px 15px;
    opacity: 1;
    background: var(--lxs-anura-title-bg, var(--lxs-anura-overlay));
    color: #fff;
    transition: background-color 0.25s ease-in-out;
    font-size: var(--lxs-anura-font-size-small);
    line-height: 1.4;
    white-space: normal;
    word-break: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/*
 * Hover layer (official "thumbnail-hover" slot): the description appears directly above the (always visible)
 * title bar. A hidden copy of the title reserves exactly the height of the title bar, so both meet seamlessly.
 * Anura gives the slot a 1px border and makes it 1.5em shorter than the figure, hence the -1px offsets and
 * bottom: calc(-1.5em - 1px) (font-size stays inherited here).
 */
anura-gallery.lxs-anura-gallery::part(lxs-anura-hover) {
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: calc(-1.5em - 1px);
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: #fff;
    overflow: hidden;
}

/* Anchored to the bottom: if the text is too long it is cut at the top (behind the buttons), never above the title. */
anura-gallery.lxs-anura-gallery::part(lxs-anura-hover-text) {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    flex: 0 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 10px 15px;
    background: var(--lxs-anura-overlay);
    font-size: 0.8125rem;
    line-height: 1.5;
}

anura-gallery.lxs-anura-gallery::part(lxs-anura-hover-title) {
    flex-shrink: 0;
    visibility: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding: 10px 15px;
    font-size: var(--lxs-anura-font-size-small);
    line-height: 1.4;
}

anura-gallery.lxs-anura-gallery::part(asset-content) {
    display: none;
}

/* Basket button: top right, white with slightly rounded corners. */
anura-gallery.lxs-anura-gallery::part(asset-actions) {
    position: absolute;
    top: 8px;
    right: 8px;
    bottom: auto;
    left: auto;
    z-index: 3;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    gap: 6px;
    background: none;
}

/* Only style, never "display": Anura hides unused buttons inline and ::part() would override that. */
anura-gallery.lxs-anura-gallery::part(asset-button) {
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    background: var(--lxs-anura-background);
    border-radius: 4px;
    box-shadow: var(--lxs-anura-shadow);
    color: var(--lxs-anura-primary);
    transition: opacity 0.25s ease-in-out, visibility 0.25s ease-in-out;
}

anura-gallery.lxs-anura-gallery::part(action-icon) {
    width: 20px;
    height: 20px;
}

/* Touch devices have no hover: always show the buttons */
@media (hover: none) {
    anura-gallery.lxs-anura-gallery::part(asset-actions) {
        height: auto;
    }

    anura-gallery.lxs-anura-gallery::part(asset-button) {
        visibility: visible;
        opacity: 1;
    }
}

/* Masonry: CSS columns, natural image height (column width = tile width, or the fixed column count) */
anura-gallery.lxs-anura-mode-masonry::part(asset-container) {
    display: block;
    columns: var(--lxs-anura-tile-width);
    column-gap: var(--lxs-anura-gutter);
}

anura-gallery.lxs-anura-mode-masonry.lxs-anura-cols::part(asset-container) {
    columns: var(--lxs-anura-cols);
}

anura-gallery.lxs-anura-mode-masonry::part(anura-asset) {
    break-inside: avoid;
    margin-bottom: var(--lxs-anura-gutter);
}

anura-gallery.lxs-anura-mode-masonry::part(asset-figure) {
    aspect-ratio: auto;
}

anura-gallery.lxs-anura-mode-masonry::part(asset-thumbnail) {
    height: auto;
}

/* Flex: rows of tiles that grow to fill the line */
anura-gallery.lxs-anura-mode-flex::part(asset-container) {
    display: flex;
    flex-wrap: wrap;
}

anura-gallery.lxs-anura-mode-flex::part(anura-asset) {
    flex: 1 1 var(--lxs-anura-tile-width);
}

/* Dense: thumbnails only, smaller tiles */
anura-gallery.lxs-anura-mode-dense {
    --lxs-anura-tile-width: 140px;
}

anura-gallery.lxs-anura-mode-dense::part(asset-figure) {
    aspect-ratio: 1;
}

anura-gallery.lxs-anura-mode-dense::part(asset-title) {
    display: none;
}

/* Pagination (like uk-pagination) */
anura-gallery.lxs-anura-gallery::part(paginator) {
    margin-top: 30px;
}

anura-gallery.lxs-anura-gallery::part(paginator-button) {
    min-width: 32px;
    padding: 5px 10px;
    border: 0;
    border-radius: var(--lxs-anura-radius);
    background: none;
    color: var(--lxs-anura-muted);
    font: inherit;
}

/* ========================================================================
   Sidebar: search, tree, filters, reset
   The look comes from the real UIkit rules of the YOOtheme style (child theme anura.less maps the
   Anura parts via LESS :extend). Here only layout and the parts UIkit has no counterpart for.
 ========================================================================== */

.lxs-anura-sidebar anura-searchbar,
.lxs-anura-sidebar anura-select,
.lxs-anura-sidebar anura-multiselect {
    margin: 0;
}

/* The form carries the input look (uk-search-input), so the inner input stays transparent. */
anura-searchbar::part(searchbar-form) {
    display: flex;
    align-items: center;
}

anura-searchbar::part(searchbar-input) {
    flex: 1;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    outline: none;
}

/* Only alignment, never "display" on searchbar-child: Anura hides some children via classes. */
anura-searchbar::part(searchbar-submit) {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* The search help is shown as text below the field (Renderer::search), not as a tooltip icon. */
anura-searchbar::part(searchbar-info) {
    display: none;
}

/* Icon buttons inside the search field, like the icon of a uk-search */
anura-searchbar::part(searchbar-button) {
    border: 0;
    background: none;
}

/* uk-select draws its own arrow */
anura-select::part(header-icon-toggle) {
    visibility: hidden;
}

anura-select::part(fieldset),
anura-multiselect::part(multi-fieldset) {
    border-radius: var(--lxs-anura-radius);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.15);
}

anura-select::part(select-count) {
    color: var(--lxs-anura-muted);
}

/* Header is not clickable (folded="false"), like the old portal. */
anura-tree::part(tree-header),
anura-tree::part(tree-label) {
    cursor: default;
}

anura-tree::part(node-icon) {
    display: none;
}

anura-tree::part(node-counter) {
    color: var(--lxs-anura-muted);
    font-size: var(--lxs-anura-font-size-small);
}

anura-reset::part(reset-icon) {
    width: 16px;
    height: 16px;
    margin: 0 8px 0 0;
    color: inherit;
    vertical-align: -0.2em;
}

anura-reset::part(reset-text) {
    padding: 0;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

anura-counter {
    color: var(--lxs-anura-muted);
    font-size: var(--lxs-anura-font-size-small);
}

anura-counter::part(counter-count) {
    color: var(--lxs-anura-emphasis);
    font-weight: bold;
}

/* ========================================================================
   Lightbox & basket
 ========================================================================== */

/* Optional: hide an empty basket (data-empty is kept in sync by lxs-anura.js) and every element with the class
   lxs-anura-basket-wrap (headline, element, column). Both start hidden, so a full basket appears without a
   flash of the empty one. */
anura-basket.lxs-anura-basket-hide-empty[data-empty],
.lxs-anura-basket-wrap:not([data-lxs-anura-empty="false"]) {
    display: none !important;
}

anura-lightbox::part(lightbox-button) {
    color: var(--lxs-anura-primary);
}

anura-lightbox::part(lightbox-title) {
    font-weight: bold;
}

anura-details::part(details-dt) {
    color: var(--lxs-anura-muted);
}
