/* Ask Amp demo chrome. Match Lee’s live guitar-amp panel on humanamp.ai.
   Honour prefers-reduced-motion. Prefer var(--ha-*). */

.amp-root {
  font-family: Manrope, var(--ha-font-sans, system-ui), sans-serif;
  color: var(--ha-ink);
  line-height: 1.45;
}

.amp-launcher,
.amp-panel,
.amp-panel * {
  box-sizing: border-box;
}

.amp-launcher {
  position: fixed;
  right: clamp(16px, 2vw, 28px);
  bottom: clamp(16px, 2vw, 28px);
  z-index: 80;
  isolation: isolate;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  cursor: pointer;
}

.amp-launcher::before,
.amp-character {
  background-image: url("ask-amp-agent-expressions.png");
  background-repeat: no-repeat;
  background-size: 700% 100%;
  background-position: 0 0;
}

.amp-launcher::before {
  content: "";
  position: absolute;
  inset: 0;
  transform-origin: 50% 88%;
}

.amp-launcher::after,
.amp-character::after {
  content: "";
  position: absolute;
  left: 11.72%;
  top: 47.27%;
  width: 76.56%;
  height: 28.13%;
  background: linear-gradient(112deg, transparent 36%, rgba(255, 255, 255, 0.92) 48%, transparent 59%) 160% 0 / 230% 100% no-repeat;
  -webkit-mask: url("ask-amp-chrome-badge.png") center / contain no-repeat;
  mask: url("ask-amp-chrome-badge.png") center / contain no-repeat;
  opacity: 0;
  pointer-events: none;
  animation: amp-chrome-glint 19s ease-in-out infinite;
}

.amp-launcher.is-blinking::before,
.amp-character.is-blinking {
  background-position: 50% 0;
}

.amp-launcher.is-winking::before,
.amp-character.is-winking {
  background-position: 83.3333% 0;
}

.amp-launcher:focus-visible,
.amp-icon-btn:focus-visible,
.amp-send:focus-visible,
.amp-note-btn:focus-visible,
.amp-choice:focus-visible,
.amp-field input:focus-visible,
.amp-field select:focus-visible,
.amp-field textarea:focus-visible {
  outline: 2px solid var(--ha-bloom-deep);
  outline-offset: 3px;
}

.amp-panel[hidden],
.amp-launcher[hidden],
.amp-handover[hidden],
.amp-thread[hidden],
.amp-error[hidden] {
  display: none;
}

/* The panel takes focus on a touch screen when it opens, not the field. */
.amp-panel:focus {
  outline: none;
}

.amp-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 81;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(398px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 88px));
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(250, 250, 249, 0.88), rgba(224, 225, 225, 0.82));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(255, 255, 255, 0.28),
    0 24px 70px rgba(var(--ha-ink-rgb), 0.24);
  -webkit-backdrop-filter: blur(36px) saturate(1.08);
  backdrop-filter: blur(36px) saturate(1.08);
}

.amp-character {
  position: absolute;
  top: -31px;
  left: 17px;
  width: 92px;
  height: 92px;
  pointer-events: none;
}

.amp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 9px 11px 9px 116px;
  border-bottom: 1px solid rgba(var(--ha-ink-rgb), 0.12);
}

.amp-header p {
  margin: 0;
  color: color-mix(in srgb, var(--ha-ink) 58%, var(--ha-paper));
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.amp-header-actions {
  display: flex;
  gap: 4px;
}

.amp-icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ha-ink);
  cursor: pointer;
}

.amp-icon-btn:hover {
  background: rgba(var(--ha-ink-rgb), 0.08);
}

.amp-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  padding: 18px 14px 12px;
  overflow: auto;
  overscroll-behavior: contain;
}

.amp-row {
  display: flex;
  flex-direction: column;
  width: fit-content;
  max-width: 84%;
  margin: 0 0 10px;
}

.amp-row-amp {
  align-self: flex-start;
}

.amp-row-user {
  align-self: flex-end;
}

.amp-bubble {
  padding: 10px 12px 7px;
  border-radius: 17px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.48;
  box-shadow: 0 1px 1px rgba(var(--ha-ink-rgb), 0.05);
}

.amp-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.amp-row-amp .amp-bubble {
  background: var(--ha-bloom);
  color: var(--ha-ink);
  border-bottom-left-radius: 5px;
}

.amp-row-user .amp-bubble {
  background: color-mix(in srgb, var(--ha-ink) 18%, var(--ha-paper));
  color: var(--ha-ink);
  border-bottom-right-radius: 5px;
}

.amp-meta {
  margin-bottom: 3px;
  color: color-mix(in srgb, var(--ha-ink) 68%, transparent);
  font-size: 10px;
  font-weight: 600;
}

.amp-time {
  align-self: flex-end;
  margin-top: 4px;
  color: color-mix(in srgb, var(--ha-ink) 48%, transparent);
  font-size: 9px;
  font-weight: 450;
  font-variant-numeric: tabular-nums;
}

