/* ================================================================
   NOTES PAGE (notes-page.js): list | title + editor | backlinks.
   Every rule is scoped under #page-notes. BlockNote's own sheet
   (../vendor/blocknote/blocknote.bundle.css) is injected on first open and
   is scoped to .bn-* / Mantine classes. Height is set by notes-page.js.
   Tokens: ../styles/variables.css.
   ================================================================ */

#page-notes {
  padding: 0;
  display: flex;
  min-height: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui-font);
}

#page-notes.hidden { display: none; }

/* ---- the list ----------------------------------------------------------- */
#page-notes .nt-side {
  flex: 0 0 250px;
  width: 250px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  padding: 30px 10px 12px;   /* clears the notch under the topbar */
  background: var(--panel-deep);
  border-right: 1px solid var(--border);
}

#page-notes .nt-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

#page-notes .nt-new {
  align-self: flex-start;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

#page-notes .nt-list,
#page-notes .nt-back {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
}

#page-notes .nt-list { flex: 1; }

#page-notes .nt-item-btn,
#page-notes .nt-back-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

#page-notes .nt-item-btn:hover,
#page-notes .nt-back-btn:hover { background: rgb(var(--tint-rgb) / calc(0.08 * var(--tint-k))); }
#page-notes .nt-item.is-open .nt-item-btn { background: rgb(var(--tint-rgb) / calc(0.14 * var(--tint-k))); }

#page-notes .nt-item-title,
#page-notes .nt-back-note {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#page-notes .nt-item-snip,
#page-notes .nt-back-text {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

#page-notes .nt-list-empty,
#page-notes .nt-list-err,
#page-notes .nt-back-empty {
  padding: 8px 9px;
  font-size: 12px;
  color: var(--muted);
}

/* ---- the note ----------------------------------------------------------- */
#page-notes .nt-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 30px 0 80px;
}

#page-notes .nt-head,
#page-notes .nt-notice,
#page-notes .nt-empty {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 54px;   /* lines up with BlockNote's own side padding */
  box-sizing: border-box;
}

#page-notes .nt-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

#page-notes .nt-title {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--prose-heading, var(--text));
  font-family: var(--prose-font, inherit);
  font-size: 30px;
  font-weight: 700;
  outline: none;
}

#page-notes .nt-status {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

#page-notes .nt-status.is-bad { color: var(--danger); }

#page-notes .nt-del {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

#page-notes .nt-del[data-armed] { border-color: var(--danger); color: var(--danger); }

#page-notes .nt-notice {
  margin-top: 10px;
  font-size: 13px;
  color: var(--danger);
}

#page-notes .nt-reload {
  margin-left: 6px;
  padding: 3px 9px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: none;
  color: var(--danger);
  font: inherit;
  cursor: pointer;
}

#page-notes .nt-empty { margin-top: 40px; color: var(--muted); }

#page-notes .nt-editor {
  max-width: 760px;
  margin: 12px auto 0;
}

#page-notes .nt-editor .bn-container,
#page-notes .nt-editor .bn-editor { background: transparent; }

/* [[ wikilinks and (( block refs, drawn by the bundle's React renderers. */
#page-notes .ddn-wikilink {
  color: var(--prose-link, var(--accent));
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}

#page-notes .ddn-blockref {
  padding: 0 4px;
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  background: rgb(var(--tint-rgb) / calc(0.08 * var(--tint-k)));
  cursor: pointer;
}

#page-notes .ddn-wikilink.is-missing,
#page-notes .ddn-blockref.is-missing {
  color: var(--muted);
  text-decoration: line-through;
  cursor: default;
}

#page-notes .ddn-flash { animation: ddn-flash 1.6s ease-out; border-radius: 6px; }

@keyframes ddn-flash {
  from { background: rgb(var(--tint-rgb) / calc(0.28 * var(--tint-k))); }
  to { background: transparent; }
}

/* ---- backlinks ---------------------------------------------------------- */
#page-notes .nt-links {
  flex: 0 0 260px;
  width: 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 30px 10px 12px;
  border-left: 1px solid var(--border);
}

#page-notes .nt-links-head {
  margin: 0 9px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 1100px) {
  #page-notes .nt-links { display: none; }
}

@media (max-width: 720px) {
  #page-notes .nt-side { flex-basis: 170px; width: 170px; }
  #page-notes .nt-head,
  #page-notes .nt-notice,
  #page-notes .nt-empty { padding: 0 16px; }
}
