html, body {
    padding: 0;
    margin: 0;
}

html {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1 {
    text-transform: uppercase;
    margin: 5px 0;
    font-size: larger;
    background: #eee;
    padding: 8px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
}

h2 {
    font-size: larger;
    background: #eee;
    padding: 4px 8px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
}

h3 {
    font-size: large;
    margin: 10px;
}

.header-link {
    font-size: small;
    text-transform: none;
    vertical-align: middle;
}

input[type="radio"] {
    margin-top: -1px;
    vertical-align: middle;
}

.header {
    position: sticky;
    top: 0;
    background: #0000aa;
    padding: 10px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    z-index: 10;
    color: white;
    display: flex;
    gap: 10px;
    overflow: hidden;
    text-shadow: -1px -1px 2px black;
    max-width: 100%;
}

.header a {
    color: white;
    white-space: nowrap;
}

.header-nav {
    display: flex;
    flex: 1;
    justify-content: space-between;
    gap: 10px;
}

.header-shortcuts {
    display: flex;
    gap: 10px;
}

.header-breadcrumbs {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 7ch;
    flex: 1;
}

.title a {
    text-decoration: none;
    color: white;
}

.content {
    padding: 10px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.artfile-card {
    background: black;
    padding: 5px;
    margin: 10px auto;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    height: fit-content;
    width: 170px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    align-items: stretch;
}

.artfile-card-wide {
    width: 360px;
}

.artfile-card-mimetype {
    font-size: larger;
    color: white;
    word-break: break-all;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80px;
}

.artfile-card-pack {
    text-align: center;
    font-size: x-small;
    word-wrap: break-word;
    color: black;
    background: #aaa;
    padding: 2px;
}

.artfile-card-title {
    text-align: center;
    font-size: x-small;
    word-wrap: break-word;
    color: black;
    background: #ccc;
    padding: 2px;
}

.artfile-card a {
    text-decoration: none;
}

.artfile-card img {
    margin-bottom: 5px;
    object-fit: cover;
}

.pack-grid {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 40px;
    justify-content: flex-start;
}

.pack-title {
    text-align: center;
    font-size: x-small;
    word-wrap: break-word;
    color: black;
    background: #ccc;
    text-decoration: none;
    padding: 5px;
}

.pack-card {
    background: black;
    padding: 5px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    line-break: anywhere;
}

.pack-card a {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 5px;
    width: 180px;
    text-decoration: none;
}

.pack-card img {
    height: 180px;
    object-fit: contain;
    flex-grow: 1;
}

.collection-card {
    background: black;
    padding: 5px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    line-break: anywhere;
}

.collection-grid {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 40px;
    justify-content: flex-start;
}

.collection-card-title {
    text-align: center;
    font-size: x-small;
    word-wrap: break-word;
    color: black;
    background: #ccc;
    text-decoration: none;
    padding: 5px;
}

.collection-card-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    height: 100%;
}

.collection-card a {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 5px;
    width: 180px;
    text-decoration: none;
}

.collection-card img {
    height: 90px;
    width: 90px;
    object-fit: cover;
    flex-grow: 1;

}

.tag-list {
    column-width: 150px;
    column-gap: 20px;
    list-style: none;
    padding: 0 40px;
    font-size: small;
    font-style: italic;
}

.tag-list li {
    padding: 4px;
    break-inside: avoid;
}

.tag-search-results {
    list-style: none;
    padding: 0 40px;
    font-size: small;
    margin: 0;
}

.tag-search-results li {
    padding: 4px;
    break-inside: avoid;
}

.sidebar {
    display: flex;
    flex-direction: column;
    background-color: #eee;
    padding-top: 0;
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 10px;
    box-shadow: 2px 0 2px rgba(0, 0, 0, 0.2);
    font-size: small;
    width: 200px;
    min-width: 200px;
}

.sidebar h2 {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #bbb;
    padding-bottom: 10px;
    align-items: flex-end;
    font-size: medium;
    background-color: #eee;
    box-shadow: none;
}

.sidebar ul {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 10px;
    list-style: none;
    padding: 10px;
    margin: 0;
}

.sidebar li {
    padding: 0;
}

.sidebar h3 {
    font-weight: bold;
    border-bottom: 1px solid #bbb;
    padding-bottom: 5px;
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: 0;
    margin-right: 0;
}

.sidebar dl {
    margin: 0;
}

.sidebar dt {
    margin-bottom: 5px;
    font-weight: bold;
}

.sidebar dd {
    margin-bottom: 5px;
    margin-left: 10px;
}

.sidebar img {
    width: 160px;
    background: black;
    padding: 8px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    align-self: center;
}

.sidebar a {
    word-break: break-all;
}

.sidebar select {
    width: 100%;
}

.sidebar label {
    word-break: break-all;
    font-style: italic;
}

.sidebar-choice-field {
    column-width: 150px;
    column-gap: 5px;
}

.sidebar-choice-field div {
    padding-top: 2px;
    padding-bottom: 2px;
}

.sidebar-clear-link {
    font-weight: normal;
    font-size: small;
    text-decoration: none;
    margin-left: 2px;
    color: darkblue;
}

.sidebar-list {
    font-style: italic;
}

.sidebar-empty-choice {
    margin: 10px;
}

.sidebar-preview {
    max-width: 100%;
    height: auto;
}

.pack-filter-form {
    display: flex;
    flex-direction: column;
}

.filter-results {
    padding: 10px;
}

.filter-results-table {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 1ch;
}

.filter-results-table > *:nth-child(odd) {
    text-align: right;
}

.filter-results-table > *:nth-child(even) {
    font-style: italic;
}

.filter-fieldsets {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

legend {
    font-weight: bold;
}

fieldset {
    border: 1px solid black;
}

.artfile-body {
    display: flex;
    flex-direction: row-reverse;
    flex: 1;
    margin: -10px;
    word-break: break-word;
}

.artfile-content-wrapper {
    margin: 20px;
    flex: 1;
}

.artfile-content-wrapper h1 {
    text-align: center;
}

.artfile-content {
    flex: 1;
    margin: 20px;
    display: flex;
    justify-content: flex-start;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.artfile-image-container {
    display: flex;
    background: black;
    color: white;
    padding: 8px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
}

.artfile-image-container a {
    display: contents;
}

.artfile-image-container img {
    height: auto;
    max-width: 100%;
}

.artfile-audio-container {
    margin-top: 10px;
}

.artfile-video-container {
    margin: 10px auto;
}

.artfile-video-container video {
    max-width: 100%;
    max-height: 400px;
}

.artfile-image-title {
    font-style: italic;
}

.hidden {
    visibility: hidden;
}

.searchbar {
    display: flex;
    gap: 5px;
    align-items: stretch;
    margin: 20px 40px;
}

.searchbar input {
    font-size: medium;
}

.searchbar input[type='text'] {
    border: 1px solid #aaa;
    border-radius: 4px;
    padding: 4px;
    box-sizing: border-box;
}

.searchbar select {
    border: 1px solid #aaa;
    border-radius: 4px;
    padding: 4px;
    box-sizing: border-box;
    font-size: medium;
}

.pagination {
    background: #eee;
    font-weight: bold;
    padding: 5px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    font-size: small;
    width: 100%;
}

.pagination-load-more {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.pagination-step-links {
    display: flex;
    justify-content: space-around;
    padding: 0 20px;
    flex: 1;
    width: min(400px, 100%);
    gap: 10px;
    white-space: nowrap;
}

.artfile-grid {
    overflow: hidden;
    min-width: 360px;
    min-height: 20px;
    /* Hide until initialized by masonry.js */
    visibility: hidden;
}

.artfile-grid-wrapper {
    margin: 0 20px;
}

.advanced-search {
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
    margin: 10px;
    font-size: small;
    background-color: #f9f9f9;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
}

.advanced-search select {
    width: 100%;
    height: 32px;
    min-height: 32px;
    border: 1px solid #aaa;
    border-radius: 4px;
}

.advanced-search .select2-selection {
    min-height: 32px;
}

.advanced-search-wrapper {
    display: flex;
    justify-content: center;
}

.advanced-search-results-total {
    font-style: italic;
    margin: 10px;
    text-align: center;
}

.advanced-search-wrapper summary {
    font-style: italic;
}

.advanced-search-options {
    column-count: 2;
    column-gap: 10px;
}

.advanced-search-options fieldset {
    break-inside: avoid;
    margin-bottom: 10px;
}

.advanced-search-section {
    display: grid;
    grid-template-columns: minmax(90px, auto) 1fr;
    align-items: center;
    gap: 5px;
}

.advanced-search-input-group {
    display: flex;
    gap: 5px;
}

.advanced-search-input {
    width: 100%;
    border: 1px solid #aaa;
    border-radius: 4px;
    padding: 5px;
    min-height: 32px;
    box-sizing: border-box;
}

.select2-container {
    font-size: small;
    min-width: 5em !important;
    width: 100% !important;
}

.select2-search__field {
    width: 100% !important;
}

.select2-selection__choice {
    white-space: normal;
}

.advanced-search-section label {
    text-align: right;
}

.advanced-search-submit input {
    width: 100%;
}

.view-all-link {
    text-align: center;
    font-size: small;
    margin: 10px;
}

.collection-description {
    text-align: center;
    margin: 20px;
    font-style: italic;
    white-space: pre-line;
}

.index-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 40px;
}

.index-grid-wide {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .tag-list {
        padding: 0 10px;
        column-width: 100px;
        column-gap: 10px;
    }

    .content {
        padding: 5px;
        margin-bottom: 20px;
    }

    .advanced-search-wrapper {
        width: initial;
        margin: 0;
    }

    .collection-description {
        text-align: center;
        margin: 10px 0;
        font-style: italic;
    }

    .advanced-search {
        margin: 10px 0;
    }

    .advanced-search-options {
        column-count: 1;
        column-gap: 10px;
    }

    .pack-grid {
        padding: 10px;
    }

    .pack-card a {
        width: 140px;
    }

    .pack-card img {
        height: 140px;
    }

    .collection-grid {
        padding: 10px;
    }

    .collection-card a {
        width: 140px;
    }

    .collection-card img {
        height: 70px;
        width: 70px;
    }

    .sidebar {
        width: auto;
        box-shadow: 2px 0 2px rgba(0, 0, 0, 0.2);
    }

    .artfile-body {
        flex-direction: column;
        align-items: normal;
    }

    .artfile-grid {
        margin: 0 auto;
    }

    .artfile-grid-wrapper {
        margin: 0;
    }

    .searchbar {
        margin: 10px;
    }

    .index-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0 10px;
    }

    .index-grid-wide {
        grid-column: span 1;
    }
}
