/* ============ effects & delights (see js/fx.js) ============ */

/* ---- view entrance: softer, with a hint of blur ---- */
.view.enter { animation: view-in-fx 520ms var(--ease); }
@keyframes view-in-fx { from { opacity: 0; transform: translateY(12px) scale(.995); filter: blur(5px); } to { opacity: 1; transform: none; filter: none; } }

/* Dashboard entrance animations play on the first paint only, not on every re-render after a click. */
.view:not(.enter) :is(.stat, .grid > .card, .bar i, .quick-launch a, .banner-buddy, .empty-lg) { animation: none; }
.view.enter .meter i { animation: meter-fill 1100ms var(--ease) 200ms both; }
@keyframes meter-fill { from { width: 0; } }

/* ---- boot: sidebar items slide in one after another ---- */
.booting .sidebar .nav-item { animation: nav-in 520ms var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms + 80ms); }
.booting .brand .logo { animation: logo-in 800ms var(--spring) both; }
@keyframes nav-in { from { opacity: 0; transform: translateX(-14px); } }
@keyframes logo-in { 0% { opacity: 0; transform: rotate(-40deg) scale(.4); } 100% { opacity: 1; transform: none; } }


/* ---- theme switch: circular reveal ---- */
.vt-reveal::view-transition-old(root), .vt-reveal::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.vt-reveal::view-transition-new(root) { z-index: 2; }

/* ---- spotlight that follows the mouse on cards ---- */
:is(.grid > .card, .stat, .subpage, .quick-launch a, .settings .card) {
  background-image: radial-gradient(420px circle at var(--mx, -999px) var(--my, -999px), color-mix(in oklab, var(--accent) 9%, transparent), transparent 55%);
}
:is(.grid > .card, .stat, .settings .card) { transition: background var(--t), border-color var(--t), transform 300ms var(--ease), box-shadow 300ms var(--ease); }
:is(.grid > .card, .stat):hover { border-color: color-mix(in oklab, var(--accent) 22%, var(--line)); }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* ---- ripple ---- */
.btn.primary, .chip, .seg > button { position: relative; overflow: hidden; isolation: isolate; }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .22; transform: scale(0); animation: ripple 620ms var(--ease) forwards; z-index: -1; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---- primary button: a sheen passes over on hover ---- */
.btn.primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / .28) 50%, transparent 65%); transform: translateX(-120%); pointer-events: none; }
.btn.primary:hover::after { transform: translateX(120%); transition: transform 700ms var(--ease); }

/* ---- banner: drifting colours, floating motes, parallax buddy ---- */
.banner { background: var(--bg-grad); background-size: 220% 220%; animation: rise 500ms var(--ease), banner-drift 30s ease-in-out var(--dd, 0s) infinite alternate; }
.view:not(.enter) .banner { animation: banner-drift 30s ease-in-out var(--dd, 0s) infinite alternate; }
@keyframes banner-drift { 0% { background-position: 0% 30%; } 50% { background-position: 100% 60%; } 100% { background-position: 40% 100%; } }
.banner-text { transform: translate(calc(var(--px, 0) * -4px), calc(var(--py, 0) * -3px)); transition: transform 600ms var(--ease); }
.banner-buddy .mascot { transform: translate(calc(var(--px, 0) * 14px), calc(var(--py, 0) * 8px)) rotate(calc(var(--px, 0) * 5deg)); transition: transform 500ms var(--ease); }
.banner-motes { position: absolute; inset: 0; z-index: -1; pointer-events: none; transform: translate(calc(var(--px, 0) * 18px), calc(var(--py, 0) * 12px)); transition: transform 900ms var(--ease); }
.banner-motes i { position: absolute; bottom: -12px; width: var(--s, 6px); height: var(--s, 6px); border-radius: 50%; background: rgb(255 255 255 / .55); box-shadow: 0 0 12px rgb(255 255 255 / .6); animation: mote 14s linear infinite; animation-delay: calc(var(--dd, 0s) + var(--o, 0s)); }
.on-dark .banner-motes i { background: rgb(255 240 220 / .5); }
.banner-motes i:nth-child(1) { left: 6%; --s: 5px; --o: -1s; }
.banner-motes i:nth-child(2) { left: 14%; --s: 8px; --o: -6s; animation-duration: 18s; }
.banner-motes i:nth-child(3) { left: 23%; --s: 4px; --o: -11s; }
.banner-motes i:nth-child(4) { left: 31%; --s: 6px; --o: -3s; animation-duration: 16s; }
.banner-motes i:nth-child(5) { left: 42%; --s: 3px; --o: -8s; }
.banner-motes i:nth-child(6) { left: 51%; --s: 7px; --o: -13s; animation-duration: 20s; }
.banner-motes i:nth-child(7) { left: 60%; --s: 4px; --o: -4s; }
.banner-motes i:nth-child(8) { left: 68%; --s: 9px; --o: -9s; animation-duration: 22s; opacity: .7; }
.banner-motes i:nth-child(9) { left: 76%; --s: 5px; --o: -2s; }
.banner-motes i:nth-child(10) { left: 84%; --s: 3px; --o: -7s; animation-duration: 12s; }
.banner-motes i:nth-child(11) { left: 91%; --s: 6px; --o: -12s; }
.banner-motes i:nth-child(12) { left: 97%; --s: 4px; --o: -5s; animation-duration: 17s; }
@keyframes mote { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 50% { transform: translate(14px, -130px); } 90% { opacity: .8; } 100% { transform: translate(-6px, -260px); opacity: 0; } }

