/* The document pane, and the column of the Vorgang's files at the right edge.
 *
 * The pane shows whatever is open, and says so when nothing is. The files have
 * a column of their own, so the list a document came from stays in sight
 * beside it and the next one is a click away.
 */

/* A column: the header, and the body that takes the rest. */
.doc {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Level with the other column headers. It names what is open and holds what
 * can be done with it, so the whole body below is the document's; the height
 * is fixed rather than a minimum, so a name and four buttons cannot push it
 * out of line with its neighbours. A container, so the buttons can drop their
 * words when the pane is narrow. */
.doc-head {
  flex: none;
  container: doc-head / inline-size;
  display: flex;
  align-items: center;
  gap: .6rem;
  height: var(--head-h);
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

/* The name over the editor's state. Takes what the buttons leave, and gives
 * way first: the name is cut short, never the buttons. */
.doc-heading {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.doc-head .doc-actions { margin-left: auto; }

/* What the browser editor holds that the file does not, yet: unsaved changes,
 * or a newer version on disk. In the warning colour, as it asks for a step. */
.doc-state {
  margin: 0;
  font-size: .78rem;
  color: var(--orange);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Unsaved changes are lost on closing the pane, so they are in red. */
.doc-state-unsaved { color: var(--red); }

.doc-experimental { font-weight: normal; }

/* A row, so the glyph and the word share a baseline. The ellipsis then belongs
 * to the word rather than to the heading, which also holds the icon. */
.doc-title {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
}

.doc-title .icon { color: var(--blue); }

.doc-title span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A file name, where the pane's own name stands when nothing is open. */
.doc-title .doc-name {
  font-family: ui-monospace, monospace;
  font-size: .9rem;
  font-weight: bold;
}

/* One height for all three, whatever element each of them is: a link styled as
 * a button and a real button do not agree on their own. */
.doc-actions { display: flex; gap: .5rem; flex: none; align-items: center; }

.doc-actions .button,
.doc-actions button {
  min-height: var(--control-h);
  padding: .3rem .7rem;
  font-size: .85rem;
}

/* A narrow pane keeps the name readable by showing the buttons as icons. The
 * words stay for screen readers, and each button carries them as its tooltip. */
@container doc-head (max-width: 44rem) {
  .doc-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .doc-actions { gap: .35rem; }
  .doc-actions .button,
  .doc-actions button { padding: .3rem .5rem; }
}

.doc-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* A column and not a track list. The provenance line above the document and
 * the note below it both come and go, and with fixed tracks a viewer whose
 * provenance line was absent dropped into the row meant for the line and
 * rendered a hundred pixels tall. A flex child that claims the remainder does
 * not care how many siblings it has. */
.doc-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.doc-source {
  margin: 0;
  padding: .5rem 1.1rem;
  font-family: ui-monospace, monospace;
  font-size: .78rem;
  color: var(--gray);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.doc-object {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 0;
  background: var(--paper);
}

.doc-source, .doc-blocked { flex: none; }

/* -- a file read as a document ------------------------------------------- */

/* The scroll belongs to this panel and not to `.doc-body`, which hides its
 * overflow — the same arrangement the file list uses, `min-height` included. */
.doc-reader {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.1rem 1.3rem 2rem;
  background: var(--paper);
}

/* `chat.css` puts h4, h5 and h6 at one size, which is right for a turn of a
 * conversation and collapses a document's structure into a single level. A
 * document gets the ramp back. */
.doc-reader .md h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
.doc-reader .md h2 { font-size: 1.2rem; margin: 1.4rem 0 .4rem; }
.doc-reader .md h3 { font-size: 1.05rem; margin: 1.1rem 0 .3rem; }
.doc-reader .md h4 { font-size: .95rem; margin: 1rem 0 .3rem; }
.doc-reader .md h5, .doc-reader .md h6 { font-size: .9rem; margin: .9rem 0 .3rem; }
.doc-reader .md h1, .doc-reader .md h2 { border-bottom: 1px solid var(--line); padding-bottom: .2rem; }

/* What is shown when the file could not be formatted: its own text, as it is
 * written, wrapped rather than run off the side of the column. */
.doc-raw {
  margin: .5rem 0 0;
  font-family: ui-monospace, monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.doc-blocked {
  margin: 0;
  padding: .6rem 1.1rem;
  background: var(--tint-notice);
  border-top: 1px solid var(--line);
}

.doc-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--gray);
}

.doc-idle p { margin: 0; max-width: 24rem; }

/* -- the file column ----------------------------------------------------- */

/* The rail's tint: the two side columns frame the work alike. */
.col-files {
  background: var(--rail-bg);
  border-left: 1px solid var(--line);
}

/* Level with the other headers: what can be done to the column, what it is,
 * and how much is in it. */
.files-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--head-h);
  padding: 0 .8rem;
  border-bottom: 1px solid var(--line);
  background: var(--rail-bg);
}

/* Takes what is left, and never less than its word: an ellipsis on
 * "Dateien" reads as a fault. */
.files-title { flex: 1 0 auto; }

.files-count {
  flex: none;
  min-width: 1.7rem;
  padding: .05rem .4rem;
  font-size: .78rem;
  text-align: center;
  color: var(--anthracite);
  background: var(--soft);
}

/* At the foot of the column whether the list is there or not: the margin
 * takes up whatever the list leaves, or all of it on the closed strip. */
.files-foot {
  flex: none;
  margin-top: auto;
  padding: .8rem;
  border-top: 1px solid var(--line);
}

.files-foot .upload button {
  justify-content: center;
  width: 100%;
  min-height: var(--control-h);
  padding: .45rem .7rem;
  font-size: .9rem;
}

/* A flex item is sized by its content along the main axis, so without this the
 * list is as tall as its rows rather than as tall as the column. */
.files-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .6rem .5rem;
}

/* Closed: a strip of icons. The toggle sits where it sat in the open header,
 * so it does not move under the pointer, with the count below it, which says
 * that something arrived while the list was out of sight; the upload keeps
 * its place at the foot. */
body:not([data-dateien="auf"]) .files-head {
  flex-direction: column;
  padding: calc((var(--head-h) - var(--control-h)) / 2) 0 0;
  border-bottom: 0;
  background: none;
}

body:not([data-dateien="auf"]) .files-title,
body:not([data-dateien="auf"]) .files-body { display: none; }

body:not([data-dateien="auf"]) .files-foot { padding: .8rem .4rem; }
body:not([data-dateien="auf"]) .files-foot .upload button { padding: .45rem 0; }

body:not([data-dateien="auf"]) .files-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* -- uploads and the list ------------------------------------------------ */

/* The upload control lives in the header now, where it has no margin to give. */
.upload {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin: 0;
}

.upload input[type="file"] { font-size: .85rem; }

.filelist { list-style: none; margin: 0; padding: 0; }

/* One row per file or folder, whatever element it is: a button when it opens
 * something, a plain line when it cannot. A button would otherwise bring its
 * own colours, weight and centring with it. */
.file-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .4rem .6rem;
  margin-bottom: .25rem;
  color: var(--anthracite);
  background: var(--paper);
  border: 0;
  border-left: 4px solid var(--file-text);
  font: inherit;
  text-align: left;
  cursor: default;
}

