/* ==========================================================================
   Grace Villa — Aleena, the chat concierge

   PlugNest's Aleena widget, same structure, sizes and motion, recoloured
   from PlugNest's purple and pink to this site's black and gold.

   Stacking: above the navigation (60), below the popups (100) and the
   entrance film (200), so Aleena never sits on top of either.
   ========================================================================== */

.al-launcher,
.al-win {
  --al-gold:    #C6A15B;
  --al-gold-hi: #F6E7C4;
  --al-gold-lt: #E9D2A0;
  --al-gold-dk: #8A6E35;
  --al-ink:     #06060A;
}

/* ---------------------------------------------------------------- launcher */

.al-launcher {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 80;
  width: 62px;
  height: 62px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--al-gold-dk), var(--al-gold-hi), var(--al-gold), var(--al-gold-dk)) 0 0 / 280% 280%;
  border: 2px solid rgba(246, 231, 196, .35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  animation: alPulse 2.6s ease-out infinite, alBob 4s ease-in-out infinite, alSpin 6s linear infinite;
  transition: transform .25s;
}
.al-launcher:hover { transform: scale(1.1) rotate(-6deg); }
.al-launcher:focus-visible { outline: 2px solid var(--al-gold-hi); outline-offset: 4px; }

.al-face {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  object-fit: cover;
  border-radius: 50%;
  z-index: 0;
}
.al-close-ov {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(6, 6, 10, .6);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 2;
}
.al-launcher.open .al-close-ov { display: flex; }
.al-launcher.open .al-spark { display: none; }

.al-spark {
  position: absolute;
  font-size: 11px;
  color: var(--al-gold-hi);
  pointer-events: none;
  z-index: 3;
  animation: alSpark 2.2s ease-in-out infinite;
}
.al-spark.s1 { top: 6px; left: 8px; }
.al-spark.s2 { bottom: 8px; right: 6px; animation-delay: 1.1s; font-size: 9px; }

/* ---------------------------------------------------------------- window */

.al-win {
  position: fixed;
  bottom: 94px;
  right: 22px;
  z-index: 80;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 130px);
  display: none;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(198, 161, 91, .28);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .65);
  font-family: var(--sans);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .25s, transform .25s;
}
.al-win.open { display: flex; }
.al-win.vis  { opacity: 1; transform: translateY(0); }

.al-head {
  background: linear-gradient(120deg, var(--al-gold-dk), var(--al-gold), var(--al-gold-lt), var(--al-gold)) 0 0 / 250% 250%;
  animation: alGrad 7s linear infinite;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  color: var(--al-ink);
}
.al-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(6, 6, 10, .35);
  flex-shrink: 0;
}
.al-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
/* the green "online" dot */
.al-avatar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10B981;
  border: 2px solid var(--al-gold-hi);
}
.al-id { flex: 1; min-width: 0; }
.al-name   { font-size: 15px; font-weight: 500; letter-spacing: .02em; }
.al-status { font-size: 10.5px; font-weight: 400; color: rgba(6, 6, 10, .72); }

.al-hbtn,
.al-x {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  color: var(--al-ink);
  transition: background .2s;
}
.al-hbtn { background: rgba(6, 6, 10, .1); border: 1px solid rgba(6, 6, 10, .22); }
.al-hbtn:hover { background: rgba(6, 6, 10, .2); }
.al-x { background: none; border: 0; }
.al-x:hover { background: rgba(6, 6, 10, .12); }

/* ---------------------------------------------------------------- messages */

