/* ============================================================
   KANAU · GroveTree（kanau-grove-tree.js）の見た目
   季節は .gt[data-season] の 1 つの値だけで変わる。木全体には filter をかけず、
   葉の房（tone 0–3 × 季節）・見える房（data-r）・花・地面・落ちるもの・光を、それぞれの layer で変える。
   ============================================================ */

/* ---- 置き場所（Home の Grove）。木と前景は同じ箱に重なる。大きさは Level と無関係 ---- */
#home-overview .grove-hero .grove-tree,
#home-overview .grove-hero .grove-tree-front {
    aspect-ratio: 420 / 380;
    bottom: 6px;
    left: 50%;
    pointer-events: none;
    position: absolute;
    transform: translateX(-50%);
    width: min(420px, 94%);
    --grove-x: -50%;   /* 元の groveFadeUp は transform を上書きするので、中央寄せをこの変数で渡す */
}
#home-overview .grove-hero .grove-tree { z-index: 2; animation: groveFadeUp 700ms ease 150ms both; }
#home-overview .grove-hero .grove-tree-front { z-index: 7; animation: groveFadeUp 700ms ease 150ms both; }
.gt .gt-svg { display: block; height: 100%; inset: 0; overflow: visible; position: absolute; width: 100%; }

/* ---- 光（木の後ろ。季節で色が変わる。段階が上がるときだけ少し強く） ---- */
.gt .gt-glow {
    background: radial-gradient(ellipse 48% 42% at 50% 42%, var(--glow, rgba(255, 238, 186, .9)), rgba(255, 238, 186, 0) 70%);
    inset: 6% -4% 16%;   /* 樹冠の内側だけ（上へはみ出さない：scroll して top bar の下に入っても光が透けない） */
    opacity: .32;
    position: absolute;
    transition: opacity 1.4s ease, background 1.2s ease;
    animation: gtGlow 9s ease-in-out infinite alternate;
}
.gt[data-season="spring"] { --glow: rgba(246, 246, 214, .95); }
.gt[data-season="summer"] { --glow: rgba(255, 236, 178, .95); }
.gt[data-season="autumn"] { --glow: rgba(255, 216, 160, .95); }
.gt[data-season="winter"] { --glow: rgba(226, 236, 244, .95); }
#home-overview .grove-hero.is-warming .gt .gt-glow { animation: none; opacity: 1; }