button.file-row { cursor: pointer; }

/* A file or folder that just appeared lights up twice and settles, so the eye
 * finds what the assistant or somebody on the share has just added. */
.file-row.file-new { animation: aufleuchten 1.1s ease-out 2; }

/* Only the peak: before and after it the row has its own ground, white in a
 * mail, none in the tree. */
@keyframes aufleuchten {
  30% { background: color-mix(in srgb, var(--light) 35%, var(--paper)); }
}

@media (prefers-reduced-motion: reduce) {
  .file-row.file-new { animation: aufleuchten 2.2s ease-out 1; }
}
button.file-row:hover { background: var(--tint-input); }

/* The file the pane shows, in the green of a shown document. */
button.file-row[aria-current="true"] { background: var(--tint-document); }

/* The glyph says what the file is before the extension has been read, and it
 * carries the same tone as the stripe down the left of the row. */
.file-row .icon { flex: none; color: var(--file-text); }

.filename {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, monospace;
  font-size: .82rem;
  overflow-wrap: anywhere;
}

.filesize { color: var(--gray); font-size: .78rem; flex: none; }

.file-tone-pdf { border-left-color: var(--file-pdf); }
.file-tone-document { border-left-color: var(--file-document); }
.file-tone-spreadsheet { border-left-color: var(--file-spreadsheet); }
.file-tone-presentation { border-left-color: var(--file-presentation); }
.file-tone-archive { border-left-color: var(--file-archive); }
.file-tone-folder { border-left-color: var(--file-folder); }
.file-tone-mail { border-left-color: var(--file-mail); }
.file-tone-image { border-left-color: var(--file-image); }
.file-tone-text { border-left-color: var(--file-text); }

.file-tone-pdf .icon { color: var(--file-pdf); }
.file-tone-document .icon { color: var(--file-document); }
.file-tone-spreadsheet .icon { color: var(--file-spreadsheet); }
.file-tone-presentation .icon { color: var(--file-presentation); }
.file-tone-archive .icon { color: var(--file-archive); }
.file-tone-folder .icon { color: var(--file-folder); }
.file-tone-mail .icon { color: var(--file-mail); }
.file-tone-image .icon { color: var(--file-image); }

/* -- an image ---------------------------------------------------------------- */

/* As large as it is, and never larger than the pane: a photograph is scaled
 * down to fit, and a small scan is not blown up into a blur. It sits on the
 * inset grey, so a white page scanned on white has an edge. */
.doc-figure {
  margin: 0;
  padding: .6rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
}

.doc-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* What the pane cannot show: still listed, so the reader knows it is there,
 * but grey throughout — stripe, glyph and name — and not a control. */
.file-muted,
.file-muted .icon,
.file-muted .filesize { color: var(--disabled); }
.file-muted { border-left-color: var(--line); background: var(--paper-2); }

