/* Slizen motion layer — shared by every page.
   Everything plays once when the page loads (or when content is re-rendered / a control is used).
   Nothing here is scroll-triggered. Needs: anim.js (count-up numbers, page-leave transition). */

:root {
  --ease: cubic-bezier(0.22, 1, 0.36, 1);        /* soft "out" curve for entrances */
  --ease-inout: cubic-bezier(0.45, 0, 0.25, 1);  /* chart drawing */
  --rowbase: 0.42s;                              /* list/table start delay; anim.js drops it to 0 after load */
}

@keyframes fadeUp   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeLeft { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes rowIn    { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popIn    { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes cardIn   { from { opacity: 0; transform: translateY(18px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes wipe     { from { clip-path: inset(0 100% 0 0 round 999px); } to { clip-path: inset(0 0 0 0 round 999px); } }
@keyframes sweep    { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes barGrow  { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes lineDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes areaSweep { from { clip-path: inset(0 100% 0 0) fill-box; opacity: 0.4; } to { clip-path: inset(0 0 0 0) fill-box; opacity: 1; } }
@keyframes dialogIn { from { opacity: 0; transform: translateY(18px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes menuIn   { from { opacity: 0; transform: translateY(-6px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes starPop  { 0% { opacity: 0; transform: scale(0.3) rotate(-25deg); } 70% { transform: scale(1.18) rotate(4deg); } 100% { opacity: 1; transform: none; } }

/* ---------- Chrome: top bar, sidebar, footer ---------- */
.topbar { animation: fadeDown 0.5s var(--ease) backwards; }
.footer { animation: fadeIn 0.6s ease 0.7s backwards; }

.sb-section { animation: fadeLeft 0.55s var(--ease) backwards; }
.sb-nav .sb-section:nth-child(1) { animation-delay: 0.04s; }
.sb-nav .sb-section:nth-child(2) { animation-delay: 0.12s; }
.sb-nav .sb-section:nth-child(3) { animation-delay: 0.20s; }
.sb-nav .sb-section:nth-child(4) { animation-delay: 0.28s; }
.sb-nav .sb-section:nth-child(5) { animation-delay: 0.36s; }
.sb-foot { animation: fadeIn 0.6s ease 0.35s backwards; }
.sb-logo { animation: popIn 0.6s var(--ease) 0.05s backwards; }

/* ---------- Page structure ---------- */
.page-head { animation: fadeUp 0.6s var(--ease) backwards; }

/* Stat cards: each one pops in, then its icon + number follow */
.stats > .stat, .ostats > .ostat, .rv-stats > .ostat { --d: 0.1s; animation: cardIn 0.65s var(--ease) var(--d) backwards; }
.stats > :nth-child(2), .ostats > :nth-child(2), .rv-stats > :nth-child(2) { --d: 0.17s; }
.stats > :nth-child(3), .ostats > :nth-child(3), .rv-stats > :nth-child(3) { --d: 0.24s; }
.stats > :nth-child(4), .ostats > :nth-child(4), .rv-stats > :nth-child(4) { --d: 0.31s; }
.stat-icon, .ostat-icon { animation: popIn 0.55s var(--ease) calc(var(--d, 0s) + 0.25s) backwards; }
.stat .delta { animation: fadeIn 0.5s ease calc(var(--d, 0s) + 0.55s) backwards; }
.ostat em, .stat-note { animation: fadeIn 0.5s ease calc(var(--d, 0s) + 0.55s) backwards; }
.stat-value, .ostat strong, .cust-box strong, .rv-score strong, .report-box strong { font-variant-numeric: tabular-nums; }

/* Cards / sections (chart card, tables, lists) */
.sales, .chart-section { animation: fadeUp 0.65s var(--ease) 0.32s backwards; }
.orders-card { animation: fadeUp 0.65s var(--ease) 0.38s backwards; }
.row-orders > .card:nth-child(1) { animation: fadeUp 0.65s var(--ease) 0.42s backwards; }
.row-orders > .card:nth-child(2) { animation: fadeUp 0.65s var(--ease) 0.5s backwards; }
.row-bottom > .card:nth-child(1) { animation: fadeUp 0.65s var(--ease) 0.58s backwards; }
.row-bottom > .card:nth-child(2) { animation: fadeUp 0.65s var(--ease) 0.66s backwards; }
.rv-top > .rv-overall { animation: cardIn 0.65s var(--ease) 0.08s backwards; }
.rv-stats > .ostat { --d: 0.16s; }
.rv-stats > :nth-child(2) { --d: 0.23s; }
.rv-stats > :nth-child(3) { --d: 0.30s; }
.rv-stats > :nth-child(4) { --d: 0.37s; }

/* Tabs / filter bar inside list cards */
.orders-card .tabs { animation: fadeIn 0.5s ease 0.5s backwards; }
.orders-card .filters { animation: fadeUp 0.5s var(--ease) 0.55s backwards; }
.orders-card .table-foot { animation: fadeIn 0.6s ease 0.85s backwards; }
.tabs .tab { transition: background 0.2s, color 0.2s; }

/* ---------- Rows: table rows, list items, cards (re-play when a list is re-rendered) ---------- */
tbody tr, .top-products li, .low-stock li, .rv-card, .timeline li {
  animation: rowIn 0.45s var(--ease) backwards;
  animation-delay: calc(var(--rowbase) + var(--k, 0) * 0.045s);
}
tbody tr:nth-child(1), .top-products li:nth-child(1), .low-stock li:nth-child(1), .rv-card:nth-child(1), .timeline li:nth-child(1) { --k: 0; }
tbody tr:nth-child(2), .top-products li:nth-child(2), .low-stock li:nth-child(2), .rv-card:nth-child(2), .timeline li:nth-child(2) { --k: 1; }
tbody tr:nth-child(3), .top-products li:nth-child(3), .low-stock li:nth-child(3), .rv-card:nth-child(3), .timeline li:nth-child(3) { --k: 2; }
tbody tr:nth-child(4), .top-products li:nth-child(4), .low-stock li:nth-child(4), .rv-card:nth-child(4), .timeline li:nth-child(4) { --k: 3; }
tbody tr:nth-child(5), .top-products li:nth-child(5), .low-stock li:nth-child(5), .rv-card:nth-child(5), .timeline li:nth-child(5) { --k: 4; }
tbody tr:nth-child(6), .top-products li:nth-child(6), .low-stock li:nth-child(6), .rv-card:nth-child(6), .timeline li:nth-child(6) { --k: 5; }
tbody tr:nth-child(7), .rv-card:nth-child(7), .timeline li:nth-child(7) { --k: 6; }
tbody tr:nth-child(8), .rv-card:nth-child(8) { --k: 7; }
tbody tr:nth-child(9) { --k: 8; }
tbody tr:nth-child(10) { --k: 9; }
tbody tr:nth-child(n+11) { --k: 10; }
.rv-card:nth-child(n+9) { --k: 8; }

/* Category tiles */
.cat-card {
  animation: cardIn 0.55s var(--ease) backwards;
  animation-delay: calc(var(--rowbase) + var(--k, 0) * 0.05s);
}
.cat-card:nth-child(1) { --k: 0; } .cat-card:nth-child(2) { --k: 1; } .cat-card:nth-child(3) { --k: 2; }
.cat-card:nth-child(4) { --k: 3; } .cat-card:nth-child(5) { --k: 4; } .cat-card:nth-child(6) { --k: 5; }
.cat-card:nth-child(7) { --k: 6; } .cat-card:nth-child(n+8) { --k: 7; }
.cat-tile { transition: transform 0.3s var(--ease); }
.cat-card:hover .cat-tile { transform: scale(1.1) rotate(-4deg); }

/* Avatars + icon tiles settle in with their rows */
.top-products .tp-icon { animation: popIn 0.5s var(--ease) calc(var(--rowbase) + 0.1s) backwards; }

/* ---------- Progress bars, sparkline, rating bars ---------- */
.ls-bar i, .split-bar i, .rv-bars .track i {
  animation: wipe 0.95s var(--ease-inout) calc(var(--rowbase) + 0.25s) backwards;
}
.rv-bars li:nth-child(2) .track i { animation-delay: calc(var(--rowbase) + 0.33s); }
.rv-bars li:nth-child(3) .track i { animation-delay: calc(var(--rowbase) + 0.41s); }
.rv-bars li:nth-child(4) .track i { animation-delay: calc(var(--rowbase) + 0.49s); }
.rv-bars li:nth-child(5) .track i { animation-delay: calc(var(--rowbase) + 0.57s); }
.low-stock li:nth-child(2) .ls-bar i { animation-delay: calc(var(--rowbase) + 0.33s); }
.low-stock li:nth-child(3) .ls-bar i { animation-delay: calc(var(--rowbase) + 0.41s); }
.low-stock li:nth-child(4) .ls-bar i { animation-delay: calc(var(--rowbase) + 0.49s); }
.rv-bars li { animation: fadeIn 0.4s ease backwards; animation-delay: calc(var(--rowbase) - 0.2s); }

.spark { animation: sweep 1.4s var(--ease-inout) 0.9s backwards; }

/* Overall rating stars pop one after another */
#overallStars svg { animation: starPop 0.6s var(--ease) backwards; }
#overallStars svg:nth-child(1) { animation-delay: 0.30s; }
#overallStars svg:nth-child(2) { animation-delay: 0.38s; }
#overallStars svg:nth-child(3) { animation-delay: 0.46s; }
#overallStars svg:nth-child(4) { animation-delay: 0.54s; }
#overallStars svg:nth-child(5) { animation-delay: 0.62s; }
.rv-card .stars svg { animation: starPop 0.5s var(--ease) backwards; animation-delay: calc(var(--rowbase) + var(--k, 0) * 0.045s + 0.15s); }

/* ---------- Charts (classes are added by dashboard.js / time-chart.js only when a chart is (re)drawn) ---------- */
.ch-anim { --cd: 0ms; }
.ch-anim .ch-axis { animation: fadeIn 0.5s ease calc(var(--cd) + 0ms) backwards; }
.ch-anim .ch-bar {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: barGrow 0.8s var(--ease) backwards;
  animation-delay: calc(var(--cd) + 160ms + var(--bi, 0) * 1ms);
}
.ch-anim .ch-line {
  stroke-dasharray: 1;
  animation: lineDraw 1.25s var(--ease-inout) calc(var(--cd) + 350ms) backwards;
}
.ch-anim .ch-area { animation: areaSweep 1.25s var(--ease-inout) calc(var(--cd) + 350ms) backwards; }
.ch-anim .ch-marker { animation: fadeIn 0.45s ease calc(var(--cd) + 1400ms) backwards; }
.chart-wrap .ch-tip-anim { animation: fadeIn 0.45s ease backwards; animation-delay: calc(var(--cd, 0ms) + 1400ms); }

/* Marker + tooltip glide between points instead of jumping */
.ch-marker { transition: transform 0.18s var(--ease); }
.chart-tip { transition: left 0.18s var(--ease), top 0.18s var(--ease); }

/* Range tabs: sliding feel */
.range-tabs button { transition: background 0.2s, color 0.2s, box-shadow 0.2s; }

/* ---------- Dropdowns, modal, drawer ---------- */
.dropdown.open > .dd-menu { animation: menuIn 0.22s var(--ease); transform-origin: top right; }
.dropdown.open .notif-list li { animation: rowIn 0.35s var(--ease) backwards; }
.dropdown.open .notif-list li:nth-child(1) { animation-delay: 0.04s; }
.dropdown.open .notif-list li:nth-child(2) { animation-delay: 0.09s; }
.dropdown.open .notif-list li:nth-child(3) { animation-delay: 0.14s; }
.dd-toggle > span[data-icon="chevron-down"] { display: inline-grid; transition: transform 0.25s var(--ease); }
.dropdown.open .dd-toggle[aria-haspopup="true"] > span[data-icon="chevron-down"] { transform: rotate(180deg); }
.notif-list li { transition: background 0.4s; }
.icon-btn.has-dot::after { animation: dotPulse 2.4s ease-out 1.2s 2; }
@keyframes dotPulse { 0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.45); } 80%, 100% { box-shadow: 0 0 0 7px rgba(231, 76, 60, 0); } }

.modal:not([hidden]) .modal-backdrop { animation: fadeIn 0.25s ease; }
.modal:not([hidden]) .modal-dialog { animation: dialogIn 0.38s var(--ease); }
.modal:not([hidden]) .report-box { animation: cardIn 0.5s var(--ease) backwards; }
.modal:not([hidden]) .report-box:nth-child(1) { animation-delay: 0.12s; }
.modal:not([hidden]) .report-box:nth-child(2) { animation-delay: 0.18s; }
.modal:not([hidden]) .report-box:nth-child(3) { animation-delay: 0.24s; }
.modal:not([hidden]) .report-box:nth-child(4) { animation-delay: 0.30s; }
.modal:not([hidden]) .report-note, .modal:not([hidden]) .modal-foot { animation: fadeIn 0.5s ease 0.4s backwards; }

.drawer:not([hidden]) .drawer-sec { animation: fadeUp 0.5s var(--ease) backwards; }
.drawer:not([hidden]) .drawer-sec:nth-of-type(1) { animation-delay: 0.12s; }
.drawer:not([hidden]) .drawer-sec:nth-of-type(2) { animation-delay: 0.19s; }
.drawer:not([hidden]) .drawer-sec:nth-of-type(3) { animation-delay: 0.26s; }
.drawer:not([hidden]) .drawer-sec:nth-of-type(4) { animation-delay: 0.33s; }
.drawer:not([hidden]) .drawer-badges { animation: fadeIn 0.4s ease 0.1s backwards; }
.drawer:not([hidden]) .timeline li { animation-delay: calc(0.35s + var(--k, 0) * 0.07s); }

/* Category detail / list view swap */
#listView:not([hidden]), #detailView:not([hidden]) { animation: fadeIn 0.3s ease; }

/* Reviews: inline reply box */
.rv-form { animation: fadeUp 0.35s var(--ease); }

/* ---------- Hover + press feedback ---------- */
.btn, .icon-btn, .store-switch, .reorder, .rv-btn, .modal-close {
  transition: transform 0.18s var(--ease), box-shadow 0.2s, background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover, .icon-btn:hover, .store-switch:hover, .reorder:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08); }
.btn:active, .icon-btn:active, .store-switch:active, .reorder:active, .rv-btn:active { transform: scale(0.96); box-shadow: none; }

.stat, .ostat { transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.stat:hover, .ostat:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(16, 24, 40, 0.08); }

.otable tbody td, .orders tbody td { transition: background 0.18s; }
.orders tbody tr:hover td { background: #F8FAF9; }
.top-products li, .low-stock li { transition: background 0.18s; }

.sb-link { transition: background 0.15s, color 0.15s, transform 0.2s var(--ease); }
.sb-link:hover { transform: translateX(2px); }

/* ---------- Leaving a page ---------- */
.main { transition: opacity 0.2s ease, transform 0.2s ease; }
html.page-leave .main { opacity: 0; transform: translateY(-8px); }

/* ---------- Respect reduced-motion settings ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.001ms !important;
  }
}
