/* Copyright 2025 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
 * #import=//resources/cr_elements/cr_icons_lit.css.js
 * #import=./composebox_shared_style.css.js
 * #scheme=relative
 * #include=cr-icons-lit composebox-shared-style
 * #css_wrapper_metadata_end */

:host {
  /* Voice carousel/chip styles, etc. are defined in
   * 'composebox_shared_style.css'.
   */
  --animated-search-padding-bottom: var(--cr-composebox-padding-bottom, 10px);
  --color-composebox-submit-button-hover: var(--color-searchbox-results-background-hovered);
  --composebox-cancel-button-top: var(--cr-composebox-cancel-button-top, 12px);
  --cr-composebox-outline-hcm: solid var(--color-composebox-outline-hcm);
  --cr-composebox-submit-container-size: 40px;
  --cr-icon-button-size: 36px;
  --cr-composebox-tool-chip-right-close-icon-color: rgba(86, 89, 94, 1);
  --input-bottom-spacing: 10px;
  --text-input-top-spacing: 10px;
  --text-input-inline-end-spacing: 80px;
  --text-input-inline-start-spacing: 16px;
  --text-input-max-height: 190px;
  --expanded-border-radius: var(--cr-composebox-expanded-border-radius, 26px);
  --standard-curve: cubic-bezier(0.4, 0, 0.2, 1);
  --emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
  --emphasized-curve: linear(
    0,
    0.002,
    0.01 3.6%,
    0.02 4.9%,
    0.034,
    0.053,
    0.074,
    0.1,
    0.128,
    0.16,
    0.194 13.4%,
    0.271 15%,
    0.344 16.1%,
    0.477 17.5%,
    0.544 18.3%,
    0.607,
    0.66 20.6%,
    0.717 22.4%,
    0.742,
    0.765,
    0.788,
    0.808,
    0.827,
    0.845 30.4%,
    0.865 32.6%,
    0.866,
    0.865 32.7%,
    0.869 33.1%,
    0.883 35.1%,
    0.9 37.7%,
    0.916 40.6%,
    0.929 43.8%,
    0.942 47.2%,
    0.953 51%,
    0.963 55%,
    0.972 59.3%,
    0.979 64%,
    0.986 69%,
    0.991 74.4%,
    0.998 86.4%,
    1
  );
  --border-radius-transition: border-radius var(--collapse-duration)
    var(--emphasized-curve);
  --fade-duration: 100ms;
  --height-expand-duration: 600ms;
  --icon-entry-transition: opacity var(--expand-ease-out-duration) linear 800ms;
  --icon-exit-transition: opacity var(--collapse-ease-in-duration)
    var(--emphasized-accelerate);
  --lens-icon-animation-duration: 1100ms;

  --submit-enabled-transition: opacity 255ms;

  border-radius: 30px;
  box-shadow: var(--cr-searchbox-shadow);
  font-size: var(--cr-composebox-font-size, 18px);
  transition: var(--border-radius-transition),
      /* Fast out (start), slow in (end) box shadow transition. */
      box-shadow 500ms cubic-bezier(0.4, 0.0, 0.2, 1);
  width: var(--cr-composebox-width, 337px);
}

@media (prefers-color-scheme: dark) {
  :host {
    --cr-composebox-tool-chip-right-close-icon-color: rgba(173, 175, 184, 1);
  }
}

:host(:not([searchbox-next-enabled])) {
  --expand-ease-in-duration: 400ms;
  --expand-delay: 300ms;
  --expand-ease-out-duration: 300ms;
  --expand-duration: calc(
    var(--expand-ease-in-duration) + var(--expand-delay) +
      var(--expand-ease-out-duration)
  );
  --collapse-ease-in-duration: 100ms;
  --collapse-ease-out-duration: 500ms;
  --collapse-duration: calc(
    var(--collapse-ease-in-duration) + var(--collapse-ease-out-duration)
  );
}

