/* ==========================================================================
   AJ-Group — "Ask AI" chat (askai.js builds the markup).
   Uses the design tokens from main.css, so both themes and the /indexcyber/
   skin repaint it without extra rules beyond the small .cy block at the end.
   ========================================================================== */

/* ------------------------------------------------------------ open button */
/* Sits in the column above the back-to-top button, and above the cookie
   notice while that is showing (askai.js sets --askai-cookie-h to its height). */
.askai-fab {
  position: fixed; right: .75rem; z-index: 140;
  bottom: calc(4.4rem + env(safe-area-inset-bottom));
  display: grid; place-items: center;
  width: 3.25rem; height: 3.25rem; padding: 0;
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  border: 0; border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: filter .16s ease, transform .16s ease;
}
.askai-fab:hover { filter: brightness(1.1); transform: translateY(-2px); }
.askai-fab:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 3px; }
.askai-fab svg { width: 1.5rem; height: 1.5rem; }
.askai-fab[hidden] { display: none; }
@media (min-width: 48rem) {
  .askai-fab { right: 1.25rem; bottom: 5.25rem; width: 3.5rem; height: 3.5rem; }
}
body:has(.cookie:not([hidden])) .askai-fab {
  bottom: calc(max(7.5rem, var(--askai-cookie-h, 0px)) + 3.4rem + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------------ panel */
.askai {
  position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 160;
  display: flex; flex-direction: column;
  width: 380px; height: 560px;
  max-width: calc(100vw - 2rem); max-height: calc(100dvh - 3rem);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: askai-in .22s cubic-bezier(.2, .9, .3, 1.1);
}
.askai[hidden] { display: none; }
@keyframes askai-in { from { opacity: 0; transform: translateY(1rem); } }

@media (max-width: 599.98px) {
  .askai {
    inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
    height: 100dvh;
    border: 0; border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  html.askai-open, html.askai-open body { overflow: hidden; }
}

.askai__head {
  display: flex; align-items: center; gap: .4rem;
  padding: .65rem .65rem .65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.askai__title { flex: 1; font-size: 1rem; letter-spacing: -.01em; margin: 0; }

.askai__icon {
  display: inline-grid; place-items: center; flex: none;
  width: 2.4rem; height: 2.4rem; padding: 0;
  color: var(--ink-2); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.askai__icon:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface); }
.askai__icon svg { width: 1.15rem; height: 1.15rem; }
.askai__icon[aria-pressed="true"] { color: var(--brand); border-color: var(--brand); }

.askai__intro {
  margin: 0; padding: .6rem 1rem;
  font-size: .8rem; line-height: 1.45; color: var(--ink-2);
  background: color-mix(in srgb, var(--brand) 7%, var(--surface));
  border-bottom: 1px solid var(--line);
}

/* --------------------------------------------------------------- messages */
.askai__log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: .6rem;
  padding: 1rem;
}
.askai__msg {
  max-width: 88%;
  padding: .55rem .8rem;
  font-size: .93rem; line-height: 1.5;
  border-radius: var(--r);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.askai__msg--user {
  align-self: flex-end;
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  border-bottom-right-radius: .25rem;
}
.askai__msg--ai {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: .25rem;
}
.askai__msg--sys {
  align-self: stretch; max-width: none;
  font-size: .86rem; color: var(--ink-2);
  background: transparent;
  border: 1px dashed var(--line-2);
}
.askai__msg a { color: var(--brand); }
.askai__text { margin: 0; }

.askai__play {
  display: inline-flex; align-items: center; gap: .35rem;
  margin-top: .4rem; padding: .2rem .6rem .2rem .45rem;
  font-size: .78rem; font-weight: 600; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px;
  cursor: pointer; white-space: nowrap;
}
.askai__play:hover { color: var(--ink); border-color: var(--brand); }
.askai__play svg { width: .9rem; height: .9rem; }
.askai__play[hidden] { display: none; }

/* typing indicator */
.askai__dots { display: inline-flex; gap: .3rem; padding: .3rem 0; }
.askai__dots i {
  width: .45rem; height: .45rem; border-radius: 50%;
  background: var(--ink-3);
  animation: askai-dot 1.1s ease-in-out infinite;
}
.askai__dots i:nth-child(2) { animation-delay: .15s; }
.askai__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes askai-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* ------------------------------------------------------------------ input */
.askai__status {
  margin: 0; padding: 0 1rem .35rem;
  font-size: .82rem; font-weight: 600; color: var(--brand);
}
.askai__status:empty { display: none; }

.askai__form {
  display: flex; align-items: flex-end; gap: .45rem;
  padding: .65rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.askai__field {
  flex: 1; min-width: 0;
  min-height: 2.6rem; max-height: 8rem;
  padding: .55rem .8rem;
  font-size: 1rem; line-height: 1.4;   /* 16px: iOS does not zoom the page on focus */
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line-2); border-radius: var(--r);
  resize: none;
}
.askai__field::placeholder { color: var(--ink-3); }
.askai__field:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 1px; }

.askai__send {
  display: inline-grid; place-items: center; flex: none;
  width: 2.6rem; height: 2.6rem; padding: 0;
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  border: 0; border-radius: 999px; cursor: pointer;
}
.askai__send svg { width: 1.15rem; height: 1.15rem; }
.askai__send:disabled { opacity: .45; cursor: not-allowed; }
.askai__form .askai__icon { width: 2.6rem; height: 2.6rem; }
.askai__icon:disabled { opacity: .45; cursor: not-allowed; }

/* recording: the mic button pulses */
.askai__mic.is-rec {
  color: var(--on-brand); background: var(--err); border-color: var(--err);
  animation: askai-pulse 1.2s ease-out infinite;
}
@keyframes askai-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--err) 55%, transparent); }
  100% { box-shadow: 0 0 0 .7rem transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .askai, .askai__dots i, .askai__mic.is-rec { animation: none; }
  .askai-fab, .askai-fab:hover { transition: none; transform: none; }
}

/* ------------------------------------------------- cyberpunk skin (/indexcyber/) */
.cy .askai-fab {
  border-radius: var(--r);
  background: linear-gradient(135deg, var(--cy-red-hot), var(--cy-red-deep));
  color: #fff;
  box-shadow: 0 0 18px -2px rgba(255, 42, 77, .75);
}
.cy .askai { border-color: rgba(255, 42, 77, .4); box-shadow: 0 0 40px -12px rgba(255, 42, 77, .5), var(--shadow-lg); }
.cy .askai .askai__title { font-size: 1.05rem; letter-spacing: .02em; text-shadow: var(--cy-glow-sm); }
.cy .askai__msg--user, .cy .askai__send { background: linear-gradient(135deg, var(--cy-red-hot), var(--cy-red-deep)); color: #fff; }
.cy .askai__msg a { color: var(--cy-cyan); }
.cy .askai__icon[aria-pressed="true"] { color: var(--cy-cyan); border-color: var(--cy-cyan); }
