/* Porterad från affectUI Ghosted Chat (illustration), MIT, Copyright (c) 2026 Florian Höller */
/* Ändrat: flytande layout i stället för skalad rityta (så texten aldrig blir under 12 px), ember i stället för rött och blått,
   en ikon i stället för emoji, ankomsten spelas på klick i stället för när scenen syns */
.ngc-wrap { width: 100%; max-width: 100%; font-family: var(--sans); }
.ui-gc {
  --ui-gc-bubble: #FFFFFF;
  --ui-gc-bubble-border: #EDEDED;
  --ui-gc-bubble-shadow: 0 2px 6px rgba(28, 29, 31, 0.08), 0 1px 2px rgba(28, 29, 31, 0.05);
  --ui-gc-text: #4A4C52;
  --ui-gc-ink: #202020;
  --ui-gc-status: rgba(0, 0, 0, 0.58);
  --ui-gc-read: rgba(0, 0, 0, 0.58);
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  font-family: var(--sans);
  cursor: default;
}
.ui-gc *, .ui-gc *::before, .ui-gc *::after { box-sizing: border-box; margin: 0; }

.ui-gc-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 0 18px; }
.ui-gc-content { position: relative; width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* Ankomst: allt syns från början; vid uppspelning tonar det in i tur och ordning */
.ui-gc-stage[data-play] .ui-gc-status { animation: ui-gc-fade 500ms ease-out 100ms both; }
.ui-gc-stage[data-play] .ui-gc-bubbles > .ui-gc-bubble { animation: ui-gc-arrive 620ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.ui-gc-stage[data-play] .ui-gc-bubbles > .ui-gc-bubble:nth-child(1) { animation-delay: 500ms; }
.ui-gc-stage[data-play] .ui-gc-bubbles > .ui-gc-bubble:nth-child(2) { animation-delay: 1300ms; }
.ui-gc-stage[data-play] .ui-gc-bubbles > .ui-gc-bubble:nth-child(3) { animation-delay: 2300ms; }
.ui-gc-stage[data-play] .ui-gc-read { animation: ui-gc-fade 500ms ease-out 3200ms both; }
.ui-gc-stage[data-play] .ui-gc-alert { animation: ui-gc-shine 1.6s ease-in-out 2900ms both; }
@keyframes ui-gc-arrive {
  from { opacity: 0; transform: translateY(10px) scale(0.92); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes ui-gc-fade { from { opacity: 0; } to { opacity: 1; } }
.ui-gc-bubbles > .ui-gc-bubble { transform-origin: 100% 100%; }

.ui-gc-status { font-size: 12px; line-height: 16px; color: var(--ui-gc-status); transition: color 0.3s ease; }
.ui-gc-bubbles { width: 100%; padding-right: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.ui-gc-bubble {
  max-width: min(78%, 28ch);
  width: fit-content;
  padding: 7px 12px;
  background: var(--ui-gc-bubble);
  border: 1px solid var(--ui-gc-bubble-border);
  border-radius: 14px 14px 4px 14px;
  box-shadow: var(--ui-gc-bubble-shadow);
  font-size: 13px;
  line-height: 18px;
  font-weight: 500;
  color: var(--ui-gc-text);
}

/* "Hallå?": ett ember-sken sveper genom texten en gång vid uppspelning */
.ui-gc-alert {
  display: inline-block;
  font-weight: 500;
  background-image: linear-gradient(90deg, var(--ui-gc-ink) 0%, var(--ui-gc-ink) 38%, #D9601C 50%, var(--ui-gc-ink) 62%, var(--ui-gc-ink) 100%);
  background-size: 300% 100%;
  background-position: 0% 0;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
@keyframes ui-gc-shine { 0% { background-position: 100% 0; } 100% { background-position: 0% 0; } }

/* Sista bubblan: mjukt sken under */
.ui-gc-bubble-last { position: relative; isolation: isolate; margin-bottom: 4px; background: transparent; border-color: transparent; box-shadow: none; }
.ui-gc-bubble-last::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  background: var(--ui-gc-bubble);
  border: 1px solid var(--ui-gc-bubble-border);
  border-radius: inherit;
  box-shadow: var(--ui-gc-bubble-shadow);
}
.ui-gc-bubble-last::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  width: 100%;
  height: 22px;
  background: rgba(217, 96, 28, 0.45);
  filter: blur(12px);
  border-radius: 50%;
  pointer-events: none;
  z-index: -2;
}
.ui-gc-read { font-size: 12px; line-height: 16px; color: var(--ui-gc-read); margin-top: 2px; transition: color 0.3s ease; }

/* Svaret: dolt, dyker upp vid hovring eller med knappen */
.ui-gc-reply {
  position: absolute;
  left: 8%;
  bottom: 30px;
  display: grid;
  place-items: center;
  max-width: none;
  width: auto;
  padding: 6px 12px;
  background: #D9601C;
  border: 1px solid #D9601C;
  border-radius: 14px 14px 14px 4px;
  color: #FFFFFF;
  box-shadow: none;
  opacity: 0;
  transform: translateY(14px) scale(0.92);
  transform-origin: bottom left;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
  pointer-events: none;
}
.ui-gc-reply svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ui-gc:hover .ui-gc-status, .ui-gc:hover .ui-gc-read,
.ui-gc[data-reply] .ui-gc-status, .ui-gc[data-reply] .ui-gc-read { color: transparent; }
.ui-gc:hover .ui-gc-bubbles, .ui-gc[data-reply] .ui-gc-bubbles { transform: translateY(-12px); }
.ui-gc:hover .ui-gc-reply, .ui-gc[data-reply] .ui-gc-reply { opacity: 1; transform: translateY(0) scale(1); }

.ngc-bar { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.ngc-play, .ngc-reply-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 28px; padding: 0 10px; margin: 0; border: 0; border-radius: 6px;
  background: #fff; color: rgba(0, 0, 0, 0.88);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 1px 1px -1px rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  font: 500 13px/20px var(--sans); cursor: pointer;
  transition: box-shadow 140ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), background-color 140ms ease;
}
.ngc-play { padding-left: 8px; }
.ngc-play:hover, .ngc-reply-btn:hover { box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 1px 1px -1px rgba(0, 0, 0, 0.12), 0 1px 3px 0 rgba(0, 0, 0, 0.07); }
.ngc-play:active, .ngc-reply-btn:active { transform: scale(0.97); }
.ngc-play:focus-visible, .ngc-reply-btn:focus-visible { outline: 2px solid rgba(217, 96, 28, 0.4); outline-offset: 1px; }
.ngc-play svg { width: 12px; height: 12px; fill: #D9601C; }
.ngc-play:disabled { opacity: 0.45; cursor: default; }
.ngc-reply-btn[aria-pressed="true"] { background: rgba(217, 96, 28, 0.1); color: #A8460F; box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  .ui-gc-status, .ui-gc-bubbles, .ui-gc-read, .ui-gc-reply { transition: none; }
  .ui-gc-stage[data-play] * { animation: none !important; }
}

/* Mörkt läge, samma konvention som affectUI */
:where(.dark, [data-theme="dark"]) .ui-gc {
  --ui-gc-bubble: #1C1B1A;
  --ui-gc-bubble-border: rgba(255, 255, 255, 0.08);
  --ui-gc-bubble-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.4);
  --ui-gc-text: rgba(255, 255, 255, 0.72);
  --ui-gc-ink: rgba(255, 255, 255, 0.92);
  --ui-gc-status: rgba(255, 255, 255, 0.58);
  --ui-gc-read: rgba(255, 255, 255, 0.58);
}
:where(.dark, [data-theme="dark"]) .ui-gc-bubble-last::after { opacity: 0.55; }
:where(.dark, [data-theme="dark"]) .ui-gc-reply { color: #161615; background: #F08A4B; border-color: #F08A4B; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }
:where(.dark, [data-theme="dark"]) .ngc-play, :where(.dark, [data-theme="dark"]) .ngc-reply-btn { background: #1C1B1A; color: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 1px 2px rgba(0, 0, 0, 0.4); }
:where(.dark, [data-theme="dark"]) .ngc-play:hover, :where(.dark, [data-theme="dark"]) .ngc-reply-btn:hover { box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.16), 0 1px 3px rgba(0, 0, 0, 0.5); }
:where(.dark, [data-theme="dark"]) .ngc-reply-btn[aria-pressed="true"] { background: rgba(240, 138, 75, 0.14); color: #F08A4B; box-shadow: none; }

/* Ingen orange glöd under bubblan */
.ui-gc-bubble-last::after { display: none; }
