/**
 * Custom Trix Editor Styles for Tailwind CSS v4
 *
 * This file provides styling for both the Trix editor (in forms)
 * and the displayed Trix content (on show pages) without requiring
 * the @tailwindcss/typography plugin.
 */

/* ============================================
   TRIX EDITOR STYLING (Form Input)
   ============================================ */

/* Editor container with modern border and focus states */
trix-editor {
  border: 1px solid rgb(209 213 219); /* gray-300 */
  border-radius: 0.5rem; /* rounded-lg */
  padding: 0.75rem 1rem;
  min-height: 12rem;
  outline: none;
  background-color: white;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

trix-editor:focus {
  border-color: rgb(156 163 175); /* gray-400 */
  box-shadow: 0 0 0 1px rgb(156 163 175 / 0.5);
}

trix-editor:empty:not(:focus)::before {
  color: rgb(156 163 175); /* gray-400 */
}

/* Toolbar modern styling */
trix-toolbar {
  border: 1px solid rgb(209 213 219); /* gray-300 */
  border-bottom: none;
  border-radius: 0.5rem 0.5rem 0 0;
  background-color: rgb(249 250 251); /* gray-50 */
  padding: 0.5rem;
}

trix-toolbar .trix-button-group {
  border: 1px solid rgb(209 213 219); /* gray-300 */
  border-radius: 0.375rem; /* rounded-md */
  background-color: white;
  margin-bottom: 0;
}

trix-toolbar .trix-button {
  color: rgb(55 65 81); /* gray-700 */
  border-bottom: none;
  background-color: transparent;
  transition: background-color 0.15s ease-in-out;
}

trix-toolbar .trix-button:hover {
  background-color: rgb(243 244 246); /* gray-100 */
}

trix-toolbar .trix-button.trix-active {
  background-color: rgb(219 234 254); /* blue-100 */
  color: rgb(29 78 216); /* blue-700 */
}

/* Stacked editor (toolbar on top) */
trix-toolbar + trix-editor {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
}

/* ============================================
   TRIX CONTENT DISPLAY (Show Page)
   ============================================ */

/* Base prose-like styling for displayed content */
.trix-content {
  color: rgb(55 65 81); /* gray-700 */
  line-height: 1.75;
  font-size: 0.875rem; /* text-sm */
}

/* Headings */
.trix-content h1 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  color: rgb(17 24 39); /* gray-900 */
}

.trix-content h1:first-child {
  margin-top: 0;
}

/* Paragraphs */
.trix-content p {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.trix-content p:first-child {
  margin-top: 0;
}

.trix-content p:last-child {
  margin-bottom: 0;
}

/* Links */
.trix-content a {
  color: rgb(37 99 235); /* blue-600 */
  text-decoration: none;
  font-weight: 500;
}

.trix-content a:hover {
  text-decoration: underline;
}

/* Strong (Bold) */
.trix-content strong {
  font-weight: 600;
  color: rgb(17 24 39); /* gray-900 */
}

/* Emphasis (Italic) */
.trix-content em {
  font-style: italic;
}

/* Strike through */
.trix-content del {
  text-decoration: line-through;
}

/* Lists - CRITICAL for Tailwind compatibility */
.trix-content ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.trix-content ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.trix-content li {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
  margin-left: 0; /* Override Trix default */
  padding-left: 0.25rem;
}

.trix-content ul ul,
.trix-content ul ol,
.trix-content ol ul,
.trix-content ol ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Blockquotes */
.trix-content blockquote {
  border-left: 4px solid rgb(209 213 219); /* gray-300 */
  padding-left: 1rem;
  margin-left: 0;
  margin-top: 1rem;
  margin-bottom: 1rem;
  font-style: italic;
  color: rgb(107 114 128); /* gray-500 */
}

/* Code blocks */
.trix-content pre {
  background-color: rgb(243 244 246); /* gray-100 */
  border-radius: 0.375rem; /* rounded-md */
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-top: 1rem;
  margin-bottom: 1rem;
  color: rgb(17 24 39); /* gray-900 */
}

/* Inline code (if needed) */
.trix-content code {
  background-color: rgb(243 244 246); /* gray-100 */
  border-radius: 0.25rem;
  padding: 0.125rem 0.375rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  color: rgb(17 24 39); /* gray-900 */
}

.trix-content pre code {
  background-color: transparent;
  border-radius: 0;
  padding: 0;
  font-size: inherit;
}

/* Images */
.trix-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

/* Attachments */
.trix-content .attachment {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.trix-content .attachment img {
  border: 1px solid rgb(229 231 235); /* gray-200 */
}

.trix-content .attachment__caption {
  text-align: center;
  font-size: 0.8125rem;
  color: rgb(107 114 128); /* gray-500 */
  margin-top: 0.5rem;
}

.trix-content .attachment--file {
  background-color: rgb(249 250 251); /* gray-50 */
  border: 1px solid rgb(209 213 219); /* gray-300 */
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgb(55 65 81); /* gray-700 */
}

.trix-content .attachment--file:hover {
  background-color: rgb(243 244 246); /* gray-100 */
}

/* Horizontal rules */
.trix-content hr {
  border: none;
  border-top: 1px solid rgb(229 231 235); /* gray-200 */
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ============================================
   ACCESSIBILITY & FOCUS STATES
   ============================================ */

trix-toolbar .trix-button:focus {
  outline: 2px solid rgb(59 130 246); /* blue-500 */
  outline-offset: 2px;
}

trix-editor:focus {
  outline: none; /* Handled by border/shadow above */
}
