/* ==========================================================================
   Noka Talk — front end
   ========================================================================== */

.nt{
  --nt-brand: #1f5fa8;
  --nt-on-brand: #ffffff;
  --nt-x: 20px;
  --nt-y: 20px;
  --nt-ym: 16px;
  --nt-fab: 56px;

  /* Per channel, written into <style id="nt-vars"> */
  --nt-c: #1f5fa8;
  --nt-on-c: #ffffff;

  position: fixed;
  z-index: 99990;
  bottom: calc(var(--nt-y) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  font-family: inherit;
  direction: rtl;
}

/* A physical side on purpose: the owner picks where it sits, and that
   choice should not flip with the language of the page. */
.nt--right{ right: var(--nt-x); left: auto; align-items: flex-end; }
.nt--left { left:  var(--nt-x); right: auto; align-items: flex-start; }

/* ==========================================================================
   The list
   ========================================================================== */
.nt__list{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nt--right .nt__list{ align-items: flex-end; }
.nt--left  .nt__list{ align-items: flex-start; }
.nt__list[hidden]{ display: none; }

.nt--horizontal .nt__list{ flex-direction: row; align-items: center; }

.nt__item{ display: flex; }

.nt__link{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  /* Not a link colour: this is a control, and the theme's a{} rules
     must not reach inside it. */
  color: inherit;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
}
.nt--left .nt__link{ flex-direction: row-reverse; }

.nt__icon{
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--nt-c);
  color: var(--nt-on-c);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .26);
  transition: transform .18s ease;
}
.nt__icon img{
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.nt__link:hover .nt__icon{ transform: translateY(-2px); }

.nt__label{
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  background: #ffffff;
  color: #14181f;
  border: 1px solid #c3c9d2;
  border-radius: 5px;
  padding: 7px 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
}

/* "On hover and focus only" hides the label visually. It stays in the
   accessibility tree either way — the name a screen reader reads is
   never a styling decision. */
.nt--labels-hover .nt__label{
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.nt--labels-hover .nt__link:hover .nt__label,
.nt--labels-hover .nt__link:focus-visible .nt__label{
  position: static;
  width: auto; height: auto;
  padding: 7px 12px; margin: 0;
  overflow: visible;
  clip: auto;
  border: 1px solid #c3c9d2;
}

.nt__item.is-offline .nt__icon{ filter: grayscale(.45); }
.nt__item.is-offline .nt__label{ color: #4b5563; }

/* ==========================================================================
   The floating button
   ========================================================================== */
.nt__fab{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: var(--nt-fab);
  min-height: var(--nt-fab);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--nt-brand);
  color: var(--nt-on-brand);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3);
  justify-content: center;
  transition: transform .2s ease;
}
.nt__fab:hover{ transform: translateY(-2px); }
.nt:not(.has-label) .nt__fab{ width: var(--nt-fab); }
.nt.has-label .nt__fab{ padding: 0 18px; }

.nt__fabLabel{ font-size: 15px; white-space: nowrap; }
.nt__fabIcon, .nt__fabClose{ display: flex; }
.nt__fabClose{ display: none; }
.nt.is-open .nt__fabIcon{ display: none; }
.nt.is-open .nt__fabClose{ display: flex; }

/* A single-colour ring disappears against one background or the other,
   and the theme behind us is not ours to choose. Two rings always show. */
.nt__fab:focus-visible,
.nt__link:focus-visible .nt__icon,
.nt__cta:focus-visible,
.nt__panelClose:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px #111b21;
}
.nt__fab:focus-visible{
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3), 0 0 0 3px #ffffff, 0 0 0 6px #111b21;
}

/* A single bounce on load, never a loop: an animation that repeats and
   cannot be stopped fails WCAG 2.2.2. */
.nt--effect-once .nt__fab{ animation: nt-nudge .7s ease 1.2s 1; }
@keyframes nt-nudge{
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-8px); }
  70%      { transform: translateY(-3px); }
}

/* ==========================================================================
   The chat panel
   ========================================================================== */
.nt__panel{
  position: absolute;
  bottom: calc(100% + 14px);
  width: min(370px, calc(100vw - 32px));
  background: #ffffff;
  color: #14181f;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  text-align: start;
}
.nt--right .nt__panel{ right: 0; left: auto; }
.nt--left  .nt__panel{ left:  0; right: auto; }
.nt__panel[hidden]{ display: none; }

