/* Breakpoints: stacked <950px, side-by-side ≥950px */
:root {
    --bp-stacked: 949px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    width: 100%;
}

html {
    cursor: none;
}

body {
    margin: 0;
    color: rgba(0, 0, 0, 1);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    cursor: none;
    display: flex;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Cursor sparkles: full-viewport overlay, non-interactive */
/* Overlay and all descendants must not capture pointer so body/book/panel cursor shows */
#sparkles-overlay,
#sparkles-overlay * {
    pointer-events: none !important;
}
/* Custom wand cursor: follows pointer so wand.png always visible (avoids 32px cursor limit) */
#custom-cursor {
    position: fixed;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    z-index: 9999;
    pointer-events: none;
}
#custom-cursor img {
    display: block;
    width: 32px;
    height: 32px;
    transform: translate(-50%, -50%);
}
#custom-cursor.is-hidden {
    opacity: 0;
    visibility: hidden;
}

#sparkles-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
}

/* Side-by-side: book left, panel right (when viewport ≥950px) */
@media (min-width: 950px) {
    body {
        flex-direction: row;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .right-panel {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        min-height: 0;
        overflow-y: auto;
    }
}

/* Black half: 3D book — canvas centered and scales with viewport */
.book {
    position: relative;
    width: 50vw;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    flex-shrink: 0;
    pointer-events: auto;
    background-color: #0d0d0d;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: none;
}

@media (max-width: 949px) {
    .book {
        width: 100%;
        max-width: 100%;
        height: 92vh;
        height: 92dvh;
        min-height: 380px;
        padding: 24px;
        padding-bottom: 32px;
        box-sizing: border-box;
    }
}

/* 400–950px: more vertical space for book so it isn’t squished */
@media (max-width: 949px) and (min-width: 400px) {
    .book {
        height: 96vh;
        height: 96dvh;
        min-height: 420px;
    }
}

.book canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    cursor: none;
}

/* White half: conceptual flow + CTA; full height so spacing goes to bottom */
.right-panel {
    width: 50vw;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 40px;
    padding-bottom: 40px;
    padding-left: 2rem;
    padding-right: 2rem;
    background-color: #fff;
    cursor: none;
}

/* Centered block: flow + CTA; takes remaining space so footer can sit at bottom */
.panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    text-align: center;
    margin-top: 60px;
    margin-bottom: 60px;
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
    cursor: none;
}

