/* Febi Wiki editor + rendered document styles.
   Content rules target both the live editor (.ed-content) and the
   server-rendered read view (.doc-body). Source: web/editor/src/editor.css */

/* ---------- content typography ---------- */

.ed-content,
.doc-body {
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: #1C2B4A;
  overflow-wrap: break-word;
  word-break: normal;
}

.ed-content {
  min-height: 320px;
  outline: none;
  white-space: pre-wrap;
}

.ed-content > :first-child,
.doc-body > :first-child {
  margin-top: 0;
}

.ed-content > :last-child,
.doc-body > :last-child {
  margin-bottom: 0;
}

.ed-content p,
.doc-body p {
  margin: 0 0 0.85em;
}

.ed-content h1,
.ed-content h2,
.ed-content h3,
.doc-body h1,
.doc-body h2,
.doc-body h3 {
  color: #0F2650;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.ed-content h1,
.doc-body h1 {
  font-size: 1.875em;
  margin: 1.4em 0 0.5em;
}

.ed-content h2,
.doc-body h2 {
  font-size: 1.45em;
  margin: 1.35em 0 0.45em;
}

.ed-content h3,
.doc-body h3 {
  font-size: 1.18em;
  margin: 1.25em 0 0.4em;
}

.ed-content a,
.doc-body a {
  color: #067C78;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.ed-content a:hover,
.doc-body a:hover {
  color: #055E5B;
}

.ed-content strong,
.doc-body strong {
  font-weight: 700;
  color: #0F2650;
}

/* ---------- lists ---------- */

.ed-content ul,
.ed-content ol,
.doc-body ul,
.doc-body ol {
  margin: 0 0 0.85em;
  padding-left: 1.6em;
}

.ed-content li,
.doc-body li {
  margin: 0.2em 0;
}

.ed-content li > p,
.doc-body li > p {
  margin: 0;
}

.ed-content li > ul,
.ed-content li > ol,
.doc-body li > ul,
.doc-body li > ol {
  margin: 0.2em 0 0;
}

.ed-content ul[data-type="taskList"],
.doc-body ul[data-type="taskList"] {
  list-style: none;
  padding-left: 0.15em;
}

.ed-content ul[data-type="taskList"] > li,
.doc-body ul[data-type="taskList"] > li {
  display: flex;
  align-items: flex-start;
  gap: 0.6em;
}

.ed-content ul[data-type="taskList"] > li > label,
.doc-body ul[data-type="taskList"] > li > label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 1.65em;
  user-select: none;
}

.ed-content ul[data-type="taskList"] > li > div,
.doc-body ul[data-type="taskList"] > li > div {
  flex: 1 1 auto;
  min-width: 0;
}

.ed-content ul[data-type="taskList"] input[type="checkbox"],
.doc-body ul[data-type="taskList"] input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #067C78;
}

.ed-content ul[data-type="taskList"] input[type="checkbox"] {
  cursor: pointer;
}

.ed-content ul[data-type="taskList"] > li[data-checked="true"] > div > p,
.doc-body ul[data-type="taskList"] > li[data-checked="true"] > div > p {
  color: #4B5572;
  text-decoration: line-through;
}

/* ---------- quote, rule, images ---------- */

.ed-content blockquote,
.doc-body blockquote {
  margin: 0 0 0.85em;
  padding: 0.15em 0 0.15em 1em;
  border-left: 3px solid #067C78;
  color: #4B5572;
}

.ed-content blockquote > :last-child,
.doc-body blockquote > :last-child {
  margin-bottom: 0;
}

.ed-content hr,
.doc-body hr {
  border: 0;
  border-top: 1px solid #E2EAF0;
  margin: 1.6em 0;
}

.ed-content img,
.doc-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 0 0.85em;
  border-radius: 8px;
}

.ed-content img.ProseMirror-selectednode,
.ed-content hr.ProseMirror-selectednode {
  outline: 2px solid #067C78;
  outline-offset: 2px;
}

/* ---------- code ---------- */

.ed-content code,
.doc-body code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.875em;
  background: #F3F8FB;
  border: 1px solid #E2EAF0;
  border-radius: 4px;
  padding: 0.1em 0.35em;
  color: #0F2650;
}

.ed-content pre,
.doc-body pre {
  margin: 0 0 0.85em;
  padding: 14px 16px;
  background: #0F2650;
  color: #E2EAF0;
  border-radius: 8px;
  overflow-x: auto;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre;
  tab-size: 2;
}

.ed-content pre code,
.doc-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ---------- tables ---------- */

