/* Lexxy app-specific overrides
 *
 * Layered on top of the canonical lexxy stylesheet that the
 * lexxy gem ships at:
 *   <lexxy-gem>/app/assets/stylesheets/lexxy.css
 *     → @imports lexxy-content.css + lexxy-editor.css
 * Propshaft picks the gem's app/assets paths up automatically, so
 * the gem's file resolves whenever a layout does
 *   stylesheet_link_tag "lexxy"
 *
 * Load this file AFTER "lexxy" in your layout so the overrides win.
 */

/* Sticky toolbar within the editor wrapper.
 * The canonical lexxy CSS does not make the toolbar sticky;
 * we want it to follow the page scroll when the editor is tall. */
lexxy-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Dark mode variable overrides for lexxy.
 * Source: https://github.com/basecamp/lexxy/issues/51 (kevcamel's final comment).
 * The upstream lexxy CSS is theme-agnostic by design, so we layer dark-mode
 * values for its CSS custom properties here. The project uses
 * `prefers-color-scheme` for dark mode (see design-system/_tokens.css). */
@media (prefers-color-scheme: dark) {
  :root {
    --lexxy-color-ink: #f7f7f8;
    --lexxy-color-ink-medium: oklch(75% 0 0);
    --lexxy-color-ink-light: oklch(65% 0 0);
    --lexxy-color-ink-lighter: oklch(35% 0 0);
    --lexxy-color-ink-lightest: oklch(23% 0.006 285);
    --lexxy-color-ink-inverted: oklch(17% 0.006 285);

    --lexxy-color-accent-dark: oklch(70% 0.19 260);
    --lexxy-color-accent-medium: oklch(75% 0.196 258);
    --lexxy-color-accent-lightest: oklch(25% 0.026 254);

    --lexxy-color-selected: oklch(23% 0.006 285);
    --lexxy-color-selected-hover: oklch(22% 0.006 285);

    --lexxy-color-code-token-att: #f97583;
    --lexxy-color-code-token-comment: #8b949e;
    --lexxy-color-code-token-function: #d2a8ff;
    --lexxy-color-code-token-operator: #ff7b72;
    --lexxy-color-code-token-property: #79c0ff;
    --lexxy-color-code-token-punctuation: #c9d1d9;
    --lexxy-color-code-token-selector: #7ee83f;
    --lexxy-color-code-token-variable: #ffa657;

    --lexxy-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* Drag-and-drop highlight when dropping a file onto the editor. */
.lexxy-editor--drag-over {
  background-color: rgb(238 242 255); /* indigo-50 */
  border-radius: 0.25rem;
  outline: 2px dashed rgb(165 180 252); /* indigo-300 */
}

@media (prefers-color-scheme: dark) {
  .lexxy-editor--drag-over {
    background-color: rgb(30 27 75); /* indigo-950 */
    outline-color: rgb(99 102 241); /* indigo-500 */
  }
}

/* Selected-attachment outline (used by image / file figures). */
lexxy-editor figure.node--selected {
  outline: 2px solid rgb(99 102 241); /* indigo-500 */
  outline-offset: 2px;
}

lexxy-editor figure.node--selected:has(img) img {
  outline: 2px solid rgb(99 102 241);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/*  Mention prompt menu — app-specific (not part of lexxy core)        */
/* ------------------------------------------------------------------ */

.lexxy-prompt-menu {
  --lexxy-prompt-avatar-size: 1.5rem;
  --lexxy-prompt-min-width: 16rem;
  --lexxy-prompt-padding: 0.5rem;

  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  color: rgb(17 24 39);
  font-family: inherit;
  font-size: 0.875rem;
  list-style: none;
  margin: 0;
  min-width: var(--lexxy-prompt-min-width);
  padding: var(--lexxy-prompt-padding);
  visibility: hidden;
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}

@media (prefers-color-scheme: dark) {
  .lexxy-prompt-menu {
    background-color: rgb(31 41 55);
    color: rgb(243 244 246);
  }
}

.lexxy-prompt-menu--visible {
  visibility: visible;
}

.lexxy-prompt-menu__item {
  align-items: center;
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  white-space: nowrap;
}

.lexxy-prompt-menu__item:hover {
  background-color: rgb(243 244 246);
}

@media (prefers-color-scheme: dark) {
  .lexxy-prompt-menu__item:hover {
    background-color: rgb(55 65 81);
  }
}

.lexxy-prompt-menu__item[aria-selected] {
  background-color: rgb(238 242 255);
}

@media (prefers-color-scheme: dark) {
  .lexxy-prompt-menu__item[aria-selected] {
    background-color: rgb(49 46 129);
  }
}

.lexxy-prompt-menu__item img {
  height: var(--lexxy-prompt-avatar-size);
  width: var(--lexxy-prompt-avatar-size);
  border-radius: 9999px;
  flex-shrink: 0;
  margin: 0;
  object-fit: cover;
}

.lexxy-prompt-menu__item + .lexxy-prompt-menu__item {
  margin-top: 2px;
}

.lexxy-prompt-menu__item--empty {
  color: rgb(107 114 128);
  padding: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  .lexxy-prompt-menu__item--empty {
    color: rgb(156 163 175);
  }
}

/* Mention styling in rendered content. */
.mention {
  display: inline-flex;
  align-items: center;
  color: rgb(79 70 229); /* indigo-600 */
}

.mention:hover {
  text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
  .mention {
    color: rgb(165 180 252); /* indigo-300 */
  }
}
