/* Ask the Town Clerk: the FAQ chat. Uses the host page's colours when it has them (the website's
   --ink, --mustard, --red, --snow; the game's --paper, --yellow) and its own otherwise. */
.tc {
  --tc-ink: var(--ink, #111111);
  --tc-paper: var(--paper, #fffaf0);
  --tc-snow: var(--snow, #ffffff);
  --tc-yellow: var(--mustard, var(--yellow, #f1c232));
  --tc-red: var(--red, #d3202a);
  --tc-sky: #87b6c0;
  --tc-muted: #3b4a50;
  --tc-display: var(--display, "Titan One", "Bowlby", "Arial Black", "Trebuchet MS", sans-serif);
  --tc-body: var(--body, "Archivo", "Trebuchet MS", system-ui, sans-serif);
  position: fixed; bottom: 14px; right: 14px; z-index: 60; font-family: var(--tc-body); color: var(--tc-ink);
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none;
}
.tc-left { right: auto; left: 14px; align-items: flex-start; }
.tc > * { pointer-events: auto; }
.tc.tc-off { display: none; }

.tc-face { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; background: var(--tc-sky); border: 3px solid var(--tc-ink); flex: none; }
.tc-face-text { display: inline-flex; align-items: center; justify-content: center; font: 900 14px/1 var(--tc-display); color: var(--tc-ink); }

.tc-launch {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 4px 16px 4px 4px; cursor: pointer;
  background: var(--tc-yellow); color: var(--tc-ink); border: 3px solid var(--tc-ink); border-radius: 999px;
  box-shadow: 4px 4px 0 var(--tc-ink); font: 800 15px/1 var(--tc-body); text-transform: uppercase; letter-spacing: .04em;
  transform: rotate(-1.5deg); transition: transform .15s;
}
.tc-launch:hover, .tc-launch:focus-visible { transform: rotate(-1.5deg) translateY(-2px); }
.tc-launch:active { transform: rotate(-1.5deg) translate(2px, 2px); box-shadow: 2px 2px 0 var(--tc-ink); }
.tc-open .tc-launch { display: none; }

.tc-panel {
  width: min(380px, calc(100vw - 28px)); max-height: min(640px, calc(100vh - 28px)); display: flex; flex-direction: column;
  background: var(--tc-paper); background-image: radial-gradient(rgba(0,0,0,0.04) 1px, transparent 1px); background-size: 5px 5px;
  color: var(--tc-ink); border: 3px solid var(--tc-ink); border-radius: 8px; box-shadow: 8px 8px 0 var(--tc-ink), 0 18px 40px rgba(0,0,0,0.35);
  overflow: hidden; animation: tc-in .22s ease-out;
}
.tc-panel[hidden] { display: none; }
@keyframes tc-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.tc-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 10px; background: var(--tc-sky); border-bottom: 3px solid var(--tc-ink); }
.tc-head .tc-face { width: 52px; height: 52px; }
.tc-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tc-tape {
  align-self: flex-start; font: 900 15px/1 var(--tc-display); text-transform: uppercase; letter-spacing: .05em; color: var(--tc-ink);
  background: var(--tc-yellow); padding: 6px 10px 5px; border: 2px solid var(--tc-ink); box-shadow: 3px 3px 0 var(--tc-ink); transform: rotate(-2deg);
}
.tc-title small { font-size: 12px; font-weight: 800; color: var(--tc-ink); line-height: 1.25; }
.tc-close { flex: none; width: 34px; height: 34px; margin: 0; padding: 0; cursor: pointer; background: var(--tc-snow); color: var(--tc-ink); border: 2px solid var(--tc-ink); border-radius: 50%; font: 900 22px/1 var(--tc-body); box-shadow: 2px 2px 0 var(--tc-ink); }
.tc-close:hover { background: var(--tc-red); color: var(--tc-snow); }

.tc-log { flex: 1 1 auto; min-height: 160px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.tc-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.tc-msg .tc-face { width: 30px; height: 30px; border-width: 2px; }
.tc-bubble { padding: 9px 12px; border: 2px solid var(--tc-ink); border-radius: 12px; font-size: 14px; line-height: 1.4; max-width: calc(100% - 44px); overflow-wrap: anywhere; }
.tc-bot .tc-bubble { background: var(--tc-snow); border-bottom-left-radius: 3px; box-shadow: 3px 3px 0 var(--tc-ink); }
.tc-me { justify-content: flex-end; }
.tc-me .tc-bubble { background: var(--tc-ink); color: var(--tc-snow); border-bottom-right-radius: 3px; max-width: 85%; }
.tc-bubble a { color: var(--tc-red); font-weight: 800; }
.tc-me .tc-bubble a { color: var(--tc-yellow); }
.tc-dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.tc-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--tc-ink); animation: tc-dot 1s infinite; }
.tc-dots i:nth-child(2) { animation-delay: .15s; } .tc-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes tc-dot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.tc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.tc-chips:empty { display: none; }
.tc-chip { margin: 0; padding: 5px 10px; cursor: pointer; background: var(--tc-snow); color: var(--tc-ink); border: 2px solid var(--tc-ink); border-radius: 999px; font: 800 12px/1.2 var(--tc-body); text-align: left; }
.tc-chip:hover, .tc-chip:focus-visible { background: var(--tc-yellow); }

.tc-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 3px solid var(--tc-ink); background: var(--tc-paper); }
.tc-in { flex: 1; min-width: 0; margin: 0; padding: 10px 12px; font: 500 15px/1.2 var(--tc-body); color: var(--tc-ink); background: var(--tc-snow); border: 2px solid var(--tc-ink); border-radius: 8px; }
.tc-in:focus { outline: 3px solid var(--tc-red); outline-offset: 2px; }
.tc-send { margin: 0; padding: 0 16px; cursor: pointer; background: var(--tc-red); color: var(--tc-snow); border: 2px solid var(--tc-ink); border-radius: 8px; font: 900 15px/1 var(--tc-display); text-transform: uppercase; letter-spacing: .05em; box-shadow: 3px 3px 0 var(--tc-ink); }
.tc-send:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--tc-ink); }
.tc-fine { margin: 0; padding: 6px 12px 10px; font-size: 11px; line-height: 1.35; color: var(--tc-muted); }
.tc-fine a { color: var(--tc-red); font-weight: 800; }

@media (max-width: 520px) {
  .tc, .tc-left { left: 0; right: 0; bottom: 0; align-items: stretch; padding: 0 10px 10px; }
  .tc-launch { align-self: flex-end; }
  .tc-left .tc-launch { align-self: flex-start; }
  .tc-launch-label { display: none; }
  .tc-launch { padding: 4px; border-radius: 50%; }
  .tc-panel { width: 100%; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
}
@media (max-height: 480px) {
  .tc-launch-label { display: none; }
  .tc-launch { padding: 2px; border-radius: 50%; }
  .tc-log { min-height: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  .tc-panel { animation: none; }
  .tc-dots i { animation: none; opacity: .6; }
}