.ed-content .tableWrapper,
.doc-body .tableWrapper,
.doc-body .table-wrap {
  overflow-x: auto;
  margin: 0 0 0.85em;
}

.ed-content table,
.doc-body table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0 0 0.85em;
  font-variant-numeric: tabular-nums;
}

.ed-content .tableWrapper > table,
.doc-body .tableWrapper > table,
.doc-body .table-wrap > table {
  margin: 0;
}

.ed-content th,
.ed-content td,
.doc-body th,
.doc-body td {
  position: relative;
  border: 1px solid #E2EAF0;
  padding: 8px 12px;
  vertical-align: top;
  text-align: left;
  min-width: 80px;
}

.ed-content th,
.doc-body th {
  background: #F3F8FB;
  color: #0F2650;
  font-weight: 700;
}

.ed-content th > p,
.ed-content td > p,
.doc-body th > p,
.doc-body td > p {
  margin: 0;
}

.ed-content .selectedCell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(6, 124, 120, 0.12);
  pointer-events: none;
}

/* ---------- callouts ---------- */

.ed-content .callout,
.doc-body .callout {
  margin: 0 0 0.85em;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid #14305F;
  background: #DFEAF8;
  color: #14305F;
}

.ed-content .callout > :last-child,
.doc-body .callout > :last-child {
  margin-bottom: 0;
}

.ed-content .callout strong,
.ed-content .callout a,
.doc-body .callout strong,
.doc-body .callout a {
  color: inherit;
}

.ed-content .callout-info,
.doc-body .callout-info {
  background: #DFEAF8;
  color: #14305F;
  border-left-color: #14305F;
}

.ed-content .callout-warning,
.doc-body .callout-warning {
  background: #FDF1E3;
  color: #5E2C04;
  border-left-color: #5E2C04;
}

.ed-content .callout-success,
.doc-body .callout-success {
  background: #DDF5F3;
  color: #055E5B;
  border-left-color: #055E5B;
}

/* ---------- mention chip ---------- */

.ed-content .mention,
.doc-body .mention {
  display: inline-block;
  background: #DFEAF8;
  color: #14305F;
  border-radius: 999px;
  padding: 0 0.5em;
  font-weight: 600;
  font-size: 0.94em;
  line-height: 1.5;
  white-space: nowrap;
  text-decoration: none;
}

/* ---------- placeholder ---------- */

.ed-content p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: #4B5572;
  opacity: 0.75;
  pointer-events: none;
}

/* ---------- toolbar ---------- */

.ed-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 8px;
  vertical-align: middle;
}

.ed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #1C2B4A;
  font: 600 14px/1 Manrope, system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.ed-btn svg {
  display: block;
  flex: 0 0 auto;
}

.ed-btn:hover {
  background: #F3F8FB;
  color: #0F2650;
}

.ed-btn.is-active {
  background: #DDF5F3;
  color: #055E5B;
  border-color: #067C78;
}

.ed-btn:disabled {
  color: #4B5572;
  opacity: 0.45;
  cursor: default;
  background: transparent;
}

.ed-btn:focus-visible,
.ed-select:focus-visible {
  outline: 2px solid #067C78;
  outline-offset: 2px;
}

.ed-select {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid #E2EAF0;
  border-radius: 8px;
  background: #fff;
  color: #1C2B4A;
  font: 600 14px/1.2 Manrope, system-ui, sans-serif;
  cursor: pointer;
}

/* ---------- suggestion popups (mentions, slash menu) ---------- */

.ed-popup {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  max-width: min(340px, calc(100vw - 16px));
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid #E2EAF0;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 38, 80, 0.16);
  font-family: Manrope, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  color: #1C2B4A;
}

.ed-popup-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.ed-popup-item.is-selected {
  background: #DDF5F3;
  color: #055E5B;
}

.ed-popup-label {
  font-weight: 600;
}

.ed-popup-sub {
  font-size: 12.5px;
  color: #4B5572;
}

.ed-popup-empty {
  padding: 8px 10px;
  color: #4B5572;
}

@media (prefers-reduced-motion: reduce) {
  .ed-btn {
    transition: none;
  }
}

/* ---------- attached file block (editor card and published preview) ---------- */

.ed-content .file-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 0.85em;
  padding: 12px 14px;
  border: 1px solid #B9C6DC;
  border-radius: 8px;
  background: #F3F8FB;
  cursor: default;
  user-select: none;
}

.ed-content .file-card.ProseMirror-selectednode {
  outline: 3px solid #07C5BF;
  outline-offset: 2px;
}

.file-card-kind {
  padding: 2px 8px;
  border-radius: 4px;
  background: #0F2650;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.file-card-name {
  font-weight: 600;
  color: #0F2650;
  overflow-wrap: anywhere;
}

