
/* ===== Scoped to .trix-theme (wrap your toolbar+editor) ===== */

/* Toolbar Container */
.trix-theme trix-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.5rem;
  position: relative;
}

/* Row: horizontal scroll on small screens */
.trix-theme trix-toolbar .trix-button-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}
.trix-theme trix-toolbar .trix-button-row::-webkit-scrollbar {
  display: none;
}

/* Button groups */
.trix-theme trix-toolbar .trix-button-group {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

/* ===== Icon Buttons (toolbar) ===== */
.trix-theme trix-toolbar .trix-button:not(.trix-button--dialog) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  margin: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

/* Hover / Press / Active */
.trix-theme trix-toolbar .trix-button:hover:not(:disabled) {
  background: var(--surface-2);
}
.trix-theme trix-toolbar .trix-button:active:not(:disabled) {
  background: var(--surface-3, var(--surface-2));
}
.trix-theme trix-toolbar .trix-button.trix-active {
  background: var(--btn-bg);
  color: var(--btn-text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.15);
}
.trix-theme trix-toolbar .trix-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Hide default Trix button content (::before pseudo-elements) */
.trix-theme trix-toolbar .trix-button::before {
  display: none !important;
}

/* SVG icons */
.trix-theme trix-toolbar .trix-button svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  stroke: currentColor;
  fill: none;
  pointer-events: none;
}
.trix-theme trix-toolbar .trix-button svg[fill]:not([fill="none"]) {
  fill: currentColor;
}

/* ===== Dialog Styles ===== */
.trix-theme trix-toolbar .trix-dialogs {
  position: relative;
}

.trix-theme trix-toolbar .trix-dialog {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 18rem;
  max-width: 24rem;
  background: var(--card, var(--surface));
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 6px 12px -2px rgb(0 0 0 / 0.12),
              0 2px 4px -2px rgb(0 0 0 / 0.05);
  padding: 0.75rem;
  margin-top: 0.25rem;
  z-index: 50;
  display: none;
}
.trix-theme trix-toolbar .trix-dialog[data-trix-active] {
  display: block;
}

/* Link fields row */
.trix-theme trix-toolbar .trix-dialog__link-fields {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Input smaller and more compact */
.trix-theme trix-toolbar .trix-input--dialog {
  flex: 1;
  min-width: 8rem;
  border: 1px solid var(--input-border);
  background: var(--input-bg, var(--surface));
  color: var(--text);
  border-radius: 0.375rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
  line-height: 1.2;
  outline: none;
}
.trix-theme trix-toolbar .trix-input--dialog:focus {
  border-color: var(--btn-bg);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--btn-bg) 20%, transparent);
}

/* ===== Dialog Buttons (Link / Unlink, etc.) ===== */
.trix-theme trix-toolbar .trix-dialog__link-fields .trix-button-group {
  display: flex;
  gap: 0.4rem;
}

.trix-theme trix-toolbar .trix-button--dialog {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  min-width: 3rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease;
  white-space: nowrap;
}

/* Primary */
.trix-theme trix-toolbar .trix-button--dialog:first-child {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: var(--btn-bg);
}
.trix-theme trix-toolbar .trix-button--dialog:first-child:hover {
  background: var(--btn-bg-hover, color-mix(in srgb, var(--btn-bg) 90%, black));
}

/* Secondary */
.trix-theme trix-toolbar .trix-button--dialog:last-child {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.trix-theme trix-toolbar .trix-button--dialog:last-child:hover {
  background: var(--surface-2);
}

/* ===== Editor field ===== */
.trix-theme trix-editor {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 0.5rem;
  padding: 0.75rem 0.875rem;
  min-height: 16rem;
  outline: none;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.5;
}
.trix-theme trix-editor:focus {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--btn-bg) 20%, transparent);
  border-color: var(--btn-bg);
}
.trix-theme trix-editor:empty:not(:focus)::before {
  color: var(--muted);
}

/* ===== Inline heading/quote formatting in editor ===== */
.trix-theme trix-editor [data-trix-attribute="heading1"] {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0.75em 0 0.5em;
}
.trix-theme trix-editor [data-trix-attribute="quote"] {
  border-left: 3px solid var(--border);
  padding-left: 0.75rem;
  color: var(--muted);
  font-style: italic;
  margin: 1rem 0;
}
.trix-theme trix-editor [data-trix-attribute="bullet"],
.trix-theme trix-editor [data-trix-attribute="number"] {
  margin-left: 1.5rem;
  list-style-position: outside;
}
.trix-theme trix-editor [data-trix-attribute="bullet"] {
  list-style-type: disc;
}
.trix-theme trix-editor [data-trix-attribute="number"] {
  list-style-type: decimal;
}

/* ===== Rendered content (when showing a post) ===== */
.trix-theme .trix-content {
  color: var(--text);
  line-height: 1.7;
}
.trix-theme .trix-content h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin: 1.5em 0 0.75em;
}
.trix-theme .trix-content h2,
.trix-theme .trix-content h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 1.25em 0 0.5em;
}
.trix-theme .trix-content p,
.trix-theme .trix-content ul,
.trix-theme .trix-content ol,
.trix-theme .trix-content pre,
.trix-theme .trix-content blockquote {
  margin: 0.75em 0;
}
.trix-theme .trix-content ul,
.trix-theme .trix-content ol {
  padding-left: 1.5rem;
}
.trix-theme .trix-content li {
  margin: 0.25em 0;
}
.trix-theme .trix-content blockquote {
  border-left: 3px solid var(--border);
  padding-left: 0.75rem;
  color: var(--muted);
  font-style: italic;
  margin: 1rem 0;
}
.trix-theme .trix-content pre {
  background: var(--surface-2);
  padding: 0.75rem;
  border-radius: 0.375rem;
  overflow-x: auto;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  font-size: 0.875rem;
}
.trix-theme .trix-content code {
  background: var(--surface-2);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  font-size: 0.875em;
}
.trix-theme .trix-content a {
  color: var(--btn-bg);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.trix-theme .trix-content .attachment {
  display: inline-block;
  position: relative;
  max-width: 100%;
  margin: 0.5rem 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface-2);
}

/* ===== Mobile optimizations ===== */
@media (max-width: 640px) {
  .trix-theme trix-toolbar { padding: 0.25rem; }
  .trix-theme trix-editor { min-height: 14rem; padding: 0.5rem; }
  .trix-theme trix-toolbar .trix-button-row { gap: 0.25rem; }
  .trix-theme trix-toolbar .trix-button-group { gap: 0.125rem; }
  .trix-theme trix-toolbar .trix-dialog {
    left: 0.5rem;
    right: 0.5rem;
    padding: 0.75rem;
  }
  .trix-theme trix-toolbar .trix-dialog__link-fields {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
}

/* ===== Print styles ===== */
@media print {
  .trix-theme trix-toolbar { display: none; }
  .trix-theme trix-editor,
  .trix-theme .trix-content {
    border: none;
    box-shadow: none;
    background: transparent;
  }
}

/* ===== Accessibility improvements ===== */
@media (prefers-reduced-motion: reduce) {
  .trix-theme trix-toolbar .trix-button,
  .trix-theme trix-toolbar .trix-button--dialog {
    transition: none;
  }
}
