@import url("/assets/lexxy-variables-3fef4323.css") layer(base);
@import url("/assets/lexxy-content-9fd5a900.css") layer(base);
@import url("/assets/lexxy-editor-cc6b87b4.css") layer(base);

/* Map beep design tokens → Lexxy variables */
:root {
  --lexxy-color-ink: var(--color-txt);
  --lexxy-color-ink-medium: var(--color-border-strong);
  --lexxy-color-ink-light: var(--color-border);
  --lexxy-color-ink-lighter: var(--color-border);
  --lexxy-color-ink-lightest: var(--color-surface);
  --lexxy-color-ink-inverted: var(--color-bg-pure);

  --lexxy-color-canvas: var(--color-bg);
  --lexxy-color-text: var(--color-txt);
  --lexxy-color-text-subtle: var(--color-txt-muted);

  --lexxy-color-accent-dark: var(--color-accent);
  --lexxy-color-accent-medium: var(--color-accent);
  --lexxy-color-accent-light: var(--color-accent-soft);
  --lexxy-color-accent-lightest: var(--color-accent-soft);

  --lexxy-color-link: var(--color-accent);
  --lexxy-color-blue: var(--color-accent);
  --lexxy-color-red: var(--color-negative);
  --lexxy-color-green: var(--color-positive);
  --lexxy-color-purple: var(--color-accent);

  --lexxy-color-selected: var(--color-accent-soft);
  --lexxy-color-selected-hover: var(--color-accent);

  --lexxy-color-code-bg: var(--color-surface);

  --lexxy-focus-ring-offset: 2px;
}

/* Global overrides — beat the gem's :where() zero-specificity rules */
.lexxy-content {
  color: currentColor;
}

.lexxy-content code,
.lexxy-content pre,
.lexxy-content code[data-language] {
  background-color: var(--color-surface);
  color: var(--color-txt);
}

/* Code blocks in editor */
.lexxy-editor__content code[data-language] {
  background-color: var(--color-surface);
  border-radius: 0.375em;
  color: var(--color-txt);
  display: block;
  font-family: var(--font-mono);
  font-size: 0.9em;
  margin-block: 0 0.5em;
  overflow-x: auto;
  padding: 1ch;
  position: relative;
  tab-size: 2;
  text-wrap: nowrap;
  white-space: pre;
}

/* Code language picker */
lexxy-editor lexxy-code-language-picker select.lexxy-code-language-picker {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-txt);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m12 19.5c-.7 0-1.3-.3-1.7-.8l-9.8-11.1c-.7-.8-.6-1.9.2-2.6.8-.6 1.9-.6 2.5.2l8.6 9.8c0 .1.2.1.4 0l8.6-9.8c.7-.8 1.8-.9 2.6-.2s.9 1.8.2 2.6l-9.8 11.1c-.4.5-1.1.8-1.7.8z' fill='currentColor'/%3E%3C/svg%3E");
}

/* Attachment images — hide caption, round corners */
.lexxy-content .attachment--preview,
.lexxy-editor__content .attachment--preview {
  border-radius: 0.75em;
  overflow: hidden;
}

.lexxy-content .attachment--preview img,
.lexxy-editor__content .attachment--preview img {
  border-radius: 0.75em;
}

.lexxy-content .attachment--preview .attachment__caption,
.lexxy-editor__content .attachment--preview .attachment__caption {
  display: none;
}

/* Tables */
.lexxy-content table,
.lexxy-editor__content table {
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--color-border);
  border-radius: 0.5em;
  overflow: hidden;
}

.lexxy-content table th,
.lexxy-content table td,
.lexxy-editor__content table th,
.lexxy-editor__content table td {
  border-color: var(--color-border);
  border-width: 0 1px 1px 0;
  background-color: var(--color-bg);
}

.lexxy-content table th:last-child,
.lexxy-content table td:last-child,
.lexxy-editor__content table th:last-child,
.lexxy-editor__content table td:last-child {
  border-inline-end-width: 0;
}

