/* TakasOlsun — "TO" yardım balonu (to.js ile). Yalnızca .to- önekli sınıflar; site stillerine dokunmaz.
   Renkler styles.css değişkenlerinden okunur, yoksa marka değerleri kullanılır. */
.to-kok {
  --to-bordo: var(--bordo, #6B1E3A);
  --to-bordo-koyu: var(--bordo-koyu, #521429);
  --to-altin: var(--altin, #C9A227);
  --to-altin-yazi: var(--altin-yazi, #2B0D18);
  --to-zemin: var(--zemin, #FBF6EF);
  --to-kart: var(--kart, #FFFFFF);
  --to-cip: var(--cip, #EFE2D6);
  --to-cizgi: var(--cizgi, #E9DCCD);
  --to-metin: var(--metin, #3E1222);
  --to-metin2: var(--metin2, #5E5052);
  --to-kenar: var(--kenar-form, #8F7F80);
  font-family: var(--govde, "Inter", system-ui, -apple-system, "Segoe UI", sans-serif);
  color: var(--to-metin);
}
.to-kok *, .to-kok *::before, .to-kok *::after { box-sizing: border-box; }

/* Balon */
.to-balon {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 79; /* çerez bandının (80) altında: band açıkken düğmelerini örtmez */
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 2px solid var(--to-altin);
  background: var(--to-bordo);
  color: var(--to-altin);
  font: 700 1.15rem/1 var(--baslik, "Fraunces", Georgia, serif);
  letter-spacing: .02em;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(43, 13, 24, .28);
  transition: transform .15s ease, background-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.to-balon:hover { background: var(--to-bordo-koyu); transform: translateY(-1px); }
.to-balon:focus-visible { outline: 3px solid var(--to-altin); outline-offset: 3px; }
.to-balon[hidden] { display: none; }

/* Pencere */
.to-pencere {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 100;
  width: min(380px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 32px));
  height: min(600px, calc(100dvh - 32px));
  display: flex; flex-direction: column;
  background: var(--to-zemin);
  border: 1px solid var(--to-cizgi);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(43, 13, 24, .35);
  overflow: hidden;
}
.to-pencere[hidden] { display: none; }
.to-ust {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px 10px 14px;
  background: var(--to-bordo); color: #fff;
}
.to-rozet {
  flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--to-altin); color: var(--to-altin-yazi);
  font: 700 .95rem/1 var(--baslik, "Fraunces", Georgia, serif);
}
.to-baslik { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.2; color: #fff; }
.to-altbaslik { margin: 2px 0 0; font-size: .78rem; color: #F3E9DE; line-height: 1.3; }
.to-ust-metin { flex: 1 1 auto; min-width: 0; }
.to-kapat {
  flex: 0 0 auto;
  min-width: 44px; min-height: 44px;
  border: 0; border-radius: 12px;
  background: transparent; color: #fff;
  font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.to-kapat:hover { background: rgba(255, 255, 255, .12); }
.to-kapat:focus-visible { outline: 3px solid var(--to-altin); outline-offset: -3px; }

.to-akis {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 12px 6px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.to-msj {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: .94rem; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.to-msj p { margin: 0; }
.to-msj.to-bot { align-self: flex-start; background: var(--to-kart); border: 1px solid var(--to-cizgi); border-bottom-left-radius: 4px; }
.to-msj.to-ben { align-self: flex-end; background: var(--to-bordo); color: #fff; border-bottom-right-radius: 4px; }
.to-msj a { color: var(--to-bordo); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.to-msj.to-ben a { color: #fff; }
.to-msj a:focus-visible { outline: 2px solid var(--to-bordo); outline-offset: 2px; border-radius: 3px; }
.to-link {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; margin-top: 6px; padding: 0 2px;
}
.to-kaynak { display: block; margin-top: 4px; font-size: .72rem; color: var(--to-metin2); }

.to-cipler { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.to-cip {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--to-cizgi); border-radius: 999px;
  background: var(--to-cip); color: var(--to-metin);
  font: inherit; font-size: .86rem; line-height: 1.25; text-align: left;
  cursor: pointer;
}
.to-cip:hover { border-color: var(--to-bordo); }
.to-cip:focus-visible { outline: 3px solid var(--to-bordo); outline-offset: 2px; }

.to-yaziyor { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--to-kart); border: 1px solid var(--to-cizgi); border-radius: 14px; }
.to-yaziyor span { width: 7px; height: 7px; border-radius: 50%; background: var(--to-metin2); animation: to-nokta 1s infinite ease-in-out; }
.to-yaziyor span:nth-child(2) { animation-delay: .15s; }
.to-yaziyor span:nth-child(3) { animation-delay: .3s; }
@keyframes to-nokta { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.to-not {
  margin: 0; padding: 6px 14px 0;
  font-size: .72rem; line-height: 1.35; color: var(--to-metin2);
}
.to-form {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--to-cizgi);
  background: var(--to-kart);
}
.to-girdi-kap { flex: 1 1 auto; min-width: 0; }
.to-girdi {
  width: 100%; min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--to-kenar); border-radius: 12px;
  background: #fff; color: var(--to-metin);
  font: inherit; font-size: 16px; /* iOS yakınlaştırmasını önler */
}
.to-girdi:focus-visible { outline: 3px solid var(--to-altin); outline-offset: 1px; border-color: var(--to-bordo); }
.to-sayac { display: block; margin-top: 2px; font-size: .7rem; color: var(--to-metin2); text-align: right; }
.to-gonder {
  flex: 0 0 auto;
  min-width: 44px; min-height: 44px;
  padding: 0 14px;
  border: 0; border-radius: 12px;
  background: var(--to-altin); color: var(--to-altin-yazi);
  font: inherit; font-weight: 700; cursor: pointer;
  margin-bottom: 18px; /* sayaç satırıyla hizalı */
}
.to-gonder:hover { background: var(--altin-acik, #DDB94A); }
.to-gonder:focus-visible { outline: 3px solid var(--to-bordo); outline-offset: 2px; }
.to-gonder:disabled { opacity: .55; cursor: default; }

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

/* Mobil: alt menünün üstünde balon, tam ekran pencere */
@media (max-width: 720px) {
  .to-balon { bottom: calc(76px + env(safe-area-inset-bottom)); right: calc(12px + env(safe-area-inset-right)); }
  .to-pencere {
    inset: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    border-radius: 0; border: 0;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .to-msj { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .to-balon { transition: none; }
  .to-balon:hover { transform: none; }
  .to-yaziyor span { animation: none; opacity: .7; }
}
@media (forced-colors: active) {
  .to-balon, .to-pencere, .to-msj, .to-cip, .to-girdi, .to-gonder { border: 1px solid CanvasText; }
}
@media print { .to-kok { display: none !important; } }

/* Site entegrasyonu (styles.css ile uyum): alt menü ≤1080 px'te görünür; çerez bandı alt menünün üstünde,
   yüksekliği --cerez-h; güncelleme bandı 84 px'te ortada. Balon bunların hiçbirinin üstüne binmez. */
@media (max-width: 1080px) {
  .to-balon { bottom: calc(76px + env(safe-area-inset-bottom)); right: calc(12px + env(safe-area-inset-right)); }
  body.cerez-acik .to-balon { bottom: calc(88px + var(--cerez-h, 160px) + env(safe-area-inset-bottom)); }
  body:has(> .guncelleme-bant) .to-balon { display: none; }
  body.klavye-acik .to-balon { display: none; }
}
/* Filtre paneli, mobil menü ve site diyalogları açıkken balon gizli (onların düğmelerini örtmesin) */
body.filtre-acik .to-balon, body.menu-acik .to-balon, html.dialog-acik .to-balon { display: none; }
