/* =============================================================================
   Prose editor — CodeMirror 6 backing for prose-textarea.
   Decoration classes (.md-bold, .md-heading-N, .wiki-link) are defined below.
   See docs/design/architecture/codemirror-prose-editor.md.
   ============================================================================= */

.prose-editor {
  position: relative;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--input-bg, var(--bg-secondary));
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.55;
  overflow: hidden;
}

.prose-editor:focus-within {
  border-color: var(--accent-red);
  outline: 2px solid var(--accent-red-bg);
  outline-offset: -1px;
}

/* CodeMirror-owned chrome — hide its default outline so our wrapper
   is the single source of focus styling. */
.prose-editor .cm-editor {
  outline: none;
  background: transparent;
  color: inherit;
}

.prose-editor .cm-editor.cm-focused {
  outline: none;
}

.prose-editor .cm-scroller {
  font-family: var(--font-body);
  line-height: 1.55;
  overflow: auto;
  padding: 0.5rem 0.75rem;
}

.prose-editor .cm-content {
  caret-color: var(--accent-red);
  padding: 0;
  min-height: 100%;
}

.prose-editor .cm-line {
  padding: 0;
}

.prose-editor .cm-placeholder {
  color: var(--text-disabled);
  font-style: italic;
}

/* Selection + focus accents tuned to the dark palette. */
.prose-editor .cm-selectionBackground,
.prose-editor .cm-content ::selection {
  background: var(--accent-red-bg) !important;
}

.prose-editor .cm-activeLine {
  background: transparent;
}

/* Read-only mode should dim like a disabled textarea. */
.prose-editor:has(.cm-editor[contenteditable="false"]) {
  background: var(--bg-disabled);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------------
   Decoration classes — emitted by prose-editor/decorations.cljs.
   Parity with the .prose rules in base.css (Phase 3a) so the visible
   output reads the same whether the user is rendering read-time prose
   or editing it live. See docs/design/architecture/codemirror-prose-editor.md.
   --------------------------------------------------------------------------- */

/* Inline content marks */
.prose-editor .md-bold   { color: var(--text-primary); font-weight: 700; }
.prose-editor .md-italic { font-style: italic; }
.prose-editor .md-link   {
  color: var(--accent-red);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.prose-editor .md-link:hover { color: var(--accent-red-hover); }

.prose-editor .md-code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-secondary);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  color: var(--text-primary);
}

/* Bullet widget — rendered in place of raw list markers (`- `, `* `, `1. `)
   on inactive lines. Matches body typography; slightly dimmed so the bullet
   reads as ornament, not content. */
.prose-editor .md-bullet {
  color: var(--text-secondary);
}

/* Heading line classes — applied to the .cm-line so we can swap the
   font-family + size without affecting the cursor row height elsewhere. */
.prose-editor .cm-line.md-heading-1,
.prose-editor .cm-line.md-heading-2,
.prose-editor .cm-line.md-heading-3,
.prose-editor .cm-line.md-heading-4,
.prose-editor .cm-line.md-heading-5,
.prose-editor .cm-line.md-heading-6 {
  font-family: var(--font-display);
  color: var(--text-primary);
  line-height: 1.2;
}

.prose-editor .cm-line.md-heading-1 { font-size: 1.6rem; font-weight: 700; }
.prose-editor .cm-line.md-heading-2 { font-size: 1.35rem; font-weight: 700; }
.prose-editor .cm-line.md-heading-3 { font-size: 1.15rem; font-weight: 600; }
.prose-editor .cm-line.md-heading-4 { font-size: 1.0rem;  font-weight: 600; }
.prose-editor .cm-line.md-heading-5 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.prose-editor .cm-line.md-heading-6 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------------------
   Focus-mode overlay variant — fills the centered 70ch column with a larger
   body type for write-heavy sessions. Works alongside the .prose-focus-shell
   chrome already defined in base.css.
   --------------------------------------------------------------------------- */

.prose-focus-shell .prose-editor.prose-focus-editor {
  flex: 1 1 auto;
  min-height: 50vh;
  border: none;
  background: transparent;
}

.prose-focus-shell .prose-editor.prose-focus-editor:focus-within {
  outline: none;
  border-color: transparent;
}

.prose-focus-shell .prose-editor.prose-focus-editor .cm-scroller {
  font-size: 1.0625rem;
  line-height: 1.6;
  padding: 0;
}

@media (max-width: 640px) {
  .prose-focus-shell .prose-editor.prose-focus-editor {
    min-height: 70vh;
  }
}
