/* Sohbet görünümü (web/chat.js). Yalnız style.css token'larını kullanır; DESIGN.md:
   mesaj metni ≥15 px, dokunma hedefleri ≥44 px, sonsuz animasyon yok. */

/* Alt sekme çubuğu: Program · Düşen Oranlar · Kuponlar · Yorumlar · Sohbet */
.tabbar { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* Sohbet açıkken hipodrom/koşu seçicisi gizlenir (yalnız mobilde sohbet sekmesi açıkken) */
body.mobile-view-sohbet #picker { display: none; }

#view-sohbet {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-window #view-sohbet {
  flex: 1;
  min-height: 0;
  padding: 0.625rem 0.75rem 0.75rem;
  box-sizing: border-box;
  overflow: hidden;
  max-width: 100%;
}
.chat-head { padding-bottom: 0.5rem; flex: none; }

.chat-pinned {
  display: grid; gap: 0.125rem;
  margin: 0 0 0.625rem; padding: 0.625rem 0.875rem;
  background: var(--brand-subtle); border: 1px solid var(--brand-line); border-radius: var(--radius-sm);
  flex: none;
}
.chat-pinned-label { font-size: 0.8125rem; font-weight: 700; color: var(--brand-strong); }
.chat-pinned-text { font-size: 1rem; line-height: 1.45; color: var(--text); }

.chat-status {
  margin: 0 0 0.5rem; padding: 0.5rem 0.75rem;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 0.9375rem;
  flex: none;
}

