/* Files in chats: the box that plays a sound file (js/sound-player.js), the MIDI previewer (js/midi.js), and a rule for SVG pictures. */

.ap { display: grid; gap: 10px; padding: 12px; outline: none; }
.ap:focus-visible { border-color: var(--line-strong); }
.ap-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ap-icon { display: grid; color: var(--accent); flex-shrink: 0; }
.ap-text { flex: 1; min-width: 0; }
.ap-name { display: block; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-size { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ap-controls { display: flex; align-items: center; gap: 2px; min-height: 32px; min-width: 0; padding: 0 4px; background: var(--bg-3); border-radius: 6px; }
.ap-btn { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); flex-shrink: 0; }
.ap-btn:hover:not(:disabled) { color: var(--text); background: var(--bg-4); }
.ap-time { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); padding: 0 8px 0 2px; white-space: nowrap; }
.ap input[type="range"] {
  appearance: none; -webkit-appearance: none; height: 16px; min-width: 0; margin: 0; padding: 0;
  background: transparent; border: 0; cursor: pointer;
}
.ap input[type="range"]:disabled { cursor: default; }
.ap input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--text) var(--p, 0%), var(--line-strong) var(--p, 0%)); }
.ap input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--text) var(--p, 0%), var(--line-strong) var(--p, 0%)); }
.ap input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: var(--text); border: 0; opacity: 0; }
.ap input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: 0; opacity: 0; }
.ap input[type="range"]:not(:disabled):hover::-webkit-slider-thumb, .ap input[type="range"]:focus-visible::-webkit-slider-thumb { opacity: 1; }
.ap input[type="range"]:not(:disabled):hover::-moz-range-thumb, .ap input[type="range"]:focus-visible::-moz-range-thumb { opacity: 1; }
.ap-seek { flex: 1; }
.ap-sound { display: flex; align-items: center; flex-shrink: 0; }
.ap-vol { width: 0; opacity: 0; transition: width .15s, opacity .15s; }
.ap-sound:hover .ap-vol, .ap-sound:focus-within .ap-vol { width: 64px; opacity: 1; margin: 0 2px 0 8px; }
@media (hover: none) { .ap-vol { display: none; } }

/* A sound this browser cannot play, or whose playable copy is still being made, says so where the controls were. */
.ap.stopped .ap-controls { gap: 10px; padding: 0 10px; flex-wrap: wrap; }
.ap-why { font-size: 13px; color: var(--text-2); padding: 6px 0; }
.ap.stopped .vp-progress { flex: 1; min-width: 60px; width: auto; margin: 0; }

/* The MIDI previewer: every note of the file on a timeline, the whole song in a strip under it, and the controls. */
.attachments .mp { width: min(100%, 560px); }
.mp-roll, .mp-map { display: block; width: 100%; background: var(--bg-0); cursor: pointer; touch-action: pan-y; }
.mp-roll { height: 200px; border-radius: 6px 6px 0 0; }
.mp-map { height: 26px; margin-top: -9px; border-radius: 0 0 6px 6px; border-top: 1px solid var(--line); outline: none; }
.mp-map:focus-visible { border-top-color: var(--text-2); }
.mp-gap { flex: 1; }
.mp-pick {
  height: 26px; max-width: 132px; min-width: 0; margin-right: 2px; padding: 0 4px; font-size: 12px; cursor: pointer;
  color: var(--text-2); background: var(--bg-4); border: 0; border-radius: 5px;
}
.mp-pick:hover, .mp-pick:focus-visible { color: var(--text); }
.mp-pick option { background: var(--bg-float); color: var(--text); }
.mp-zoom { width: 26px; font-size: 16px; line-height: 1; }
@media (max-width: 480px) { .mp-zoom { display: none; } .mp-roll { height: 160px; } }

/* Pictures. An SVG drawing need not say how large it is; opened large it would then have no width at all. */
.lb-stage img[src$=".svg" i] { width: min(100%, 80vh); }

/* A text file (js/text-preview.js): its first lines where it was sent, more of them when opened, and under them
   the name with the buttons. */
.attachments .tp { width: min(100%, 520px); }
.tp { background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tp-view { position: relative; max-height: 128px; overflow: hidden; background: var(--bg-0); }
.tp.loading .tp-view { height: 128px; } /* room for six lines, so the chat does not jump when the text arrives */
.tp-text {
  margin: 0; padding: 10px 12px; font: 12.5px/18px var(--mono); color: var(--text-2);
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; user-select: text; -webkit-user-select: text;
}
.tp.empty .tp-text { font-family: inherit; font-size: 13px; color: var(--muted); }
.tp.empty .tp-full { display: none; } /* nothing to read */
.tp.long:not(.open) .tp-view::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40px; pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg-0));
}
.tp.open .tp-view { max-height: min(60vh, 520px); overflow: auto; overscroll-behavior: contain; }
.tp-more { padding: 0 12px 10px; font-size: 12px; color: var(--muted); }
.tp-more[hidden] { display: none; }
.tp-foot { display: flex; align-items: center; gap: 2px; min-width: 0; padding: 6px; border-top: 1px solid var(--line); }
.tp-toggle, .tp-mark { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 6px; color: var(--text-2); }
.tp-toggle:hover { color: var(--text); background: var(--bg-3); }
.tp-toggle svg { transition: transform .15s; }
.tp.open .tp-toggle svg { transform: rotate(180deg); }
.tp:not(.long) .tp-toggle, .tp.long .tp-mark { display: none; }
.tp-name { flex: 1; min-width: 0; margin: 0 8px 0 4px; line-height: 1.3; }
.tp-file { display: block; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-size { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* All of a text file, full-screen: numbered lines. The numbers are not part of the text, so they are never copied. */
.tv-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 0 28px; outline: none; }
.tv-lines {
  --digits: 2; counter-reset: line; width: min(100%, 1100px); margin: 0 auto;
  font: 13px/20px var(--mono); color: #d6d6d6; user-select: text; -webkit-user-select: text;
}
.tv-line {
  position: relative; min-height: 20px; padding: 0 16px 0 calc(var(--digits) * 1ch + 30px);
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; counter-increment: line;
}
.tv-line::before {
  content: counter(line); position: absolute; left: 0; top: 0; width: calc(var(--digits) * 1ch + 14px);
  text-align: right; color: #5c5c5c; user-select: none; -webkit-user-select: none;
}
.tv-note { padding: 18px 16px 0; text-align: center; font-size: 13px; color: #999; }
.tv-note[hidden] { display: none; }
@media (max-width: 480px) {
  .tv-lines { font-size: 12px; line-height: 18px; }
  .tv-line { min-height: 18px; padding-right: 10px; padding-left: calc(var(--digits) * 1ch + 20px); }
  .tv-line::before { width: calc(var(--digits) * 1ch + 8px); }
}
