/* =========================================================================
   Rich text — Tiptap editor surface + ActionText rendered output.
   Both are styled with the SAME selectors so the editor preview matches the
   final render exactly. Tokens come from style.css (:root).
   ========================================================================= */

/* ---- Editor shell ---- */
.tiptap-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

.tiptap-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .2rem;
  padding: .45rem .55rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  position: sticky;
  top: 0;
  z-index: 2;
}

.tiptap-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--moor);
  font: inherit;
  font-size: .92rem;
  line-height: 1;
  min-width: 2rem;
  padding: .4rem .55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.tiptap-btn:hover { background: var(--card); border-color: var(--line); }
.tiptap-btn.is-active { background: var(--moor); color: #f3f0e6; border-color: var(--moor); }
.tiptap-btn:disabled { opacity: .35; cursor: default; }
.tiptap-btn:disabled:hover { background: transparent; border-color: transparent; }

.tiptap-sep { width: 1px; align-self: stretch; background: var(--line); margin: .1rem .35rem; }
.tiptap-sep-grow { flex: 1 1 auto; background: transparent; }

.tiptap-mount { display: block; }
.tiptap-surface {
  min-height: 18rem;
  padding: 1.2rem 1.3rem;
  outline: none;
}
.tiptap-surface:focus-visible { box-shadow: inset 0 0 0 2px rgba(79,111,74,.2); }

/* ---- Shared typography: editor surface + rendered output ---- */
.tiptap-surface,
.rich-text-content {
  color: var(--ink);
  line-height: 1.7;
  font-size: 1.02rem;
}
.tiptap-surface > :first-child,
.rich-text-content > :first-child { margin-top: 0; }
.tiptap-surface > :last-child,
.rich-text-content > :last-child { margin-bottom: 0; }

.tiptap-surface p,
.rich-text-content p { margin: 0 0 1.1em; }

.tiptap-surface h2,
.rich-text-content h2 {
  font-family: var(--serif);
  color: var(--moor);
  font-size: 1.5rem;
  margin: 1.8em 0 .5em;
  line-height: 1.25;
}
.tiptap-surface h3,
.rich-text-content h3 {
  font-family: var(--serif);
  color: var(--moor);
  font-size: 1.2rem;
  margin: 1.5em 0 .4em;
}

.tiptap-surface a,
.rich-text-content a {
  color: var(--water-dk);
  border-bottom: 1px solid rgba(47,95,99,.35);
}
.tiptap-surface a:hover,
.rich-text-content a:hover { border-bottom-color: var(--water); }

.tiptap-surface ul, .tiptap-surface ol,
.rich-text-content ul, .rich-text-content ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.tiptap-surface li,
.rich-text-content li { margin-bottom: .4em; }
.tiptap-surface li::marker,
.rich-text-content li::marker { color: var(--reed); }

.tiptap-surface blockquote,
.rich-text-content blockquote {
  margin: 1.4em 0;
  padding: .4em 0 .4em 1.1em;
  border-left: 3px solid var(--reed);
  color: var(--ink-soft);
  font-family: var(--serif);
  font-style: italic;
}

.tiptap-surface hr,
.rich-text-content hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }

.tiptap-surface strong,
.rich-text-content strong { color: var(--moor); }

/* ---- Tables (Tiptap writes plain <table>; ActionText keeps it) ---- */
.tiptap-surface table,
.rich-text-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
  font-size: .95rem;
  table-layout: fixed;
}
.tiptap-surface th, .tiptap-surface td,
.rich-text-content th, .rich-text-content td {
  border: 1px solid var(--line);
  padding: .55rem .7rem;
  text-align: left;
  vertical-align: top;
}
.tiptap-surface th,
.rich-text-content th {
  background: var(--paper-2);
  font-weight: 700;
  color: var(--moor);
}
/* ProseMirror selected-cell + column-resize affordances (editor only) */
.tiptap-surface { position: relative; }
.tiptap-surface .selectedCell { background: rgba(79,111,74,.12); }
.tiptap-surface table { position: relative; }
.tiptap-surface .column-resize-handle {
  position: absolute;
  right: -2px; top: 0; bottom: -2px;
  width: 4px;
  background: var(--reed);
  pointer-events: none;
}
.tiptap-surface .tableWrapper { overflow-x: auto; }

/* Images inside rendered rich text (ActionText attachments) */
.rich-text-content figure { margin: 1.5em 0; }
.rich-text-content img { max-width: 100%; height: auto; border-radius: var(--radius); }
.rich-text-content figcaption { font-size: .85rem; color: var(--ink-soft); margin-top: .4rem; }
