/**
 * CCR Comment Editor — TipTap-based editor styling.
 *
 * Uses the judging-page CSS variables (--cc-judging-theme-color etc.) so the
 * editor inherits the page theme. When the planned dark/light toggle lands,
 * the same rules will work — just swap the variable values.
 */

/* The Comment tab's parent has display:flex (for the Draw tab's left/right
 * split). For the Comment tab we want toolbar + editor stacked, so override
 * flex-direction here. */
.ccr-add-comment-tab-contents.ccr-addcomment-commenttab {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

/* Toolbar host — sits directly above #ccr-addcomment-editor */
.ccr-editor-toolbar-host {
  background: #ffffff22;
  border: 1px solid #ffffff33;
  border-bottom: 0;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  padding: 4px;
}

.ccr-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.ccr-editor-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  min-width: 36px;
  min-height: 36px;
  padding: 6px 8px;
  text-align: center;
  transition: background-color 0.15s ease;
}

/* Touch-friendly sizing on coarse pointers (tablets, phones) */
@media (pointer: coarse) {
  .ccr-editor-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
  }
}

.ccr-editor-btn:hover,
.ccr-editor-btn:focus-visible {
  background: #ffffff22;
  outline: none;
}

.ccr-editor-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--cc-judging-theme-lighter, #c5b5fb);
}

.ccr-editor-btn.is-active {
  background: var(--cc-judging-theme-color, #4E00FF);
  color: #ffffff;
}

.ccr-editor-btn:disabled,
.ccr-editor-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.35;
}

.ccr-editor-btn:disabled:hover,
.ccr-editor-btn[disabled]:hover {
  background: transparent;
}

.ccr-editor-btn i {
  font-size: 14px;
  line-height: 1;
}

.ccr-editor-divider {
  background: #ffffff33;
  display: inline-block;
  height: 20px;
  margin: 0 2px;
  width: 1px;
}

/* Inline link input — unified box (URL field + apply/open/remove icons all
 * inside one bordered container). Appears below the toolbar buttons when
 * "Link" is clicked. */
.ccr-editor-link-input {
  align-items: center;
  background: #ffffff11;
  border: 1px solid #ffffff33;
  border-radius: 4px;
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  margin-top: 6px;
  padding: 2px;
}

.ccr-editor-link-input[hidden] {
  display: none;
}

.ccr-editor-link-url {
  background: transparent;
  border: 0;
  color: #ffffff;
  flex: 1 1 200px;
  font: inherit;
  font-size: 14px;
  min-height: 32px;
  min-width: 0;
  padding: 4px 8px;
}

.ccr-editor-link-url::placeholder {
  color: #ffffff66;
}

.ccr-editor-link-url:focus {
  outline: none;
}

.ccr-editor-link-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  min-width: 36px;
  min-height: 36px;
  padding: 6px 8px;
  transition: background-color 0.15s ease;
}

.ccr-editor-link-btn:hover,
.ccr-editor-link-btn:focus-visible {
  background: #ffffff22;
  outline: none;
}

.ccr-editor-link-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--cc-judging-theme-lighter, #c5b5fb);
}

.ccr-editor-link-btn i {
  font-size: 14px;
  line-height: 1;
}

.ccr-editor-link-input-divider {
  background: #ffffff33;
  display: inline-block;
  height: 20px;
  margin: 0 4px;
  width: 1px;
}

@media (pointer: coarse) {
  .ccr-editor-link-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
  }
}

/* Editor surface — TipTap mounts a ProseMirror contenteditable inside this div */
#ccr-addcomment-editor {
  background: #ffffff11;
  border: 1px solid #ffffff33;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  color: #ffffff;
  font-size: 14px;
  min-height: 150px;
  padding: 12px 15px;
}

#ccr-addcomment-editor .ProseMirror {
  min-height: 130px;
  outline: none;
}

#ccr-addcomment-editor .ProseMirror:focus {
  outline: none;
}

#ccr-addcomment-editor .ProseMirror p {
  margin: 0 0 0.6em 0;
}

#ccr-addcomment-editor .ProseMirror p:last-child {
  margin-bottom: 0;
}

#ccr-addcomment-editor .ProseMirror h3,
#ccr-addcomment-editor .ProseMirror h4 {
  color: #ffffff;
  font-weight: 600;
  margin: 0.6em 0 0.4em 0;
}

#ccr-addcomment-editor .ProseMirror h3 {
  font-size: 1.15em;
}

#ccr-addcomment-editor .ProseMirror h4 {
  font-size: 1.05em;
}

#ccr-addcomment-editor .ProseMirror ul,
#ccr-addcomment-editor .ProseMirror ol {
  margin: 0 0 0.6em 0;
  padding-left: 1.5em;
}

#ccr-addcomment-editor .ProseMirror li {
  margin: 0.15em 0;
}

#ccr-addcomment-editor .ProseMirror a {
  color: var(--cc-judging-theme-lighter, #c5b5fb);
  text-decoration: underline;
}

/* Placeholder when empty — relies on @tiptap/extension-placeholder, which
 * sets the is-editor-empty class and the data-placeholder attribute on the
 * empty paragraph. */
#ccr-addcomment-editor .ProseMirror p.is-editor-empty:first-child::before {
  color: #ffffff66;
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
}

/* Visual highlight for the link target while the URL input is open.
 * Rendered via the LinkTargetHighlight ProseMirror plugin. Independent
 * of browser focus state — survives the user clicking into the URL
 * input or anywhere else outside the editor. */
#ccr-addcomment-editor .ProseMirror .ccr-editor-link-target {
  background: rgba(197, 181, 251, 0.45); /* --cc-judging-theme-lighter @ ~45% */
  border-radius: 2px;
}
