/*
 * Action Text attachment display styles for Lexxy (not Trix).
 * Editor chrome comes from the Lexxy gem stylesheet (`lexxy`).
 */

.lexxy-content,
.lexxy-editor__content {
  line-height: 1.55;
  color: var(--color-ink);
}

:is(.lexxy-content, .lexxy-editor__content) * {
  box-sizing: border-box;
  max-width: 100%;
}

:is(.lexxy-content, .lexxy-editor__content) h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 0.75em 0 0.35em;
}

:is(.lexxy-content, .lexxy-editor__content) h2 {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0.75em 0 0.35em;
}

:is(.lexxy-content, .lexxy-editor__content) h3 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0.75em 0 0.35em;
}

:is(.lexxy-content, .lexxy-editor__content) p {
  margin: 0 0 0.75em;
}

:is(.lexxy-content, .lexxy-editor__content) ul,
:is(.lexxy-content, .lexxy-editor__content) ol {
  margin: 0 0 0.85em;
  padding-inline-start: 1.5em;
}

:is(.lexxy-content, .lexxy-editor__content) ul {
  list-style: disc;
}

:is(.lexxy-content, .lexxy-editor__content) ol {
  list-style: decimal;
}

:is(.lexxy-content, .lexxy-editor__content) li {
  margin: 0.25em 0;
  padding-inline-start: 0.15em;
}

:is(.lexxy-content, .lexxy-editor__content) li > ul,
:is(.lexxy-content, .lexxy-editor__content) li > ol {
  margin-block: 0.25em 0;
}

:is(.lexxy-content, .lexxy-editor__content) blockquote {
  border-left: 3px solid var(--color-line-strong);
  margin: 0.75em 0;
  padding-left: 1em;
  color: var(--color-muted);
}

:is(.lexxy-content, .lexxy-editor__content) code {
  background: var(--color-surface-2);
  border: 1px solid var(--color-line);
  border-radius: 0.35em;
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.08em 0.3em;
}

:is(.lexxy-content, .lexxy-editor__content) pre {
  background: var(--color-surface-2);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-btn);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  overflow-x: auto;
  padding: 0.75em 1em;
}

:is(.lexxy-content, .lexxy-editor__content) pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

:is(.lexxy-content, .lexxy-editor__content) img {
  max-width: 100%;
  height: auto;
}

.lexxy-content .attachment {
  display: inline-block;
  max-width: 100%;
  position: relative;
}

.lexxy-content .attachment a {
  color: inherit;
  text-decoration: none;
}

.lexxy-content .attachment__caption,
lexxy-editor .attachment__caption {
  color: var(--color-faint);
  font-size: 0.78rem;
  text-align: center;
}

.lexxy-content .attachment--file .attachment__caption,
lexxy-editor .attachment--file .attachment__caption {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
}

.lexxy-content .attachment__type,
lexxy-editor .attachment__type {
  color: var(--color-muted);
  font: 600 var(--text-label)/1 var(--font-mono);
  letter-spacing: 0.06em;
}

.lexxy-content .attachment__download,
lexxy-editor .attachment__download {
  color: var(--color-brand) !important;
  font-weight: 600;
  text-decoration: underline !important;
  text-underline-offset: 0.15em;
}

.lexxy-content .attachment--preview {
  width: 100%;
  text-align: center;
}

.lexxy-content .attachment--file {
  background: var(--color-surface-2);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-btn);
  color: var(--color-muted);
  padding: 0.75em 1em;
}

.lexxy-content action-text-attachment .attachment {
  padding: 0 !important;
  max-width: 100% !important;
}

/* Mentions (Weacon) — single inline token, text-sized */
.lexxy-content action-text-attachment[content-type^="application/vnd.actiontext"],
lexxy-editor action-text-attachment[content-type^="application/vnd.actiontext"] {
  display: inline !important;
  align-items: baseline;
  margin: 0;
  padding: 0;
  line-height: inherit;
  vertical-align: baseline;
  white-space: nowrap;
}

