/* Dewdrop's Match Meadow — game styles.
   Loaded AFTER gamekit.css so it may override shared tokens. */

:root {
    --leaf: #8FD05A;
    --leaf-rim: #5E9A12;
    --well: #FFF8EC;
    --coral: #8A5A3C;
}

html, body { height: 100%; overflow: hidden; background: #CDEEFF; }

#stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    font-family: var(--gk-font);
}

/* ── Scene ────────────────────────────────────────────────────────────── */
#scene { position: absolute; inset: 0; z-index: 0; }
#scene svg { width: 100%; height: 100%; display: block; }

.cloud { animation: drift 60s linear infinite; }
.cloud-1 { animation-duration: 78s; }
.cloud-2 { animation-duration: 92s; }
@keyframes drift {
    from { transform: translateX(-160px) var(--s, ); }
    to   { transform: translateX(1440px); }
}
/* keep the scale from the inline transform by animating only a wrapper opacity instead */
.stream-glint { animation: glint 2.4s ease-in-out infinite; }
@keyframes glint { 0%,100% { opacity: 0.25; } 50% { opacity: 1; transform: scale(1.5); } }

/* ── Play area ────────────────────────────────────────────────────────── */
#play { position: absolute; inset: 0; z-index: 2; touch-action: none; }
#ribbon-layer, #fx-layer {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none; overflow: visible;
}
#ribbon-layer { z-index: 2; }
#nodes { position: absolute; inset: 0; z-index: 3; }
#fx-layer { z-index: 4; }

/* ── Leaf-pod node ────────────────────────────────────────────────────── */
.node {
    position: absolute;
    width: 120px; height: 120px;
    margin: -60px 0 0 -60px;         /* positioned by centre */
    cursor: pointer;
    touch-action: none;
    -webkit-user-select: none; user-select: none;
    transition: transform 0.18s ease;
}
.node .leaf {
    position: absolute; inset: 0;
    border-radius: 46% 54% 48% 52% / 54% 46% 54% 46%;
    background:
        radial-gradient(circle at 34% 30%, #B6E884 0%, var(--leaf) 52%, #79BE3C 100%);
    border: 4px solid var(--leaf-rim);
    box-shadow: 0 8px 18px rgba(60, 90, 20, 0.28), inset 0 -6px 10px rgba(94, 154, 18, 0.35);
    animation: breathe 3.4s ease-in-out infinite;
}
.node.right .leaf { border-radius: 54% 46% 52% 48% / 46% 54% 46% 54%; }
.node .vein {
    position: absolute; inset: 0; pointer-events: none;
}
.node .well {
    position: absolute; left: 14px; top: 12px; right: 14px; bottom: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 34%, #FFFFFF 0%, var(--well) 70%, #F4E7CC 100%);
    box-shadow: inset 0 3px 8px rgba(120, 90, 40, 0.22);
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.node .well svg { width: 96%; height: 96%; display: block; }

/* glowing bud connector on the inner edge */
.node .bud {
    position: absolute; top: 50%; width: 30px; height: 30px;
    margin-top: -15px; border-radius: 50%;
    background: radial-gradient(circle at 38% 34%, #FFF9D6, #FFD35C 60%, #F7A23B);
    border: 3px solid #E88A2A;
    box-shadow: 0 0 0 0 rgba(255, 211, 92, 0.7);
    animation: budpulse 1.8s ease-in-out infinite;
}
.node.left  .bud { right: -8px; }
.node.right .bud { left: -8px; }
@keyframes budpulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 211, 92, 0.55); }
    50%      { box-shadow: 0 0 0 10px rgba(255, 211, 92, 0); }
}
@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.035); }
}

.node.pop-in { animation: nodePop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) backwards; }
@keyframes nodePop {
    from { transform: scale(0) rotate(-14deg); opacity: 0; }
    to   { transform: scale(1) rotate(0); opacity: 1; }
}

/* selected (tap flow) */
.node.selected { transform: scale(1.08); z-index: 6; }
.node.selected .leaf { border-color: #FFB43C; box-shadow: 0 0 0 5px rgba(255, 211, 92, 0.6), 0 10px 22px rgba(60, 90, 20, 0.3); animation: none; }
.node.selected .bud { animation: none; box-shadow: 0 0 14px 6px rgba(255, 211, 92, 0.9); transform: scale(1.25); }

/* invite pulse on candidate right buds while dragging */
.node.invite .bud { animation: invite 0.7s ease-in-out infinite; }
@keyframes invite {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px 3px rgba(0,180,216,0.5); }
    50%      { transform: scale(1.35); box-shadow: 0 0 18px 8px rgba(0,180,216,0.75); }
}

