/* Aria, the AI assistant (inc/aria.php, assets/js/components/aria.js): a launcher in the bottom
   right corner on every page and a conversation panel (a full-screen sheet on phones). */
.pe-aria {
  --aria-bg: rgba(22, 27, 33, 0.94);
  --aria-line: var(--wp--preset--color--color-line, #2A313B);
  --aria-text: var(--wp--preset--color--color-text-primary, #F2F4F7);
  --aria-muted: var(--wp--preset--color--color-text-secondary, #A3ABB8);
  --aria-accent: var(--wp--preset--color--color-accent, #3070A8);
  --aria-glow: var(--wp--preset--color--color-highlight, #1AB3F5);
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 9990;
  color: var(--aria-text);
  font-family: var(--wp--preset--font-family--geist, system-ui, sans-serif);
  font-size: 15px;
  line-height: 1.45;
}
.pe-aria [hidden] { display: none !important; }
.pe-aria * { box-sizing: border-box; text-shadow: none; }
.pe-aria .screen-reader-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- launcher ---------- */
.pe-aria__launcher {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 18px 6px 6px; margin: 0;
  background: var(--aria-bg); color: var(--aria-text);
  border: 1px solid var(--aria-line); border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  cursor: pointer; font: inherit; text-align: left;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.pe-aria__launcher:hover { border-color: var(--wp--preset--color--color-accent-muted, #5A9FCB); transform: translateY(-1px); }
.pe-aria__launcher:focus-visible, .pe-aria button:focus-visible, .pe-aria input:focus-visible { outline: 2px solid var(--aria-glow); outline-offset: 2px; }
.pe-aria__face {
  position: relative; flex: none; width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  background: #121821; box-shadow: 0 0 0 2px rgba(26, 179, 245, 0.55);
}
.pe-aria__face video { width: 100%; height: 100%; object-fit: cover; transform: scale(1.75); transform-origin: 50% 38%; display: block; }
.pe-aria__face::after {
  content: ""; position: absolute; right: 3px; bottom: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: #34D399; border: 2px solid #161B21;
}
.pe-aria__launcher-text { display: flex; flex-direction: column; }
.pe-aria__launcher-text strong { font-size: 15px; font-weight: 600; }
.pe-aria__launcher-text span { font-size: 12px; color: var(--aria-muted); }
.pe-aria.is-open .pe-aria__launcher { display: none; }

.pe-aria__hello {
  position: absolute; right: 0; bottom: calc(100% + 12px); width: 250px;
  padding: 12px 34px 12px 14px; background: var(--aria-bg); border: 1px solid var(--aria-line);
  border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: pe-aria-rise 0.35s ease both;
}
.pe-aria__hello p { margin: 0; font-size: 14px; }
.pe-aria__hello-close {
  position: absolute; top: 4px; right: 6px; width: 26px; height: 26px; padding: 0;
  background: none; border: 0; color: var(--aria-muted); font-size: 20px; line-height: 1; cursor: pointer;
}
@keyframes pe-aria-rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- panel ---------- */
.pe-aria__panel {
  display: flex; flex-direction: column;
  width: min(400px, calc(100vw - 32px));
  max-height: min(720px, calc(100dvh - 32px));
  background: var(--aria-bg); border: 1px solid var(--aria-line); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); overflow: hidden;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: pe-aria-rise 0.3s ease both;
}
.pe-aria__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 10px 16px; }
.pe-aria__title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.2; color: var(--aria-text); letter-spacing: 0; }
.pe-aria__label {
  display: inline-block; margin: 4px 0 0; padding: 2px 8px; border: 1px solid rgba(26, 179, 245, 0.45); border-radius: 999px;
  font-family: var(--wp--preset--font-family--geist-mono, ui-monospace, monospace); font-size: 11px; letter-spacing: 0.02em; color: #9BD8F5;
}
.pe-aria__close {
  width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1px solid var(--aria-line);
  background: transparent; color: var(--aria-text); font-size: 22px; line-height: 1; cursor: pointer;
}
.pe-aria__close:hover { border-color: var(--aria-muted); }

.pe-aria__stage { position: relative; aspect-ratio: 3 / 2; background: #0D1219; flex: none; }
.pe-aria__stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; }
.pe-aria__live { opacity: 0; transition: opacity 0.4s ease; }
.pe-aria[data-state="live"] .pe-aria__live { opacity: 1; }
.pe-aria__status:empty, .pe-aria__timer:empty { display: none; }
.pe-aria__status {
  position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0; padding: 8px 12px;
  background: rgba(10, 14, 19, 0.82); border-radius: 10px; font-size: 13px; color: var(--aria-text); text-align: center;
}
.pe-aria[data-state="connecting"] .pe-aria__status::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%;
  border: 2px solid var(--aria-glow); border-right-color: transparent; vertical-align: -1px; animation: pe-aria-spin 0.8s linear infinite;
}
@keyframes pe-aria-spin { to { transform: rotate(360deg); } }
.pe-aria__timer {
  position: absolute; top: 10px; right: 10px; padding: 2px 8px; border-radius: 999px; background: rgba(10, 14, 19, 0.7);
  font-family: var(--wp--preset--font-family--geist-mono, ui-monospace, monospace); font-size: 12px; color: var(--aria-muted);
}

.pe-aria__log { flex: 1 1 auto; min-height: 0; max-height: 220px; margin: 0; padding: 10px 14px 4px; overflow-y: auto; list-style: none; }
.pe-aria__log:empty { display: none; }
.pe-aria__log li { margin: 0 0 8px; max-width: 88%; }
.pe-aria__log li.is-you { margin-left: auto; text-align: right; }
.pe-aria__who { display: block; font-size: 11px; color: var(--aria-muted); margin-bottom: 2px; }
.pe-aria__log p { display: inline-block; margin: 0; padding: 7px 11px; border-radius: 12px; font-size: 14px; text-align: left; background: #222933; }
.pe-aria__log .is-you p { background: var(--aria-accent); color: #fff; }

.pe-aria__start { padding: 14px 16px 16px; }
.pe-aria__start > p:first-child { margin: 0 0 12px; font-size: 14px; color: var(--aria-muted); }
.pe-aria__go {
  display: block; width: 100%; padding: 12px 16px; border: 0; border-radius: 10px;
  background: var(--aria-accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.pe-aria__go:hover { background: #3A82C2; }
.pe-aria__note { margin: 10px 0 0; font-size: 12px; color: var(--aria-muted); }
.pe-aria__note a { color: #9BD8F5; text-decoration: underline; }

.pe-aria__controls { display: flex; align-items: center; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--aria-line); }
.pe-aria__say { flex: 1 1 auto; min-width: 0; margin: 0; }
.pe-aria__say input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--aria-line); border-radius: 10px;
  background: #11161D; color: var(--aria-text); font: inherit; font-size: 14px;
}
.pe-aria__say input::placeholder { color: #7D8794; }
.pe-aria__mic, .pe-aria__send, .pe-aria__end { flex: none; height: 40px; border-radius: 10px; font: inherit; font-size: 14px; cursor: pointer; }
.pe-aria__mic { position: relative; width: 40px; padding: 0; border: 1px solid var(--aria-line); background: #11161D; }
.pe-aria__mic span {
  position: absolute; left: 50%; top: 50%; width: 12px; height: 18px; margin: -11px 0 0 -6px;
  border: 2px solid var(--aria-glow); border-radius: 6px;
}
.pe-aria__mic span::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 2px; height: 5px; margin-left: -1px; background: var(--aria-glow); }
.pe-aria.is-muted .pe-aria__mic span { border-color: var(--aria-muted); }
.pe-aria.is-muted .pe-aria__mic span::after { background: var(--aria-muted); }
.pe-aria.is-muted .pe-aria__mic::after {
  content: ""; position: absolute; left: 9px; right: 9px; top: 50%; height: 2px; background: #F87171; transform: rotate(-45deg);
}
.pe-aria__send { padding: 0 14px; border: 0; background: var(--aria-accent); color: #fff; font-weight: 600; }
.pe-aria__end { padding: 0 12px; border: 1px solid var(--aria-line); background: transparent; color: var(--aria-text); }
.pe-aria__end:hover { border-color: #F87171; color: #FCA5A5; }

/* ---------- phones: the panel becomes a full-screen sheet ---------- */
@media (max-width: 600px) {
  .pe-aria__launcher { padding: 5px; }
  .pe-aria__launcher-text { display: none; }
  .pe-aria__face { width: 58px; height: 58px; }
  .pe-aria__hello { width: min(250px, calc(100vw - 32px)); }
  .pe-aria.is-open { inset: 0; }
  .pe-aria.is-open .pe-aria__panel { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; }
  .pe-aria__stage { aspect-ratio: 4 / 5; flex: 0 1 auto; min-height: 220px; max-height: 58dvh; }
  .pe-aria__log { max-height: none; }
  .pe-aria__head { padding-top: max(12px, env(safe-area-inset-top)); }
  .pe-aria__controls { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .pe-aria__panel, .pe-aria__hello { animation: none; }
  .pe-aria__launcher { transition: none; }
}
