/*
 * Searchia omnibox — closed capsule; open = one continuous fused card.
 * Same in-flow geometry on home, SERP, and chrome pages (no center flip).
 * Dismiss layer stays transparent — never dim the page.
 */

.omnibox-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-omnibox-scrim, 10040);
  margin: 0;
  padding: 0;
  border: none;
  appearance: none;
  -webkit-appearance: none;
  /* Invisible hit target only — never dim the page behind suggestions. */
  background: transparent;
  opacity: 0;
  pointer-events: none;
  cursor: default;
}
.omnibox-scrim.open {
  opacity: 1;
  pointer-events: auto;
}

/* Shared: header-hosted search must stack above the dismiss scrim. */
html.omnibox-open header,
body.omnibox-open header {
  z-index: 10060;
  isolation: isolate;
}

.omnibox-wrap {
  position: relative;
  z-index: var(--z-omnibox, 40);
  width: 100%;
  display: block;
}
.omnibox-wrap.omnibox-open,
.omnibox-wrap.omnibox-raised {
  /* Above the transparent dismiss layer (--z-omnibox-scrim). */
  z-index: var(--z-omnibox-modal, 10050);
}

.omnibox-host {
  --omnibox-radius: var(--r-search);
  position: relative;
  z-index: 2;
  border-radius: var(--omnibox-radius);
  background: var(--search-bar-bg, var(--bg));
}
/*
 * Set border-radius directly (not via a multi-value custom prop) — Safari
 * can drop `var(--x)` when --x is `26px 26px 0 0`, leaving a stair-step.
 */
/* Beat catalog `.search-bar { border-radius: var(--omnibox-radius) }` regardless
   of stylesheet order (catalog can win equal-specificity races). */
.search-bar.omnibox-host.omnibox-open,
.omnibox-host.omnibox-open {
  border-radius: var(--r-omnibox-open) var(--r-omnibox-open) 0 0 !important;
  border-color: var(--border) !important;
  border-bottom-color: transparent !important;
  /* Shadow only downward so side edges stay flush with the panel. */
  box-shadow: var(--omnibox-open-shadow) !important;
  z-index: 3;
  background: var(--search-bar-bg, var(--bg));
}

/* Instant open — one continuous card with the host (no air gap, no popover) */
.omnibox-panel {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  margin: 0;
  padding: 0;
  max-height: min(70vh, 620px);
  overflow: visible;
  box-sizing: border-box;
  background: var(--search-bar-bg, var(--bg));
  border: 1px solid var(--border);
  border-top: 1px solid var(--surface1);
  border-radius: 0 0 var(--r-omnibox-open) var(--r-omnibox-open);
  box-shadow: var(--omnibox-panel-shadow);
}
.omnibox-panel.open {
  display: flex;
}
.omnibox-panel-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--surface1) transparent;
  /* Columns follow the bar (omnibox.js sets --ob-icon-x / --ob-text-x from
     the search icon centre and the input's text start, measured from this
     list's left edge): row icons sit under the search icon, row text and
     section labels start where typed text starts. 28px = row icon box. */
  --ob-pad: max(4px, calc(var(--ob-icon-x, 28px) - 8px - 14px));
  --ob-gap: max(
    8px,
    calc(var(--ob-text-x, 51px) - var(--ob-icon-x, 28px) - 14px)
  );
  /* Even 8px inset on every side (rows add their own 8px side margins). */
  padding: 8px 0;
  border-radius: 0 0 calc(var(--r-omnibox-open) - 1px)
    calc(var(--r-omnibox-open) - 1px);
  box-sizing: border-box;
}
/* Optional sliding highlight — active rows also get surface0 so selection
   remains visible if hl is missing or off. */
.omnibox-hl {
  position: absolute;
  top: 0;
  left: 8px;
  right: 8px;
  border-radius: var(--r-omnibox-item);
  background: var(--surface0);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition:
    transform var(--duration-fast) var(--ease-out),
    height var(--duration-fast) var(--ease-out),
    opacity var(--duration-fast) var(--ease-out);
}
.omnibox-hl.on {
  opacity: 1;
}
.omnibox-hl.snap {
  transition: opacity var(--duration-fast) var(--ease-out);
}
/* Rows keep their natural height and the list scrolls. As a flex column
   with a capped height, children would otherwise shrink: two-line rows
   squashed to min-height and section labels to zero (short windows). */
