/* ==========================================================================
   Labour Life practice system: linking.css. Owner: linking (M9). SPEC 7.6.4 and 7.6.5.
   The email trail of a company or a task, and the link dialog. Class prefix lnk-.
   Nothing restates a class of the core files or of emails.css. The trail's
   attachment rows and its "pictures are blocked" bar use the em- classes of
   emails.css as they are. Tokens only, no raw colours.
   Phone first: the base styles are the phone.

     Email trail (components/email-trail.js)
       .lnk-trail  .lnk-top (__b)  .lnk-find  .lnk-list-box  .lnk-list  .lnk-more  .lnk-empty-b   the frame of the trail, its search box
       .is-unread on .lnk-conv and .lnk-mail, with .em-dot of emails.css   unread mail (26 Oct 2026)
       .lnk-conv (.is-open, __head __btn __t __s __p __w __k __nm __f __m __n __v __chips)  one conversation, a card
       .lnk-chip  .lnk-clip                                              a task chip, the paperclip
       .lnk-mails (__note)                                               the emails of an open card
       .lnk-mail (.is-open .is-out, __row __btn __tab __top __who __from __head __h __k __v __d __s __open)   one email
       .lnk-way (--received --sent)                                      Received or Sent (27 Oct 2026)
       .lnk-bodybox  .lnk-body  .lnk-text                                the body, in place
       .lnk-atts  .lnk-acts  .lnk-open  .lnk-tab  .lnk-h                 attachments, the row of buttons
       .lnk-atts__head                                                   the heading of the attachments with Save all (5 Nov 2026)
     Link dialog (components/link-dialog.js)
       .lnk-dialog  .lnk-about (__s __f)                                 the email being linked
       .lnk-sugs (__none __how)  .lnk-suglist  .lnk-sug ([aria-pressed], .is-linked, __box __t __n __c __w)   suggestions, each a tick
       .lnk-addrow  .lnk-add                                             "Add to the list"
       .lnk-chosen (__list __i __t __n __s __x)                          the places Link files the email under
       .lnk-warn                                                         the confidential warning
   ========================================================================== */

/* ---------- shared ---------- */

.lnk-h { margin: 0 0 var(--s2); font-size: var(--fs-lg); }
.lnk-clip { display: inline-grid; place-items: center; color: var(--ink-soft); }

/* ---------- the trail ---------- */

.lnk-trail, .lnk-list-box { display: grid; gap: var(--s3); min-width: 0; }
/* The head (26 Oct 2026): the search box of this trail, then New email. */
.lnk-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); }
.lnk-top[hidden] { display: none; }
.lnk-find { flex: 1 1 220px; max-width: 360px; }
.lnk-top__b { display: flex; flex: 1 1 auto; justify-content: flex-end; }
.lnk-top__b:empty { display: none; }
.lnk-top__b > .btn { flex: 1 1 auto; }
.lnk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); min-width: 0; }
.lnk-more { display: flex; justify-content: center; padding: var(--s2) 0; }
.lnk-empty-b { display: flex; justify-content: center; padding: 0 var(--s4) var(--s5); }

/* ---------- one conversation ---------- */

