/* ==========================================================================
   Yasmin AI Assistant widget -- lightweight, no build step, follows the
   existing Plan9 dark editorial design tokens (see plan9.css :root).
   ========================================================================== */

.p9-yasmin {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: inherit;
}

.p9-yasmin-launcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--p9-border-hi, #303030);
  background: var(--p9-bg-raised, #111111);
  color: var(--p9-text, #f0f0ef);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.p9-yasmin-launcher:hover {
  border-color: var(--p9-red, #e8334a);
  transform: translateY(-1px);
}

.p9-yasmin-panel {
  position: absolute;
  right: 0;
  bottom: 60px;
  width: 340px;
  max-width: calc(100vw - 40px);
  max-height: 480px;
  flex-direction: column;
  background: var(--p9-bg-panel, #0d0d0d);
  border: 1px solid var(--p9-border, #232323);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  transform-origin: bottom right;
  /* Deliberately NO `display` here. Layout/visibility is controlled
     entirely by the [hidden] attribute (native browser behaviour --
     display:none) when closed. `display: flex` is only ever set by the
     .p9-yasmin-open class below, which JS only ever applies at the same
     time it removes [hidden] -- so the two never compete for the same
     element at once. (An always-on `display: flex` here was the earlier
     bug: an author rule beats the browser's own [hidden]{display:none}
     rule regardless of source order, which made the panel un-closeable.) */
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.p9-yasmin-panel.p9-yasmin-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.p9-yasmin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--p9-border, #232323);
}

.p9-yasmin-name {
  color: var(--p9-text, #f0f0ef);
  font-weight: 700;
  font-size: 0.95rem;
}

.p9-yasmin-tagline {
  color: var(--p9-muted, #96968f);
  font-size: 0.75rem;
}

.p9-yasmin-close {
  background: none;
  border: none;
  color: var(--p9-muted, #96968f);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.p9-yasmin-close:hover {
  color: var(--p9-text, #f0f0ef);
}

.p9-yasmin-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
}

.p9-yasmin-msg {
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 88%;
  white-space: pre-wrap;
  word-break: break-word;
}

.p9-yasmin-msg-bot {
  align-self: flex-start;
  background: var(--p9-bg-raised, #111111);
  color: var(--p9-text, #f0f0ef);
  border: 1px solid var(--p9-border, #232323);
}

.p9-yasmin-msg-bot a {
  color: var(--p9-red-hi, #ff4d63);
  text-decoration: underline;
  word-break: break-all;
}

.p9-yasmin-msg-bot a:hover,
.p9-yasmin-msg-bot a:focus-visible {
  color: var(--p9-red, #e8334a);
}

.p9-yasmin-msg-user {
  align-self: flex-end;
  background: var(--p9-red, #e8334a);
  color: #fff;
}

.p9-yasmin-msg-loading {
  align-self: flex-start;
  color: var(--p9-muted, #96968f);
  font-style: italic;
}

.p9-yasmin-error {
  margin: 0 16px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--p9-red-lo, rgba(232, 51, 74, 0.1));
  color: var(--p9-red-hi, #ff4d63);
  font-size: 0.78rem;
}

.p9-yasmin-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--p9-border, #232323);
}

.p9-yasmin-input {
  flex: 1;
  background: var(--p9-bg-sunken, #050505);
  border: 1px solid var(--p9-border, #232323);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--p9-text, #f0f0ef);
  font-size: 0.85rem;
}

.p9-yasmin-input:focus {
  outline: none;
  border-color: var(--p9-red, #e8334a);
}

.p9-yasmin-send {
  background: var(--p9-red, #e8334a);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.p9-yasmin-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .p9-yasmin {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }
  .p9-yasmin-panel {
    width: 100%;
    right: 0;
    left: 0;
  }
}

/* ---------- Custom scrollbar (Yasmin widget) ----------
   Same brand colours as the site-wide scrollbar (see plan9.css), just
   slightly slimmer to suit this compact panel. Scoped explicitly (rather
   than relying on inheriting the site-wide rule) so this stays correct
   even if the widget is ever embedded somewhere that doesn't load
   plan9.css. */
.p9-yasmin-messages {
  scrollbar-color: var(--p9-border-hi, #303030) var(--p9-bg-sunken, #050505);
  scrollbar-width: thin;
}

.p9-yasmin-messages::-webkit-scrollbar {
  width: 8px;
}

.p9-yasmin-messages::-webkit-scrollbar-track {
  background: var(--p9-bg-sunken, #050505);
}

.p9-yasmin-messages::-webkit-scrollbar-thumb {
  background-color: var(--p9-border-hi, #303030);
  border-radius: 8px;
}

.p9-yasmin-messages::-webkit-scrollbar-thumb:hover {
  background-color: var(--p9-red, #e8334a);
}
