/* ============================================================
   scenes.css — 三个告白场景
   sr-* 星河来信 / sk-* 樱花恋文 / hb-* 心跳信号
   ============================================================ */

.scene-root { position: fixed; inset: 0; overflow: hidden; }
.scene-root.is-paused,
.scene-root.is-paused *,
.scene-root.is-paused *::before,
.scene-root.is-paused *::after { animation-play-state: paused !important; }
.scene-root canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ============================================================
   场景一 · 星河来信
   ============================================================ */
.sr-root {
    background:
        radial-gradient(130% 90% at 50% -18%, #141a38 0%, transparent 58%),
        radial-gradient(90% 70% at 108% 112%, #1d1633 0%, transparent 60%),
        linear-gradient(175deg, #0a0f22 0%, #070b18 52%, #05080f 100%);
}
.sr-nebula { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.sr-nebula__b {
    position: absolute; border-radius: 50%; filter: blur(90px);
    animation: sr-blob 30s ease-in-out infinite alternate;
}
.sr-nebula__b--1 {
    width: 55vmax; height: 55vmax; top: -24vmax; left: -14vmax;
    background: radial-gradient(circle, rgba(86,104,196,.2), transparent 65%);
}
.sr-nebula__b--2 {
    width: 48vmax; height: 48vmax; right: -18vmax; bottom: -20vmax;
    background: radial-gradient(circle, rgba(138,92,178,.16), transparent 65%);
    animation-duration: 38s; animation-delay: -10s;
}
@keyframes sr-blob {
    from { transform: translate3d(0,0,0) scale(1); }
    to   { transform: translate3d(5vmax,3.5vmax,0) scale(1.12); }
}
.sr-canvas { z-index: 1; }
.sr-grain {
    position: absolute; inset: -50%; z-index: 2; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
    opacity: .05; mix-blend-mode: overlay;
}
.sr-stage { position: absolute; inset: 0; z-index: 3; }

.sr-note {
    position: absolute; top: 0; left: 0;
    transform: translate3d(var(--x,0), var(--y,0), 0);
    cursor: pointer; outline: none;
    -webkit-tap-highlight-color: transparent;
}
.sr-note:focus-visible .sr-note__card {
    border-color: rgba(231,196,140,.65);
    box-shadow: 0 0 0 2px rgba(231,196,140,.25);
}
.sr-note__float {
    animation: sr-bob var(--float-dur,5s) ease-in-out var(--float-delay,0s) infinite;
    will-change: transform;
}
@keyframes sr-bob {
    0%,100% { transform: translate3d(0,0,0) rotate(0); }
    50% { transform: translate3d(var(--sway,4px), calc(-1 * var(--lift,8px)), 0) rotate(var(--tilt,.8deg)); }
}
.sr-note__card {
    position: relative;
    width: fit-content;
    max-width: min(70vw, 16.5em);
    padding: .52em .92em .58em 1.02em;
    border-radius: 15px;
    font-size: var(--fs,16px);
    font-weight: 500; line-height: 1.6; letter-spacing: .3px;
    text-align: center;
    word-break: break-word; overflow-wrap: anywhere;
    color: #dfe5fb;
    background: linear-gradient(155deg, rgba(255,255,255,.075), rgba(255,255,255,.028));
    border: 1px solid rgba(223,229,251,.12);
    backdrop-filter: blur(12px) saturate(1.25);
    -webkit-backdrop-filter: blur(12px) saturate(1.25);
    box-shadow: 0 18px 40px -18px rgba(0,0,0,.75), inset 0 1px 0 rgba(255,255,255,.07);
    opacity: 0;
    transform: translateY(16px) scale(.92);
    transition: opacity .7s ease, transform .72s cubic-bezier(.34,1.4,.52,1),
                border-color .4s ease, box-shadow .4s ease, background .4s ease;
}
.sr-note.is-shown .sr-note__card { opacity: 1; transform: none; }
.sr-note__card::before {
    content: ""; position: absolute; top: -7px; left: -7px;
    width: 15px; height: 15px;
    background: var(--accent,#e7c48c);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 0C17.2 10.4 21.6 14.8 32 16 21.6 17.2 17.2 21.6 16 32 14.8 21.6 10.4 17.2 0 16 10.4 14.8 14.8 10.4 16 0z'/%3E%3C/svg%3E") center/contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 0C17.2 10.4 21.6 14.8 32 16 21.6 17.2 17.2 21.6 16 32 14.8 21.6 10.4 17.2 0 16 10.4 14.8 14.8 10.4 16 0z'/%3E%3C/svg%3E") center/contain no-repeat;
    filter: drop-shadow(0 0 5px var(--accent-glow,rgba(231,196,140,.8)));
    animation: sr-twinkle 2.8s ease-in-out infinite;
}
@keyframes sr-twinkle { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.sr-note.is-lit .sr-note__card {
    border-color: var(--accent-soft,rgba(231,196,140,.5));
    background: linear-gradient(155deg, rgba(255,255,255,.12), rgba(255,255,255,.05));
    box-shadow: 0 0 26px -2px var(--accent-glow,rgba(231,196,140,.45)),
                0 18px 44px -18px rgba(0,0,0,.7),
                inset 0 1px 0 rgba(255,255,255,.1);
}
.sr-root.is-finale .sr-note:not(.is-lit) .sr-note__card { opacity: .38; }
.sr-root.is-finale .sr-note:not(.is-lit) .sr-note__card::before { opacity: .35; }

.sr-note.is-leaving { pointer-events: none; }
.sr-note.is-leaving .sr-note__float { animation: sr-leave .7s ease forwards; }
@keyframes sr-leave {
    to { opacity: 0; transform: translateY(-46px) scale(.92); }
}

@media (max-width: 720px) {
    .sr-note__card {
        padding: .4em .68em .44em .78em;
        line-height: 1.45; letter-spacing: .2px; border-radius: 12px;
    }
}

/* ============================================================
   场景二 · 樱花恋文
   ============================================================ */
.sk-root {
    background:
        radial-gradient(110% 80% at 80% -10%, rgba(255,190,210,.55), transparent 60%),
        radial-gradient(90% 70% at 0% 110%, rgba(255,215,190,.5), transparent 60%),
        linear-gradient(168deg, #fff0f5 0%, #ffe0ea 48%, #ffd9dd 100%);
}
.sk-glow {
    position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(46vmin 34vmin at 50% 46%, rgba(255,255,255,.55), transparent 70%);
}
.sk-canvas { z-index: 1; }
.sk-stage {
    position: absolute; inset: 0; z-index: 2;
    display: flex; align-items: center; justify-content: center;
    padding: 70px 20px 40px;
}

/* 拂动指引 */
.sk-guide {
    position: absolute;
    left: 50%; top: calc(50% + 150px);
    transform: translateX(-50%);
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    border-radius: 999px;
    background: rgba(255,255,255,.7);
    border: 1px solid rgba(255,255,255,.95);
    box-shadow: 0 14px 36px -16px rgba(214,89,132,.4);
    font-size: 13px; letter-spacing: 1.5px; color: #b04a70;
    opacity: 0; transition: opacity .5s ease;
    pointer-events: none;
    white-space: nowrap;
}
.sk-guide.is-on { opacity: 1; animation: sk-guide-bob 2.2s ease-in-out infinite; }
.sk-guide__finger { font-size: 18px; }
@keyframes sk-guide-bob {
    0%,100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-46%) translateY(-7px); }
}

/* 信笺 */
.sk-letter {
    position: relative;
    width: min(86vw, 430px);
    opacity: 0;
    transform: translateY(26px) scale(.96);
    transition: opacity .6s ease, transform .65s cubic-bezier(.34,1.4,.52,1);
}
.sk-letter.is-in { opacity: 1; transform: none; }
.sk-letter.is-out {
    opacity: 0;
    transform: translateY(-30px) scale(.98);
    transition: opacity .6s ease, transform .6s ease;
}
.sk-letter__paper {
    position: relative;
    padding: clamp(26px, 5vmin, 40px) 30px clamp(30px,5.5vmin,44px);
    border-radius: 6px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.75), rgba(255,255,255,0) 12%),
        linear-gradient(160deg, #fffdf9, #fdf1ea);
    box-shadow:
        0 30px 70px -26px rgba(190, 80, 110, .38),
        inset 0 0 0 1px rgba(255,255,255,.7);
}
/* 信纸横格 */
.sk-letter__paper::before {
    content: "";
    position: absolute; inset: 0;
    border-radius: 6px;
    background-image: repeating-linear-gradient(
        transparent 0, transparent 35px,
        rgba(232,112,154,.1) 35px, rgba(232,112,154,.1) 36px);
    pointer-events: none;
}
.sk-letter__text {
    position: relative;
    font-family: var(--serif);
    font-size: clamp(19px, 2.8vmin, 24px);
    font-weight: 600;
    letter-spacing: 2px;
    line-height: 1.9;
    text-align: center;
    color: #8c4a5e;
    filter: blur(9px);
    opacity: .4;
    transform: scale(.98);
    transition: filter .65s ease, opacity .65s ease, transform .65s ease;
}
.sk-letter.is-open .sk-letter__text {
    filter: blur(0); opacity: 1; transform: none;
}
/* 朱印 */
.sk-letter__seal {
    position: absolute;
    right: 18px; bottom: 14px;
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 7px;
    background: linear-gradient(145deg, #e8709a, #d4527f);
    color: #fff;
    font-family: var(--serif);
    font-size: 15px;
    box-shadow: 0 6px 16px -6px rgba(212,82,127,.7);
    opacity: 0;
    transform: scale(.6) rotate(-12deg);
    transition: opacity .5s ease .25s, transform .5s cubic-bezier(.34,1.4,.52,1) .25s;
}
.sk-letter.is-open .sk-letter__seal { opacity: 1; transform: scale(1) rotate(-8deg); }

/* 花瓣覆盖层 */
.sk-cover { position: absolute; inset: -4px; z-index: 3; }
.sk-petal {
    position: absolute;
    width: 19px; height: 15px;
    border-radius: 100% 0 100% 0;
    transform: rotate(var(--r,0deg)) scale(var(--s,1));
    box-shadow: inset -2px -2px 4px rgba(255,255,255,.35),
                0 4px 8px -3px rgba(214,89,132,.35);
    animation: sk-petal-idle 3.2s ease-in-out infinite;
    will-change: transform;
}
@keyframes sk-petal-idle {
    0%,100% { transform: rotate(var(--r,0deg)) scale(var(--s,1)); }
    50% { transform: rotate(calc(var(--r,0deg) + 14deg)) scale(calc(var(--s,1) * 1.08)); }
}
.sk-letter.is-open .sk-cover { pointer-events: none; }

/* ============================================================
   场景三 · 心跳信号
   ============================================================ */
.hb-root {
    background:
        radial-gradient(90% 60% at 50% 115%, rgba(255,77,109,.14), transparent 65%),
        linear-gradient(180deg, #0b0b16 0%, #07070f 100%);
    --pulse: 0;
}
/* 心跳搏动时的全屏红韵 */
.hb-root::after {
    content: "";
    position: absolute; inset: 0; z-index: 4; pointer-events: none;
    background: radial-gradient(80% 60% at 50% 100%, rgba(255,77,109,.35), transparent 70%);
    opacity: calc(var(--pulse,0) * .55);
    transition: opacity 60ms linear;
}
.hb-grid {
    position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background-image:
        linear-gradient(rgba(120,140,255,.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(120,140,255,.05) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(80% 80% at 50% 50%, #000 30%, transparent 100%);
    -webkit-mask-image: radial-gradient(80% 80% at 50% 50%, #000 30%, transparent 100%);
}
.hb-canvas { z-index: 2; }

/* 句子流 */
.hb-feed {
    position: absolute;
    z-index: 5;
    top: 21%; left: 0; right: 0;
    display: flex; flex-direction: column; align-items: center;
    gap: 14px;
    padding: 0 24px;
    pointer-events: none;
}
.hb-card {
    max-width: min(82vw, 380px);
    padding: 12px 22px;
    border-radius: 12px;
    font-size: clamp(15px, 2.2vmin, 18px);
    font-weight: 600; letter-spacing: 1px;
    text-align: center;
    color: #eef1ff;
    background: linear-gradient(155deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
    border: 1px solid rgba(255,255,255,.1);
    border-left: 3px solid var(--hb-accent, #ff6b8a);
    box-shadow: 0 0 28px -8px var(--hb-accent, #ff6b8a),
                0 16px 40px -20px #000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(18px) scale(.95);
    transition: opacity .5s ease, transform .55s cubic-bezier(.34,1.4,.52,1);
}
.hb-card.is-in { opacity: 1; transform: none; }
.hb-card.is-out {
    opacity: 0;
    transform: translateY(-26px) scale(.96);
    transition: opacity .55s ease, transform .55s ease;
}

/* 底部控制区 */
.hb-bottom {
    position: absolute;
    z-index: 6;
    left: 0; right: 0;
    bottom: max(30px, calc(env(safe-area-inset-bottom) + 22px));
    display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.hb-hint {
    font-size: 12.5px; letter-spacing: 3px;
    color: rgba(190,198,230,.6);
}
.hb-actions { display: flex; align-items: center; justify-content: center; }
.hb-btn {
    position: relative;
    width: 88px; height: 88px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: radial-gradient(circle at 35% 30%, #ff7a95, #e11d48 70%);
    box-shadow: 0 18px 44px -12px rgba(225,29,72,.75), inset 0 2px 6px rgba(255,255,255,.35);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: transform .15s ease;
}
.hb-btn svg {
    position: relative; z-index: 2;
    width: 40px; height: 40px;
    fill: #fff;
    filter: drop-shadow(0 2px 4px rgba(120,0,20,.4));
}
.hb-btn.is-hold {
    transform: scale(.92);
    box-shadow: 0 10px 30px -10px rgba(225,29,72,.9), inset 0 4px 10px rgba(120,0,20,.35);
}
/* 扩散环 */
.hb-btn__ring {
    position: absolute; inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(255,77,109,.55);
    animation: hb-ring 1.6s ease-out infinite;
    pointer-events: none;
}
.hb-btn__ring::after {
    content: "";
    position: absolute; inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(255,77,109,.4);
    animation: hb-ring 1.6s ease-out .8s infinite;
}
@keyframes hb-ring {
    0% { transform: scale(.9); opacity: .8; }
    100% { transform: scale(1.55); opacity: 0; }
}
.hb-auto {
    font-size: 12px; letter-spacing: 3px;
    padding: 7px 18px;
    border-radius: 999px;
    color: rgba(190,198,230,.65);
    border: 1px solid rgba(190,198,230,.2);
    transition: color .3s ease, border-color .3s ease, background .3s ease;
}
.hb-auto.is-on {
    color: #ff8aa2;
    border-color: rgba(255,77,109,.45);
    background: rgba(255,77,109,.08);
}

/* 移动端微调 */
@media (max-width: 600px) {
    .hb-feed { top: 17%; gap: 10px; }
    .hb-card { padding: 10px 18px; }
    .hb-btn { width: 82px; height: 82px; }
    .sk-guide { top: calc(50% + 132px); }
}

/* ============================================================
   减弱动态
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .sr-nebula__b, .sr-note__float, .sr-note__card::before,
    .sk-petal, .sk-guide.is-on, .hb-btn__ring, .hb-btn__ring::after {
        animation: none !important;
    }
    .sk-letter__text { filter: none; opacity: .85; }
    .sk-letter.is-open .sk-letter__text { opacity: 1; }
}
