/* ============================================================
   GiuLLM — chat overlay (Giulia's AI digital twin)
   Framed, dotted "notebook" paper inside; product-design polish in a strong,
   minimal black/white style. The one colour is electric blue (About trigger hover).
   ============================================================ */
:root { --gm-accent: #2962ff; --gm-frame: #989ca6; }   /* electric blue */

/* The icon: a 4-point star inside a tilted ellipse (mirrored tilt). overflow
   visible so the breathing ellipse isn't clipped by the square viewBox. */
.gm-star { display: block; overflow: visible; }

/* Trigger — an electric-blue "Ask GiuLLM" rectangle that trails the cursor (JS
   sets left/top), inverting against the page. Visual only on desktop (the page
   click opens the chat), so it never blocks links or text selection. */
.gm-fab {
  position: fixed;
  left: 0;
  top: 0;                          /* JS sets left/top to the cursor centre */
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 0.34em;
  pointer-events: none;
  opacity: 0;                      /* shown after the first mouse move */
  background: var(--gm-accent);
  color: #fff;
  border: none;
  padding: 0.3em 0.55em;
  font-family: var(--font-serif);  /* GiuLLM wordmark in serif */
  font-weight: 400;                /* Instrument Serif only ships 400; 600 = grainy faux-bold */
  font-size: var(--fs-body);       /* same size as the Welcome pill */
  letter-spacing: 0;
  white-space: nowrap;
  will-change: transform;          /* JS eases it toward the cursor (a soft chase) */
  transition: opacity 0.18s ease;
}
/* "Ask" stays in Archivo; only "GiuLLM" is the serif wordmark. */
.gm-fab > span:first-child,
.gm-ask > span:first-child,
.gm-bubble > span:first-child { font-family: var(--font-sans); font-weight: 400; font-size: 0.85em; }
.gm-fab .gm-star { width: 1.05em; height: 1.05em; transform: rotate(12deg); }
body.gm-cta-on .gm-fab { opacity: 1; }
body.giullm-open .gm-fab { opacity: 0 !important; }

/* Mobile: no cursor — a normal button sitting at the end, below the bio. */
/* No cursor on mobile: the cursor-pill trigger is hidden; pages provide their own
   static trigger (.gm-ask) where it makes sense. */
@media (max-width: 760px) {
  .gm-fab { display: none; }
}

/* Persistent GiuLLM trigger, pinned bottom-right on every page. Collapsed by default on
   EVERY viewport: a round icon-only bubble. On hover (desktop) it grows into the full
   "Ask GiuLLM" pill with a white background. Touch devices have no hover → it stays the
   round icon. */
.gm-bubble {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + clamp(16px, 3vw, 28px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(16px, 3vw, 28px));
  z-index: 45;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 28px;              /* a perfect circle while collapsed (flattens smoothly to a sharp rectangle on hover) */
  background: var(--gm-accent);
  color: #fff;
  border: 1.5px solid transparent;
  font-family: var(--font-serif);   /* GiuLLM wordmark in serif */
  font-weight: 400;                 /* Instrument Serif only ships 400 */
  font-size: var(--fs-body);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.24);
  transition: gap 0.55s cubic-bezier(0.22, 1, 0.36, 1), padding 0.55s cubic-bezier(0.22, 1, 0.36, 1), border-radius 0.55s cubic-bezier(0.22, 1, 0.36, 1), background 0.35s ease, color 0.35s ease, border-color 0.35s ease, transform 0.25s ease, opacity 0.25s ease;
}
.gm-bubble .gm-star { flex: none; width: 26px; height: 26px; transform: rotate(12deg); transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1), height 0.55s cubic-bezier(0.22, 1, 0.36, 1); }
/* The "Ask" / "GiuLLM" labels stay collapsed (width 0) until the hover expand. */
.gm-bubble > span { max-width: 0; opacity: 0; overflow: hidden; transition: max-width 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease; }

