/* ==========================================================================
   Base Reset, Typography, Numeric Alignment & Accessibility Primitives
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-canvas);
  background-image: var(--bg-canvas-gradient);
  background-attachment: fixed;
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

/* Ambient breathing aurora & top precision telemetry grid */
body::before {
  content: "";
  position: fixed;
  inset: -12% -8% auto -8%;
  height: 540px;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(520px 260px at 22% 18%, rgba(37, 99, 235, 0.12), transparent 72%),
    radial-gradient(480px 240px at 78% 12%, rgba(16, 185, 129, 0.10), transparent 72%),
    radial-gradient(420px 220px at 52% 32%, rgba(99, 102, 241, 0.08), transparent 74%);
  animation: ambient-aurora 16s ease-in-out infinite alternate;
  will-change: transform, opacity;
}

body::after {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 400px;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--telemetry-grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--telemetry-grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.22) 210px, transparent 390px);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.22) 210px, transparent 390px);
}

body.scroll-locked {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}

code,
kbd,
pre,
.mono {
  font-family: var(--font-mono);
}

.num,
.mono,
time {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--ring-color);
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 12px;
  z-index: 200;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--ink-inverse);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top 120ms ease;
}

.skip-link:focus {
  top: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Custom subtle scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-muted);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* Skeleton shimmer */
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skel {
  display: inline-block;
  border-radius: var(--r-xs);
  background: linear-gradient(
    90deg,
    var(--bg-subtle) 25%,
    var(--bg-hover) 50%,
    var(--bg-subtle) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.86); }
}

@keyframes radar-ping {
  0% { transform: scale(0.95); opacity: 0.85; }
  75%, 100% { transform: scale(2.35); opacity: 0; }
}

@keyframes text-shimmer {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}

@keyframes gentle-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

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

@keyframes ambient-aurora {
  0% { transform: translate3d(-1.8%, -1%, 0) scale(1); opacity: 0.82; }
  50% { transform: translate3d(1.6%, 2.2%, 0) scale(1.05); opacity: 1; }
  100% { transform: translate3d(-0.8%, 1.2%, 0) scale(0.98); opacity: 0.88; }
}

@keyframes marquee-scroll {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}

@keyframes view-fade-up {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes row-cascade-in {
  from { opacity: 0; transform: translate3d(0, 6px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes card-cascade-in {
  from { opacity: 0; transform: translate3d(0, 10px, 0) scale(0.988); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes drawer-slide-in {
  from { transform: translate3d(100%, 0, 0); }
  to { transform: translate3d(0, 0, 0); }
}

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

@keyframes modal-pop-in {
  from { opacity: 0; transform: translate3d(0, 12px, 0) scale(0.968); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes dock-float-in {
  from { opacity: 0; transform: translate(-50%, 18px) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translate3d(0, 12px, 0) scale(0.95); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes panel-unfurl {
  from { opacity: 0; transform: translate3d(0, -6px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes bar-grow-x {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes cta-sheen {
  0% { transform: translateX(-140%) skewX(-20deg); }
  35%, 100% { transform: translateX(240%) skewX(-20deg); }
}

@keyframes spin-sync {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes scanline-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(260%); }
}

@keyframes num-tick-flash {
  0% { transform: translateY(-2px) scale(1.06); filter: brightness(1.22); }
  100% { transform: translateY(0) scale(1); filter: brightness(1); }
}

@keyframes icon-spring-pop {
  0% { transform: scale(0.84); }
  55% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

@keyframes radar-dial-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.is-num-tick {
  display: inline-block;
  animation: num-tick-flash 360ms var(--ease-spring);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body::before,
  .skel,
  .status-dot.is-live,
  .radar-ping-dot::after,
  .live-shimmer,
  .price-promo-pulse,
  .live-ticker-track,
  .header-sync-fill.is-syncing,
  .sync-icon.is-spinning,
  .radar-dial-sweep,
  .tag-badge.is-restock::after,
  .btn-buy-cta::after,
  .is-num-tick { animation: none !important; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
