/* ==========================================================================
   EXO — czat na stronie (js/czat.js)
   Spis: 1 przycisk · 2 panel · 3 wiadomości · 4 formularz · 5 telefon
   ========================================================================== */

.chat {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 55; /* pod panelem rekordu (60) i mapą (70) */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
}

/* ---------- 1. Przycisk ---------- */
.chat__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 1.1rem 0 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(9, 15, 30, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-deep);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg);
  transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur) var(--ease-out);
}
.chat__tab:hover,
.chat.is-open .chat__tab {
  border-color: var(--holo-dim);
  box-shadow: var(--shadow-deep), var(--glow-holo);
}
.chat__tab svg {
  color: var(--holo);
}
/* licznik nieprzeczytanych: 1–4, potem „5+” */
.chat__badge {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffc06a, var(--accent) 60%, #ea9228);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 21px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg), 0 0 14px rgba(246, 169, 69, 0.75);
}
.chat__badge.is-bump {
  animation: badge-bump 480ms var(--ease-out);
}
@keyframes badge-bump {
  0% {
    transform: scale(0.5);
  }
  60% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- 2. Panel ---------- */
.chat__panel {
  display: flex;
  flex-direction: column;
  width: 340px;
  height: min(520px, calc(100vh - 160px));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--glass-hi), transparent 30%), rgba(8, 13, 27, 0.94);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-deep), var(--glow-holo);
  overflow: hidden;
  transform-origin: bottom right;
  animation: chat-in 260ms var(--ease-out) both;
}
@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}
.chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
}
.chat__title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
}
.chat__note {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.08em;
  color: var(--fg-faint);
}
/* dzwonek: dźwięk powiadomień włączony (cyjan) albo wyłączony (przekreślony) */
.chat__bell {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg-faint);
  transition: color var(--dur), border-color var(--dur), background var(--dur);
}
.chat__bell:hover {
  color: var(--fg);
  border-color: var(--line-strong);
}
.chat__bell[aria-pressed="true"] {
  color: var(--holo);
  border-color: var(--holo-dim);
  background: var(--holo-soft);
}
.chat__bell .i-off,
.chat__bell[aria-pressed="false"] .i-on {
  display: none;
}
.chat__bell[aria-pressed="false"] .i-off {
  display: block;
}
.chat__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg-muted);
  transition: color var(--dur), border-color var(--dur);
}
.chat__close:hover {
  color: var(--fg);
  border-color: var(--line-strong);
}

/* ---------- 3. Wiadomości ---------- */
.chat__list {
  flex: 1;
  display: grid;
  align-content: start;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-4);
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.chat__empty {
  padding: var(--space-6) var(--space-3);
  font-size: var(--fs-sm);
  color: var(--fg-faint);
  text-align: center;
}
.chat__msg {
  display: grid;
  gap: 2px;
}
.chat__meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--fs-xs);
}
.chat__meta b {
  font-weight: 600;
}
.chat__meta time {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--fg-faint);
}
.chat__text {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--fg-muted);
  overflow-wrap: anywhere;
}

/* ---------- 4. Formularz ---------- */
.chat__form {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--line);
  background: rgba(3, 5, 11, 0.35);
}
.chat__nick,
.chat__input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
  color: var(--fg);
  outline: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.chat__nick {
  height: 34px;
  padding: 0 0.7rem;
}
.chat__nick:focus,
.chat__input:focus {
  border-color: var(--holo-dim);
  box-shadow: 0 0 0 3px var(--holo-soft);
}
.chat__nick::placeholder,
.chat__input::placeholder {
  color: var(--fg-faint);
}
.chat__row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}
.chat__input {
  min-height: 42px;
  max-height: 120px;
  padding: 0.55rem 0.7rem;
  resize: none;
  font-family: var(--font-body);
  line-height: 1.4;
}
.chat__send {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffc06a, var(--accent) 55%, #ea9228);
  color: var(--accent-ink);
  box-shadow: var(--glow-accent);
  transition: transform var(--dur) var(--ease-out), opacity var(--dur);
}
.chat__send:hover {
  transform: translateY(-1px);
}
.chat__send:disabled {
  opacity: 0.5;
  cursor: default;
}
/* pole-pułapka na boty: niewidoczne dla ludzi */
.chat__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.chat__status {
  min-height: 1em;
  font-size: var(--fs-xs);
  color: var(--fg-faint);
}
.chat__status:empty {
  display: none;
}
.chat__status[data-kind="error"] {
  color: #ff9f8a;
}

/* ---------- 5. Telefon ---------- */
@media (max-width: 560px) {
  .chat__tab-label {
    display: none;
  }
  .chat__tab {
    width: 48px;
    height: 48px;
    padding: 0;
    justify-content: center;
  }
  .chat__panel {
    width: calc(100vw - 32px);
    height: min(70vh, 520px);
  }
}
