/* ==========================================================================
   The chat assistant (assets/js/chat.js): bottom right on every public page.
   A gold-ringed seal opens a small vitrine — black falling into royal green, like the price board.
   ========================================================================== */
.gec {
  --gec-ink: #f4f0e8;
  --gec-soft: rgb(244 240 232 / 0.72);
  --gec-gold: #e2c06e;                 /* the board's light gold: readable on the dark ground */
  --gec-line: rgb(191 143 33 / 0.32);
  --gec-edge: max(20px, env(safe-area-inset-right));
  --gec-foot: max(20px, env(safe-area-inset-bottom));
  position: fixed;
  right: var(--gec-edge);
  bottom: var(--gec-foot);
  z-index: 65;                         /* above the header (50) and the copy note (60) */
  font-family: var(--font-text);
  direction: rtl;
}
html.menu-open .gec { display: none; }

/* ---------- the robot: it floats where it stands, its shadow breathing beneath it ---------- */
/* its turn in space, in degrees: --ry > 0 looks to the left, --rx > 0 looks up. Registered, so they
   can be animated and every part (the figure, its light, its shadow) follows the same turn. */
@property --ry { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --rx { syntax: "<number>"; inherits: true; initial-value: 0; }
.gec__launcher {
  animation: gec-turn 7.2s ease-in-out infinite;   /* idle: a slow look around (chat.js: the cursor) */
  position: relative;
  display: block;
  width: 84px;
  height: 104px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gec__bot {
  position: absolute;
  inset: 0 0 14px;
  display: block;
  perspective: 420px;                  /* the depth its turn is seen with */
  transform-origin: 50% 100%;
  animation: gec-float 3.4s ease-in-out infinite;
  transition: transform 0.5s var(--ease-lux);
}
.gec__bot-3d {
  position: relative;
  display: block;
  transform: rotateY(calc(var(--ry) * -1deg)) rotateX(calc(var(--rx) * 1deg));   /* CSS rotateY(+) faces right */
  transform-style: preserve-3d;
}
.gec__bot-img {
  display: block;
  width: 100%;
  height: auto;
  /* the white robot stays distinct on the pearl pages too; its shadow falls away from the turn */
  filter: drop-shadow(calc(var(--ry) * 0.3px) 6px 10px rgb(12 13 12 / 0.2));
}
/* light on its curves: a sheen that travels as it turns, and the far side a little in shade —
   drawn only inside the robot's own outline (masked by the same picture) */
.gec__bot-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask: url("../img/chat/robot-160.webp") top center / 100% 100% no-repeat;
  mask: url("../img/chat/robot-160.webp") top center / 100% 100% no-repeat;
  background:
    linear-gradient(100deg, transparent 36%, rgb(255 255 255 / 0.42) 47%, transparent 58%)
      calc(55% - var(--ry) * 0.85%) 0 / 300% 100% no-repeat,    /* light from the left; it slides against the turn */
    linear-gradient(90deg,
      rgb(12 13 12 / calc(max(0, var(--ry)) * 0.014)), transparent 42%,
      transparent 58%, rgb(12 13 12 / calc(max(0, -1 * var(--ry)) * 0.014)));
  mix-blend-mode: soft-light;          /* a sheen on the curves, never a grey veil over the dark visor */
  opacity: 0.9;
}
.gec__bot-shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 54px;
  height: 9px;
  margin-left: -27px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(12 13 12 / 0.32), transparent);
  translate: calc(var(--ry) * -0.4px) 0;
  animation: gec-shadow 3.4s ease-in-out infinite;
}
@keyframes gec-float {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-9px) rotate(1.5deg); }
}
@keyframes gec-shadow {
  0%, 100% { scale: 1; opacity: 1; }
  50% { scale: 0.72; opacity: 0.55; }
}
@keyframes gec-turn {
  0%, 100% { --ry: 0; --rx: 0; }
  25% { --ry: 16; --rx: 3; }
  50% { --ry: 0; --rx: -2; }
  75% { --ry: -16; --rx: 3; }
}
/* following the cursor (chat.js sets --ry/--rx itself) */
.gec.is-tracking .gec__launcher { animation: none; }
/* hovered: it rises to meet the visitor */
.gec__launcher:hover .gec__bot,
.gec__launcher:focus-visible .gec__bot { animation-duration: 1.7s; }
.gec__launcher:focus-visible { outline: 1px solid var(--gold); outline-offset: 6px; border-radius: 4px; }

