
/* Motion + math lab chrome (shared across designs) */
@keyframes tn-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}
@keyframes tn-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes tn-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes tn-draw {
  from { stroke-dashoffset: 240; }
  to { stroke-dashoffset: 0; }
}
.viz-live i {
  animation: tn-pulse 1.6s ease-in-out infinite;
}
.hero-viz .viz-card {
  animation: tn-float 7s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .viz-live i, .hero-viz .viz-card { animation: none !important; }
}
.btn.primary {
  background-size: 200% 100%;
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}
.btn.primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}
.timeline-item, .project-card, .skill-card, .math-card, .insight-card {
  transition: transform 0.25s cubic-bezier(0.22,1,0.36,1), box-shadow 0.25s ease, border-color 0.25s ease;
}
.math-section { padding-bottom: 1rem; }
.math-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.math-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 14px);
  box-shadow: var(--shadow, 0 16px 40px rgba(0,0,0,0.12));
  padding: 1.1rem 1.15rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 100%;
}
.math-card h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.math-kicker {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.math-eq {
  margin: 0.15rem 0 0.35rem;
  overflow-x: auto;
  padding: 0.65rem 0.75rem;
  border-radius: calc(var(--radius, 14px) - 6px);
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  border: 1px solid var(--border);
  font-size: 1.02rem;
  line-height: 1.5;
}
.math-eq .katex-display { margin: 0.35rem 0; }
.math-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}
.math-viz-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.math-viz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 14px);
  box-shadow: var(--shadow, 0 16px 40px rgba(0,0,0,0.12));
  padding: 0.9rem;
}
.math-viz-card canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: calc(var(--radius, 14px) - 4px);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
.math-caption {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}
@media (max-width: 980px) {
  .math-grid, .math-viz-row {
    grid-template-columns: 1fr;
  }
}
/* KaTeX inherits theme */
.katex { color: var(--text) !important; }
.katex .mord, .katex .mrel, .katex .mbin { color: inherit; }


/* Decorative math wallpaper (background layer) */
.tn-math-wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.55;
}
.tn-math-wallpaper .tn-eq {
  position: absolute;
  color: var(--accent, #38bdf8);
  opacity: 0.14;
  font-family: "KaTeX_Main", "Times New Roman", "Computer Modern", serif;
  white-space: nowrap;
  user-select: none;
  transform-origin: center center;
  filter: blur(0.2px);
  transition: opacity 0.4s ease;
}
.tn-math-wallpaper .tn-eq .katex {
  color: inherit !important;
  font-size: inherit !important;
}
.tn-math-wallpaper .tn-eq.tn-eq-muted {
  color: var(--muted, #94a3b8);
  opacity: 0.11;
}
.tn-math-wallpaper .tn-eq.tn-eq-strong {
  color: var(--accent-2, #818cf8);
  opacity: 0.16;
}
@keyframes tn-eq-drift {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(var(--rot, 0deg)); }
  50% { transform: translate3d(var(--dx, 8px), var(--dy, -10px), 0) rotate(var(--rot, 0deg)); }
}
@keyframes tn-eq-fade {
  0%, 100% { opacity: var(--op, 0.12); }
  50% { opacity: calc(var(--op, 0.12) * 1.45); }
}
.tn-math-wallpaper .tn-eq.tn-anim {
  animation:
    tn-eq-drift var(--dur, 18s) ease-in-out infinite,
    tn-eq-fade var(--fdur, 12s) ease-in-out infinite;
  animation-delay: var(--delay, 0s), var(--delay, 0s);
}
@media (prefers-reduced-motion: reduce) {
  .tn-math-wallpaper .tn-eq.tn-anim { animation: none !important; }
}
/* Keep content above wallpaper; bg-canvas stays ambient */
.bg-canvas { z-index: 0; }
main, .site-header, .site-footer, #nn-switcher { position: relative; z-index: 1; }
/* Soft vignette so equations never fight body text */
.tn-math-wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, transparent 0%, color-mix(in srgb, var(--bg, #020617) 55%, transparent) 72%, var(--bg, #020617) 100%),
    linear-gradient(to bottom, color-mix(in srgb, var(--bg, #020617) 25%, transparent), transparent 18%, transparent 78%, color-mix(in srgb, var(--bg, #020617) 40%, transparent));
  pointer-events: none;
}
