/* Main Content */
.main-content {
    margin-top: 0;
    padding: 10px 5px;
    width: 100%;
}

/* Main page keeps the tall mobile header with the description; other pages use the compact one (base.css) */
@media (max-width: 480px) {
    :root {
        --header-height: 140px;
    }

    .header-info {
        display: block;
    }

    .mobile-menu-description {
        display: none;
    }
}

/* Footer links — only shown at the 1-column breakpoint; grid layouts use the credit cell instead */
.collection-mobile-footer {
    display: none;
}

@media (max-width: 480px) {
    .collection-mobile-footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px 20px;
        padding: 20px;
        background: #000;
        color: #fff;
    }

    .collection-mobile-footer .header-link {
        font-size: 14px;
        color: #fff;
    }

    /* Inverted strip across the full width of the footer: black on white */
    .collection-footer-curated {
        grid-column: 1 / -1;
        margin: 4px -20px -20px;
        padding: 14px 20px;
        background: #fff;
    }

    /* retry.studio on the left, logo on the right */
    .collection-footer-curated .header-link {
        font-size: 14px;
        color: #000;
        width: 100%;
        justify-content: space-between;
    }

    .collection-footer-curated .header-link svg path {
        fill: #000;
    }

    .collection-mobile-footer .header-link svg,
    .collection-footer-curated .header-link svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }
}

/* Tape Grid */
.tape-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 0;
    width: 100%;
}

.grid-item {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: visible;
}

/* Safari fallback for aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
    .grid-item {
        height: 0;
        padding-bottom: 100%;
    }
}

.grid-item-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

/* Divider lines using pseudo-elements */
.grid-item::before,
.grid-item::after {
    content: '';
    position: absolute;
    background-color: #ffffff70;
    z-index: 100;
    pointer-events: none;
}

/* Vertical line (right border) */
.grid-item::before {
    right: 0;
    top: 15px;
    bottom: 15px;
    width: 1px;
}

/* Horizontal line (bottom border) */
.grid-item::after {
    bottom: 0;
    left: 15px;
    right: 15px;
    height: 1px;
}

/* Column-specific divider rules */
.tape-grid[data-cols="4"] .grid-item:nth-child(4n)::before {
    display: none;
}
.tape-grid[data-cols="4"] .grid-item:nth-last-child(-n+4)::after {
    display: none;
}

.tape-grid[data-cols="3"] .grid-item:nth-child(3n)::before {
    display: none;
}
.tape-grid[data-cols="3"] .grid-item:nth-last-child(-n+3)::after {
    display: none;
}

.tape-grid[data-cols="2"] .grid-item:nth-child(2n)::before {
    display: none;
}
.tape-grid[data-cols="2"] .grid-item:nth-last-child(-n+2)::after {
    display: none;
}

.tape-grid[data-cols="1"] .grid-item::before {
    display: none;
}
.tape-grid[data-cols="1"] .grid-item:last-child::after {
    display: none;
}

/* Grid item image/video transforms */
.grid-item-inner img,
.grid-item-inner video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    rotate: 0deg;
    scale: 1.1;
    transition: scale 0.3s ease;
}

.grid-item:hover .grid-item-inner img,
.grid-item:hover .grid-item-inner video {
    scale: 1.3;
    z-index: 10;
    position: relative;
}

/* Grid item info overlay */
.grid-item-info {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    padding: 30px;
    z-index: 11;
    pointer-events: none;
}

.grid-item:hover .grid-item-info,
.grid-item.touch .grid-item-info {
    display: block;
}

.grid-item-id, .grid-item-title, .grid-item-location {
    position: absolute;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.grid-item-id {
    top: 10px;
    left: 15px;
}

.grid-item-title {
    bottom: 10px;
    left: 15px;
}

.grid-item-location {
    bottom: 10px;
    right: 15px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .tape-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .tape-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
    }
}

@media (max-width: 480px) {
    .tape-grid {
        grid-template-columns: 1fr;
    }
    
    .grid-item-inner {
        padding: 20px;
    }
    
    .grid-item-inner img,
    .grid-item-inner video {
        rotate: -90deg;
        scale: 1.0;
    }

    .grid-item:hover .grid-item-inner img,
    .grid-item:hover .grid-item-inner video {
        scale: 1.0;
    }
    
    .tape-grid[data-cols="1"] .grid-item-info {
        display: block !important;
    }
}

/* Feed banners as grid cells (2+ columns) — one tape cell each, inserted by updateGrid().
   Type scales with the cell width, which ranges from about 235px to 430px across breakpoints. */
.grid-item-banner {
    container-type: inline-size;
}

.grid-item-banner .feed-banner {
    position: absolute;
    inset: 0;
    min-height: 0;
    padding: 12px 15px 15px;
}

.grid-item-banner .feed-banner-title {
    font-size: clamp(20px, 8.5cqw, 30px);
    line-height: 1.15;
}

.grid-item-banner .feed-banner-caption {
    font-size: clamp(13px, 5cqw, 16px);
}

/* Submit cell: the plus link is stretched over the whole cell, so the block is one click target
   and every element reacts to hover together */
.grid-item-banner .feed-banner-plus {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
    z-index: 1;
}

.grid-item-banner .feed-banner-plus svg {
    display: block;
    width: 22cqw;
    height: 22cqw;
}

/* Donation cell: same idea, with the button's link stretched over the whole cell */
.grid-item-banner .feed-banner-donate .feed-banner-button::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

.grid-item-banner .feed-banner-submit:hover .feed-banner-title,
.grid-item-banner .feed-banner-submit:hover .feed-banner-caption,
.grid-item-banner .feed-banner-donate:hover .feed-banner-title,
.grid-item-banner .feed-banner-donate:hover .feed-banner-caption {
    color: #999;
}

.grid-item-banner .feed-banner-submit:hover .feed-banner-plus svg {
    opacity: 0.5;
}

.grid-item-banner .feed-banner-submit:hover .feed-banner-button,
.grid-item-banner .feed-banner-donate:hover .feed-banner-button {
    background-color: #999;
}

/* The submit caption's forced break is tuned for phone widths; in a cell it breaks before "part of the archive" instead */
.grid-item-banner .feed-banner-submit .feed-banner-caption br {
    display: none;
}

/* Donation caption on three fixed lines — only where the cell is wide enough for each line to fit */
@container (min-width: 260px) {
    .grid-item-banner .feed-banner-cell-break {
        display: inline;
    }
}

@container (max-width: 340px) {
    .grid-item-banner .feed-banner-links {
        grid-template-columns: 1fr;
    }
}

/* Credit cell — the very last grid cell: retry logo top-left, retry.studio bottom-left */
/* Text and insets match the tape labels (.grid-item-id / .grid-item-title: 16px, 10px from the cell edge) */
.grid-item-banner .feed-banner-credit {
    padding: 10px 15px;
    font-size: 16px;
    letter-spacing: -0.5px;
    color: #fff;
}

.grid-item-banner .feed-banner-credit svg {
    width: auto;
    height: clamp(22px, 8.5cqw, 30px);
    align-self: flex-start;
}

.grid-item-banner .feed-banner-credit:hover {
    opacity: 0.5;
}

/* The server-rendered submit cell belongs to grid layouts only; keep it out of the 1-column feed
   until updateGrid() removes it */
@media (max-width: 480px) {
    .tape-grid > .grid-item-banner {
        display: none;
    }
}
