/* Lattice motion & polish layer. Sits on top of chat.css to bring the
   platform to life. All effects gate on prefers-reduced-motion at the end. */

/* ─── Keyframes ─────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.25); opacity: 0.55; }
}
@keyframes pulse-ring {
  0%   { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(2.0); opacity: 0; }
}
@keyframes shimmer {
  0%   { background-position: -400% 0; }
  100% { background-position: 400% 0; }
}
@keyframes cursor-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translate3d(-8px, 0, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes progress-indeterminate {
  0%   { transform: translate3d(-100%, 0, 0); }
  100% { transform: translate3d(400%, 0, 0); }
}
@keyframes typing-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-4px); opacity: 1; }
}
@keyframes ambient-drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  50%  { transform: translate3d(3%, -2%, 0) rotate(4deg); }
  100% { transform: translate3d(0, 0, 0) rotate(0deg); }
}

/* ─── Page fade-in on load ──────────────────────────────────── */
.app-main > .page {
  animation: fadeInUp 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─── Staggered list reveal ─────────────────────────────────── */
[data-stagger] > * {
  opacity: 0;
  animation: fadeInUp 360ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
[data-stagger] > *:nth-child(1) { animation-delay: 40ms; }
[data-stagger] > *:nth-child(2) { animation-delay: 90ms; }
[data-stagger] > *:nth-child(3) { animation-delay: 140ms; }
[data-stagger] > *:nth-child(4) { animation-delay: 190ms; }
[data-stagger] > *:nth-child(5) { animation-delay: 240ms; }
[data-stagger] > *:nth-child(6) { animation-delay: 290ms; }
[data-stagger] > *:nth-child(7) { animation-delay: 340ms; }
[data-stagger] > *:nth-child(8) { animation-delay: 380ms; }
[data-stagger] > *:nth-child(n+9) { animation-delay: 420ms; }

/* ─── Live status indicator (pulsing dot + ring) ────────────── */
.live-dot {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: 0.3px; color: #55555e;
  font-weight: 600; text-transform: uppercase;
}
.live-dot::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #2ea44f;
  box-shadow: 0 0 0 0 rgba(46, 164, 79, 0.5);
  animation: pulse-dot 1600ms ease-in-out infinite;
  position: relative;
}
.live-dot--amber::before  { background: #f59e0b; box-shadow: 0 0 0 0 rgba(245,158,11,0.5); }
.live-dot--yellow::before { background: #ffe600; box-shadow: 0 0 0 0 rgba(255,230,0,0.5); }
.live-dot--red::before    { background: #cf222e; box-shadow: 0 0 0 0 rgba(207,34,46,0.5); }

.live-dot--ring { position: relative; }
.live-dot--ring::after {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(46, 164, 79, 0.35);
  transform-origin: center;
  animation: pulse-ring 1800ms ease-out infinite;
  pointer-events: none;
  margin-top: -4px;
}

/* ─── Shimmer loading (skeleton) ────────────────────────────── */
.shimmer, .skeleton {
  background: linear-gradient(
    100deg,
    rgba(230, 230, 225, 0.35) 0%,
    rgba(255, 230, 0, 0.18) 20%,
    rgba(230, 230, 225, 0.35) 40%,
    rgba(230, 230, 225, 0.35) 100%
  );
  background-size: 400% 100%;
  animation: shimmer 2400ms ease-in-out infinite;
  border-radius: 6px;
}
.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton-line--lg { height: 18px; margin: 10px 0; }
.skeleton-line--sm { height: 10px; margin: 4px 0; }

/* ─── Typing indicator (AI draft in-progress) ───────────────── */
.typing-indicator {
  display: inline-flex; align-items: flex-end; gap: 4px;
  padding: 6px 10px; background: #f3f3ee;
  border-radius: 16px; vertical-align: middle;
}
.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #55555e;
  animation: typing-dot 1200ms ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 160ms; }
.typing-indicator span:nth-child(3) { animation-delay: 320ms; }

/* ─── Indeterminate progress bar ────────────────────────────── */
.progress-indeterminate {
  position: relative; height: 3px; background: rgba(0,0,0,0.05);
  overflow: hidden; border-radius: 2px;
}
.progress-indeterminate::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 25%; background: linear-gradient(90deg, transparent, #ffe600, transparent);
  animation: progress-indeterminate 1600ms ease-in-out infinite;
}

/* ─── Hover elevation for cards ─────────────────────────────── */
.doc-module, .meth-card, .ctc-tile, .rag-tile, .budget-metric, .raid-card {
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 220ms ease;
  will-change: transform;
}
.doc-module:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(46, 46, 56, 0.08), 0 4px 8px rgba(46, 46, 56, 0.04);
}
.meth-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(46, 46, 56, 0.10), 0 4px 8px rgba(46, 46, 56, 0.04);
}
.ctc-tile:hover,
.budget-metric:hover,
.rag-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(46, 46, 56, 0.06);
}
.raid-card {
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}
.raid-card:hover {
  transform: translateX(2px);
  box-shadow: 0 6px 14px rgba(46, 46, 56, 0.06);
}

