@import 'tailwindcss';
@import '@viamrobotics/tailwind-config';

/*
  These tokens are missing from (danger/success/info) or differ
  in @viamrobotics/tailwind-config v1.1.0. Remove once reconciled 
  upstream.
*/
@theme {
  --color-danger-bright: #fb2c36;
  --color-warning-bright: #efa300;
  --color-success-bright: #00c907;
  --color-info-bright: #2b95ff;
}

/*
  Pin to prime's historical values.
  
  @viamrobotics/tailwind-config v1.1.0 snaps these to the nearest gray token 
  (bg-medium→gray-2, bg-dark→gray-7,  border-dark→gray-8), an imperceptible 
  but non-zero shift. Remove once we decide whether to adopt the shared config's 
  values upstream.
*/
@utility bg-medium {
  background-color: #f1f1f4;
}

@utility bg-dark {
  background-color: #7a7a7a;
}

@utility border-dark {
  border-color: #4e4e4e;
}

/* Bridge utilities missing from @viamrobotics/tailwind-config v1.1.0. */
@utility z-max {
  z-index: 1000;
}

@utility slider-track-w-full {
  &::-webkit-slider-runnable-track {
    width: 100%;
  }
  &::-moz-range-track {
    width: 100%;
  }
}

/* Dotted utility names are rejected by @utility, so these two are plain rules. */
.slider-track-h-0\.5 {
  &::-webkit-slider-runnable-track {
    height: 0.125rem;
  }
  &::-moz-range-track {
    height: 0.125rem;
  }
}

.scrollbar-w-1\.5 {
  &::-webkit-scrollbar {
    width: 0.375rem;
  }
}

@utility slider-thumb-light {
  &::-webkit-slider-thumb {
    background: var(--color-gray-1);
  }
  &::-moz-range-thumb {
    background: var(--color-gray-1);
  }
}

@utility slider-thumb-w-5 {
  &::-webkit-slider-thumb {
    width: 1.25rem;
  }
  &::-moz-range-thumb {
    width: 1.25rem;
  }
}

@utility slider-thumb-h-5 {
  &::-webkit-slider-thumb {
    height: 1.25rem;
    margin-top: -0.625rem;
  }
  &::-moz-range-thumb {
    height: 1.25rem;
  }
}

@utility scrollbar-thumb-border-0 {
  &::-webkit-scrollbar-thumb {
    border-width: 0;
  }
}

/*
  The default border color has changed to `currentcolor` in Tailwind CSS v4,
  so we've added these compatibility styles to make sure everything still
  looks the same as it did with Tailwind CSS v3.

  If we ever want to remove these styles, we need to add an explicit border
  color utility to any element that depends on these defaults.
*/
@layer base {
  *,
  ::after,
  ::before,
  ::backdrop,
  ::file-selector-button {
    border-color: var(--color-gray-200, currentcolor);
  }
}

input,
button {
  font-family: inherit;
}

button {
  cursor: pointer;
}

:host {
  display: block;
}

:host([hidden]) {
  display: none;
}

/* 
  Enter animation for floating elements.
  
  Applied via the popupEnter action in src/lib/floating/popup-enter.ts. 
*/
@keyframes popup-enter {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.popup-enter {
  animation: popup-enter 120ms cubic-bezier(0.165, 0.84, 0.44, 1) both;
}

/*
 Applied while waiting for floating-ui to resolve the popup's position,
 before the enter animation starts. 
 */
.popup-enter-pending {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .popup-enter {
    animation: none;
  }

  .popup-enter-pending {
    opacity: 1;
  }
}