.amp-composer {
  padding: 10px;
  border-top: 1px solid rgba(var(--ha-ink-rgb), 0.1);
  background: rgba(248, 248, 247, 0.46);
  border-radius: 0 0 22px 22px;
}

.amp-compose-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

/* The field holds the dictation mic, as in the reference composers, so the
   mic reads as part of typing and the waveform as its own thing. */
.amp-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.amp-composer input {
  max-height: 112px;
  min-height: 42px;
  width: 100%;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--ha-hairline);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ha-ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  outline: 0;
}

.amp-composer.has-dictate input[name="message"] {
  padding-right: 44px;
}

.amp-composer input:focus {
  border-color: var(--ha-bloom-deep);
  box-shadow: 0 0 0 3px rgba(var(--ha-bloom-rgb), 0.18);
}

.amp-composer input::placeholder {
  color: color-mix(in srgb, var(--ha-ink) 45%, var(--ha-paper));
}

.amp-attach,
.amp-dictate,
.amp-talk,
.amp-send {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.amp-attach[hidden],
.amp-dictate[hidden],
.amp-talk[hidden],
.amp-send[hidden],
.amp-files[hidden],
.amp-dictation-status[hidden] {
  display: none;
}

.amp-attach {
  border: 1px solid var(--ha-hairline);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ha-ink);
}

.amp-attach:hover,
.amp-dictate:hover {
  background: rgba(var(--ha-ink-rgb), 0.08);
}

.amp-dictate {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 36px;
  height: 36px;
  transform: translateY(-50%);
  background: transparent;
  color: color-mix(in srgb, var(--ha-ink) 70%, var(--ha-paper));
}

.amp-dictate[aria-pressed="true"] {
  background: rgba(var(--ha-bloom-rgb), 0.24);
  color: var(--ha-ink);
}

/* Voice conversation. The one prominent optional control: a filled pill in
   the site colour, so it reads as a mode, not a field button. A customer
   panel swaps the colour through its own tokens. */
.amp-talk {
  width: 52px;
  border-radius: 21px;
  background: var(--amp-voice-bg, var(--ha-bloom));
  color: var(--amp-voice-ink, var(--ha-ink));
  box-shadow: 0 1px 2px rgba(var(--ha-ink-rgb), 0.12);
}

.amp-talk:hover {
  background: color-mix(in srgb, var(--amp-voice-bg, var(--ha-bloom)) 86%, var(--ha-ink));
}

.amp-attach:focus-visible,
.amp-dictate:focus-visible,
.amp-talk:focus-visible,
.amp-live-btn:focus-visible,
.amp-files button:focus-visible {
  outline: 2px solid var(--ha-bloom-deep);
  outline-offset: 3px;
}

/* Files picked for the note. Said plainly: they go to the team, not Amp. */
.amp-files {
  margin: 0 0 8px;
  padding: 7px 9px;
  border: 1px solid rgba(var(--ha-ink-rgb), 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.amp-files-note {
  margin: 0 0 5px;
  color: color-mix(in srgb, var(--ha-ink) 70%, var(--ha-paper));
}

.amp-files ul {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.amp-files li {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 2px 2px 2px 9px;
  border-radius: 999px;
  background: rgba(var(--ha-ink-rgb), 0.07);
}

.amp-files li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amp-files li button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ha-ink);
  font-size: 15px;
  cursor: pointer;
}

.amp-dictation-status {
  margin: 6px 4px 0;
  color: color-mix(in srgb, var(--ha-ink) 72%, var(--ha-paper));
  font-size: 11px;
}

/* The live strip sits between the thread and the composer, outside the
   thread so the handover card cannot hide the call controls. */
.amp-live {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 8px;
  padding: 8px 10px;
  border: 1px solid rgba(var(--ha-ink-rgb), 0.12);
  border-radius: 12px;
  background: rgba(250, 250, 249, 0.72);
  color: var(--ha-ink);
  font-size: 11px;
  line-height: 1.35;
}

.amp-live[hidden] {
  display: none;
}

.amp-live-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ha-bloom-deep);
  animation: amp-talk-pulse 1.6s ease-in-out infinite;
}

.amp-live.is-connecting .amp-live-dot {
  background: color-mix(in srgb, var(--ha-ink) 40%, var(--ha-paper));
}

.amp-live.is-muted .amp-live-dot {
  background: color-mix(in srgb, var(--ha-ink) 40%, var(--ha-paper));
  animation: none;
}

.amp-live-text {
  flex: 1 1 auto;
  min-width: 0;
}

.amp-live-btn {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(var(--ha-ink-rgb), 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ha-ink);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.amp-live-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--ha-ink) 16%, var(--ha-paper));
}

.amp-live-btn[hidden] {
  display: none;
}

.amp-live-stop {
  background: var(--ha-ink);
  border-color: var(--ha-ink);
  color: var(--ha-paper);
}

.amp-row-live .amp-bubble {
  opacity: 0.92;
}