.node.shake { animation: nodeShake 0.5s ease; }
@keyframes nodeShake {
    0%,100% { transform: translateX(0); }
    20% { transform: translateX(-7px) rotate(-3deg); }
    40% { transform: translateX(7px) rotate(3deg); }
    60% { transform: translateX(-5px) rotate(-2deg); }
    80% { transform: translateX(5px) rotate(2deg); }
}

/* locked / matched — contented dim glow, no longer draggable */
.node.matched { cursor: default; pointer-events: none; }
.node.matched .leaf {
    filter: saturate(0.9) brightness(1.02);
    border-color: #8FC24A;
    box-shadow: 0 0 0 4px rgba(255, 211, 92, 0.35), 0 6px 14px rgba(60,90,20,0.22);
    animation: none;
}
.node.matched .well { opacity: 0.9; }
.node.matched .bud { opacity: 0; }
.node.pop-match { animation: nodeMatch 0.5s cubic-bezier(0.2,1.5,0.4,1); }
@keyframes nodeMatch {
    0% { transform: scale(1); } 45% { transform: scale(1.14); } 100% { transform: scale(1); }
}

/* idle-hint glow on a still-open node */
.node.hint-glow .leaf { animation: hintGlow 1s ease-in-out infinite; }
@keyframes hintGlow {
    0%,100% { box-shadow: 0 8px 18px rgba(60,90,20,0.28); }
    50% { box-shadow: 0 0 0 7px rgba(181,101,216,0.5), 0 8px 20px rgba(60,90,20,0.3); }
}

/* win wiggle-dance */
.node.dance { animation: dance 0.7s ease-in-out; }
@keyframes dance {
    0%,100% { transform: rotate(0) translateY(0); }
    25% { transform: rotate(-8deg) translateY(-8px); }
    75% { transform: rotate(8deg) translateY(-4px); }
}

/* ── Bloom / ring fx ──────────────────────────────────────────────────── */
.bloom { transform-box: fill-box; transform-origin: center; }
.bloom .bloom-g { transform-box: fill-box; transform-origin: center; animation: bloomIn 0.55s cubic-bezier(0.2,1.6,0.4,1) backwards; }
@keyframes bloomIn { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
.bloom.spin .bloom-g { animation: bloomSpin 1.6s linear; }
@keyframes bloomSpin { to { transform: rotate(360deg); } }
.ring { fill: none; stroke: #FFD35C; stroke-width: 4; opacity: 0.9; transform-box: fill-box; transform-origin: center; animation: ringOut 0.7s ease-out forwards; }
@keyframes ringOut { from { transform: scale(0.2); opacity: 0.9; } to { transform: scale(1.8); opacity: 0; } }
.fxstar { transform-box: fill-box; transform-origin: center; animation: fxstar 0.7s ease-out forwards; }
@keyframes fxstar { from { transform: scale(0); opacity: 1; } to { transform: scale(1.4) translateY(-18px); opacity: 0; } }

/* ── Progress vine ────────────────────────────────────────────────────── */
#progress {
    position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
    display: flex; align-items: center; z-index: 5;
    background: rgba(255,255,255,0.55); border-radius: 40px; padding: 6px 14px;
    box-shadow: 0 4px 12px rgba(60,90,20,0.16);
}
#vine-line { display: none; }
#vine-buds { display: flex; gap: 10px; }
.vbud {
    width: 24px; height: 24px; border-radius: 50%;
    background: #DDEFC8; border: 2px solid #9CC96A;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; line-height: 1; transition: transform 0.3s;
}
.vbud.on { background: radial-gradient(circle at 40% 34%, #FFF3B0, #FFD35C); border-color: #E8A828; transform: scale(1.18); }
.vbud.on::after { content: '⭐'; }

/* ── Dewdrop mascot ───────────────────────────────────────────────────── */
#dewdrop-wrap {
    position: absolute; left: 12px; bottom: 8px; z-index: 6;
    width: 168px; height: 150px;
    pointer-events: none;
}
#dw-leaf {
    position: absolute; left: 6px; bottom: 2px; width: 150px; height: 42px;
    background: radial-gradient(ellipse at 50% 30%, #A2D96A, #6FAE2E);
    border: 3px solid var(--leaf-rim);
    border-radius: 50% 50% 46% 54% / 70% 70% 40% 40%;
    box-shadow: 0 6px 14px rgba(60,90,20,0.3);
    transform: rotate(-3deg);
}
#dw-leaf::before {
    content: ''; position: absolute; left: 50%; top: 8px; width: 60%; height: 2px;
    background: #5E9A12; opacity: 0.5; transform: translateX(-50%);
}
#dewdrop {
    position: absolute; left: 20px; bottom: 20px; width: 132px; height: 122px;
    transform-origin: 50% 100%;
    animation: dwIdleBob 3.6s ease-in-out infinite;
}
#dewdrop.hello { animation: dwHello 1.5s cubic-bezier(0.2,1.2,0.4,1); }
@keyframes dwHello {
    0% { transform: translateX(-220px) rotate(-12deg) scale(0.9); }
    60% { transform: translateX(10px) rotate(6deg) scale(1.03); }
    100% { transform: translateX(0) rotate(0) scale(1); }
}
@keyframes dwIdleBob { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-5px) rotate(-1deg); } }

