/* Home landing → Gundua scroll transition (feed peeks below search) */

body.home-has-gundua-peek {
    --home-gundua-reveal: 0;
    /* Vertical center of main panel; search anchor = top → center of input stack */
    --home-main-center: 50dvh;
    --home-search-anchor: clamp(168px, 28vh, 248px);
    --home-peek-gap: clamp(18px, 3.5vh, 32px);
}

@media (max-width: 768px) {
    body.home-has-gundua-peek {
        --home-main-center: calc((100dvh - 56px) / 2);
        --home-search-anchor: clamp(148px, 25vh, 208px);
        --home-peek-gap: clamp(14px, 2.5vh, 24px);
    }
}

body.home-has-gundua-peek .chat-container {
    scroll-behavior: auto;
}

/* Landing: pin search vertical center to main-panel midpoint */
body.home-has-gundua-peek:not(.home-gundua-active) .home-landing-panel {
    min-height: 0;
    display: block;
    box-sizing: border-box;
    padding-top: max(6px, calc(var(--home-main-center) - var(--home-search-anchor)));
    padding-bottom: 10px;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    opacity: calc(1 - var(--home-gundua-reveal) * 0.85);
    transform: translateY(calc(var(--home-gundua-reveal) * -16px));
}

body.home-has-gundua-peek:not(.home-gundua-active) .home-landing-panel .messages-container {
    flex: 0 0 auto;
    padding-top: 0;
    padding-bottom: 0;
}

body.home-has-gundua-peek:not(.home-gundua-active) .welcome-message {
    height: auto;
    min-height: 0;
    padding: 0 20px;
    gap: 0;
    justify-content: flex-start;
}

body.home-has-gundua-peek:not(.home-gundua-active) .welcome-message h2 {
    margin-bottom: 6px;
}

body.home-has-gundua-peek:not(.home-gundua-active) .landing-about-link {
    margin-top: -8px;
    margin-bottom: 10px;
}

body.home-has-gundua-peek:not(.home-gundua-active) .landing-ctas-container {
    margin-top: 8px;
}

/* SSR peek content: skip entrance animations (avoids load flicker on landing) */
body.home-has-gundua-peek:not(.home-gundua-active) .home-gundua-peek .discover-card,
body.home-has-gundua-peek:not(.home-gundua-active) .home-gundua-peek .discover-upcoming-card,
body.home-has-gundua-peek:not(.home-gundua-active) .home-gundua-peek .topic-list-item {
    animation: none;
    opacity: 1;
    transform: none;
}

body.home-has-gundua-peek.home-chat-active .home-gundua-peek {
    display: none;
}

.home-gundua-peek {
    position: relative;
    z-index: 2;
    margin-top: var(--home-peek-gap);
}

.home-gundua-peek__lip {
    display: none;
}

.home-gundua-peek__sheet {
    position: relative;
    border-radius: 28px 28px 0 0;
    overflow: hidden;
    background: var(--bg-main);
    box-shadow:
        0 -14px 40px rgba(0, 0, 0, 0.07),
        0 -1px 0 rgba(255, 255, 255, 0.7) inset;
}

/* Peek: show source strip + stories; hide Gundua title/filter chrome until locked */
body.home-has-gundua-peek:not(.home-gundua-active) .home-gundua-peek__discover .discover-header {
    display: none;
}

body.home-has-gundua-peek:not(.home-gundua-active) .home-gundua-peek__discover .discover-grid-wrapper {
    padding-top: 12px;
}

body.home-gundua-active.home-has-gundua-peek .home-landing-panel {
    display: none;
}

body.home-gundua-active.home-has-gundua-peek #homeScrollStage {
    display: block;
    min-height: auto;
}

body.home-gundua-active.home-has-gundua-peek .home-gundua-peek {
    margin-top: 0;
}

body.home-gundua-active.home-has-gundua-peek .home-gundua-peek__discover {
    min-height: min-content;
}

body.home-gundua-active.home-has-gundua-peek .home-gundua-peek__sheet {
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}

body.home-gundua-active.home-has-gundua-peek .home-gundua-peek__discover .discover-grid-wrapper {
    padding-top: 24px;
}

body.home-gundua-active.home-has-gundua-peek .home-gundua-peek__discover .discover-header {
    position: sticky;
    top: 0;
    z-index: 10;
}

body.home-gundua-active.home-has-gundua-peek .chat-container {
    scroll-behavior: smooth;
}

body.home-gundua-active.home-has-gundua-peek .home-gundua-peek__discover .discover-header {
    animation: homeGunduaReveal 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

@media (max-width: 768px) {
    .home-gundua-peek__sheet {
        border-radius: 22px 22px 0 0;
    }

    body.home-has-gundua-peek:not(.home-gundua-active) .home-gundua-peek__discover .discover-grid-wrapper {
        padding-top: 8px;
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.home-has-gundua-peek:not(.home-gundua-active) .home-landing-panel,
    .home-gundua-peek__sheet {
        transition: none;
    }

    body.home-gundua-active.home-has-gundua-peek .home-gundua-peek__discover .discover-header {
        animation: none;
    }
}
