/*
 * RichTextEditor ProseMirror content styles
 */

/* Ensure EditorContent wrapper stretches to fill the content area */
.sky-editor-content > div {
  height: 100%;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) {
  outline: none;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.625;
  color: var(--sky-fg);
  cursor: text;
}

/* ProseMirror (RTE) keeps its original padding */
.sky-editor-content .ProseMirror {
  padding: 0.75rem 1rem;
}

/* Markdown preview matches the textarea's px-3 py-2.5 */
.sky-editor-content .sky-md-preview {
  padding: 0.625rem 0.75rem;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) p {
  margin: 0.25em 0;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) h1 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) h2 {
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.35;
  margin-top: 1.25rem;
  margin-bottom: 0.375rem;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) h3 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

/* Remove top margin from the first child element */
.sky-editor-content :is(.ProseMirror, .sky-md-preview) > :first-child {
  margin-top: 0;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) li {
  margin: 0.125rem 0;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) li p {
  margin: 0;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) a {
  color: var(--sky-accent, #ffb31c);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) a:hover {
  opacity: 0.8;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) strong {
  font-weight: 700;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) em {
  font-style: italic;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) u {
  text-decoration: underline;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) s {
  text-decoration: line-through;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) sub {
  font-size: 0.8em;
  vertical-align: sub;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) sup {
  font-size: 0.8em;
  vertical-align: super;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) code {
  background: var(--sky-muted);
  border-radius: 0.25rem;
  color: var(--sky-fg);
  font-family: monospace;
  font-size: 0.85em;
  padding: 0.15em 0.35em;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) pre {
  background: var(--sky-muted);
  border-radius: 0.375rem;
  color: var(--sky-fg);
  font-family: monospace;
  font-size: 0.85em;
  line-height: 1.5;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  overflow-x: auto;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) pre code {
  background: none;
  border-radius: 0;
  padding: 0;
  font-size: inherit;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) blockquote {
  border-left: 3px solid var(--sky-border);
  margin: 0.75rem 0;
  padding-left: 1rem;
  color: var(--sky-muted-fg);
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) table {
  border-collapse: collapse;
  margin: 0.75rem 0;
  overflow: hidden;
  width: 100%;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) td,
.sky-editor-content :is(.ProseMirror, .sky-md-preview) th {
  border: 1px solid var(--sky-border);
  box-sizing: border-box;
  min-width: 75px;
  padding: 0.375rem 0.5rem;
  position: relative;
  vertical-align: top;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) th {
  background: var(--sky-muted);
  font-weight: 600;
  text-align: left;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) img {
  max-width: 100%;
  height: auto;
  margin: 0.75rem 0;
}

.sky-editor-content :is(.ProseMirror, .sky-md-preview) p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--sky-muted-fg);
  opacity: 0.5;
  pointer-events: none;
  position: absolute;
}

/* Disabled state */
.sky-editor-content[data-disabled="true"] .ProseMirror {
  cursor: not-allowed;
  opacity: 0.6;
  user-select: none;
}

/*
 * Focus ring. Uses :has([contenteditable]:focus-visible) so the ring is
 * keyboard-visible (and visible when the user clicks into the text surface —
 * browsers always promote text-input clicks to :focus-visible) but NOT on
 * mouse interactions with other chrome like the toolbar. Ring sizing +
 * offset match SkyInput / SkyTextarea for visual consistency across the
 * Sky form-control kit. Replaces a browser-default black contenteditable
 * outline that otherwise leaks through.
 */
.sky-editor-root {
  transition:
    box-shadow 120ms ease-out,
    border-color 120ms ease-out;
}

.sky-editor-root:has([contenteditable="true"]:focus-visible) {
  outline: none;
  /* Inner 1px offset in the background color, outer 2px ring in --color-ring,
     matching Tailwind's `ring-2 ring-ring ring-offset-1` stack on
     SkyInput/SkyTextarea. */
  box-shadow:
    0 0 0 1px var(--color-background, #fff),
    0 0 0 3px var(--color-ring);
  border-color: var(--color-ring);
}

.sky-editor-root[data-validation-state="error"]:has([contenteditable="true"]:focus-visible) {
  box-shadow:
    0 0 0 1px var(--color-background, #fff),
    0 0 0 3px var(--color-destructive);
  border-color: var(--color-destructive);
}

/* Green-500 — matches the success border color on the container. */
.sky-editor-root[data-validation-state="success"]:has([contenteditable="true"]:focus-visible) {
  box-shadow:
    0 0 0 1px var(--color-background, #fff),
    0 0 0 3px rgb(34 197 94);
  border-color: rgb(34 197 94);
}

/* Yellow-500 — matches the warning border color on the container. */
.sky-editor-root[data-validation-state="warning"]:has([contenteditable="true"]:focus-visible) {
  box-shadow:
    0 0 0 1px var(--color-background, #fff),
    0 0 0 3px rgb(234 179 8);
  border-color: rgb(234 179 8);
}

/* Disabled containers never show a focus ring. */
.sky-editor-root[data-disabled]:has([contenteditable]:focus-visible) {
  box-shadow: none;
  border-color: var(--color-border);
}

@media (prefers-reduced-motion: reduce) {
  .sky-editor-root {
    transition: none;
  }
}
