/* Shared note editor chrome for Next.js and generated Antora pages. Values
   mirror the existing annotation editor and rendered note-card styles in
   globals.css and app-docs.css so the visual surface looks identical to
   both. Consumed by public/app-docs-note-editor.js's create(); the two
   annotation modals wire it in in later commits. */

:root {
  --app-docs-note-editor-ink: #172033;
  --app-docs-note-editor-heading: #23384c;
  --app-docs-note-editor-muted: #7b8c9d;
  --app-docs-note-editor-label: #334e68;
  --app-docs-note-editor-line: #b9c8d5;
  --app-docs-note-editor-line-soft: #d8e2ea;
  --app-docs-note-editor-surface: #fff;
  --app-docs-note-editor-code-surface: #edf2f6;
  --app-docs-note-editor-accent: #1e73be;
  --app-docs-note-editor-focus: #8bc9ff;
  --app-docs-note-editor-link: #116aa6;
  --app-docs-note-editor-danger: #9b2c2c;
}

.app-docs-note-editor {
  display: flex;
  flex-direction: column;
  margin: 0 1.1rem;
  border: 1px solid var(--app-docs-note-editor-line);
  border-radius: 0.5rem;
  background: var(--app-docs-note-editor-surface);
}

.app-docs-note-editor:focus-within {
  border-color: var(--app-docs-note-editor-accent);
  box-shadow: 0 0 0 3px rgb(30 115 190 / 14%);
}

/* Toolbar */

.app-docs-note-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--app-docs-note-editor-line-soft);
}

.app-docs-note-editor-toolbar-separator {
  align-self: stretch;
  width: 1px;
  margin: 0.2rem 0.25rem;
  background: var(--app-docs-note-editor-line-soft);
}

.app-docs-note-editor-toolbar-spacer {
  flex: 1;
}

.app-docs-note-editor .app-docs-note-editor-command {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--app-docs-note-editor-label);
}

.app-docs-note-editor .app-docs-note-editor-command:hover:not(:disabled) {
  border-color: var(--app-docs-note-editor-line);
  background: var(--app-docs-note-editor-code-surface);
}

.app-docs-note-editor .app-docs-note-editor-command[aria-pressed='true'] {
  border-color: var(--app-docs-note-editor-accent);
  background: rgb(30 115 190 / 12%);
  color: var(--app-docs-note-editor-accent);
}

.app-docs-note-editor .app-docs-note-editor-command:focus-visible,
.app-docs-note-editor .app-docs-note-editor-select:focus-visible,
.app-docs-note-editor .app-docs-note-editor-toggle:focus-visible {
  outline: 2px solid var(--app-docs-note-editor-focus);
  outline-offset: 1px;
}

.app-docs-note-editor .app-docs-note-editor-command:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app-docs-note-editor-icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-docs-note-editor .app-docs-note-editor-select {
  height: 1.9rem;
  padding: 0 0.4rem;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--app-docs-note-editor-label);
  font-size: 0.78rem;
}

.app-docs-note-editor .app-docs-note-editor-select:hover {
  border-color: var(--app-docs-note-editor-line);
  background: var(--app-docs-note-editor-code-surface);
}

.app-docs-note-editor .app-docs-note-editor-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 1.9rem;
  padding: 0 0.55rem;
  border: 1px solid var(--app-docs-note-editor-line);
  border-radius: 0.35rem;
  background: transparent;
  color: var(--app-docs-note-editor-label);
  font-size: 0.74rem;
  font-weight: 700;
}

.app-docs-note-editor .app-docs-note-editor-toggle[aria-pressed='true'] {
  border-color: var(--app-docs-note-editor-accent);
  background: rgb(30 115 190 / 12%);
  color: var(--app-docs-note-editor-accent);
}

/* Rich (contenteditable) surface */

.app-docs-note-editor-rich {
  min-height: 7rem;
  /* Caps to a share of the viewport height too, so a short screen still
     leaves room for the modal's header/footer instead of forcing the
     whole popup to scroll just to reach the Salvar button. */
  max-height: min(16rem, 30vh);
  overflow-y: auto;
  padding: 0.7rem 0.8rem;
  overflow-wrap: anywhere;
  color: var(--app-docs-note-editor-ink);
  font-size: inherit;
  line-height: 1.45;
}

.app-docs-note-editor-rich:focus {
  outline: 0;
}

/* An empty note is never a bare :empty container: fromMarkdown always
   seeds a lone <p><br></p> so the paragraph has real click-target height
   (see emptyEditableParagraph in app-docs-note-editor.js). Match that
   shape explicitly, not just :empty, or the placeholder never shows. */
