[data-detail-collapsible] {
  position: relative;
}

[data-detail-collapsible-body] {
  overflow: hidden;
  transition: max-height 0.28s ease, opacity 0.28s ease;
}

[data-detail-collapsible][data-detail-expanded="true"] [data-detail-collapsible-body] {
  max-height: 1000px;
  overflow: visible;
  opacity: 1;
}

[data-detail-collapsible][data-detail-expanded="false"][data-detail-device="desktop"] [data-detail-collapsible-body] {
  max-height: 0;
  opacity: 0;
}

[data-detail-collapsible][data-detail-expanded="false"][data-detail-device="mobile"] [data-detail-collapsible-body] {
  max-height: var(--detail-preview-height, 14rem);
  opacity: 1;
  position: relative;
}

[data-detail-collapsible][data-detail-expanded="false"][data-detail-device="mobile"] [data-detail-collapsible-body]::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3.5rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.96));
  pointer-events: none;
}

[data-detail-collapsible-toggle] {
  min-width: 5.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid #fdba74;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

[data-detail-collapsible-toggle]:hover {
  background: #ffedd5;
}

.detail-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.detail-tooltip__trigger {
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 9999px;
  border: 1px solid #fdba74;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.detail-tooltip__trigger:hover,
.detail-tooltip__trigger:focus-visible {
  background: #ffedd5;
  outline: none;
}

.detail-tooltip__bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translateX(-50%) translateY(0.2rem);
  min-width: 15.5rem;
  max-width: min(22rem, calc(100vw - 2.5rem));
  padding: 0.6rem 0.75rem;
  border-radius: 0.65rem;
  border: 1px solid #fbd38d;
  background: #fffaf0;
  color: #7c2d12;
  font-size: 0.75rem;
  line-height: 1.45;
  box-shadow: 0 8px 22px rgba(124, 45, 18, 0.14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
  z-index: 15;
  text-align: left;
}

.detail-tooltip__bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border-width: 0.4rem;
  border-style: solid;
  border-color: #fffaf0 transparent transparent transparent;
  filter: drop-shadow(0 1px 0 #fbd38d);
}

.detail-tooltip:hover .detail-tooltip__bubble,
.detail-tooltip:focus-within .detail-tooltip__bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* On touch / non-hover devices, prevent Tailwind's hover:bg-gray-50
   from leaving a persistent gray background when elements are tapped. */
@media (hover: none), (pointer: coarse) {
  /* On touch devices, make the hover/active state match the active color
     so tapping doesn't briefly show the gray color. Do NOT override :focus
     here to avoid forcing the active color to remain after deselect. */
  .hover\:bg-gray-50:hover,
  .hover\:bg-gray-50:active {
    background-color: #fff7ed !important;
    background-image: none !important;
  }
  /* Remove focus outline / tap highlight on touch devices to avoid
     visual artifacts where focus remains until tapping elsewhere. */
  button:focus {
    outline: none !important;
  }
  button {
    -webkit-tap-highlight-color: transparent;
  }
}

/* Ensure hover/active on this page use the same background as active state
   so desktop hover and mobile tap look consistent. Do not force :focus here. */
.hover\:bg-gray-50:hover,
.hover\:bg-gray-50:active {
  background-color: #fff7ed !important;
  background-image: none !important;
}