.lnk-conv { min-width: 0; }
.lnk-conv__head { min-width: 0; }
.lnk-conv__btn {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s1) var(--s3); align-items: start;
  width: 100%; min-height: var(--tap); padding: var(--s3) var(--s4);
  border: 0; background: transparent; text-align: left; border-radius: var(--r-md);
}
.lnk-conv__btn:hover { background: var(--tint); }
.lnk-conv__t { grid-column: 1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.lnk-conv__s { font-size: var(--fs-lg); line-height: var(--lh-snug); overflow-wrap: anywhere; }
/* The newest email of the conversation (item 114): From and To, then its first line. */
.lnk-conv__p {
  display: flex; flex-wrap: wrap; gap: 0 var(--s3); min-width: 0;
  color: var(--ink); font-size: var(--fs-sm); line-height: var(--lh-snug);
}
.lnk-conv__w { min-width: 0; overflow-wrap: anywhere; }
.lnk-conv__k { font-weight: 600; color: var(--ink-soft); }
.lnk-conv__f {
  display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-sm); line-height: var(--lh-snug);
}
/* Open, the emails below show their own first lines. */
.lnk-conv.is-open .lnk-conv__f { display: none; }
.lnk-conv__m {
  grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3);
  color: var(--ink-mute); font-size: var(--fs-sm);
}
.lnk-conv__n { font-weight: 600; color: var(--ink-soft); }
.lnk-conv__v {
  grid-column: 2; grid-row: 1 / span 2; align-self: center; display: inline-grid; place-items: center;
  color: var(--ink-soft); transition: transform var(--dur-1) ease;
}
.lnk-conv.is-open .lnk-conv__v { transform: rotate(180deg); }
.lnk-conv__chips { display: flex; flex-wrap: wrap; gap: var(--s2); padding: 0 var(--s4) var(--s3); }
.lnk-chip:hover { background: var(--tint-2); border-color: var(--field-line); }
/* A task chip says the task's title too (decision 473, 12 Nov 2026): one line, cut short with an ellipsis. */
.lnk-chip { min-width: 0; max-width: 100%; }
.lnk-chip > .num { flex: none; }
.lnk-chip__t { min-width: 0; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lnk-conv.is-open .lnk-conv__head { border-bottom: 1px solid var(--line); }

/* ---------- the emails of an open conversation ---------- */

.lnk-mails { list-style: none; margin: 0; padding: 0; display: grid; min-width: 0; }
.lnk-mails__note { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.lnk-mail { min-width: 0; border-top: 1px solid var(--line); }
.lnk-mail:first-child { border-top: 0; }
.lnk-mail__btn {
  display: grid; gap: 2px; width: 100%; min-height: var(--tap); padding: var(--s3) var(--s4);
  border: 0; background: transparent; text-align: left;
}
.lnk-mail__btn:hover { background: var(--tint); }
.lnk-mail.is-open .lnk-mail__btn { background: var(--sunken); box-shadow: inset 3px 0 0 var(--red-ink); }
/* 26 Oct 2026: the row of one email and its "Open in a new tab" beside it. */
.lnk-mail__row { display: flex; align-items: stretch; min-width: 0; }
.lnk-mail__row > .lnk-mail__btn { flex: 1 1 auto; min-width: 0; }
.lnk-mail__tab { flex: 0 0 auto; align-self: center; margin: 0 var(--s2); color: var(--ink-soft); }
.lnk-mail.is-open .lnk-mail__row { background: var(--sunken); }
.lnk-mail__top { display: grid; gap: 2px; min-width: 0; }
.lnk-mail__who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s2); min-width: 0; }
.lnk-mail__from { overflow-wrap: anywhere; }
.lnk-mail__d { display: inline-flex; align-items: center; gap: var(--s2); }
.lnk-mail__s {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  font-size: var(--fs-sm); line-height: var(--lh-snug); overflow-wrap: anywhere;
}
.lnk-mail.is-open .lnk-mail__s { display: none; }
/* 27 Oct 2026: on a computer an email of the trail is a link to its own page in a new tab. */
a.lnk-mail__btn { color: inherit; text-decoration: none; }
a.lnk-mail__btn:hover .lnk-mail__from { text-decoration: underline; text-underline-offset: 2px; }

/* 27 Oct 2026 (Jose: "what is sent and what is received"): Received or Sent,
   an arrow and the word, on every email of a trail and on the newest email
   of a card. Blue for received, green for sent; the word is always there. */
.lnk-way {
  display: inline-flex; align-items: center; gap: 2px; flex: none; align-self: center;
  padding: 1px var(--s2) 1px var(--s1); border: 1px solid; border-radius: var(--r-pill);
  font-size: var(--fs-label); font-weight: 600; line-height: 1.3; white-space: nowrap;
}
.lnk-way--received { color: var(--info-ink); background: var(--info-bg); border-color: var(--info-line); }
.lnk-way--sent { color: var(--success-ink); background: var(--success-bg); border-color: var(--success-line); }
.lnk-mail__who > .em-imp, .lnk-conv__s > .em-imp { margin-right: var(--s2); vertical-align: middle; }