.app-docs-note-editor-rich:empty::before,
.app-docs-note-editor-rich:has(> p:only-child > br:only-child)::before {
  color: var(--app-docs-note-editor-muted);
  content: attr(data-placeholder);
  pointer-events: none;
}

.app-docs-note-editor-rich > * {
  margin: 0.4rem 0 0;
}

.app-docs-note-editor-rich > :first-child {
  margin-top: 0;
}

.app-docs-note-editor-rich h1,
.app-docs-note-editor-rich h2,
.app-docs-note-editor-rich h3 {
  color: var(--app-docs-note-editor-heading);
  line-height: 1.3;
}

.app-docs-note-editor-rich h1 {
  font-size: 1.05rem;
}

.app-docs-note-editor-rich h2 {
  font-size: 0.98rem;
}

.app-docs-note-editor-rich h3 {
  font-size: 0.9rem;
}

.app-docs-note-editor-rich ul,
.app-docs-note-editor-rich ol {
  padding-inline-start: 1.25rem;
}

.app-docs-note-editor-rich blockquote {
  padding-left: 0.65rem;
  border-left: 0.18rem solid var(--app-docs-note-editor-line);
  font-style: normal;
}

.app-docs-note-editor-rich pre {
  max-width: 100%;
  padding: 0.55rem 0.65rem;
  overflow: auto;
  border-radius: 0.4rem;
  background: var(--app-docs-note-editor-code-surface);
  color: var(--app-docs-note-editor-heading);
  white-space: pre;
}

.app-docs-note-editor-rich :not(pre) > code {
  padding: 0.08rem 0.25rem;
  border-radius: 0.25rem;
  background: var(--app-docs-note-editor-code-surface);
  color: var(--app-docs-note-editor-heading);
}

.app-docs-note-editor-rich hr {
  border: 0;
  border-top: 1px solid var(--app-docs-note-editor-line-soft);
}

.app-docs-note-editor-rich a {
  color: var(--app-docs-note-editor-link);
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.13em;
}

/* Raw Markdown textarea (shown instead of the rich surface in raw mode) */

.app-docs-note-editor textarea {
  width: 100%;
  min-height: 7rem;
  padding: 0.7rem 0.8rem;
  resize: vertical;
  border: 0;
  color: var(--app-docs-note-editor-ink);
  font: inherit;
  line-height: 1.45;
}

.app-docs-note-editor textarea:focus {
  outline: 0;
}

.app-docs-note-editor[data-mode='markdown'] .app-docs-note-editor-rich {
  display: none;
}

.app-docs-note-editor[data-mode='rich'] textarea {
  display: none;
}

/* Footer row: character counter and live status */

.app-docs-note-editor-counter {
  margin: 0;
  padding: 0.3rem 0.8rem 0.5rem;
  color: var(--app-docs-note-editor-muted);
  font-size: 0.72rem;
  text-align: end;
}

.app-docs-note-editor-counter[data-limit-reached='true'] {
  color: var(--app-docs-note-editor-danger);
  font-weight: 700;
}

.app-docs-note-editor-hint {
  margin: 0.3rem 0.8rem 0;
  color: var(--app-docs-note-editor-muted);
  font-size: 0.72rem;
}

/* Visually hidden live region (mode announcements): scoped to this module
   so it never depends on either host's own utility class name. */
.app-docs-note-editor-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Link popover, opened by the toolbar's link command */

.app-docs-note-editor {
  position: relative;
}

.app-docs-note-editor-link-popover {
  position: absolute;
  z-index: 1;
  display: flex;
  gap: 0.3rem;
  padding: 0.4rem;
  border: 1px solid var(--app-docs-note-editor-line);
  border-radius: 0.4rem;
  background: var(--app-docs-note-editor-surface);
  box-shadow: 0 0.35rem 0.9rem rgb(23 32 51 / 16%);
  inset-block-start: 2.4rem;
  inset-inline-start: 0.4rem;
}

.app-docs-note-editor-link-input {
  width: 14rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--app-docs-note-editor-line);
  border-radius: 0.3rem;
  font-size: 0.78rem;
}

.app-docs-note-editor-link-input:focus-visible {
  border-color: var(--app-docs-note-editor-accent);
  outline: 2px solid var(--app-docs-note-editor-focus);
  outline-offset: 1px;
}

.app-docs-note-editor-link-confirm {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--app-docs-note-editor-accent);
  border-radius: 0.3rem;
  background: var(--app-docs-note-editor-accent);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
}
