/* ---------- "Open in app" popup (behavior wired up by app-banner.js) ---------- */
/* Kept in the DOM at all times via [hidden]; JS removes [hidden] then toggles .is-open
   a frame later so the opacity/transform transitions actually get to play (removing
   [hidden] and adding a transitioning class in the same tick wouldn't animate). */
.app-popup[hidden] {
    display: none;
}

.app-popup {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
}

.app-popup.is-open {
    opacity: 1;
    pointer-events: auto;
}

.app-popup-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(12, 12, 12, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.app-popup-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 380px;
    margin: 16px;
    padding: 32px 24px 24px 24px;
    background-color: var(--surface-page);
    border-radius: 32px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(12px) scale(0.96);
    transition: transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.app-popup.is-open .app-popup-card {
    transform: none;
}

/* Mobile: bottom sheet */
.app-popup-sheet {
    align-items: flex-end;
}

.app-popup-sheet .app-popup-card {
    max-width: 480px;
    margin: 0;
    padding: 12px 24px calc(24px + env(safe-area-inset-bottom)) 24px;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
    transition: transform 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app-popup-handle {
    width: 40px;
    height: 4px;
    border-radius: 9999px;
    background-color: var(--border-primary);
    margin-bottom: 20px;
}

.app-banner-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: var(--surface-page-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 150ms ease;
}

.app-banner-close:hover {
    background-color: var(--border-primary);
}

.app-banner-close svg {
    width: 20px;
    height: 20px;
    display: block;
}

.app-banner-logo {
    display: block;
    height: 32px;
    width: auto;
    margin-bottom: 20px;
}

.app-banner-text {
    min-width: 0;
    max-width: 300px;
}

.app-banner-title {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.app-banner-subtitle {
    color: var(--text-secondary);
}

.app-banner-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 24px;
}

.app-banner-cta {
    display: block;
    box-sizing: border-box;
    width: 100%;
    text-align: center;
    text-decoration: none;
    background-color: var(--surface-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: 60px;
    padding: 14px 24px;
    cursor: pointer;
    transition: background-color 150ms ease, transform 150ms ease;
}

.app-banner-cta:active {
    transform: scale(0.98);
    background-color: var(--surface-primary-hover);
}

.app-banner-secondary {
    width: 100%;
    background: none;
    border: none;
    border-radius: 60px;
    padding: 12px 24px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Desktop: QR code */
.app-banner-qr-frame {
    margin-top: 24px;
    padding: 16px;
    border-radius: 24px;
    background-color: var(--surface-studio-mist);
    border: 1px solid var(--border-brand-subtle);
}

.app-banner-qr {
    display: block;
    width: 168px;
    height: 168px;
    padding: 10px;
    border-radius: 12px;
    background-color: var(--surface-page);
}

.app-banner-stores {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 20px;
}

.app-banner-store {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-primary);
    border-radius: 60px;
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 150ms ease, color 150ms ease;
}

.app-banner-store:hover {
    border-color: var(--border-brand);
    color: var(--text-brand);
}

/* Elements that just prompt the app popup instead of doing anything themselves. */
[data-app-gate] {
    cursor: pointer;
}

/* ---------- Horizontal drag-to-scroll track (behavior wired up by carousel.js) ---------- */
.h-scroll {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
    user-select: none;
}

.h-scroll::-webkit-scrollbar { display: none; }

.h-scroll.dragging {
    cursor: grabbing;
}

/* Disabled both while actively dragging AND while the JS spring is animating —
   native scroll-snap fights a programmatic scrollLeft change every frame otherwise. */
.h-scroll.dragging,
.h-scroll.snapping {
    scroll-snap-type: none;
}

/* ---------- Icon buttons ---------- */
.icon-button-round {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-inverse);
    cursor: pointer;
}

.icon-button-round svg {
    width: 24px;
    height: 24px;
    display: block;
}

.action-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-inverse);
}

.action-item svg {
    width: 24px;
    height: 24px;
    display: block;
}

.action-count {
    color: var(--text-inverse);
    min-width: 12px;
}

.menu-button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-inverse);
    cursor: pointer;
}

