/* 工作台交互与动效层：只动画 transform / opacity，并统一键盘与触控反馈。 */
:root {
  --motion-fast: 120ms;
  --motion-view: 180ms;
  --motion-dialog: 240ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-standard: cubic-bezier(.2, .8, .2, 1);
}

/* 动效层不得覆盖应用壳的高度约束；布局统一由 index.html 负责。 */
button, input, textarea, select { touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid rgba(111, 78, 55, .35);
  outline-offset: 2px;
}

.btn {
  transition: transform var(--motion-fast) var(--ease-standard),
    background-color var(--motion-fast) ease, color var(--motion-fast) ease,
    border-color var(--motion-fast) ease, opacity var(--motion-fast) ease;
}
.todo-content-button {
  display: block;
  width: 100%;
  text-align: left;
  color: inherit;
  line-height: inherit;
}
.photo-view-btn { display: block; width: 100%; height: 100%; border-radius: inherit; overflow: hidden; }
.todo-check, .todo-del, .order-card, .photo-add, .modal-close,
.tl-action, .stage-row .s-actions button, header.appbar .h-actions button {
  transition: transform var(--motion-fast) var(--ease-standard),
    background-color var(--motion-fast) ease, color var(--motion-fast) ease,
    border-color var(--motion-fast) ease, opacity var(--motion-fast) ease;
}
.todo-check:active, .todo-del:active, .order-card:active, .photo-add:active,
.modal-close:active, .tl-action:active, .stage-row .s-actions button:active {
  transform: scale(.97);
}

nav.tabbar button {
  position: relative;
  transition: color var(--motion-fast) ease, transform var(--motion-fast) var(--ease-standard);
}
nav.tabbar button::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 18px;
  height: 3px;
  border-radius: 3px;
  background: var(--primary);
  opacity: 0;
  transform: translateX(-50%) scaleX(.4);
  transition: opacity var(--motion-fast) ease, transform var(--motion-fast) var(--ease-out);
}
nav.tabbar button.active { transform: translateY(-1px); }
nav.tabbar button.active::after { opacity: 1; transform: translateX(-50%) scaleX(1); }

.fab {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(.86);
  transition: opacity var(--motion-view) ease, transform var(--motion-view) var(--ease-out),
    background-color var(--motion-fast) ease;
}
.fab.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.fab:active { transform: translateY(1px) scale(.94); }

.view-enter { animation: view-enter var(--motion-view) var(--ease-out) both; }
.list-enter > .todo-item,
.list-enter > .order-card,
.list-enter > .ov-item,
.list-enter > .card {
  animation: item-enter var(--motion-view) var(--ease-out) both;
}
.list-enter > :nth-child(2) { animation-delay: 24ms; }
.list-enter > :nth-child(3) { animation-delay: 48ms; }
.list-enter > :nth-child(4) { animation-delay: 72ms; }
.list-enter > :nth-child(n+5) { animation-delay: 88ms; }

.todo-check.checked svg { animation: check-pop var(--motion-view) var(--ease-out) both; }
.login-logo { animation: logo-arrive 420ms var(--ease-out) both; }
#app-view.is-revealing { animation: app-reveal var(--motion-dialog) var(--ease-out) both; }

.modal-mask.show { animation: backdrop-in var(--motion-dialog) ease both; }
.modal-mask.show .modal { animation: dialog-in var(--motion-dialog) var(--ease-out) both; }
.modal-mask.show.center .modal { animation-name: dialog-center-in; }
.modal-mask.closing { display: flex; animation: backdrop-out 160ms ease both; }
.modal-mask.closing .modal { animation: dialog-out 160ms ease both; }
.modal-mask.closing.center .modal { animation-name: dialog-center-out; }

#toast {
  transform: translate(-50%, -10px) scale(.98);
  transition: opacity var(--motion-view) ease, transform var(--motion-view) var(--ease-out);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.photo-loading, .skeleton-line, .skeleton-card::after {
  background: linear-gradient(100deg, #EEE9E1 20%, #F8F5F0 40%, #EEE9E1 60%);
  background-size: 220% 100%;
  animation: shimmer 1.25s linear infinite;
}
.skeleton-card {
  height: 92px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  padding: 16px;
  overflow: hidden;
}
.skeleton-line { height: 12px; border-radius: 8px; margin-bottom: 12px; }
.skeleton-line.short { width: 46%; }
.skeleton-line.medium { width: 72%; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: rgba(18, 15, 12, .92);
}
.lightbox.show { display: flex; animation: backdrop-in var(--motion-view) ease both; }
.lightbox.closing { display: flex; animation: backdrop-out 140ms ease both; }
.lightbox img {
  display: block;
  max-width: min(100%, 1080px);
  max-height: 88dvh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 16px 60px rgba(0, 0, 0, .38);
  animation: dialog-center-in var(--motion-dialog) var(--ease-out) both;
}
.lightbox-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .14);
  color: #fff;
}
.badge-upcoming { background: var(--info); }

@media (hover:hover) and (pointer:fine) {
  .order-card:hover, .todo-item:hover, .ov-item:hover { box-shadow: var(--shadow-lift); }
  .order-card:hover { transform: translateY(-2px); }
  .fab:hover { background: var(--primary-dark); transform: translateY(-2px) scale(1.03); }
  .btn:not(:disabled):hover { transform: translateY(-1px); }
}

@media (min-width:760px) {
  .fab { right: 24px; }
}

@media (max-width:360px) {
  .form-row { flex-direction: column; gap: 0; }
  .user-create-row { flex-direction: column; }
  .user-create-row .btn { width: 100%; }
  .filter-bar .form-control { min-width: 100%; }
  .oc-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@keyframes view-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes item-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes check-pop { 0% { opacity: 0; transform: scale(.45); } 70% { transform: scale(1.14); } 100% { opacity: 1; transform: scale(1); } }
@keyframes logo-arrive { from { opacity: 0; transform: translateY(10px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes app-reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes dialog-in { from { opacity: .65; transform: translateY(42px); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(28px); } }
@keyframes dialog-center-in { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes dialog-center-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes shimmer { to { background-position-x: -220%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