:host([searchbox-next-enabled]) {
  --cr-composebox-font-size: var(--cr-composebox-custom-font-size, 16px);
  --contextual-entrypoint-and-carousel-context-menu-container-padding-inline-start: 0px;
  /*
   * TODO(crbug.com/470081925): Refactor and keep necessary
   * --input-bottom-spacing values in this file.
   */
  --input-bottom-spacing: 12px;
  --text-input-inline-start-spacing: var(--cr-composebox-text-input-inline-start, 18px);
}

:host([expanding_]) {
  border-radius: var(--expanded-border-radius);
}

:host([energy-effect-enabled]) {
  --box-shadow-energy-effect: 0 4px 18px -2px rgba(60, 64, 67, 0.12);
  box-shadow: none;
  position: relative;
}

:host([energy-effect-animation-enabled]) {
  /* Energy Effect Motion Curves */
  --emphasized-accelerate-curve: cubic-bezier(0.3, 0, 0.8, 0.15);
  --standard-decelerate-curve: cubic-bezier(0, 0, 0, 1);

  /* Energy Effect Box Shadow */
  --box-shadow-energy-effect-no-alpha: 0 4px 18px -2px rgba(60, 64, 67, 0);
  --box-shadow-animation-duration: 650ms;
  position: relative;
}

:host([energy-effect-enabled])::after,
:host([energy-effect-animation-enabled])::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid
    var(--color-composebox-input-plate-outline, rgba(240, 242, 245, 1));
  border-radius: inherit;
  box-sizing: border-box;
  pointer-events: none;
}

#errorScrim {
  border-radius: inherit;
}

/* This, along with its input container child's contents determine the height
 * of cr-composebox.
 */
#composebox {
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  transition:
    opacity var(--fade-duration) ease-in-out,
    visibility var(--fade-duration) ease-in-out;
}

:host([searchbox-next-enabled]) #composebox {
  padding-bottom: var(--cr-composebox-padding-bottom, 10px);
}

search-animated-glow {
  pointer-events: none;
  inset: -2px;
  z-index: 1;
}

:host([is-dragging-file][energy-effect-animation-enabled]) search-animated-glow {
  position: absolute;
  z-index: auto;
}

:host([is-collapsible]) #composebox {
  min-height: 60px;
  max-height: 60px;
  transition:
    max-height var(--collapse-duration) var(--emphasized-curve),
    min-height var(--collapse-duration) var(--emphasized-curve),
    opacity var(--fade-duration) ease-in-out,
    visibility var(--fade-duration) ease-in-out;
}

:host(:not([is-collapsible])) #composebox {
  /* If the composebox is not expandable, meaning expanding_ is always true,
   * then the above transition will never be triggered. Instead, manually
   * start the animation so it expands as soon as it is rendered */
  height: 60px;
}

:host([expanding_]) #composebox {
  height: calc-size(auto, size);
  max-height: var(--cr-composebox-max-height, 422px);
  transition:
    max-height var(--expand-duration) var(--emphasized-curve),
    min-height var(--expand-duration) var(--emphasized-curve),
    opacity var(--fade-duration) ease-in-out,
    visibility var(--fade-duration) ease-in-out;
}

:host([is-collapsible][expanding_]) #composebox {
  min-height: 136px;
  max-height: 254px;
}

:host([energy-effect-animation-enabled][animation-state='expanding']) #composebox {
  will-change: opacity;
  animation: zero-state-composebox-fade-in 50ms
      var(--emphasized-accelerate-curve) both;
}

@keyframes zero-state-composebox-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

:host([is-collapsible][expanding_][show-file-carousel][carousel-on-top_]) #composebox {
  min-height: calc(136px + 52px);
}

:host([energy-effect-enabled]) #composebox {
  box-shadow: var(--box-shadow-energy-effect);
}

:host([energy-effect-animation-enabled][animation-state='expanding']:not([entrypoint-name='Realbox'])) #composebox,
:host([energy-effect-animation-enabled][animation-state='submitting']:not([entrypoint-name='Realbox'])) #composebox {
  animation: animateShadow var(--box-shadow-animation-duration) both;
}