@media (hover: hover) {
  .gm-bubble:hover {
    gap: 0.34em;
    padding: 0 0.95em;
    border-radius: 0;               /* a straight-edged, right-angled rectangle */
    background: #fff;                /* a bit of white on hover */
    color: var(--gm-accent);
    border-color: var(--gm-accent);   /* same electric blue as the wordmark */
  }
  .gm-bubble:hover > span { max-width: 7em; opacity: 1; }
  .gm-bubble:hover .gm-star { width: 1.15em; height: 1.15em; }
}
/* Tuck it away while the chat is open, or behind a full-screen overlay (a project's
   Info panel — which has its own contextual trigger — or the Space catalogue). */
body.giullm-open .gm-bubble { opacity: 0; transform: scale(0.95); pointer-events: none; }
body.info-open .gm-bubble,
body.catalogue-open .gm-bubble { opacity: 0; pointer-events: none; }
/* About (desktop) uses the cursor-trailing pill instead — drop the bottom-right one. */
@media (hover: hover) {
  body.gm-has-cursor-cta .gm-bubble { display: none; }
}

.giullm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, background 0.4s ease, visibility 0s linear 0.4s;
}
.giullm.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.34);                 /* softer, lighter full-screen grey */
  backdrop-filter: blur(3px);                      /* …gently blurred for a dolce feel */
  -webkit-backdrop-filter: blur(3px);
  transition: opacity 0.4s ease, background 0.4s ease;
}

/* The frame: a clean black border; the dotted paper sits inset inside it. */
.giullm__panel {
  position: relative;
  width: min(520px, 100%);
  height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  color: #181a1f;
  background-color: #f7f9fc;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.13);   /* soft, diffuse shadow behind the chat */
  border-radius: 6px;                            /* corners rounded a touch */
  overflow: hidden;                              /* clip the flush header to the radius */
  padding: clamp(20px, 2.8vw, 28px);
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  /* gentle ease-out (expo-ish) so it settles softly into place */
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.34s ease;
}
.giullm.is-open .giullm__panel { transform: translateY(0) scale(1); opacity: 1; }
.giullm__panel::before {
  content: "";
  position: absolute;
  inset: clamp(7px, 1vw, 11px);
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.1) 0.85px, transparent 1.3px);
  background-size: 25px 25px;
  pointer-events: none;
}
.giullm__panel > * { position: relative; z-index: 1; }
.giullm__panel { user-select: text; -webkit-user-select: text; }   /* selectable chat */

.giullm__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Flush to the panel's outer border (negative = the panel padding), filled with
     the frame colour — reads as the top edge of the frame, just thicker. */
  margin: calc(-1 * clamp(20px, 2.8vw, 28px)) calc(-1 * clamp(20px, 2.8vw, 28px)) 20px;
  padding: 11px clamp(14px, 1.8vw, 18px);
  background: var(--gm-accent);    /* electric-blue header */
  color: #fff;                     /* white title + icons */
}
.giullm__bar .giullm__icon-btn { color: #fff; }
.giullm__title {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-serif);   /* GiuLLM wordmark in Instrument Serif */
  letter-spacing: 0;
  font-size: 1.55em;
  font-weight: 400;
}
.giullm__title .gm-star { width: 1.2em; height: 1.2em; transform: rotate(12deg); transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
/* Cursor over the icon → a smooth full spin. */
.giullm__title .gm-star:hover { transform: rotate(372deg); }
/* Same ellipse weight on both stars (trigger + chat) so the icon is identical and
   only scales with its size. */
.gm-star ellipse { stroke-width: 1.5px; }
.giullm__name { display: inline-flex; align-items: center; }

/* Instrument Serif only ships weight 400; a hair of text-stroke fakes a touch more
   weight without the grainy synthetic-bold. (The small "i" tooltip glyph is excluded.) */
.giullm__hello,
.giullm__name,
.gm-fab > span:last-child,
.gm-ask > span:last-child,
.gm-bubble > span:last-child { -webkit-text-stroke: 0.3px currentColor; }
.gm-info { -webkit-text-stroke: 0; }

/* Info "i" with a hover tooltip. */
.gm-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3em;
  height: 1.3em;
  margin-left: 1.15em;
  border: 1.1px solid rgba(255, 255, 255, 0.75);   /* white on the blue bar */
  color: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  font-size: 0.52em;              /* a touch smaller */
  font-weight: 600;               /* thicker glyph */
  font-style: normal;
  line-height: 1;
  opacity: 1;
}
.gm-info:hover, .gm-info:focus { color: #fff; border-color: #fff; outline: none; }
/* Disclaimer pill — glued to the cursor while hovering the "i" (positioned by JS
   via inline left/top). Solid black box, white text, sharp corners, no invert. */
.gm-tip-pill {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;
  opacity: 0;
  background: #000;
  color: #fff;
  font: inherit;
  font-size: clamp(10px, 1.1vw, 12px);
  font-style: normal;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.015em;
  max-width: 230px;
  padding: 0.3em 0.5em;
  pointer-events: none;
  will-change: transform;          /* JS eases it toward the cursor (same chase as the sound pill) */
  transition: opacity 0.14s ease;
}
body.gm-tip-on .gm-tip-pill { opacity: 1; }

.giullm__tools { display: inline-flex; align-items: center; gap: 6px; }
.giullm__icon-btn {
  width: 30px;
  height: 30px;
  padding: 5px;
  background: none;
  border: none;
  color: #181a1f;                  /* black icons (restart + ×) */
}
.giullm__icon-btn svg { width: 100%; height: 100%; display: block; }
#gm-restart svg { transform: scaleX(-1) scale(0.86); }   /* mirrored, a touch smaller */

.giullm__log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
  scrollbar-width: none;
}
.giullm__log::-webkit-scrollbar { width: 0; }