/* ─── Primary button: gradient + sheen hover ────────────────── */
.btn-primary, .btn.btn-primary {
  background: linear-gradient(135deg, #ffe600 0%, #ffd700 100%);
  color: #2e2e38;
  border: 0;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 220ms ease, filter 180ms ease;
  box-shadow: 0 4px 10px rgba(255, 214, 0, 0.25);
}
.btn-primary::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg,
    transparent 0%, transparent 30%,
    rgba(255,255,255,0.55) 50%,
    transparent 70%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(255, 214, 0, 0.35);
  filter: brightness(1.02);
}
.btn-primary:hover::before { transform: translateX(100%); }
.btn-primary:active { transform: translateY(0); }

/* ─── Ghost button — refined hover ───────────────────────────── */
.btn-ghost:hover {
  background: rgba(255, 230, 0, 0.08);
  border-color: #ffe600;
}

/* ─── Sidebar: glass + active indicator ─────────────────────── */
.app-sidebar {
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
}

.nav-item {
  position: relative;
  transition: color 160ms ease, background 160ms ease;
}
.nav-item::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; background: #ffe600; border-radius: 0 2px 2px 0;
  transform: scaleY(0); transform-origin: center;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-item.is-active::before,
.nav-item:hover::before {
  transform: scaleY(1);
}
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(255,230,0,0.08), rgba(255,230,0,0) 60%);
}
.nav-item:hover { background: rgba(46, 46, 56, 0.04); }

/* ─── Topbar: frosted glass ─────────────────────────────────── */
.topbar {
  position: relative;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}

/* ─── Toast refinement — soft bounce ────────────────────────── */
.toast.is-in {
  animation: fadeInUp 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Status-chip pulse when active ─────────────────────────── */
.status-chip.status-active {
  position: relative;
}
.status-chip.status-active::before {
  content: ""; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: #2ea44f; margin-right: 6px;
  animation: pulse-dot 1600ms ease-in-out infinite;
  vertical-align: middle;
}

/* ─── Ambient hero gradient (dashboard, login) ─────────────── */
.ambient-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.ambient-hero::before,
.ambient-hero::after {
  content: ""; position: absolute; border-radius: 50%;
  filter: blur(70px); opacity: 0.35; pointer-events: none;
  z-index: -1;
}
.ambient-hero::before {
  width: 440px; height: 440px; top: -120px; right: -80px;
  background: radial-gradient(circle, rgba(255,230,0,0.55), transparent 65%);
  animation: ambient-drift 14s ease-in-out infinite alternate;
}
.ambient-hero::after {
  width: 520px; height: 520px; bottom: -200px; left: -120px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.30), transparent 65%);
  animation: ambient-drift 18s ease-in-out infinite alternate-reverse;
}

/* ─── Counter number tick-up emphasis ───────────────────────── */
.counter {
  font-variant-numeric: tabular-nums;
  transition: color 220ms ease;
}
.counter.is-animating { color: #caa800; }

/* ─── RAG tile chip pulse when amber/red ────────────────────── */
.rag-tile.rag-amber::before,
.rag-tile.rag-red::before {
  animation: pulse-dot 2200ms ease-in-out infinite;
}

/* ─── Focus-visible polish: keyboard only ───────────────────── */
:where(a, button, input, select, textarea, [role="button"]):focus-visible {
  outline: 2px solid #ffe600;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─── Section entrance when scrolled into view (JS-controlled) */
.reveal {
  opacity: 0; transform: translate3d(0, 14px, 0);
  transition: opacity 480ms cubic-bezier(0.22, 1, 0.36, 1),
              transform 480ms cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-in {
  opacity: 1; transform: translate3d(0, 0, 0);
}

/* ─── SOW/RFP section body focus — accent ring ──────────────── */
.sow-section-body:focus {
  outline: none;
  box-shadow: inset 3px 0 0 #ffe600;
  transition: box-shadow 220ms ease;
}

/* ─── Reduced motion: kill everything ambient ───────────────── */
@media (prefers-reduced-motion: reduce) {
  .app-main > .page,
  [data-stagger] > *,
  .reveal,
  .toast.is-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .live-dot::before,
  .live-dot--ring::after,
  .status-chip.status-active::before,
  .rag-tile.rag-amber::before,
  .rag-tile.rag-red::before,
  .ambient-hero::before,
  .ambient-hero::after,
  .typing-indicator span {
    animation: none !important;
  }
  .doc-module:hover, .meth-card:hover,
  .ctc-tile:hover, .budget-metric:hover,
  .rag-tile:hover, .raid-card:hover,
  .btn-primary:hover {
    transform: none !important;
  }
  .btn-primary::before { display: none; }
  .progress-indeterminate::before { animation: none !important; }
  .shimmer, .skeleton { animation: none !important; background: rgba(230,230,225,0.35); }
}
