/* Sonaline Fax on the web (fax.js): the Fax door's list, in the list's
 * column as Voicemail's is, and what opens from it in the pane beside it.
 * On a phone the pane covers the list while something is open.
 *
 * Fax is drawn with the app's own pieces, not its own: the list is
 * Voicemail's (.pane-head, .chiprow/.chip, .daylabel, .row with the
 * tinted .avatar, .when, .fab), an open fax is an open voicemail's
 * (.cd-hero, .call-btns), New fax is New chat's head
 * (.nc-head) over the inbox's form fields (.field), and the empty states
 * are .nothing. What is left here is only what those do not cover: the
 * door itself, the pane's place on the desk and on a phone, the PDF's
 * frame, and the pages a new fax is made of. Colours are the theme's
 * tokens; sizes are the shared components' own. */

  /* ---------- the door ---------- */
  body.tab-fax #faxpane { display: flex; }
  body.tab-fax section.list, body.tab-fax section.thread, body.tab-fax section.newchat,
  body.tab-fax #pane-empty, body.tab-fax #vm-open { display: none !important; }
  #faxopen { display: none; }
  .faxui .hidden { display: none !important; }
  /* Fax counts in the accent, as Messages does: an unread fax is
     something to read, not a missed call (HomeNav.kt's door colours). */
  nav.bottomnav #badge-fax { background: var(--primary); }
  /* Six doors on a phone (Fax added to the five): all the width a phone
     has, as five take (app.css data-doors). */
  @media (max-width: 839px) {
    nav.bottomnav[data-doors="6"] { max-width: 390px; }
  }

  /* The shared chips, icon buttons, buttons and back link are drawn
     smaller than a finger (30 to 40px): on the fax screens each takes a
     44px tap target round it, invisible, so the look stays the app's. */
  .faxui :is(.chip, .icon-btn, .btn, .back-link, .nothing button) { position: relative; }
  .faxui :is(.chip, .icon-btn, .btn, .back-link, .nothing button)::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
  }

  /* ---------- the list ---------- */
  /* Nothing to list: the rows give their room to what to do instead. */
  #fax-rows:empty { display: none; }
  #fax-note { margin: 8px auto 0; width: calc(100% - 24px); }
  /* The way a fax went, as a Recents row's arrow (.callrow .what svg). */
  .fx-row .snippet { display: block; }
  /* Why a fax waits or failed, and when it is tried next, is what a
     person looks for: two lines for it rather than an ellipsis. */
  .fx-row .snippet:is(.fx-waiting, .fx-failed) { white-space: normal; display: -webkit-box;
    -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .fx-row .snippet svg { display: inline-block; width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; }
  /* A fax that did not go through, as a text that failed (.meta.bad); one
     on the wire in the text's own colour, so it reads as happening now. */
  .fx-state.fx-failed { color: var(--danger); }
  .fx-state:is(.fx-dialing, .fx-ringing, .fx-connected, .fx-sending) { color: var(--text); }

  /* ---------- the pane ---------- */
  #faxopen { flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
  #faxopen .nc-head .title { margin: 0; font-size: 20px; font-weight: 400;
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fx-body { flex: 1; min-height: 0; overflow: auto; }
  .fx-wait { padding: 24px; color: var(--text-2); }
  /* The desk's pane with nothing open: New fax under the words, as the
     desk's empty pane puts New message (#pane-empty .acts). */
  .fx-pick .acts { justify-content: center; gap: 10px; margin-top: 18px; }

  /* An open fax: the voicemail's head, its buttons, then the document. */
  .fx-viewer { display: flex; flex-direction: column; }
  .fx-hero { flex: none; padding-top: 16px; }
  .fx-hero .avatar { font-size: 28px; }   /* as #cd-body .cd-hero .avatar */
  .fx-hero b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Where the fax stands: one quiet group under the head, the status in
     words with its glyph, the call's steps while it is under way, then
     why, when next and what to do, then the facts. */
  .fx-story { width: calc(100% - 56px); max-width: 560px; margin: 20px auto 0; box-sizing: border-box;
    padding: 16px 20px; border-radius: 16px; background: var(--surface-2); }
  .fx-story-top { display: flex; align-items: center; gap: 10px; }
  .fx-story-top svg { width: 22px; height: 22px; flex: none; fill: var(--text-2); }
  .fx-story .fx-status { font: 500 17px var(--ui); color: var(--text); }
  .fx-story.fx-sent .fx-story-top svg, .fx-story.fx-received .fx-story-top svg { fill: var(--primary); }
  .fx-story.fx-failed .fx-story-top svg, .fx-story.fx-failed .fx-status { fill: var(--danger); color: var(--danger); }
  .fx-story p { margin: 8px 0 0 32px; font-size: 14px; line-height: 1.45; color: var(--text); }
  .fx-story .fx-since { color: var(--text-2); }
  .fx-story .fx-fix { color: var(--text-2); }
  /* The call's steps: four parts of one line, lit as the call gets there. */
  .fx-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 14px 0 2px 32px; }
  .fx-step { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .fx-track { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
  .fx-track i { display: block; height: 100%; background: var(--primary); border-radius: 2px;
    transition: width .2s ease-out; }
  .fx-step-name { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .fx-step.on .fx-step-name { color: var(--text); font-weight: 500; }
  .fx-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 14px 0 0 32px;
    font-size: 14px; }
  .fx-facts dt { color: var(--text-2); }
  .fx-facts dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
  /* The tries: one line a call, its time and what came of it. */
  .fx-calls { margin: 16px 0 0 32px; padding-top: 12px; border-top: 1px solid var(--border); }
  .fx-calls h3 { margin: 0 0 6px; font: 500 11px var(--ui); letter-spacing: 1.2px; text-transform: uppercase;
    color: var(--text-2); }
  .fx-calls ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
  .fx-calls li { display: grid; grid-template-columns: max-content 1fr; gap: 16px; font-size: 14px; color: var(--text); }
  .fx-calls time { color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 64px; }
  .fx-acts.call-btns { flex: none; width: 100%; max-width: 640px; margin: 0 auto; padding: 20px 28px 0; box-sizing: border-box; }
  a.call-btn { text-decoration: none; }
  .fx-frame { flex: 1 0 480px; width: calc(100% - 56px); max-width: 640px; margin: 20px auto 28px;
    border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }

  /* ---------- a new fax ---------- */
  .fx-new { padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 4px; }
  .fx-new .field { margin-bottom: 4px; }
  /* A form, not a page: a readable width in the desk's wide pane. */
  .fx-new { align-items: center; }
  .fx-new > :not(.fx-foot, .fx-file) { width: 100%; max-width: 680px; box-sizing: border-box; }
  .fx-new > .fx-foot { align-self: stretch; }
  /* Send later and the cover page: a check that opens its fields. */
  .fx-opt { display: flex; flex-direction: column; margin-top: 8px; }
  .fx-opt > .field { margin: 14px 0 4px; }
  .fx-opt > .fx-hint { margin: 0 2px 4px; }
  .fx-when { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
  .faxui .field textarea { resize: vertical; min-height: 88px; }
  /* The email choice: a quiet group of two checks, 44px rows. */
  .fx-mail { border: 0; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; column-gap: 24px; }
  .fx-mail legend { padding: 0; margin-bottom: 2px; font-size: 13px; color: var(--text-2); }
  .fx-check { display: flex; align-items: center; gap: 12px; min-height: 44px; color: var(--text); cursor: pointer; }
  .fx-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); }
  .faxui .field input, .faxui .field textarea { box-sizing: border-box; color: var(--text); font: inherit; }
  .faxui .field input[aria-invalid="true"] + label { color: var(--danger); }
  .fx-hint { margin: 6px 2px 12px; font-size: 13px; color: var(--text-2); }
  .fx-hint.fx-bad, .fx-error { color: var(--danger); }
  .fx-error { margin: 4px 2px 8px; font-size: 14px; }

  .fx-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
  /* The pages: an empty slot to choose or drop into (.sdm-empty's dashed
     slot), a list of what is in, and the PDF as it will go. */
  .fx-drop {
    display: flex; align-items: center; gap: 14px;
    min-height: 72px; padding: 12px 16px; margin-top: 4px;
    border: 1.5px dashed var(--border); border-radius: 16px;
    color: var(--text-2); cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
  }
  .fx-drop:hover, .fx-drop:focus-visible, body.fax-drag .fx-drop { background: var(--hover); outline: none; }
  .fx-drop:focus-visible, body.fax-drag .fx-drop { border-color: var(--primary); }
  .fx-drop svg { flex: none; }
  .fx-drop-words { display: flex; flex-direction: column; gap: 2px; }
  .fx-drop-words b { font-weight: 500; font-size: 15px; color: var(--text); }
  .fx-drop-words span { font-size: 13px; }
  /* A file held over the door is a page about to be added, drawn as a
     file held over a conversation is (section.thread.dropping). */
  body.fax-drag #faxpane::after, body.fax-drag #faxopen::after {
    content: ""; position: absolute; inset: 8px; border-radius: 16px;
    border: 2px dashed var(--primary); pointer-events: none;
  }
  body.fax-drag #faxopen { position: relative; }

  .fx-files { list-style: none; margin: 8px 0 12px; padding: 0; display: flex; flex-direction: column; }
  .fx-file-row { display: flex; align-items: center; gap: 14px; padding: 8px 4px 8px 0; }
  .fx-thumb { width: 40px; height: 52px; flex: none; object-fit: cover; border-radius: 4px;
    border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; }
  .fx-thumb-doc svg { color: var(--text-2); }
  .fx-file-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .fx-file-name b { font-weight: 500; font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fx-file-name span { font-size: 13px; color: var(--text-2); }
  /* Up: the back arrow turned to point up. */
  .fx-up svg { transform: rotate(90deg); }
  .faxui .icon-btn:disabled { opacity: .38; cursor: default; }

  .fx-preview { margin-top: 12px; display: flex; flex-direction: column; }
  .fx-preview:empty { display: none; }
  .fx-preview-head { margin: 0; padding: 14px 0 6px; font: 500 11px var(--ui); letter-spacing: 1.2px;
    text-transform: uppercase; color: var(--text-2); }
  .fx-preview .fx-frame { height: 380px; flex: none; width: 100%; margin: 0; }
  .fx-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
    margin-top: 16px; }
  /* Send stays in reach below a long preview: the foot sticks to the
     bottom of the form as it scrolls. */
  .fx-new .fx-foot { position: sticky; bottom: -20px; margin: 16px -20px -20px; padding: 12px 20px 16px;
    background: var(--surface); border-top: 1px solid var(--border); }
  .fx-foot .fx-hint { flex: 1 1 200px; margin: 0; }

  .fx-gap { flex: 1; }

  /* ---------- a phone: the pane covers the list ---------- */
  @media (max-width: 839.98px) {
    /* The head holds only the name, hidden on a phone: it goes, as
       Contacts' does (app.css #contactspane > .pane-head). */
    #faxpane > .pane-head { display: none; }
    body.tab-fax.fax-open #faxpane { display: none; }
    body.tab-fax.fax-open #faxopen {
      display: flex; flex: 1; position: relative; min-height: 0;
    }
    body.tab-fax.fax-open .bottomnav, body.tab-fax.fax-open .navfade { display: none; }
    .fx-preview .fx-frame { height: 320px; }
    .fx-acts.call-btns { padding: 20px 16px 0; }
    .fx-story { width: calc(100% - 32px); padding: 14px 16px; }
    .fx-story p, .fx-steps, .fx-facts, .fx-calls { margin-left: 0; }
    .fx-frame { width: calc(100% - 32px); margin: 16px auto 16px; }
  }
  /* ---------- a desktop: the list's column and the pane beside it ---------- */
  @media (min-width: 840px) {
    body.tab-fax #faxopen {
      display: flex; grid-column: 4; grid-row: 3;
      margin: 0 16px 16px 0; border: 1px solid var(--border); border-radius: 24px; overflow: hidden;
    }
    body.tab-fax.board-dock #faxopen { margin-right: 0; }
    /* The list is beside it: no way back to draw. */
    .fx-top { display: none; }
    .fx-hero { padding-top: 32px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .fx-drop, .fx-track i { transition: none; }
  }
