/* Extracted from ui/templates/components/dynamic_table/table.html. Linked via sekizai so a page loads it once,
   however many instances it renders. */

.dynamic-table,
.dynamic-table * {
    box-sizing: border-box;
    font-family: "NYU Perstare", sans-serif;
}

.dynamic-table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-bottom: 40px;
    overflow: hidden;
    transition: opacity 160ms ease;
}

.dynamic-table.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.dynamic-table__title {
    margin: 0 0 20px;
    color: #57068C;
    font-size: 32px;
    line-height: 41px;
    font-weight: 800;
    letter-spacing: -0.04em;
    text-transform: uppercase;
}

/* The title is rich text, so the editor wraps it in block tags
   (<p>, sometimes a heading). Flatten those into the h2 rather than
   letting them add their own margins or type scale. */
.dynamic-table__title p,
.dynamic-table__title div,
.dynamic-table__title h1,
.dynamic-table__title h2,
.dynamic-table__title h3,
.dynamic-table__title h4,
.dynamic-table__title h5,
.dynamic-table__title h6 {
    display: inline;
    margin: 0;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}

.dynamic-table__title a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.dynamic-table__message {
    margin: 0 0 20px;
    padding: 22px 24px;
    background: #F7F7F7;
    color: #4B4B4B;
    font-size: 14px;
    line-height: 20px;
}

.dynamic-table__message--error {
    border-left: 4px solid #B00020;
    background: #FFF5F6;
    color: #8A0018;
}

.dynamic-table__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.dynamic-table__count {
    margin: 0;
    color: #4B4B4B;
    font-size: 14px;
    line-height: 18px;
    font-weight: 400;
}

.dynamic-table__count strong {
    color: #161616;
    font-weight: 500;
}

.dynamic-table__sort {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #4B4B4B;
    font-size: 14px;
    line-height: 18px;
    white-space: nowrap;
}

.dynamic-table__sort select {
    height: 32px;
    min-width: 128px;
    border: 1px solid #CECECE;
    border-radius: 3px;
    background: #FFFFFF;
    color: #4B4B4B;
    padding: 0 10px;
    font-size: 14px;
    line-height: 18px;
    font-weight: 400;
    cursor: pointer;
    outline: none;
}

.dynamic-table__sort select:focus-visible {
    outline: none;
}

/* Sort and search sit together on the right of the topbar, so they wrap
   as one group rather than the search dropping under the row count. */
.dynamic-table__controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px 18px;
    flex-wrap: wrap;
    min-width: 0;
}

/* The header's search bar, smaller. These are `.site-search` and its
   children from generic.css, rule for rule; the only values changed are
   the ones that set the size (width, height, gap, padding, type scale,
   icon). Colours are written as literals rather than as the --text-mid /
   --text-dark variables the header uses, because those are declared in
   generic.css and this component also renders on pages that do not load
   it; the values are the same.

   Nothing here styles focus, which is the point: the header's bar does
   not either, and `outline: none` on the field is what keeps the browser
   from drawing its own ring inside the box. */
.dynamic-table__search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 180px;
    max-width: 100%;
    min-width: 0;
    height: 32px;
    padding: 0 12px;
    background: #FFFFFF;
    border: 1px solid #D9D9D9;
    border-radius: 4px;
}

.dynamic-table__search-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.dynamic-table__search-field {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: #4B4B4B;
    font-size: 14px;
    line-height: 18px;
    font-weight: 400;
}

.dynamic-table__search-field::placeholder {
    color: #4B4B4B;
    opacity: 1;
}

.dynamic-table__search-button {
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    color: #4B4B4B;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 180ms ease;
}

.dynamic-table__search-button:hover {
    color: #161616;
}

.dynamic-table__search-button svg {
    width: 14px;
    height: 14px;
}

