/* Note list and note cards, with their pictures and files. */

#notes {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-content: start;
  gap: 0.5rem;
  margin: 0;
  padding: 1rem;
  list-style: none;
}
/* The empty list must not push the "No notes" text down */
#notes:empty { flex: 0; padding: 0; }

.note {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.7rem 0.35rem 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  touch-action: pan-y;               /* horizontal moves are ours: swipe to delete */
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.15s;
}
.note.swiping { transition: none; user-select: none; }
.note:focus-visible { outline-offset: 0; }

.note-body { flex: 1; min-width: 0; }
.note-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.pending {
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.actions { display: flex; margin-top: -0.35rem; }
.actions button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.actions button:hover { background: var(--hover); color: var(--fg); }
.actions .delete:hover { color: var(--danger); }
.actions .edit { display: none; }   /* touch: tap the note itself; shown with a mouse */

.skeleton {
  height: 4.25rem;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--skel) 25%, var(--skel-hi) 50%, var(--skel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { margin: 2rem 1rem; text-align: center; color: var(--muted); }
.kbd-hint { display: none; }

/* ---------- Attachments in notes ---------- */

.note-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.note-text + .note-images, .note-text + .note-files { margin-top: 0.5rem; }
.note-body > :first-child { margin-top: 0; }
.thumb {
  display: block;
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.note-images.single { grid-template-columns: 1fr; }
.note-images.single .thumb { aspect-ratio: auto; max-height: 18rem; }
.note-images.single .thumb img { max-height: 18rem; }
.thumb.broken { aspect-ratio: 1; max-width: 5.5rem; }
.thumb.broken img { visibility: hidden; }

.note-files { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }
.file-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  font-size: 0.875rem;
}
.file-chip:hover { border-color: var(--accent); }
.file-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip small { color: var(--muted); }
.file-chip svg { color: var(--muted); }

/* Tapping a note opens the editor */
.note { cursor: pointer; }

@media (hover: hover) and (pointer: fine) {
  .note:hover { box-shadow: 0 2px 10px rgb(0 0 0 / 0.06); }
  .note .actions { opacity: 0; transition: opacity 0.15s; }
  .actions .edit { display: grid; }
  .note:hover .actions,
  .note:focus .actions,
  .note:focus-within .actions { opacity: 1; }
  .kbd-hint { display: inline; }
}

/* Wide screens: notes as a card grid */
@media (min-width: 48rem) {
  #notes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1rem;
    padding: 0;
  }
  .note { flex-direction: column; min-height: 7.5rem; padding: 1rem 1rem 0.5rem; }
  .note-body { width: 100%; }
  .actions { align-self: flex-end; margin: 0 -0.5rem 0 0; }
  .skeleton { height: 7.5rem; }

  .empty { margin: 3rem 0; }
}
