/* === mirror-cosmos.css — Home "universe of mirrors" scroll experience ===
   Loaded only on the home page (via @section Head). Works with
   wwwroot/js/mirror-cosmos.js, which drives the --ap / --hp variables. */

#mirror-cosmos {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* Overlay canvas: herald shards fly IN FRONT of the content and land on cards.
   Below the fixed header (z-index 50). */
#mirror-cosmos-front {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 30;
    pointer-events: none;
}

.cosmos-home {
    position: relative;
}

/* ---------- hero ---------- */
.cosmos-hero {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    padding-top: 90px;
}

.cosmos-hero-inner {
    --hp: 0;
    max-width: 760px;
    opacity: calc(1 - var(--hp));
    transform: translateY(calc(var(--hp) * -64px)) scale(calc(1 - var(--hp) * 0.05));
    will-change: transform, opacity;
}

.cosmos-hero-inner h1 {
    margin: 14px 0 18px;
    font-size: clamp(2.5rem, 6vw, 4.3rem);
    font-weight: 800;
    line-height: 1.06;
    letter-spacing: -0.02em;
    background: linear-gradient(120deg, #f5f9ff 20%, var(--ob-blue) 55%, var(--ob-violet) 90%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 60px rgba(169, 221, 255, .18);
}

.cosmos-hero .hero-copy {
    max-width: 560px;
    color: var(--ob-muted);
    font-size: 1.08rem;
    line-height: 1.75;
}

.cosmos-hero .hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 26px;
}

.cosmos-scroll-cue {
    position: absolute;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: .78rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--ob-soft);
    opacity: calc(1 - var(--hp, 0) * 2.2);
    pointer-events: none;
}

.cosmos-scroll-cue span {
    width: 1px;
    height: 44px;
    background: linear-gradient(180deg, transparent, rgba(214, 240, 255, .75));
    animation: cosmos-cue 2.4s ease-in-out infinite;
    transform-origin: top;
}

@keyframes cosmos-cue {
    0%, 100% { transform: scaleY(.35); opacity: .35; }
    50%      { transform: scaleY(1);   opacity: 1; }
}

/* ---------- approaching mirrors (scroll-driven via --ap) ---------- */
[data-mirror] {
    --ap: 0;
    opacity: calc(var(--ap) * var(--ap));
    transform:
        perspective(1100px)
        translateY(calc((1 - var(--ap)) * 88px))
        translateZ(calc((1 - var(--ap)) * -520px))
        rotateX(calc((1 - var(--ap)) * 9deg));
    will-change: transform, opacity;
}

/* Framed cards materialize late — the flying herald shard carries the approach,
   then the card resolves out of its landing flash. */
.mirror-frame[data-mirror] {
    opacity: calc(var(--ap) * var(--ap) * var(--ap));
}

/* mirror frame — glassy pane with a metallic gradient rim + sweeping sheen */
.mirror-frame {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    border: 1.5px solid transparent;
    background:
        linear-gradient(var(--ob-glass), var(--ob-glass)) padding-box,
        linear-gradient(135deg,
            rgba(214, 240, 255, .72),
            rgba(185, 167, 255, .28) 34%,
            rgba(214, 240, 255, .07) 52%,
            rgba(243, 207, 183, .34) 82%,
            rgba(214, 240, 255, .55)) border-box;
    box-shadow:
        0 24px 70px rgba(1, 7, 18, .5),
        0 0 42px rgba(169, 221, 255, calc(.05 + var(--ap, 0) * .1));
    backdrop-filter: blur(14px) saturate(130%);
}

/* sheen that sweeps across the pane as the mirror approaches */
.mirror-frame::before {
    content: "";
    position: absolute;
    inset: -60% -40%;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(112deg,
        transparent 42%,
        rgba(232, 246, 255, .13) 50%,
        rgba(232, 246, 255, .04) 54%,
        transparent 60%);
    transform: translateX(calc((var(--ap, 0) - .5) * 130%));
}

/* faint inner reflection along the top edge */
.mirror-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, .07), transparent 30%);
}

.mirror-frame > * {
    position: relative;
    z-index: 2;
}

