/* Notes: the tree, the Markdown editor and the rendered note. */
/* ---- Notes layout. It was written with the colours of another application: the hover and the selected
       line named variables that do not exist here, so they fell back on a near-black wash — invisible in
       dark mode — and the borders were lighter than the frames of every other page. ---- */
/* The notes: the tree on the left, what is open on the right — two panels side by side rather than one
   box split in two. The tree follows the page as a long note scrolls past it, and scrolls on its own
   when it is taller than the window. */
.proj-layout { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.proj-sidebar { background: var(--surface); border: 1px solid var(--line-strong); min-width: 0;
  position: sticky; top: .8rem; max-height: calc(100vh - 1.6rem); overflow-y: auto; }
/* The note itself needs no box around it: the writing surface has its own border, and a list of notes
   reads better directly on the page than inside a second frame. */
.proj-content { min-width: 0; }
.nt-retour { display: none; margin-bottom: .6rem; font-weight: 600; }
/* reading and editing a document share the same box, so switching between them never resizes the page */
.proj-doc-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
/* the name of a note is what its author typed, so it is shown as typed — the uppercase of the other h2 of
   the application would shout it */
.proj-doc-title { font-size: 1.3rem; font-weight: 700; border: none; background: transparent; width: 100%; padding: .3rem 0; outline: none; color: var(--text); text-transform: none; letter-spacing: 0; }
.proj-doc-title[readonly] { cursor: default; }
.proj-pane { width: 100%; box-sizing: border-box; min-height: min(62vh, 640px); border: 1px solid var(--line); padding: .8rem; background: var(--surface); }
.proj-editor { font-family: inherit; font-size: .95rem; resize: vertical; color: var(--text); }
.proj-preview { overflow-wrap: anywhere; }
.proj-preview > :first-child { margin-top: 0; }
.proj-item { display: flex; align-items: center; padding: .3rem .45rem; cursor: pointer; gap: .4rem;
  font-size: .9rem; min-width: 0; flex: 1 1 auto; color: var(--text); text-decoration: none; }
.proj-item:hover { background: var(--surface-2); }
.proj-item.active { background: var(--accent-soft); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
/* The arrow that folds a folder is a target of its own, next to the name rather than inside it. */
.proj-folder > .proj-item { display: flex; }
.proj-toggle { flex: none; width: 1.1rem; min-width: 1.1rem; text-align: center; cursor: pointer; color: var(--muted); font-size: .8rem; }
.proj-icon { flex: none; font-size: .95rem; line-height: 1;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.proj-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-action { background: none; border: none; cursor: pointer; opacity: 0; font-size: .9rem; padding: 0 .2rem; color: var(--danger); }
.proj-item:hover .proj-action { opacity: .6; }
.proj-action:hover { opacity: 1 !important; }
.proj-children { padding-left: 1.1rem; }
.proj-doc-title:focus { border-bottom: 2px solid var(--accent) !important; }
@media (max-width: 640px) {
  /* one pane at a time: the tree, or what is open, with « ‹ Notes » to come back */
  .proj-layout { grid-template-columns: 1fr; }
  .proj-sidebar { position: static; max-height: none; }
  .proj-layout.nt-ouvert .proj-sidebar { display: none; }
  .proj-content { min-height: 0; }
  .nt-retour { display: inline-block; }
}


/* ---------- writing: Markdown and its result ---------- */
.md-editor { border: 1px solid var(--line-strong); background: var(--surface); }
.md-bar { display: flex; gap: .2rem; flex-wrap: wrap; padding: .3rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.md-bar button { min-height: 28px; padding: .1rem .45rem; font-weight: 700; }
.md-split { display: grid; grid-template-columns: 1fr 1fr; }
.md-split.single { grid-template-columns: 1fr; }   /* the result is hidden behind the "Aperçu" button */
.md-side { position: relative; min-width: 0; }
.md-side + .md-side { border-left: 1px solid var(--line); }
textarea.md-input { width: 100%; height: 100%; min-height: 16rem; border: 0; resize: vertical; padding: .7rem; font: inherit; background: var(--surface); color: var(--text); }
textarea.md-input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.md-view { padding: .7rem; overflow-wrap: anywhere; min-height: 16rem; }
.md-view.note-read { border: 1px solid var(--line-strong); background: var(--surface); min-height: 24rem; }
.mention-pop { position: absolute; left: .6rem; bottom: .6rem; z-index: 20; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 2px 10px rgba(0,0,0,.3); max-height: 14rem; overflow: auto; min-width: 12rem; }
button.mention-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: .35rem .6rem; min-height: 0; }
button.mention-item.on, button.mention-item:hover { background: var(--accent-soft); }

/* ---------- a note: read first, written on demand ---------- */
/* The button that opens the editor belongs to the note, not to the page: bar and text share one frame, so
   "Modifier" reads as part of what is being read rather than as another header action. */
.doc-block { display: block; border: 1px solid var(--line-strong); background: var(--surface); }
.doc-block .md-editor { border: 0; }
.doc-block .md-view.note-read { border: 0; min-height: 20rem; }
.doc-bar { display: flex; justify-content: flex-end; padding: .35rem .4rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.doc-actions { margin-top: 0; padding: .5rem; border-top: 1px solid var(--line); background: var(--surface-2); align-items: baseline; }
.doc-actions .muted { flex: 1 1 14rem; }

/* the column on the left: search, sections, results */
/* the search field stays in view at the top of the tree, as in Orgacom */
.nt-tools { display: flex; flex-direction: column; gap: .5rem; padding: .6rem; border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.nt-tools input { width: 100%; }
.nt-sec + .nt-sec { border-top: 1px solid var(--line); }
.nt-sec-head { padding: .55rem .7rem .25rem; font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
/* a list of notes in the right pane: one per line, as in Orgacom */
.nt-h2 { margin: 1rem 0 .5rem; }
.nt-list { display: flex; flex-direction: column; border: 1px solid var(--line-strong); background: var(--surface); }
.nt-row { display: flex; align-items: center; gap: .55rem; padding: .55rem .8rem; border-bottom: 1px solid var(--line);
  color: var(--text); text-decoration: none; cursor: pointer; min-width: 0; }
.nt-row:last-child { border-bottom: 0; }
.nt-row:hover { background: var(--accent-soft); }
.nt-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-when { white-space: nowrap; color: var(--muted); font-size: .85rem; }
.nt-results:not(:empty) { border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.proj-item.nt-hit { align-items: flex-start; padding: .45rem .5rem; }
.nt-hit .grow { display: flex; flex-direction: column; gap: .1rem; }
.nt-snip { font-size: .8rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* where the note sits, as a path one can click back through */
.nt-crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .3rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem; }
button.linkish { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }
.nt-meta { margin: .2rem 0 .6rem; }


/* two versions of the same note, side by side, when a save met somebody else's */
.nt-conflict { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.nt-conflict h3 { margin-bottom: .3rem; font-size: .95rem; }
.nt-conflict .md-view { max-height: 24rem; overflow: auto; min-height: 0; }
@media (max-width: 820px) { .nt-conflict { grid-template-columns: 1fr; } }

/* the rendered note */
.md-view > :first-child { margin-top: 0; }
.md-h { margin: .9rem 0 .35rem; text-transform: none; letter-spacing: 0; }
h2.md-h { font-size: 1.25rem; } h3.md-h { font-size: 1.1rem; } h4.md-h { font-size: 1rem; }
.md-p { margin: 0 0 .6rem; line-height: 1.5; }
.md-list { margin: 0 0 .6rem 1.2rem; padding: 0; }
.md-list li { margin: .12rem 0; line-height: 1.45; }
.md-list li.task { list-style: none; margin-left: -1.2rem; display: flex; gap: .45rem; align-items: flex-start; }
.md-list li.task .done { color: var(--muted); text-decoration: line-through; }
input.md-task { margin-top: .25rem; flex: none; }
pre.md-code { background: var(--surface-2); border: 1px solid var(--line); padding: .6rem .7rem; overflow-x: auto; margin: 0 0 .6rem; }
pre.md-code code { font-size: .88rem; }
blockquote.md-quote { margin: 0 0 .6rem; padding: .1rem .8rem; border-left: 3px solid var(--accent); color: var(--muted); }
table.md-table { margin: 0 0 .7rem; border: 1px solid var(--line); }
table.md-table th { position: static; }
.md-chip { display: inline-block; padding: 0 .3rem; font-weight: 600; background: var(--accent-soft); border: 1px solid var(--accent); text-decoration: none; color: var(--text); }
.md-chip.unknown { background: var(--surface-2); border-color: var(--line); color: var(--muted); font-weight: 400; }
a.md-chip:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- notes ---------- */
.proj-quota { padding: .3rem .5rem; border-bottom: 1px solid var(--line); }
.proj-empty { padding: 1rem .5rem; text-align: center; }
.note-welcome { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.note-welcome h2 { text-transform: none; letter-spacing: 0; }

@media (max-width: 900px) {
  .lieux-layout { grid-template-columns: 1fr; }
  .md-split { grid-template-columns: 1fr; }
  .md-side + .md-side { border-left: 0; border-top: 1px solid var(--line); }
  /* two columns left: a quarter becomes a half, three quarters becomes everything */
  .widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget.w1 { grid-column: span 1; } .widget.w2, .widget.w3, .widget.w4 { grid-column: 1 / -1; }
  .kb { grid-template-columns: repeat(5, 78vw); }
  .cal-day { min-height: 4.5rem; }
  button.cal-ev { font-size: .7rem; }
  /* no room beside the month any more: what has no date goes under it */
  .proj-month.with-side { grid-template-columns: minmax(0, 1fr); }
  .proj-side { max-height: 18rem; }
}
@media (max-width: 700px) {
  nav.sub { padding: 0; }
  nav.sub a { padding: .55rem .7rem; }
  .cal-month { font-size: .9rem; grid-template-columns: 1.7rem repeat(7, minmax(0, 1fr)); }
  .cal-day { min-height: 3.6rem; }
  /* no pointer to hover with: the « + » of each day stays visible */
  button.cal-add { opacity: 1; }
  .vtabs { overflow-x: auto; max-width: 100%; }
  .projets-head h1 { flex: 1 1 100%; }
  .fcount { margin-left: 0; }
  /* on a phone every widget takes the whole width, whatever was chosen */
  .widgets { grid-template-columns: 1fr; }
  .widget.w1, .widget.w2, .widget.w3, .widget.w4 { grid-column: 1 / -1; }
}

@media print {
  header.top, .toolbar, .bulk, #toasts, .no-print, .foot { display: none !important; }
  body { background: #fff; color: #000; } main { padding: 0; }
}
