/* ========================================
   LIYU: FOR GOOD — Style Sheet
   ======================================== */

@font-face {
    font-family: 'HeirofLight';
    src: local('Heir of Light OTF'),
         local('Heir of Light'),
         url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-07@1.0/HeirofLightBold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'HeirofLight';
    src: local('Heir of Light OTF'),
         local('Heir of Light'),
         url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-07@1.0/HeirofLightRegular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-dark: #0a0612;
    --purple-deep: #2d1b4e;
    --purple-mid: #5b3b8c;
    --purple-glow: #9b6dd7;
    --gold: #c9a84c;
    --text-light: #e8d5f5;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: 'Noto Sans KR', sans-serif;
    color: var(--purple-deep);
    -webkit-font-smoothing: antialiased;
}

body.entered {
    overflow-y: auto;
    overflow-x: hidden;
    background: #ffffff;
}

button {
    font: inherit;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

/* ========================================
   INTRO SCREEN (Inside a Giant Iridescent Bubble)
   ======================================== */
#intro {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    background: radial-gradient(
        circle at 50% 44%,
        rgba(185, 130, 235, 0.16) 0%,
        rgba(145, 82, 200, 0.34) 48%,
        rgba(72, 28, 128, 0.62) 85%,
        rgba(38, 12, 76, 0.78) 100%
    );
    transition: opacity 0.65s ease-out 0.1s, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

#intro.hiding {
    opacity: 0;
    transform: scale(1.28);
    pointer-events: none;
}

#intro.hidden {
    display: none;
}

/* Swirling iridescent soap-film layer warped by SVG turbulence */
.bubble-iridescent {
    position: absolute;
    inset: -14%;
    pointer-events: none;
    z-index: 1;
    filter: url(#bubble-warp);
    mix-blend-mode: screen;
    opacity: 0.92;
}

.bubble-swirl {
    width: 100%;
    height: 100%;
    background:
        conic-gradient(
            from 20deg at 48% 46%,
            rgba(255, 135, 222, 0.52),
            rgba(120, 240, 255, 0.44),
            rgba(195, 130, 255, 0.52),
            rgba(255, 225, 155, 0.42),
            rgba(145, 255, 218, 0.38),
            rgba(255, 128, 205, 0.52)
        ),
        radial-gradient(ellipse 68% 48% at 25% 24%, rgba(255, 150, 230, 0.55) 0%, transparent 65%),
        radial-gradient(ellipse 62% 52% at 78% 72%, rgba(105, 235, 255, 0.48) 0%, transparent 68%),
        radial-gradient(ellipse 55% 42% at 72% 22%, rgba(255, 235, 170, 0.42) 0%, transparent 64%);
    animation: swirlUndulate 10s ease-in-out infinite alternate;
}

@keyframes swirlUndulate {
    0% {
        transform: translate3d(-4%, -3%, 0) rotate(-6deg) scale(1.04);
    }
    33% {
        transform: translate3d(3%, -2%, 0) rotate(5deg) scale(1.12, 1.04);
    }
    66% {
        transform: translate3d(4%, 3%, 0) rotate(10deg) scale(1.05, 1.13);
    }
    100% {
        transform: translate3d(-3%, 4%, 0) rotate(-4deg) scale(1.1);
    }
}

#bubble-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Curved Glinda-style spherical rim refraction & edge highlights */
.bubble-rim {
    position: absolute;
    inset: -5%;
    border-radius: 44% 48% 46% 42% / 46% 42% 48% 44%;
    pointer-events: none;
    z-index: 3;
    background:
        radial-gradient(ellipse 58% 22% at 50% 4%, rgba(255, 245, 255, 0.52) 0%, rgba(255, 195, 240, 0.25) 45%, transparent 75%),
        radial-gradient(ellipse 74% 68% at 50% 50%, transparent 56%, rgba(255, 145, 225, 0.28) 76%, rgba(120, 235, 255, 0.32) 89%, rgba(255, 210, 250, 0.48) 100%);
    box-shadow:
        inset 0 0 48px rgba(255, 230, 250, 0.62),
        inset 0 0 110px rgba(255, 130, 215, 0.42),
        inset 0 0 185px rgba(105, 232, 255, 0.34),
        inset 0 0 280px rgba(140, 72, 220, 0.46);
    animation: bubbleMembrane 6.5s ease-in-out infinite alternate;
}

@keyframes bubbleMembrane {
    0% {
        transform: scale(1) skew(0deg, 0deg);
        border-radius: 43% 49% 46% 42% / 47% 41% 49% 43%;
    }
    33% {
        transform: scale(1.03, 1.01) skew(1.2deg, -0.8deg);
        border-radius: 48% 42% 43% 49% / 42% 48% 44% 47%;
    }
    66% {
        transform: scale(1.01, 1.03) skew(-1.1deg, 0.9deg);
        border-radius: 44% 47% 49% 43% / 48% 43% 42% 48%;
    }
    100% {
        transform: scale(1.025) skew(0.6deg, 0.6deg);
        border-radius: 46% 44% 42% 48% / 44% 47% 48% 42%;
    }
}

/* Specular curved soap-film sheen arcs sweeping across screen */
.bubble-sheen {
    position: absolute;
    inset: -22%;
    pointer-events: none;
    z-index: 4;
    background:
        radial-gradient(ellipse 46% 24% at 22% 18%, rgba(255, 255, 255, 0.46) 0%, rgba(185, 245, 255, 0.24) 42%, transparent 72%),
        radial-gradient(ellipse 52% 28% at 78% 82%, rgba(255, 155, 225, 0.42) 0%, rgba(210, 145, 255, 0.22) 48%, transparent 75%),
        radial-gradient(ellipse 36% 52% at 14% 66%, rgba(135, 242, 255, 0.28) 0%, transparent 70%),
        radial-gradient(ellipse 40% 48% at 86% 30%, rgba(255, 200, 240, 0.34) 0%, transparent 70%);
    mix-blend-mode: screen;
    animation: sheenDrift 7.5s ease-in-out infinite alternate;
}

@keyframes sheenDrift {
    0% {
        transform: translate3d(-3%, -2.5%, 0) rotate(-3deg) scale(1);
        opacity: 0.85;
    }
    50% {
        transform: translate3d(3.5%, 2%, 0) rotate(3deg) scale(1.06);
        opacity: 1;
    }
    100% {
        transform: translate3d(-2%, 3%, 0) rotate(-2deg) scale(1.03);
        opacity: 0.9;
    }
}

.intro-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(28px, 5vh, 46px);
    text-align: center;
    padding: 0 24px;
}

