@use "uswds-core" as *;

.usa-accordion--select,
.usa-accordion--more-actions {
    display: inline-block;
    width: auto;
    position: relative;
    .usa-accordion__button {
        border-radius: units(.5);
    }
    .usa-accordion__button:focus {
        outline-offset: 0;
        outline-width: 3px;
    }
    .usa-accordion__button[aria-expanded=false],
    .usa-accordion__button[aria-expanded=false]:hover,
    .usa-accordion__button[aria-expanded=true],
    .usa-accordion__button[aria-expanded=true]:hover {
        background-image: none;
    }
    .usa-accordion__button[aria-expanded=true] {
        background-color: color('primary-lighter');
    }
    .usa-accordion__content {
        // Note, width is determined by a custom width class on one of the children
        position: absolute;
        z-index: 1;
        border-radius: 4px;
        border: solid 1px color('base-lighter');
        padding: units(2) units(2) units(3) units(2);
        width: max-content;
    }
    h2 {
        font-size: size('body', 'sm');
    }
    .usa-button {
        width: 100%;
    }
    .margin-top-0 {
        margin-top: 0 !important;
    }
    .margin-top-2px {
        margin-top: 2px !important;
    }
}

// This will work in responsive tables if we overwrite the overflow value on the table container
// Works with styles in _tables
@include at-media(desktop) {
    .usa-accordion--more-actions .usa-accordion__content {
        left: 0;
    }
}

.usa-accordion--select .usa-accordion__content {
    top: 33.88px;
}

.usa-accordion--more-actions .usa-accordion__content {
    // We need to match the height of the trigger button
    // to align the 'popup' underneath
    top: 20px;
    &.top-28px {
        top: 28px;
    }
}

// Special positioning for the kabob menu popup in the last row on a given page
// This won't work on the Members table rows because that table has show-more rows
// Currently, that's not an issue since that Members table is not wrapped in the
// reponsive wrapper.
@include at-media-max("desktop") {
    tr:last-of-type .usa-accordion--more-actions .usa-accordion__content,
    tr.view-only-row:nth-last-of-type(2) .usa-accordion--more-actions .usa-accordion__content {
        top: auto;
        bottom: -10px;
        right: 20px;
    }
}

// A CSS only show-more/show-less based on usa-accordion
.usa-accordion--show-more {
    width: auto;
    .usa-accordion__button[aria-expanded=false],
    .usa-accordion__button[aria-expanded=false]:hover,
    .usa-accordion__button[aria-expanded=true],
    .usa-accordion__button[aria-expanded=true]:hover {
        background-image: none;
        background-color: transparent;
        padding-right: 0;
        padding-left: 0;
        font-weight: normal;
    }
    .usa-accordion__button[aria-expanded=true] .expand-more {
        display: inline-block;
    }
    .usa-accordion__button[aria-expanded=true] .expand-less {
        display: none;
    }
    .usa-accordion__button[aria-expanded=false] .expand-more {
        display: none;
    }
    .usa-accordion__button[aria-expanded=false] .expand-less {
        display: inline-block;
    }
}
