/* ui-motion.css: 施工日程アプリ共通のアニメーション（2026-10-20）
   - 重いアニメーションは付けない（ガントの表のセルなど何百もある要素には付けない）
   - animation は fill-mode: backwards にする（both だと最後のtransformが残り、fixed の要素を壊すため）
   - 最後の reduced-motion で全部止める */

/* ---- ページ表示時のふわっと出る ---- */
@keyframes ui-page-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
body > div:not(.modal):not(.toast-container) {
    animation: ui-page-enter 0.4s ease-out backwards;
}

/* ---- 工程ページ（.step-page）が表示された時のフェードイン（d-none が外れた時に再生） ---- */
@keyframes ui-step-fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.step-page:not(.d-none) {
    animation: ui-step-fade 0.35s ease-out backwards;
}

/* ---- カード: 出現時 fade+scale、hover で軽く浮く ---- */
@keyframes ui-card-in {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}
.card {
    animation: ui-card-in 0.25s ease-out backwards;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px -10px rgba(15, 23, 42, 0.25);
}

/* ---- モーダル: 出現時 fade+scale。hover では浮かせない ---- */
.modal-content {
    animation: ui-card-in 0.25s ease-out backwards;
}

/* ---- ボタン ---- */
.btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.btn:hover {
    transform: translateY(-1px);
}
.btn:active {
    transform: scale(0.97);
}

/* ---- バッジの出現 pop（表の中のバッジは対象外） ---- */
@keyframes ui-badge-pop {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}
.badge:not(td .badge):not(th .badge) {
    animation: ui-badge-pop 0.25s ease-out backwards;
}

/* ---- アラートのスライドイン ---- */
@keyframes ui-alert-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.alert {
    animation: ui-alert-in 0.3s ease-out backwards;
}

/* ---- 表の行の hover 背景（セル単位の重いアニメーションはしない） ---- */
.table tbody tr {
    transition: background-color 0.15s ease;
}

/* ---- 入力欄 focus 時の影 ---- */
.form-control,
.form-select {
    transition: border-color 0.15s ease, box-shadow 0.2s ease;
}

/* ---- 工程のパンくず（#step-nav-bar。switchStep() が .active を付け外しする） ---- */
#step-nav-bar .crumb {
    border: 0 !important;
    border-radius: 0.375rem;
    background-color: transparent;
    color: #64748b;
    box-shadow: none;
    padding: 0.25rem 0.5rem;
}
#step-nav-bar .crumb:hover {
    background-color: #f1f5f9;
    text-decoration: underline;
}
#step-nav-bar .crumb.active {
    color: #0284c7;
    font-weight: 700;
    border-radius: 0;
    /* 下線は ::after で伸びて出す（下の「パンくずの下線」）。高さが変わらないよう下の余白で 2px を取る */
    border-bottom: 0 !important;
    padding-bottom: calc(0.25rem + 2px);
    background-color: transparent;
}
/* 今いる工程より前の工程（DOM上で .active より前にあるもの）は「済」を薄い緑で出す */
#step-nav-bar .crumb:has(~ .crumb.active) {
    color: #2e8b57;
}
#step-nav-bar .crumb-sep {
    color: #94a3b8;
    padding: 0 0.1rem;
    user-select: none;
}

/* ---- アコーディオン（ui-accordion.js が付ける class） ---- */
/* 開閉の印は見出しの左端にそろえる（2026-10-20徹くん指示）。見出しの中の並び（左右に振り分けたflex）を崩さないよう、印は絶対配置にして、その分だけ左に余白を取る */
.acc-head {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-left: 1.75rem !important;
}
.acc-head:focus-visible {
    outline: 2px solid #0284c7;
    outline-offset: 2px;
}
.acc-chevron {
    position: absolute;
    left: 0.45rem;
    top: 50%;
    width: 1rem;
    text-align: center;
    line-height: 1;
    color: #64748b;
    transform: translateY(-50%);
    transition: transform 0.25s ease;
}
.acc-head[aria-expanded="false"] .acc-chevron {
    transform: translateY(-50%) rotate(-90deg);
}
.acc-body {
    overflow: hidden;
    transition: height 0.25s ease;
}

/* ---- アコーディオン（2026-10-20 追加の演出）: 開いた時に中身が順に出る。閉じると消える（fill は backwards） ---- */
@keyframes ui-acc-child-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.acc-head[aria-expanded="true"] ~ .acc-body > * {
    animation: ui-acc-child-in 0.3s ease-out backwards;
}
.acc-head {
    transition: box-shadow 0.2s ease;
}
.acc-head:hover {
    box-shadow: inset 0 0 0 9999px #f1f5f9;
}
.acc-head[aria-expanded="true"] .acc-chevron {
    color: #1d4ed8;
}

