* {
    box-sizing: border-box;
}

:root {
    --text: #B7B7B7;
    --panel: url("data/ui/container-bg.png");
    --panel-dark: url("data/ui/container-bg-darker.png");
    --panel-brown: url("data/ui/container-bg-brown.png");
    --border: url("data/ui/border.png");
    --button: url("data/ui/button_brown.png");
    --buttonBlack: url("data/ui/button_black.png");
    --transparencyTiles: url("data/ui/transparency_tiles.png");
    --accent: #d8b56a;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 24px 12px 60px;

    color: var(--text);
    background: url("data/ui/page_bg_2.jpg") center / cover fixed no-repeat;
    background-color: #111;

    display: flex;
    flex-direction: column;
    align-items: center;

    font-family: 'Special Elite', cursive;
    text-shadow: 1px 1px 1px #000;
    font-style: normal;
}

body {
    -webkit-user-select: none;
    user-select: none;
}

img {
    user-drag: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.background-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 4s ease-in-out;
    pointer-events: none;
}

.background-layer.active {
    opacity: 1;
}

.logo-banner {
    display: block;
    width: 100%;
    max-width: 600px;
    height: auto;
    object-fit: contain;
    //margin-bottom: 16px;
}

.items-container {
    z-index: 9999;
    width: 100%;
    max-width: 1100px;
    padding: 8px;

    background-image: url("data/ui/container-bg.png");
    background-repeat: repeat;
    background-size: 64px 64px;

    box-shadow: 0 0 32px rgba(0, 0, 0, 0.75);
    border: 8px solid;
    border-image: var(--border) 32 repeat;
}

.heading-container {
    width: 100%;
    padding: 20px 12px;
    margin-bottom: 12px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;

    text-align: center;

    background-image: var(--panel-brown);
    background-repeat: repeat;
    background-size: 64px 64px;

    box-shadow: 0 0 24px rgba(0, 0, 0, 0.7);
    border: 8px solid;
    border-image: var(--border) 32 repeat;
}

h1 {
    margin: 32px;
    font-size: clamp(14px, 5vw, 16px);
    font-weight: normal;
    letter-spacing: 1px;
    text-align: center;
}

h2 {
    font-size: 20px;
    margin: 0 0 12px;
}

p {
    line-height: 1.6;
}

.heading-container p {
    max-width: 600px;
    margin: 0;
    font-size: 14px;
}

.items-toolbar {
    padding: 12px;
    margin-bottom: 12px;

    background-image: var(--panel-dark);
    background-size: 48px 48px;
    box-shadow: inset 0 0 8px #000;

    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-row {
    display: flex;
    width: 100%;
    gap: 8px;
}

#items-search {
    flex: 1;
    min-width: 0;
    padding: 12px;

    font-family: inherit;
    font-size: 14px;
    color: #ddd;
    text-shadow: inherit;

    background: rgba(0, 0, 0, 0.65);
    border: 2px solid #555;
    outline: none;
}

#items-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(216, 181, 106, 0.3);
}

#items-search::placeholder {
    color: #888;
}

.license-button {
    width: 100%;
    padding: 2px 8px;
    padding-top: 6px;
    font-family: inherit;
    color: inherit;

    border: 5px solid;
    border-image: url("data/ui/button_brown.png") 32 fill repeat;
    cursor: pointer;
    margin-bottom: 16px;
    box-shadow: 0 0 6px #000;
    display: block;
    text-align: center;
}

.license-button:hover {
    filter: brightness(1.3);
}

.download-license-button {
    padding: 0 14px;
    font-family: inherit;
    color: inherit;

    border: 5px solid;
    border-image: url("data/ui/button_brown.png") 32 fill repeat;
    cursor: pointer;
}

.download-license-button:hover {
    filter: brightness(1.3);
}

.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.tag-button {
    padding: 6px 12px !important;
    font-family: inherit;
    font-size: 12px;
    color: var(--text);

    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: 0.35s ease-in-out;
    text-align: center !important;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 1), 0 0 8px black;
}

.tag-button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tag-button.active {
    color: #f1d9a0;
    border-color: var(--accent);
    background: rgba(130, 95, 35, 0.25);
}


.items-container {
    width: 100%;
    max-width: 1250px;
    padding: 8px;

    background-image: url("data/ui/container-bg.png");
    background-repeat: repeat;
    background-size: 64px 64px;

    box-shadow: 0 0 32px rgba(0, 0, 0, 0.75);
    border: 8px solid;
    border-image: url("data/ui/border.png") 32 repeat;
}

.items-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 14px;
    align-items: start;
}

.items-main {
    min-width: 0;
}

.items-sidebar {
    position: sticky;
    top: 16px;
    min-width: 0;
    padding: 10px;

    background-image: url("data/ui/container-bg-darker.png");
    background-repeat: repeat;
    background-size: 48px 48px;

    box-shadow: inset 0 0 10px #000;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.sidebar-section {
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.sidebar-section h2 {
    margin: 0 0 12px;
    padding-bottom: 8px;
    font-size: 17px;
    border-bottom: 2px solid rgba(216, 181, 106, 0.35);
}

#items-search {
    width: 100%;
    min-width: 0;
    padding: 10px;

    font-family: inherit;
    font-size: 13px;
    color: #ddd;

    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #555;
    outline: none;
}