/* Unread (26 Oct 2026): a card with an unread email, and the unread email,
   in bold behind the blue dot of emails.css (.em-dot), on a light blue tint.
   Read ones in normal weight. */
.lnk-conv.is-unread .lnk-conv__s { font-weight: 700; }
.lnk-conv__s .em-dot, .lnk-mail__who .em-dot { display: inline-block; margin-right: var(--s2); vertical-align: middle; }
.lnk-conv.is-unread > .lnk-conv__head { background: var(--info-bg); border-radius: var(--r-md) var(--r-md) 0 0; }
.lnk-conv.is-unread:not(.is-open) > .lnk-conv__head { border-radius: var(--r-md); }
.lnk-mail.is-unread .lnk-mail__from { font-weight: 700; }
.lnk-mail.is-unread:not(.is-open) > .lnk-mail__row { background: var(--info-bg); }

.lnk-mail__open { display: grid; gap: var(--s4); min-width: 0; padding: var(--s3) var(--s4) var(--s4); }
.lnk-bodybox { display: grid; gap: var(--s3); min-width: 0; }
.lnk-bodybox > p { margin: 0; }
/* The frame cannot be measured from outside (it is sandboxed), so its height is fixed and it scrolls by itself. */
.lnk-body { display: block; width: 100%; height: 60vh; border: 0; background: var(--surface); }
.lnk-text { max-height: 60vh; overflow-y: auto; overscroll-behavior: contain; padding: var(--s3) var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); }
.lnk-atts { min-width: 0; }
/* The heading of the attachments with Save all beside it (5 Nov 2026). */
.lnk-atts__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); margin: 0 0 var(--s2); }
.lnk-atts__head > .lnk-h { margin: 0; }

/* One row of buttons under the body, each 44px high, wrapping to a second row. */
.lnk-acts { padding-top: var(--s3); border-top: 1px solid var(--line); }
.lnk-acts > .btn { flex: 1 1 auto; min-height: var(--tap); }

@media (min-width: 720px) {
  .lnk-top__b > .btn, .lnk-acts > .btn { flex: 0 0 auto; }
  .lnk-acts > .lnk-open { margin-left: auto; }
  .lnk-acts > .lnk-tab { margin-left: 0; }
  .lnk-conv__btn { padding: var(--s4) var(--s5); }
  .lnk-conv__chips { padding: 0 var(--s5) var(--s3); }
  .lnk-mail__btn { padding: var(--s3) var(--s5); }
  .lnk-mail__top { grid-template-columns: minmax(0, 1fr) auto; gap: var(--s3); align-items: baseline; }
  .lnk-mail__open { padding: var(--s4) var(--s5) var(--s5); }
  .lnk-mails__note { padding: var(--s3) var(--s5); }
  /* Roomier since 26 Oct 2026 (Jose: "The mail display is too small"). */
  .lnk-body { height: min(75vh, 720px); }
  .lnk-text { max-height: min(75vh, 720px); }
}

/* ---------- the link dialog ---------- */

.lnk-dialog { min-width: 0; }
.lnk-dialog .lnk-h { margin-top: var(--s4); }
.lnk-dialog > .check { margin-top: var(--s2); }
.lnk-dialog > .check + .lnk-h { margin-top: var(--s2); }
.lnk-about { display: grid; gap: 2px; padding: var(--s3) var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--sunken); }
.lnk-about__s { font-weight: 600; overflow-wrap: anywhere; }
.lnk-about__f { overflow-wrap: anywhere; }

.lnk-sugs { min-width: 0; }
.lnk-sugs > .loading { padding: var(--s4); }
.lnk-sugs__none { margin: 0; }
.lnk-suglist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
/* A suggestion is a tick (item 116, 19 Oct 2026): a click puts it on the
   list and a second click takes it off. aria-pressed carries the state; the
   box on the left shows it, and a ticked row has the red wash. */
