/* ══════════════════════════════════════════════════════════════════════════
   enhancements.css — modern polish + motion layer
   Loaded LAST (after style.css + cyber-theme.css), so it refines without
   replacing anything. Two goals:
     1. Make LIGHT mode feel clean & premium (soften the dark-oriented glows
        and black shadows that cyber-theme.css applies to every theme).
     2. Add tasteful, user-friendly motion (staggered entrances, smooth
        hovers, animated theme toggle) — all gated by prefers-reduced-motion.
   Safe to remove: delete the <link> in index.html to fully revert.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Motion tokens ────────────────────────────────────────────────────────── */
:root {
  --ease-out:   cubic-bezier(.22, .61, .36, 1);
  --ease-back:  cubic-bezier(.34, 1.56, .64, 1);
  --dur-fast:   .16s;
  --dur-med:    .28s;
  --dur-slow:   .5s;
}

/* ══════════════════════════════════════════════════════════════════════════
   1 ▸ LIGHT-MODE REFINEMENT
   cyber-theme.css was authored dark-first; in light mode its blue text-glows
   read as blurry halos and its rgba(0,0,0,.35) shadows look muddy. Re-tune.
   ══════════════════════════════════════════════════════════════════════════ */
[data-theme="light"] {
  /* Cleaner, layered soft shadows instead of a single heavy black one */
  --shadow:      0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.08);
  --shadow-glow: 0 0 0 1px rgba(59,130,246,.10), 0 6px 20px rgba(15,23,42,.07);
}

/* Kill the blurry blue halo on dark text; keep a crisp accent underline */
[data-theme="light"] .page-title,
[data-theme="light"] .cyber-hero-title,
[data-theme="light"] .modal-header h3 { text-shadow: none; }
[data-theme="light"] .stat-value      { text-shadow: none; }

/* Card / stat hover — soft elevation, faint accent border (no black glow) */
[data-theme="light"] .card:hover,
[data-theme="light"] .stat-card:hover {
  border-color: rgba(59,130,246,.35);
  box-shadow: 0 10px 28px rgba(15,23,42,.10), 0 0 0 1px rgba(59,130,246,.08);
}

/* HITL / conn cards + modal — replace heavy dark shadows */
[data-theme="light"] .hitl-card:hover {
  border-color: rgba(59,130,246,.4);
  box-shadow: 0 8px 24px rgba(15,23,42,.10);
}
[data-theme="light"] .modal {
  box-shadow: 0 24px 60px rgba(15,23,42,.18), 0 0 0 1px rgba(59,130,246,.12);
}
[data-theme="light"] .toast { box-shadow: 0 8px 24px rgba(15,23,42,.12); }

/* Softer table header tint + gentler row hover for a paper-clean feel */
[data-theme="light"] thead th {
  background: linear-gradient(180deg, rgba(59,130,246,.08), var(--bg-surface));
  border-bottom: 1px solid rgba(59,130,246,.22);
}
[data-theme="light"] .table-wrap table tbody tr:hover,
[data-theme="light"] tbody tr:hover { background: rgba(59,130,246,.05); }

/* Tone down badge/status glows so light mode stays flat & legible */
[data-theme="light"] .badge { box-shadow: none !important; }
[data-theme="light"] .status-dot.green  { box-shadow: 0 0 4px rgba(22,163,74,.5); }
[data-theme="light"] .status-dot.yellow { box-shadow: 0 0 4px rgba(217,119,6,.5); }
[data-theme="light"] .status-dot.red    { box-shadow: 0 0 4px rgba(220,38,38,.5); }

/* Light-mode scrollbar — the blue thumb from cyber-theme is too loud on white */
[data-theme="light"] *::-webkit-scrollbar-thumb { background: rgba(100,116,139,.35); }
[data-theme="light"] *::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,.55); }

/* Emblem glow is designed for a dark backdrop — soften on white */
[data-theme="light"] .logo-emblem { filter: drop-shadow(0 1px 3px rgba(15,23,42,.2)); animation: none; }

/* ══════════════════════════════════════════════════════════════════════════
   2 ▸ MOTION — entrance, hover & interaction polish
   ══════════════════════════════════════════════════════════════════════════ */

/* Staggered entrance for grids of cards/tiles. The nth-child delays make items
   cascade in instead of popping all at once — reads as intentional & premium. */