.intro-logo {
    width: clamp(250px, 56vw, 480px);
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-select: none;
    filter:
        drop-shadow(0 0 20px rgba(255, 232, 255, 0.72))
        drop-shadow(0 4px 18px rgba(72, 28, 128, 0.6));
    animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Text-only TOUCH button (Heir of Light OTF) */
.touch-btn {
    position: relative;
    padding: 10px 24px;
    background: none;
    border: none;
    box-shadow: none;
    color: #ffffff;
    transition: transform 0.3s ease, opacity 0.3s ease;
    animation: touchPulse 2.6s ease-in-out infinite;
}

@keyframes touchPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.86;
    }
    50% {
        transform: scale(1.07);
        opacity: 1;
    }
}

.touch-btn:hover {
    transform: scale(1.1);
    opacity: 1;
}

.touch-btn:active {
    transform: scale(0.95);
}

.touch-btn:focus-visible {
    outline: 1.5px solid rgba(255, 255, 255, 0.65);
    outline-offset: 6px;
    border-radius: 8px;
}

.touch-text {
    position: relative;
    z-index: 1;
    font-family: 'HeirofLight', 'Heir of Light OTF', 'Heir of Light', serif;
    font-size: clamp(20px, 3.2vw, 30px);
    font-weight: 700;
    letter-spacing: 0.28em;
    padding-left: 0.28em;
    color: #ffffff;
    text-shadow:
        0 0 14px rgba(255, 255, 255, 0.85),
        0 0 28px rgba(255, 165, 235, 0.65),
        0 2px 10px rgba(62, 20, 115, 0.6);
}

/* ========================================
   MAIN HOME STAGE (home.png layout)
   ======================================== */
