/* === BRAND FLOAT CARD === */

.brand-float {
    position: fixed;
    z-index: 160;
    pointer-events: auto;
    opacity: 0;
    transform: perspective(600px) scale(0.92) translateY(8px) rotateX(-8deg);
    transform-origin: top center;
    transition: opacity 0.2s var(--ease-expo),
                transform 0.2s var(--ease-expo);
    background:
        /* Covers: scroll with content, hide fades at edges */
        linear-gradient(var(--surface) 30%, transparent) top / 100% 80px no-repeat local,
        linear-gradient(transparent, var(--surface) 70%) bottom / 100% 80px no-repeat local,
        /* Fades: stay fixed, revealed as content scrolls away from edge */
        linear-gradient(to bottom, var(--surface), transparent) top / 100% 48px no-repeat scroll,
        linear-gradient(to top, var(--surface), transparent) bottom / 100% 48px no-repeat scroll,
        var(--surface);
    border: 2px solid var(--text-3);
    padding: 20px;
    min-width: 200px;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    overscroll-behavior: contain;
}

.brand-float.visible {
    opacity: 1;
    transform: perspective(600px) scale(1) translateY(0) rotateX(0);
}

.brand-float.exiting {
    opacity: 0;
    transform: perspective(600px) scale(0.96) translateY(4px) rotateX(-5deg);
    transition-duration: 0.12s;
    pointer-events: none;
}

.brand-float-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.brand-float-title-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--text-3);
}

.brand-float-title-link:hover {
    text-decoration-color: currentColor;
}

.brand-float-count {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 400;
    line-height: 1.3;
    color: var(--text-3);
    letter-spacing: 0.5px;
}

.brand-float-grid {
    display: grid;
    gap: 10px;
    /* columns set dynamically by JS */
}

.brand-float-tile {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--line);
    overflow: hidden;
    transition: border-color 0.2s var(--ease-quart);
}

.brand-float-tile:hover {
    border-color: var(--text-3);
}

.brand-float-tile-thumb {
    width: 100%;
    aspect-ratio: 16 / 10;
    background: var(--bg);
    overflow: hidden;
}

.brand-float-tile-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* opacity: 0.7; */
    /* filter: grayscale(100%) brightness(2); */
    transition: opacity 0.2s var(--ease-quart), filter 0.2s var(--ease-quart);
}

.brand-float-tile:hover .brand-float-tile-thumb img {
    /* opacity: 1; */
    /* filter: grayscale(0%) brightness(1); */
}

.brand-float-tile-placeholder {
    width: 100%;
    aspect-ratio: 16 / 10;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1.3;
    color: var(--text-3);
    letter-spacing: 1.5px;
}

.brand-float-tile-name {
    padding: 10px;
    padding-bottom: 0;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.brand-float-tile-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.brand-float-tile-name .arrow {
    font-size: 14px;
    color: var(--text-3);
    flex-shrink: 0;
    transition: transform 0.3s var(--ease-expo);
}

.brand-float-tile:hover .brand-float-tile-name .arrow {
    transform: translate(2px, -2px);
}

.brand-float-tile-brands {
    padding: 4px 10px 0;
    font-size: 10px;
    font-family: var(--mono);
    line-height: 1.3;
    color: var(--text-3);
    opacity: 0.6;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-float-tile-info {
    padding: 2px 10px 0;
    font-size: 10px;
    font-family: var(--mono);
    line-height: 1.3;
    color: var(--text-3);
    letter-spacing: 0.5px;
}

.brand-float-tile-info:last-child {
    padding-bottom: 10px;
}

.brand-float-tile-info2 {
    padding: 2px 10px 10px;
    font-size: 10px;
    font-family: var(--mono);
    line-height: 1.3;
    color: var(--text-3);
    opacity: 0.75;
    letter-spacing: 0.5px;
}

/* --- Close button for touch devices --- */

.brand-float-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-3);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1.3;
    font-family: var(--mono);
    z-index: 2;
    transition: border-color 0.2s var(--ease-quart), color 0.2s var(--ease-quart);
}

.brand-float-close:hover {
    border-color: var(--text-2);
    color: var(--text-1);
}

.brand-float-close:focus-visible {
    border-color: var(--text-1);
    color: var(--text-1);
    outline: 1px dashed var(--text-1);
    outline-offset: 2px;
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .brand-float-tile-thumb {
        aspect-ratio: 16 / 9;
    }

    .brand-float-tile-name {
        font-size: 13px;
        padding: 8px;
        padding-bottom: 0;
    }

    .brand-float-tile-info {
        padding: 2px 8px 8px;
        font-size: 10px;
    }
}

/* Touch device bottom sheet layout */
@media (hover: none) {
    .brand-float {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 60vh !important;
        padding: 20px;
        padding-top: 48px;
        transform: translateY(100%);
        transform-origin: bottom center;
        border: none;
        border-top: 2px solid var(--text-3);
    }

    .brand-float.visible {
        transform: translateY(0);
    }

    .brand-float.exiting {
        transform: translateY(100%);
    }

    .brand-float-close {
        display: flex;
    }
}