.lexxy-content .mention,
lexxy-editor .mention,
.lexxy-content .weacon-mention,
lexxy-editor .weacon-mention {
  display: inline;
  margin: 0;
  padding: 0.05em 0.3em;
  border-radius: 0.3em;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  line-height: inherit;
  text-decoration: none;
  vertical-align: baseline;
  white-space: nowrap;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.lexxy-content .weacon-mention--person,
lexxy-editor .weacon-mention--person {
  background: var(--color-ai-soft);
  color: var(--color-ai);
}

.lexxy-content .weacon-mention--plan,
lexxy-editor .weacon-mention--plan {
  background: var(--color-brand-soft);
  border-color: var(--color-brand-line);
  color: var(--color-brand);
}

.lexxy-content .weacon-mention--task,
lexxy-editor .weacon-mention--task {
  background: var(--color-dev-soft);
  color: var(--color-dev-ink);
}

.lexxy-content .weacon-mention--knowledge,
lexxy-editor .weacon-mention--knowledge {
  background: var(--color-ai-soft);
  color: var(--color-ai);
}

/* Prompt picker — match site cards / pills */
.lexxy-prompt-menu {
  --lexxy-prompt-padding: 0.35rem;
  min-inline-size: min(22rem, calc(100% - 1rem)) !important;
  max-inline-size: min(28rem, calc(100% - 1rem)) !important;
  max-block-size: 16rem !important;
  padding: 0.35rem !important;
  border: 1px solid var(--color-line) !important;
  border-radius: var(--radius-card) !important;
  background: var(--color-surface) !important;
  box-shadow: var(--shadow-card), var(--shadow-overlay) !important;
  color: var(--color-ink) !important;
  font-family: var(--font-sans) !important;
  z-index: 70 !important;
}

.lexxy-prompt-menu__item {
  display: flex !important;
  align-items: stretch !important;
  gap: 0 !important;
  min-height: var(--height-row) !important;
  margin: 0 !important;
  padding: 0.4rem 0.55rem !important;
  border-radius: var(--radius-ctl) !important;
  cursor: pointer !important;
  user-select: none;
}

.lexxy-prompt-menu__item + .lexxy-prompt-menu__item {
  margin-top: 0.15rem !important;
}

.lexxy-prompt-menu__item:hover {
  background: var(--color-surface-2) !important;
}

.lexxy-prompt-menu__item[aria-selected] {
  background: var(--color-canvas-deep) !important;
  box-shadow: inset 3px 0 0 0 var(--color-brand);
}

.lexxy-prompt-menu__item--empty {
  color: var(--color-faint) !important;
  font: 500 var(--text-meta)/1.4 var(--font-sans) !important;
  padding: 0.75rem 0.55rem !important;
}

.weacon-prompt-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  width: 100%;
  pointer-events: none;
}

.weacon-prompt-item__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  background: var(--color-brand);
  color: var(--color-surface);
  font: 600 0.625rem/1 var(--font-sans);
  letter-spacing: 0.02em;
}

.weacon-prompt-item__kind {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: var(--height-pill);
  padding: 0 0.55rem;
  border-radius: var(--radius-pill);
  font: 600 var(--text-label)/1 var(--font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.weacon-prompt-item__kind--plan {
  background: var(--color-brand-soft);
  color: var(--color-brand);
}

.weacon-prompt-item__kind--task {
  background: var(--color-dev-soft);
  color: var(--color-dev-ink);
}

.weacon-prompt-item__kind--knowledge {
  background: var(--color-ai-soft);
  color: var(--color-ai);
}

.weacon-prompt-item__body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}

.weacon-prompt-item__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 600 var(--text-body)/1.25 var(--font-sans);
  color: var(--color-ink);
}

.weacon-prompt-item__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 500 var(--text-meta)/1.2 var(--font-sans);
  color: var(--color-muted);
}

/* Lexxy toolbar → design_specs §4.7 / notes reference */
.lexxy-editor-shell {
  --lexxy-toolbar-button-size: 30px;
  --lexxy-toolbar-gap: 2px;
  --lexxy-toolbar-spacing: 0.6ch;
  --lexxy-toolbar-padding: 8px;
  --lexxy-toolbar-border-size: 1px;
  --lexxy-radius: 8px;
  --lexxy-color-selected: var(--color-surface);
  --lexxy-color-selected-hover: var(--color-surface);
  --lexxy-color-ink-lighter: var(--color-line);
}

.lexxy-editor-shell lexxy-editor {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-block-size: 12rem;
}

.lexxy-editor-shell.flex-1 lexxy-editor,
.lexxy-editor-shell.flex-1 .lexxy-editor__content,
.lexxy-editor-shell.flex-1 .lexxy-content {
  flex: 1 1 auto;
  min-block-size: 12rem;
}

.lexxy-editor-shell.flex-1 .lexxy-editor__content,
.lexxy-editor-shell.flex-1 .lexxy-content {
  overflow-y: auto;
}

