/* 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
 * #import=chrome://resources/cr_elements/cr_icons_lit.css.js
 * #import=chrome://resources/cr_elements/cr_shared_vars.css.js
 * #scheme=relative
 * #include=cr-icons-lit
 * #css_wrapper_metadata_end */

:host {
  --bg-bottom-url: url(images/refresh_bg_bottom_light.svg);
  --bg-right-url: url(images/refresh_bg_right_light.svg);
  --background-color: white;
  --search-engine-icon-size: 24px;
  --action-button-margins: 24px;
  --content-container-width: 500px;
  --radio-button-horizontal-padding: 16px;
  --choice-gap: 16px;
  --search-engine-name-line-height: 20px;
  --marketing-snippet-line-height: 16px;
  --choice-height: calc(var(--search-engine-name-line-height) +
      var(--marketing-snippet-line-height));

  --child-max-height: 31.25rem;
  --child-max-width: 31.25rem;
  --content-gap: 3rem;
  --content-width: calc(2 * var(--child-max-width) + var(--content-gap));

  --showcase-text-gap: 1.5rem;
  --showcase-text-padding-top: 3rem;
  --subtitle-font-size: 1rem;
  --text-max-width: 21.875rem;
  --title-font-size: 1.5rem;
  color: var(--cr-primary-text-color);
  display: flex;
  flex-direction: column;
  height: 100%;
}

#product-logo {
  height: 2.5rem;
  width: 2.5rem;
}

#content-div {
  align-items: flex-start;
  display: flex;
  flex: 1;
  flex-direction: row;
  gap: var(--content-gap);
  justify-content: center;
  margin: 0 3rem 0;
}

@media screen and ((max-width: 780px) or (max-height: 600px)) {
  :host {
    --showcase-text-gap: 0.75rem;
    --showcase-text-padding-top: 0.75rem;
    --text-max-width: 18.125rem;
  }
}

.content-child {
  align-items: flex-start;
  display: flex;
  flex: 1;
  max-height: var(--child-max-height);
  max-width: var(--child-max-width);
  width: 60%;
  margin: 20vh 0 0 0;
}

#showcase-illustration {
  flex-direction: column;
  width: var(--content-container-width);
  max-height: 450px;
}

#showcase-description {
  align-items: flex-start;
  flex-direction: column;
  justify-content: flex-start;
}

#showcase-text {
  display: flex;
  flex-direction: column;
  gap: var(--showcase-text-gap);
  padding-top: var(--showcase-text-padding-top);
}

.title {
  font-weight: 500;
  letter-spacing: 0;
  line-height: 2rem;
  font-size: var(--title-font-size);
  max-width: var(--text-max-width);
  margin: 0;
}

.subtitle {
  font-size: var(--subtitle-font-size);
  font-weight: 400;
  line-height: 1.5rem;
  margin: 0;
  max-width: var(--text-max-width);
}

#buttonContainer {
  display: flex;
  pointer-events: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

#actionButton {
  pointer-events: all;
}

cr-checkbox {
  --cr-checkbox-label-color: var(--google-grey-700);
  --cr-checkbox-label-padding-start: 8px;
  font-size: 0.75rem;
  pointer-events: all;
}

#choiceList {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  text-align: start;
  overflow-y: auto;
  margin: 0;
}

.choice {
  display: flex;
  flex-direction: row;
  gap: var(--choice-gap);
}

.choice-text {
  --choice-text-width: calc(var(--content-container-width) -
      2 * var(--radio-button-horizontal-padding) -
      var(--search-engine-icon-size) - var(--choice-gap) -
      var(--cr-radio-button-label-spacing) - var(--cr-radio-button-size));
  display: flex;
  flex-direction: column;
  width: var(--choice-text-width);
}

.choice-icon {
  background-size: var(--search-engine-icon-size);
  border-radius: 4px;
  flex: none;
  height: var(--search-engine-icon-size);
  /* So that the icon doesn't change position when the snippet is expanded. */
  margin-top: calc((var(--choice-height) - var(--search-engine-icon-size))/2);
  width: var(--search-engine-icon-size);
}

.choice-title {
  align-items: center;
  display: flex;
  flex-direction: row;
  font-family: Roboto, Arial;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 20px;
  text-align: start;
}

.cr-icon {
  --cr-icon-color: currentColor;
  --cr-icon-image: url(images/arrow_downward_old.svg);
  --cr-icon-ripple-size: 18px;
  --cr-icon-size: 18px;
  margin: 0;
}

#choiceList.overlap-mitigation {
  --button-container-height: calc(var(--cr-button-height) + 2 *
      var(--action-button-margins));
  padding-bottom: var(--button-container-height);
}

#buttonContainer.overlap-mitigation {
  background-color: var(--background-color);
  border-top: var(--cr-separator-line);
  pointer-events: unset;
}