.chat-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-list {
  list-style: none; margin: 0; padding: 0.625rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  height: calc(100vh - 31rem); height: calc(100dvh - 31rem); min-height: 12rem;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.chat-list:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.chat-msg { display: flex; justify-content: flex-start; }
.chat-msg.mine { justify-content: flex-end; }
.chat-bubble {
  max-width: min(85%, 34rem);
  padding: 0.5rem 0.75rem 0.5625rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  border-bottom-left-radius: 0.25rem;
}
.chat-msg.mine .chat-bubble {
  background: var(--brand-subtle); border-color: var(--brand-line);
  border-bottom-left-radius: var(--radius); border-bottom-right-radius: 0.25rem;
}
.chat-msg.team .chat-bubble { border-color: var(--brand-line); }
.chat-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.125rem 0.5rem; }
.chat-nick { font-weight: 700; font-size: 0.9375rem; color: var(--text); }
.chat-msg.team .chat-nick { color: var(--brand-strong); }
.chat-badge {
  font-size: 0.8125rem; font-weight: 700; color: var(--brand-strong);
  border: 1px solid var(--brand-line); border-radius: 999px; padding: 0 0.4375rem;
}
.chat-time { font-size: 0.8125rem; color: var(--dim); }
.chat-text { font-size: 1rem; line-height: 1.5; color: var(--text); margin-top: 0.125rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-race {
  display: inline-block; margin-top: 0.375rem;
  font-size: 0.8125rem; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 0.0625rem 0.5rem;
  background: var(--raised);
}

.chat-empty, .chat-loading {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 0.25rem;
  padding: 1rem; color: var(--muted); font-size: 1rem; pointer-events: none;
}
.chat-empty-title { font-weight: 700; color: var(--text); font-size: 1.0625rem; }
.chat-empty[hidden], .chat-loading[hidden] { display: none; }

.chat-new {
  position: absolute; left: 50%; bottom: 0.75rem; transform: translateX(-50%);
  min-height: var(--tap); padding: 0 1.125rem;
  border: 1px solid var(--brand-line); border-radius: 999px;
  background: var(--brand-strong); color: var(--card);
  font-weight: 700; font-size: 0.9375rem; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.chat-form { margin-top: 0.625rem; display: grid; gap: 0.5rem; }
.chat-rules { font-size: 0.9375rem; color: var(--muted); line-height: 1.45; }
.chat-slow { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.chat-tag {
  justify-self: start; min-height: var(--tap); padding: 0 0.875rem;
  border: 1px dashed var(--border-strong); border-radius: 999px; background: var(--card);
  color: var(--muted); font-size: 0.9375rem; font-weight: 600; cursor: pointer; text-align: left;
}
.chat-tag[aria-pressed="true"] { border-style: solid; border-color: var(--brand-line); background: var(--brand-subtle); color: var(--brand-strong); }
.chat-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; align-items: stretch; }
.chat-input-row textarea {
  width: 100%; min-height: 3.25rem; max-height: 8rem; resize: vertical;
  padding: 0.625rem 0.75rem;
  font: inherit; font-size: 1rem; line-height: 1.45; color: var(--text);
  background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.chat-input-row textarea::placeholder { color: var(--dim); }
.chat-send, .chat-primary {
  min-height: var(--tap); min-width: 5.5rem; padding: 0 1.125rem;
  border: 1px solid var(--brand-strong); border-radius: var(--radius-sm);
  background: var(--brand-strong); color: var(--card);
  font-weight: 700; font-size: 1rem; cursor: pointer;
}
.chat-send:disabled, .chat-primary:disabled { opacity: 0.6; cursor: default; }
.chat-under { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.chat-count { font-size: 0.8125rem; color: var(--dim); }
.chat-count.warn { color: var(--neg); font-weight: 700; }
.chat-linkbtn {
  min-height: var(--tap); padding: 0 0.5rem; border: 0; background: none;
  color: var(--brand); font-weight: 700; font-size: 0.9375rem; cursor: pointer; text-decoration: underline;
}
.chat-error {
  padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  background: var(--neg-tint); color: var(--neg-ink); font-size: 0.9375rem; font-weight: 600;
}
.chat-kvkk { font-size: 0.8125rem; color: var(--dim); line-height: 1.45; }
.chat-kvkk a { color: var(--brand); font-weight: 600; }

/* Rumuz penceresi */
.chat-dlg {
  width: min(26rem, calc(100vw - 2rem)); padding: 1.25rem 1.125rem;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.chat-dlg::backdrop { background: rgba(10, 12, 16, 0.6); }
.chat-dlg form { display: grid; gap: 0.625rem; }
.chat-dlg-title { font-size: 1.25rem; font-weight: 700; }
.chat-dlg-text { font-size: 0.9375rem; color: var(--muted); line-height: 1.5; }
.chat-dlg-label { font-weight: 700; font-size: 0.9375rem; }
.chat-dlg input {
  min-height: 3rem; padding: 0 0.75rem; font: inherit; font-size: 1.0625rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.chat-dlg-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.25rem; }

.chat-window .chat-list { height: 100% !important; flex: 1; min-height: 8rem; }
.chat-window .chat-head { padding-bottom: 0.25rem; margin-bottom: 0.25rem; }
.chat-window .chat-head .view-title { display: none; }
.chat-window .chat-head .view-sub { font-size: 0.8125rem; margin: 0; }
.chat-window .chat-rules { font-size: 0.8125rem; line-height: 1.35; }
.chat-window .chat-kvkk { font-size: 0.75rem; line-height: 1.35; }

/* ---------- Yüzen ve Küçültülebilir Sohbet Penceresi ---------- */
.chat-window {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform-origin: bottom right;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

@media (min-width: 64rem) {
  .chat-window {
    right: 1.5rem;
    bottom: calc(var(--ticker-h) + 1rem);
    width: 23rem;
    height: 34rem;
    max-height: calc(100vh - var(--topbar-h) - var(--ticker-h) - 2rem);
  }
}

@media (max-width: 63.99rem) {
  .chat-window {
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    z-index: 9999;
  }
}

.chat-window[hidden] {
  display: none !important;
}

@keyframes chatPopIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-window:not([hidden]) {
  animation: chatPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Pencere başlık çubuğu */
.chat-window-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--raised);
  border-bottom: 1px solid var(--border);
  flex: none;
  user-select: none;
}
.chat-window-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}
.chat-window-icon {
  font-size: 1.0625rem;
  line-height: 1;
}
.chat-window-title-text {
  letter-spacing: -0.01em;
}
.chat-window-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.chat-window-btn {
  min-height: 44px;
  min-width: 44px;
  display: inline-grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  min-width: 1.875rem;
  min-height: 1.875rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chat-window-btn:hover {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}
#chatWindowClose:hover {
  background: var(--neg-tint);
  color: var(--neg-ink);
  border-color: var(--neg-line);
}

/* Yüzen Launcher / Dock butonu */
.chat-launcher {
  position: fixed;
  z-index: 40;
  right: 1.5rem;
  bottom: calc(var(--ticker-h) + 1rem);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  background: var(--brand-strong);
  color: #ffffff;
  border: 1px solid var(--brand-line);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
  animation: chatPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.36);
}
.chat-launcher:active {
  transform: translateY(0) scale(0.98);
}
.chat-launcher[hidden] {
  display: none !important;
}
.chat-launcher-icon {
  font-size: 1.0625rem;
  line-height: 1;
}
.chat-launcher-text {
  white-space: nowrap;
}
.chat-launcher-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.chat-launcher-badge[hidden] {
  display: none !important;
}

@media (max-width: 63.99rem) {
  .chat-launcher {
    right: 1rem;
    bottom: calc(var(--tabbar-h) + var(--ticker-h) + 0.75rem);
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-window:not([hidden]),
  .chat-launcher {
    animation: none !important;
    transition: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-list { scroll-behavior: auto; }
}

/* Onay bekleyen rumuz vb. bilgi satırı (hata değil) */
.chat-info {
  padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  background: var(--brand-subtle); color: var(--text); font-size: 0.9375rem; line-height: 1.45;
  border: 1px solid var(--brand-line);
}

/* Onay penceresi: 18 yaş, kurallar, KVKK kutuları (her satır ≥44 px dokunma alanı) */
.chat-check {
  display: flex; align-items: flex-start; gap: 0.625rem;
  min-height: var(--tap); padding: 0.5rem 0.25rem;
  font-size: 0.9375rem; line-height: 1.45; cursor: pointer;
}
.chat-check input { flex: none; width: 1.25rem; height: 1.25rem; margin: 0.0625rem 0 0; accent-color: var(--brand-strong); }
.chat-check a { color: var(--brand); font-weight: 700; }

/* Uyar-Kaldır Bildir Butonu */
.chat-report-btn {
  background: none; border: none; padding: 4px;
  color: var(--muted); cursor: pointer;
  font-size: 1rem; line-height: 1;
  opacity: 0; transition: opacity 0.2s, color 0.2s;
  margin-left: 0.5rem;
}
.chat-msg:hover .chat-report-btn, .chat-report-btn:focus { opacity: 1; }
.chat-report-btn:hover { color: var(--danger, #ff4444); }
@media (hover: none) { .chat-report-btn { opacity: 0.6; } }

/* Toast Bildirimi */
.chat-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--text);
  padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000; font-size: 0.875rem;
  animation: toast-in 0.3s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