/* ---- 幹・枝（左から光） ---- */
.gt .gt-bark { fill: #8d6745; }
.gt .gt-twig { fill: #84603f; }
.gt .gt-bark-shade { fill: #6c4c31; opacity: .6; }
.gt .gt-bark-light { fill: #b28d64; opacity: .6; }
.gt .gt-bark-line { fill: none; opacity: .3; stroke: #4f321d; stroke-linecap: round; stroke-width: 1.4; }
.gt .gt-knot { fill: #4f321d; opacity: .7; }
.gt .gt-frost { fill: none; opacity: 0; stroke: #f7fbfd; stroke-linecap: round; stroke-width: 2.2; transition: opacity 1.2s ease; }
.gt[data-season="winter"] .gt-frost { opacity: .85; }
.gt[data-season="winter"] .gt-bark { fill: #846247; }

/* ---- 葉の塊：影 / 地 / 光 / 葉の筋。季節 × tone（0 手前の濃い塊 … 3 樹冠のいちばん上）。参照画像の柔らかな黄緑を目標に ---- */
.gt .gt-mass { transition: opacity 1.4s ease; }
.gt .gt-back { opacity: .94; }
.gt[data-season="summer"] .gt-mass[data-tone="0"] { --ls: #557a3e; --lb: #789c4f; --lh: #a7bf68; --ld: #42612f; }
.gt[data-season="summer"] .gt-mass[data-tone="1"] { --ls: #5f8443; --lb: #86a756; --lh: #b8c973; --ld: #4a6b35; }
.gt[data-season="summer"] .gt-mass[data-tone="2"] { --ls: #789c52; --lb: #9cb862; --lh: #cbd585; --ld: #5f8443; }
.gt[data-season="summer"] .gt-mass[data-tone="3"] { --ls: #86a656; --lb: #aec46a; --lh: #dcdd92; --ld: #6a8e48; }
/* spring：淡い若葉、少し透ける */
.gt[data-season="spring"] .gt-mass[data-tone="0"] { --ls: #7fae5f; --lb: #a0c67a; --lh: #cbe3a0; --ld: #679448; }
.gt[data-season="spring"] .gt-mass[data-tone="1"] { --ls: #8db96a; --lb: #acd086; --lh: #d6eab0; --ld: #73a052; }
.gt[data-season="spring"] .gt-mass[data-tone="2"] { --ls: #a3c87f; --lb: #c0dc9b; --lh: #e3f1c4; --ld: #86b063; }
.gt[data-season="spring"] .gt-mass[data-tone="3"] { --ls: #b1d18c; --lb: #cde4a8; --lh: #ecf5d2; --ld: #94bb70; }
.gt[data-season="spring"] .gt-canopy { opacity: .92; }
/* autumn：木そのものが秋（黄土・金・橙。緑は残さない） */
.gt[data-season="autumn"] .gt-mass[data-tone="0"] { --ls: #8c7a35; --lb: #ad9a45; --lh: #cfbd68; --ld: #6e5f28; }
.gt[data-season="autumn"] .gt-mass[data-tone="1"] { --ls: #b07a2c; --lb: #d39a3c; --lh: #ecc066; --ld: #8a5d1f; }
.gt[data-season="autumn"] .gt-mass[data-tone="2"] { --ls: #c0802f; --lb: #dfa24a; --lh: #f0c674; --ld: #955f22; }
.gt[data-season="autumn"] .gt-mass[data-tone="3"] { --ls: #b45a2c; --lb: #d77a3e; --lh: #efa060; --ld: #8b4220; }
.gt[data-season="winter"] .gt-mass { --ls: #9c7a52; --lb: #b8946a; --lh: #d2b48a; --ld: #7a5a3c; }

/* 葉の量：夏は全部 / 春は若い（いくつかの塊がまだ無い）/ 秋は減って枝が見える / 冬は枝だけ */
.gt[data-season="spring"] .gt-mass:not([data-keep*="s"]),
.gt[data-season="autumn"] .gt-mass:not([data-keep*="a"]),
.gt[data-season="winter"] .gt-mass { opacity: 0; }
.gt[data-season="autumn"] .gt-edge[data-k="2"], .gt[data-season="autumn"] .gt-edge[data-k="3"],
.gt[data-season="spring"] .gt-edge[data-k="3"] { opacity: 0; }

/* 春だけ：つぼみ・花 */
.gt .gt-spring { opacity: 0; transition: opacity 1.4s ease; }
.gt[data-season="spring"] .gt-spring { opacity: 1; }
.gt .gt-bud { fill: #f2b8c4; }
.gt .gt-blossom { --bp: #fbe4e9; --bc: #eab650; }

/* ---- 地面 ---- */
.gt .gt-mound { fill: var(--g-base); transition: fill 1.2s ease; }
.gt .gt-mound-light { fill: var(--g-light); transition: fill 1.2s ease; }
.gt .gt-mound-shade { fill: var(--g-shade); transition: fill 1.2s ease; }
.gt[data-season="spring"] { --g-base: #c6dba0; --g-light: #dcebbd; --g-shade: #aecb88; --grass: #8fbf63; --grass-d: #6fa04b; --plant: #8fbf63; }
.gt[data-season="summer"] { --g-base: #b7cf8e; --g-light: #cfe0a8; --g-shade: #9bb874; --grass: #6f9d4c; --grass-d: #557f39; --plant: #648f44; }
.gt[data-season="autumn"] { --g-base: #cfc894; --g-light: #e2dbad; --g-shade: #b8ae78; --grass: #a8a45a; --grass-d: #8b8444; --plant: #b49a4c; }
.gt[data-season="winter"] { --g-base: #dfe4e0; --g-light: #f2f5f3; --g-shade: #c9d0cc; --grass: #a3ad94; --grass-d: #8c977e; --plant: #9aa38c; }
.gt .gt-grass { fill: var(--grass); transition: opacity 1.2s ease, fill 1.2s ease; }
.gt .gt-grass:nth-child(odd) { fill: var(--grass-d); }
.gt[data-season="autumn"] .gt-grass[data-r="8"], .gt[data-season="autumn"] .gt-grass[data-r="9"],
.gt[data-season="winter"] .gt-grass:not([data-r="0"]):not([data-r="1"]):not([data-r="2"]):not([data-r="3"]) { opacity: 0; }
/* 野の花：春は多く、夏は少し、秋冬は無し */
.gt .gt-flower { opacity: 0; transition: opacity 1.2s ease; }
.gt .gt-flower[data-tone="1"] { --fp: #f7dfe6; } .gt .gt-flower[data-tone="2"] { --fp: #fbf1c9; }
.gt[data-season="spring"] .gt-flower { opacity: 1; }
.gt[data-season="summer"] .gt-flower[data-r="0"], .gt[data-season="summer"] .gt-flower[data-r="3"], .gt[data-season="summer"] .gt-flower[data-r="6"] { opacity: 1; }
/* 落ち葉：秋だけ根元に */
.gt .gt-fallen { opacity: 0; transition: opacity 1.2s ease; }
.gt .gt-fallen[data-tone="0"] { --leaf: #c4672e; } .gt .gt-fallen[data-tone="1"] { --leaf: #d0a53f; }
.gt .gt-fallen[data-tone="2"] { --leaf: #c98a35; } .gt .gt-fallen[data-tone="3"] { --leaf: #b5552c; }
.gt[data-season="autumn"] .gt-fallen { opacity: .95; }
.gt[data-season="winter"] .gt-fallen[data-tone="1"] { --leaf: #a88a63; opacity: .55; }
/* 石：苔は春夏、雪は冬 */
.gt .gt-rock .r { fill: #bab3a5; } .gt .gt-rock .rh { fill: #dcd6c8; opacity: .75; }
.gt .gt-rock .rsnow, .gt .gt-snow { fill: #fbfdff; opacity: 0; transition: opacity 1.2s ease; }
.gt[data-season="winter"] .gt-rock .rsnow { opacity: .95; }
.gt[data-season="winter"] .gt-snow { opacity: .9; }

/* ---- 揺れ：樹冠だけ、根元を中心にごく小さく（枝と地面は動かない）。pointer の風（--grove-sway）も足す ---- */
.gt .gt-canopy {
    transform: rotate(calc(var(--grove-sway, 0deg) * .5));
    transform-box: view-box;
    transform-origin: 180px 346px;
    transition: transform 900ms cubic-bezier(.2, .7, .2, 1), opacity 1.2s ease;
}
.gt .gt-back { animation: gtSway 8s ease-in-out infinite alternate; }
.gt .gt-mid { animation: gtSway 7s ease-in-out -2s infinite alternate; }
.gt .gt-front { animation: gtSway 6.2s ease-in-out -4s infinite alternate; }
.gt[data-season="winter"] .gt-canopy { animation-duration: 14s; }
#home-overview .grove-hero.is-rustling .gt .gt-canopy { animation: gtRustle 1.1s ease-in-out 2; }
.gt .gt-ground-front .gt-grass { transform-box: fill-box; transform-origin: 50% 100%; animation: gtGrass 5.5s ease-in-out infinite alternate; }

/* ---- 落ちるもの：木の箱いっぱいの層（左右も上下も木と同じ座標）。1 枚ずつの動きは JS（WAAPI） ---- */
#home-overview .grove-hero .grove-tree .gt-fall,
.gt .gt-fall-front { height: 100%; inset: 0; overflow: visible; pointer-events: none; position: absolute; width: 100%; z-index: 3; }
.gt .gt-fall .grove-fall-item { margin: -6px 0 0 -6px; position: absolute; will-change: transform; }
.gt .gt-fall .grove-fall-item svg { display: block; height: 100%; width: 100%; }
#home-overview .grove-hero .gt-fall[data-kind="snow"] .grove-fall-item,
.gt[data-season="winter"] .gt-fall-front .grove-fall-item { filter: drop-shadow(0 0 2px rgba(150, 170, 180, .5)); }

/* ---- スマホ：構図はそのまま。小さな飾りだけ省く ---- */
@media (max-width: 640px) {
    #home-overview .grove-hero .grove-tree,
    #home-overview .grove-hero .grove-tree-front { width: min(360px, 96%); }
    .gt [data-minor="1"] { display: none; }
}

@keyframes gtSway { 0% { rotate: -.45deg; } 100% { rotate: .5deg; } }
@keyframes gtRustle { 0%, 100% { rotate: 0deg; } 25% { rotate: -1.4deg; } 70% { rotate: 1.1deg; } }
@keyframes gtGrass { 0% { rotate: -2deg; } 100% { rotate: 2.5deg; } }
@keyframes gtGlow { 0% { opacity: .3; } 100% { opacity: .5; } }

@media (prefers-reduced-motion: reduce) {
    .gt *, .gt *::before, .gt *::after { animation: none !important; transition: none !important; }
    #home-overview .grove-hero .gt-fall, .gt .gt-fall-front { display: none; }
}
