/* ============================================================
   TalkTheBlog — Floating Voice Reader
   Colors: bg #efe2c3 | text #663425 | accent #663425
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── Reset scoped to our container ── */
#ttb-container *,
#ttb-container *::before,
#ttb-container *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ── Root container ── */
#ttb-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

/* ── FAB (Floating Action Button) ── */
#ttb-fab {
  pointer-events: all;
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #663425;
  color: #efe2c3;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 16px rgba(102, 52, 37, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.2);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
  outline: none;
  flex-shrink: 0;
}

#ttb-fab:hover {
  transform: scale(1.08);
  box-shadow:
    0 6px 22px rgba(102, 52, 37, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.25);
}

#ttb-fab:active {
  transform: scale(0.95);
}

#ttb-fab.ttb-fab--active {
  background: #7a3e2b;
}

/* Pulsing ring when speaking */
.ttb-fab-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(102, 52, 37, 0.5);
  animation: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#ttb-fab.ttb-fab--speaking .ttb-fab-ring {
  opacity: 1;
  animation: ttb-pulse 1.4s ease-in-out infinite;
}

#ttb-fab.ttb-fab--listening .ttb-fab-ring {
  opacity: 1;
  border-color: rgba(200, 50, 50, 0.7);
  animation: ttb-pulse 0.9s ease-in-out infinite;
}

@keyframes ttb-pulse {
  0%   { transform: scale(1);   opacity: 0.8; }
  50%  { transform: scale(1.25); opacity: 0.3; }
  100% { transform: scale(1);   opacity: 0.8; }
}

/* ── Panel ── */
#ttb-panel {
  pointer-events: all;
  width: 320px;
  background: #efe2c3;
  border: 1.5px solid rgba(102, 52, 37, 0.2);
  border-radius: 16px;
  box-shadow:
    0 8px 32px rgba(102, 52, 37, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /* Hidden by default */
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition:
    opacity 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom right;
}

#ttb-panel.ttb-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Panel Header ── */
#ttb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  background: #663425;
  color: #efe2c3;
}

#ttb-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #efe2c3;
}

#ttb-title svg {
  flex-shrink: 0;
  opacity: 0.9;
}

#ttb-minimize {
  background: transparent;
  border: none;
  color: #efe2c3;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  opacity: 0.8;
}

#ttb-minimize:hover {
  background: rgba(239, 226, 195, 0.15);
  opacity: 1;
}

/* ── Status Bar ── */
#ttb-status {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: #663425;
  background: rgba(102, 52, 37, 0.07);
  border-bottom: 1px solid rgba(102, 52, 37, 0.1);
  min-height: 34px;
  display: flex;
  align-items: center;
  letter-spacing: 0.01em;
  transition: color 0.2s ease;
}

#ttb-status.ttb-thinking {
  color: #7a3e2b;
  animation: ttb-blink 1s ease infinite;
}

@keyframes ttb-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Waveform ── */
#ttb-wave {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 28px;
  padding: 4px 14px;
  background: rgba(102, 52, 37, 0.04);
  border-bottom: 1px solid rgba(102, 52, 37, 0.08);
}

.ttb-bar {
  display: block;
  width: 4px;
  background: rgba(102, 52, 37, 0.25);
  border-radius: 2px;
  height: 4px;
  transition: background 0.3s ease;
}

#ttb-wave.ttb-wave--active .ttb-bar {
  background: #663425;
  animation: ttb-wave-bar 0.8s ease-in-out infinite;
}

#ttb-wave.ttb-wave--active .ttb-bar:nth-child(1) { animation-delay: 0.0s; }
#ttb-wave.ttb-wave--active .ttb-bar:nth-child(2) { animation-delay: 0.1s; }
#ttb-wave.ttb-wave--active .ttb-bar:nth-child(3) { animation-delay: 0.2s; }
#ttb-wave.ttb-wave--active .ttb-bar:nth-child(4) { animation-delay: 0.1s; }
#ttb-wave.ttb-wave--active .ttb-bar:nth-child(5) { animation-delay: 0.0s; }

@keyframes ttb-wave-bar {
  0%, 100% { height: 4px; }
  50%       { height: 18px; }
}

/* ── Chat Log ── */
#ttb-log {
  flex: 1;
  min-height: 110px;
  max-height: 160px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 52, 37, 0.25) transparent;
}