/* ---------- content sections ---------- */
.cosmos-intro {
    margin: 24vh auto 10vh;
    display: flex;
    justify-content: center;
}

.mirror-pane {
    max-width: 640px;
    padding: 42px 46px;
    text-align: center;
}

.mirror-pane h2 {
    margin: 10px 0 16px;
    font-size: clamp(1.5rem, 3vw, 2.1rem);
    letter-spacing: -0.01em;
}

.mirror-pane p:last-child {
    margin: 0;
    color: var(--ob-muted);
    line-height: 1.8;
}

.cosmos-approach {
    margin: 14vh auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}

.cosmos-approach .mirror-frame {
    padding: 28px;
}

.cosmos-approach span {
    font-size: .8rem;
    letter-spacing: .2em;
    color: var(--ob-blue);
}

.cosmos-section {
    margin: 26vh auto;
}

.cosmos-section .section-heading-row {
    margin-bottom: 34px;
}

.mirror-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    align-items: stretch;
}

.mirror-card {
    display: flex;
    flex-direction: column;
}

.mirror-card .preview-card-body {
    padding: 20px 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mirror-card h3 {
    margin: 0;
    font-size: 1.12rem;
    line-height: 1.4;
}

.mirror-card h3 a {
    color: var(--ob-text);
    text-decoration: none;
}

.mirror-card h3 a:hover,
.mirror-card h3 a:focus-visible {
    color: var(--ob-blue-2);
}

.mirror-card .preview-excerpt {
    margin: 0;
    color: var(--ob-muted);
    font-size: .93rem;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* feed cards: the image is the "vision inside the mirror" */
.mirror-card .feed-preview-thumb {
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
}

.mirror-card .feed-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: scale(calc(1.12 - var(--ap, 0) * .12));
    transition: transform .4s ease;
}

.mirror-card .feed-preview-author {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mirror-card .feed-preview-author img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--ob-border-strong);
}

.mirror-card .author-name {
    font-weight: 600;
    font-size: .92rem;
}

/* library cards keep their tall-cover mirror look */
.mirror-card .library-preview-link {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
    height: 100%;
}

.mirror-card .library-preview-cover {
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(150deg, rgba(21, 36, 58, .9), rgba(13, 23, 40, .9));
    font-size: 2.4rem;
    color: var(--ob-blue);
}

.mirror-card .library-preview-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---------- figure scene (shards → human → rabbit) ---------- */
.cosmos-figure {
    height: 300vh;
    position: relative;
}

.cosmos-figure-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 9vh;
    pointer-events: none;
}

.cosmos-figure-line {
    position: absolute;
    bottom: 9vh;
    left: 50%;
    transform: translateX(-50%);
    width: min(640px, 86vw);
    margin: 0;
    text-align: center;
    font-size: clamp(1rem, 2vw, 1.25rem);
    line-height: 1.7;
    color: var(--ob-lilac);
    text-shadow: 0 2px 26px rgba(7, 17, 31, .9);
    opacity: 0;
}

/* ---------- closing ---------- */
.cosmos-cta {
    margin: 20vh auto 26vh;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 56px 36px;
}

.cosmos-cta h2 {
    margin: 0;
    font-size: clamp(1.6rem, 3.4vw, 2.4rem);
    letter-spacing: -0.01em;
}

/* ---------- fallbacks ---------- */
.cosmos-static [data-mirror],
.cosmos-static .cosmos-hero-inner {
    opacity: 1;
    transform: none;
}

.cosmos-static .cosmos-figure {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    [data-mirror],
    .cosmos-hero-inner {
        opacity: 1 !important;
        transform: none !important;
    }
    .cosmos-figure {
        display: none;
    }
    .cosmos-scroll-cue span {
        animation: none;
    }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .mirror-grid,
    .cosmos-approach {
        grid-template-columns: 1fr;
        max-width: 480px;
        margin-inline: auto;
    }
    .cosmos-section {
        margin: 18vh auto;
    }
    .cosmos-figure {
        height: 240vh;
    }
    .mirror-pane {
        padding: 32px 26px;
    }
}
