/* Copyright 2026 The Chromium Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file. */

/* #css_wrapper_metadata_start
 * #type=style-lit
 * #scheme=relative
 * #css_wrapper_metadata_end */

:host {
  display: flex;
  align-items: center;
  width: auto;
  --toolbar-chip-font-family:
      var(--omnibox-primary-body-3-emphasis-font-family);
  --toolbar-chip-font-size: var(--omnibox-primary-body-3-emphasis-font-size);
  --toolbar-chip-font-weight:
      var(--omnibox-primary-body-3-emphasis-font-weight);
  line-height: var(--omnibox-primary-body-3-emphasis-line-height);

  /* Omnibox specific colors to override generic toolbar defaults */
  --toolbar-chip-bg-color: transparent;
  /* TODO(crbug.com/489109708): Fix color mismatch with C++ views. */
  --toolbar-chip-fg-color: var(--color-omnibox-results-icon, currentColor);
  --toolbar-chip-ink-drop-hover-color:
      var(--color-omnibox-icon-hover, transparent);
  --toolbar-chip-ink-drop-ripple-color:
      var(--color-omnibox-icon-pressed, transparent);
  --explanatory-text-width: 200px;
}

/* In native Views, ContentSettingImageView and PageActionIconView both inherit
 * from IconLabelBubbleView and share the exact same geometric bounds. */
#chip {
  --toolbar-chip-height: calc(
      var(--location-bar-trailing-icon-size) +
      var(--location-bar-page-action-icon-padding-top) +
      var(--location-bar-page-action-icon-padding-bottom));
  --toolbar-chip-icon-size: var(--location-bar-trailing-icon-size);
  --toolbar-chip-padding-start: calc(
      var(--location-bar-page-action-icon-padding-start) +
      var(--location-bar-icon-interior-padding-start));
  --toolbar-chip-padding-end: calc(
      var(--location-bar-page-action-icon-padding-end) +
      var(--location-bar-icon-interior-padding-end));
}

#icon {
  height: var(--icon-size);
  width: var(--icon-size);
  background-color: currentColor;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

#label {
  max-width: 0;
  margin-inline-start: 0;
  overflow: hidden;
  white-space: nowrap;
}

:host([should-run-animation]):has(#label:not(:empty)) #label {
  /* TODO(crbug.com/501447940): The highlight isn't centered on the icon during
     animation due to this rule. It also causes a jarring shift at the end of
     the animation. */
  margin-inline-start: var(--location-bar-child-internal-spacing);
  /* TODO(crbug.com/534766201): Opening the bubble is supposed to pause
     animation. */
  animation: slide-in-out 3s;
}

@keyframes slide-in-out {
  0% {
    max-width: 0;
    animation-timing-function: ease-out;
  }
  20% {
    max-width: var(--explanatory-text-width);
  }
  80% {
    max-width: var(--explanatory-text-width);
    animation-timing-function: ease-out;
  }
  100% {
    max-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  :host([should-run-animation]):has(#label:not(:empty)) #label {
    animation: pop-in-out 3s steps(1, end) !important;
  }

  @keyframes pop-in-out {
    from {
      max-width: var(--explanatory-text-width);
    }
    to {
      max-width: 0;
    }
  }
}
