.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    gap: var(--spacing-md);
}

body.mobile .topbar {
    justify-content: center;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

/* Hidden topbar background gradient for details page */
body:not(.mobile).hide-topbar .topbar::before {
    z-index: -1;
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: calc(var(--topbar-height) * 2);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.0) 100%);
    pointer-events: none;
    transition: background var(--transition-slow) ease;
}

body:not(.mobile) .topbar::before {
    background: none;
}

.topbar-bg {
    position: absolute;
    inset: 0;
    background-color: var(--color-topbar);
    z-index: -1; /* Ensure the background is behind the content */
    opacity: 1;
    transition: opacity var(--transition-slow) ease;
}

body:not(.mobile).hide-topbar .topbar-bg {
    opacity: 0;
}

.topbar-bg::after {
    /* 1px horizontal line at the bottom of the topbar */
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    width: 100%;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.05)
}

.topbar-upper { /* Only on mobile */
    height: 100%;
    display: flex;
    align-items: center;
}

.topbar svg {
    width: 24px;
    height: 24px;
}

.topbar a {
    display: flex;
    align-items: center;
}

.topbar-logo {
    height: 24px;
    flex-shrink: 0;
}

body:not(.mobile) .topbar-logo {
    margin-right: var(--spacing-md);
}

.topbar-logo svg {
    height: 100%;
    width: auto;
    color: var(--color-button-light);
    transition: color var(--transition-medium) ease, filter var(--transition-medium) ease;
}

.topbar-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    list-style: none;
    padding: 0;
    margin: 0;
}

body.mobile .topbar-links {
    width: 100%;
    gap: 0;
    justify-content: space-evenly;
}

.topbar-link {
    box-sizing: border-box;  /* Ensure padding and border are included in the width */
    width: var(--button-size);
    height: var(--button-size);
    padding: 0 calc((var(--button-size) - 24px) / 2);
    gap: var(--spacing-sm);
    display: flex;
    flex-direction: row;
    text-decoration: none;
    overflow: hidden;
    color: var(--color-text-secondary-light);
    background-color: transparent;
    border-radius: var(--radius-md);
    /* mix-blend-mode: overlay; */
    transition: color var(--transition-medium) ease, background-color var(--transition-medium) ease, width var(--transition-slow) ease-in-out;
}

.topbar-link svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

body.mobile .topbar-link {
    width: 100%;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
}

.topbar-link:hover {
    color: var(--color-text-primary-light);
    background-color: var(--color-button-light-hover);
}

body:not(.mobile) .topbar-link:hover {
    width: calc(var(--link-expanded-width) + calc((var(--button-size) - 24px) / 2)); /* Width + padding */
}

.topbar-link:active {
    background-color: var(--color-button-light-active);
}

.topbar-link.active {
    color: var(--color-text-primary-dark);
    /* width: calc(var(--link-expanded-width) + calc((var(--button-size) - 24px) / 2)); */
    background-color: var(--color-button-light-focus);
}

.topbar-link.active:active {
    background-color: var(--color-button-light-focus-active);
}

/* Collapse the active link when another link is hovered
.topbar-links:has(.topbar-link:hover) .topbar-link.active {
    width: var(--button-size);
}
.topbar-links:has(.topbar-link.active:hover) .topbar-link.active {
    width: calc(var(--link-expanded-width) + calc((var(--button-size) - 24px) / 2));
}
*/

.topbar-search-form {
    /* Remove default form styles */
    all: unset;
}

.topbar-search-form {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background-color: var(--color-button-dark-active);
    backdrop-filter: var(--glass-blur) var(--glass-saturate);
    -webkit-backdrop-filter: var(--glass-blur) var(--glass-saturate);
    border: 1px solid var(--color-button-light-active);
    border-radius: 9999px;
    height: var(--button-size);
    padding: 0 var(--spacing-md);
    transition: border-color var(--transition-medium) ease, background-color var(--transition-medium) ease;
}

.topbar-search-form:focus-within {
    border-color: var(--color-accent);
    background-color: var(--color-button-dark-focus);
}

body.mobile .topbar-search-form {
    width: 100vw;
    height: 100%;
    border-radius: 0;
}

.topbar-search-form input {
    /* Remove default input styles */
    all: unset;
    outline: none !important;
}

.topbar-search-form input:focus {
    outline: none !important;
}

body.mobile .topbar-search-input {
    width: 100%;
    height: 100%;
    padding: 0 var(--spacing-md);
}

.topbar-search-button {
    all: unset; /* Reset styles */
    cursor: pointer;
    display: flex;
    align-items: center;
    background: none;
    outline: none;
}

.topbar-search-button::after {
    all: unset; /* Reset styles */
}

.topbar-search-button:hover {
    background: none;
    outline: none;
}
.topbar-search-button:active {
    background: none;
}

.topbar-search-button svg {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary-light);
    transition: color var(--transition-medium) ease;
}

.topbar-search-button:hover svg {
    color: var(--color-text-primary-light);
}

.topbar-account-button {
    all: unset; /* Reset styles */
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary-light);
    cursor: pointer;
    transition: color var(--transition-medium) ease;
}

.topbar-account-button:hover {
    color: var(--color-text-primary-light);
    background: none;
    outline: none;
}

.topbar-account-button:active {
    background: none;
    outline: none;
    color: var(--color-button-focus-active);
}