/* 首页封面：苹果树场景 */

.scene {
    position: relative;
    aspect-ratio: 16 / 9;
    /* 整棵树（连同草地上的小女孩）落在第一屏里：高度不超过屏幕减去标题区 */
    max-width: max(640px, calc((100svh - 316px) * 16 / 9));
    margin: 0 auto 64px;
}

.scene-bg {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(31, 29, 26, 0.06), 0 12px 32px rgba(31, 29, 26, 0.08);
}

.scene-art,
.scene-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scene.has-cover .scene-art {
    display: none;
}

/* 苹果 */
.apple {
    position: absolute;
    transform: translate(-50%, -50%);
    border: 0;
    border-radius: 50%;
    padding: 0;
    animation: sway 4s ease-in-out infinite;
    animation-delay: var(--sway-delay, 0s);
}

.apple::after {
    /* 小叶子 */
    content: '';
    position: absolute;
    top: -22%;
    left: 52%;
    width: 42%;
    height: 26%;
    border-radius: 0 100% 0 100%;
    background: #5f8f45;
}

.apple-project {
    width: clamp(18px, 3.4%, 40px);
    aspect-ratio: 1;
    cursor: pointer;
    background:
        radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.65) 0 12%, transparent 13%),
        radial-gradient(circle at 40% 40%, #ee6a55, #c8392c 70%);
    box-shadow: 0 3px 6px rgba(120, 30, 20, 0.3);
}

.apple-project:hover,
.apple-project.is-active,
.apple-project:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(255, 250, 240, 0.9), 0 0 0 7px rgba(200, 57, 44, 0.45);
    animation-play-state: paused;
}

/* 没有项目的苹果：小一点、青色、点不了 */
.apple-plain {
    width: clamp(10px, 2%, 24px);
    aspect-ratio: 1;
    pointer-events: none;
    background: radial-gradient(circle at 40% 40%, #d6e08a, #a3b856 75%);
    opacity: 0.9;
}

.apple.is-falling {
    animation: none;
}

@keyframes sway {
    0%, 100% { rotate: -4deg; }
    50% { rotate: 4deg; }
}

/* 苹果卡片 */
.apple-card {
    position: absolute;
    z-index: 5;
    display: flex;
    gap: 12px;
    width: min(320px, calc(100% - 16px));
    padding: 12px;
    border-radius: 12px;
    background: var(--cream);
    color: var(--ink);
    box-shadow: 0 10px 30px rgba(31, 29, 26, 0.18);
}

.apple-card[hidden] {
    display: none;
}

.card-thumb {
    flex: 0 0 88px;
    height: 88px;
    border-radius: 8px;
    overflow: hidden;
}

.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-thumb-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 6px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    line-height: 1.15;
    text-align: center;
    color: #1f1d1a;
}

.card-text {
    min-width: 0;
}

.card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    line-height: 1.3;
}

.card-summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.card-pick {
    margin-top: 8px;
    padding: 4px 12px;
    border: 0;
    border-radius: 999px;
    background: #c8392c;
    color: #fffaf0;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.card-pick:hover,
.card-pick:focus-visible {
    background: #a92e23;
}

/* 小女孩 */
.girl {
    position: absolute;
    bottom: 3%;
    z-index: 2;
    width: 7.5%;
    aspect-ratio: 120 / 200;
    transform: translate(-50%, 0);
    pointer-events: none;
}

.girl svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.girl.is-flipped svg {
    transform: scaleX(-1);
}

.girl.is-flipped .girl-img {
    transform: translateX(-50%) scaleX(-1);
}

/* 水彩小女孩图：两张都加载成功才替换 SVG */
.girl-img {
    position: absolute;
    bottom: 0;
    left: 50%;
    height: 100%;
    width: auto;
    max-width: none;
    transform: translateX(-50%);
    transform-origin: 50% 95%;
    transition: rotate 0.35s ease;
    display: none;
}

.girl.has-art svg {
    display: none;
}

.girl.has-art .girl-img-back,
.girl.has-art.is-front .girl-img-front {
    display: block;
}

.girl.has-art.is-front .girl-img-back {
    display: none;
}

.girl.is-bending .girl-img {
    rotate: 14deg;
}

.girl .girl-front,
.girl .girl-arms-hold {
    display: none;
}

.girl.is-front .girl-front,
.girl.is-front.has-apple .girl-arms-hold {
    display: inline;
}

.girl.is-front .girl-back,
.girl.is-front.has-apple .girl-arms-down {
    display: none;
}

.girl-upper {
    transform-origin: 60px 150px;
    transition: transform 0.35s ease;
}

.girl.is-bending .girl-upper {
    transform: rotate(28deg) translateY(10px);
}

.girl.is-walking svg,
.girl.is-walking .girl-img {
    animation: walk 0.36s ease-in-out infinite;
}

@keyframes walk {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -4%; }
}

@media (max-width: 800px) {
    .scene {
        margin-bottom: 40px;
    }

    .girl {
        width: 9%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apple {
        animation: none;
    }
}