:host([energy-effect-animation-enabled][animation-state='dragging']) #composebox {
  box-shadow: none;
}

@keyframes animateShadow {
  0% {
    box-shadow: var(--box-shadow-energy-effect);
    animation-timing-function: var(--standard-decelerate-curve);
  }
  25% {
    box-shadow: var(--box-shadow-energy-effect-no-alpha);
  }
  50% {
    animation-timing-function: var(--emphasized-accelerate-curve);
    box-shadow: var(--box-shadow-energy-effect-no-alpha);
  }
  100% {
    box-shadow: var(--box-shadow-energy-effect);
  }
}

:host([energy-effect-animation-enabled][animation-state='expanding'])::after {
  animation: animateBorder var(--box-shadow-animation-duration) linear both;
  opacity: 0;
}

:host([energy-effect-animation-enabled][animation-state='submitting'])::after {
  animation: animateBorderSubmitting var(--box-shadow-animation-duration) linear both;
  opacity: 0;
}

:host([energy-effect-animation-enabled][animation-state='dragging'])::after {
  display: none;
}

@keyframes animateBorder {
  0% {
    opacity: 1;
    animation-timing-function: var(--standard-decelerate-curve);
  }
  25% {
    opacity: 0;
  }
  50% {
    opacity: 0;
    animation-timing-function: var(--emphasized-accelerate-curve);
  }
  100% {
    opacity: 1;
  }
}

@keyframes animateBorderSubmitting {
  0% {
    opacity: 1;
    animation-timing-function: var(--standard-decelerate-curve);
  }
  25% {
    opacity: 0;
  }
  50% {
    opacity: 0;
    animation-timing-function: var(--emphasized-accelerate-curve);
  }
  100% {
    opacity: 1;
  }
}

#inputContainer {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--input-bottom-spacing);
  overflow: hidden;
  width: 100%;
}

:host([searchbox-next-enabled]) #inputContainer {
  --input-bottom-spacing: 0;
}

:host-context([dir='rtl']) .action-icon {
  left: 16px;
  right: unset;
}

@keyframes fade-out-in {
  0% {
    opacity: 0;
  }

  73% {
    opacity: 0;
  }
}

#lensIcon {
  --cr-icon-button-icon-size: 20px;
  --cr-icon-image: url(//resources/cr_components/searchbox/icons/camera.svg);
  bottom: var(--input-bottom-spacing);
  display: none;
  opacity: 1;
  position: absolute;
  inset-inline-end: 16px;
  top: 6px;
}

#lensIcon:focus-visible:focus {
  box-shadow: none;
  outline: 2px solid var(--color-searchbox-results-icon-focused-outline);
  outline-offset: 2px;
}

:host([expanding_]) #lensIcon {
  animation: fade-out-in var(--lens-icon-animation-duration) linear;
  inset-inline-end: 68px;
  top: auto;
}

:host([lens-button-disabled]) #lensIcon {
  opacity: 0.3;
}

:host(:not([submit-enabled])) cr-composebox-submit::part(submit) {
  display: none;
}

:host([searchbox-layout-mode='Compact']) {
  /* Used in search-animated-glow-element. */
  --search-animated-glow-drag-drop-placeholder-top: 16px;
  /* Changes both composebox and voice-search's: */
  --composebox-cancel-button-top: 10px;
  /* Changes voicebox text top padding. */
  --composebox-voice-search-top-padding: 9px;
}

@media (forced-colors: active) {
  :host,
  .action-icon {
    border: var(--composebox-outline-hcm);
  }
}

#suggestionActivity {
  color: var(--color-composebox-suggestion-activity);
  display: flex;
  font-size: 12px;
  font-weight: 400;
  justify-content: flex-end;
  line-height: 18px;
  padding-bottom: 10px;
  padding-inline-end: 18px;
  position: relative;
}