.gm-msg {
  max-width: 78%;
  line-height: 1.2;                /* tighter, matching the rest of the site */
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}
/* My question: a white rectangle with the same grey line as everything else.
   Equal breathing room above (from the previous turn) and below (to the answer). */
.gm-msg--user {
  align-self: flex-end;
  background: #fff;
  border: 1px solid var(--gm-frame);
  color: #181a1f;
  padding: 0.6em 0.85em;
  margin: 22px 0;
}
/* Giullm's answer: written straight on the background, no bubble. A 2/3 measure
   from the left keeps the line length comfortable to read. */
.gm-msg--bot {
  align-self: flex-start;
  max-width: 66%;
  color: #181a1f;
  padding: 0.1em 0;
}

/* After an answer: a grey divider line, then the suggested follow-up questions. */
.gm-followups {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--gm-frame);
}
.gm-msg--typing { display: inline-flex; gap: 6px; align-items: center; padding-top: 4px; }
.gm-msg--typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gm-accent);    /* electric blue */
  animation: gm-bounce 0.85s ease-in-out infinite;
}
.gm-msg--typing span:nth-child(2) { animation-delay: 0.13s; }
.gm-msg--typing span:nth-child(3) { animation-delay: 0.26s; }
/* Playful bounce: hop up + squash/stretch. */
@keyframes gm-bounce {
  0%, 100% { transform: translateY(0) scale(0.8); opacity: 0.45; }
  35%      { transform: translateY(-7px) scale(1.15); opacity: 1; }
}

/* Intro / suggestions — at the bottom, just above the input. Hidden once chatting. */
/* padding-bottom + the form's margin-top ≈ the 34px above the questions, so the
   suggestions sit evenly between the greeting and the input bar. */
.giullm__intro { flex: none; padding-top: 12px; padding-bottom: 18px; }
.giullm.gm-started .giullm__intro { display: none; }
.giullm__hello { margin: 0 0 34px; font-family: var(--font-serif); font-weight: 400; font-size: 2.1em; line-height: 1; letter-spacing: 0; }
.giullm__suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }

.gm-arrow { width: 18px; height: auto; flex: none; color: #9196a0; transition: color 0.15s ease; }

/* Suggested questions: not buttons — text + a small grey 90° arrow; on hover a light
   orange wash and the text + arrow turn orange. */
.gm-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;                        /* text sits closer to the arrow */
  width: auto;
  background: none;
  border: none;
  color: #9196a0;                  /* grey, same as the arrows */
  font: inherit;
  font-size: 0.92em;               /* questions a touch smaller */
  text-align: left;
  /* The arrow stays aligned with the greeting above and the input bar below
     (negative margin cancels the padding), while the orange hover wash bleeds
     outward on both sides. */
  padding: 0.3em 0.85em;
  margin-left: -0.85em;
  /* Smooth cross-fade as the cursor moves between questions. */
  transition: background 0.35s ease, color 0.35s ease;
}
.gm-chip:hover { background: rgba(41, 98, 255, 0.14); color: var(--gm-accent); }
.gm-chip:hover .gm-arrow { color: var(--gm-accent); }

/* Input bar — a plain grey rectangle with an up-arrow send. No hover state. */
.giullm__form {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;   /* less gap above the input → the greeting block sits a little lower */
  padding: 0.78em 0.7em 0.78em 0.95em;
  background: #fff;
  border: 1px solid var(--gm-frame);
}
.giullm__input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: #181a1f;
  font: inherit;
}
.giullm__input::placeholder { color: #9196a0; }
.giullm__input:focus { outline: none; }
.giullm__send {
  flex: none;
  width: 2.3em;
  height: 2.3em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5em;
  background: none;
  border: 1.5px solid transparent;
  border-radius: 50%;
  color: #9196a0;                  /* grey send arrow when empty */
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.giullm__send svg { width: 100%; height: 100%; display: block; }
/* Hover ring only appears once there's text to send. */
.giullm__form.gm-has-text .giullm__send:hover { border-color: rgba(41, 98, 255, 0.55); }
/* With text typed: an orange circle behind, the up-arrow turns orange (and it
   submits the question). */
.giullm__form.gm-has-text .giullm__send {
  background: rgba(41, 98, 255, 0.16);
  color: var(--gm-accent);
}

/* No cursor hover-blur on anything inside the chat. */
.giullm .cursor-blur { filter: none !important; }

/* Static "Ask GiuLLM" trigger — used where there's no cursor pill (e.g. inside a
   project's Info panel). A clickable electric-blue rectangle with the star. */
.gm-ask {
  display: inline-flex;
  align-self: flex-start;          /* hug the text, don't stretch (flex parent) */
  justify-self: start;             /* …and in a grid (About mobile column) */
  width: max-content;
  max-width: 100%;
  align-items: center;
  gap: 0.34em;
  margin-top: 1.4em;
  padding: 0.4em 0.7em;
  /* Solid electric-blue base (identical to the About trigger); on hover it turns
     light-blue with a blue ring (like the send button with text). */
  background: var(--gm-accent);
  color: #fff;
  border: 1.5px solid transparent;
  font-family: var(--font-serif);  /* GiuLLM wordmark in serif */
  font-weight: 400;                /* Instrument Serif only ships 400; 600 = grainy faux-bold */
  font-size: 1.05em;
  letter-spacing: 0;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.gm-ask .gm-star { width: 1.05em; height: 1.05em; transform: rotate(12deg); }
.gm-ask:hover {
  background: rgba(41, 98, 255, 0.16);
  color: var(--gm-accent);
  border-color: rgba(41, 98, 255, 0.55);
}
.gm-ask.cursor-blur { filter: none !important; }   /* no hover blur on the trigger */

/* ---- Mobile: the chat is a bottom sheet that slides up from the bottom ---- */
@media (max-width: 760px) {
  .giullm { align-items: flex-end; padding: 0; }
  .giullm__panel {
    width: 100%;
    max-width: none;
    height: 90vh;
    height: 90dvh;
    border-radius: 6px 6px 0 0;
    /* slide up from below (no scale/fade — a clean sheet) */
    transform: translateY(100%);
    opacity: 1;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .giullm.is-open .giullm__panel { transform: translateY(0); }

  /* The disclaimer "i" tooltip: placed by CSS (not glued to the tap point, so it can't
     touch the edge), bigger and clearer. */
  .gm-tip-pill {
    left: clamp(18px, 6vw, 28px);
    right: clamp(18px, 6vw, 28px);
    top: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
    max-width: none;
    font-size: 15px;
    line-height: 1.5;
    padding: 0.75em 0.95em;
    transform: none !important;
  }
}
