/* ═══════════════════════════════════════════════════════════════════════════
   DASHCAM — Custom styles (keyframes, scrollbar, grain, Tailwind overrides)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Grain Texture Overlay ─────────────────────────────────────────────── */
.grain-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.02;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ── Keyframe Animations ───────────────────────────────────────────────── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slide-up-mobile {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes gradient-rotate {
  0%   { --angle: 0deg; }
  100% { --angle: 360deg; }
}

@keyframes toast-countdown {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Status dot pulse ──────────────────────────────────────────────────── */
.status-dot {
  animation: pulse-dot 2.5s ease-in-out infinite;
}

/* ── Card entrance animation ───────────────────────────────────────────── */
.card-animate {
  animation: card-in 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Panel transition ──────────────────────────────────────────────────── */
.panel-animate {
  animation: panel-in 250ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Crossfade image container ─────────────────────────────────────────── */
.crossfade-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.crossfade-container img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease;
}

/* ── Animated gradient border for focus viewport ───────────────────────── */
.gradient-border {
  background: conic-gradient(
    from var(--angle, 0deg),
    #818cf8, #6366f1, #4f46e5, #818cf8
  );
  padding: 2px;
  border-radius: 12px;
  animation: gradient-rotate 4s linear infinite;
}

@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

/* ── Live badge glow ───────────────────────────────────────────────────── */
.live-glow {
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.3), 0 0 16px rgba(52, 211, 153, 0.1);
}

/* ── Toast countdown bar ───────────────────────────────────────────────── */
.toast-countdown {
  animation: toast-countdown 5s linear forwards;
  transform-origin: left;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

/* ── Sidebar collapse transition ───────────────────────────────────────── */
.sidebar-transition {
  transition: width 300ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* ── Command palette ───────────────────────────────────────────────────── */
.palette-backdrop {
  animation: fade-in 150ms ease both;
}

.palette-modal {
  animation: slide-up 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (max-width: 639px) {
  .palette-modal {
    animation: slide-up-mobile 250ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }
}

/* ── Touch-friendly: disable hover scale on touch devices ──────────────── */
@media (hover: none) {
  .card-no-hover-scale {
    transform: none !important;
  }
}

/* ── Mobile: card action bar always visible on touch ───────────────────── */
@media (hover: none) {
  .touch-actions-visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
  }
}

/* ── Active press feedback for touch ───────────────────────────────────── */
.touch-action-manipulation {
  -webkit-tap-highlight-color: transparent;
}

/* ── Focus sidebar: auto width on mobile ───────────────────────────────── */
@media (max-width: 1023px) {
  .sidebar-transition {
    width: auto !important;
    transition: none;
  }
}

/* ── Reduced Motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0ms !important;
  }
}
