/* Taskly — Priority Matrix, Journey, Home "next step", and the motion layer.
 * Loaded last. Every animation is switched off under prefers-reduced-motion
 * (see the end of this file), and none of them is needed to read a page.
 */

/* ============================================================ Next step */
.next-step {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center;
  margin: 0 0 18px; padding: 16px 18px; border-radius: 20px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.next-step::before {
  content: ""; position: absolute; inset: 0; padding: 1.5px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(110deg, #2C58DD, #34D0CF 45%, #A149D4 80%, #FBBD08);
  background-size: 220% 100%; animation: border-flow 7s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
@keyframes border-flow { to { background-position: 220% 0; } }
.next-orb {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 32% 30%, #fff 0 8%, #7FE6E5 22%, #2C58DD 62%, #A149D4 100%);
  box-shadow: 0 0 0 6px rgba(44, 88, 221, 0.10); animation: orb-breathe 3.6s ease-in-out infinite;
}
@keyframes orb-breathe { 50% { transform: scale(1.08); box-shadow: 0 0 0 11px rgba(44, 88, 221, 0.05); } }
.next-kicker { margin: 0 0 2px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-strong); }
.next-title { margin: 0; font-size: 1.06rem; line-height: 1.3; color: var(--text); overflow-wrap: anywhere; }
.next-reason { margin: 2px 0 0; font-size: 0.86rem; color: var(--muted); }
.next-also { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.next-also:empty { display: none; }
button.next-alt { min-height: 0; padding: 3px 10px; font: inherit; font-size: 0.76rem; font-weight: 500; border-radius: 999px; background: var(--surface-3); color: var(--text-2); border: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.next-alt:hover { background: var(--accent-soft); color: var(--accent-strong); }
button.next-cta { position: relative; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
button.next-cta .icon { width: 16px; height: 16px; transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1); }
button.next-cta:hover .icon { transform: translateX(4px); }
@media (max-width: 640px) {
  .next-step { grid-template-columns: auto minmax(0, 1fr); }
  button.next-cta { grid-column: 1 / -1; justify-content: center; }
}

/* ====================================================== Priority Matrix */
.matrix-help { margin: 0 0 14px; font-size: 0.88rem; color: var(--muted); max-width: 86ch; }
.matrix { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 26px 0 0 30px; }
.matrix-axis { position: absolute; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.matrix-axis.x1 { top: 2px; left: calc(30px + 25% - 15px); transform: translateX(-50%); }
.matrix-axis.x2 { top: 2px; left: calc(30px + 75% - 15px); transform: translateX(-50%); }
.matrix-axis.y1, .matrix-axis.y2 { left: 0; writing-mode: vertical-rl; transform: rotate(180deg) translateY(50%); }
.matrix-axis.y1 { top: calc(26px + 25%); }
.matrix-axis.y2 { top: calc(26px + 75%); }
.matrix-box {
  --q: var(--accent); --q-soft: var(--accent-soft);
  position: relative; min-height: 220px; padding: 14px; border-radius: 20px; border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--q-soft), var(--surface) 110px); overflow: hidden;
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.matrix-box[data-q="do"] { --q: var(--p-urgent, #E5484D); --q-soft: var(--p-urgent-soft, #FDECEC); }
.matrix-box[data-q="schedule"] { --q: var(--focus-blue, var(--accent)); --q-soft: var(--blue-10, var(--accent-soft)); }
.matrix-box[data-q="quick"] { --q: var(--tone-amber, #A57800); --q-soft: var(--yellow-10, var(--warn-soft)); }
.matrix-box[data-q="later"] { --q: var(--tone-teal, #138C8B); --q-soft: var(--teal-10, var(--surface-3)); }
.matrix-box header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 10px; }
.matrix-box h2 { margin: 0; font-size: 1.02rem; color: var(--q); }
.mx-hint { font-size: 0.78rem; color: var(--muted); }
.mx-count { margin-left: auto; font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--q); }
.matrix-box .mx-here { margin-left: 4px; min-height: 28px; padding: 2px 12px; }
.matrix-box.drop { border-color: var(--q); box-shadow: 0 0 0 3px color-mix(in srgb, var(--q) 28%, transparent); transform: scale(1.012); }
.mx-list { display: grid; gap: 6px; align-content: start; max-height: 330px; overflow-y: auto; padding: 2px; margin: -2px; }
button.mx-task {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left;
  min-height: 0; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 500; cursor: grab;
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease), background var(--ease);
}
button.mx-task:hover { background: var(--surface); border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
button.mx-task[aria-pressed="true"] { border-color: var(--q); box-shadow: 0 0 0 2px color-mix(in srgb, var(--q) 30%, transparent); }
button.mx-task.dragging { opacity: 0.45; cursor: grabbing; }
.mx-task .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-task .d { font-size: 0.74rem; color: var(--muted); white-space: nowrap; }
.mx-task .d.late { color: var(--danger); font-weight: 600; }
.mx-empty { margin: 0; padding: 22px 10px; text-align: center; font-size: 0.86rem; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: 12px; }
.mx-more { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted); }
@media (max-width: 760px) {
  .matrix { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .matrix-axis { display: none; }
  .matrix-box { min-height: 0; }
}

/* ================================================================ Journey */
.journey-hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: center;
  padding: 26px 28px; margin-bottom: 16px; border-radius: 24px; color: #fff;
  background: linear-gradient(120deg, #1D2F7F 0%, #2C58DD 38%, #7A3FC0 78%, #A149D4 100%);
  box-shadow: 0 18px 44px rgba(72, 60, 190, 0.26);
}
.journey-hero::before, .journey-hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; filter: blur(2px); }
.journey-hero::before { width: 320px; height: 320px; right: -90px; top: -150px; background: radial-gradient(closest-side, rgba(52, 208, 207, 0.55), transparent); animation: drift 16s ease-in-out infinite; }
.journey-hero::after { width: 240px; height: 240px; right: 18%; bottom: -150px; background: radial-gradient(closest-side, rgba(251, 189, 8, 0.45), transparent); animation: drift 20s ease-in-out infinite reverse; }
@keyframes drift { 50% { transform: translate(-26px, 18px) scale(1.08); } }
.journey-hero > * { position: relative; z-index: 1; }
.level-ring {
  --pct: 0; width: 132px; aspect-ratio: 1; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(closest-side, rgba(20, 28, 80, 0.72) 80%, transparent 81%), conic-gradient(#FBBD08 calc(var(--pct) * 1%), rgba(255, 255, 255, 0.22) 0);
  transition: --pct 900ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@property --pct { syntax: "<number>"; inherits: true; initial-value: 0; }
.level-num { font-family: var(--display); font-size: 2.6rem; font-weight: 700; line-height: 1; color: #fff; }
.level-word { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; }
.journey-kicker { margin: 0; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.85; }
.journey-name { margin: 2px 0 4px; color: #fff !important; font-size: clamp(1.5rem, 4vw, 2.2rem); line-height: 1.1; }
.journey-xp { margin: 0 0 12px; font-size: 0.95rem; opacity: 0.95; }
.journey-xp strong { font-family: var(--display); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.journey-meter { height: 8px; max-width: 420px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); overflow: hidden; }
.journey-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #FBBD08, #FFE08A); transition: width 900ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.badge-card {
  --b: var(--focus-blue, var(--accent)); --b-soft: var(--blue-10, var(--accent-soft));
  position: relative; display: grid; gap: 6px; justify-items: center; text-align: center; padding: 14px 10px 12px;
  border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); overflow: hidden;
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease);
}
.badge-card[data-tone="yellow"] { --b: var(--yellow-text, #A57800); --b-soft: var(--yellow-10, #FFF8E1); }
.badge-card[data-tone="teal"] { --b: var(--teal-text, #138C8B); --b-soft: var(--teal-10, #E8FAFA); }
.badge-card[data-tone="purple"] { --b: var(--purple-text, #7D2FAE); --b-soft: var(--purple-10, #F5EDFB); }
.badge-card[data-tone="orange"] { --b: var(--tone-coral, #B8481A); --b-soft: var(--tone-coral-soft, #FEF0E8); }
.badge-medal { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 1.05rem; background: var(--surface-3); color: var(--muted); }
.badge-card strong { font-size: 0.88rem; color: var(--text); }
.badge-card span.how { font-size: 0.74rem; color: var(--muted); line-height: 1.3; }
.badge-card .prog { width: 100%; height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 2px; }
.badge-card .prog i { display: block; height: 100%; border-radius: inherit; background: var(--b); }
.badge-card .count { font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge-card.earned { background: var(--b-soft); border-color: transparent; }
.badge-card.earned .badge-medal { background: var(--b); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--b) 38%, transparent); }
:root[data-theme="dark"] .badge-card.earned .badge-medal { color: #12141F; }
.badge-card.earned::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; transform: translateX(-120%);
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.5) 50%, transparent 65%);
}
.badge-card.earned:hover::after { animation: sheen 900ms ease; }
.badge-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.badge-card.fresh { animation: badge-pop 900ms cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes badge-pop { 0% { transform: scale(0.6) rotate(-8deg); } 60% { transform: scale(1.08) rotate(2deg); } 100% { transform: none; } }
@keyframes sheen { to { transform: translateX(120%); } }
@media (max-width: 560px) {
  .journey-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 22px 18px; }
  .journey-meter { margin: 0 auto; }
}

/* ============================================================ Confetti */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3000; display: none; }
.confetti.on { display: block; }

/* ============================================================== Motion */
/* Theme switch: the new theme opens as a circle from the toggle button. */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.theme-reveal::view-transition-new(root) { animation: theme-reveal 620ms cubic-bezier(0.3, 0.7, 0.2, 1); z-index: 2; }
html.theme-reveal::view-transition-old(root) { z-index: 1; }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--reveal-x, 90%) var(--reveal-y, 5%)); }
  to { clip-path: circle(150vmax at var(--reveal-x, 90%) var(--reveal-y, 5%)); }
}

/* A page's blocks rise in one after another when you open it. */
.tab-panel.enter > * { animation: rise-in 460ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.tab-panel.enter > *:nth-child(2) { animation-delay: 50ms; }
.tab-panel.enter > *:nth-child(3) { animation-delay: 100ms; }
.tab-panel.enter > *:nth-child(4) { animation-delay: 150ms; }
.tab-panel.enter > *:nth-child(5) { animation-delay: 200ms; }
.tab-panel.enter > *:nth-child(n+6) { animation-delay: 240ms; }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } }

/* Lists and tiles that are filled in by script arrive in a short cascade. */
.kpis > .kpi, .badges > .badge-card, .mx-list > .mx-task, .focus-picks > .focus-pick,
.review-list > .rl, .quality-scores > .q-score { animation: rise-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
:is(.kpis, .badges, .mx-list, .focus-picks, .review-list, .quality-scores) > :nth-child(2) { animation-delay: 40ms; }
:is(.kpis, .badges, .mx-list, .focus-picks, .review-list, .quality-scores) > :nth-child(3) { animation-delay: 80ms; }
:is(.kpis, .badges, .mx-list, .focus-picks, .review-list, .quality-scores) > :nth-child(4) { animation-delay: 120ms; }
:is(.kpis, .badges, .mx-list, .focus-picks, .review-list, .quality-scores) > :nth-child(5) { animation-delay: 160ms; }
:is(.kpis, .badges, .mx-list, .focus-picks, .review-list, .quality-scores) > :nth-child(n+6) { animation-delay: 200ms; }

/* Bars grow from zero; heatmap squares pop in column by column. */
.bar-row .fill, .q-score .meter i, .badge-card .prog i { transform-origin: left center; animation: grow-x 800ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.rd-bars i, .focus-week .bar { transform-origin: center bottom; animation: grow-y 700ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes grow-y { from { transform: scaleY(0); } }
.heat span { animation: heat-pop 420ms cubic-bezier(0.2, 1.3, 0.4, 1) backwards; animation-delay: calc(var(--i, 0) * 9ms); }
@keyframes heat-pop { from { transform: scale(0.2); opacity: 0; } }

/* Toasts spring up; dialogs settle in; the bell rings once when something is new. */
.toast { animation: toast-spring 460ms cubic-bezier(0.2, 1.25, 0.35, 1) backwards; }
@keyframes toast-spring { from { opacity: 0; transform: translateY(18px) scale(0.94); } }
dialog[open]:not(.welcome) { animation: dialog-in 300ms cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
.bell:has(.bell-dot:not([hidden])) .icon { transform-origin: 50% 10%; animation: bell-ring 1.1s ease 600ms 1; }
@keyframes bell-ring { 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); } }
.welcome-steps li { animation: rise-in 420ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.welcome-steps li:nth-child(1) { animation-delay: 160ms; }
.welcome-steps li:nth-child(2) { animation-delay: 240ms; }
.welcome-steps li:nth-child(3) { animation-delay: 320ms; }

/* The current navigation marker slides into place; the logo nods on hover. */
button.nav-item[aria-current="page"]::before { animation: marker-in 320ms cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes marker-in { from { transform: scaleY(0); opacity: 0; } }
.top-brand .logo-mark { transition: transform 420ms cubic-bezier(0.2, 1.4, 0.4, 1); }
.top-brand:hover .logo-mark { transform: rotate(-8deg) scale(1.08); }
.hero-deco { animation: drift 18s ease-in-out infinite; }

/* A light sweeps across the main call-to-action buttons on hover. */
#focusStart, button.next-cta, #analyzeButton, #welcomeSample { position: relative; overflow: hidden; }
:is(#focusStart, button.next-cta, #analyzeButton, #welcomeSample)::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; transform: translateX(-120%);
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.34) 50%, transparent 70%);
}
:is(#focusStart, button.next-cta, #analyzeButton, #welcomeSample):hover::after { animation: sheen 800ms ease; }

/* Tiles follow the pointer with a soft light. */
.kpi, .badge-card, .matrix-box, .q-score { --mx: 50%; --my: 0%; }
:is(.kpi, .q-score, .matrix-box)::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 240ms ease; border-radius: inherit;
  background: radial-gradient(220px circle at var(--mx) var(--my), color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
}
.q-score { position: relative; overflow: hidden; }
:is(.kpi, .q-score, .matrix-box):hover::after { opacity: 1; }
.matrix-box > * { position: relative; z-index: 1; }

/* A number that just changed gets a brief lift. */
.tick { animation: tick 520ms cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes tick { 40% { transform: translateY(-3px) scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  .next-step::before, .next-orb, .journey-hero::before, .journey-hero::after, .hero-deco,
  .tab-panel.enter > *, .kpis > .kpi, .badges > .badge-card, .mx-list > .mx-task, .focus-picks > .focus-pick,
  .review-list > .rl, .quality-scores > .q-score, .bar-row .fill, .q-score .meter i, .badge-card .prog i,
  .rd-bars i, .focus-week .bar, .heat span, .toast, dialog[open]:not(.welcome), .bell .icon, .welcome-steps li,
  button.nav-item[aria-current="page"]::before, .badge-card.fresh, .tick { animation: none !important; }
  .level-ring, .journey-meter i, .top-brand .logo-mark { transition: none; }
  html.theme-reveal::view-transition-new(root) { animation: none; }
}