/* ---- streak ---- */
.streak { display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; padding: 5px 12px 5px 8px; border-radius: 99px; font-size: 13px; font-weight: 600; background: rgb(255 255 255 / .38); backdrop-filter: blur(6px); }
.on-dark .streak { background: rgb(255 255 255 / .12); }
.streak b { font-weight: 800; }
.streak .flame { display: inline-block; font-size: 16px; transform-origin: 50% 90%; }
.streak.lit .flame { animation: flicker 1.6s ease-in-out infinite; filter: drop-shadow(0 0 6px rgb(255 150 50 / .7)); }
.streak.cold .flame { filter: grayscale(.8); opacity: .7; }
@keyframes flicker { 0%, 100% { transform: rotate(-4deg) scale(1); } 25% { transform: rotate(3deg) scale(1.08, .95); } 50% { transform: rotate(-2deg) scale(.96, 1.06); } 75% { transform: rotate(4deg) scale(1.04); } }

/* ---- completing a task: a sweep of light across the row ---- */
.task.completing { background-image: linear-gradient(100deg, transparent 20%, color-mix(in oklab, var(--accent) 16%, transparent) 50%, transparent 80%); background-size: 300% 100%; animation: settle 380ms var(--ease) forwards, sweep 650ms var(--ease); }
@keyframes sweep { from { background-position: 100% 0; } to { background-position: 0% 0; } }

/* ---- toast with Undo shows how long it stays ---- */
.toast:has(.toast-action) { position: relative; overflow: hidden; }
.toast:has(.toast-action)::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--accent); transform-origin: left; animation: toast-timer 5s linear forwards; }
@keyframes toast-timer { to { transform: scaleX(0); } }

/* ---- smart quick-add chips ---- */
.quick-add { position: relative; }
.qa-chips { display: flex; gap: 5px; flex: none; }
.qa-chips:empty { display: none; }
.qa-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--accent-soft); color: var(--accent-ink); }
.qa-chip.new { animation: chip-pop 380ms var(--spring); }
.qa-pri-high { background: color-mix(in oklab, var(--danger) 14%, transparent); color: var(--danger); }
.qa-pri-low { background: var(--surface-2); color: var(--muted); }
.qa-time { background: color-mix(in oklab, #4f9bd1 15%, transparent); color: color-mix(in oklab, #4f9bd1 75%, var(--text)); }
@keyframes chip-pop { from { opacity: 0; transform: scale(.5) translateY(4px); } }

/* ---- confetti ---- */
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 90; }

/* ---- focus: sound chips, zen ---- */
.ambient { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.ambient .muted { margin-right: 4px; }
.focus-card { position: relative; overflow: hidden; }
.zen-aurora, .zen-exit { display: none; }
.zen .focus-card { position: fixed; inset: 0; z-index: 45; border: 0; border-radius: 0; justify-content: center; gap: 28px; background: var(--bg); animation: zen-in 600ms var(--ease); }
.zen .focus-card > :not(.zen-aurora) { position: relative; z-index: 1; }
.zen .zen-aurora { display: block; position: absolute; inset: -25%; z-index: 0; filter: blur(70px); opacity: .5; pointer-events: none; }
.zen .focus-card.running .zen-aurora { opacity: .75; }
.zen-aurora i { position: absolute; width: 50%; aspect-ratio: 1; border-radius: 50%; mix-blend-mode: normal; }
.zen-aurora i:nth-child(1) { background: var(--accent); left: 15%; top: 20%; animation: aur-a 22s ease-in-out infinite alternate; }
.zen-aurora i:nth-child(2) { background: var(--buddy); left: 45%; top: 35%; opacity: .7; animation: aur-b 28s ease-in-out infinite alternate; }
.zen-aurora i:nth-child(3) { background: #7d9cc9; left: 30%; top: 50%; opacity: .6; animation: aur-c 25s ease-in-out infinite alternate; }
.zen .focus-card.running .zen-aurora i { animation-duration: 12s, 15s, 14s; }
@keyframes aur-a { to { transform: translate(30%, 25%) scale(1.2); } }
@keyframes aur-b { to { transform: translate(-35%, -20%) scale(.85); } }
@keyframes aur-c { to { transform: translate(20%, -30%) scale(1.15); } }
@keyframes zen-in { from { opacity: 0; transform: scale(1.03); } }
.zen .focus-card > .zen-exit { display: grid; position: absolute; top: 18px; right: 18px; z-index: 2; }
.zen .focus-task { display: none; }
.zen .ring { width: min(460px, 62vh, 86vw); }
.zen .ring-time { font-size: clamp(56px, 11vh, 96px); }
.zen .topbar, .zen .buddy { visibility: hidden; }
.zen .ring-fg { filter: drop-shadow(0 0 10px color-mix(in oklab, var(--accent) 60%, transparent)); }

/* ---- the secret ---- */
.party .app { animation: party-hue 1.4s linear 3; }
.party .logo { animation: spin 700ms var(--spring) 3; }
@keyframes party-hue { to { filter: hue-rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .banner-motes, .zen-aurora { display: none !important; }
}