.omnibox-panel-inner > * {
  flex-shrink: 0;
}
.omnibox-panel-inner::-webkit-scrollbar {
  width: 6px;
}
.omnibox-panel-inner::-webkit-scrollbar-track {
  background: transparent;
  margin-block: 10px;
}
.omnibox-panel-inner::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 32%, transparent);
  border-radius: var(--r-pill);
}
.omnibox-panel-inner::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 48%, transparent);
}
.omnibox-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--ob-gap);
  margin-inline: 8px;
  min-height: var(--hit-target, 44px);
  padding: 8px 12px 8px var(--ob-pad);
  border-radius: var(--r-omnibox-item);
  cursor: pointer;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background-color var(--duration-fast) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .omnibox-item:hover {
    background: var(--surface0);
  }
}
.omnibox-item.active {
  background: var(--surface0);
}
.omnibox-item:active {
  background: var(--fill-tertiary, var(--surface1));
}
.omnibox-icon {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: color var(--duration-fast) var(--ease-out);
}
.omnibox-icon svg {
  width: 20px;
  height: 20px;
}
.omnibox-item.active .omnibox-icon {
  color: var(--text);
}
.omnibox-thumb {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--surface0);
  box-shadow: 0 0 0 1px var(--separator, var(--border));
}
.omnibox-text {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.omnibox-title {
  font-size: var(--type-body, 15px);
  font-weight: 500;
  letter-spacing: var(--tracking-body, -0.01em);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.omnibox-title .omnibox-typed {
  font-weight: 400;
  color: var(--subtext);
}
.omnibox-desc {
  font-size: var(--type-footnote, 13px);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.omnibox-arrow {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: 0;
}
.omnibox-arrow svg {
  width: 16px;
  height: 16px;
}
.omnibox-item.active .omnibox-arrow {
  opacity: 0.7;
}
.omnibox-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-inline: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  /* Label starts at the icon column (20px glyph centred in its 28px box),
     like the rows' leading edge, not indented to the text column. */
  padding: 8px 12px 2px calc(var(--ob-pad) + 4px);
  min-height: 0;
}
/* Quiet text action — expand hit target without bloating the Recent row. */
.omnibox-clear {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  font: inherit;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--blue, #1a73e8);
  background: transparent;
  border: none;
  padding: 2px 4px;
  min-height: 0;
  margin: 0;
  cursor: pointer;
  border-radius: var(--r-sm);
  white-space: nowrap;
  line-height: 1.3;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
.omnibox-clear::before {
  content: "";
  position: absolute;
  inset: -10px -8px;
}
@media (hover: hover) {
  .omnibox-clear:hover {
    text-decoration: underline;
  }
}
.omnibox-clear:focus {
  outline: none;
}
.omnibox-clear:focus-visible {
  outline: 2px solid var(--blue, #1a73e8);
  outline-offset: 2px;
}

/* Input wrap + trailing actions (clear + mic) — Google/Bing-style right cluster */
.search-clear {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
}
.search-clear > input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  color: var(--text, #202124);
  caret-color: var(--text, #202124);
  /* Trailing controls live outside the input as flex siblings */
  padding-right: 4px !important;
}
:root[data-theme="dark"] .search-clear > input {
  color: var(--text, #e8eaed);
  caret-color: var(--text, #e8eaed);
}
/* Hide built-in browser clear/credential UI that fights our clear control */
.search-bar input::-webkit-search-decoration,
.search-bar input::-webkit-search-cancel-button,
.search-bar input::-webkit-search-results-button,
.search-bar input::-webkit-credentials-auto-fill-button,
.search-bar input::-webkit-contacts-auto-fill-button,
.search-clear > input::-webkit-search-decoration,
.search-clear > input::-webkit-search-cancel-button,
.search-clear > input::-webkit-search-results-button,
.search-clear > input::-webkit-credentials-auto-fill-button,
.search-clear > input::-webkit-contacts-auto-fill-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
/* Far-right action cluster: [clear] [mic] — mic stays put like Google/Bing */
.search-bar:has(.search-voice-btn),
.search-bar:has(.search-trailing.has-value) {
  /* Mirror left icon inset when trailing controls are visible */
  padding-right: 10px !important;
}
.search-trailing {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 0;
  margin-left: 0;
}
.search-clear-btn,
.search-voice-btn,
.rimg-btn {
  position: relative;
  z-index: 4;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted, #5f6368);
  cursor: pointer;
  transition:
    background var(--duration-fast, 0.1s) var(--ease-out, ease),
    color var(--duration-fast, 0.1s) var(--ease-out, ease),
    opacity var(--duration-base, 0.16s) var(--ease-out, ease),
    scale var(--duration-slow, 0.22s) var(--ease-out, ease);
}
.search-clear-btn:active,
.search-voice-btn:active,
.rimg-btn:active {
  scale: 0.92;
}
.search-clear-btn[hidden],
.search-voice-btn[hidden] {
  display: none !important;
}
@media (hover: hover) {
  .search-clear-btn:hover,
  .search-voice-btn:hover,
  .rimg-btn:hover {
    background: var(--surface0, #f1f3f4);
    color: var(--text, #202124);
  }
  .search-bar:not(:hover, .rimg-drop, .rimg-busy)
    .rimg-btn:not(:focus-visible) {
    opacity: 0;
  }
}
.search-voice-btn.is-listening {
  color: var(--blue, #1a73e8);
  background: color-mix(in srgb, var(--blue, #1a73e8) 14%, transparent);
}
.search-clear-btn:focus-visible,
.search-voice-btn:focus-visible {
  outline: 2px solid var(--blue, #1a73e8);
  outline-offset: 1px;
}
/* Match home .search-icon (20×20, filled). SERP chrome uses 18×18. */
.search-clear-btn svg,
.search-voice-btn svg,
.rimg-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}
.search-container .search-clear-btn svg,
.search-container .search-voice-btn svg,
.search-container .rimg-btn svg {
  width: 18px;
  height: 18px;
}
.search-container .search-clear-btn,
.search-container .search-voice-btn,
.search-container .rimg-btn {
  width: var(--hit-target);
  height: var(--hit-target);
}
.search-bar.rimg-drop {
  position: relative;
  border-color: var(--blue, #1a73e8) !important;
  outline: 1px solid var(--blue, #1a73e8);
}
.search-bar.rimg-drop::after {
  content: "Drop an image to search";
  position: absolute;
  inset: 3px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: color-mix(
    in srgb,
    var(--blue, #1a73e8) 14%,
    var(--surface0, #f1f3f4)
  );
  color: var(--blue, #1a73e8);
  font-size: 0.875rem;
  pointer-events: none;
  z-index: 5;
}
.search-bar.rimg-busy {
  cursor: progress;
}
.search-bar.rimg-busy .rimg-btn {
  opacity: 0.5;
}
.search-bar .rimg-qchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-right: 4px;
}
.search-bar .rimg-qchip-img {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface0, #f1f3f4);
}
.search-bar .rimg-qchip-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.search-bar .rimg-qchip-x {
  position: relative;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted, #5f6368);
  cursor: pointer;
  padding: 0;
}
.search-bar .rimg-qchip-x::after {
  content: "";
  position: absolute;
  inset: calc((var(--hit-target) - 24px) / -2);
}

/* Google/Bing-style voice listening overlay */
.voice-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-close) var(--ease-out);
  font-family: inherit;
}
.voice-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.voice-overlay-card {
  position: relative;
  width: min(440px, 100%);
  padding: var(--space-8) var(--space-7) var(--space-6);
  border-radius: var(--r-sheet);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--lift-2);
  text-align: center;
}
:root[data-theme="dark"] .voice-overlay-card {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--lift-2);
}
.voice-overlay-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: var(--hit-target);
  height: var(--hit-target);
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
@media (hover: hover) {
  .voice-overlay-close:hover {
    background: var(--surface0);
    color: var(--text);
  }
}
.voice-overlay-close svg {
  width: 20px;
  height: 20px;
}
.voice-overlay-mic {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 4px auto 22px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--blue);
  color: var(--bg);
  cursor: pointer;
}
.voice-overlay-mic svg {
  width: 44px;
  height: 44px;
  position: relative;
  z-index: 1;
}
.voice-overlay-mic::before,
.voice-overlay-mic::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--blue) 35%, transparent);
  z-index: 0;
  opacity: 0;
}
.voice-overlay.open:not(.is-error) .voice-overlay-mic::before,
.voice-overlay.open:not(.is-error) .voice-overlay-mic::after {
  animation: voice-pulse 1.6s var(--ease-out) infinite;
}
.voice-overlay.open:not(.is-error) .voice-overlay-mic::after {
  animation-delay: 0.5s;
}
@keyframes voice-pulse {
  0% {
    transform: scale(1);
    opacity: 0.55;
  }
  100% {
    transform: scale(1.85);
    opacity: 0;
  }
}
.voice-overlay.is-error .voice-overlay-mic {
  background: var(--red);
}
.voice-overlay-status {
  margin: 0 0 10px;
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: inherit;
}
.voice-overlay.is-error .voice-overlay-status {
  font-size: 1.05rem;
  color: var(--red);
}
.voice-overlay-transcript {
  min-height: 1.4em;
  margin: 0;
  font-size: 1.1rem;
  color: var(--muted);
  word-break: break-word;
}
.voice-overlay-hint {
  margin: 18px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.voice-overlay[hidden] {
  display: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .search-clear-btn,
  .search-voice-btn,
  .voice-overlay,
  .omnibox-hl,
  .omnibox-item {
    transition-property: opacity, background-color !important;
  }
  .voice-overlay-mic::before,
  .voice-overlay-mic::after {
    animation: none !important;
    opacity: 0 !important;
  }
}
@media (hover: hover) and (pointer: fine) {
  .omnibox-item:hover .omnibox-arrow {
    opacity: 0.7;
  }
}
