/* Motion.
   One orchestrated moment — the period card cascading in and the report writing
   itself out. Everything else is a 120-180ms micro-interaction that acknowledges
   an action and gets out of the way. */

:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --fast: 140ms;
  --base: 220ms;
  --slow: 420ms;
}

/* --------------------------------------------------------------- keyframes */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rise-sm {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  60% {
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* The one flourish on a new entry: a blue wash that drains away. */
@keyframes settle {
  0% {
    opacity: 0;
    transform: translateY(-6px);
    background: rgba(0, 82, 255, 0.07);
  }
  100% {
    opacity: 1;
    transform: none;
    background: transparent;
  }
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(207, 32, 47, 0.5);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(207, 32, 47, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(207, 32, 47, 0);
  }
}

@keyframes bar {
  0%,
  100% {
    transform: scaleY(0.35);
  }
  50% {
    transform: scaleY(1);
  }
}

@keyframes shimmer {
  from {
    background-position: -420px 0;
  }
  to {
    background-position: 420px 0;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------ entry states */

.screen-enter {
  animation: rise var(--base) var(--ease-out) both;
}

.task-row {
  animation: rise-sm var(--base) var(--ease-out) both;
}

.task-row.is-new {
  animation: settle var(--slow) var(--ease-out) both;
}

/* The cascade: each day row lands a beat after the one above it. */
.ui-day {
  animation: rise-sm var(--base) var(--ease-out) both;
}

.rail-item {
  animation: fade var(--base) var(--ease-out) both;
}

.badge {
  animation: pop var(--base) var(--ease-out) both;
}

/* ------------------------------------------------------ micro-interactions */

.icon {
  flex: none;
  transition: transform var(--fast) var(--ease-out);
}

.btn,
.btn-icon,
.tab,
.rail-item,
.preset,
.task-actions button {
  transition:
    background-color var(--fast) var(--ease-out),
    border-color var(--fast) var(--ease-out),
    color var(--fast) var(--ease-out),
    transform var(--fast) var(--ease-out),
    box-shadow var(--fast) var(--ease-out),
    opacity var(--fast) var(--ease-out);
}

.btn:active:not(:disabled),
.btn-icon:active,
.preset:active {
  transform: scale(0.96);
}

.btn-icon:hover .icon {
  transform: scale(1.12);
}

.day-nav .btn-icon:hover {
  background: var(--hairline);
}

.composer {
  transition: box-shadow var(--base) var(--ease-out), border-color var(--base) var(--ease-out);
}

.composer:focus-within {
  box-shadow: var(--shadow-soft);
}

.task-row {
  transition: background-color var(--fast) var(--ease-out);
}

.task-row:hover {
  background: var(--surface-soft);
}

.ui-card {
  transition: transform var(--base) var(--ease-out);
}

.report-card {
  transition: box-shadow var(--base) var(--ease-out);
}

.report-card:hover {
  box-shadow: var(--shadow-soft);
}

/* Copy -> Copied, without a layout jump. */
.btn .icon-swap {
  display: inline-grid;
  place-items: center;
}

.btn.is-done {
  color: var(--semantic-up);
}

/* ------------------------------------------------------------- mic states */

.mic-group.listening {
  animation: pulse-ring 1.6s ease-out infinite;
}

.mic-bars {
  display: none;
  align-items: center;
  gap: 2px;
  height: 14px;
}

.mic-group.listening .mic-bars {
  display: inline-flex;
}

.mic-group.listening .icon-mic-slot {
  display: none;
}

.mic-bars span {
  width: 2px;
  height: 100%;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
  animation: bar 900ms var(--ease-in-out) infinite;
}

.mic-bars span:nth-child(2) {
  animation-delay: 140ms;
}
.mic-bars span:nth-child(3) {
  animation-delay: 280ms;
}
.mic-bars span:nth-child(4) {
  animation-delay: 420ms;
}

/* ---------------------------------------------------- report writing state */

.spinner {
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--on-primary);
  animation: spin 700ms linear infinite;
}

/* Lines fill in one after another, so waiting reads as writing rather than hanging. */
.skeleton {
  display: none;
  padding: var(--space-md) 0;
}

.skeleton.on {
  display: block;
  animation: fade var(--base) var(--ease-out) both;
}

.skeleton-line {
  height: 12px;
  border-radius: var(--r-xs);
  margin-bottom: var(--space-sm);
  background: linear-gradient(
    90deg,
    var(--surface-strong) 25%,
    var(--surface-soft) 50%,
    var(--surface-strong) 75%
  );
  background-size: 840px 100%;
  animation: shimmer 1.5s linear infinite;
}

/* --------------------------------------------------------------- toasts */

.toast {
  animation: toast-in var(--base) var(--ease-out) both;
}

/* ---------------------------------------------------------- accessibility */

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.hero-dark :focus-visible {
  outline-color: var(--on-dark);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .btn:active:not(:disabled),
  .btn-icon:active,
  .preset:active {
    transform: none;
  }
}
