/* ============================================================
   dynamic.css — Ledger motion layer
   Uses ONLY existing tokens (colours, fonts).
   Concept: a brass rule is "struck under" a checked entry; numbers
   tick like a ledger counter. Load AFTER animations.css.
   Rules: animate transform/opacity only; entrance animations use
   fill-mode `backwards` (never `both`) so hover transforms still work.
   ============================================================ */

:root {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --brass-rgb: 29, 78, 216;
  --emerald-rgb: 4, 120, 87;
}

/* ---------- Global polish ---------- */
::selection { background: rgba(var(--brass-rgb), 0.28); color: var(--ink); }
h1, h2, h3 { text-wrap: balance; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
.btn:focus-visible, .tab-btn:focus-visible { outline-offset: 2px; }

/* ---------- Scroll progress rule (width driven by --scroll, set in motion.js) ---------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; width: 100%; height: 3px; z-index: 10000;
  background: linear-gradient(90deg, #1D4ED8, #14B8A6);
  transform: scaleX(var(--scroll, 0)); transform-origin: 0 50%; pointer-events: none;
}

.app-header { transition: box-shadow 0.3s, background 0.3s; }
html[data-scrolled] .app-header { box-shadow: var(--shadow-sm); }

/* ---------- Page + entrance choreography ---------- */
@keyframes rise   { from { opacity: 0; transform: translateY(18px) scale(0.985); } }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } }
.page-enter { animation: pageIn 0.5s var(--ease-out) backwards; }

/* ---------- Cards: lift + pointer spotlight (vars set in motion.js) ---------- */
.card { position: relative; }
.card:hover {
  background-image: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(var(--brass-rgb), 0.10), transparent 62%);
}

/* ---------- Buttons: lift, brass sheen, press ---------- */
.btn { position: relative; overflow: hidden; transition: transform 0.18s var(--ease-out), box-shadow 0.25s, background-color 0.25s, color 0.25s, border-color 0.25s; }
.btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:not(:disabled):active { transform: translateY(1px) scale(0.97); box-shadow: none; }
.btn-primary::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-130%); transition: transform 0.8s var(--ease-out);
}
.btn-primary:not(:disabled):hover::before { transform: translateX(130%); }

/* ---------- Status chips: attention dot / stamp ---------- */
@keyframes pop     { 0% { opacity: 0; transform: scale(0.6); } 100% { opacity: 1; transform: scale(1); } }
@keyframes dotPulse{ 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }
@keyframes stamp   { 0% { opacity: 0; transform: scale(2.2) rotate(-18deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.badge { animation: pop 0.45s var(--ease-spring) backwards; }
/* Attention dot / stamp only on real STATUS chips (StatusChip wraps them in .status-chip-container) — not on role/label badges */
.status-chip-container :is(.badge-yellow, .badge-orange, .badge-blue)::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; animation: dotPulse 1.8s ease-in-out infinite;
}
.status-chip-container .badge-green::before { content: '✓' / ''; font-weight: 700; display: inline-block; animation: stamp 0.55s 0.15s var(--ease-spring) backwards; }
.status-chip-container .badge-red::before   { content: '!' / ''; font-weight: 700; display: inline-block; animation: stamp 0.55s 0.15s var(--ease-spring) backwards; }

/* ---------- Tabs, inputs, toasts ---------- */
.tab-btn { border-radius: var(--radius-xs) var(--radius-xs) 0 0; }
.tab-btn:hover { background: rgba(var(--brass-rgb), 0.08); color: var(--ink); }
.tab-btn.active { background: linear-gradient(180deg, transparent, rgba(var(--brass-rgb), 0.07)); }
.tab-panel.active { animation: pageIn 0.4s var(--ease-out) backwards; }
input, select, textarea { transition: border-color 0.2s, box-shadow 0.25s; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; border-color: rgb(var(--brass-rgb)); box-shadow: var(--shadow-glow); }
@keyframes toastIn { from { opacity: 0; transform: translateX(28px) scale(0.96); } }
.toast { animation: toastIn 0.5s var(--ease-spring) backwards; }

/* ---------- Chatbot ---------- */
@keyframes ring { 0% { transform: scale(1); opacity: 0.7; } 80%, 100% { transform: scale(1.6); opacity: 0; } }
.chatbot-fab::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(var(--brass-rgb), 0.6); animation: ring 2.8s ease-out infinite; pointer-events: none; }
.chatbot-fab.open::before { animation: none; opacity: 0; }
.chatbot-fab:not(.open):hover { transform: scale(1.08) rotate(-4deg); }
.chatbot-window { transform-origin: bottom right; transition: opacity 0.3s, transform 0.4s var(--ease-spring); }

/* Reveal: hidden ONLY when JS has opted in (html.motion) — never blank without JS / reduced motion */
.reveal { opacity: 1; transform: none; }
html.motion .reveal:not(.in-view) { opacity: 0; transform: translateY(26px); }
html.motion .reveal .eyebrow::before { transform: scaleX(0); transform-origin: left; transition: transform 0.9s 0.25s var(--ease-out); }
html.motion .reveal.in-view .eyebrow::before { transform: scaleX(1); }

/* Layout safety: long text inside a .badge (About page <p class="badge">) must wrap instead of forcing horizontal scroll */
.badge { max-width: 100%; }
p.badge { white-space: normal; text-align: left; }

/* ---------- Respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .scroll-progress { display: none; }
}
@media (hover: none) { .card:hover { background-image: none; } }
