/* 意味のある動き。色・字・寸法は既存の部品を使い、動かすのは transform / opacity だけ。 */
:root {
  --dur-fast: 150ms;
  --dur-base: var(--dur-2);
  --dur-row: 200ms;
  --dur-sheet: var(--dur-3);
  --dur-exit: 250ms;
  --ease-in: cubic-bezier(.4, 0, 1, 1);
}

/* 主操作は1px沈むだけ。ラベルとヒット領域の大きさは変えない。 */
html body :is(.btn, .k-btn, .toggle i, .seg-item span) { transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out); }
html body :is(.btn-main, .btn-cta, .k-btn-main):active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(1px); }
html body .toggle i::after { transition: transform var(--dur-base) var(--ease-out); }
html body [aria-invalid="true"]:is(input, textarea, select) { animation: motion-error var(--dur-row) var(--ease-out); }
@keyframes motion-error { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-3px); } 65% { transform: translateX(3px); } }
@keyframes motion-fade { from { opacity: 0; } to { opacity: 1; } }

/* チェックは右下に2画で現れる。読み上げは既存の成功通知が担当する。 */
html body .motion-success { position: relative; }
.motion-check { display: inline-block; position: relative; width: 14px; height: 14px; color: var(--brand-text); }
html body .motion-success .motion-check { position: absolute; right: 4px; bottom: 4px; color: inherit; }
.motion-complete .motion-check { margin-left: var(--sp-8); }
.motion-check i { position: absolute; overflow: hidden; height: 2px; transform-origin: left center; }
.motion-check i:first-child { left: 1px; top: 6px; width: 5px; transform: rotate(45deg); }
.motion-check i:last-child { left: 4px; top: 10px; width: 11px; transform: rotate(-45deg); }
.motion-check b { display: block; width: 100%; height: 100%; background: currentColor; animation: motion-check var(--dur-fast) var(--ease-out) both; }
.motion-check i:last-child b { animation-delay: calc(var(--dur-fast) / 3); }
@keyframes motion-check { from { transform: translateX(-100%); opacity: 0; } to { transform: none; opacity: 1; } }
.motion-wish-dot { position: fixed; top: 0; left: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); pointer-events: none; z-index: 120; }

/* dialog の古い translate と animation を置き換え、入る/出るを同じ軸でつなぐ。 */
html body dialog:not(.still) { animation: motion-sheet-in var(--dur-sheet) var(--ease-out) both; }
html body dialog.still { animation: none; }
html body dialog::backdrop { animation: motion-fade var(--dur-sheet) var(--ease-out); }
@keyframes motion-sheet-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
html body dialog.motion-sheet-exit { position: fixed; inset: 0; height: fit-content; z-index: 110; pointer-events: none; animation: motion-sheet-out var(--dur-exit) var(--ease-in) both; }
.motion-exit-scrim { position: fixed; inset: 0; z-index: 100; pointer-events: none; background: color-mix(in srgb, var(--label) 28%, transparent); animation: motion-fade-out var(--dur-exit) var(--ease-in) both; }
@keyframes motion-sheet-out { to { opacity: 0; transform: translateY(16px); } }
@keyframes motion-fade-out { to { opacity: 0; } }
@media (max-width: 699px) {
  @keyframes motion-sheet-in { from { opacity: .6; transform: translateY(100%); } to { opacity: 1; transform: none; } }
  @keyframes motion-sheet-out { to { opacity: 0; transform: translateY(100%); } }
}

html body #toast { top: calc(var(--bar-h, 56px) + env(safe-area-inset-top) + var(--sp-8)); bottom: auto; transform: translate(-50%, -8px); transition: opacity var(--dur-base) var(--ease-in), transform var(--dur-base) var(--ease-in); }
html body #toast.show { transform: translate(-50%, 0); transition-timing-function: var(--ease-out); }

/* View Transition の既定のサイズ補間を止める。スナップショットはクリックを遮らない。 */
::view-transition { pointer-events: none; }
::view-transition-group(main) { animation: none; }
html[data-dir]::view-transition-old(main) { animation-timing-function: var(--ease-in); }
@keyframes k-vt-in-r { from { transform: translateX(40px); opacity: 0; } }
@keyframes k-vt-in-l { from { transform: translateX(-40px); opacity: 0; } }
@keyframes k-vt-out-l { to { transform: translateX(-40px); opacity: 0; } }
@keyframes k-vt-out-r { to { transform: translateX(40px); opacity: 0; } }
html[data-dir="tab"][data-motion-tab="right"]::view-transition-new(main) { animation: motion-tab-right var(--dur-base) var(--ease-out) both; }
html[data-dir="tab"][data-motion-tab="left"]::view-transition-new(main) { animation: motion-tab-left var(--dur-base) var(--ease-out) both; }
@keyframes motion-tab-right { from { transform: translateX(8px); opacity: 0; } }
@keyframes motion-tab-left { from { transform: translateX(-8px); opacity: 0; } }
@media (min-width: 700px) {
  html[data-dir="forward"]::view-transition-new(main), html[data-dir="back"]::view-transition-new(main) { animation: motion-desktop-in var(--dur-base) var(--ease-out) both; }
  html[data-dir="forward"]::view-transition-old(main), html[data-dir="back"]::view-transition-old(main) { animation: motion-fade-out var(--dur-fast) var(--ease-in) both; }
}
@keyframes motion-desktop-in { from { opacity: 0; transform: translateY(4px); } }

/* 行や進行状況の「更新」は一度のフェード。色の点滅・ループは増やさない。 */
html body .flash { animation: motion-update var(--dur-row) var(--ease-out); }
@keyframes motion-update { from { opacity: .55; } to { opacity: 1; } }
html body .wish-list.is-sorting > li { transition: none; }
html body .wish-list.is-sorting > li.is-dragging { box-shadow: none; outline: 1px solid var(--line-strong); }
html body .wish-list > li.is-leaving { pointer-events: none; }
html body .k-dot, html body #main .fold-seg { transition: opacity var(--dur-base) var(--ease-out); }
html body :is(.k-dots-i, .k-band-i, .k-step, #k-side .step-item).is-fresh .k-dot,
html body #main .fold-seg.is-fresh { animation: motion-update var(--dur-row) var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  html body :is(.btn, .k-btn, .toggle i, .toggle i::after, .seg-item span) { transition: none; }
  html body :is(.btn-main, .btn-cta, .k-btn-main):active:not(:disabled):not([aria-disabled="true"]) { transform: none; }
  html body [aria-invalid="true"]:is(input, textarea, select), html body dialog:not(.still), html body dialog::backdrop, html body .flash,
  html body .motion-check b,
  html body :is(.k-dots-i, .k-band-i, .k-step, #k-side .step-item).is-fresh .k-dot, html body #main .fold-seg.is-fresh { animation: none; }
  html body #toast, html body #toast.show { transform: translate(-50%, 0); transition: opacity var(--dur-fast) var(--ease-out); }
  html[data-dir][data-motion-tab]::view-transition-old(main), html[data-dir][data-motion-tab]::view-transition-new(main),
  html[data-dir]::view-transition-old(main), html[data-dir]::view-transition-new(main) { animation: none; }
}
@media print {
  .motion-exit-scrim, .motion-wish-dot, .motion-check { display: none; }
}