.app {
    position: relative;
    width: 100%;
    min-height: 100vh;
    /* Seamless match to home.png side edges for monitors wider than 1440px */
    background: linear-gradient(
        180deg,
        #a58cd6 0%,
        #c7afe3 15%,
        #e8d5f3 30%,
        #feebf9 42%,
        #fffbfe 58%,
        #ffffff 80%,
        #ffffff 100%
    );
    opacity: 0.94;
    filter: blur(11px) saturate(1.15);
    transform: scale(1.04);
    animation: behindBubbleSway 7s ease-in-out infinite alternate;
    transition:
        opacity 0.55s ease,
        filter 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

@keyframes behindBubbleSway {
    0% {
        transform: scale(1.045) translate3d(-0.8%, -0.5%, 0) skew(0.5deg, 0.3deg);
    }
    50% {
        transform: scale(1.06, 1.035) translate3d(0.8%, 0.6%, 0) skew(-0.6deg, -0.3deg);
    }
    100% {
        transform: scale(1.04, 1.055) translate3d(-0.5%, 0.8%, 0) skew(0.4deg, -0.4deg);
    }
}

/* filter/transform이 남아 있으면 내부 position:fixed(#sparkles)가 화면 고정이 안 되므로 none */
.app.visible {
    opacity: 1;
    filter: none;
    transform: none;
    animation: none;
    pointer-events: auto;
}

#sparkles {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* 1440 x 2050 proportional stage (cropped below last non-white cloud row y=1945) */
.home-stage {
    position: relative;
    width: 100%;
    max-width: 1440px;
    aspect-ratio: 1440 / 2050;
    margin: 0 auto;
    background-image: url('assets/home.png');
    background-repeat: no-repeat;
    background-position: top center;
    background-size: 100% auto;
    z-index: 10;
}

/* ========================================
   BOOK SECTION (matches home_1.png & home_2.png)
   ======================================== */
.book-section {
    position: absolute;
    top: 8.8%;
    left: 50%;
    transform: translateX(-50%);
    width: 65.7%;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
}

.viewer {
    width: 100%;
    position: relative;
    touch-action: pan-y pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
    perspective: 2200px;
}

.book {
    width: 100%;
    aspect-ratio: 1800 / 1277;
    position: relative;
    isolation: isolate;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.22, 0.61, 0.2, 1);
}

/* Closed cover centered visually like home_1.png */
.book.is-closed {
    transform: translateX(-18.5%);
}

/* Base pages */
.base {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    overflow: hidden;
}

.base.left {
    left: 0;
    display: none;
}

.base.right {
    right: 0;
}

/* Leaves */
/* .book의 isolation:isolate가 3D를 평면화하므로 원근은 책장 부모에 직접 지정 */
.leaves {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    perspective: 2200px;
}

.leaf {
    position: absolute;
    left: 50%;
    top: 0;
    width: 50%;
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.2, 1);
}

.leaf.flipped {
    transform: rotateY(-180deg);
}

.face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
}

.face.front {
    transform: rotateY(0deg);
}

.face.back {
    transform: rotateY(180deg);
}

.page-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    transition: filter 0.25s ease;
}

.leaf.in-motion .page-img {
    filter: brightness(0.96);
}

/* Cover click cue when closed */
.book.is-closed .leaf:first-child .face.front {
    cursor: pointer;
}

/* Click edges for page turning */
.click-edge {
    position: absolute;
    top: 8%;
    bottom: 8%;
    width: 14%;
    z-index: 210;
    cursor: pointer;
}

.click-edge.prev {
    left: 0;
}

.click-edge.next {
    right: 0;
}

.book.is-closed ~ .click-edge.prev {
    pointer-events: none;
}

.book.is-closed ~ .click-edge.next {
    left: 30%;
    right: 12%;
    width: auto;
}

/* ========================================
   NAVIGATION (Slider bar + counter pill)
   ======================================== */
.nav {
    width: min(100%, 620px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: clamp(12px, 1.6vw, 22px);
    z-index: 30;
}

.slider-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 4px 0;
}

.page-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(230, 230, 234, 0.95);
    box-shadow: inset 0 1px 2px rgba(74, 45, 122, 0.1);
    outline: none;
    cursor: pointer;
    touch-action: pan-x;
}

.page-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #8724e6;
    border: none;
    box-shadow: 0 2px 8px rgba(135, 36, 230, 0.38);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.page-slider::-webkit-slider-thumb:hover {
    transform: scale(1.12);
    box-shadow: 0 3px 12px rgba(135, 36, 230, 0.5);
}

.page-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.16);
}

.page-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #8724e6;
    border: none;
    box-shadow: 0 2px 8px rgba(135, 36, 230, 0.38);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.page-slider:focus-visible {
    outline: 2px solid var(--purple-glow);
    outline-offset: 4px;
}