#dewdrop.happy { animation: dwHappy 0.6s ease; }
@keyframes dwHappy {
    0%,100% { transform: translateY(0) scale(1,1); }
    30% { transform: translateY(4px) scale(1.1,0.9); }
    60% { transform: translateY(-14px) scale(0.93,1.1); }
}
#dewdrop.happy #dw-shell { animation: shellSpin 0.6s ease; }
@keyframes shellSpin { to { transform: rotate(360deg); } }
#dw-shell { transform-box: fill-box; transform-origin: center; }

#dewdrop.gentle #dw-body { animation: dwLean 0.9s ease; transform-box: fill-box; transform-origin: bottom center; }
@keyframes dwLean { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-7deg); } }

#dewdrop.win { animation: dwWin 1.4s ease-in-out; }
@keyframes dwWin {
    0% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(30px) rotate(10deg) translateY(-10px); }
    50% { transform: translateX(0) rotate(0) translateY(-16px); }
    75% { transform: translateX(-24px) rotate(-10deg) translateY(-8px); }
    100% { transform: translateX(0) rotate(0); }
}

/* eyestalk waggle + blink live on inner groups */
#dw-stalkL { transform-box: fill-box; transform-origin: bottom center; animation: waggleL 4s ease-in-out infinite; }
#dw-stalkR { transform-box: fill-box; transform-origin: bottom center; animation: waggleR 4.6s ease-in-out infinite; }
@keyframes waggleL { 0%,100% { transform: rotate(0); } 50% { transform: rotate(5deg); } }
@keyframes waggleR { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-5deg); } }
#dewdrop.blink .dw-pupil { animation: none; }
#dewdrop.blink #dw-stalkL, #dewdrop.blink #dw-stalkR { animation: blinkDip 0.28s ease; }
@keyframes blinkDip { 50% { transform: scaleY(0.6) translateY(4px); } }
.dw-drop-sparkle { transform-box: fill-box; transform-origin: center; animation: dropSpark 3s ease-in-out infinite; }
@keyframes dropSpark { 0%,100% { opacity: 0.3; transform: scale(0.7) rotate(0); } 50% { opacity: 1; transform: scale(1.1) rotate(40deg); } }
#dw-drop { transform-box: fill-box; transform-origin: 66px 44px; animation: dropWobble 2.6s ease-in-out infinite; }
@keyframes dropWobble { 0%,100% { transform: translateX(0) rotate(0); } 50% { transform: translateX(2px) rotate(4deg); } }
#dewdrop.fidget #dw-drop { animation: dropNudge 0.8s ease; }
@keyframes dropNudge { 0%,100% { transform: translateX(0) rotate(0); } 40% { transform: translate(6px,-4px) rotate(-12deg); } }