/* -- the tree ------------------------------------------------------------- */

/* A file tree as a file manager draws one: rows flush on the column, no card
 * or stripe per row, the kind told by the glyph's colour, and the hierarchy by
 * indent and a hairline guide. Scoped to `.filetree`, because a mail's
 * attachment list uses the same rows and keeps its stripes.
 *
 * Every row sets its text on one line height, `--tree-lh`, whatever size the
 * name has been fitted to, and the glyphs sit on that first line. A name that
 * wraps then grows downwards and its icon, chevron and size stay level with
 * its first line. */
.filetree {
  --tree-lh: 1.3rem;
  --tree-icon: 1.1rem;
  --tree-chevron: .95rem;
  --tree-gap: .35rem;
  --tree-pad: .3rem;
  --name-size: .85rem;
}

.filetree .file-row {
  align-items: flex-start;
  gap: var(--tree-gap);
  margin: 0;
  padding: .22rem .4rem .22rem var(--tree-pad);
  line-height: var(--tree-lh);
  background: transparent;
  border-left: 0;
}

.filetree .file-row .icon {
  width: var(--tree-icon);
  height: var(--tree-icon);
  margin-top: calc((var(--tree-lh) - var(--tree-icon)) / 2);
}

/* A file has no chevron, and takes its width as indent, so its glyph lines up
 * with the folder glyphs at its level. */
.filetree .tree-file > .file-row {
  padding-left: calc(var(--tree-pad) + var(--tree-chevron) + var(--tree-gap));
}

/* A sans name breaks where its words do; `docpane.js` adds the places a file
 * name has words — after `_`, `-` and spaces, before the extension, between
 * camelCase — and shrinks a name that nearly fits until it does. */
.filetree .filename {
  font-family: inherit;
  font-size: var(--name-size);
  overflow-wrap: break-word;
}

.filetree .filesize {
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
}

/* While `docpane.js` measures: every name on one line, at its full size. A
 * `<wbr>` breaks a line even under `nowrap`, so the breaks are taken out of
 * the layout as well. */
.filetree.tree-measuring .filename {
  overflow: hidden;
  white-space: nowrap;
  font-size: var(--name-size) !important;
}

.filetree.tree-measuring wbr { display: none; }

.filetree button.file-row:hover { background: var(--tint-input); }
.filetree button.file-row[aria-current="true"] { background: var(--tint-document); }
.filetree .file-muted { background: transparent; }

/* A folder: a chevron that turns, a folder glyph that opens with it. */
.tree-chevron {
  width: var(--tree-chevron);
  height: var(--tree-chevron);
  color: var(--gray);
  transition: transform .12s ease-out;
}

.filetree .tree-folder > .file-row .tree-chevron {
  width: var(--tree-chevron);
  height: var(--tree-chevron);
  margin-top: calc((var(--tree-lh) - var(--tree-chevron)) / 2);
  color: var(--gray);
}

.tree-folder > .file-row[aria-expanded="false"] .tree-chevron { transform: rotate(-90deg); }

.tree-folder > .file-row[aria-expanded="true"] .tree-shut,
.tree-folder > .file-row[aria-expanded="false"] .tree-open { display: none; }

/* The guide runs under the folder's chevron, so each level hangs from the
 * folder it belongs to. */
.tree-children {
  margin-left: calc(var(--tree-pad) + var(--tree-chevron) / 2);
  padding-left: calc(var(--tree-gap) - 1px);
  border-left: 1px solid var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .tree-chevron { transition: none; }
}

/* -- a mail ---------------------------------------------------------------- */

/* Laid out as a mail programme lays one out: the subject, then who and when in
 * two columns, the text, and what was attached at the foot. */
.mail { max-width: 52rem; }

.mail-head {
  padding-bottom: .7rem;
  margin-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}

.mail-subject { font-size: 1.15rem; margin: 0 0 .6rem; }

.mail-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: .15rem .8rem;
  margin: 0;
  font-size: .88rem;
}

.mail-meta dt { color: var(--gray); }
.mail-meta dd { margin: 0; overflow-wrap: anywhere; }

.mail-toggle {
  margin-bottom: .8rem;
  padding: .25rem .6rem;
  font-size: .82rem;
}

/* The text as it was written: its line breaks kept, long lines wrapped, and
 * the quoted history of a reply greyed so the new part stands out. */
.mail-text { font-size: .95rem; }
.mail-line, .mail-quote { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.3em; }
.mail-quote { color: var(--gray); }

.mail-attachments {
  margin-top: 1.4rem;
  padding-top: .8rem;
  border-top: 1px solid var(--line);
}

.mail-attachments-title {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin: 0 0 .5rem;
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gray);
}

.mail-attachments li { display: flex; align-items: stretch; gap: .3rem; }
.mail-attachments .file-row { flex: 1; min-width: 0; }

.file-action {
  flex: none;
  margin-bottom: .25rem;
  padding: .3rem .5rem;
}

.doc-back { padding: .3rem .5rem; min-height: var(--control-h); }
