/* ==========================================================================
   AI Search — popup, prompt, suggestions, answer card, search page.
   Uses the colour tokens from app.css (light + dark theme).
   ========================================================================== */
.ai-fab { gap: 8px; }
.ai-fab .icon { animation: ai-spark 2.4s ease-in-out infinite; }
@keyframes ai-spark { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(1.18) rotate(12deg); opacity: .85; } }
html.ai-lock { overflow: hidden; }

/* Prompt box (glowing gradient border) */
.ai-prompt {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 7px 7px 18px; border-radius: 999px;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(110deg, #ff344f, #ff8a3d 40%, #b44dff 80%) border-box;
  border: 2px solid transparent; box-shadow: 0 10px 34px rgba(255, 52, 79, .18);
}
.ai-prompt:focus-within { box-shadow: 0 10px 40px rgba(255, 52, 79, .32); }
.ai-prompt__icon { display: grid; place-items: center; flex: none; color: var(--red); }
.ai-prompt input { flex: 1; min-width: 0; height: 48px; border: 0; background: transparent; color: var(--ink); font-size: 17px; outline: none; }
.ai-prompt input::placeholder { color: var(--muted); }
.ai-prompt input::-webkit-search-cancel-button { display: none; }
.ai-prompt__btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 48px; padding: 0 22px; border: 0; border-radius: 999px;
  background: linear-gradient(110deg, #ff344f, #ff5a3d); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}
.ai-prompt__btn:hover { filter: brightness(1.05); }

/* Live suggestions */
.ai-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 30; max-height: 340px; overflow-y: auto; margin: 0; padding: 6px;
  list-style: none; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow);
}
.ai-suggest[hidden] { display: none; }
.ai-suggest__opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--ink); font-size: 15px; }
.ai-suggest__opt.is-active, .ai-suggest__opt:hover { background: var(--bg-soft); }
.ai-suggest__opt--business .ai-suggest__label { font-weight: 700; }
.ai-suggest__hint { flex: none; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); font-size: 12px; }
.ai-suggest__opt--location .ai-suggest__hint { background: #e8f6ee; color: #16794a; }
.ai-suggest__opt--business .ai-suggest__hint { background: #ffe8ec; color: var(--red); }

/* Example questions */
.ai-examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.ai-examples a {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 999px;
  background: rgba(255, 255, 255, .06); color: #fff; font-size: 14px; transition: background-color .2s, border-color .2s;
}
.ai-examples a:hover { border-color: var(--red); background: rgba(255, 52, 79, .2); color: #fff; }
.ai-examples--light { justify-content: center; }
.ai-examples--light a { border-color: var(--line); background: var(--surface); color: var(--ink); }
.ai-examples--light a:hover { border-color: var(--red); background: #fff0f2; color: var(--red); }
.ai-examples .icon { color: var(--red); }

/* Answer card */
.ai-answer {
  margin-bottom: 26px; padding: 22px 24px; border-radius: var(--radius);
  background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(120deg, rgba(255, 52, 79, .55), rgba(180, 77, 255, .45)) border-box;
  border: 1px solid transparent; box-shadow: var(--shadow-sm);
}
.ai-answer__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--red); }
.ai-answer__badge { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #ff344f, #b44dff); color: #fff; }
.ai-answer__text { color: var(--ink); font-size: 17px; line-height: 1.7; }
.ai-answer__text.is-typing::after { content: "▍"; margin-left: 2px; color: var(--red); animation: ai-blink .8s steps(1) infinite; }
@keyframes ai-blink { 50% { opacity: 0; } }
.ai-answer__fix { margin-top: 10px; color: var(--muted); font-size: 14px; }
.ai-answer__fix strong { color: var(--ink); }
.ai-chips, .ai-follow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.ai-chips__label { margin-right: 2px; color: var(--muted); font-size: 13px; font-weight: 700; }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 999px; background: #fff0f2; color: var(--red); font-size: 14px; font-weight: 600; }
.ai-chip--location { background: #e8f6ee; color: #16794a; }
.ai-chip--keyword { background: var(--bg-soft); color: var(--ink); }
.ai-chip--open { background: #fff6dc; color: #9a6b00; }
.ai-chip a { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: inherit; font-size: 16px; line-height: 1; opacity: .7; }
.ai-chip a:hover { background: rgba(0, 0, 0, .08); opacity: 1; }
.ai-follow__chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 14px; transition: border-color .2s, color .2s; }
.ai-follow__chip:hover { border-color: var(--red); color: var(--red); }
.ai-follow__chip--guide { border-style: dashed; }
.ai-follow--start { margin-top: 10px; }

/* Search page */
.ai-hero { position: relative; overflow: hidden; padding-block: 100px 48px; /* the sticky header overlaps 50px on desktop */ background: radial-gradient(900px 300px at 15% 0%, rgba(255, 52, 79, .35), transparent 70%), radial-gradient(700px 300px at 90% 100%, rgba(180, 77, 255, .28), transparent 70%), #141518; color: #fff; }
.ai-hero__inner { max-width: 860px; }
@media (max-width: 991px) { .ai-hero { padding-top: 48px; } }
.ai-hero__eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, .08); font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.ai-hero__eyebrow .icon { color: #ff6b7f; }
.ai-hero__title { margin-bottom: 22px; font-size: clamp(26px, 4vw, 40px); font-weight: 800; line-height: 1.2; }
.ai-subs { margin: 0; padding: 0; list-style: none; max-height: 300px; overflow-y: auto; }
.ai-open { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-weight: 700; }
.ai-start { padding: 28px; border: 1px dashed var(--line); border-radius: var(--radius); }
.ai-start__title { margin: 0 0 12px; font-size: 20px; font-weight: 800; color: var(--ink); }
.ai-start__steps { display: grid; gap: 10px; margin: 0 0 26px; padding-left: 20px; color: var(--text); line-height: 1.6; }
.ai-start__steps strong { color: var(--ink); }

/* Popup */
.ai-dialog { width: min(760px, calc(100vw - 24px)); max-width: none; max-height: min(86vh, 860px); margin: 6vh auto auto; padding: 0; border: 0; border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); overflow: hidden; }
.ai-dialog::backdrop { background: rgba(10, 10, 14, .62); backdrop-filter: blur(3px); }
.ai-dialog[open] { animation: ai-pop .22s ease-out; }
@keyframes ai-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.ai-dialog__box { display: flex; flex-direction: column; max-height: min(86vh, 860px); }
.ai-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px 22px; }
.ai-dialog__title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; color: var(--ink); font-size: 18px; font-weight: 800; }
.ai-dialog__title small { color: var(--muted); font-size: 13px; font-weight: 500; }
.ai-dialog__close { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--bg-soft); color: var(--ink); cursor: pointer; }
.ai-dialog__close:hover { background: #ffe8ec; color: var(--red); }
.ai-dialog__prompt { position: relative; z-index: 2; padding: 4px 22px 16px; border-bottom: 1px solid var(--line); }
.ai-dialog__body { flex: 1; min-height: 160px; overflow-y: auto; padding: 18px 22px 22px; overscroll-behavior: contain; }
.ai-dialog .ai-answer { margin-bottom: 16px; padding: 16px 18px; }
.ai-dialog .ai-answer__text { font-size: 16px; }
.ai-start-pop { padding: 10px 0; text-align: center; }
.ai-start-pop .ai-examples { margin-top: 10px; }
.ai-thinking { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 0; color: var(--muted); font-weight: 600; }
.ai-thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: ai-dot 1s infinite ease-in-out; }
.ai-thinking i:nth-of-type(2) { animation-delay: .15s; }
.ai-thinking i:nth-of-type(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.ai-count { margin: 0 0 8px; color: var(--muted); font-size: 14px; font-weight: 600; }
.ai-hits { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.ai-hit { display: flex; align-items: center; gap: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; transition: border-color .2s, box-shadow .2s; }
.ai-hit:hover { border-color: rgba(255, 52, 79, .45); box-shadow: var(--shadow-sm); }
.ai-hit__img { flex: none; width: 72px; height: 72px; overflow: hidden; border-radius: 10px; background: var(--bg-soft); }
.ai-hit__img img, .ai-hit__img picture { display: block; width: 100%; height: 100%; object-fit: cover; }
.ai-hit__body { flex: 1; min-width: 0; }
.ai-hit__name { display: block; overflow: hidden; color: var(--ink); font-size: 16px; font-weight: 800; white-space: nowrap; text-overflow: ellipsis; }
.ai-hit__name:hover { color: var(--red); }
.ai-hit__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 2px; color: var(--muted); font-size: 13.5px; }
.ai-hit__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ai-hit__tags:empty { display: none; }
.ai-tag { padding: 2px 9px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); font-size: 12px; font-weight: 700; }
.ai-tag--red { background: #ffe8ec; color: var(--red); }
.ai-tag--blue { background: #e7f0ff; color: #2563eb; }
.ai-tag--green { background: #e8f6ee; color: #16794a; }
.ai-hit__acts { display: flex; align-items: center; gap: 8px; flex: none; }
.ai-hit__call { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #e8f6ee; color: #16794a; }
.ai-hit__call:hover { background: #16794a; color: #fff; }
.ai-hit__view { padding: 9px 16px; border-radius: 999px; background: var(--red); color: #fff; font-size: 14px; font-weight: 700; }
.ai-hit__view:hover { background: var(--red-dark); color: #fff; }
.ai-more-row { display: flex; justify-content: center; padding-top: 6px; }
.ai-more { padding: 10px 22px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 700; cursor: pointer; }
.ai-more:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.ai-empty { padding: 24px 0; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  .ai-prompt { padding-left: 12px; }
  .ai-prompt input { height: 44px; font-size: 16px; }
  .ai-prompt__btn { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .ai-prompt__btn span { display: none; }
  .ai-dialog { margin-top: 2vh; max-height: 94vh; border-radius: 18px; }
  .ai-dialog__box { max-height: 94vh; }
  .ai-dialog__head, .ai-dialog__prompt, .ai-dialog__body { padding-inline: 14px; }
  .ai-hit { align-items: flex-start; }
  .ai-hit__img { width: 58px; height: 58px; }
  .ai-hit__acts { flex-direction: column-reverse; }
  .ai-hit__view { padding: 7px 12px; font-size: 13px; }
  .ai-hero { padding-block: 40px 36px; }
}