.lexxy-content table tr:last-child th,
.lexxy-content table tr:last-child td,
.lexxy-editor__content table tr:last-child th,
.lexxy-editor__content table tr:last-child td {
  border-block-end-width: 0;
}

.lexxy-content table th.lexxy-content__table-cell--header,
.lexxy-editor__content table th.lexxy-content__table-cell--header {
  background-color: var(--color-bg);
}

.lexxy-content table tr:first-child th.lexxy-content__table-cell--header,
.lexxy-editor__content table tr:first-child th.lexxy-content__table-cell--header {
  background-color: var(--color-surface);
  font-weight: 600;
}

/* Table editor selected states */
.lexxy-editor__content table td.lexxy-content__table-cell--selected,
.lexxy-editor__content table th.lexxy-content__table-cell--selected {
  background-color: var(--color-accent-soft);
}

/* Divider */
.lexxy-content hr,
.lexxy-editor__content hr {
  border: none;
  block-size: 2px;
  inline-size: 100%;
  background: linear-gradient(to right, transparent, var(--color-border) 12%, var(--color-border) 88%, transparent);
  margin-block: 1.5em;
}

/* Strikethrough */
.lexxy-content__strikethrough {
  text-decoration: line-through;
}

/* Restore list markers killed by Tailwind reset */
.lexxy-content ul,
.lexxy-editor__content ul {
  list-style-type: disc;
  padding-inline-start: 1.5em;
}

.lexxy-content ol,
.lexxy-editor__content ol {
  list-style-type: decimal;
  padding-inline-start: 1.5em;
}

/* Editor element base */
lexxy-editor {
  background-color: transparent;
  border-color: var(--color-border);
  color: var(--color-txt);
}

lexxy-editor button,
lexxy-editor summary {
  background: transparent;
}

/* Prompt menu (mention autocomplete) */
.lexxy-prompt-menu {
  background-color: var(--color-bg-pure);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.15);
  color: var(--color-txt);
  border-radius: 10px;
}

.lexxy-prompt-menu__item:hover {
  background-color: var(--color-hover);
}

.lexxy-prompt-menu__item[aria-selected] {
  background-color: var(--color-accent-soft);
}

/* Admin form: Lexxy editor */
.admin-form__group--editor {
  lexxy-editor {
    --lexxy-editor-padding: 0;
    --lexxy-toolbar-button-size: 2rem;

    border: none;
    border-radius: 0;

    .lexxy-editor__content {
      min-block-size: 20em;
      padding: 1.25em;
      background-color: var(--color-bg);
      border: 1px solid var(--color-border);
      border-radius: 0 0 0.5em 0.5em;
      transition: border-color 150ms ease, box-shadow 150ms ease;

      &:focus {
        border-color: var(--color-txt);
        box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-txt) 10%, transparent);
        outline: none;
      }
    }
  }

  lexxy-toolbar {
    display: flex;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: 0.5em 0.5em 0 0;
    gap: 0;
    padding: 0.4em 0.5em;
  }

  .lexxy-editor__toolbar-button {
    background: transparent;

    &[aria-pressed="true"],
    [open] > & {
      background-color: color-mix(in oklab, var(--color-txt) 15%, transparent);
    }

    @media (any-hover: hover) {
      &:hover:not([aria-pressed="true"]) {
        background-color: color-mix(in oklab, var(--color-txt) 8%, transparent);
      }
    }
  }

  .lexxy-editor__toolbar-dropdown {
    summary ~ * {
      background-color: var(--color-bg);
      border-color: var(--color-border);
      box-shadow: 0 4px 16px oklch(0% 0 0 / 0.2);
      color: var(--color-txt);
    }
  }

  .lexxy-content {
    line-height: 1.7;
    font-size: 1rem;

    h1 { font-size: 1.25rem; }

    blockquote {
      border-left: 1px solid var(--color-border);
      padding-left: 0.75em;
      color: var(--color-txt-muted);
    }
  }
}