/* ---- パンくずの下線（伸びて出る）と hover の浮き ---- */
@keyframes ui-crumb-line {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}
#step-nav-bar .crumb.active::after {
    content: "";
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0;
    height: 2px;
    background-color: #0284c7;
    transform: scaleX(1);
    transform-origin: left center;
    animation: ui-crumb-line 0.3s ease-out backwards;
}
#step-nav-bar .crumb:not(.active) {
    transition: transform 0.15s ease, background-color 0.15s ease;
}
#step-nav-bar .crumb:not(.active):hover {
    transform: translateY(-1px);
}

/* ---- 工程ページが表示された時、直下のカードが順に出る（70ms ずつ・最大8枚目まで） ---- */
@keyframes ui-step-card-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.step-page:not(.d-none) > .card {
    animation: ui-step-card-in 0.4s ease-out backwards;
}
.step-page:not(.d-none) > .card:nth-child(2) { animation-delay: 70ms; }
.step-page:not(.d-none) > .card:nth-child(3) { animation-delay: 140ms; }
.step-page:not(.d-none) > .card:nth-child(4) { animation-delay: 210ms; }
.step-page:not(.d-none) > .card:nth-child(5) { animation-delay: 280ms; }
.step-page:not(.d-none) > .card:nth-child(6) { animation-delay: 350ms; }
.step-page:not(.d-none) > .card:nth-child(7) { animation-delay: 420ms; }
.step-page:not(.d-none) > .card:nth-child(8) { animation-delay: 490ms; }
.step-page:not(.d-none) > .card:nth-child(n+9) { animation-delay: 490ms; }

/* ---- スクロールで出る（ui-motion.js が付ける ui-reveal = 隠れた状態 / ui-reveal-in = 出た状態） ---- */
.ui-reveal {
    opacity: 0;
    transform: translateY(14px);
    animation: none !important;
}
.ui-reveal-in {
    opacity: 1;
    transform: none;
    animation: none !important;
}
.ui-reveal,
.ui-reveal-in {
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s ease;
}

/* ---- ボタンのリップル（ui-motion.js が押した位置に span を足して、すぐ消す） ---- */
.ui-ripple-host {
    position: relative;
    overflow: hidden;
}
@keyframes ui-ripple {
    from { transform: scale(0); opacity: 0.28; }
    to { transform: scale(2.5); opacity: 0; }
}
.ui-ripple {
    position: absolute;
    border-radius: 50%;
    background-color: currentColor;
    pointer-events: none;
    transform: scale(0);
    animation: ui-ripple 0.55s ease-out forwards;
}

/* ---- 表（ガント含む）: 行の hover はセルの影の色だけ変える（背景色は消さない） ---- */
.table tbody tr > * {
    transition: box-shadow 0.15s ease;
}
.table tbody tr:hover > * {
    --bs-table-accent-bg: rgba(241, 245, 249, 0.6);
}
/* ガントのバッジは、そのセル（td）に乗せると少し大きくなる（セルには動きを付けない） */
.ui-gantt-badge {
    transition: transform 0.15s ease;
}
td:hover .ui-gantt-badge {
    transform: scale(1.08);
}
/* ガントのセルを押した時の一瞬の光（ui-motion.js が ui-pulse を付ける） */
@keyframes ui-cell-pulse {
    from { box-shadow: inset 0 0 0 0 rgba(2, 132, 199, 0.5); }
    to { box-shadow: inset 0 0 0 3px rgba(2, 132, 199, 0); }
}
td.step5-cell.ui-pulse {
    animation: ui-cell-pulse 0.45s ease-out;
}

/* ---- モーダル: 下からふわっと（.show で元に戻る）。背景は少しゆっくり ---- */
.modal.fade .modal-dialog {
    transform: translateY(24px) scale(0.97);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal.show .modal-dialog {
    transform: none;
}
.modal-backdrop.fade {
    transition: opacity 0.3s linear;
}

/* ---- トースト: 右からスライドイン ---- */
@keyframes ui-toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
.toast.show {
    animation: ui-toast-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

/* ---- 入力欄の focus: 影の輪が広がる（Bootstrap の既定の影を置き換える。is-invalid/is-valid は残る） ---- */
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.18);
}

/* ---- ログイン画面（index.html の .main-card）: カードがふわっと出て、左右の列が両側から入る ---- */
@keyframes ui-login-card-in {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes ui-slide-from-left {
    from { opacity: 0; transform: translateX(-18px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes ui-slide-from-right {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: translateX(0); }
}
.main-card {
    animation: ui-login-card-in 0.5s ease-out backwards;
}
.main-card .left-panel {
    animation: ui-slide-from-left 0.5s ease-out 0.1s backwards;
}
.main-card .right-panel {
    animation: ui-slide-from-right 0.5s ease-out 0.1s backwards;
}

/* ---- 動きを減らす設定の人には、すべて止める（この block は必ず最後） ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
