/* walk.css - 万歩計（page-walk.php 専用）。色は base.css のトークンに従う（白／黒どちらも）
 *
 * 歩く動き：#wk-stage[data-state="walking"] のときだけキャラの足・腕・体を動かし、背景を流す。
 * 1歩の速さは walk.js が --wk-cycle（2歩ぶんの秒数）に入れる。歩いた速さにキャラの足が合う。
 */

.wk { --wk-cycle: 1.1s; margin-bottom: var(--space-5); }
.wk [hidden] { display: none !important; }
.wk button, .wk input { font: inherit; color: inherit; }
.wk button { cursor: pointer; }
.wk :focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* 注意（いちばん上・目立たせる） */
.wk-notice { margin: 0 0 var(--space-2); padding: 14px 16px; border: 1px solid #f08c00; border-left-width: 5px; border-radius: var(--radius-md); background: rgba(255, 169, 77, 0.12); }
.wk-notice__title { margin: 0 0 6px; font-weight: 700; color: #d9480f; }
.wk-notice ul { margin: 0; padding-left: 1.2em; font-size: 0.9rem; line-height: 1.7; }
.wk-notice li + li { margin-top: 2px; }
html:not([data-theme="light"]) .wk-notice__title { color: #ffa94d; }

/* 舞台（キャラと背景） */
.wk-stage { position: relative; height: 250px; overflow: hidden; border-radius: 14px; border: 1px solid var(--color-border); }
.wk-scene, .wk-scene > div { position: absolute; inset: 0; }
.wk-sky { background: linear-gradient(180deg, #a5d8ff 0%, #e7f5ff 70%); }
.wk-scene .wk-far {
    top: auto; height: 120px; bottom: 42px;
    /* 遠くの丘と木。横に繰り返して流す */
    background:
        radial-gradient(18px 26px at 60px 74px, #69db7c 98%, transparent) 0 0 / 240px 120px repeat-x,
        radial-gradient(14px 20px at 170px 84px, #8ce99a 98%, transparent) 0 0 / 240px 120px repeat-x,
        linear-gradient(#b2f2bb, #b2f2bb) 0 100% / 100% 22px no-repeat,
        radial-gradient(160px 60px at 120px 120px, #d3f9d8 98%, transparent) 0 0 / 320px 120px repeat-x;
}
.wk-scene .wk-ground {
    top: auto; height: 44px;
    background:
        repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.09) 0 26px, transparent 26px 60px) 0 14px / 60px 4px repeat-x,
        linear-gradient(#e9d8a6, #dcc48c);
}
html:not([data-theme="light"]) .wk-sky { background: linear-gradient(180deg, #1b2a4a 0%, #2b3e66 75%); }
html:not([data-theme="light"]) .wk-far {
    background:
        radial-gradient(18px 26px at 60px 74px, #2f6b3c 98%, transparent) 0 0 / 240px 120px repeat-x,
        radial-gradient(14px 20px at 170px 84px, #387a46 98%, transparent) 0 0 / 240px 120px repeat-x,
        linear-gradient(#2b5a36, #2b5a36) 0 100% / 100% 22px no-repeat,
        radial-gradient(160px 60px at 120px 120px, #244a2e 98%, transparent) 0 0 / 320px 120px repeat-x;
}
html:not([data-theme="light"]) .wk-ground { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 26px, transparent 26px 60px) 0 14px / 60px 4px repeat-x, linear-gradient(#5c5040, #4a4034); }

.wk-walker { position: absolute; left: 50%; bottom: 20px; width: 190px; transform: translateX(-50%); }
.wk-char { display: block; width: 100%; height: auto; overflow: visible; }

.wk-bubble {
    position: absolute; left: 50%; top: 12px; transform: translateX(-50%); margin: 0; padding: 6px 14px;
    max-width: calc(100% - 24px); border-radius: 999px; background: rgba(255, 255, 255, 0.92); color: #1f2328;
    font-size: 0.88rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* キャラの部品。回転の中心は make_walker.py の座標（肩 52,87／85,87、腰 61,104／76,104） */
.wk-char g { transform-box: view-box; }
.wk-leg--l { transform-origin: 61px 104px; }
.wk-leg--r { transform-origin: 76px 104px; }
.wk-arm--l { transform-origin: 52px 87px; }
.wk-arm--r { transform-origin: 85px 87px; }
.wk-head { transform-origin: 68.5px 82px; }
.wk-face--joy { display: none; }
.wk-stage[data-state="goal"] .wk-face--calm,
.wk-stage.is-goal .wk-face--calm { display: none; }
.wk-stage[data-state="goal"] .wk-face--joy,
.wk-stage.is-goal .wk-face--joy { display: inline; }

/* 歩いているとき */
.wk-stage[data-state="walking"] .wk-bob { animation: wk-bob calc(var(--wk-cycle) / 2) ease-in-out infinite; }
.wk-stage[data-state="walking"] .wk-leg--l { animation: wk-step var(--wk-cycle) ease-in-out infinite; }
.wk-stage[data-state="walking"] .wk-leg--r { animation: wk-step var(--wk-cycle) ease-in-out infinite; animation-delay: calc(var(--wk-cycle) / -2); }
.wk-stage[data-state="walking"] .wk-arm--l { animation: wk-swing var(--wk-cycle) ease-in-out infinite; animation-delay: calc(var(--wk-cycle) / -2); }
.wk-stage[data-state="walking"] .wk-arm--r { animation: wk-swing-r var(--wk-cycle) ease-in-out infinite; }
.wk-stage[data-state="walking"] .wk-head { animation: wk-nod var(--wk-cycle) ease-in-out infinite; }
.wk-stage[data-state="walking"] .wk-far { animation: wk-scroll-far calc(var(--wk-cycle) * 8) linear infinite; }
.wk-stage[data-state="walking"] .wk-ground { animation: wk-scroll-ground var(--wk-cycle) linear infinite; }
.wk-stage[data-state="walking"] .wk-shadow { animation: wk-shadow calc(var(--wk-cycle) / 2) ease-in-out infinite; }

/* 待っているとき（足を止めて、ゆっくり呼吸） */
.wk-stage[data-state="idle"] .wk-bob,
.wk-stage[data-state="paused"] .wk-bob { animation: wk-breathe 2.6s ease-in-out infinite; }
.wk-stage[data-state="paused"] .wk-head { transform: rotate(-4deg); }

/* 目標を達成したとき */
.wk-stage[data-state="goal"] .wk-bob { animation: wk-jump 0.6s ease-in-out infinite; }
.wk-stage[data-state="goal"] .wk-arm--l { transform: rotate(150deg); }
.wk-stage[data-state="goal"] .wk-arm--r { transform: rotate(-150deg); }

@keyframes wk-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes wk-step {
    0%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-7px) rotate(-6deg); }
    50% { transform: translateY(0) rotate(0); }
}
@keyframes wk-swing { 0%, 100% { transform: rotate(-22deg); } 50% { transform: rotate(18deg); } }
@keyframes wk-swing-r { 0%, 100% { transform: rotate(22deg); } 50% { transform: rotate(-18deg); } }
@keyframes wk-nod { 0%, 50%, 100% { transform: rotate(0); } 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
@keyframes wk-scroll-far { to { background-position: -240px 0, -240px 0, 0 100%, -320px 0; } }
@keyframes wk-scroll-ground { to { background-position: -60px 14px, 0 0; } }
@keyframes wk-shadow { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(0.9); } }
@keyframes wk-breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.5px); } }
@keyframes wk-jump { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.wk-shadow { transform-box: view-box; transform-origin: 68.5px 124.5px; }

@media (prefers-reduced-motion: reduce) {
    .wk-stage * { animation: none !important; }
}

/* 数字 */
.wk-count { margin: var(--space-2) 0; text-align: center; }
.wk-steps { margin: 0; font-size: clamp(3rem, 14vw, 4.4rem); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.wk-steps small { margin-left: 4px; font-size: 1.1rem; font-weight: 700; color: var(--color-text-muted); }
.wk-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; }
.wk-stats div { padding: 8px 4px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg-elevated); }
.wk-stats dt { font-size: 0.75rem; color: var(--color-text-muted); }
.wk-stats dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.wk-goal { margin-top: 14px; }
.wk-goal__bar { height: 10px; border-radius: 999px; background: var(--color-border); overflow: hidden; }
.wk-goal__bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #40c057, #12b886); transition: width 0.4s; }
.wk-goal__text { margin: 6px 0 0; font-size: 0.85rem; color: var(--color-text-muted); }

/* ボタン */
.wk-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.wk-btn { min-height: 52px; padding: 0 22px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-bg-elevated); font-weight: 700; }
.wk-btn:hover { border-color: var(--color-accent); }
.wk .wk-btn--main { min-width: 220px; border-color: #2f9e44; background: #2f9e44; color: #fff; font-size: 1.05rem; }
.wk .wk-btn--main:hover { background: #2b8a3e; }

.wk-message { margin: 14px 0 0; padding: 10px 14px; border-radius: var(--radius-md); background: rgba(77, 171, 247, 0.12); border: 1px solid rgba(77, 171, 247, 0.5); font-size: 0.9rem; }
.wk-message.is-warn { background: rgba(255, 169, 77, 0.14); border-color: #f08c00; }

/* 設定 */
.wk-settings { margin-top: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg-elevated); }
.wk-settings summary { padding: 12px 14px; cursor: pointer; font-weight: 700; }
.wk-settings__body { display: grid; gap: 14px; padding: 0 14px 14px; }
.wk-field { display: grid; gap: 4px; }
.wk-field span { font-size: 0.8rem; color: var(--color-text-muted); }
.wk-field input { width: 100%; max-width: 200px; min-height: 44px; padding: 0 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg); font-size: 16px; }
.wk-field small { font-size: 0.78rem; color: var(--color-text-muted); }

/* 記録 */
.wk-history { margin-top: var(--space-2); }
.wk-history__title { margin: 0 0 6px; font-size: 1.05rem; }
.wk-today { margin: 0 0 8px; }
.wk-today strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.wk-list { margin: 0; padding: 0; list-style: none; }
.wk-list li { display: flex; justify-content: space-between; gap: 8px; padding: 10px 2px; border-bottom: 1px solid var(--color-border); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.wk-list li span:last-child { color: var(--color-text-muted); }
.wk-list .wk-empty { justify-content: center; color: var(--color-text-muted); }
.wk-history__note { margin: 8px 0 0; font-size: 0.78rem; color: var(--color-text-muted); }
