/* Escape to Magic Chat — passport-inspired floating bubble */

.etm-chat-root {
  --etm-red: #ed4441;
  --etm-red-deep: #e02b20;
  --etm-navy: #000054;
  --etm-navy-mid: #0a0a6a;
  --etm-gold: #c9a227;
  --etm-cream: #f6f1e7;
  --etm-paper: #fffdf8;
  --etm-ink: #1a1a32;
  --etm-muted: #5c5c78;
  --etm-shadow: 0 12px 40px rgba(0, 0, 84, 0.28);
  --etm-font-head: Oswald, "Arial Narrow", Impact, sans-serif;
  --etm-font-body: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999999;
  font-family: var(--etm-font-body);
  color: var(--etm-ink);
  line-height: 1.45;
  pointer-events: none;
}

.etm-chat-root *,
.etm-chat-root *::before,
.etm-chat-root *::after {
  box-sizing: border-box;
}

.etm-chat-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.etm-chat-launcher,
.etm-chat-panel,
.etm-chat-close,
.etm-chat-send,
.etm-chat-input {
  pointer-events: auto;
}

.etm-chat-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin: 0;
  padding: 0;
  border: 3px solid var(--etm-navy);
  border-radius: 50%;
  background: linear-gradient(180deg, var(--etm-red) 0%, var(--etm-red-deep) 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--etm-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.etm-chat-launcher svg {
  width: 26px;
  height: 26px;
}

.etm-chat-launcher:hover,
.etm-chat-launcher:focus-visible {
  background: linear-gradient(180deg, #f25a57 0%, var(--etm-red) 100%);
  outline: 3px solid var(--etm-gold);
  outline-offset: 3px;
}

.etm-chat-launcher-pulse {
  position: absolute;
  inset: -6px;
  border: 2px solid var(--etm-red);
  border-radius: 50%;
  opacity: 0;
  animation: etm-chat-pulse 2.8s ease-out infinite;
  pointer-events: none;
}

.etm-chat-root .etm-chat-launcher[aria-expanded="true"] .etm-chat-launcher-pulse {
  display: none;
}

@keyframes etm-chat-pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.55;
  }
  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

.etm-chat-panel {
  display: flex;
  flex-direction: column;
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(380px, calc(100vw - 32px));
  height: min(540px, calc(100vh - 120px));
  overflow: hidden;
  background: var(--etm-paper);
  border: 2px solid var(--etm-navy);
  border-radius: 6px 6px 4px 4px;
  box-shadow: var(--etm-shadow);
}

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

.etm-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background:
    linear-gradient(135deg, rgba(201, 162, 39, 0.12) 0 2px, transparent 2px) 0 0 / 10px 10px,
    linear-gradient(180deg, var(--etm-navy) 0%, var(--etm-navy-mid) 100%);
  color: #fff;
  border-bottom: 3px solid var(--etm-red);
}

.etm-chat-header-mark {
  flex: 0 0 auto;
}

.etm-chat-stamp {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--etm-gold);
  border-radius: 50%;
  font-family: var(--etm-font-head);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--etm-gold);
  transform: rotate(-8deg);
}

.etm-chat-header-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.etm-chat-title {
  margin: 0;
  font-family: var(--etm-font-head);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.15;
  color: #fff;
}

.etm-chat-kicker {
  margin: 2px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d8d4c4;
}

.etm-chat-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.etm-chat-close:hover,
.etm-chat-close:focus-visible {
  color: var(--etm-gold);
  outline: 2px solid var(--etm-gold);
  outline-offset: 2px;
}

.etm-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px;
  background:
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 11px,
      rgba(0, 0, 84, 0.015) 11px,
      rgba(0, 0, 84, 0.015) 12px
    ),
    var(--etm-cream);
}

.etm-chat-row {
  display: flex;
  margin-bottom: 10px;
}

.etm-chat-row--assistant {
  justify-content: flex-start;
}

.etm-chat-row--visitor {
  justify-content: flex-end;
}

.etm-chat-bubble {
  max-width: 86%;
  padding: 10px 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.etm-chat-bubble--assistant {
  background: #fff;
  color: var(--etm-ink);
  border: 1px solid #e4dcc8;
  border-left: 3px solid var(--etm-red);
  border-radius: 2px 12px 12px 12px;
}

.etm-chat-bubble--visitor {
  background: var(--etm-navy);
  color: #fff;
  border-radius: 12px 2px 12px 12px;
}

.etm-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid #e4dcc8;
}

.etm-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #cfc6b2;
  border-radius: 4px;
  background: var(--etm-paper);
  color: var(--etm-ink);
  font-family: var(--etm-font-body);
  font-size: 16px;
}

.etm-chat-input:focus {
  outline: 2px solid var(--etm-navy);
  outline-offset: 1px;
  border-color: var(--etm-navy);
}

.etm-chat-send {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: var(--etm-red);
  color: #fff;
  cursor: pointer;
}

.etm-chat-send svg {
  width: 20px;
  height: 20px;
}

.etm-chat-send:hover,
.etm-chat-send:focus-visible {
  background: var(--etm-red-deep);
  outline: 2px solid var(--etm-navy);
  outline-offset: 2px;
}

.etm-chat-send:disabled {
  opacity: 0.55;
  cursor: wait;
}

@media (max-width: 480px) {
  .etm-chat-root {
    right: 12px;
    bottom: 12px;
  }

  .etm-chat-panel {
    position: fixed;
    right: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
    height: min(70vh, calc(100vh - 100px));
    max-height: 70vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .etm-chat-launcher-pulse {
    animation: none;
    display: none;
  }

  .etm-chat-launcher,
  .etm-chat-panel,
  .etm-chat-close,
  .etm-chat-send {
    transition: none;
  }
}


/* Dedicated advertised page: [etm_chat] shortcode */
.etm-chat-page-mount {
  width: 100%;
  min-height: min(72vh, 720px);
}

body.etm-chat-page .etm-chat-page-mount {
  min-height: calc(100vh - 180px);
}

.etm-chat-root.etm-chat-root--page {
  position: relative;
  right: auto;
  bottom: auto;
  width: 100%;
  height: 100%;
  min-height: min(72vh, 720px);
  pointer-events: auto;
}

.etm-chat-root--page .etm-chat-launcher,
.etm-chat-root--page .etm-chat-close {
  display: none !important;
}

.etm-chat-root--page .etm-chat-panel {
  position: relative;
  right: auto;
  bottom: auto;
  width: 100%;
  height: min(72vh, 720px);
  min-height: 480px;
  max-width: 720px;
  margin: 0 auto;
}

@media (max-width: 480px) {
  .etm-chat-root--page .etm-chat-panel {
    position: relative;
    right: auto;
    bottom: auto;
    width: 100%;
    height: calc(100vh - 140px);
    max-height: none;
  }
}