@keyframes fx-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.stats-grid > .stat-card,
.grid-auto > .card,
.conn-grid > .conn-card,
.hitl-card {
  animation: fx-rise var(--dur-med) var(--ease-out) both;
}
.stats-grid > .stat-card:nth-child(1),
.grid-auto  > .card:nth-child(1) { animation-delay: .02s; }
.stats-grid > .stat-card:nth-child(2),
.grid-auto  > .card:nth-child(2) { animation-delay: .07s; }
.stats-grid > .stat-card:nth-child(3),
.grid-auto  > .card:nth-child(3) { animation-delay: .12s; }
.stats-grid > .stat-card:nth-child(4),
.grid-auto  > .card:nth-child(4) { animation-delay: .17s; }
.stats-grid > .stat-card:nth-child(5) { animation-delay: .22s; }
.stats-grid > .stat-card:nth-child(6) { animation-delay: .27s; }

/* Table rows fade in as data lands (first ~10 rows staggered, rest instant) */
@keyframes fx-row { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
tbody tr { animation: fx-row var(--dur-med) var(--ease-out) both; }
tbody tr:nth-child(1) { animation-delay: .02s; }
tbody tr:nth-child(2) { animation-delay: .05s; }
tbody tr:nth-child(3) { animation-delay: .08s; }
tbody tr:nth-child(4) { animation-delay: .11s; }
tbody tr:nth-child(5) { animation-delay: .14s; }
tbody tr:nth-child(6) { animation-delay: .17s; }
tbody tr:nth-child(7) { animation-delay: .20s; }
tbody tr:nth-child(8) { animation-delay: .23s; }

/* Nav items — smooth icon nudge + active pop */
.nav-item { transition: background var(--dur-fast) var(--ease-out),
                        color var(--dur-fast) var(--ease-out),
                        box-shadow var(--dur-fast) var(--ease-out),
                        transform var(--dur-fast) var(--ease-out); }
.nav-item:hover  { transform: translateX(2px); }
.nav-item .nav-icon { transition: transform var(--dur-med) var(--ease-back); }
.nav-item:hover .nav-icon { transform: scale(1.18); }
.nav-item.active .nav-icon { transform: scale(1.1); }

/* Buttons — lift on hover, press on active (works alongside existing glow) */
.btn { transition: transform var(--dur-fast) var(--ease-out),
                   box-shadow var(--dur-fast) var(--ease-out),
                   background var(--dur-fast) var(--ease-out),
                   filter var(--dur-fast) var(--ease-out); }
.btn:hover:not(:disabled)  { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }

/* Theme toggle — the icon rotates & scales through the switch for delight */
.topbar-theme-toggle {
  transition: transform var(--dur-med) var(--ease-back),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  overflow: hidden;
}
.topbar-theme-toggle:hover { transform: rotate(18deg) scale(1.08); background: var(--cyan-glow); }
.topbar-theme-toggle:active { transform: rotate(-40deg) scale(.9); }

/* Modal entrance — scale/blur in rather than instant appear */
@keyframes fx-modal-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.modal { animation: fx-modal-in var(--dur-med) var(--ease-out) both; }
@keyframes fx-overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay { animation: fx-overlay-in var(--dur-fast) ease both; }

/* Badges / chips — gentle pop when they mount */
@keyframes fx-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
.badge, .cyber-chip { animation: fx-pop var(--dur-med) var(--ease-back) both; }

/* Progress / confidence bars — animated shimmer while filling */
.progress-fill { position: relative; overflow: hidden; }
.progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  transform: translateX(-100%);
  animation: fx-shimmer 1.8s var(--ease-out) infinite;
}
@keyframes fx-shimmer { to { transform: translateX(100%); } }

/* Toast — slide in from the right with a soft bounce */
.toast { animation: fx-toast-in var(--dur-med) var(--ease-back) both; }
@keyframes fx-toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* Skeleton shimmer helper — pages can add class="skeleton" for graceful loads */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 37%, var(--bg-card) 63%);
  background-size: 400% 100%;
  animation: fx-skeleton 1.4s ease infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
}
@keyframes fx-skeleton { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ── Smooth theme switch ───────────────────────────────────────────────────
   app.js adds .theme-transition to <html> just for the ~300ms of the toggle,
   so colors cross-fade instead of snapping — without transitions firing on
   every page navigation (which would be janky). */
html.theme-transition,
html.theme-transition * ,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color var(--dur-med) ease,
              color var(--dur-med) ease,
              border-color var(--dur-med) ease,
              box-shadow var(--dur-med) ease !important;
}

/* ── Respect reduced-motion: disable all of the above cleanly ──────────────── */
@media (prefers-reduced-motion: reduce) {
  .stats-grid > .stat-card, .grid-auto > .card, .conn-grid > .conn-card, .hitl-card,
  tbody tr, .modal, .modal-overlay, .badge, .cyber-chip, .toast {
    animation: none !important;
  }
  .progress-fill::after { animation: none; display: none; }
  .nav-item:hover, .btn:hover:not(:disabled), .topbar-theme-toggle:hover { transform: none; }
}
