/* MAG Assistant across the site (assets/js/agent-demo.js): the agent, the "Ask MAG"
   window and its launcher, and the home page's ask-your-factory section. */

/* ---- The agent: MAG's mark with eyes (apps/admin-app/src/index.css) ---- */
.mag-agent { flex: none; overflow: visible; }
.mag-agent .mag-agent-arms,
.mag-agent .mag-agent-blink { transform-box: view-box; transform-origin: 50px 50px; }
.mag-agent .mag-agent-arms { animation: mag-agent-breathe 6s ease-in-out infinite; animation-delay: var(--mag-delay, 0s); }
.mag-agent .mag-agent-look { transform: translate(var(--mag-look-x, 0px), var(--mag-look-y, 0px)); transition: transform 0.25s ease-out; }
.mag-agent .mag-agent-glance { animation: mag-agent-glance 9s ease-in-out infinite; animation-delay: var(--mag-delay, 0s); }
.mag-agent .mag-agent-blink { animation: mag-agent-blink 5s infinite; animation-delay: var(--mag-delay, 0s); }
.mag-agent[data-track] .mag-agent-glance { animation: none; }
.mag-agent[data-state="thinking"] .mag-agent-arms { animation: mag-agent-spin 1.4s cubic-bezier(0.65, 0, 0.35, 1) infinite; }
.mag-agent[data-state="thinking"] .mag-agent-look { transform: translate(1.5px, -2.5px); }
.mag-agent[data-state="thinking"] .mag-agent-glance { animation: none; }
@media (hover: hover) and (pointer: fine) {
  .ag-launcher:hover .mag-agent[data-state="idle"] .mag-agent-arms,
  .mn-feature:hover .mag-agent[data-state="idle"] .mag-agent-arms { animation: mag-agent-twirl 0.7s cubic-bezier(0.34, 1.3, 0.64, 1); }
}
@keyframes mag-agent-breathe { 0%, 100% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(4deg) scale(1.03); } }
@keyframes mag-agent-spin { from { transform: rotate(0deg); } to { transform: rotate(180deg); } }
@keyframes mag-agent-twirl { from { transform: rotate(0deg); } to { transform: rotate(180deg); } }
@keyframes mag-agent-blink { 0%, 90%, 100% { transform: scaleY(1); } 93% { transform: scaleY(0.1); } }
@keyframes mag-agent-glance {
  0%, 30%, 100% { transform: translate(0, 0); }
  36%, 50% { transform: translate(-2.5px, 0.5px); }
  56%, 70% { transform: translate(2.5px, 0.5px); }
  76% { transform: translate(0, 0); }
}