.lnk-sugs__how { margin: 0 0 var(--s2); }
.lnk-sug {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--s3);
  width: 100%; min-height: var(--control-h-lg); padding: var(--s2) var(--s3);
  border: 1px solid var(--field-line); border-radius: var(--r-sm); background: var(--surface); text-align: left;
  transition: background-color var(--dur-1) ease, border-color var(--dur-1) ease;
}
.lnk-sug:hover { background: var(--sunken); border-color: var(--field-line-hover); }
.lnk-sug:active { background: var(--tint-2); }
.lnk-sug[aria-pressed="true"] { background: var(--red-wash); border-color: var(--red-ink); }
.lnk-sug[disabled] { color: var(--ink-disabled); border-color: var(--line-strong); }
.lnk-sug__box {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border: 2px solid var(--field-line); border-radius: var(--r-xs); background: var(--surface); color: transparent;
}
.lnk-sug[aria-pressed="true"] .lnk-sug__box { border-color: var(--red); background: var(--red); color: var(--on-red); }
.lnk-sug__t { display: grid; gap: 2px; min-width: 0; }
.lnk-sug__n { font-weight: 600; line-height: var(--lh-snug); overflow-wrap: anywhere; }
.lnk-sug__c { margin-left: var(--s2); font-weight: 400; color: var(--ink-soft); font-size: var(--fs-sm); }
.lnk-sug__w { font-size: var(--fs-sm); color: var(--ink-mute); line-height: var(--lh-snug); }
.lnk-sug[disabled] .lnk-sug__w, .lnk-sug[disabled] .lnk-sug__c { color: inherit; }
/* A task the email is linked to already (26 Oct 2026): ticked and fixed, in grey. */
.lnk-sug.is-linked { border-color: var(--line-strong); background: var(--sunken); }
.lnk-sug.is-linked:hover { background: var(--sunken); border-color: var(--line-strong); }
.lnk-sug.is-linked .lnk-sug__box { border-color: var(--ink-soft); background: var(--ink-soft); color: var(--surface); }

/* "Add to the list", then the list of places Link files the email under. */
.lnk-addrow { display: flex; margin: 0 0 var(--s3); }
.lnk-addrow > .btn { flex: 1 1 auto; min-height: var(--tap); }
/* New task under the Task box (decision 471, 12 Nov 2026), with its line while no company is chosen. */
.lnk-newtask { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin: 0 0 var(--s3); }
.lnk-newtask > .btn { flex: 0 0 auto; min-height: var(--tap); }
.lnk-newtask__h { min-width: 0; }
.lnk-chosen { min-width: 0; padding-top: var(--s3); border-top: 1px solid var(--line); }
.lnk-chosen > .lnk-h { margin-top: 0; }
.lnk-chosen__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.lnk-chosen__i {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s2);
  padding: var(--s1) var(--s1) var(--s1) var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--sunken);
}
.lnk-chosen__t { display: grid; gap: 2px; min-width: 0; }
.lnk-chosen__n { font-weight: 600; line-height: var(--lh-snug); overflow-wrap: anywhere; }
.lnk-chosen__s { overflow-wrap: anywhere; }
.lnk-chosen__x { width: var(--tap); height: var(--tap); }

@media (min-width: 560px) {
  .lnk-addrow > .btn { flex: 0 0 auto; }
}

.lnk-warn { margin: 0 0 var(--s3); }
.lnk-sugs > .lnk-warn { margin: var(--s3) 0 0; }

@media print {
  .lnk-top, .lnk-acts, .lnk-more, .lnk-conv__v { display: none; }
}

/* 30 Oct 2026 (decision 354, Jose: "who it was sent to, everyone, who was CC'd ... the subject line"): the head
   of every email of a trail, as Outlook shows it: To and CC with everyone, and the subject, under From. The
   line between two emails is darker, so each email of a conversation stands apart. */
.lnk-mail { border-top-color: var(--line-strong); }
.lnk-mail__head { display: grid; gap: 1px; min-width: 0; margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-soft); }
.lnk-mail__h { overflow-wrap: anywhere; }
.lnk-mail__k { font-weight: 600; color: var(--ink); }