/* Staged reveal: flow lines one at a time → CTA → X logo. Very smooth ease. */
@keyframes panelReveal {
    from {
        opacity: 0;
        visibility: hidden;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

/* Very soft easing: no sudden start, smooth settle */
:root {
    --panel-reveal-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Flow children: one at a time in DOM order; staggered fade-in. */
.flow > * {
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    animation: panelReveal 0.65s var(--panel-reveal-ease) both;
}

/* Sequential: line → arrow … (delay = (n-1) * 0.13s) */
.flow > *:nth-child(1) { animation-delay: 0s; }
.flow > *:nth-child(2) { animation-delay: 0.13s; }
.flow > *:nth-child(3) { animation-delay: 0.26s; }
.flow > *:nth-child(4) { animation-delay: 0.39s; }
.flow > *:nth-child(5) { animation-delay: 0.52s; }
.flow > *:nth-child(6) { animation-delay: 0.65s; }
.flow > *:nth-child(7) { animation-delay: 0.78s; }
.flow > *:nth-child(8) { animation-delay: 0.91s; }
.flow > *:nth-child(9) { animation-delay: 1.04s; }
.flow > *:nth-child(10) { animation-delay: 1.17s; }
.flow > *:nth-child(11) { animation-delay: 1.3s; }
.flow > *:nth-child(12) { animation-delay: 1.43s; }
.flow > *:nth-child(13) { animation-delay: 1.56s; }
.flow > *:nth-child(14) { animation-delay: 1.69s; }
.flow > *:nth-child(15) { animation-delay: 1.82s; }

/* CTA bar: button + X logo. Desktop = column (button above logo); mobile = row (beside) */
.cta-bar {
    flex-shrink: 0;
    border-top: none;
    background-color: #fff;
    padding: 1rem 2rem 20px;
    padding-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 50px;
    text-align: center;
}

.cta-bar .cta {
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    animation: panelReveal 0.65s var(--panel-reveal-ease) 2.1s both;
}

.cta-bar-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    animation: panelReveal 0.65s var(--panel-reveal-ease) 2.65s both;
}

.cta-bar-x img {
    display: block;
    filter: invert(1);
    opacity: 0.55;
    transition: opacity 0.2s ease, filter 0.2s ease;
}

.cta-bar-x:hover img {
    opacity: 1;
    filter: invert(1) brightness(1.15);
}

@media (max-width: 949px) {
    body {
        flex-direction: column;
    }

    .right-panel {
        width: 100%;
        max-width: 100%;
        height: 48vh;
        height: 48dvh;
        min-height: 380px;
        flex: 1;
        padding: 1.5rem;
        padding-bottom: calc(96px + 1.5rem + env(safe-area-inset-bottom, 0px)); /* clear space above fixed cta-bar */
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cta-bar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        background-color: rgba(255, 255, 255, 1);
        border-top: 1px solid rgba(131, 128, 128, 1);
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        padding: 1rem 20px;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    .cta-bar .cta {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        animation: none;
    }

    .cta-bar-x {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        animation: none;
    }

}

/* Narrow phones (≤400px): white panel gets more height for content */
@media (max-width: 400px) {
    .right-panel {
        min-height: 95dvh;
        min-height: 1000px;
    }
}

.flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
}

.flow-line {
    color: #000;
    font-size: clamp(0.75rem, 1.2vw, 1rem);
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
}

.flow-arrow {
    color: #000;
    font-size: 1rem;
    opacity: 0.8;
}

.cta-bar .cta,
.cta {
    display: inline-block;
    background: #1A9653;
    color: #fff;
    font-family: inherit;
    font-size: clamp(0.8rem, 1.1vw, 1rem);
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    padding: 1rem 2.5rem;
    border: none;
    cursor: pointer;
    transition: transform 0.5s var(--panel-reveal-ease);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cta-bar .cta:hover,
.cta:hover,
.cta-bar .cta:active,
.cta:active {
    transform: scale(1.06) !important;
}

/* Stacked (viewport <950px): tighter flow/CTA */
@media (max-width: 949px) {
    .flow {
        gap: 0.4rem;
        margin-bottom: 2rem;
    }

    .flow-line {
        font-size: clamp(0.7rem, 2.5vw, 0.95rem);
    }

    .cta {
        padding: 0.875rem 2rem;
        font-size: clamp(0.75rem, 2vw, 0.95rem);
    }
}

/* Small phones: tighter padding and fonts */
@media (max-width: 767px) {
    .right-panel {
        padding: 1.25rem 1rem;
    }

    .flow {
        gap: 0.35rem;
        margin-bottom: 1.5rem;
    }

    .flow-line {
        font-size: clamp(0.7rem, 3.5vw, 0.9rem);
    }

    .flow-arrow {
        font-size: 0.9rem;
    }

    .cta {
        padding: 0.875rem 1.75rem;
        font-size: 0.8rem;
    }
}

/* Very small phones: prevent overflow */
@media (max-width: 380px) {
    .right-panel {
        padding: 1rem 0.75rem;
    }

    .flow-line {
        font-size: 0.7rem;
    }

    .cta {
        padding: 0.75rem 1.5rem;
        font-size: 0.75rem;
    }
}

/* Accessibility: no panel reveal animation when motion is reduced */
@media (prefers-reduced-motion: reduce) {
    .flow > *,
    .cta-bar .cta,
    .cta-bar-x {
        animation: none;
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}