cr-radio-button {
  /* So that the radio button doesn't change position when the snippet is
  expanded. */
  --cr-radio-button-disc-margin-block-start: calc((var(--choice-height) -
      var(--cr-radio-button-size))/2);
  --cr-radio-button-label-spacing: 16px;
  --cr-radio-button-size: 20px;
  align-items: start;
  background-color: var(--cr-fallback-color-surface2);
  border-bottom: 1px solid var(--background-color);
  border-radius: 2px;
  padding: 8px var(--radio-button-horizontal-padding);
}

cr-radio-button:first-of-type {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

cr-radio-button:last-of-type {
  border-bottom: unset;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

cr-radio-button[checked] {
  background-color: var(--cr-fallback-color-tonal-container);
}

/* Using a class instead of relying only on the pseudo-class allows
disabling this style in screenshot tests, where the inability to
control the pointer location causes some flakiness. */
.hoverable:hover:not([checked]) {
  background-color: var(--cr-hover-on-subtle-background-color);
}

.marketing-snippet {
  color: var(--cr-secondary-text-color);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: var(--marketing-snippet-line-height);
}

.truncate-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-engine-name {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: var(--search-engine-name-line-height);
}

.info-dialog-illustration {
  content: url(images/info_dialog_illustration.svg);
  margin-bottom: 24px;
  width: 100%;
}

.background-shape {
  position: fixed;
  z-index: -1;
}

#background-right {
  content: var(--bg-right-url);
  height: 33%;
  right: 0;
  top: 50%;
  /* The image starts shrinking when space between the image and content is
  equal to 40% of image's width. It pushes away the image 1px for every 2px of
  smaller screen size. Part "max(0px, calc(...))" prevents the image from being
  driven away to the left from the right edge */
  transform: translate(
    max(0px, calc(60% - (50vw - var(--content-width) / 2) / 2)),
    -100%);
}

#background-bottom {
  bottom: 0;
  content: var(--bg-bottom-url);
  left: 65%;
  width: 20%;
  /* Same as above, but start point is 10% as we have more space vertically */
  transform: translate(
    -50%,
    max(0px, calc(10% - (50vh - (var(--child-max-height) / 2)) / 2)));
}

:host-context([dir='rtl']) #background-right {
  left: 0;
  right: auto;
  transform: scaleX(-1) translate(
      max(0px, calc(60% - (50vw - var(--content-width) / 2) / 2)),
      -100%);
}

:host-context([dir='rtl']) #background-bottom {
  left: auto;
  right: 65%;
  transform: scaleX(-1) translate(
    -50%,
    max(0px, calc(10% - (50vh - (var(--child-max-height) / 2)) / 2)));
}

/* 'hidden' will not work for '<cr-checkbox>'. This change makes the
  'hidden' attribute selector is more specific than the class selector. */
[hidden]{
  display: none;
}

@media screen and ((max-width: 1000px) or (max-height: 640px)) {
  .background-shape {
    display: none;
  }
}

:host([use-horizontal-mode_]) {
    --showcase-text-gap: 0.75rem;
    --showcase-text-padding-top: 0.75rem;
    --content-gap: 1.5rem;
  }

:host([use-horizontal-mode_]) #content-div {
  align-items: center;
  flex-direction: column-reverse;
  margin: unset;
}

:host([use-horizontal-mode_]) .content-child {
  height: auto;
  margin: 0;
}

:host([use-horizontal-mode_]) #showcase-description {
  align-items: center;
  margin-top: 64px;
}

:host([use-horizontal-mode_]) #choiceList {
  height: auto;
  max-height: unset;
  min-height: 0;
}

:host([use-horizontal-mode_]) .title,
:host([use-horizontal-mode_]) .subtitle {
  text-align: center;
  max-width: unset;
}

:host([use-horizontal-mode_]) #buttonContainer {
  align-items: center;
  bottom: 0;
  box-sizing: border-box;
  flex-direction: row;
  justify-content: flex-end;
  left: 0;
  padding: 24px;
  pointer-events: none;
  position: fixed;
  width: 100%;
  z-index: 1;
}

:host([use-horizontal-mode_]) #showcase-illustration {
  max-height: unset;
  padding-bottom: 48px;
}

:host([use-horizontal-mode_])
  #buttonContainer:has(> #guestCheckbox:not([hidden])) {
  justify-content: space-between;
}

:host(:not([use-horizontal-mode_])) #choiceList.overlap-mitigation {
  #choiceList.overlap-mitigation {
    padding-bottom: 0;
  }
}

@media screen and (max-width: 548px) {
  :host {
    --content-container-width: 452px;
  }
}

@media (prefers-color-scheme: dark) {
  :host {
    --background-color: var(--md-background-color);
    --bg-bottom-url: url(images/refresh_bg_bottom_dark.svg);
    --bg-right-url: url(images/refresh_bg_right_dark.svg);
  }

  #infoLink {
    color: var(--google-blue-300);
  }

  cr-radio-button {
    --cr-radio-button-unchecked-color: var(--google-grey-100);
  }

  cr-checkbox {
    --cr-checkbox-label-color: var(--google-grey-500);
  }
}

:host-context([webui-rounded-icons]) .cr-icon {
  --cr-icon-image: url(images/arrow_downward.svg);
}
