/* =========================================================================
   views/notes.css — Project Notes — list, cards, empty state, editor modal
   Split from the old monolithic styles/views.css. LOAD ORDER MATTERS:
   the <link> order in Magnet CRM.html / Client App.html reproduces the
   original file order, so the cascade is unchanged — add new rules to the
   matching feature file, not the end of the list.
   ========================================================================= */
/* ====================================================================== */
/* Project Notes (Attio-style) — list, cards, empty state, editor modal   */
/* ====================================================================== */
.cnotes { display: flex; flex-direction: column; gap: var(--space-5); }
/* standalone Notes page (direct child of the scroll area) needs page padding +
   full height so the drag-select marquee has empty space to grab */
#viewScroll > .cnotes { padding: 20px var(--space-6) var(--space-6); min-height: 100%; }
@media (max-width: 640px) {
  #viewScroll > .cnotes { padding: var(--space-4) max(var(--space-4), var(--safe-left)) 0 max(var(--space-4), var(--safe-right)); }
}
.cnotes-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.cnotes-title { font-size: var(--text-xl); font-weight: var(--fw-bold); color: var(--text-strong); letter-spacing: -0.01em; }
.cnotes-new { white-space: nowrap; }

/* card grid */
.cnotes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-3); align-content: start; }
.note-card {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); min-height: 160px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  cursor: pointer; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .note-card:hover { border-color: var(--border-strong); background: var(--gray-25); box-shadow: var(--shadow-xs); }
}
.note-card.sel { border-color: var(--info-600); background: var(--info-bg); box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  .note-card.sel:hover { background: var(--info-bg); }
}
.note-card.sel .note-kebab { opacity: 1; }
.note-card:focus-visible { outline: none; border-color: var(--primary-400); box-shadow: var(--ring-primary); }
.note-card-top { display: flex; align-items: center; gap: var(--space-2); }
.note-card-top .proj-logo.xs { width: 22px; height: 22px; font-size: 11px; }
.note-card-project { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-fav { display: inline-flex; color: var(--warning-600); }
.note-card-fav svg { width: 14px; height: 14px; fill: currentColor; }
.note-card-top .spacer { flex: 1; }
.note-card-top .avatar-sm { width: 24px; height: 24px; font-size: 9px; flex-shrink: 0; }
.note-kebab { flex-shrink: 0; width: 28px; height: 28px; border-color: transparent; background: transparent; opacity: 0; transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.note-kebab svg { width: 15px; height: 15px; }
.note-card:focus-within .note-kebab { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .note-card:hover .note-kebab { opacity: 1; }
}
/* standalone cards (global Notes page) — no header row; kebab floats top-right */
.note-card--bare { position: relative; }
.note-card--bare .note-kebab { position: absolute; top: var(--space-3); right: var(--space-3); }
.note-card--bare .note-card-title { padding-right: 26px; }
.note-card--bare .note-card-foot .note-card-fav { margin-left: var(--space-1); }
.note-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.note-card-title { font-size: var(--text-md); font-weight: var(--fw-semibold); color: var(--text-strong); line-height: var(--leading-snug); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card-preview { font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-card-foot { display: flex; align-items: center; gap: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border-faint); }
/* author profile photo fills the round avatar (vs the initials fallback) */
.note-author-av { background: var(--gray-100); }
.note-author-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.note-card-author { font-size: var(--text-xs); font-weight: var(--fw-medium); color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-date { font-size: var(--text-xs); color: var(--text-soft); white-space: nowrap; flex-shrink: 0; margin-left: auto; }

/* mobile: no hover to reveal the kebab, so show it always; and drop the
   sticky :hover highlight that lingers after a tap and reads as "selected". */
@media (max-width: 640px) {
  .note-kebab { opacity: 1; }
  @media (hover: hover) and (pointer: fine) {
    .note-card:hover { border-color: var(--border); background: var(--surface); box-shadow: none; }
  }
}

/* empty state */
.cnotes-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); min-height: 56vh; padding: var(--space-6); text-align: center; }
.cnotes-empty-ico { width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-lg); background: var(--gray-100); color: var(--text-soft); margin-bottom: 2px; }
.cnotes-empty-ico svg { width: 25px; height: 25px; }
.cnotes-empty h3 { font-size: var(--text-lg); font-weight: var(--fw-semibold); color: var(--text-strong); }
.cnotes-empty p { font-size: var(--text-sm); color: var(--text-muted); max-width: 320px; }
.cnotes-empty-new { margin-top: var(--space-4); }

/* note actions menu (reuses .filter-menu / .cfile-menu styling) */
.note-menu { position: fixed; min-width: 210px; z-index: var(--z-popover); }

/* ---------------------------------------------------------------------- */
/* Note editor modal                                                      */
/* ---------------------------------------------------------------------- */
.ne { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ne-bar { flex-shrink: 0; display: flex; align-items: center; gap: var(--space-2); padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--border); }
.ne-bar-id { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }
.ne-bar-id .proj-logo.xs { width: 22px; height: 22px; font-size: 11px; }
.ne-bar-ico { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; color: var(--text-soft); }
.ne-bar-ico svg { width: 17px; height: 17px; }
.ne-bar-name { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ne-bar-title, .ne-bar .ne-bar-done { display: none; }   /* mobile bottom-sheet header only */
.ne-bar-spacer { flex: 1; }
.ne-bar-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-soft); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .ne-bar-btn:hover { background: var(--nav-hover-bg); color: var(--text-strong); }
}
.ne-bar-btn svg { width: 17px; height: 17px; }
.ne-bar-copy { width: auto; gap: 6px; padding: 0 11px; font-size: var(--text-sm); font-weight: var(--fw-medium); }
.ne-bar-copy svg { width: 15px; height: 15px; }