.menu-button svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* ---------- Pager badge (overlay counter, e.g. "1 of 3") ---------- */
.pager-badge {
    background-color: var(--surface-primary-40);
    border-radius: 9999px;
    height: 24px;
    min-width: 52px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pager-badge span {
    color: var(--text-inverse);
    font-size: 12px;
    line-height: 18px;
    font-weight: 300;
}

/* ---------- Pager dots ---------- */
.pager-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 32px;
}

.pager-dot {
    height: 8px;
    border-radius: 9999px;
    margin: 0 4px;
    background-color: rgba(178, 178, 178, 0.3);
    width: 8px;
    transition: width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.25s ease;
}

.pager-dot.active {
    width: 24px;
    background-color: var(--text-brand);
}

/* ---------- Follow button ---------- */
.follow-button {
    padding: 6px 20px;
    border: 1px solid var(--border-brand);
    background-color: transparent;
    color: var(--text-brand);
    border-radius: 9999px;
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    cursor: pointer;
}

/* ---------- Section divider (flat gray block, not a line) ---------- */
.section-divider {
    background-color: var(--surface-page-secondary);
    height: 16px;
    width: 100%;
}

/* ---------- Item card (post's own items, e.g. product being sold) ---------- */
.item-card {
    flex: 0 0 auto;
    width: var(--item-card-width);
    height: 460px;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    background-color: var(--surface-page);
    border: 1px solid var(--divider-primary);
    border-radius: 16px;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.08);
    padding: 12px 16px 16px 16px;
}

.item-card-image-wrap {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.item-card-image {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
    pointer-events: none;
}

.item-card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: var(--surface-primary-90);
    border: 1px solid var(--divider-primary);
    border-radius: 9999px;
    padding: 4px 12px;
}

.item-card-badge span {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 18px;
}

.item-card-brand {
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 21px;
    margin: 4px 0 12px 0;
}

.item-card-brand-link {
    display: block;
    text-decoration: none;
}

.item-card-brand-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.item-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.item-card-name {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.item-card-price {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
}

.item-card-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-brand);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    text-decoration: none;
    -webkit-user-drag: none;
}

.item-card-link svg {
    width: 24px;
    height: 24px;
}

/* ---------- Similar item card (small horizontal-scroll recommendation card) ---------- */
.similar-item-card {
    flex: 0 0 auto;
    width: 164px;
    text-decoration: none;
    color: inherit;
    -webkit-user-drag: none;
}

.similar-item-image {
    width: 164px;
    height: 204px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
    pointer-events: none;
}

.similar-item-info {
    margin-top: 4px;
    padding: 2px 0;
}

.similar-item-brand {
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.similar-item-name {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.similar-item-price {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Similar post card (recommended post preview) ---------- */
.similar-post-card {
    flex: 0 0 auto;
    width: 164px;
    text-decoration: none;
    color: inherit;
    -webkit-user-drag: none;
}

.similar-post-image-wrap {
    position: relative;
    width: 164px;
    height: 205px;
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--surface-page-secondary);
}

.similar-post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
    pointer-events: none;
}

.similar-post-gradient {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 39px;
    background: linear-gradient(to top, rgba(58,58,58,0.8), rgba(27,27,27,0.44) 54%, rgba(0,0,0,0));
    pointer-events: none;
}

.similar-post-likes {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--text-inverse);
}

.similar-post-likes svg {
    width: 16px;
    height: 16px;
    display: block;
}

.similar-post-bookmark {
    position: absolute;
    top: 0;
    right: 0;
    padding: 6px;
}

.similar-post-bookmark-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(67, 67, 67, 0.15);
    color: var(--text-inverse);
}

.similar-post-bookmark-button svg {
    width: 20px;
    height: 20px;
    display: block;
}

.similar-post-likes span {
    color: var(--text-inverse);
    font-size: 11px;
    line-height: 13px;
    font-weight: 500;
    margin-left: 4px;
}

.similar-post-info {
    margin-top: 4px;
    padding: 2px 0;
}

.similar-post-title {
    color: var(--text-primary);
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.similar-post-meta {
    color: var(--text-tertiary);
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Creator card ---------- */
.creator-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Also an <a> to the creator's profile, so link styling is kept off it. */
.creator-info {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.creator-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.creator-details {
    margin-left: 12px;
}

.creator-details h3 {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
}

.creator-followers {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 21px;
    font-weight: 300;
    margin-top: 2px;
}