/* ---- Shared by every conversation ---- */
.ag-window, .ag-panel, .ag-stage {
  --ag-ink: #0b0b0c;
  --ag-text: #33445a;
  --ag-muted: #5b6b7e;
  --ag-line: #e6ebf0;
  font-family: var(--mag-sans);
}
.ag-you { align-self: flex-end; max-width: 85%; margin: 0; padding: 8px 14px; border-radius: 16px 16px 4px 16px; background: var(--ag-ink); color: #fff; font-size: 13.5px; line-height: 1.4; }
.ag-turn { display: flex; align-items: flex-start; gap: 10px; align-self: stretch; }
.ag-turn-agent { width: 22px; height: 22px; margin-top: 1px; }
.ag-reading { margin: 2px 0 0; font-size: 13px; color: var(--ag-muted); }
.ag-reading::after { content: "…"; }
.ag-answer-body { min-width: 0; animation: ag-in 240ms cubic-bezier(0.23, 1, 0.32, 1); }
@keyframes ag-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.ag-answer-body p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ag-ink); }
.ag-answer-body small { display: block; margin-top: 6px; font-size: 11.5px; color: var(--ag-muted); }
.ag-report { padding: 11px 13px; border: 1px solid var(--ag-line); border-radius: 12px; min-width: 260px; background: #fff; }
.ag-report strong { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 700; color: var(--ag-ink); }
.ag-report-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 8px; padding: 6px 0; border-top: 1px solid #f0f3f6; font-size: 12px; color: var(--ag-text); }
.ag-report-row span:last-child { color: var(--ag-muted); text-align: right; }
.ag-report-files { display: flex; gap: 6px; margin-top: 7px; }
.ag-report-files span { padding: 2px 8px; border: 1px solid var(--ag-line); border-radius: 100px; font-size: 11px; font-weight: 600; color: var(--ag-text); }

/* ---- The compact window (launcher panel, Products page) ---- */
.ag-window, .ag-panel {
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--ag-line); border-radius: 18px;
  text-align: left; overflow: hidden;
}
.ag-window { box-shadow: 0 1px 2px rgba(11, 29, 51, 0.04), 0 24px 56px -30px rgba(11, 29, 51, 0.32); }
.ag-head { display: flex; align-items: center; gap: 9px; padding: 12px 14px 12px 16px; border-bottom: 1px solid var(--ag-line); }
.ag-head-agent { width: 22px; height: 22px; }
.ag-head strong { font-size: 14px; font-weight: 700; color: var(--ag-ink); }
.ag-sample { margin-left: auto; font-size: 11.5px; color: var(--ag-muted); }
.ag-thread { display: flex; flex-direction: column; gap: 12px; height: 270px; padding: 16px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.ag-hello { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.ag-hello-agent { width: 44px; height: 44px; }
.ag-hello p { margin: 0; max-width: 24ch; font-size: 14px; line-height: 1.5; color: var(--ag-muted); }
.ag-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 14px; border-top: 1px solid var(--ag-line); }
.ag-chip { padding: 6px 11px; border: 1px solid #d3dbe3; border-radius: 100px; background: #fff; font-size: 12.5px; font-weight: 500; color: var(--ag-ink); transition: background-color 120ms ease, border-color 120ms ease, transform 120ms cubic-bezier(0.23, 1, 0.32, 1); }
.ag-chip:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .ag-chip:hover { background: #f3f5f8; border-color: #b4c1cf; } }

/* ---- The launcher and its window: bottom right on every page ---- */
.ag-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 45;
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px 0 11px;
  border-radius: 100px; background: #0b0b0c; color: #fff; font-family: var(--mag-sans); font-size: 13px; font-weight: 700;
  box-shadow: 0 10px 28px -10px rgba(11, 11, 12, 0.55);
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), bottom 200ms ease;
}
.ag-launcher-agent { width: 24px; height: 24px; }
.ag-launcher:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .ag-launcher:hover { transform: translateY(-2px); } }
.ag-panel {
  position: fixed; right: 20px; bottom: 74px; z-index: 45; width: min(390px, calc(100vw - 24px));
  box-shadow: 0 2px 6px rgba(11, 29, 51, 0.06), 0 28px 64px -24px rgba(11, 29, 51, 0.42);
  opacity: 0; visibility: hidden; transform: translateY(8px) scale(0.98); transform-origin: bottom right;
  transition: opacity 160ms ease, transform 180ms cubic-bezier(0.23, 1, 0.32, 1), visibility 180ms;
}
/* Visible at once on opening, so focus can move into it. */
.ag-panel.is-open { opacity: 1; visibility: visible; transform: none; transition: opacity 160ms ease, transform 180ms cubic-bezier(0.23, 1, 0.32, 1), visibility 0s; }
.ag-close { width: 26px; height: 26px; margin-left: 4px; border-radius: 50%; font-size: 19px; line-height: 1; color: var(--ag-muted); }
@media (hover: hover) and (pointer: fine) { .ag-close:hover { background: #f0f3f6; color: var(--ag-ink); } }
/* Clear of the model's view buttons where the two would touch. */
@media (min-width: 901px) and (max-width: 1280px) {
  .fx-on-products .ag-launcher { bottom: 78px; }
  .fx-on-products .ag-panel { bottom: 132px; }
}
@media (max-width: 480px) {
  .ag-launcher { right: 12px; bottom: 12px; }
  .ag-panel { right: 12px; bottom: 64px; }
  .ag-panel .ag-thread { height: 230px; }
}

/* ---- Home: ask your factory ---- */
#home .ag-home { background: #fff; padding: 112px 24px 104px; }
.ag-stage { max-width: 680px; margin: 0 auto; text-align: center; }
.ag-stage .section-label { margin: 0 auto 30px; }
.ag-hero { display: grid; place-items: center; width: 92px; height: 92px; margin: 0 auto 26px; border-radius: 28px; background: #f6f8fa; box-shadow: inset 0 0 0 1px #edf1f5; }
.ag-hero .mag-agent { width: 60px; height: 60px; }
#home .ag-stage .section-headline { margin: 0 auto 14px; font-size: clamp(40px, 5vw, 64px); }
#home .ag-stage .section-body { margin: 0 auto; max-width: 52ch; font-size: 17px; }

.ag-convo { display: flex; flex-direction: column; gap: 14px; max-width: 600px; margin: 0 auto; text-align: left; overflow: hidden; }
.ag-convo.has-turn { margin-top: 40px; }

.ag-prompt {
  display: flex; align-items: center; gap: 8px; max-width: 600px; margin: 36px auto 0; padding: 7px 7px 7px 22px;
  background: #fff; border: 1px solid #e3e8ee; border-radius: 999px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.07);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.ag-convo.has-turn + .ag-prompt { margin-top: 24px; }
.ag-prompt:focus-within { border-color: #b9c8d6; box-shadow: 0 8px 30px rgba(15, 23, 42, 0.07), 0 0 0 4px rgba(49, 161, 247, 0.12); }
.ag-prompt input { flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--ag-ink); }
.ag-prompt input::placeholder { color: #94a1b0; }
.ag-send { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--ag-ink); color: #fff; transition: background-color 150ms ease, transform 120ms cubic-bezier(0.23, 1, 0.32, 1); }
.ag-send:disabled { background: #eef1f5; color: #a3afbd; }
.ag-send:not(:disabled):active { transform: scale(0.94); }
.ag-send:focus-visible, .ag-suggestion:focus-visible { outline: 2px solid #1f4e8c; outline-offset: 2px; }

.ag-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 600px; margin: 18px auto 0; }
.ag-suggestion { padding: 7px 13px; border-radius: 100px; background: #f3f5f8; font-size: 13px; font-weight: 500; color: var(--ag-text); transition: background-color 120ms ease, color 120ms ease, transform 120ms cubic-bezier(0.23, 1, 0.32, 1); }
.ag-suggestion:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .ag-suggestion:hover { background: #e8ecf1; color: var(--ag-ink); } }

/* Four facts in one even row under a hairline, wider than the column above them. */
.ag-facts {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(880px, calc(100vw - 48px)); margin: 64px 0 0; position: relative; left: 50%; transform: translateX(-50%);
  padding: 28px 0 0; list-style: none; border-top: 1px solid var(--ag-line);
}
.ag-facts li { padding: 0 20px; font-size: 13px; line-height: 1.5; color: var(--ag-muted); }
.ag-facts li + li { border-left: 1px solid var(--ag-line); }
.ag-facts strong { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--ag-ink); }
.ag-note { margin: 28px 0 0; font-size: 12px; color: #94a1b0; }

@media (max-width: 700px) {
  #home .ag-home { padding: 80px 20px 72px; }
  .ag-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 24px; margin-top: 48px; }
  .ag-facts li { padding: 0 14px; }
  .ag-facts li:nth-child(3) { border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mag-agent *, .mag-agent .mag-agent-look { animation: none !important; transition: none !important; }
  .ag-answer-body { animation: none; }
  .ag-panel, .ag-launcher, .ag-prompt { transition-duration: 0ms; }
}