/* open: a small gold seal with «×» on the robot's shoulder closes the chat */
.gec__launcher-close {
  position: absolute;
  top: 2px;
  left: -4px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--black);
  background: var(--gold);
  box-shadow: 0 0 0 3px rgb(244 240 232 / 0.9);
  opacity: 0;
  transform: scale(0.6) rotate(-45deg);
  transition: opacity 0.35s var(--ease-lux), transform 0.5s var(--ease-lux);
}
.gec__launcher-close svg { width: 16px; height: 16px; }
.gec.is-open .gec__launcher-close { opacity: 1; transform: none; }

/* while the greeting waits to be read, the robot hops a little higher */
.gec.is-teasing:not(.is-open) .gec__bot { animation-name: gec-hop; }
@keyframes gec-hop {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  40% { transform: translateY(-14px) rotate(2deg); }
  60% { transform: translateY(-12px) rotate(1deg); }
}

/* ---------- the greeting ---------- */
.gec__teaser {
  position: absolute;
  right: 0;
  bottom: calc(100% + 16px);
  width: max-content;
  max-width: min(290px, calc(100vw - 2 * var(--gec-edge)));
  padding: 0.9rem 1rem 0.9rem 2.4rem;
  color: var(--ink);
  background: var(--pearl);
  border: 1px solid var(--gold-line);
  box-shadow: 0 20px 44px -22px rgb(12 13 12 / 0.55);
  animation: gec-rise 0.7s var(--ease-lux) both;
}
.gec__teaser::after {                  /* points at the robot */
  content: "";
  position: absolute;
  right: 36px;                         /* above the robot's head */
  top: 100%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  background: var(--pearl);
  border-right: 1px solid var(--gold-line);
  border-bottom: 1px solid var(--gold-line);
  transform: rotate(45deg);
}
.gec__teaser-text {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.85;
  text-align: start;
  cursor: pointer;
}
.gec__teaser-close {
  position: absolute;
  left: 0.4rem;
  top: 0.4rem;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.gec__teaser-close svg { width: 14px; height: 14px; }
.gec__teaser-close:hover { color: var(--ink); }
@keyframes gec-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- the panel ---------- */
.gec__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 16px);
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 2 * var(--gec-edge)));
  height: min(640px, calc(100svh - 170px));   /* the robot stands below it */
  color: var(--gec-ink);
  border: 1px solid var(--gold-line);
  background:
    radial-gradient(80% 40% at 90% 0%, rgb(46 112 84 / 0.32), transparent 70%),
    linear-gradient(162deg, #070908 0%, #0b1511 30%, #10261d 62%, #143326 100%);
  box-shadow: 0 40px 80px -40px rgb(12 13 12 / 0.8);
  animation: gec-rise 0.55s var(--ease-lux) both;
}
.gec__panel[hidden] { display: none; }
.gec__panel::before {                   /* the vitrine's inner hairline */
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgb(191 143 33 / 0.14);
  pointer-events: none;
}

.gec__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem 0.85rem;
  border-bottom: 1px solid var(--gec-line);
}
.gec__avatar {
  display: grid;
  place-items: end center;
  flex: none;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--pearl);
  box-shadow: 0 0 0 1px var(--gold);
}
.gec__avatar-img { display: block; width: 40px; height: auto; margin-bottom: -10px; }
.gec__titles { flex: 1; min-width: 0; }
.gec__title {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: calc(var(--display-scale) * 1.15rem);
  line-height: 1.5;
  color: var(--gec-gold);
}
.gec__sub { font-size: 0.75rem; color: var(--gec-soft); line-height: 1.6; }
.gec__close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gec-soft);
  cursor: pointer;
}
.gec__close svg { width: 18px; height: 18px; }
.gec__close:hover, .gec__close:focus-visible { color: var(--gec-gold); }

/* ---------- the conversation ---------- */
.gec__log {
  position: relative;                  /* messages measure their place from here (chat.js) */
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1rem 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgb(191 143 33 / 0.4) transparent;
}
.gec__log:focus { outline: none; }

.gec-msg { display: grid; justify-items: start; margin-bottom: 0.85rem; }
.gec-msg--user { justify-items: end; }
.gec-msg__bubble {
  max-width: 88%;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  line-height: 1.95;
  white-space: pre-line;
}
.gec-msg--bot .gec-msg__bubble {
  color: var(--gec-ink);
  background: rgb(244 240 232 / 0.06);
  border: 1px solid rgb(191 143 33 / 0.2);
}
.gec-msg--user .gec-msg__bubble {
  color: var(--black);
  background: var(--gold);              /* flat gold: black text on it reads at 7.5:1 */
}
.gec-msg__note {
  max-width: 94%;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  line-height: 1.85;
  color: var(--gec-soft);
}
.gec-msg__links { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 0.45rem; }
.gec-link {
  font-size: 0.875rem;
  color: var(--gec-gold);
  text-decoration: underline;
  text-decoration-color: var(--gec-line);
  text-underline-offset: 0.3em;
}
.gec-link:hover { text-decoration-color: var(--gec-gold); }

