/**
 * Embedded note (discussion 1853): another note, or one section of it, shown
 * inside this one, read only. The source holds a marker line (or the
 * Obsidian form ![[Title#Section]]), which both Markdown parsers rebuild into
 *   <div class="note-embed" data-note-embed="12" data-section="setup">
 *     <a class="note-embed-link" href="index.php?note=12#section-setup">Title</a>
 *   </div>
 * In the app, js/note-embed.js replaces the link with a header and the note
 * itself; a public page (lib/note-embed.php) does the same on the server when
 * the visitor may read that note, an export keeps the link.
 *
 * The body is read with the rules of the page around it: the preview's in
 * the preview and on a share, the note's in the editor views. Only the frame
 * is drawn here.
 */

.note-embed {
    --note-embed-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%3Cpath d='M10 9H8'/%3E%3Cpath d='M16 13H8'/%3E%3Cpath d='M16 17H8'/%3E%3C/svg%3E");
    --note-embed-open-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h6v6'/%3E%3Cpath d='M10 14 21 3'/%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3C/svg%3E");
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin: 0 0 1em;
    padding: 0;
    border: 1px solid var(--pz-border);
    border-radius: var(--pz-radius-sm);
    background: var(--pz-bg);
    color: inherit;
    text-align: left;
    white-space: normal;
}

.note-embed:last-child {
    margin-bottom: 0;
}

/* In a note, `.noteentry div { margin: 0 }` (css/notes/noteentry.css) would
   glue the paragraph that follows to the frame */
.noteentry .note-embed {
    margin: 0 0 1em;
}

.noteentry .note-embed:last-child {
    margin-bottom: 0;
}

/* The header: the note (and section) it shows, a link that opens it, and the
   fallback link before js/note-embed.js has filled the block */
.note-embed .note-embed-header,
.note-embed > .note-embed-link {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 6px 12px;
    font-size: 13px !important;
    line-height: 1.4;
    color: var(--pz-text-muted);
    text-decoration: none;
}

.note-embed .note-embed-header {
    border-bottom: 1px solid var(--pz-border);
    background: var(--pz-surface);
}

.note-embed .note-embed-header::before,
.note-embed > .note-embed-link::before {
    content: "";
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    background-color: var(--pz-accent-text);
    -webkit-mask: var(--note-embed-icon) center / contain no-repeat;
    mask: var(--note-embed-icon) center / contain no-repeat;
}

.note-embed a.note-embed-title,
.note-embed a.note-embed-link {
    overflow: hidden;
    color: var(--pz-accent-text);
    font-weight: var(--pz-weight-medium);
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-embed a.note-embed-title {
    min-width: 0;
    font-size: inherit !important;
}

.note-embed .note-embed-section {
    overflow: hidden;
    min-width: 0;
    font-size: inherit !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-embed a.note-embed-title:hover,
.note-embed a.note-embed-link:hover {
    text-decoration: underline;
}

/* The end of the header: remove the block, Element visibility, open the
   note (js/note-embed.js; a public page has none of them) */
.note-embed .note-embed-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.note-embed .note-embed-action {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--pz-text-subtle);
    cursor: pointer;
}

.note-embed .note-embed-action .lucide {
    font-size: 15px !important;
}

.note-embed .note-embed-visibility:hover {
    color: var(--pz-accent-text);
}

.note-embed .note-embed-delete:hover {
    color: var(--pz-danger-text, var(--pz-accent-text));
}

/* Open the note: an arrow at the end of the header */
.note-embed a.note-embed-open {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    background-color: var(--pz-text-subtle);
    -webkit-mask: var(--note-embed-open-icon) center / contain no-repeat;
    mask: var(--note-embed-open-icon) center / contain no-repeat;
}

.note-embed a.note-embed-open:hover {
    background-color: var(--pz-accent-text);
}

/* The body reads the preview's rules wherever it is (css/markdown.css lists
   .note-embed-body next to .markdown-preview): in the editor views the
   note's own rules would give its paragraphs no margin, and the blank line
   between two of them would vanish. Same line height as the preview. */
.note-embed .note-embed-body {
    padding: 12px 16px;
    overflow-x: auto;
    line-height: 1.4;
}

.note-embed .note-embed-body > :first-child {
    margin-top: 0 !important;
}

.note-embed .note-embed-body > :last-child {
    margin-bottom: 0 !important;
}

/* Loading, not found, circular, not shown here */
.note-embed .note-embed-message {
    margin: 0;
    font-size: 13px !important;
    font-style: italic;
    color: var(--pz-text-muted);
}

.note-embed .note-embed-message.is-error {
    color: var(--pz-danger-text, var(--pz-text-muted));
}

/* An embedded task list note: its tasks as a plain read-only list */
.note-embed .note-embed-tasks {
    margin: 0;
    padding: 0;
    list-style: none;
}

.note-embed .note-embed-task {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 2px 0;
}

.note-embed .note-embed-task.is-subtask {
    padding-left: 24px;
}

.note-embed .note-embed-task.is-done .note-embed-task-text {
    text-decoration: line-through;
    opacity: 0.6;
}

.note-embed .note-embed-task input {
    margin: 3px 0 0;
}
