/*
  Tooltip 04 — Adaptive Tooltip — standalone HTML/CSS/JS implementation.
  No build step, no framework, no external dependency: copy index.html,
  this file, and script.js into any project as-is.
*/

:root {
  --tooltip-accent: #39ff14;
  --tooltip-fg: oklch(0.145 0 0);
  --tooltip-muted: oklch(0.5 0 0);
  --tooltip-border: oklch(0.85 0 0);
  --tooltip-border-hover: oklch(0.72 0 0);
}

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

body {
  margin: 0;
  display: flex;
  min-height: 17rem;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  background: linear-gradient(to bottom, #fafafa, #f4f4f5);
}

.tooltip04-board {
  position: relative;
  height: 16rem;
  width: 100%;
  max-width: 36rem;
  border: 1px solid oklch(0.9 0 0);
  border-radius: 1rem;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 16px 40px -16px rgba(0, 0, 0, 0.14);
}

.tooltip04-board__slot {
  position: absolute;
}

.tooltip04-board__slot--tl {
  top: 0.75rem;
  left: 0.75rem;
}

.tooltip04-board__slot--tr {
  top: 0.75rem;
  right: 0.75rem;
}

.tooltip04-board__slot--bl {
  bottom: 0.75rem;
  left: 0.75rem;
}

.tooltip04-board__slot--br {
  bottom: 0.75rem;
  right: 0.75rem;
}

.tooltip04-board__slot--center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.tooltip04 {
  position: relative;
  display: inline-flex;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji";
}

.tooltip04__trigger {
  display: flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid var(--tooltip-border);
  background-color: #ffffff;
  font-family: inherit;
  color: var(--tooltip-muted);
  cursor: pointer;
  outline: none;
  transition: border-color 150ms ease-out, color 150ms ease-out;
}

.tooltip04__trigger svg {
  height: 0.875rem;
  width: 0.875rem;
}

.tooltip04__trigger:hover {
  border-color: var(--tooltip-border-hover);
  color: var(--tooltip-fg);
}

.tooltip04__trigger:focus-visible {
  outline: 2px solid var(--tooltip-fg);
  outline-offset: 2px;
}

.tooltip04__bubble {
  position: absolute;
  z-index: 10;
  display: block;
  width: max-content;
  max-width: 10rem;
  animation-duration: 150ms;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
}

.tooltip04__bubble[hidden] {
  display: none;
}

.tooltip04__bubble[data-side="top"] {
  bottom: 100%;
  left: 50%;
  margin-bottom: 0.625rem;
  transform: translate(-50%, 0);
  animation-name: tooltip04-in-top;
}

.tooltip04__bubble[data-side="bottom"] {
  top: 100%;
  left: 50%;
  margin-top: 0.625rem;
  transform: translate(-50%, 0);
  animation-name: tooltip04-in-bottom;
}

.tooltip04__bubble[data-side="left"] {
  top: 50%;
  right: 100%;
  margin-right: 0.625rem;
  transform: translate(0, -50%);
  animation-name: tooltip04-in-left;
}

.tooltip04__bubble[data-side="right"] {
  top: 50%;
  left: 100%;
  margin-left: 0.625rem;
  transform: translate(0, -50%);
  animation-name: tooltip04-in-right;
}

@keyframes tooltip04-in-top {
  from {
    opacity: 0;
    transform: translate(-50%, 4px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes tooltip04-in-bottom {
  from {
    opacity: 0;
    transform: translate(-50%, -4px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes tooltip04-in-left {
  from {
    opacity: 0;
    transform: translate(4px, -50%);
  }
  to {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

@keyframes tooltip04-in-right {
  from {
    opacity: 0;
    transform: translate(-4px, -50%);
  }
  to {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

.tooltip04__content {
  display: block;
  border-radius: 0.5rem;
  background-color: var(--tooltip-fg);
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  line-height: 1.35;
  font-weight: 500;
  color: #ffffff;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.35);
}

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