/* Compact comment/reply composer — single short row.
   Keep overflow on the content box only so Lexxy prompt menus
   (appended to <lexxy-editor>) are not clipped. */
.lexxy-editor-shell--compact {
  min-block-size: 44px !important;
  flex: none !important;
  overflow: visible !important;
}

.lexxy-editor-shell--compact lexxy-toolbar {
  display: none;
}

.lexxy-editor-shell--compact lexxy-editor,
.lexxy-editor-shell--compact.flex-1 lexxy-editor {
  flex: none !important;
  min-block-size: 44px !important;
  max-block-size: none !important;
  overflow: visible !important;
}

.lexxy-editor-shell--compact .lexxy-editor__content,
.lexxy-editor-shell--compact.flex-1 .lexxy-editor__content,
.lexxy-editor-shell--compact .lexxy-content,
.lexxy-editor-shell--compact.flex-1 .lexxy-content {
  flex: none !important;
  min-block-size: 44px !important;
  max-block-size: 8rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.55rem 0.25rem;
}

.lexxy-editor-shell--compact .lexxy-prompt-menu {
  z-index: 80 !important;
}

.lexxy-editor-shell lexxy-toolbar {
  background: var(--color-surface-2);
  border: 1px solid var(--color-line);
  border-block-end: 1px solid var(--color-line);
  border-radius: var(--radius-ctl);
  color: var(--color-muted);
  margin: 0 0 0.75rem;
  min-block-size: var(--height-row);
  padding: 8px 12px;
}

.lexxy-editor-shell .lexxy-editor__toolbar-button {
  appearance: none;
  background: transparent;
  border-radius: var(--radius-ctl);
  color: var(--color-muted);
}

.lexxy-editor-shell .lexxy-editor__toolbar-button:hover:not([aria-disabled="true"]) {
  background: transparent;
  color: var(--color-ink);
}

.lexxy-editor-shell .lexxy-editor__toolbar-button:is(:active):not([aria-disabled="true"]),
.lexxy-editor-shell .lexxy-editor__toolbar-button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-ink);
}

.lexxy-editor-shell .lexxy-editor__toolbar-button[aria-pressed="true"]:hover {
  background: var(--color-surface);
  color: var(--color-ink);
}

.lexxy-editor-shell .lexxy-editor__content,
.lexxy-editor-shell .lexxy-content {
  padding: 0.75rem 0.25rem 0.25rem;
}

/* Non-video file attachments stay in Action Text so Active Storage can track
   them, but the writing surface should remain a writing surface. The editor
   attachments controller mirrors these nodes into the rail below. */
.lexxy-editor-shell .lexxy-editor__content figure.weacon-editor-attachment-hidden {
  display: none !important;
}

.weacon-editor-attachments-rail {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 0 0 auto;
  margin-top: 0.55rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--color-line);
}

.weacon-editor-attachments-rail__scroll {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 0.1rem 0.1rem 0.35rem;
  scrollbar-width: thin;
}

.weacon-editor-attachment-card {
  position: relative;
  display: flex;
  flex: 0 0 min(18rem, 78vw);
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
  padding: 0.65rem 0.65rem 0.65rem 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-ctl);
  background: var(--color-surface-2);
  box-shadow: var(--shadow-card);
}

.weacon-editor-attachment-card__details {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

.weacon-editor-attachment-card__identity {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}

.weacon-editor-attachment-card__type {
  display: inline-flex;
  min-width: 2.15rem;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--color-brand-soft);
  color: var(--color-brand);
  font: 600 var(--text-label)/1 var(--font-mono);
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
}

.weacon-editor-attachment-card__size {
  color: var(--color-muted);
  font: 500 0.62rem/1 var(--font-mono);
  white-space: nowrap;
}

.weacon-editor-attachment-card__name {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--color-ink);
  font: 500 var(--text-meta)/1.2 var(--font-sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weacon-editor-attachment-card__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.3rem;
}

.weacon-editor-attachment-card__action {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-ctl);
  background: var(--color-surface);
  color: var(--color-faint);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 120ms ease-out, color 120ms ease-out, background-color 120ms ease-out;
}

.weacon-editor-attachment-card__action svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.weacon-editor-attachment-card__action:hover {
  border-color: var(--color-line-strong);
  background: var(--color-surface-2);
  color: var(--color-ink);
}

.weacon-editor-attachment-card__action[data-editor-attachment-remove]:hover {
  border-color: var(--color-danger-line);
  color: var(--color-danger);
}

.weacon-editor-attachment-card__action:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}