:host([expanding_][show-file-carousel][carousel-on-top_]) #inputContainer {
  padding-top: 60px;
  --text-input-max-height: 130px;
}

/* Only nextbox (cobrowsing) has 'top' class. General voice styling
 * should be in composebox shared styles. */
#voiceCarouselContainer:has(#voiceSearchCarousel.top) {
  --context-carousel-inline-start-spacing: 12px;
  /* Spec has -8px bottom margin, but the item under has 6px top-padding
   * so net distance between the two is -2px.
   */
  --context-top-carousel-bottom-margin: -2px;
  /* This + parent's padding = 12px space above. */
  --context-top-carousel-top-margin: 6px;

  /* Render above the recording wave, which is order 1,
   * if carousel should be on top.
   */
  order: 0;
}

#carousel.top {
  margin-bottom: var(--context-top-carousel-bottom-margin, 0);
  margin-top: var(--context-top-carousel-top-margin, 0);
  position: absolute;
  top: var(--context-carousel-top-position, 14px);
  width: auto;
}

/* Contextual tasks specific formatting for voice carousel. */
#voiceSearchCarousel.top {
  margin-bottom: var(--context-top-carousel-bottom-margin, 0);
  margin-top: var(--context-top-carousel-top-margin, 0);
  width: auto;
}

:host([is-omnibox-in-compact-mode_]) .context-menu-container {
  min-height: 0;
}

#contextEntrypoint {
  color: var(--color-searchbox-results-foreground);
  /* Do not set 'padding-inline-end/start' here. It is set in
   * 'composebox_shared_style.css'.
   */
}

#toolChipsContainer,
#voiceToolChipsContainer {
  padding-bottom: 4px;
  padding-inline-start: 16px;
  padding-top: 14px;
}

:host(:not([file-uploads-complete])) .upload-button {
  cursor: not-allowed;
}

:host([upload-button-disabled]) .upload-button {
  color: var(--color-composebox-upload-button-disabled);
}

:host([searchbox-layout-mode='Compact'])
    #contextEntrypoint::part(context-menu-entrypoint-icon) {
  position: absolute;
  top: 10px;
}

:host([searchbox-next-enabled][searchbox-layout-mode^='Tall'][show-dropdown]) {
  --expanded-border-radius: var(--cr-composebox-expanded-border-radius, 24px);
}

:host([searchbox-next-enabled][searchbox-layout-mode='Compact']) {
  --expanded-border-radius: var(--cr-composebox-expanded-border-radius, 30px);
  --input-bottom-spacing: 12px;
}

:host([searchbox-next-enabled][searchbox-layout-mode='Compact'][show-file-carousel]) {
  /* Eliminate redundant bottom spacing above carousel */
  --input-bottom-spacing: 0px;
}

:host([searchbox-next-enabled]) cr-composebox-submit::part(submit-icon) {
  --cr-icon-button-icon-size: 12px;
}

:host([expanding_][show-dropdown][searchbox-next-enabled][searchbox-layout-mode='Compact']) cr-composebox-dropdown {
  padding-bottom: 0;
  padding-top: 4px;
}

:host([searchbox-layout-mode='Compact'][show-dropdown]) .carousel-divider {
  --contextual-entrypoint-and-carousel-carousel-divider-margin-bottom: 8px;
  --contextual-entrypoint-and-carousel-carousel-divider-margin-top: 12px;
}

#voiceSearchButton {
  --cr-icon-button-fill-color: var(--color-composebox-font-light);
  --cr-icon-button-hover-background-color: var(--color-composebox-voice-button-hover-background);
  --cr-icon-button-margin-end: 0px;
  --cr-icon-button-margin-start: 0px;
  --cr-icon-button-size: 36px;
}

@media (forced-colors: active) {
  #voiceSearchButton {
    --cr-icon-button-fill-color: ButtonText;
  }
}

