/* ===== FEED HEADER ===== */
.feed-header {
    margin: 10px;
    font-weight: 600;
    font-size: medium;
    display: flex;
    justify-content: space-between;
    contain: layout style;
}

/* ===== INTERACTIONS CONTAINER ===== */
.interactions-container {
    align-items: center;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}

/*
 * ===== GRID ITEMS =====
 * Design decision: keep a consistent two-column default on small screens for quick browse
 * scanning, with breakpoint-specific overrides later in this file for wider viewports.
 */
.grid-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    position: relative;
    margin: 0;
    min-height: 0;
}

/* ===== GRID ITEM ===== */
.grid-item {
    position: relative;
    contain: layout style;
    content-visibility: auto;
    contain-intrinsic-size: auto 175px 312px;
    aspect-ratio: 9 / 16;
    border-radius: 10px;
    overflow: hidden;
    animation: gridItemIn 0.4s ease-out both;
}

.grid-item:nth-child(even) {
    animation-delay: 60ms;
}

@keyframes gridItemIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== PAGINATION ===== */
.pagination {
    position: absolute;
    bottom: 68px;
    right: 24px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: var(--spacing-md, 12px);
}

.pagination button {
    display: flex;
    padding: 9px 16px 10px 16px;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--color-text, #000);
    color: var(--color-text, #000);
    font-size: var(--font-size-sm, 14px);
    font-style: normal;
    font-weight: 600;
    line-height: 150%;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 500ms ease;
    min-height: var(--touch-target, 44px);
    min-width: var(--touch-target, 44px);
}

.pagination button:hover {
    opacity: 1;
}

#end-div {
    height: 1px;
    width: 100%;
}

/* ===== GRID CONTAINER ===== */
.grid-container {
    margin-top: 4px;
    contain: layout style;
    min-height: 60vh;
}

/* ===== CONTENT TOOLBAR (search + filters) ===== */
.content-toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: var(--color-bg, #FFFFFF);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 10px 0 0;
}

.content-toolbar .search-bar {
    display: flex;
    height: 40px;
    width: 100%;
    margin-bottom: 4px;
}

.content-toolbar .search-bar input {
    border-radius: var(--radius-full, 90px) 0 0 var(--radius-full, 90px);
}

.content-toolbar .search-bar .search-icon {
    border-radius: 0 var(--radius-full, 90px) var(--radius-full, 90px) 0;
}

.content-toolbar .search-modal {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 10;
}

/* ===== HOME FILTER ===== */
.home-filter {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: flex-start;
    height: auto;
    min-height: auto;
    flex-wrap: nowrap;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 6px 0;
    -webkit-mask-image: linear-gradient(to right, transparent, black 2px, black calc(100% - 16px), transparent);
    mask-image: linear-gradient(to right, transparent, black 2px, black calc(100% - 16px), transparent);
}

.home-filter::-webkit-scrollbar {
    display: none;
}

.home-filter img, .home-filter i, .home-filter p {
    width: 20px;
    height: 20px;
    font-size: 20px;
}

.home-filter-item {
    font-size: var(--font-size-sm, 14px);
    font-style: normal;
    font-weight: 500;
    line-height: 150%;
    color: var(--color-text, #000000);
    display: flex;
    padding: 6px 12px 7px 12px;
    align-items: center;
    gap: var(--spacing-sm, 8px);
    cursor: pointer;
    white-space: nowrap;
    width: fit-content;
    flex: 0 0 auto;
    flex-direction: column;
    text-align: center;
    min-height: var(--touch-target, 44px);
    touch-action: manipulation;
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
}

.home-filter-item.vertical {
    flex-direction: column;
}

.home-filter-item.horizontal {
    flex-direction: row;
}

.home-filter-item.border {
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.10));
}

.home-filter-item.underline {
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.10));
    color: var(--color-text-muted, rgba(0, 0, 0, 0.60));
}