.dynamic-table__search-clear {
    color: #4B4B4B;
    font-size: 13px;
    line-height: 17px;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.dynamic-table__search-clear:hover,
.dynamic-table__search-clear:focus-visible {
    color: #57068C;
}

.dynamic-table__wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    padding: 6px 0;
}

.dynamic-table__table {
    width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
}

.dynamic-table__table thead {
    position: relative;
    z-index: 5;
}

.dynamic-table__table th {
    position: relative;
    z-index: 5;
    height: 36px;
    padding: 0 12px 8px;
    border-bottom: 2px solid #161616;
    background: #FFFFFF;
    color: #4B4B4B;
    font-size: 14px;
    line-height: 18px;
    font-weight: 400;
    text-align: left;
    letter-spacing: -0.04em;
    vertical-align: bottom;
}

.dynamic-table__sort-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: inherit;
    text-decoration: none;
}

.dynamic-table__sort-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: inherit;
    text-decoration: none;
    cursor: default;
}

.dynamic-table__sort-link:hover,
.dynamic-table__sort-link:focus-visible {
    color: #57068C;
    outline: none;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.dynamic-table__table tbody tr {
    position: relative;
    min-height: 54px;
    transform-origin: center;
    transition:
        background-color 180ms ease,
        transform 180ms ease,
        box-shadow 180ms ease;
}

.dynamic-table__table tbody tr:nth-child(even) {
    background: #F4F4F4;
}

.dynamic-table__table tbody tr:nth-child(odd) {
    background: #FFFFFF;
}

.dynamic-table__table tbody tr:hover {
    background: #FAF5FF;
    transform: translateX(3px);
    box-shadow:
        -3px 0 0 #57068C,
        0 8px 18px rgba(0, 0, 0, 0.10);
    z-index: 2;
}

.dynamic-table__table tbody tr:hover td {
    background: #FAF5FF;
}

.dynamic-table__table td {
    min-height: 54px;
    padding: 10px 12px;
    color: #000000;
    font-size: 14px;
    line-height: 18px;
    font-weight: 400;
    letter-spacing: -0.04em;
    vertical-align: middle;
    min-width: 0;
    transition: background-color 180ms ease;
}

.dynamic-table__cell {
    display: block;
    min-width: 0;
    max-width: 34ch;
    overflow-wrap: anywhere;
}

.dynamic-table__cell--strong {
    font-weight: 700;
}

.dynamic-table--achievements .dynamic-table__table {
    table-layout: fixed;
}

.dynamic-table--achievements .dynamic-table__wrap {
    overflow-x: hidden;
}

.dynamic-table--achievements .dynamic-table__table th:first-child,
.dynamic-table--achievements .dynamic-table__table td:first-child {
    width: 34%;
}

.dynamic-table--achievements .dynamic-table__table th:nth-child(2),
.dynamic-table--achievements .dynamic-table__table td:nth-child(2) {
    width: 66%;
}

.dynamic-table--achievements .dynamic-table__cell {
    max-width: none;
}

.dynamic-table--achievements .dynamic-table__table td {
    padding-top: 16px;
    padding-bottom: 16px;
    vertical-align: top;
}

.dynamic-table__link {
    color: #57068C;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dynamic-table__link:hover,
.dynamic-table__link:focus-visible {
    color: #3a0066;
}

.dynamic-table__badge {
    display: inline-flex;
    width: 34px;
    height: 25px;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    background: var(--dynamic-table-badge-color, #6B7280);
    color: #FFFFFF;
    font-size: 13px;
    line-height: 17px;
    font-weight: 500;
    letter-spacing: -0.04em;
    text-align: center;
    text-transform: uppercase;
}

.dynamic-table__pagination {
    width: 100%;
    margin-top: 42px;
}

.dynamic-table__pagination-row {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 18px;
}

.dynamic-table__pagination-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.dynamic-table__pagination-line {
    height: 1px;
    flex: 1 1 auto;
    background: #DBDBDB;
}

.dynamic-table__page-link,
.dynamic-table__page-current,
.dynamic-table__page-ellipsis {
    display: inline-flex;
    width: 31px;
    height: 31px;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 14px;
    line-height: 18px;
    font-weight: 400;
    letter-spacing: -0.04em;
    text-decoration: none;
}

.dynamic-table__page-link {
    border: 1px solid #DBDBDB;
    background: #F7F7F7;
    color: #4B4B4B;
    transition:
        border-color 180ms ease,
        color 180ms ease,
        background-color 180ms ease;
}

.dynamic-table__page-link:hover,
.dynamic-table__page-link:focus-visible {
    border-color: #57068C;
    color: #57068C;
    background: #FFFFFF;
    outline: none;
}

.dynamic-table__page-current {
    border: 1px solid #57068C;
    background: #FFFFFF;
    color: #57068C;
}

.dynamic-table__page-ellipsis {
    width: auto;
    min-width: 18px;
    border: 0;
    background: transparent;
    color: rgba(75, 75, 75, 0.65);
    letter-spacing: 0.06em;
}

@media (max-width: 900px) {
    .dynamic-table__topbar {
        align-items: center;
        flex-wrap: wrap;
        gap: 8px 14px;
        margin-bottom: 16px;
    }

    .dynamic-table__count {
        flex: 0 0 100%;
        order: 2;
        font-size: 12px;
        line-height: 16px;
    }

    .dynamic-table__controls {
        order: 1;
        margin-left: auto;
        gap: 8px 14px;
    }

    .dynamic-table__sort {
        gap: 8px;
        font-size: 12px;
        line-height: 16px;
    }

    .dynamic-table__sort select {
        height: 32px;
        min-width: 112px;
        padding: 0 8px;
        font-size: 13px;
        line-height: 17px;
    }
}

/* Narrow enough that a 200px field beside a sort dropdown would push the
   row off its line: the search takes the width it has and the sort sits
   under it. */
@media (max-width: 640px) {
    .dynamic-table__controls {
        flex: 0 0 100%;
        justify-content: flex-start;
    }

    .dynamic-table__search {
        flex: 1 1 100%;
        width: auto;
    }
}

@media (max-width: 700px) {
    .dynamic-table--achievements {
        overflow: visible;
    }

    .dynamic-table--achievements .dynamic-table__title {
        font-size: 32px;
        line-height: 38px;
    }

    .dynamic-table--achievements .dynamic-table__wrap {
        overflow-x: visible;
        padding: 0;
    }

    .dynamic-table--achievements .dynamic-table__table,
    .dynamic-table--achievements .dynamic-table__table tbody,
    .dynamic-table--achievements .dynamic-table__table tr,
    .dynamic-table--achievements .dynamic-table__table td {
        display: block;
        width: 100% !important;
        min-width: 0;
    }

    .dynamic-table--achievements .dynamic-table__table {
        min-width: 0;
    }

    .dynamic-table--achievements .dynamic-table__table thead {
        display: none;
    }

    .dynamic-table--achievements .dynamic-table__table tbody tr {
        min-height: 0;
        border-bottom: 1px solid #DBDBDB;
    }

    .dynamic-table--achievements .dynamic-table__table tbody tr:hover {
        transform: none;
        box-shadow: none;
    }

    .dynamic-table--achievements .dynamic-table__table td {
        min-height: 0;
        padding: 14px 18px;
        font-size: 15px;
        line-height: 21px;
    }

    .dynamic-table--achievements .dynamic-table__table td + td {
        padding-top: 0;
    }

    .dynamic-table--achievements .dynamic-table__table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        color: #4B4B4B;
        font-size: 12px;
        line-height: 16px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0;
    }

}

@media (prefers-reduced-motion: reduce) {
    .dynamic-table,
    .dynamic-table__table tbody tr,
    .dynamic-table__table td,
    .dynamic-table__page-link {
        transition: none !important;
    }

    .dynamic-table__table tbody tr:hover {
        transform: none !important;
    }
}