#items-search:focus {
    border-color: #d8b56a;
    box-shadow: 0 0 8px rgba(216, 181, 106, 0.3);
}

#items-search::placeholder {
    color: #888;
}

.clear-button {
    width: 100%;
    margin-top: 8px;
    margin-bottom: 16px;
    padding-top: 8px;
    padding-bottom: 4px;

    font-family: inherit;
    font-size: 11px;
    color: inherit;
    cursor: pointer;

    border: 5px solid;
    border-image: url("data/ui/button_brown.png") 32 fill repeat;
    box-shadow: 0 0 6px #000;
    text-shadow: 1px 1px 1px #000;
}

.clear-button:hover {
    filter: brightness(1.3);
}

.tag-filters {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.items-status {
    display: none;
}

@media (max-width: 760px) {
    .items-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .items-sidebar {
        position: static;
        grid-row: 1;
    }

    .tag-filters {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .tag-button {
        width: auto;
        text-align: center;
    }

    .item-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 460px) {
    .item-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.item-card {
    min-height: 256px;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;

    background-image: var(--panel-dark);
    background-size: 48px 48px;
    background-color: rgba(0, 0, 0, 0.4);

    border: 2px solid rgba(255, 255, 255, 0.13);
    box-shadow: inset 0 0 10px #000, 0 0 6px #000;
    animation: fadeBlurIn 0.35s ease-out forwards;
}

@keyframes fadeBlurIn {
    from {
        opacity: 0.5;
        filter: blur(6px);
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0);
    }
}

.item-image-link,
.item-preview {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background-image: var(--transparencyTiles);
    background-size: 48px 48px;

    box-shadow: 0 0 6px #000;
    border: 8px solid;
    border-image: url("data/ui/border.png") 32 repeat;

    box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.75), 0 0 6px rgba(0, 0, 0, 0.75);
}

.item-preview model-viewer {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
    --poster-color: transparent;
}

.model-fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #888;
    font-size: 12px;
    text-align: center;
}

.item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-title {
    margin: 2px 0 0;
    font-size: 14px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    text-align: center;
    padding-top: 2px;

    background-image: url("data/ui/container-bg.png");
    background-repeat: repeat;
    background-size: 64px 64px;

    box-shadow: 0 0 6px #000;
    border: 5px solid;
    border-image: url("data/ui/border.png") 32 repeat;
}

.item-description {
    text-align: center;
    margin: 0;
    font-size: 12px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    flex: 1;
    opacity: 0.65;
}

.item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.item-tag {
    padding: 3px 5px;
    font-size: 10px;
    line-height: 1.3;
    color: #c5b58f;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(216, 181, 106, 0.25);
}

.item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.item-footer button,
.item-footer a {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.item-button {
    display: inline-block;
    padding: 8px 8px;
    padding-top: 10px;

    text-align: center;
    text-decoration: none;
    color: inherit;
    font-family: inherit;
    font-size: 11px;

    border: 5px solid;
    border-image: var(--buttonBlack) 32 fill repeat;
    box-shadow: 0 0 6px #000;

    transition: filter 0.2s;
}

.item-button:hover {
    filter: brightness(1.3);
}

.download-button {
    display: inline-block;
    padding: 8px 8px;
    padding-top: 10px;

    text-align: center;
    text-decoration: none;
    color: inherit;
    font-family: inherit;
    font-size: 11px;

    border: 5px solid;
    border-image: var(--button) 32 fill repeat;
    box-shadow: 0 0 6px #000;

    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    text-shadow: 1px 1px 1px #000;

    transition: filter 0.2s;
}

.download-button:hover {
    filter: brightness(1.3);
}

.no-results {
    display: none;
    padding: 36px 12px;
    text-align: center;
    font-size: 14px;
    background-image: var(--panel-dark);
    background-size: 48px 48px;
    box-shadow: inset 0 0 8px #000;
}

.items-footer {
    margin-top: 14px;
    text-align: center;
    font-size: 12px;
    opacity: 0.7;
}

.items-footer a {
    color: inherit;
}

#rain-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
}

@media (max-width: 750px) {
    .item-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 460px) {
    body {
        padding: 12px 6px 30px;
    }

    .items-container {
        padding: 5px;
    }

    .item-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .item-card {
        padding: 10px;
    }

    .item-image-link,
    .item-preview {
        aspect-ratio: 16 / 9;
    }

    .item-title {
        font-size: 17px;
    }

    .item-description {
        font-size: 13px;
    }

    .item-tag {
        font-size: 11px;
    }

    .tag-button {
        padding: 8px 9px;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
    }
}


a {
    font-size: small;
    text-decoration: none;
}

.preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 32px black;

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.preview-overlay.active {
    opacity: 1;
    visibility: visible;
}

