/* media: what goes with a message (photos, videos, files), dictation, the `/` picker, the pictures
   and videos a thread names, the full-screen viewer and agents' marks (js/features/media.js). */

/* ---------------------------------------------------------------- The composer's tools */

/* The box holds what pops over it (the `/` picker, the + menu). + comes first, then the words,
   then the microphone beside Send, as the iPhone has them. */
.composer-box {
  position: relative;
}

.composer-box > .media-attach {
  order: -2;
  margin-left: -9px;
}

.composer-box > textarea {
  order: -1;
}

.media-attach {
  position: relative;
  display: inline-flex;
  flex: none;
}

.media-btn {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--fg) 9%, transparent);
  color: var(--fg-strong);
}

.media-btn.plain {
  background: transparent;
}

.media-btn:active {
  background: color-mix(in srgb, var(--fg) 16%, transparent);
}

.media-btn[disabled] {
  opacity: 0.4;
}

/* Listening: the microphone filled (as the iPhone's Keep is, so it isn't taken for Send), in a ring
   of the accent that breathes; a tap stops it and keeps the words. */
.media-mic.on {
  background: var(--fg-strong);
  color: var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
  animation: media-listen 1.6s ease-in-out infinite;
}

@keyframes media-listen {
  0%,
  100% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
  }
  60% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 0 9px color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

.media-listening {
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
}

.composer-box:has(.media-mic.on) textarea::placeholder {
  color: transparent;
}

/* What pops over the box: the + menu and the `/` picker. */
.media-pop {
  position: absolute;
  z-index: 5;
  padding: 6px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--raised);
  box-shadow: var(--shadow);
  animation: media-pop 0.14s ease-out;
}

@keyframes media-pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.media-menu {
  bottom: calc(100% + 12px);
  left: 0;
  min-width: 220px;
}

.media-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--fg-strong);
  font-size: 15px;
  text-align: left;
}

.media-menu-item:active {
  background: var(--hover);
}

.media-commands {
  left: -1px;
  right: -1px;
  bottom: calc(100% + 8px);
  max-height: min(236px, 42vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.media-command {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 4px 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--fg-strong);
  text-align: left;
}

.media-command:active {
  background: var(--hover);
}

.media-command-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  color: var(--muted);
}

.media-command-icon.trek {
  color: var(--accent);
}

.media-command-words {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.media-command-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 550;
  white-space: nowrap;
}

.media-command-name .mono {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-command-kind {
  flex: none;
  padding: 0 6px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.media-command-desc {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- What's attached */

.media-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 8px 8px 2px;
  margin-bottom: 2px;
}

.media-strip::-webkit-scrollbar {
  display: none;
}

.media-tile-box {
  position: relative;
  flex: none;
}

.media-tile {
  position: relative;
  height: 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  color: var(--muted);
}

.media-tile.photo,
.media-tile.video {
  width: 56px;
  padding: 0;
}

.media-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-tile.video {
  background: linear-gradient(#26262b, #111113);
  color: #fff;
}

.media-tile.video img {
  position: absolute;
  inset: 0;
}

.media-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.38);
}

.media-length {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 5px;
  border-radius: 8px;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.media-length .icon.xs {
  width: 8px;
  height: 8px;
}

.media-tile.file {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px 0 10px;
  color: var(--fg-strong);
}

.media-file-icon {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.media-file-words {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 150px;
  min-width: 0;
  text-align: left;
}

.media-file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-file-size {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ✕ on a tile's corner: a dark disc that reads on any photo; the tap target is larger than it. */
.media-remove {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
}

.media-remove::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.62);
  box-shadow: 0 0 0 1.5px var(--bg);
}

.media-remove .icon {
  position: relative;
  stroke-width: 3;
}

.media-ring {
  display: block;
  fill: none;
  stroke-width: 3;
}

.media-ring .track {
  stroke: color-mix(in srgb, var(--fg) 18%, transparent);
}

.media-ring .fill {
  stroke: var(--fg-strong);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.2s ease-out;
}

.media-ring.light .track {
  stroke: rgb(255 255 255 / 0.3);
}

.media-ring.light .fill {
  stroke: #fff;
}

/* ---------------------------------------------------------------- A new thread's box */

.new-compose {
  position: relative;
  padding: 4px 6px 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.new-compose textarea.input {
  border: 0;
  background: transparent;
  padding: 8px 6px;
  min-height: 132px;
  outline: 0;
}

.new-compose:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.new-compose-tools {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.new-compose-tools:empty {
  display: none;
}

/* Here it says so beside the buttons, the task's own prompt left as it is. */
.new-compose .media-listening {
  position: static;
  padding-left: 4px;
  font-size: 14px;
}

/* ---------------------------------------------------------------- A message's photos, videos and files */

.msg-media {
  align-self: flex-end;
  max-width: 88%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-top: -4px;
}

.msg-photos {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.msg-photo {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  color: var(--muted);
}

.msg-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: fade 0.2s ease-out;
}

.msg-photo-more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.45);
  color: #fff;
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.msg-files {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 100%;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 12px 7px 10px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-strong);
  font-size: 13px;
  font-weight: 550;
}

.file-chip .icon {
  color: var(--muted);
}

.file-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A video: its first frame with a play badge, then the player in its place. */
.video-card {
  width: 260px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.watch .video-card {
  width: 300px;
}

.video-face {
  position: relative;
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(#26262b, #111113);
}

.video-face video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
}

.video-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgb(255 255 255 / 0.8);
}

.video-play {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.38);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18);
  color: #fff;
}

