/* Ask NSG widget. Layout matches the Ask Schneide chat box.
   Colors and fonts match nationalsharpenersguild.com
   (paper, steel, brass, ink; Fraunces + Source Sans 3, which the site already loads).
   No fonts, libraries, or CDNs of its own. */

#nsg-chat,
#nsg-chat * {
  box-sizing: border-box;
}

#nsg-chat {
  --nsg-paper: #f3efe6;
  --nsg-ink: #1c1915;
  --nsg-steel: #1e3a40;
  --nsg-steel-deep: #14282c;
  --nsg-brass: #8d5e2a;
  --nsg-brass-soft: #f4e7d4;
  --nsg-line: #ddd4c6;
  --nsg-muted: #5c564c;
  --nsg-sans: "Source Sans 3", ui-sans-serif, system-ui, sans-serif;
  --nsg-display: "Fraunces", ui-serif, Georgia, serif;
  font-family: var(--nsg-sans);
  color: var(--nsg-ink);
  line-height: 1.45;
}

#nsg-chat button,
#nsg-chat input {
  font-family: var(--nsg-sans);
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

#nsg-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--nsg-steel);
  color: var(--nsg-paper);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(20, 40, 44, 0.28);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#nsg-chat-launcher:hover,
#nsg-chat-launcher:focus-visible {
  background: var(--nsg-brass);
  outline: none;
}

#nsg-chat-launcher:focus-visible {
  box-shadow: 0 0 0 3px var(--nsg-paper), 0 0 0 5px var(--nsg-brass);
}

#nsg-chat-launcher[aria-expanded="true"] {
  background: var(--nsg-steel-deep);
}

#nsg-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 1000;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: calc(100vh - 112px);
  max-height: 640px;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: var(--nsg-ink);
  border: 2px solid var(--nsg-steel-deep);
  box-shadow: 0 0 0 4px rgba(243, 239, 230, 0.85), 0 22px 56px rgba(20, 40, 44, 0.45), 0 6px 16px rgba(20, 40, 44, 0.28);
  overflow: hidden;
}

#nsg-chat-panel[hidden] {
  display: none !important;
}

.nsg-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--nsg-steel-deep);
  color: var(--nsg-paper);
  padding: 14px 16px 12px 20px;
  flex: 0 0 auto;
}

.nsg-chat-header h2 {
  font-family: var(--nsg-display);
  font-size: 26px;
  font-weight: 520;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--nsg-paper);
  line-height: 1.15;
}

.nsg-chat-label {
  margin: 4px 0 0;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--nsg-brass-soft);
  font-weight: 600;
}

#nsg-chat-close {
  width: 36px;
  height: 36px;
  margin: -4px -4px 0 0;
  border: 1px solid rgba(243, 239, 230, 0.25);
  border-radius: 0;
  background: transparent;
  color: var(--nsg-paper);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

#nsg-chat-close:hover,
#nsg-chat-close:focus-visible {
  background: var(--nsg-brass);
  border-color: var(--nsg-brass);
  outline: none;
}

#nsg-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 16px 8px;
  background: var(--nsg-paper);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nsg-msg {
  max-width: 92%;
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 12px;
  border: 1px solid var(--nsg-line);
  overflow-wrap: anywhere;
}

.nsg-msg p {
  margin: 0 0 8px;
  color: inherit;
}

.nsg-msg p:last-child {
  margin-bottom: 0;
}

.nsg-msg a {
  color: var(--nsg-brass);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.nsg-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--nsg-ink);
}

.nsg-msg-user {
  align-self: flex-end;
  background: var(--nsg-steel-deep);
  color: var(--nsg-paper);
  border-color: var(--nsg-steel-deep);
}

.nsg-msg-user a {
  color: var(--nsg-paper);
}

#nsg-chat .nsg-msg-action {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-top: 10px;
  padding: 0 14px;
  background: var(--nsg-steel);
  color: var(--nsg-paper);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