/* ── Speech bubble ────────────────────────────────────────────────────── */
#speech {
    position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
    width: min(66vw, 560px); text-align: center;
    background: #fff; color: var(--gk-text);
    border: 3px solid #B6E884;
    border-radius: 22px; padding: 12px 22px;
    font-size: clamp(1rem, 2.6vw, 1.4rem); font-weight: bold; line-height: 1.25;
    box-shadow: 0 8px 22px rgba(60,90,20,0.22);
    z-index: 8; pointer-events: none;
    animation: bubblePop 0.3s cubic-bezier(0.2,1.5,0.4,1);
}
#speech::after {   /* down-left tail, toward Dewdrop */
    content: ''; position: absolute; left: 64px; bottom: -16px;
    border: 11px solid transparent; border-top-color: #B6E884;
}
@keyframes bubblePop {
    from { opacity: 0; transform: translateX(-50%) scale(0.86) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* ── Start screen ─────────────────────────────────────────────────────── */
#start-screen {
    position: absolute; inset: 0; z-index: 20;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(circle at 50% 8%, rgba(255,255,255,0.35), transparent 55%),
        linear-gradient(180deg, rgba(205,238,255,0.55), rgba(255,246,230,0.35));
    backdrop-filter: blur(1px);
}
body.playing #start-screen { display: none; }
#start-inner { text-align: center; padding: 20px; max-width: 92vw; }
#game-title {
    display: flex; flex-direction: column; line-height: 1.02;
    font-size: clamp(2.2rem, 8vw, 4.2rem);
    color: #fff; -webkit-text-stroke: 2px #5E9A12;
    text-shadow: 0 5px 0 #5E9A12, 0 8px 14px rgba(0,0,0,0.18);
    margin-bottom: 6px;
}
#game-title .t1 { color: #FFD35C; -webkit-text-stroke: 2px #C98A1E; text-shadow: 0 4px 0 #C98A1E; }
#tagline { font-size: clamp(1rem, 3.4vw, 1.5rem); color: #4A6A1E; font-weight: bold; margin-bottom: 8px; }
#hello-dewdrop { width: 150px; height: 138px; margin: 0 auto 6px; }
#hello-dewdrop #dw-svg { animation: helloBob 2.4s ease-in-out infinite; }
@keyframes helloBob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
#btn-start { margin: 6px auto 16px; }

#level-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.lvl-btn {
    min-width: 108px; min-height: 88px; padding: 8px 12px;
    border: 3px solid #fff; border-radius: 22px; cursor: pointer;
    background: linear-gradient(160deg, #8FD05A, #6FAE2E);
    color: #fff; font-weight: bold; box-shadow: 0 6px 16px rgba(60,90,20,0.3);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    transition: transform 0.15s;
}
.lvl-btn:active { transform: scale(0.95); }
.lvl-btn .lvl-num {
    width: 40px; height: 40px; border-radius: 50%;
    background: #fff; color: #5E9A12; font-size: 1.5rem;
    display: flex; align-items: center; justify-content: center;
}
.lvl-btn .lvl-cap { font-size: 0.85rem; }
.lvl-btn.locked { background: linear-gradient(160deg, #C4C4C4, #9C9C9C); }
.lvl-btn.locked .lvl-num::after { content: '🔒'; font-size: 1rem; }
.lvl-btn.locked .lvl-num { color: transparent; }
.lvl-btn.current { outline: 4px solid #FFD35C; outline-offset: 2px; }

/* ── For grown-ups ────────────────────────────────────────────────────── */
#info-btn {
    position: fixed; left: 12px; top: 12px; z-index: 30;
    width: 56px; height: 56px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.92); font-size: 1.5rem; cursor: pointer;
    box-shadow: 0 4px 12px rgba(90,60,130,0.25);
}
#info-overlay {
    position: fixed; inset: 0; z-index: 60;
    display: flex; align-items: center; justify-content: center;
    background: rgba(74,59,92,0.45); padding: 16px;
    animation: gk-fade-in 0.3s;
}
#info-card { max-width: min(92vw, 520px); max-height: 88vh; overflow: auto; }
#info-card h2 { color: var(--gk-orange); margin-bottom: 8px; font-size: clamp(1.3rem, 4vw, 1.8rem); }
#info-card p { margin: 10px 0; font-size: clamp(0.95rem, 2.6vw, 1.12rem); line-height: 1.45; }
#info-close { margin-top: 12px; }

/* idle-hint dotted shimmer arc */
.hintarc { animation: hintarc 1s linear infinite; opacity: 0.9; }
@keyframes hintarc { to { stroke-dashoffset: -32; } }

/* win: giant rainbow dew-arc sweeps over the meadow */
.dewarc {
    stroke-dasharray: 2600; stroke-dashoffset: 2600;
    animation: dewsweep 1.1s ease-out forwards;
}
@keyframes dewsweep { to { stroke-dashoffset: 0; } }

/* win: rainbow wave shimmer travelling across the locked ribbons */
#locked.wave { animation: locwave 1.2s ease-in-out; }
@keyframes locwave {
    0%,100% { filter: brightness(1); }
    50% { filter: brightness(1.5) saturate(1.4); }
}

@media (prefers-reduced-motion: reduce) {
    .cloud, .stream-glint, .node .leaf, .node .bud, #dewdrop, #dw-stalkL, #dw-stalkR, #dw-drop, .dw-drop-sparkle { animation: none !important; }
}

/* short landscape (phones) — shrink chrome so nodes fit */
@media (max-height: 560px) {
    #dewdrop-wrap { transform: scale(0.8); transform-origin: left bottom; }
    #hello-dewdrop { width: 108px; height: 100px; }
}
