/*
 * The Ask panel's styles, shared by fmandc.com and the customer portal along
 * with assets/ask.js. It reads the site's design tokens (--red, --ink,
 * --s-4 and the rest): the website defines them on :root in site.css, and the
 * portal defines the same names on the element that holds the panel. Keep
 * every panel rule here, never in site.css or the portal, so the two hosts
 * cannot drift.
 */

.ask .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.ask {
  /* The drop from the top is also what the height has to give back, so it is
     a variable rather than two numbers that can drift apart and let the panel
     hang off the bottom of a short window. */
  --ask-top: clamp(var(--s-6), 12vh, var(--s-9));

  width: min(36rem, calc(100vw - var(--s-6)));
  max-height: calc(100dvh - var(--ask-top) - var(--s-6));
  margin: var(--ask-top) auto var(--s-6);
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 32px 64px -24px rgb(42 38 34 / 40%);
  overflow: hidden;
}
.ask::backdrop {
  background: rgb(42 38 34 / 45%);
  backdrop-filter: blur(3px);
}
.ask[open] {
  animation: ask-rise 180ms ease-out;
}
.ask[open]::backdrop {
  animation: ask-fade 180ms ease-out;
}
@keyframes ask-rise {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
}
@keyframes ask-fade {
  from {
    opacity: 0;
  }
}

.ask__panel {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  padding: var(--s-5);
}
.ask__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
}
.ask__title {
  margin: 0;
  font-size: var(--t--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}
.ask__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -0.6rem -0.6rem -0.6rem 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}
.ask__close:hover {
  background: var(--ground-alt);
  color: var(--ink);
}
.ask__close svg {
  width: 1.1rem;
  height: 1.1rem;
}

.ask__form {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: 2px solid var(--rule-strong);
  transition: border-color 160ms ease-out;
}
.ask__form:focus-within {
  border-bottom-color: var(--red);
}
.ask__icon {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--ink-faint);
}
.ask__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--display);
  font-size: var(--t-2);
  font-weight: 500;
  color: var(--ink);
}
.ask__input::placeholder {
  font-weight: 400;
  color: var(--ink-faint);
}
.ask__input:focus {
  outline: none;
}
.ask__input::-webkit-search-cancel-button {
  display: none;
}
.ask__clear,
.ask__mic {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}
.ask__clear svg {
  width: 1rem;
  height: 1rem;
}
.ask__mic svg {
  width: 1.25rem;
  height: 1.25rem;
}
.ask__clear:hover,
.ask__mic:hover {
  background: var(--ground-alt);
  color: var(--ink);
}
/* `hidden` is a UA display rule, and the display above outranks it. Without
   this the clear cross sits in an empty box and the mic shows in a browser
   that cannot listen. */
.ask__clear[hidden],
.ask__mic[hidden] {
  display: none;
}
/* Listening is the one state on the site that keeps moving on its own, so it
   is the one place a pulse is worth the attention it takes. */
.ask.is-listening .ask__mic {
  background: var(--red);
  color: #fff;
  animation: ask-pulse 1.4s ease-out infinite;
}
@keyframes ask-pulse {
  from {
    box-shadow: 0 0 0 0 rgb(191 29 29 / 45%);
  }
  to {
    box-shadow: 0 0 0 0.75rem rgb(191 29 29 / 0%);
  }
}

.ask__hint {
  margin: var(--s-3) 0 0;
  font-size: var(--t--1);
  color: var(--ink-faint);
}
.ask.is-listening .ask__hint {
  color: var(--red);
}

.ask__seeds {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-4);
}
.ask__seeds[hidden] {
  display: none;
}
.ask__seed {
  padding: 0.35rem var(--s-3);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--ground-alt);
  font: inherit;
  font-size: var(--t--1);
  color: var(--ink-soft);
  cursor: pointer;
}
.ask__seed:hover {
  border-color: var(--red);
  background: var(--red-tint);
  color: var(--red);
}

.ask__results {
  flex: 1 1 auto;
  overflow-y: auto;
  margin: var(--s-4) calc(var(--s-5) * -1) calc(var(--s-5) * -1);
  border-top: 1px solid var(--rule);
}
.ask__hit {
  display: grid;
  gap: 0.15rem;
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--rule);
  color: inherit;
  text-decoration: none;
}
.ask__hit:first-child {
  border-top: 0;
}
.ask__hit:hover,
.ask__hit[aria-selected='true'] {
  background: var(--red-tint);
}
.ask__hit-q {
  font-family: var(--display);
  font-weight: 600;
  color: var(--ink);
}
.ask__hit-where {
  font-size: var(--t--1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--red);
}
.ask__hit-snip {
  font-size: var(--t--1);
  color: var(--ink-faint);
  /* Two lines of the answer is enough to recognise it and short enough that
     eight results still fit on a phone screen. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Database answers have no page to jump to, so they open right in the list.
   The hit is a <button>, not a link, and clicking it swaps the two-line
   snippet for the full answer. */
.ask__hit--extra {
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ask__hit--extra .ask__hit-full {
  display: none;
}
.ask__hit--extra.is-open .ask__hit-snip {
  display: none;
}
.ask__hit--extra.is-open .ask__hit-full {
  display: block;
  font-size: var(--t-0);
  line-height: 1.55;
  color: var(--ink-soft);
  white-space: pre-line;
}
.ask__hit--extra.is-open {
  background: var(--red-tint);
}

/* The AI helper's answer. Deliberately set apart from Brad's own answers:
   muted ground, and the not-checked-by-FMandC label always attached. */
.ask__ai {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  background: var(--ground-alt);
  border-top: 1px solid var(--rule);
}
.ask__ai-a {
  margin: 0;
  font-size: var(--t-0);
  line-height: 1.55;
  color: var(--ink-soft);
}
.ask__ai .ask__hit-where {
  color: var(--ink-faint);
}
.ask__ai-note {
  margin: 0;
  font-size: var(--t--1);
  color: var(--ink-soft);
}
.ask__ai-note a,
.ask__empty a {
  color: var(--red);
  font-weight: 600;
  text-decoration: none;
}

.ask__related-note {
  margin: 0;
  padding: var(--s-3) var(--s-5) var(--s-1);
  border-top: 1px solid var(--rule);
  font-size: var(--t--1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.ask__checking {
  margin: 0;
  padding: 0 var(--s-5) var(--s-4);
  font-size: var(--t--1);
  color: var(--ink-faint);
}

.ask__empty {
  padding: var(--s-4) var(--s-5);
  font-size: var(--t--1);
  color: var(--ink-soft);
}

@media (max-width: 560px) {
  .ask {
    --ask-top: var(--s-5);
  }
  .ask__panel {
    padding: var(--s-4);
  }
  .ask__results {
    margin-inline: calc(var(--s-4) * -1);
  }
  .ask__hit,
  .ask__empty {
    padding-inline: var(--s-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ask[open],
  .ask[open]::backdrop,
  .ask.is-listening .ask__mic {
    animation: none;
  }
}