.nav-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.navbtn {
    position: relative;
    width: clamp(30px, 2.8vw, 36px);
    height: clamp(30px, 2.8vw, 36px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(91, 59, 140, 0.22);
    box-shadow: 0 2px 8px rgba(74, 45, 122, 0.12);
    backdrop-filter: blur(8px);
    color: var(--purple-mid);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    padding: 0;
    transition: all 0.2s ease;
}

.navbtn::after {
    font-size: clamp(16px, 1.8vw, 21px);
    font-weight: 700;
    color: var(--purple-mid);
    line-height: 1;
}

.navbtn.prev::after {
    content: '‹';
    margin-left: -1px;
}

.navbtn.next::after {
    content: '›';
    margin-left: 1px;
}

.navbtn:hover:not(:disabled) {
    background: #ffffff;
    border-color: var(--purple-glow);
    box-shadow: 0 4px 12px rgba(91, 59, 140, 0.2);
    transform: translateY(-1px);
}

.navbtn:active:not(:disabled) {
    transform: translateY(1px) scale(0.96);
}

.navbtn:disabled {
    opacity: 0.32;
    cursor: default;
}

.index {
    font: 500 clamp(12px, 1.15vw, 15px) 'Noto Sans KR', system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
    min-width: 78px;
    text-align: center;
    white-space: nowrap;
    color: #1f1b24;
    background: rgba(218, 218, 222, 0.92);
    padding: 6px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(74, 45, 122, 0.08);
    backdrop-filter: blur(6px);
}

/* ========================================
   CELEBRATION VIDEO SECTION (below the book)
   ======================================== */
.video-section {
    position: absolute;
    top: 56.2%;
    left: 50%;
    transform: translateX(-50%);
    width: 73.75%;
    z-index: 20;
}

.video-card {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: clamp(10px, 1.2vw, 18px);
    overflow: hidden;
    background: rgba(196, 196, 196, 0.92);
    box-shadow: 0 12px 36px rgba(74, 45, 122, 0.14);
    border: 1px solid rgba(155, 109, 215, 0.22);
}

.video-card iframe,
#celebration-player {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #333333;
    background: linear-gradient(145deg, #c9c7ce 0%, #bcb9c4 100%);
    pointer-events: none;
}

.video-placeholder.hidden {
    display: none;
}

.video-play-icon {
    width: clamp(46px, 5vw, 68px);
    height: clamp(46px, 5vw, 68px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(18px, 2vw, 26px);
    color: var(--purple-deep);
    padding-left: 3px;
}

.video-placeholder-text {
    font-size: clamp(14px, 1.6vw, 22px);
    font-weight: 500;
    color: #2c2438;
}

/* ========================================
   FOOTER (putter.png)
   ======================================== */
.site-footer {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

.footer-img {
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-select: none;
}

/* ========================================
   BGM TOGGLE
   ======================================== */
.bgm-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(91, 59, 140, 0.3);
    box-shadow: 0 4px 16px rgba(74, 45, 122, 0.2);
    color: var(--purple-mid);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.bgm-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.bgm-btn:hover {
    background: #ffffff;
    border-color: var(--purple-glow);
    transform: scale(1.06);
}

.bgm-btn.muted .bgm-icon {
    opacity: 0.35;
}

#bgm-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 200px;
    height: 200px;
    opacity: 0.001;
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   RESPONSIVE (Mobile: keep 2-page spread wide & readable!)
   ======================================== */
@media (max-width: 768px) {
    .home-stage {
        aspect-ratio: auto;
        min-height: 100svh;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 13vw 2vw 72px;
        gap: 28px;
        background-size: 100% auto;
        background-position: top center;
    }

    .book-section {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: 100%;
    }

    .book.is-closed {
        transform: translateX(-25%) scale(1.16);
        transform-origin: 75% 50%;
    }

    .nav {
        width: 88%;
        margin-top: 16px;
        gap: 10px;
    }

    .navbtn {
        width: 34px;
        height: 34px;
    }

    .navbtn::after {
        font-size: 18px;
    }

    .index {
        font-size: 13px;
        padding: 6px 14px;
        min-width: 76px;
    }

    .video-section {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: 94%;
        margin-top: 8px;
    }

    .bgm-btn {
        bottom: 14px;
        right: 14px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .leaf,
    .book {
        transition-duration: 0.01ms !important;
    }
    .intro-logo,
    .touch-btn,
    .bubble-swirl,
    .bubble-rim,
    .bubble-sheen,
    .app {
        animation: none;
    }
    #intro {
        transition-duration: 0.01ms;
    }
}
