/* =====================================================================================
   Secure media vault theme + motion. Loaded after app.css.
   All animation lives in stylesheets (the CSP forbids inline styles and scripts), and
   everything is turned off under prefers-reduced-motion at the bottom of this file.
   ===================================================================================== */

:root {
  --accent-2: #0ea5e9;
  --glow: rgb(36 88 230 / 0.22);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (prefers-color-scheme: dark) {
  :root { --accent-2: #38bdf8; --glow: rgb(107 147 255 / 0.28); }
}

/* Smooth cross-page transitions (Chromium); header and sidebar stay put. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.22s; }
.app .topbar { view-transition-name: topbar; }
.app .sidebar { view-transition-name: sidebar; }

/* ---- Keyframes ---- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); } 50% { transform: translateY(-12px) rotate(var(--r, 0deg)); } }
@keyframes pulse-ring { 0% { transform: scale(0.55); opacity: 0.75; } 100% { transform: scale(2); opacity: 0; } }
@keyframes draw { from { stroke-dashoffset: 200; } to { stroke-dashoffset: 0; } }
@keyframes shackle { 0%, 15% { transform: translateY(-4px); } 28%, 88% { transform: none; } 100% { transform: translateY(-4px); } }
@keyframes scan { 0% { top: -20%; } 100% { top: 110%; } }
@keyframes chip-in { 0%, 30% { opacity: 0; transform: translateY(6px) scale(0.9); } 40%, 88% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-4px); } }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(0.3); } 50% { opacity: 1; transform: scale(1); } }
@keyframes glow-shift { 0%, 100% { transform: translate(-8%, -4%) scale(1); } 50% { transform: translate(8%, 6%) scale(1.15); } }
@keyframes grid-move { to { background-position: 0 44px, 0 44px; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes blink-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes progress { 0% { transform: scaleX(0); } 50% { transform: scaleX(0.6); } 100% { transform: scaleX(0.9); } }
@keyframes bell { 0%, 78%, 100% { transform: rotate(0); } 82% { transform: rotate(-12deg); } 87% { transform: rotate(10deg); } 92% { transform: rotate(-6deg); } }
@keyframes attn { 0%, 100% { box-shadow: 0 0 0 0 rgb(227 176 75 / 0); } 50% { box-shadow: 0 0 0 6px rgb(227 176 75 / 0.16); } }

/* ---- Brand & icons ---- */
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-shield { fill: var(--accent); transition: filter 0.3s; }
.brand-frame, .brand-hill { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.brand:hover .brand-shield { filter: drop-shadow(0 0 6px var(--accent)); }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }

/* ---- Buttons & inputs ---- */
.btn { transition: transform 0.15s var(--ease), background-color 0.2s, box-shadow 0.25s, filter 0.2s; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 20px -10px var(--accent); }
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), var(--accent-2)); box-shadow: 0 12px 26px -12px var(--accent); transform: translateY(-1px); }
.btn.is-loading { pointer-events: none; opacity: 0.85; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
input, select, textarea { transition: border-color 0.2s, box-shadow 0.2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 72px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.82rem; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.pw-toggle:hover { color: var(--accent); background: var(--accent-soft); }

/* ---- Auth: split layout with the vault scene ---- */
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr); }
.auth-visual {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 48px;
  background: linear-gradient(160deg, #0a1230 0%, #0f1a44 48%, #07233f 100%); color: #e8eeff;
}
.vault { position: absolute; inset: 0; z-index: -1; }
.vault-grid {
  position: absolute; inset: -40% -20% 0;
  background-image: linear-gradient(rgb(255 255 255 / 0.06) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  transform: perspective(700px) rotateX(58deg); transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, #000 10%, transparent 75%);
  animation: grid-move 6s linear infinite;
}
.vault-glow { position: absolute; width: 70%; aspect-ratio: 1; left: 15%; top: 0; background: radial-gradient(circle, rgb(80 120 255 / 0.5), transparent 65%); filter: blur(24px); animation: glow-shift 14s ease-in-out infinite; }
.core { position: absolute; left: 50%; top: 34%; width: 130px; height: 130px; margin: -65px 0 0 -65px; display: grid; place-items: center; }
.core .ring { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgb(125 160 255 / 0.65); animation: pulse-ring 3.6s var(--ease) infinite; }
.core .ring:nth-child(2) { animation-delay: 1.2s; }
.core .ring:nth-child(3) { animation-delay: 2.4s; }
.core-shield { width: 100px; height: 100px; filter: drop-shadow(0 10px 30px rgb(60 110 255 / 0.6)); animation: float 6s ease-in-out infinite; }
.shield-fill { fill: rgb(45 95 245 / 0.35); }
.shield-line { fill: none; stroke: #9db8ff; stroke-width: 2; stroke-linejoin: round; stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw 2.2s var(--ease) 0.3s forwards; }
.lock-body { fill: #e8eeff; }
.lock-shackle { fill: none; stroke: #e8eeff; stroke-width: 3; stroke-linecap: round; animation: shackle 4.5s ease-in-out infinite; }
.lock-hole { fill: #0f1a44; }
.orbit { position: absolute; left: 50%; top: 34%; border-radius: 50%; border: 1px dashed rgb(150 180 255 / 0.22); animation: spin 26s linear infinite; }
.orbit-a { width: 300px; height: 300px; margin: -150px 0 0 -150px; }
.orbit-b { width: 460px; height: 460px; margin: -230px 0 0 -230px; animation: spin-rev 42s linear infinite; }
.orbit i { position: absolute; width: 8px; height: 8px; border-radius: 50%; top: -4px; left: calc(50% - 4px); background: #7dd3fc; box-shadow: 0 0 12px #7dd3fc; }
.orbit i:nth-child(2) { top: auto; bottom: -4px; background: #a5b4fc; box-shadow: 0 0 12px #a5b4fc; }
.orbit i:nth-child(3) { top: calc(50% - 4px); left: -4px; background: #86efac; box-shadow: 0 0 12px #86efac; }
.tile {
  position: absolute; width: 150px; border-radius: 12px; overflow: hidden;
  background: rgb(255 255 255 / 0.07); border: 1px solid rgb(255 255 255 / 0.14);
  backdrop-filter: blur(8px); box-shadow: 0 20px 40px rgb(0 0 0 / 0.35);
  animation: float 7s ease-in-out infinite;
}
.tile-a { left: 7%; top: 10%; --r: -6deg; }
.tile-b { right: 7%; top: 16%; --r: 5deg; animation-duration: 8s; animation-delay: -2s; }
.tile-c { left: 13%; top: 50%; width: 132px; --r: 4deg; animation-delay: -4s; }
.tile-d { right: 15%; top: 54%; width: auto; padding: 8px 14px; --r: -3deg; animation-delay: -1s; }
.tile-art { position: relative; height: 84px; overflow: hidden; }
.tile-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.art-sunset { background: linear-gradient(180deg, #f59e0b, #ec4899 60%, #7c3aed); }
.art-sunset circle { fill: #fde68a; }
.art-sunset path { fill: rgb(15 23 42 / 0.75); }
.art-ocean { background: linear-gradient(180deg, #38bdf8, #1e40af); }
.art-ocean path { fill: rgb(255 255 255 / 0.28); }
.art-ocean path + path { fill: rgb(255 255 255 / 0.45); }
.art-doc { background: #f8fafc; padding: 12px 14px; display: flex; flex-direction: column; gap: 7px; }
.art-doc span { height: 5px; border-radius: 3px; background: #cbd5e1; }
.art-doc span:nth-child(2) { width: 82%; }
.art-doc span:nth-child(3) { width: 92%; }
.art-doc span:nth-child(4) { width: 55%; }
.art-doc b { position: absolute; right: 10px; bottom: 8px; font-size: 0.68rem; color: #fff; background: #dc2626; padding: 1px 6px; border-radius: 4px; }
.scanline { position: absolute; left: 0; right: 0; height: 18px; top: -20%; background: linear-gradient(180deg, transparent, rgb(125 211 252 / 0.8), transparent); box-shadow: 0 0 18px rgb(125 211 252 / 0.8); animation: scan 3.2s ease-in-out infinite; }
.tile-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 8px 10px; font-size: 0.72rem; }
.ext { font: 700 0.7rem ui-monospace, Consolas, monospace; letter-spacing: 0.05em; color: #c7d2fe; }
.chip { padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; animation: chip-in 6.4s ease-in-out infinite; }
.chip-ok { background: rgb(34 197 94 / 0.2); color: #86efac; }
.chip-lock { background: rgb(168 85 247 / 0.22); color: #d8b4fe; animation-delay: 1.6s; }
.chip-cdn { background: rgb(14 165 233 / 0.22); color: #7dd3fc; animation-delay: 3.2s; }
.spark { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px #fff; animation: twinkle 3s ease-in-out infinite; }
.s1 { left: 30%; top: 22%; }
.s2 { left: 72%; top: 44%; animation-delay: 1s; }
.s3 { left: 56%; top: 9%; animation-delay: 2s; }
.vault-copy { position: relative; max-width: 480px; animation: rise 0.8s var(--ease) 0.2s both; }
.vault-copy .eyebrow { color: #93c5fd; }
.vault-copy h2 { font-size: 1.9rem; margin: 0 0 16px; color: #fff; }
.trust { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.trust li { display: flex; gap: 10px; align-items: center; color: #cbd5f5; animation: rise 0.6s var(--ease) both; }
.trust li:nth-child(1) { animation-delay: 0.45s; }
.trust li:nth-child(2) { animation-delay: 0.6s; }
.trust li:nth-child(3) { animation-delay: 0.75s; }
.trust .icon { color: #7dd3fc; }

.auth-main { display: flex; flex-direction: column; min-height: 100vh; padding: 24px clamp(20px, 5vw, 64px); background: var(--bg); }
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.muted-link { color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.auth-body { flex: 1; display: grid; place-items: center; padding: 28px 0; }
.auth-body > section { width: 100%; max-width: 420px; margin: 0; animation: rise 0.6s var(--ease) 0.1s both; }
.auth-body .card { border-radius: 16px; padding: 32px; box-shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 28px 56px -28px rgb(16 24 40 / 0.35); }
.auth-body .field { animation: rise 0.5s var(--ease) both; }
.auth-body .field:nth-of-type(1) { animation-delay: 0.2s; }
.auth-body .field:nth-of-type(2) { animation-delay: 0.28s; }
.auth-body .field:nth-of-type(3) { animation-delay: 0.36s; }
.auth-body .field:nth-of-type(4) { animation-delay: 0.44s; }
.auth-body .field:nth-of-type(5) { animation-delay: 0.52s; }
.auth-body form + p { margin: 18px 0 0; }
.auth-foot { color: var(--muted); font-size: 0.85rem; display: flex; gap: 6px; align-items: center; justify-content: center; }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-visual { min-height: 230px; padding: 20px 24px; }
  .vault-copy h2 { font-size: 1.25rem; margin: 0; }
  .vault-copy .eyebrow, .trust, .tile-c, .tile-d, .orbit-b, .s3 { display: none; }
  .core, .orbit { top: 42%; }
  .core { transform: scale(0.75); }
  .tile { width: 118px; }
  .tile-art { height: 62px; }
  .auth-main { min-height: 0; }
}

/* ---- Dashboard motion ---- */
.app .topbar, .public .topbar { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(160%) blur(10px); }
.nav-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform: scaleX(0); transform-origin: left; opacity: 0; transition: opacity 0.2s; }
body.is-navigating .nav-progress { opacity: 1; animation: progress 1.6s var(--ease) forwards; }

.content > * { animation: rise 0.5s var(--ease) both; }
.content > *:nth-child(2) { animation-delay: 0.05s; }
.content > *:nth-child(3) { animation-delay: 0.1s; }
.content > *:nth-child(4) { animation-delay: 0.15s; }
.content > *:nth-child(5) { animation-delay: 0.2s; }
.content > *:nth-child(6) { animation-delay: 0.25s; }
.content > *:nth-child(n+7) { animation-delay: 0.3s; }

.sidebar a { justify-content: flex-start; gap: 10px; position: relative; transition: background-color 0.2s, color 0.2s, transform 0.2s var(--ease); }
.sidebar a:hover { transform: translateX(3px); }
.sidebar a .count { margin-left: auto; animation: pop 0.45s var(--ease) 0.3s both; }
.sidebar .icon { opacity: 0.75; transition: opacity 0.2s, transform 0.25s var(--ease); }
.sidebar a:hover .icon, .sidebar a.active .icon { opacity: 1; }
.sidebar a:hover .icon { transform: scale(1.1); }
.sidebar a.active::before { content: ""; position: absolute; left: -6px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: linear-gradient(var(--accent), var(--accent-2)); animation: grow-y 0.35s var(--ease); }

.stat { position: relative; overflow: hidden; padding-right: 64px; transition: transform 0.25s var(--ease), box-shadow 0.25s, border-color 0.25s; animation: rise 0.5s var(--ease) both; }
.stats .stat:nth-child(2) { animation-delay: 0.06s; }
.stats .stat:nth-child(3) { animation-delay: 0.12s; }
.stats .stat:nth-child(4) { animation-delay: 0.18s; }
.stat::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / 0.09) 50%, transparent 70%); transform: translateX(-100%); transition: transform 0.9s var(--ease); }
.stat:hover { transform: translateY(-3px); box-shadow: 0 16px 32px -20px rgb(16 24 40 / 0.5); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.stat:hover::before { transform: translateX(100%); }
.stat-icon { position: absolute; right: 14px; top: 14px; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); transition: transform 0.3s var(--ease); }
.stat:hover .stat-icon { transform: rotate(-8deg) scale(1.08); }
.stat .icon { width: 20px; height: 20px; }
.tone-ok .stat-icon { background: var(--ok-soft); color: var(--ok); }
.stat-attn { animation: rise 0.5s var(--ease) both, attn 2.6s ease-in-out 1s infinite; }
.stat-attn .stat-icon { background: var(--warn-soft); color: var(--warn); animation: bell 2.6s ease-in-out 1s infinite; }

.card { transition: border-color 0.25s, box-shadow 0.25s; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 18%, var(--border)); }
.alert { animation: slide-in 0.45s var(--ease) both; }
.badge-warn::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; vertical-align: 1px; border-radius: 50%; background: currentColor; animation: blink-dot 1.6s ease-in-out infinite; }

.table tbody tr { animation: fade 0.4s var(--ease) both; transition: background-color 0.15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:nth-child(2) { animation-delay: 0.03s; }
.table tbody tr:nth-child(3) { animation-delay: 0.06s; }
.table tbody tr:nth-child(4) { animation-delay: 0.09s; }
.table tbody tr:nth-child(5) { animation-delay: 0.12s; }
.table tbody tr:nth-child(n+6) { animation-delay: 0.15s; }

.usage-fill { position: relative; overflow: hidden; transform-origin: left; animation: grow 1.1s var(--ease) 0.25s both; }
.usage-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.4), transparent); background-size: 200% 100%; animation: shimmer 2.4s linear 1.4s infinite; }
.onboarding li.done .dot { animation: pop 0.45s var(--ease) both; }
.file-card { transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.file-card:hover { transform: translateY(-3px); box-shadow: 0 18px 32px -20px rgb(16 24 40 / 0.55); }
.file-thumb { overflow: hidden; }
.file-thumb img { transition: transform 0.5s var(--ease); }
.file-card:hover .file-thumb img { transform: scale(1.06); }
.tab-panel:not([hidden]) { animation: fade 0.3s var(--ease) both; }

/* ---- Reduced motion: keep every end state, drop the movement ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .chip { animation: none !important; opacity: 1; }
  .scanline, .spark { display: none; }
  @view-transition { navigation: none; }
}
