* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f3f5f9;
  color: #243046;
  font-family: system-ui, sans-serif;
}

main {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.tooltip-wrapper {
  position: relative;
  display: inline-flex;
}

.tooltip-trigger {
  padding: 11px 18px;
  border: 1px solid #cbd4e2;
  border-radius: 7px;
  background: #fff;
  color: #333462;
  font: inherit;
  cursor: pointer;
}

.tooltip-trigger:hover {
  border-color: #407bff;
}

.tooltip-trigger:focus-visible {
  outline: 3px solid #9bbaff;
  outline-offset: 4px;
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  z-index: 1000;
  width: max-content;
  max-width: min(260px, calc(100vw - 32px));
  visibility: hidden;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 150ms ease, visibility 150ms ease;
}

.tooltip-content {
  position: relative;
  display: block;
  padding: 9px 15px;
  border-radius: 4px;
  background: #196bde;
  color: #fff;
  font: 12px/1.4 Arial, sans-serif;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 10px rgb(0 0 0 / 12%);
}

.tooltip-content::before {
  content: "";
  position: absolute;
  inset: -10px;
  z-index: -1;
}

.tooltip-content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-bottom-width: 0;
  border-top-color: #2d2d2d;
  transform: translateX(-50%);
}

.tooltip-count {
  color: #f0ad63;
}

.tooltip-wrapper:hover .tooltip,
.tooltip-wrapper:focus-within .tooltip {
  visibility: visible;
  opacity: 1;
}

@supports (anchor-name: --enterprise) and (position-area: top) and (position-try-fallbacks: --below) and (container-type: anchored) {
  .tooltip-trigger {
    anchor-name: --enterprise;
  }

  .tooltip {
    position: fixed;
    position-anchor: --enterprise;
    position-area: top;
    position-try-fallbacks: --below, --right, --left;
    container-type: anchored;
    inset: auto;
    margin: 10px;
    transform: none;
  }
}

@position-try --below {
  position-area: bottom;
}

@position-try --right {
  position-area: right;
}

@position-try --left {
  position-area: left;
}

@container anchored(fallback: --below) {
  .tooltip-content::after {
    inset: auto;
    bottom: 100%;
    left: 50%;
    border: 7px solid transparent;
    border-top-width: 0;
    border-bottom-color: #2d2d2d;
    transform: translateX(-50%);
  }
}

@container anchored(fallback: --right) {
  .tooltip-content::after {
    inset: auto;
    top: 50%;
    right: 100%;
    border: 7px solid transparent;
    border-left-width: 0;
    border-right-color: #2d2d2d;
    transform: translateY(-50%);
  }
}

@container anchored(fallback: --left) {
  .tooltip-content::after {
    inset: auto;
    top: 50%;
    left: 100%;
    border: 7px solid transparent;
    border-right-width: 0;
    border-left-color: #2d2d2d;
    transform: translateY(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tooltip {
    transition: none;
  }
}
