/* Sending the files to the client's own server or bucket
   (js/recipient-send*.js): the chooser, the destination forms, the test, the
   transfer's progress, and the short list of earlier transfers on the page.
   The sheet is app.css's .overlay and .sheet; fields are components.css's
   .field .lbl .text .hint .err; buttons, tags, bars and callouts are
   app.css's. This adds only what they don't have. Loaded after
   recipient-download.css.

   The chooser:
     How do you want to receive these files?
     [ [icon] Download in my browser                          ]
     [ [icon] Send to my server (SFTP)               [Suggested] ]
     [ [icon] Send to my S3 bucket                   [Suggested] ]

   The SFTP form (the port sits beside the address on a wide screen):
     Server address [ files.example.com      ]  Port [ 22 ]
     Username       [                        ]
     How do you sign in?   (o) A private key  ( ) A password
     Private key    [ textarea ]  [Choose key file]
     Folder         [ /incoming/theirway     ]

   The page's list of earlier transfers:
     Sent to your own server
     alice@files.example.com:22, folder /in  [Done]  214 of 214 files  View

   Shapes: the choices are 12px cards, the icon a rounded square, the
   fingerprint a framed block of its own, states are .tag words. The advice
   is information (callout.info) and the fingerprint check a caution (the
   default, amber callout); neither is a selection, so neither is the
   accent. */

.rc-send { max-width: 600px; }

/* The form's sheet is as tall as a sheet gets, always. A field's error
   appears when it loses focus, and on a shorter sheet that would move the
   footer between the press and the release of a click on "Test the
   connection", so the click would land on the footer and do nothing. */
.rc-send[data-step=form],
.rc-send[data-step=testing] { height: 86vh; }
.rc-send[data-step=form] .body,
.rc-send[data-step=testing] .body { flex: 1; min-height: 0; }
.rc-send footer { flex-wrap: wrap; }
.rc-send .callout p { margin: 0; }
.rc-send .callout p + p { margin-top: var(--space-2); }

/* --- the chooser ------------------------------------------------------ */

.callout.rc-send-advice { margin: 0 0 var(--space-4); max-width: none; }
.rc-rails-pick { display: grid; gap: var(--space-3); }

/* A choice is a card: hover darkens the edge and lifts the ground a step,
   press gives a little (the same 100ms as a button), focus is the app's. */
.rc-rail {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--control-l);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-l);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform 100ms var(--ease-out);
}
.rc-rail:hover { border-color: var(--ink2); background: var(--hover); }
.rc-rail:active { transform: scale(.99); }

/* The icon sits in a rounded square on the sunken ground. It is neutral:
   the accent is for what the client has chosen, and nothing is chosen yet. */
.rc-rail-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: var(--control);
  height: var(--control);
  border-radius: var(--radius-control);
  background: var(--sunken);
  color: var(--ink2);
}
.rc-rail-icon svg { width: var(--icon-l); height: var(--icon-l); }

.rc-rail-text { flex: 1; min-width: 0; }
.rc-rail-text b { display: block; font-weight: 500; }
.rc-rail-text .s { display: block; color: var(--ink2); }
.rc-rail-tag { flex: none; }

.rc-send-privacy { margin: var(--space-4) 0 0; color: var(--ink2); }

/* --- the form ----------------------------------------------------------- */

.rc-send-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8rem;
  gap: var(--space-4);
}
.rc-send-form .field { grid-column: 1 / -1; min-width: 0; margin: 0; }
.rc-send-form .field[data-box=host] { grid-column: 1; }
.rc-send-form .field[data-box=port] { grid-column: 2; }

/* .field says display:block, which would beat the hidden attribute that
   hides the key's or the password's box. */
.rc-send-form [hidden] { display: none; }

/* The two ways to sign in sit side by side. */
.rc-send-form fieldset.checks { display: flex; flex-wrap: wrap; gap: 0 var(--space-5); }
.rc-send-form fieldset.checks legend { width: 100%; }

/* A key is long lines of characters: it scrolls inside its box, never the
   page. */
.rc-send-key {
  min-height: calc(var(--control) * 3);
  font: 400 var(--text-m)/18px var(--font-mono);
  white-space: pre;
  overflow: auto;
}
.rc-send-pick { margin-top: var(--space-2); }

.rc-send-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-size: var(--text-l);
  line-height: 22px;
}
.rc-send-form + .rc-send-status { margin-top: var(--space-4); }
.rc-send-where { margin: 0 0 var(--space-4); color: var(--ink2); overflow-wrap: anywhere; }
.rc-send-problem { margin-bottom: var(--space-4); }

/* The fingerprint is on its own line: it is 50 characters, and what the
   client has to compare. */
.rc-send-print { margin: 0 0 var(--space-4); }
.rc-send-print code { font: 400 var(--text-m)/18px var(--font-mono); overflow-wrap: anywhere; }
.rc-send-print [data-part=send-fingerprint] { display: block; margin-top: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); }

@media (max-width: 520px) {
  .rc-send-form { grid-template-columns: minmax(0, 1fr); }
  .rc-send-form .field[data-box=host],
  .rc-send-form .field[data-box=port] { grid-column: 1; }
}

/* --- the transfer ------------------------------------------------- */

.rc-send-state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-3); }
.rc-send-state .s { min-width: 0; overflow-wrap: anywhere; }
.rc-send-bar { height: var(--space-2); }
.rc-send-amount { margin: var(--space-2) 0 0; }
.rc-send-result { margin: var(--space-3) 0 0; font-size: var(--text-l); line-height: 22px; }
.rc-send-trouble { margin: var(--space-2) 0 0; color: var(--warning-fg); }

.rc-send-failed {
  max-height: 40vh;
  margin: var(--space-4) 0 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  list-style: none;
}
.rc-send-failed li { display: grid; gap: var(--space-0); padding: var(--space-2) var(--space-3); }
.rc-send-failed li + li { border-top: 1px solid var(--line2); }
.rc-send-name { overflow-wrap: anywhere; }

/* --- earlier transfers, on the page ------------------------------- */

.rc-sends { max-width: 720px; margin: 0 0 var(--space-5); }
.rc-sends-title { margin: 0 0 var(--space-3); font: 500 var(--text-l)/22px var(--font-sans); color: var(--ink); }
.rc-sends-list { margin: 0; padding: 0; overflow: hidden; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.rc-sends-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem 12rem auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.rc-sends-row + .rc-sends-row { border-top: 1px solid var(--line2); }
.rc-sends-where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-sends-row .tag { justify-self: start; }
.rc-sends-counts { text-align: right; }

/* On a phone the address has a line to itself, then the state, the counts
   and View share the next. */
@media (max-width: 520px) {
  .rc-sends-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); }
  .rc-sends-where { grid-column: 1 / -1; }
  .rc-sends-counts { text-align: left; }
}
