/**
 * editor-blocks.css — Read and print styling for the `::name` editor elements.
 *
 * Scoped to `nb-*` class names, which is what `markdown-print.js` emits. The
 * in-editor rendering is done by the CodeMirror plugins (each carries its own
 * `createTheme` and uses `cm-*` classes), so nothing here applies while editing
 * and the two surfaces cannot collide.
 */

.nb-divider {
  display: flex;
  align-items: center;
  gap: 0.75em;
/*   margin: 1.5em 0; */
  break-inside: avoid;
  page-break-inside: avoid;
}

.nb-divider-rule {
  flex: 1 1 auto;
  height: 1px;
  background: var(--color-border, #d0d7de);
}

.nb-divider-label {
  flex: 0 0 auto;
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted, #6a737d);
  white-space: nowrap;
}

/* Without a label the widget is a bare rule. */
.nb-divider:not(:has(.nb-divider-label)) {
  border-top: 1px solid var(--color-border, #d0d7de);
  height: 0;
  gap: 0;
}

/*
 * Older WebKit and any server-side renderer without `:has()` would otherwise get
 * a flex row with no children, which collapses to zero height and loses the rule
 * entirely. A border on the wrapper is the fallback.
 */
@supports not selector(:has(*)) {
  .nb-divider {
    border-top: 1px solid var(--color-border, #d0d7de);
    height: 0;
  }
}

.nb-signature {
  display: flex;
  align-items: center;
  gap: 0.5em;
/*   margin: 1.5em 0; */
  break-inside: avoid;
  page-break-inside: avoid;
}

.nb-signature-icon {
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  opacity: 0.6;
}

.nb-signature-text {
  flex: 0 0 auto;
  font-size: 0.9em;
  color: var(--color-text-muted, #6a737d);
  white-space: nowrap;
}

.nb-signature-rule {
  flex: 1 1 auto;
  height: 1px;
  min-width: 6em;
  background: var(--color-border, #d0d7de);
}

/*
 * In the editor these widgets are click-to-edit: clicking one hands the caret to
 * the raw `::directive` so it can be typed into directly (see selection-touch.js
 * `focusLabel`). The text cursor and a faint tint advertise that. Print and read
 * surfaces never hover, so nothing here reaches them.
 */
.nb-divider:hover,
.nb-signature:hover {
  cursor: text;
  background: rgba(127, 127, 127, 0.08);
  border-radius: 4px;
}

/*
 * In-place edit mode. The widget keeps its rendered rule / signing line, but the
 * middle is a transparent `<input>` so the content is typed directly with no
 * `::directive` source ever shown. `.nb-divider--edit` has to undo the
 * label-less border rule above, which the input is invisible to.
 */
.nb-divider.nb-divider--edit {
  border-top: none;
  height: auto;
  gap: 0.75em;
}

.nb-divider-edit,
.nb-signature-edit {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-weight: inherit;
  color: var(--color-text-muted, #6a737d);
  border-radius: 3px;
  outline: none;
}

.nb-divider-edit:focus,
.nb-signature-edit:focus {
  background: rgba(127, 127, 127, 0.12);
}

.nb-divider-edit {
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.nb-signature-edit {
  font-size: 0.9em;
}

/*
 * In-place edit mode hides a fenced block's `::name` / `::` line by replacing it
 * with this zero-height block widget, so the caret can never rest on the raw
 * markdown. It must not be `display:none`: CodeMirror measures the widget, and a
 * replaced line has to still exist as a box.
 */
.cm-fence-skip {
  display: block;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.nb-arrow {
  display: inline-block;
  box-sizing: border-box;
/*   margin: 0 0.35em; */
  /* Clears the specified polygons' 8px notches on both sides. */
  padding: 0 14px;
  border-radius: 3px;
  font-size: 0.85em;
  line-height: 1.6;
  background: var(--nb-arrow-bg, #6b7280);
  color: var(--nb-arrow-text, #ffffff);
  isolation: isolate;
}

/*
 * The specified shapes, verbatim — the same polygons as `arrow-plugin.js`, kept
 * in step deliberately. Each is one continuous figure, so the tab and its
 * pointer cannot show a seam.
 */
.nb-arrow-right {
  clip-path: polygon(0% 0%, calc(100% - 8px) 0%, 100% 50%, calc(100% - 8px) 100%, 100% 100%, 0% 100%, 8px 50%);
}

.nb-arrow-left {
  clip-path: polygon(100% 0%, calc(100% - 8px) 50%, 100% 100%, 8px 100%, 0% 50%, 8px 0%);
}

/* ------------------------------------------------------------------ *
 * PDF embed — browser PDF viewer in an iframe card
 * ------------------------------------------------------------------ */

.nb-pdf {
  display: block;
  margin: 0.75em 0;
  padding: 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

.nb-pdf-frame {
  display: block;
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--color-border, #d0d7de);
  border-radius: 6px;
  background: var(--color-surface, #fff);
}

.nb-pdf-caption {
  padding: 0.35em 0 0;
  color: var(--color-text-muted, #6a737d);
  font-size: 0.85em;
  line-height: 1.4;
}

/* ------------------------------------------------------------------ *
 * Casing — a whole block framed in one colour
 * ------------------------------------------------------------------ */

.nb-casing {
  display: block;
  box-sizing: border-box;
  margin: 0.75em 0;
  padding: 2px 10px;
  border: 1px solid var(--nowt-case-border, #9aa1ac);
  border-radius: 3px;
  background: var(--nowt-case-bg, #d3d7dc);
  color: var(--nowt-case-text, #1a1a1a);
  break-inside: avoid;
  page-break-inside: avoid;
}

.nb-casing-title {
  padding: 3px 0 1px;
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nb-casing-line {
  padding: 1px 0;
  white-space: pre-wrap;
}

/* ------------------------------------------------------------------ *
 * Compaction — a summary that discloses its detail
 * ------------------------------------------------------------------ */

.nb-compaction {
  display: block;
  box-sizing: border-box;
  margin: 0.75em 0;
  padding: 2px 10px;
  border-left: 2px solid var(--nowt-comp-border, var(--color-border, #9aa1ac));
  border-radius: 0 3px 3px 0;
  /* The same three variables the editor plugin paints with, so a printout
   * carries the block's own colour instead of the generic grey. */
  background: var(--nowt-comp-bg, rgba(127, 127, 127, 0.08));
  color: var(--nowt-comp-text, inherit);
  break-inside: avoid;
  page-break-inside: avoid;
}

.nb-compaction-summary {
  cursor: pointer;
  font-weight: 500;
  /* The default disclosure triangle is the affordance; keep it. */
  list-style: revert;
  margin: 0;
}

.nb-compaction-body {
  /* No visual of its own — the indent lives on the lines — but `display: block`
   * keeps the body from collapsing to one run of text if it ever lands in a
   * flex container, and it is the stable hook for print overrides. */
  display: block;
}

.nb-compaction-line {
  padding-left: 1.2em;
  color: var(--color-text-muted, #6a737d);
}

@media print {
  .nb-divider,
  .nb-signature,
  .nb-casing,
  .nb-compaction {
    /* A rule or a framed box that lands at a page break reads as a stray line. */
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* On paper the disclosure triangle is meaningless — the content is always
   * shown — and the summary is no longer a control, so it is left unstyled
   * except for its weight. */
  .nb-compaction-summary {
    list-style: none;
    cursor: default;
  }
}