.al-body {
  flex: 1;
  overflow-y: auto;
  background: #0B0B11;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.al-body::-webkit-scrollbar { width: 6px; }
.al-body::-webkit-scrollbar-thumb { background: rgba(198, 161, 91, .4); border-radius: 3px; }

.al-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.al-msg.bot {
  align-self: flex-start;
  background: rgba(198, 161, 91, .1);
  border: 1px solid rgba(198, 161, 91, .25);
  color: rgba(242, 237, 227, .88);
  border-bottom-left-radius: 4px;
}
.al-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--al-gold), var(--al-gold-lt));
  color: var(--al-ink);
  border-bottom-right-radius: 4px;
}
.al-msg strong { font-weight: 500; color: var(--al-gold-hi); }
.al-msg.user strong { color: var(--al-ink); }
.al-msg img { max-width: 100%; border-radius: 9px; margin-top: 6px; display: block; }
.al-msg a { color: var(--al-gold-lt); text-decoration: underline; text-underline-offset: 2px; }
.al-msg.user a { color: var(--al-ink); }

.al-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  align-self: flex-start;
  background: rgba(198, 161, 91, .1);
  border: 1px solid rgba(198, 161, 91, .25);
  border-radius: 14px 14px 14px 4px;
}
.al-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--al-gold-lt);
  animation: alTyping 1.2s ease-in-out infinite;
}
.al-typing span:nth-child(2) { animation-delay: .15s; }
.al-typing span:nth-child(3) { animation-delay: .3s; }

/* ---------------------------------------------------------------- composer */

.al-foot {
  background: #11111A;
  border-top: 1px solid rgba(198, 161, 91, .22);
  padding: 10px 12px;
  flex-shrink: 0;
}
.al-attach-chip {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 9px;
  background: rgba(198, 161, 91, .1);
  border: 1px solid rgba(198, 161, 91, .3);
  font-size: 11.5px;
  color: var(--al-gold-lt);
}
.al-attach-chip img { width: 34px; height: 24px; object-fit: cover; border-radius: 5px; }
#al-chip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#al-chip-x { background: none; border: 0; color: #e0a295; cursor: pointer; display: flex; }

.al-row { display: flex; align-items: center; gap: 8px; }
.al-input {
  flex: 1;
  max-height: 90px;
  padding: 11px 13px;
  resize: none;
  outline: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(198, 161, 91, .28);
  color: #F2EDE3;
  font-family: inherit;
  font-size: 13.5px;
}
.al-input::placeholder { color: rgba(242, 237, 227, .38); }
.al-input:focus { border-color: var(--al-gold); }

.al-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  border: 0;
  cursor: pointer;
  transition: transform .15s, opacity .2s;
}
.al-btn:hover { transform: scale(1.08); }
.al-btn:disabled { opacity: .5; cursor: default; transform: none; }
.al-btn-attach { background: rgba(198, 161, 91, .12); border: 1px solid rgba(198, 161, 91, .35); color: var(--al-gold-lt); }
.al-btn-send   { background: linear-gradient(135deg, var(--al-gold-dk), var(--al-gold), var(--al-gold-lt)); color: var(--al-ink); }

/* ---------------------------------------------------------------- motion */

@keyframes alPulse {
  0%   { box-shadow: 0 0 0 0 rgba(198, 161, 91, .55); }
  70%  { box-shadow: 0 0 0 16px rgba(198, 161, 91, 0); }
  100% { box-shadow: 0 0 0 0 rgba(198, 161, 91, 0); }
}
@keyframes alBob    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes alSpin   { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes alGrad   { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes alSpark  { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); } 50% { opacity: 1; transform: scale(1) rotate(25deg); } }
@keyframes alTyping { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------------------------------------------------------------- context */

/* the phone menu covers the page — so does Aleena's button otherwise */
.sheet.is-open ~ .al-launcher,
.sheet.is-open ~ .al-win { display: none !important; }

@media (max-width: 480px) {
  .al-launcher { width: 54px; height: 54px; bottom: 16px; right: 16px; }
  .al-win {
    right: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
    height: min(560px, calc(100vh - 110px));
    border-radius: 16px;
  }
  .al-msg { font-size: 12.5px; }
}
@supports (height: 100dvh) {
  @media (max-width: 820px) { .al-win { max-height: calc(100dvh - 110px); } }
}

@media (prefers-reduced-motion: reduce) {
  .al-launcher, .al-head, .al-spark, .al-typing span { animation: none; }
  .al-win { transition: none; }
}