.home-filter-item.border.selected, .home-filter-item.border.selected i, .home-filter-item.border.selected p {
    background-color: var(--color-text, #000000);
    color: var(--color-bg, #FFFFFF);
}

.home-filter-item.border.selected img {
    filter: invert(1);
}

.home-filter-item.underline.selected {
    border-bottom: 1px solid rgba(0, 0, 0);
    color: rgba(0, 0, 0);
}

/* ===== LOADING MESSAGE ===== */
.loadingMessage {
    display: none;
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--color-text-muted, rgba(0, 0, 0, 0.5));
    font-size: var(--font-size-sm, 14px);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.loadingMessage::before {
    content: '';
    display: block;
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--color-border, rgba(0, 0, 0, 0.1));
    border-top-color: var(--primary-color, #333);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.dots::after {
    content: '';
    display: inline-block;
    animation: dots 1.2s steps(4, end) infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* ===== BANNER STYLES ===== */
.discover-banner {
    position: relative;
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    contain: layout style paint;
}

.banner-dismiss {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 1;
    padding: 0;
    min-width: var(--touch-target, 44px);
    min-height: var(--touch-target, 44px);
}

.banner-dismiss:hover {
    background: rgba(0, 0, 0, 0.4);
}

.banner-content {
    display: flex;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    gap: 1.25rem;
    flex-direction: column;
    align-items: flex-start;
}

.banner-text {
    flex: 1;
    color: white;
    padding-bottom: 1rem;
}

.banner-title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.375rem;
    color: white;
}

.banner-description {
    font-size: 0.8125rem;
    line-height: 1.5;
    opacity: 0.95;
    max-width: 100%;
    color: white;
}

.banner-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
    width: 100%;
    flex-direction: column;
    justify-content: flex-start;
}

.banner-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    white-space: nowrap;
    min-width: auto;
    width: 100%;
    text-align: center;
    min-height: var(--touch-target, 44px);
}

.banner-btn.primary {
    background-color: white;
    color: var(--primary-color, #333);
}

.banner-btn.primary span {
    color: inherit;
}

.banner-btn.primary:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.banner-btn.secondary {
    background-color: transparent;
    color: white;
    border: 2px solid white;
}

.banner-btn.secondary span {
    color: inherit;
}

.banner-btn.secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* ===== PREVIEW CANVAS ===== */
.preview-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    pointer-events: none;
    z-index: 1;
}

/* ===== SMALL SCREEN FIX ===== */
@media (max-width: 395px) {
    .grid-items {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== TABLET (min-width: 768px) ===== */
@media (min-width: 768px) {
    .feed-header {
        font-size: large;
    }

    .grid-items {
        grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
        gap: 14px 10px;
        min-height: auto;
    }

    .interactions-container {
        align-items: center;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .pagination {
        bottom: 12px;
    }

    .pagination button {
        opacity: 0.5;
    }

    .grid-container {
        margin-top: 16px;
    }

    .loadingMessage {
        left: 50%;
    }

    .discover-banner {
        border-radius: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .banner-content {
        padding: 1.5rem 2rem;
        gap: 2rem;
        flex-direction: row;
        align-items: center;
    }

    .banner-title {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }

    .banner-description {
        font-size: 0.875rem;
        max-width: 42.5rem;
    }

    .banner-actions {
        width: auto;
        flex-direction: row;
    }

    .banner-btn {
        min-width: 120px;
        width: auto;
    }

    .home-filter {
        padding: 4px 0 6px;
    }

    .content-toolbar {
        padding: 8px 0 0;
    }
}

/* ===== DESKTOP HOVER EFFECTS ===== */
@media (hover: hover) {
    .grid-item {
        transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
                    box-shadow 0.25s ease;
    }

    .grid-item:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        z-index: 2;
    }
}

/* ===== LARGE DESKTOP (min-width: 1560px) ===== */
@media (min-width: 1560px) {
    .grid-items {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ===== FOOTER ===== */
.site-footer {
    position: sticky;
    bottom: var(--mobile-nav-height);
    z-index: 1;
    background: var(--color-bg, #fff);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    font-size: 11px;
    color: rgba(0, 0, 0, 0.3);
    letter-spacing: 0.01em;
}

/* Desktop: no mobile nav, footer sits at scroll bottom */
@media (min-width: 1025px) {
    .site-footer {
        bottom: 0;
    }
}