.ne-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.ne-doc { max-width: 720px; margin: 0 auto; padding: var(--space-8) var(--space-8) var(--space-12); }
.ne-title { width: 100%; border: 0; outline: 0; background: transparent; padding: 0; margin: 0 0 var(--space-3); font-family: var(--font-sans); font-size: var(--text-3xl); font-weight: var(--fw-bold); line-height: 1.18; letter-spacing: -0.02em; color: var(--text-strong); resize: none; overflow: hidden; }
.ne-title::placeholder { color: var(--text-soft); }
.ne-title:focus, .ne-title:focus-visible { outline: none; box-shadow: none; border: 0; }
.ne-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-5); padding-bottom: var(--space-5); border-bottom: 1px solid var(--border-faint); }
.ne-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-full); background: var(--gray-100); font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text); }
.ne-chip .proj-logo.xs { width: 16px; height: 16px; font-size: 9px; }
.ne-chip-add { background: transparent; border: 1px dashed var(--border-strong); color: var(--text-soft); cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .ne-chip-add:hover { background: var(--surface-hover); color: var(--text); border-color: var(--primary-300); }
}
.ne-chip-add svg { width: 14px; height: 14px; }

/* the writing surface */
.ne-editor { min-height: 280px; font-size: var(--text-base); line-height: var(--leading-relaxed); color: var(--text); border: 0; outline: 0; background: transparent; resize: none; }
.ne-editor:focus, .ne-editor:focus-visible { outline: none; box-shadow: none; border: 0; }
.ne-editor:empty::before { content: attr(data-placeholder); color: var(--gray-400); pointer-events: none; }
/* Auto-linked + manually-inserted URLs read as real hyperlinks (base.css resets
   anchors to inherit/none). Shared by the notes editor and the Tasks description
   (.td-desc.ne-editor), so .td-desc is covered too. */
.ne-editor a { color: var(--info-600); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.ne-editor a:hover { text-decoration-thickness: 2px; }
/* every direct line is tight by default; line-height controls the rhythm so
   plain text lines stay evenly spaced whether the browser wraps them in a
   <div> or a <p>. Only real blocks (headings, lists, hr, images) add margin. */
.ne-editor > * { margin: 0; }
.ne-editor > p, .ne-editor > div { margin: 0; }
.ne-editor > h1, .ne-editor > h2, .ne-editor > h3 { margin: 0.8em 0 0.2em; }
.ne-editor > h1:first-child, .ne-editor > h2:first-child, .ne-editor > h3:first-child { margin-top: 0; }
.ne-editor > ul, .ne-editor > ol, .ne-editor > .ne-todo { margin: 0.4em 0; }
.ne-editor > .ne-hr { margin: 1em 0; }
.ne-editor > .ne-img-ph { margin: 0.6em 0; }
.ne-editor > *:last-child { margin-bottom: 0; }
.ne-editor h1 { font-size: var(--text-2xl); font-weight: var(--fw-bold); letter-spacing: -0.01em; color: var(--text-strong); line-height: 1.25; }
.ne-editor h2 { font-size: var(--text-xl); font-weight: var(--fw-bold); color: var(--text-strong); line-height: 1.3; }
.ne-editor h3 { font-size: var(--text-lg); font-weight: var(--fw-semibold); color: var(--text-strong); line-height: 1.35; }
.ne-editor p { font-size: var(--text-base); }
.ne-editor ul, .ne-editor ol { padding-left: 1.5em; }
.ne-editor ul { list-style: disc; }
.ne-editor ol { list-style: decimal; }
.ne-editor li { margin-bottom: 0.25em; display: list-item; }
.ne-editor li::marker { color: var(--text-soft); }
.ne-img-ph { display: flex; align-items: center; gap: var(--space-3); margin: 0.6em 0; padding: 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--gray-25); color: var(--text-soft); font-size: var(--text-sm); }
.ne-img-ph svg { width: 20px; height: 20px; flex-shrink: 0; }
.ne-img-ph code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--text-xs); }
