/* Jötunn motion layer — tasteful, GPU-friendly (transform/opacity), on-brand midnight/ice.
   Everything here is disabled automatically when the user chooses reduced motion
   (body[data-motion=reduced]) or the OS prefers reduced motion — see the guard at the end. */

:root {
  --ease-out: cubic-bezier(.22, .68, 0, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --t-fast: .16s;
  --t-med: .28s;
}

/* ---------- Keyframes ---------- */
@keyframes jo-rise { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }
@keyframes jo-pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes jo-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes jo-slide-up { from { opacity: 0; transform: translate3d(0, 24px, 0); } to { opacity: 1; transform: none; } }
@keyframes jo-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--good); opacity: 1; } 50% { box-shadow: 0 0 10px 2px var(--good); opacity: .65; } }
@keyframes jo-breathe { 0%, 100% { box-shadow: 0 10px 40px #00000077, 0 0 0 1px #49728f55; } 50% { box-shadow: 0 10px 44px #00000088, 0 0 14px 1px #7ecfff33; } }
@keyframes jo-sheen { from { transform: translateX(-120%) skewX(-18deg); } to { transform: translateX(260%) skewX(-18deg); } }
@keyframes jo-shimmer { from { background-position: -420px 0; } to { background-position: 420px 0; } }
@keyframes jo-check-pop { 0% { transform: scale(0); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes jo-bump { 0% { transform: scale(1); } 35% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes jo-spin { to { transform: rotate(360deg); } }
@keyframes jo-dot-ping { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(2.4); opacity: 0; } }
@keyframes jo-drop-flash { 0% { box-shadow: inset 0 0 0 2px var(--accent); } 100% { box-shadow: inset 0 0 0 2px transparent; } }

/* ---------- Page / view entrance (played on navigation only; app.js toggles .view-enter) ---------- */
#content.view-enter > * { animation: jo-rise var(--t-med) var(--ease-out) both; }
.topbar .view-enter, #topbar.enter #page-title { animation: jo-fade var(--t-med) var(--ease-out) both; }
/* a touch of life inside the first screenful */
.view-enter .stats > * { animation: jo-pop var(--t-med) var(--ease-spring) both; }
.view-enter .stats > :nth-child(2) { animation-delay: .05s; }
.view-enter .stats > :nth-child(3) { animation-delay: .1s; }
.view-enter .stats > :nth-child(4) { animation-delay: .15s; }
.view-enter .stepper-cards > * { animation: jo-pop var(--t-med) var(--ease-spring) both; }
.view-enter .stepper-cards > :nth-child(2) { animation-delay: .04s; }
.view-enter .stepper-cards > :nth-child(3) { animation-delay: .08s; }
.view-enter .stepper-cards > :nth-child(4) { animation-delay: .12s; }
.view-enter .stepper-cards > :nth-child(5) { animation-delay: .16s; }
.view-enter .stepper-cards > :nth-child(6) { animation-delay: .2s; }

/* ---------- Buttons: press, lift, sheen on primary, icon nudge ---------- */
.btn { transition: background .15s, transform .12s var(--ease-spring), box-shadow .18s, filter .15s, border-color .15s; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.97); }
.btn.primary { position: relative; overflow: hidden; }
.btn.primary::after { content: ''; position: absolute; top: 0; left: 0; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, #ffffff55, transparent); transform: translateX(-120%) skewX(-18deg); opacity: 0; pointer-events: none; }
.btn.primary:hover:not(:disabled)::after { opacity: 1; animation: jo-sheen .7s var(--ease-out); }
.btn.primary:hover:not(:disabled) { transform: translateY(-2px) scale(1.01); }
.btn:hover:not(:disabled) .ico { transition: transform .2s var(--ease-spring); }
.btn:hover:not(:disabled) .ico { transform: translateX(1px); }
/* arrow/next buttons: nudge the trailing glyph */
.btn:hover:not(:disabled) { }
.next-step .btn:hover:not(:disabled), .step-card:hover { }
.chip, .seg button, .sev-chip, .result-chips .chip { transition: background .15s, border-color .15s, color .15s, transform .12s var(--ease-spring); }
.chip:active, .result-chips .chip:active { transform: scale(.92); }
.chip[aria-pressed=true] { animation: jo-pop .22s var(--ease-spring); }
.link, .cell-link { transition: color .15s; }

/* icon-only buttons spin/scale a touch */
.btn.icon:hover:not(:disabled) .ico, .btn.ghost.icon:hover:not(:disabled) { transition: transform .25s var(--ease-spring); }
.menu-wrap .btn.icon[aria-expanded=true] { color: var(--accent); }

/* ---------- Cards, rows, tiles: hover lift + enter pop ---------- */
.project-card, .rcard, .note-card, .tool-card, .ref-card, .playbook-card, .cmd-card, .hyp-card, .ev-tile, .test-tile, .choice-card { transition: transform .18s var(--ease-out), box-shadow .2s, border-color .18s; }
.project-card:hover, .rcard:hover, .note-card:hover, .ev-tile:hover, .test-tile:hover, .choice-card:not(.static):hover { transform: translateY(-3px); }
.view-enter .card-grid > *, .view-enter .evidence-grid > *, .view-enter .test-grid > * { animation: jo-pop .3s var(--ease-out) both; }
.view-enter .card-grid > :nth-child(n+2), .view-enter .test-grid > :nth-child(n+2) { animation-delay: .03s; }
.view-enter .card-grid > :nth-child(n+4), .view-enter .test-grid > :nth-child(n+4) { animation-delay: .06s; }
.view-enter .card-grid > :nth-child(n+6), .view-enter .test-grid > :nth-child(n+6) { animation-delay: .09s; }
.dtable tbody tr, .list-row, .fx-item, .audit-row, .import-list li, .tl-row, .search-hit { transition: background .14s, color .14s; }
.dtable tbody tr:hover { transform: none; }
.row-link, .cell-link, .as-link { transition: background .14s, color .14s; }
.kcard { transition: transform .15s var(--ease-out), box-shadow .18s, border-color .15s, opacity .15s; }
.kcard:hover { transform: translateY(-2px) scale(1.01); }
.kcard:active { cursor: grabbing; }
.kcol.drop-target { animation: jo-drop-flash .5s var(--ease-out); }

/* stat tiles: accent bar sweep on hover + lift */
.stat { transition: transform .18s var(--ease-out), border-color .18s, box-shadow .2s; }
a.stat:hover { transform: translateY(-3px); box-shadow: 0 12px 30px #00000033; }
.stat::before { transition: width .3s var(--ease-out); }
.stat:hover::before { width: 46px; }

/* ---------- Navigation ---------- */
.mainnav a { transition: background .16s, border-color .16s, color .16s, transform .12s; }
.mainnav a:hover { transform: translateX(2px); }
.mainnav a[aria-current=page] { animation: jo-fade .3s var(--ease-out); }
.mainnav a .ico { transition: transform .2s var(--ease-spring); }
.mainnav a:hover .ico { transform: scale(1.18); }
.subnav a, .ptabs a, .dtabs a { transition: background .16s, color .16s, box-shadow .16s; }
.ptabs a[aria-current=page] { animation: jo-pop .26s var(--ease-spring); }

/* ---------- Lifecycle steps / checkmarks ---------- */
.step-card .step-n, .ptabs .n.done, .ready-list .ok .mark, .check-row.is-done input { transition: background .2s, border-color .2s, color .2s; }
.step-card.done .step-n, .ptabs .n.done { }
.ready-list .ok .mark { animation: jo-check-pop .34s var(--ease-spring); }
.sev-dot, .live-dot { transition: transform .2s var(--ease-spring); }

/* ---------- Progress bars: smooth fill + subtle sheen ---------- */
progress { transition: none; }
progress::-webkit-progress-value { transition: width .5s var(--ease-out); background-image: linear-gradient(100deg, var(--accent), #bfe9ff); }
progress::-moz-progress-bar { transition: width .5s var(--ease-out); }

/* ---------- Timer / session bar: slides in, breathes, dot pings ---------- */
#session-bar:not([hidden]) { animation: jo-slide-up .36s var(--ease-spring) both, jo-breathe 3.4s ease-in-out 1.2s infinite; }
#session-bar .live-dot:not(.paused) { position: relative; }
#session-bar .live-dot:not(.paused)::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 1px solid var(--good); animation: jo-dot-ping 1.6s var(--ease-out) infinite; }
#session-bar .live-dot.paused { animation: none; }
#sb-clock { transition: color .3s; }
.btn[data-action=timer-start] .ico { transition: transform .3s var(--ease-spring); }
.btn[data-action=timer-start]:hover .ico { transform: rotate(-20deg) scale(1.15); }

/* ---------- Toast: pop in from the corner ---------- */
#toast:not([hidden]) { animation: jo-slide-up .34s var(--ease-spring) both; }

/* ---------- Dialogs: scale + fade, backdrop fade ---------- */
dialog[open] { animation: jo-pop .26s var(--ease-out) both; }
dialog::backdrop { animation: jo-fade .2s ease both; }
.modal-head, .wizard-body, .modal-body { }
.stepper .current .step-n { animation: jo-pop .3s var(--ease-spring); }

/* ---------- Hero: gentle fade-in on entrance ---------- */
.hero { overflow: hidden; }
.view-enter .hero { animation: jo-pop .4s var(--ease-out) both; }

/* ---------- CVSS score bump when it changes (findings.js adds .bump) ---------- */
.cvss-out .cvss-score.bump { animation: jo-bump .4s var(--ease-spring); }
.cvss-score b { transition: color .25s; }

/* ---------- Severity / value badges: gentle hover ---------- */
.badge, .sev { transition: transform .12s var(--ease-spring), border-color .15s; }
a.badge:hover { transform: translateY(-1px); }

/* ---------- Loading shimmer (apply .skeleton to a placeholder box) ---------- */
.skeleton { background: linear-gradient(100deg, #0c2032 30%, #16344b 50%, #0c2032 70%); background-size: 840px 100%; border-radius: var(--radius-sm); animation: jo-shimmer 1.3s linear infinite; min-height: 1em; color: transparent !important; }
.loading-dot { display: inline-block; width: 1em; text-align: center; }
.loading-dot::after { content: '◷'; display: inline-block; animation: jo-spin 1s linear infinite; }

/* ---------- Alerts bell ---------- */
.bell .dot-count { animation: jo-pop .4s var(--ease-spring) both; }
@keyframes jo-bell-swing { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(14deg); } 40% { transform: rotate(-10deg); } 60% { transform: rotate(6deg); } 80% { transform: rotate(-3deg); } }
.bell:hover { animation: jo-bell-swing .6s var(--ease-out); }

/* ---------- Respect the calm: disable ALL of the above ---------- */
body[data-motion=reduced] *, body[data-motion=reduced] *::before, body[data-motion=reduced] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
}
@media (prefers-reduced-motion: reduce) {
  body:not([data-motion=full]) *, body:not([data-motion=full]) *::before, body:not([data-motion=full]) *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
  }
}