.preview-window {
    position: relative;

    width: 100%;
    max-width: 850px;
    padding: 20px;

    background-image: var(--panel);
    background-size: 64px 64px;

    border: 8px solid;
    border-image: var(--border) 32 repeat;

    box-shadow: 0 0 40px #000;

    transform: translateY(15px);
    transition: transform 0.25s ease;
}

.preview-overlay.active .preview-window {
    transform: translateY(0);
}

.preview-close {
    position: absolute;
    top: -5px;
    right: -6px;

    padding: 2px 8px;

    color: #ddd;
    background: transparent;
    border: none;

    font-family: inherit;
    font-size: 28px;
    cursor: pointer;
    text-shadow: 1px 1px 1px #000;
}

.preview-close:hover {
    color: red;
}


.preview-model-container {
    position: relative;
    width: 100%;
    height: min(60vh, 500px);
    min-height: 250px;
    overflow: hidden;

    background-image: var(--transparencyTiles);
    background-size: 48px 48px;

    border: 8px solid;
    border-image: var(--border) 32 repeat;
    
    box-shadow: 0 0 4px black, inset 0 0 16px black;
}

#preview-content model-viewer {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
    --poster-color: transparent;
}

.preview-texture {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;

    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.preview-skybox {
    width: 100%;
    height: 100%;
    background: #111;
}

#preview-download {
    position: absolute;
    bottom: -64px;
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    white-space: nowrap;
    padding-top: 12px;
    text-shadow: 1px 1px 1px #000;
}

#preview-download:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(1);
}

@media (max-width: 600px) {
    .preview-model-container {
        height: 50vh;
        min-height: 250px;
    }
}

#preview-title {
    text-shadow: 0 0 16px black;
    text-align: center !important;

}

.download-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: download-spin 0.7s linear infinite;
}

@keyframes download-spin {
    to {
        transform: rotate(360deg);
    }
}

#preview-download:not(.loading) .download-spinner {
    display: none;
}

body.preview-open {
    overflow: hidden;
}

@media (max-width: 600px) {
    .preview-window {
        padding: 12px;
    }

    .preview-model-container {
        height: 50vh;
        min-height: 250px;
    }
}

#preview-download:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(1);

}

.custom-container {
  display: flex;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;

  background-image: var(--panel-dark);
  background-size: 48px 48px;
  box-shadow: inset 0 0 8px #000;

  border: 3px solid;
  border-image: var(--border) 32 repeat;
  box-shadow: 0 0 6px #000;
  padding: 4px 4px 6px;
  gap: 6px;
  margin-bottom: 12px;
}

.custom-container > a {
  flex: 1 1 0;
  min-width: 0;
}

.custom-button {
  transition: .2s ease-in-out;
  flex: 1;
  display: flex;
  justify-content: center;
  margin-bottom: -2px;
  padding-top: 5px;
  padding-bottom: -10px;
  border: 5px solid;
  border-image: var(--button) 32 fill repeat;
  transition: filter 0.2s;
  box-shadow: 0 0 6px #000;
  font-size: clamp(7px, 1.5vw, 16px);
  color: var(--text) !important;
}

.custom-button:hover {
  filter: brightness(1.3);
}

.new-tag-badge {
    display: inline-block;
    margin-left: 6px;
    margin-bottom: 2px;
    padding-left: 4px;
    padding-right: 4px;
    padding-top: 2px;

    font-size: 10px;
    line-height: 1;

    color: #fff;
    background: #a83d35;
    border-radius: 2px;

    vertical-align: middle;
    letter-spacing: 1px;
    box-shadow: 0 0 4px #000;
    text-shadow: 1px 1px 1px #000;
}

.preview-model-container {
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

#preview-content {
    position: absolute;
    inset: 0;
    z-index: 1;
}

#preview-content model-viewer,
#preview-content .preview-texture,
#preview-content .preview-skybox {
    display: block;
    width: 100%;
    height: 100%;
}

.preview-shadow-overlay {
    position: absolute;
    inset: 0;
    z-index: 2147483647;
    pointer-events: none;

    box-shadow: inset 0 0 8px rgba(0, 0, 0, 1);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 25px 0;
}

.pagination button {
    padding: 6px 12px !important;
    font-family: inherit;
    font-size: 12px;
    color: var(--text);

    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: 0.35s ease-in-out;
    text-align: center !important;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 1), 0 0 8px black;
}

.pagination button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
}

.pagination button.active {
    color: #f1d9a0;
    border-color: var(--accent);
    background: rgba(130, 95, 35, 0.25);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination .pagination-ellipsis {
    color: var(--text);
    padding: 6px 4px;
}

.item-card-empty {
    visibility: visible;
    pointer-events: none;
}

.page-layout {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.link-sidebar {
    display: flex;

    padding: 8px;
    padding-bottom: 0px;
    margin-bottom: 16px;
}

.link-sidebar .sidebar-section {
    display: flex;
    gap: 10px;
}

.link-buttons {
    display: flex;
    gap: 8px;
}

.link-buttons .tag-button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
    min-width: 128px;
}