/* Help-page Rubiyomi Support: body-level fixed panel, red accent glow. */

.help-support {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 80;
  width: min(28rem, calc(100vw - 32px));
  font-family: var(--sans);
  pointer-events: none;
}

.help-support > * {
  pointer-events: auto;
}

.help-support-launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  margin-left: auto;
  float: right;
  clear: both;
  padding: 11px 16px;
  color: var(--text);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(195, 69, 54, 0.28), transparent 55%),
    var(--surface);
  border: 1px solid rgba(237, 133, 117, 0.35);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(195, 69, 54, 0.12),
    0 8px 28px rgba(0, 0, 0, 0.35),
    0 0 24px rgba(195, 69, 54, 0.18);
  transform: translateY(0);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.help-support-launcher:hover {
  border-color: rgba(237, 133, 117, 0.55);
  box-shadow:
    0 0 0 1px rgba(195, 69, 54, 0.2),
    0 10px 32px rgba(0, 0, 0, 0.4),
    0 0 32px rgba(195, 69, 54, 0.28);
  transform: translateY(-2px);
}

.help-support-launcher:active {
  transform: translateY(0) scale(0.98);
}

.help-support-launcher:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.help-support.is-open .help-support-launcher {
  display: none;
}

.help-support-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: min(36rem, calc(100vh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  max-height: min(36rem, calc(100vh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  padding: 12px;
  color: var(--text);
  background:
    radial-gradient(90% 70% at 100% 0%, rgba(195, 69, 54, 0.22), transparent 50%),
    var(--surface);
  border: 1px solid rgba(237, 133, 117, 0.38);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(195, 69, 54, 0.14),
    0 16px 40px rgba(0, 0, 0, 0.45),
    0 0 40px rgba(195, 69, 54, 0.2);
  transform-origin: bottom right;
}

.help-support-panel[hidden] {
  display: none;
}

.help-support.is-open .help-support-panel:not([hidden]) {
  animation: help-panel-in 180ms ease-out;
}

.help-support-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.help-support-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.help-support-close {
  margin: 0;
  padding: 4px 8px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.help-support-close:hover {
  color: var(--text);
  border-color: var(--rule);
}

.help-support-close:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.help-chat {
  flex: 1 1 auto;
  min-height: 12rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(237, 133, 117, 0.28);
  border-radius: 8px;
  background: rgba(16, 16, 15, 0.72);
  box-shadow: inset 0 0 24px rgba(195, 69, 54, 0.06);
}

.help-transcript {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.help-turn {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule-soft);
}

.help-turn:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.help-turn-greeting {
  animation: help-greeting-in 220ms ease-out;
}

.help-turn-label {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.help-turn-body {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  white-space: pre-wrap;
}

.help-typing-caret {
  display: inline-block;
  width: 0.08em;
  height: 1em;
  margin-left: 0.06em;
  vertical-align: -0.12em;
  background: var(--accent-text, #ed8575);
  animation: help-caret 900ms steps(1, end) infinite;
}

.help-turn-body p {
  margin: 0 0 0.65em;
  color: var(--text);
}

.help-turn-body p:last-child {
  margin-bottom: 0;
}

.help-sources {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.help-sources ul {
  margin: 4px 0 0;
  padding-left: 16px;
}

.help-composer {
  margin: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.help-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.help-composer textarea {
  display: block;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  resize: none;
  box-sizing: border-box;
  min-height: 44px;
  max-height: 8em;
  margin: 0;
  padding: 10px 11px;
  color: var(--text);
  background: var(--page-bg);
  border: 1px solid rgba(237, 133, 117, 0.3);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  overflow-y: auto;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.help-composer textarea:disabled {
  opacity: 0.6;
}

.help-composer textarea:focus-visible {
  outline: none;
  border-color: rgba(237, 133, 117, 0.55);
  box-shadow: 0 0 0 2px rgba(195, 69, 54, 0.25);
}

.help-send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  color: #fff;
  background: var(--accent);
  border: 1px solid rgba(237, 133, 117, 0.55);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(195, 69, 54, 0.35);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.help-send:hover {
  background: #d14f3e;
  box-shadow: 0 0 22px rgba(195, 69, 54, 0.45);
}

.help-send:active {
  transform: scale(0.96);
}

.help-send:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

.help-send:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.help-send-icon {
  display: block;
  font-size: 18px;
  line-height: 1;
  font-weight: 600;
}

.help-support-note {
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(10px, 2.1vw, 12px);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.help-support-note a {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.help-support-note a:hover {
  color: var(--text);
}

.help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 0;
}

.help-reset {
  margin: 0;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.help-reset:hover {
  color: var(--text);
}

.help-reset[hidden] {
  display: none;
}

.help-status {
  min-height: 0;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.help-status:empty {
  display: none;
}

.help-status.is-error {
  color: var(--accent-text);
}

@keyframes help-panel-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes help-caret {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .help-support-launcher,
  .help-support-close,
  .help-composer textarea,
  .help-send {
    transition: none;
  }

  .help-support.is-open .help-support-panel:not([hidden]),
  .help-turn-greeting {
    animation: none;
  }

  .help-typing-caret {
    animation: none;
    opacity: 1;
  }

  .help-support-launcher:hover,
  .help-support-launcher:active,
  .help-send:active {
    transform: none;
  }
}

@media (max-width: 520px) {
  .help-support {
    right: 12px;
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    width: auto;
  }

  .help-support-launcher {
    float: none;
    display: flex;
    width: 100%;
  }

  .help-support-panel {
    height: min(75vh, calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    max-height: min(75vh, calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  }

  .help-support-note {
    font-size: 10px;
  }
}