:host(:not([searchbox-next-enabled])) #voiceSearchButton,
:host([searchbox-layout-mode='TallBottomContext']) #voiceSearchButton {
  bottom: 12px;
  inset-inline-end: 12px;
  position: absolute;
}

:host([submit-enabled]:not([searchbox-next-enabled])) #voiceSearchButton {
  inset-inline-end: calc(var(--cr-icon-button-size) + 18px);
}

:host([searchbox-layout-mode='Compact']) #voiceSearchButton {
  position: absolute;
  inset-inline-end: calc(var(--cr-composebox-submit-container-size) + 12px);
  top: 10px;
}

:host([searchbox-next-enabled][searchbox-layout-mode='Compact'])
    #carouselContainer,
:host([searchbox-next-enabled][searchbox-layout-mode='Compact'])
    #voiceCarouselContainer,
:host([searchbox-next-enabled][searchbox-layout-mode='TallBottomContext'])
    #carouselContainer,
:host([searchbox-next-enabled][searchbox-layout-mode='TallBottomContext'])
    #voiceCarouselContainer {
  align-items: flex-end;
  display: flex;
  flex-direction: row;
}

:host([submit-enabled][searchbox-layout-mode='Compact']) cr-composebox-submit::part(submit) {
  inset-inline-end: 0;
  margin-block: 12px 2px;
  margin-inline: auto 10px;
  position: relative;
}

:host([submit-enabled][searchbox-layout-mode='TallBottomContext']) cr-composebox-submit::part(submit) {
  position: absolute;
}

:host([submit-enabled][searchbox-layout-mode='TallBottomContext']:not([show-dropdown])) cr-composebox-submit::part(submit) {
  bottom: 10px;
}

:host([submit-enabled][searchbox-layout-mode='TallBottomContext'][show-dropdown]) cr-composebox-submit::part(submit) {
  top: var(--cr-composebox-submit-container-top, 58px);
}

:host([submit-enabled][searchbox-layout-mode='TallBottomContext'][show-dropdown]:not([show-file-carousel])) .carousel-divider {
  --contextual-entrypoint-and-carousel-carousel-divider-margin-top: 50px;
}

:host([submit-enabled][searchbox-layout-mode='TallBottomContext'][show-dropdown][show-file-carousel]) .carousel-divider {
  --contextual-entrypoint-and-carousel-carousel-divider-margin-top: 8px;
}

:host([submit-enabled][searchbox-layout-mode='TallBottomContext']) #voiceSearchButton {
  inset-inline-end: calc(var(--cr-composebox-submit-container-size) + 18px);
}

:host([submit-enabled][searchbox-layout-mode='TallBottomContext'][show-dropdown]) #voiceSearchButton {
  bottom: unset;
  top: var(--cr-composebox-voice-icon-top, 60px);
}

:host([searchbox-next-enabled]) #contextEntrypoint::part(context-menu-entrypoint-icon) {
  --cr-icon-button-icon-size: 24px;
  --cr-icon-button-margin-start: 2px;
  --cr-icon-button-size: 36px;
}

:host([searchbox-next-enabled][entrypoint-name='Omnibox']) #contextEntrypoint[is-oblong-shape]::part(context-menu-entrypoint-icon) {
  --cr-icon-button-size: 32px;
}

:host([searchbox-next-enabled][searchbox-layout-mode^='Tall']) #contextEntrypoint::part(context-menu-entrypoint-icon) {
  --cr-icon-button-icon-size: 20px;
}

:host([searchbox-next-enabled]) #carousel,
:host([searchbox-next-enabled]) #voiceSearchCarousel {
  --context-non-top-carousel-bottom-margin: 12px;
  --context-non-top-carousel-top-margin: 6px;
}

:host([is-omnibox-in-compact-mode_]) #carousel,
:host([is-omnibox-in-compact-mode_]) #voiceSearchCarousel {
  --context-non-top-carousel-bottom-margin: 12px;
  margin-top: 12px !important;
}

:host([in-voice-search-mode]) #suggestionActivity {
  display: none;
}