.video-play .icon {
  width: 22px;
  height: 22px;
}

.video-words {
  padding: 0 2px;
  text-align: left;
}

.msg-media .video-words {
  text-align: right;
}

.video-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-strong);
  overflow-wrap: anywhere;
}

.away .video-name {
  color: var(--muted);
}

.video-caption {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.video-caption.bad {
  color: var(--failed);
}

/* ---------------------------------------------------------------- What `watch_video` saw */

.watch {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 2px 0 4px;
}

.watch-note {
  font-size: 12.5px;
  color: var(--muted);
}

.watch-frames {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.watch-frames::-webkit-scrollbar {
  display: none;
}

.watch-frame {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
}

.watch-frame .mono {
  font-size: 10.5px;
}

.watch-thumb {
  position: relative;
  height: 64px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}

.watch-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------------------------------------------------------------- An answer's pictures */

.md .md-pic {
  display: block;
  position: relative;
  margin: 8px 0;
  max-width: 100%;
}

.md .md-pic img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  animation: fade 0.2s ease-out;
}

.md .md-pic.loading img,
.md .md-pic.failed img,
.md .md-pic.away img {
  display: none;
}

.md .md-pic-note {
  display: none;
}

.md .md-pic.loading .md-pic-note,
.md .md-pic.failed .md-pic-note,
.md .md-pic.away .md-pic-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 140px;
  padding: 0 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--fg) 5%, transparent);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.md .md-pic.failed {
  cursor: pointer;
}

.md .md-pic.failed .md-pic-note {
  color: var(--failed);
}

.md .md-pic-note span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md .md-pic:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 12px;
}

/* A picture on the web: the page talks only to your computer, so it's a link to open instead. */
.md .md-web-pic {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
}

.md .md-web-pic .icon {
  color: var(--muted);
}

.md-web-pic-words {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.md-web-pic-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-web-pic-host {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- Full screen */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  color: #fff;
  animation: fade 0.15s ease-out;
  user-select: none;
  -webkit-user-select: none;
}

.viewer-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}

.viewer-stage > * {
  grid-area: 1 / 1;
}

.viewer-img {
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
  will-change: transform;
}

.viewer-img.blurred {
  width: 100vw;
  height: 100dvh;
  filter: blur(8px);
  opacity: 0.8;
}

.viewer-spin {
  color: #fff;
}

.viewer-failed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 32px;
  text-align: center;
  color: rgb(255 255 255 / 0.75);
  font-size: 14px;
}

.viewer-failed b {
  color: #fff;
  font-size: 16px;
}

.viewer-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--top)) 14px 10px;
  pointer-events: none;
}

.viewer-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(40 40 44 / 0.62);
  backdrop-filter: blur(12px);
  color: #fff;
  pointer-events: auto;
}

span.viewer-btn {
  visibility: hidden;
}

.viewer-count {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
}

.viewer-step {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(40 40 44 / 0.62);
  color: #fff;
}

.viewer-step.prev {
  left: 14px;
}

.viewer-step.next {
  right: 14px;
}

/* Arrows where there's a mouse; a finger swipes. */
@media (pointer: fine) {
  .viewer-step {
    display: grid;
  }
}

/* ---------------------------------------------------------------- Agents' marks */

.agent-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  vertical-align: middle;
  border-radius: 22%;
}

.agent-mark.logo {
  background: var(--logo-dark) center / contain no-repeat;
}

:root[data-scheme='light'] .agent-mark.logo {
  background-image: var(--logo-light);
}

/* An added agent's icon: a shape drawn in the text colour, or a picture. */
.agent-mark.shape {
  border-radius: 0;
  background: currentColor;
  -webkit-mask: var(--shape) center / 88% no-repeat;
  mask: var(--shape) center / 88% no-repeat;
}

.agent-mark.picture {
  background: var(--picture) center / cover no-repeat;
}

.agent-mark.none {
  color: var(--muted);
}

.agent-mark.none .icon {
  width: 88%;
  height: 88%;
  stroke-width: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  .media-mic.on,
  .media-pop,
  .viewer,
  .msg-photo img,
  .md .md-pic img {
    animation: none;
  }
}