.file-card-hint {
  margin-left: auto;
  font-size: 13px;
  color: #4B5572;
}

.doc-body .file-view {
  margin: 0 0 0.85em;
  border: 1px solid #E2EAF0;
  border-radius: 8px;
  background: #FFFFFF;
  overflow: hidden;
}

.doc-body .file-view > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 14px;
  cursor: pointer;
  list-style: none;
}

.doc-body .file-view > summary::-webkit-details-marker {
  display: none;
}

.doc-body .file-view > summary:hover {
  background: #F3F8FB;
}

.doc-body .file-view .file-toggle {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: #067C78;
}

.doc-body .file-view[open] .file-toggle-show,
.doc-body .file-view:not([open]) .file-toggle-hide {
  display: none;
}

.doc-body .file-view .file-links {
  display: flex;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid #E2EAF0;
  font-size: 13px;
}

.doc-body .file-view iframe {
  display: block;
  width: 100%;
  height: 720px;
  max-height: 85vh;
  border: 0;
  border-top: 1px solid #E2EAF0;
  background: #EAF1F6;
}

.doc-body .file-plain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

/* ---------- code blocks: language bar, copy button, syntax colours ---------- */

.ed-content .code-block,
.doc-body .code-block {
  margin: 0 0 0.85em;
  background: #0F2650;
  border-radius: 8px;
  overflow: hidden;
}

.code-block pre {
  margin: 0 !important;
  border-radius: 0 !important;
}

.code-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  background: #0A1D3F;
  border-bottom: 1px solid rgba(226, 234, 240, 0.12);
  font-family: Inter, system-ui, sans-serif;
  font-size: 12.5px;
  color: #B8C7DA;
  user-select: none;
}

.code-lang {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.code-lang-select {
  font: inherit;
  color: #E2EAF0;
  background: #16315F;
  border: 1px solid rgba(226, 234, 240, 0.22);
  border-radius: 6px;
  padding: 3px 6px;
  max-width: 190px;
}

.code-btn {
  font: inherit;
  font-weight: 600;
  color: #E2EAF0;
  background: transparent;
  border: 1px solid rgba(226, 234, 240, 0.28);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
}

.code-btn:hover {
  background: rgba(226, 234, 240, 0.12);
}

.code-btn:focus-visible,
.code-lang-select:focus-visible {
  outline: 2px solid #7FB2FF;
  outline-offset: 1px;
}

.code-copy {
  margin-left: auto;
}

.code-block .hljs-comment,
.code-block .hljs-quote { color: #8BA0BF; font-style: italic; }
.code-block .hljs-keyword,
.code-block .hljs-selector-tag,
.code-block .hljs-doctag,
.code-block .hljs-meta .hljs-keyword { color: #C4A7FF; }
.code-block .hljs-string,
.code-block .hljs-regexp,
.code-block .hljs-addition,
.code-block .hljs-selector-attr,
.code-block .hljs-selector-pseudo { color: #A6E3A1; }
.code-block .hljs-number,
.code-block .hljs-literal,
.code-block .hljs-symbol,
.code-block .hljs-bullet,
.code-block .hljs-variable,
.code-block .hljs-template-variable { color: #FAB387; }
.code-block .hljs-attr,
.code-block .hljs-attribute,
.code-block .hljs-property,
.code-block .hljs-name,
.code-block .hljs-tag,
.code-block .hljs-selector-class,
.code-block .hljs-selector-id { color: #89DCEB; }
.code-block .hljs-title,
.code-block .hljs-section,
.code-block .hljs-function .hljs-title { color: #89B4FA; }
.code-block .hljs-built_in,
.code-block .hljs-type,
.code-block .hljs-class .hljs-title,
.code-block .hljs-meta { color: #F9E2AF; }
.code-block .hljs-deletion { color: #F38BA8; }
.code-block .hljs-emphasis { font-style: italic; }
.code-block .hljs-strong { font-weight: 700; }

@media print {
  .code-bar .code-btn { display: none; }
}

/* ---------- editing together: other people's cursors and selections ---------- */

.ed-content .live-caret {
  position: relative;
  margin-left: -1px;
  margin-right: -1px;
  border-left: 2px solid;
  pointer-events: none;
  word-break: normal;
}

.ed-content .live-caret-label {
  position: absolute;
  top: -1.45em;
  left: -2px;
  padding: 1px 6px;
  border-radius: 4px 4px 4px 0;
  color: #fff;
  font-family: Manrope, system-ui, sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  user-select: none;
}
