/* ============================================================
   MOTION - extra animation and micro-interactions.
   Everything here is switched off by the "Pause animations"
   setting (html.a11y-no-motion, see accessibility.css) and by
   the device's reduced-motion preference (base.css).
   ============================================================ */

/* Reading progress line */
/* Width is set via `transform: scaleX(...)` from JS (cheaper than changing
   `width` — scale is compositor-only, width triggers layout).
   `transform-origin: 0 50%` means it grows from the left edge. */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 120;                 /* above modals (110) so it's always visible */
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

/* Cards and spotlight tiles lift on hover */
.paper-card {
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.paper-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-pop);
  border-color: var(--gold);
}

.spot-card {
  transition: transform .22s ease, box-shadow .22s ease, background .2s ease;
}

.spot-card:hover {
  transform: translateY(-3px);
}

/* Buttons: soft lift and press */
.btn,
.chip,
.cite-tab,
.icon-btn {
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}

/* Hover lifts slightly; active presses down (scale) for tactile feedback.
   Two different transforms so hover and click feel distinct. */
.btn:hover,
.chip:hover {
  transform: translateY(-1px);
}

.btn:active,
.chip:active,
.icon-btn:active {
  transform: scale(.97);
}

/* Chat: bubbles and the launcher */
/* `both` fill mode: keep the from-state before the animation starts
   AND the to-state after it ends — no flash of unstyled content. */
.chat-msg {
  animation: msgIn .28s ease both;
}

/* Follow-up chips arrive 100ms after the bubble they belong to. */
.chat-chips {
  animation: msgIn .35s ease .1s both;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Floating buttons ease in */
/* `.back-to-top` is listed here but the actual class used in the HTML is
   `.fab-top` — harmless (this selector just doesn't match anything). */
.a11y-fab,
.footer-fab,
.back-to-top {
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
}

.a11y-fab:hover {
  transform: scale(1.08);
}

/* Theme toggle icon turns */
/* [data-theme-toggle] is a generic hook in case future theme toggles use
   the attribute instead of the .theme-toggle class. */
.theme-toggle svg,
[data-theme-toggle] svg {
  transition: transform .4s ease;
}

.theme-toggle:hover svg,
[data-theme-toggle]:hover svg {
  transform: rotate(18deg);
}

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

/* Filter chips and the saved banner appear with a small pop / slide */
.filter-chip {
  animation: chipIn .25s ease both;
}

@keyframes chipIn {
  from {
    opacity: 0;
    transform: scale(.85);
  }
}

.saved-banner {
  animation: slideDown .3s ease both;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Paper details and empty states fade up when they open */
.detail-layout,
.empty-state,
.error-state {
  animation: msgIn .4s ease both;
}

/* Accessibility button draws attention twice, then rests */
/* 4-value shorthand: name | duration | timing | delay | iteration-count.
   Delay of 1.5s lets the page settle first; iteration-count 2 means it
   pulses twice and then stops (doesn't nag the visitor forever). */
.a11y-fab {
  animation: fabRing 2.4s ease 1.5s 2;
}

/* Pulsing ring: starts with a coloured ring flush against the button,
   expands outward to 16px and fades to transparent. Combined with
   `var(--shadow-pop)` so the resting box-shadow is preserved. */
@keyframes fabRing {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 169, 55, .6), var(--shadow-pop);
  }
  70%,
  100% {
    box-shadow: 0 0 0 16px rgba(212, 169, 55, 0), var(--shadow-pop);
  }
}

/* Switches and stepper respond when touched */
.a11y-switch,
.a11y-row {
  transition: background .15s ease;
}

.a11y-switch:hover {
  background: rgba(212, 169, 55, .1);
}

.a11y-stepper button {
  transition: transform .15s ease, background .15s ease;
}

/* :not(:disabled) so the disabled A− / A+ buttons stay visually inert. */
.a11y-stepper button:hover:not(:disabled) {
  background: rgba(212, 169, 55, .18);
  transform: translateY(-1px);
}

/* Stats and spotlight numbers rise a little on hover */
.hero-stats .stat {
  transition: transform .2s ease;
}

.hero-stats .stat:hover {
  transform: translateY(-3px);
}