/* the pieces: a row that scrolls sideways */
.gec-cards {
  display: flex;
  gap: 0.6rem;
  width: calc(100% + 2rem);
  margin: 0.55rem -1rem 0;
  padding: 0.15rem 1rem 0.5rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgb(191 143 33 / 0.4) transparent;
}
.gec-card {
  flex: 0 0 152px;
  display: grid;
  align-content: start;
  gap: 0.15rem;
  scroll-snap-align: start;
  color: var(--gec-ink);
  border: 1px solid rgb(191 143 33 / 0.2);
  background: rgb(12 13 12 / 0.35);
  transition: border-color 0.4s var(--ease-lux);
}
.gec-card:hover, .gec-card:focus-visible { border-color: var(--gold); }
.gec-card:focus-visible { outline: none; }
.gec-card__img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  margin-bottom: 0.4rem;
  background: #1a1d1b;
}
.gec-card__name, .gec-card__meta, .gec-card__price { padding-inline: 0.6rem; }
.gec-card__name { font-size: 0.8125rem; line-height: 1.7; }
.gec-card__meta { font-size: 0.6875rem; color: var(--gec-soft); }
.gec-card__price { padding-bottom: 0.55rem; font-size: 0.71875rem; color: var(--gec-gold); }

/* quick answers */
.gec-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.1rem 0 0.9rem; }
.gec-chip {
  min-height: 36px;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--gec-line);
  border-radius: 999px;
  background: transparent;
  color: var(--gec-ink);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color 0.35s var(--ease-lux), color 0.35s var(--ease-lux), border-color 0.35s var(--ease-lux);
}
.gec-chip:hover, .gec-chip:focus-visible { background: var(--gold); border-color: var(--gold); color: var(--black); outline: none; }

/* three dots while an answer is on its way */
.gec-typing .gec-msg__bubble { display: inline-flex; gap: 5px; padding-block: 0.85rem; }
.gec-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gec-gold);
  animation: gec-dot 1s ease-in-out infinite;
}
.gec-typing span:nth-child(2) { animation-delay: 0.15s; }
.gec-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes gec-dot { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

/* ---------- writing ---------- */
.gec__privacy {
  margin: 0;
  padding: 0.35rem 0.85rem 0;
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--ink-soft, rgb(41 55 48 / 0.6));
  border-top: 1px solid var(--gec-line);
}
.gec__form {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem 0.85rem;
}
.gec__input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0.5rem 0.85rem;
  border: 1px solid rgb(191 143 33 / 0.3);
  background: rgb(244 240 232 / 0.05);
  color: var(--gec-ink);
  font: inherit;
  font-size: 1rem;                      /* ≥16px: no zoom-on-focus on iOS */
}
.gec__input::placeholder { color: rgb(244 240 232 / 0.45); }
.gec__input:focus { outline: none; border-color: var(--gold); }
.gec__send {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  background: var(--gold);
  color: var(--black);
  cursor: pointer;
  transition: background-color 0.35s var(--ease-lux);
}
.gec__send svg { width: 20px; height: 20px; }
.gec__send:hover, .gec__send:focus-visible { background: var(--gec-gold); outline: none; }

/* ---------- phones: the panel becomes a sheet from the bottom ---------- */
@media (max-width: 599px) {
  .gec { --gec-edge: max(14px, env(safe-area-inset-right)); --gec-foot: max(14px, env(safe-area-inset-bottom)); }
  .gec__launcher { width: 68px; height: 86px; }
  .gec__bot { inset-block-end: 12px; }
  .gec__bot-shadow { width: 44px; margin-left: -22px; }
  .gec__panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    height: min(82svh, 640px);
    border-inline: 0;
    border-bottom: 0;
  }
  .gec.is-open .gec__launcher { display: none; }
  .gec__panel .gec__form { padding-bottom: max(0.85rem, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .gec__panel, .gec__teaser { animation: none; }
  .gec__launcher, .gec__bot, .gec__bot-shadow { animation: none !important; }
  .gec__bot-shine { display: none; }
  .gec-typing span { animation: none; opacity: 0.7; }
}