.amp-composer input:disabled {
  background: rgba(255, 255, 255, 0.5);
  color: color-mix(in srgb, var(--ha-ink) 55%, var(--ha-paper));
}

@keyframes amp-talk-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--ha-bloom-rgb), 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(var(--ha-bloom-rgb), 0); }
}

.amp-send {
  background: var(--ha-ink);
  color: var(--ha-paper);
}

.amp-send:disabled {
  opacity: 0.42;
  cursor: default;
}

.amp-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 4px 0 0;
  padding: 0 4px;
  color: color-mix(in srgb, var(--ha-ink) 56%, transparent);
  font-size: 9px;
}

.amp-foot a {
  color: inherit;
}

.amp-note-btn,
.amp-handover button[type="submit"] {
  position: relative;
  min-height: 40px;
  padding: 8px 15px 8px 12px;
  border: 0;
  border-radius: 0;
  background: color-mix(in srgb, var(--ha-ink) 28%, var(--ha-paper));
  color: var(--ha-ink);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
  cursor: pointer;
}

.amp-note-btn::after,
.amp-handover button[type="submit"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 9px;
  height: 9px;
  background: var(--ha-bloom);
  clip-path: polygon(100% 0, 0 100%, 0 0);
}

.amp-handover .amp-secondary {
  background: color-mix(in srgb, var(--ha-ink) 16%, var(--ha-paper));
  color: var(--ha-ink);
  clip-path: none;
}

.amp-handover .amp-secondary::after {
  content: none;
}

/* A note on its way: the button says so and takes no second tap. */
.amp-handover button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.amp-handover {
  min-height: 0;
  overflow: auto;
  margin: 4px 14px 12px;
  padding: 13px;
  border: 1px solid rgba(var(--ha-ink-rgb), 0.12);
  border-radius: 14px;
  background: rgba(250, 250, 249, 0.62);
}

.amp-handover h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.amp-field {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}

.amp-field label,
.amp-field p {
  color: var(--ha-ink-soft);
  font-size: 11px;
  font-weight: 600;
}

.amp-field input,
.amp-field select,
.amp-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(var(--ha-ink-rgb), 0.2);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--ha-ink);
  font: inherit;
  font-size: 13px;
}

.amp-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.amp-choice {
  font: inherit;
  font-size: 0.8rem;
  border: 1px solid var(--ha-hairline);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ha-ink);
  padding: 6px 8px;
  cursor: pointer;
}

.amp-choice.is-selected {
  border-color: var(--ha-bloom-deep);
  background: color-mix(in srgb, var(--ha-bloom) 18%, var(--ha-white));
}

.amp-error {
  margin: 5px 14px 12px;
  padding: 10px 12px;
  border: 1px solid rgba(var(--ha-ink-rgb), 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ha-ink-soft);
  font-size: 11px;
  line-height: 1.45;
}

.amp-status {
  font-size: 0.8rem;
  color: var(--ha-ink-soft);
}

@keyframes amp-chrome-glint {
  0%, 72%, 100% { opacity: 0; background-position: 160% 0; }
  75% { opacity: 0.75; }
  82% { opacity: 0; background-position: -60% 0; }
}

@media (max-width: 760px) {
  .amp-launcher {
    width: 76px;
    height: 76px;
    right: 14px;
    bottom: 14px;
  }
  .amp-panel {
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .amp-character {
    top: max(4px, env(safe-area-inset-top));
    left: 12px;
    width: 68px;
    height: 68px;
  }
  .amp-header {
    min-height: calc(64px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-left: 92px;
  }
  .amp-composer {
    border-radius: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

/* Touch: every composer control at least 44px. */
@media (pointer: coarse) {
  .amp-attach,
  .amp-talk,
  .amp-send,
  .amp-composer input[name="message"] {
    min-height: 44px;
    height: 44px;
  }
  .amp-attach,
  .amp-send {
    width: 44px;
  }
  .amp-dictate {
    width: 40px;
    height: 40px;
  }
  /* 16px stops iOS zooming the page when the field takes focus. */
  .amp-composer input[name="message"] {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .amp-launcher::after,
  .amp-character::after,
  .amp-launcher,
  .amp-panel,
  .amp-bubble,
  .amp-live-dot {
    animation: none;
    transition: none;
  }
}

/* What Amp has picked up about the visitor so far. Sits above the composer so
   they can see it while they talk, and read as a note rather than a form. */
.amp-details {
  margin: 0 14px 8px;
  padding: 8px 10px;
  border: 1px solid rgba(var(--ha-ink-rgb), 0.12);
  border-radius: 12px;
  background: rgba(250, 250, 249, 0.72);
  color: var(--ha-ink);
  font-size: 11px;
  line-height: 1.35;
}

.amp-details[hidden] {
  display: none;
}

.amp-details-title {
  margin: 0 0 4px;
  font-weight: 600;
  opacity: 0.7;
}

.amp-details dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  margin: 0;
}

.amp-details dt {
  opacity: 0.6;
}

.amp-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Read by screen readers, never seen: announces that a streamed reply was stopped. */
.amp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