.nt__panelHead{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--nt-c);
  color: var(--nt-on-c);
}
.nt__panelHead .nt__icon{
  width: 42px; height: 42px;
  background: rgba(128, 128, 128, .3);
  color: inherit;
  box-shadow: none;
}
.nt__panelWho{ flex: 1; min-width: 0; }
.nt__panelName{ display: block; font-size: 16px; font-weight: 800; }
.nt__panelStatus{ display: block; font-size: 12.5px; margin-top: 2px; }

.nt__panelClose{
  width: 44px; height: 44px;
  flex: 0 0 44px;
  display: grid; place-items: center;
  background: none; border: 0;
  color: inherit; font-size: 18px; cursor: pointer;
  border-radius: 50%;
}
.nt__panelClose:hover{ background: rgba(128, 128, 128, .3); }

.nt__log{
  padding: 18px 16px;
  max-height: 46vh;
  overflow-y: auto;
  background: #ece5dd;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nt__msg{ display: flex; }
.nt__msg--them{ justify-content: flex-start; }
.nt__msg--me{ justify-content: flex-end; }

.nt__bubble{
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 14px;
  background: #ffffff;
  color: #111b21;
  font-size: 14.5px;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.nt__msg--me .nt__bubble{ background: #d9fdd3; }

.nt__msg.is-pending{ opacity: 0; transform: translateY(6px); }
.nt__msg.is-in{
  opacity: 1; transform: none;
  transition: opacity .28s ease, transform .28s ease;
}

.nt__typing{
  display: inline-flex; gap: 4px;
  padding: 13px 16px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.nt__typing i{
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: nt-blink 1.2s infinite;
}
.nt__typing i:nth-child(2){ animation-delay: .2s; }
.nt__typing i:nth-child(3){ animation-delay: .4s; }
@keyframes nt-blink{ 0%, 60%, 100% { opacity: .3 } 30% { opacity: 1 } }

.nt__panelFoot{ padding: 14px 16px 16px; background: #ffffff; }
.nt__cta{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 12px;
  background: var(--nt-c);
  color: var(--nt-on-c);
  font-weight: 800;
  font-size: 15.5px;
  text-decoration: none;
}
.nt__cta:hover{ color: var(--nt-on-c); }
.nt__note{
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  color: #5b6672;
}

.nt__sr{
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Screens
   ========================================================================== */
@media (max-width: 600px){
  .nt{ bottom: calc(var(--nt-ym) + env(safe-area-inset-bottom, 0px)); }
  .nt__panel{ width: calc(100vw - 24px); }
  .nt__log{ max-height: 44vh; }
  .nt--horizontal .nt__list{ flex-direction: column; align-items: inherit; }
  .nt__item--no-mobile{ display: none; }
  .nt--no-mobile{ display: none; }
}
@media (min-width: 601px){
  .nt__item--no-desktop{ display: none; }
  .nt--no-desktop{ display: none; }
}

/* The stack covers the bottom of the page. On a phone that can hide a
   form's submit button. Added only when the widget is really visible. */
@media (max-width: 600px){
  body.nt-pad{ padding-bottom: 84px; }
}

@media (max-width: 380px){
  .nt__bubble{ font-size: 14px; }
  .nt__log{ max-height: 40vh; }
}

/* ==========================================================================
   Reduced motion and forced colours
   ========================================================================== */
@media (prefers-reduced-motion: reduce){
  .nt__fab, .nt__icon, .nt__msg{ transition: none; }
  .nt__fab:hover, .nt__link:hover .nt__icon{ transform: none; }
  .nt--effect-once .nt__fab{ animation: none; }
  .nt__typing i{ animation: none; opacity: .6; }
  .nt__msg.is-pending{ opacity: 1; transform: none; }
}

/* box-shadow is not painted in forced colours, so the double ring is
   replaced by an outline the system does draw. */
@media (forced-colors: active){
  .nt__fab:focus-visible,
  .nt__link:focus-visible .nt__icon,
  .nt__cta:focus-visible,
  .nt__panelClose:focus-visible{
    outline: 3px solid Highlight;
    outline-offset: 2px;
  }
  .nt__panel, .nt__label{ border: 1px solid CanvasText; }
}
