/* 迷你幼儿园 Web3D Demo */
body:has(.kg-page) {
    background:
        radial-gradient(120% 80% at 10% 0%, #dff4ff 0%, transparent 55%),
        radial-gradient(90% 70% at 100% 10%, #ffe8d4 0%, transparent 50%),
        linear-gradient(180deg, #eaf7ff 0%, #f7fbff 45%, #eef6ea 100%);
}

body:has(.kg-page) .content {
    max-width: none;
    padding: 0;
    margin: 0;
}

body:has(.kg-page) .footer {
    display: none;
}

.kg-page {
    --kg-ink: #3a3128;
    --kg-muted: #7a6e62;
    --kg-coral: #ff8f7a;
    --kg-mint: #7ec8b3;
    --kg-sky: #6eb6e8;
    --kg-sun: #ffd66b;
    --kg-cream: #fff8f0;
    --kg-line: rgba(58, 49, 40, 0.12);
    font-family: "Nunito", "Microsoft YaHei", sans-serif;
    color: var(--kg-ink);
    min-height: calc(100vh - var(--site-header-h, 64px));
    min-height: calc(100dvh - var(--site-header-h, 64px));
}

.kg-stage {
    position: relative;
    width: 100%;
    height: calc(100vh - var(--site-header-h, 64px));
    height: calc(100dvh - var(--site-header-h, 64px));
    overflow: hidden;
    background: linear-gradient(180deg, #b8e0f5 0%, #e8f6ff 55%, #d8efc8 100%);
    cursor: grab;
    outline: none;
    touch-action: none;
}

.kg-stage:active {
    cursor: grabbing;
}

.kg-canvas {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: scale(1.04);
    transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.kg-stage.is-ready .kg-canvas {
    opacity: 1;
    transform: scale(1);
}

.kg-loader {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 214, 107, 0.35), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(126, 200, 179, 0.3), transparent 45%),
        linear-gradient(160deg, #eaf7ff, #fff6ea);
    transition: opacity 0.55s ease, visibility 0.55s ease;
}

.kg-loader.is-done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none !important;
}

.kg-stage.is-ready .kg-loader {
    display: none !important;
    pointer-events: none !important;
}

.kg-loader-card {
    text-align: center;
    padding: 28px 32px;
    max-width: 360px;
}

.kg-loader-orbit {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    border: 3px solid rgba(255, 143, 122, 0.25);
    border-top-color: var(--kg-coral);
    animation: kg-spin 0.9s linear infinite;
}

.kg-loader-brand {
    margin: 0 0 6px;
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--kg-coral);
}

.kg-loader-card h1 {
    margin: 0 0 8px;
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: clamp(1.6rem, 4vw, 2.1rem);
    font-weight: 600;
}

.kg-loader-tip {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--kg-muted);
}

.kg-loader-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(58, 49, 40, 0.08);
    overflow: hidden;
}

.kg-loader-bar i {
    display: block;
    height: 100%;
    width: 8%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--kg-coral), var(--kg-sun), var(--kg-mint));
    transition: width 0.35s ease;
}

.kg-topbar {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 30;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}

.kg-brand-block,
.kg-top-actions {
    pointer-events: auto;
}

.kg-eyebrow {
    margin: 0 0 2px;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(58, 49, 40, 0.55);
}

.kg-title {
    display: inline-block;
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: clamp(1.15rem, 2.5vw, 1.55rem);
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 14px;
    background: rgba(255, 248, 240, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid var(--kg-line);
    box-shadow: 0 8px 24px rgba(58, 49, 40, 0.06);
}

.kg-top-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.kg-chip,
.kg-hotspots button {
    appearance: none;
    border: 1px solid var(--kg-line);
    background: rgba(255, 248, 240, 0.9);
    backdrop-filter: blur(8px);
    color: var(--kg-ink);
    font-family: inherit;
    font-weight: 700;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.kg-chip:hover,
.kg-hotspots button:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 143, 122, 0.45);
}

.kg-chip-accent,
.kg-chip.is-on,
.kg-hotspots button.is-active {
    background: linear-gradient(135deg, #ffe0d6, #fff4cc);
    border-color: rgba(255, 143, 122, 0.5);
    color: #a14a38;
}

.kg-hotspots {
    position: absolute;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: min(920px, calc(100% - 24px));
    padding: 8px;
    border-radius: 20px;
    background: rgba(255, 248, 240, 0.72);
    backdrop-filter: blur(10px);
    border: 1px solid var(--kg-line);
    pointer-events: auto;
}

.kg-hint {
    position: absolute;
    top: 78px;
    left: 14px;
    z-index: 7;
    max-width: 280px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(6px);
    border: 1px solid var(--kg-line);
    pointer-events: none;
}

.kg-hint p {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--kg-muted);
}

.kg-label {
    position: absolute;
    z-index: 9;
    transform: translate(-50%, -120%);
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 252, 247, 0.95);
    border: 1px solid rgba(255, 143, 122, 0.45);
    box-shadow: 0 10px 24px rgba(58, 49, 40, 0.12);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
}

.kg-fallback {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: none;
    place-items: center;
    padding: 24px;
    background: rgba(247, 251, 255, 0.92);
    text-align: center;
}

/* 勿用 display:grid 覆盖 [hidden]，否则成功渲染仍会挡住场景 */
.kg-fallback[hidden] {
    display: none !important;
}

.kg-stage.is-fallback .kg-fallback,
.kg-fallback.is-visible {
    display: grid;
}

.kg-stage.is-fallback .kg-loader {
    display: none;
}

@keyframes kg-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
    .kg-hint {
        display: none;
    }

    .kg-hotspots {
        bottom: 12px;
        gap: 6px;
    }

    .kg-hotspots button,
    .kg-chip {
        padding: 7px 11px;
        font-size: 12px;
    }

    .kg-topbar {
        top: 10px;
        left: 10px;
        right: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kg-canvas,
    .kg-loader,
    .kg-chip,
    .kg-hotspots button {
        transition: none;
    }

    .kg-loader-orbit {
        animation: none;
    }
}