#nsg-chat .nsg-msg-action:hover,
#nsg-chat .nsg-msg-action:focus-visible {
  background: var(--nsg-brass);
  outline: none;
}

.nsg-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
  min-height: 44px;
}

.nsg-typing span:not(.nsg-sr-only) {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--nsg-muted);
  animation: nsg-dot 1s ease-in-out infinite;
}

.nsg-typing span:not(.nsg-sr-only):nth-child(2) {
  animation-delay: 0.15s;
}

.nsg-typing span:not(.nsg-sr-only):nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes nsg-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nsg-typing span:not(.nsg-sr-only) {
    animation: none;
    opacity: 0.7;
  }
}

.nsg-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px 4px;
  background: #fff;
  border-top: 1px solid var(--nsg-line);
  flex: 0 0 auto;
}

.nsg-chip {
  font-family: var(--nsg-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.3;
  padding: 7px 11px;
  border: 1px solid var(--nsg-line);
  border-radius: 0;
  background: var(--nsg-paper);
  color: var(--nsg-ink);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.nsg-chip:hover,
.nsg-chip:focus-visible {
  background: var(--nsg-brass);
  border-color: var(--nsg-brass);
  color: var(--nsg-paper);
  outline: none;
}

#nsg-chat-form {
  display: flex;
  gap: 8px;
  padding: 6px 16px 8px;
  background: #fff;
  flex: 0 0 auto;
}

#nsg-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--nsg-line);
  border-radius: 0;
  background: var(--nsg-paper);
  color: var(--nsg-ink);
  font-family: var(--nsg-sans);
  font-size: 14px;
}

#nsg-chat-input::placeholder {
  color: var(--nsg-muted);
}

#nsg-chat-input:focus {
  outline: none;
  border-color: var(--nsg-steel-deep);
  background: #fff;
}

#nsg-chat-send {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--nsg-steel-deep);
  border-radius: 0;
  background: var(--nsg-steel-deep);
  color: var(--nsg-paper);
  font-family: var(--nsg-sans);
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

#nsg-chat-send:hover,
#nsg-chat-send:focus-visible {
  background: var(--nsg-brass);
  border-color: var(--nsg-brass);
  outline: none;
}

#nsg-chat-send:disabled,
#nsg-chat-input:disabled,
.nsg-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#nsg-chat-send:disabled:hover {
  background: var(--nsg-steel-deep);
  border-color: var(--nsg-steel-deep);
}

.nsg-chip:disabled:hover {
  background: var(--nsg-paper);
  border-color: var(--nsg-line);
  color: var(--nsg-ink);
}

.nsg-chat-status {
  margin: 0;
  padding: 0 16px 4px;
  background: #fff;
  color: var(--nsg-muted);
  font-size: 11px;
  text-align: right;
  flex: 0 0 auto;
}

.nsg-chat-footer {
  margin: 0;
  padding: 0 16px 12px;
  background: #fff;
  color: var(--nsg-muted);
  font-size: 11px;
  line-height: 1.45;
  flex: 0 0 auto;
}

.nsg-chat-footer a {
  color: var(--nsg-brass);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.nsg-chat-footer a:hover,
.nsg-chat-footer a:focus-visible {
  color: var(--nsg-steel-deep);
}

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

@media (max-width: 480px) {
  #nsg-chat-launcher {
    right: 16px;
    bottom: 16px;
  }

  /* Inset full-screen on phones, matching the Schneide format (JS also
     fits the panel to visualViewport so the keyboard does not cover it). */
  #nsg-chat-panel {
    right: 8px;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
  }

  #nsg-chat-launcher[aria-expanded="true"] {
    visibility: hidden;
  }

  /* Keep the footer clear of the iPhone home bar. */
  .nsg-chat-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* 16px stops iOS from zooming the page when the field is focused. */
  #nsg-chat-input {
    font-size: 16px;
  }
}

/* Weekly limit reached: hide the suggestion chips; the Contact button is in the message. */
#nsg-chat-panel.nsg-limited .nsg-chat-chips {
  display: none;
}