#ttb-log::-webkit-scrollbar {
  width: 4px;
}
#ttb-log::-webkit-scrollbar-thumb {
  background: rgba(102, 52, 37, 0.25);
  border-radius: 2px;
}

.ttb-log-entry {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: ttb-fade-in 0.2s ease;
}

@keyframes ttb-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ttb-log-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(102, 52, 37, 0.5);
}

.ttb-log-user .ttb-log-label  { color: rgba(102, 52, 37, 0.6); }
.ttb-log-assistant .ttb-log-label { color: rgba(102, 52, 37, 0.45); }

.ttb-log-text {
  font-size: 12.5px;
  color: #663425;
  line-height: 1.5;
  background: rgba(102, 52, 37, 0.07);
  border-radius: 8px;
  padding: 5px 9px;
}

.ttb-log-user .ttb-log-text {
  background: rgba(102, 52, 37, 0.13);
  align-self: flex-end;
  text-align: right;
}

/* ── Section Chips ── */
#ttb-sections {
  padding: 8px 12px 6px;
  border-top: 1px solid rgba(102, 52, 37, 0.1);
}

#ttb-sections-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(102, 52, 37, 0.5);
  margin-bottom: 5px;
}

#ttb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ttb-chip {
  font-size: 11px;
  font-weight: 500;
  color: #663425;
  background: rgba(102, 52, 37, 0.1);
  border: 1px solid rgba(102, 52, 37, 0.18);
  border-radius: 20px;
  padding: 3px 10px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.1s ease;
  outline: none;
  white-space: nowrap;
}

.ttb-chip:hover {
  background: #663425;
  color: #efe2c3;
  transform: translateY(-1px);
}

.ttb-chip:active {
  transform: translateY(0);
}

/* ── Controls Row ── */
#ttb-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px 6px;
  border-top: 1px solid rgba(102, 52, 37, 0.1);
}

#ttb-controls button {
  border: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
  outline: none;
  color: #efe2c3;
}

#ttb-controls button:hover {
  transform: scale(1.1);
}

#ttb-controls button:active {
  transform: scale(0.93);
}

/* Mic button */
#ttb-mic {
  width: 46px;
  height: 46px;
  background: #663425;
  box-shadow: 0 2px 10px rgba(102, 52, 37, 0.35);
}

#ttb-mic.ttb-mic--listening {
  background: #c0392b;
  box-shadow:
    0 0 0 4px rgba(192, 57, 43, 0.25),
    0 2px 10px rgba(192, 57, 43, 0.5);
  animation: ttb-mic-pulse 1s ease infinite;
}

@keyframes ttb-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.25), 0 2px 10px rgba(192, 57, 43, 0.5); }
  50%        { box-shadow: 0 0 0 8px rgba(192, 57, 43, 0.15), 0 2px 10px rgba(192, 57, 43, 0.5); }
}

/* Pause button */
#ttb-pause {
  width: 36px;
  height: 36px;
  background: rgba(102, 52, 37, 0.7);
}

#ttb-pause:hover {
  background: rgba(102, 52, 37, 0.9);
}

/* Stop button */
#ttb-stop {
  width: 36px;
  height: 36px;
  background: rgba(102, 52, 37, 0.5);
}

#ttb-stop:hover {
  background: rgba(102, 52, 37, 0.8);
}

/* ── Text Input Row ── */
#ttb-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 12px;
}

#ttb-input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid rgba(102, 52, 37, 0.22);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
  color: #663425;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#ttb-input::placeholder {
  color: rgba(102, 52, 37, 0.38);
}

#ttb-input:focus {
  border-color: rgba(102, 52, 37, 0.55);
  box-shadow: 0 0 0 3px rgba(102, 52, 37, 0.1);
  background: rgba(255, 255, 255, 0.75);
}

#ttb-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #663425;
  color: #efe2c3;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
  outline: none;
}

#ttb-send:hover {
  transform: scale(1.1);
  background: #7a3e2b;
}

#ttb-send:active {
  transform: scale(0.92);
}

/* ── Responsive ── */
@media (max-width: 400px) {
  #ttb-container {
    bottom: 12px;
    right: 12px;
  }
  #ttb-panel {
    width: calc(100vw - 24px);
  }
}
