/*
 * TianTian touch feedback.
 * A soft tone ripple grows from the pointer, while solid controls get
 * a restrained Windows Tile-like edge and press depth.
 */

:where(
  button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"],
  input[type="image"],
  [role="button"],
  a.btn,
  a.button,
  a[class^="btn-"],
  a[class*="-btn"],
  a[class*="-button"]
) {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.tt-touch-host {
  --tt-touch-tile-edge: rgba(32, 33, 36, 0.14);
  --tt-touch-tile-edge-strong: rgba(32, 33, 36, 0.26);
  isolation: isolate;
  transform-origin: center;
  transition:
    translate 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 100ms ease,
    filter 100ms ease;
}

.tt-touch-host.tt-touch-positioned {
  position: relative;
}

.tt-touch-host.tt-touch-clipped {
  overflow: hidden;
}

.tt-touch-host:not(:disabled):not([aria-disabled="true"]):not(.disabled):active,
.tt-touch-host:not(:disabled):not([aria-disabled="true"]):not(.disabled).tt-touch-pressed {
  opacity: 0.98;
  filter: brightness(0.91) saturate(0.96);
  translate: 0 1px;
  transition-duration: 80ms;
}

@media (hover: hover) and (pointer: fine) {
  .tt-touch-tile:not(:disabled):not([aria-disabled="true"]):not(.disabled):hover {
    outline: 1px solid var(--tt-touch-tile-edge);
    outline-offset: -1px;
  }
}

.tt-touch-tile:not(:disabled):not([aria-disabled="true"]):not(.disabled):active,
.tt-touch-tile:not(:disabled):not([aria-disabled="true"]):not(.disabled).tt-touch-pressed {
  outline: 1px solid var(--tt-touch-tile-edge-strong);
  outline-offset: -1px;
}

.tt-touch-ripple {
  position: absolute;
  z-index: 1;
  display: block;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.08);
  transform-origin: center;
  animation: tt-touch-ripple 480ms cubic-bezier(0.16, 0.78, 0.22, 1) forwards;
  will-change: transform, opacity;
}

@keyframes tt-touch-ripple {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.08);
  }
  10% {
    opacity: 1;
  }
  48% {
    opacity: 0.66;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tt-touch-host {
    transition: opacity 80ms ease;
  }

  .tt-touch-host:not(:disabled):not([aria-disabled="true"]):not(.disabled):active,
  .tt-touch-host:not(:disabled):not([aria-disabled="true"]):not(.disabled).tt-touch-pressed {
    opacity: 0.9;
    filter: brightness(0.88);
    translate: none;
  }

  .tt-touch-tile:not(:disabled):not([aria-disabled="true"]):not(.disabled):active,
  .tt-touch-tile:not(:disabled):not([aria-disabled="true"]):not(.disabled).tt-touch-pressed {
    outline-offset: -1px;
  }

  .tt-touch-ripple {
    display: none;
  }
}
