/* Photos, files and voice notes in a conversation (src/media/), as the web design's boards draw them: conv-media,
   conv-media-states, conv-file, conv-voice, conv-voice-playing, conv-mic-ask, conv-mic-refused, conv-too-large,
   conv-viewer, conv-drop, conv-caption (the kit's .ml-photo, .ml-file, .ml-voice, .ml-wave, .ml-rec, .w-lightbox,
   .w-drop, here as .m-*).
   Every colour, size and type style is a token from design/tokens.json (tokens.css, written by
   `tools/keel gen-tokens`); no literal where a variable exists. Logical properties only. Loaded in index.html's
   order: frame, start, chats, conversation, media, contact, calls, settings. */

.m-media { display: flex; flex-direction: column; gap: var(--space-1-half); min-inline-size: 0; }
.m-media__words { color: var(--ink-muted); padding-inline: var(--space-2-half); }
.m-media[data-mine="true"] .m-media__words { color: inherit; opacity: var(--opacity-pressed); }
.m-muted { color: var(--ink-muted); }
.m-grow { flex: 1 1 auto; min-inline-size: 0; }

/* A transfer's bar (k-progress): the core's percent fills it. */
.m-progress {
  display: block;
  block-size: var(--space-1-half);
  margin-inline: var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}
.m-progress i { display: block; block-size: 100%; border-radius: var(--radius-pill); background: var(--mesh); }
.m-file .m-progress { margin: var(--space-1-half) 0 0; }

/* A photo in its bubble (ml-photo): a click opens the viewer; an offer is a tap that downloads (ml-ring). */
.m-photo {
  position: relative;
  display: block;
  inline-size: var(--image-bubble-width);
  max-inline-size: 100%;
  block-size: var(--image-bubble-height);
  padding: 0;
  border: none;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface-sunken);
  color: inherit;
  cursor: pointer;
}
div.m-photo { cursor: default; }
.m-photo img { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; }
.m-photo:focus-visible { outline: var(--stroke-regular) solid var(--focus); outline-offset: var(--stroke-regular); }
.m-placeholder { display: block; inline-size: 100%; block-size: 100%; filter: blur(6px); transform: scale(1.1); }
.m-ring {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  display: grid;
  place-items: center;
  inline-size: var(--transfer-ring);
  block-size: var(--transfer-ring);
  translate: -50% -50%;
  border-radius: var(--radius-pill);
  background: var(--scrim);
  color: var(--on-call);
}

/* A file (ml-file): the badge, the name, its size and the core's line. */
.m-file {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-inline-size: 220px;
  max-inline-size: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
}
button.m-file { cursor: pointer; }
.m-file:focus-visible { outline: var(--stroke-regular) solid var(--focus); outline-offset: var(--space-1); border-radius: var(--radius-sm); }
.m-file__badge {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: var(--file-badge-width);
  block-size: var(--file-badge-height);
  border-radius: var(--radius-sm);
  background: var(--mesh);
  color: var(--on-mesh);
  font: var(--label-mono-weight) var(--label-mono-size) / 1 var(--font-mono);
}
.m-file__badge[data-tone="danger"] { background: var(--danger); color: var(--on-danger); }
.m-file__badge[data-tone="plain"] { background: var(--surface-sunken); color: var(--ink-muted); }
.m-media[data-mine="true"] .m-file__badge[data-tone="mesh"] { background: var(--on-mesh); color: var(--mesh); }
.m-file__text { display: flex; flex-direction: column; flex: 1 1 auto; min-inline-size: 0; }
.m-file__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: var(--callout-strong-weight) var(--callout-strong-size) / var(--callout-strong-line) var(--callout-strong-family);
}
.m-file__meta { color: var(--ink-muted); font: var(--footnote-weight) var(--footnote-size) / var(--footnote-line) var(--footnote-family); }
.m-media[data-mine="true"] .m-file__meta { color: inherit; opacity: var(--opacity-pressed); }

/* A voice note (ml-voice): play or pause, the bars, the length or the time played. */
.m-voice { display: flex; align-items: center; gap: var(--space-2-half); inline-size: var(--voice-bubble-width); max-inline-size: 100%; }
.m-voice__play {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: var(--compact);
  block-size: var(--compact);
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--mesh);
  color: var(--on-mesh);
  cursor: pointer;
}
.m-voice__play:disabled { opacity: var(--opacity-disabled); cursor: default; }
.m-voice__play:focus-visible { outline: var(--stroke-regular) solid var(--focus); outline-offset: var(--stroke-regular); }
.m-media[data-mine="true"] .m-voice__play { background: var(--on-mesh); color: var(--mesh); }
.m-wave { display: flex; align-items: center; gap: var(--stroke-hairline); flex: 1 1 auto; min-inline-size: 0; block-size: var(--waveform-height); }
.m-wave i { flex: 1 1 0; min-block-size: 3px; border-radius: var(--stroke-hairline); background: var(--ink-muted); }
.m-wave i.on { background: var(--mesh); }
.m-media[data-mine="true"] .m-wave i { background: currentColor; opacity: 0.5; }
.m-media[data-mine="true"] .m-wave i.on { opacity: 1; }
.m-voice__time {
  flex: none;
  color: var(--ink-muted);
  font: var(--metric-weight) var(--metric-size) / var(--metric-line) var(--metric-family);
  font-variant-numeric: tabular-nums;
}
.m-media[data-mine="true"] .m-voice__time { color: inherit; opacity: var(--opacity-pressed); }

/* The recorder (ml-rec, conv-voice and conv-mic-ask, where the browser asks over it): it stands in the composer's
   place while it records, so the composer's other parts step aside. */
form:has(> .m-rec) > :not(.m-rec) { display: none; }
.m-rec { display: flex; align-items: center; gap: var(--space-3); flex: 1 1 auto; min-inline-size: 0; }
.m-rec__dot { display: block; flex: none; inline-size: var(--recording-dot); block-size: var(--recording-dot); border-radius: var(--radius-pill); background: var(--recording); }
.m-rec__words { display: flex; flex-direction: column; gap: var(--space-half); min-inline-size: 0; }
.m-rec__time {
  color: var(--recording);
  font: 500 var(--body-size) / var(--headline-line) var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.m-send {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: var(--icon-button);
  block-size: var(--icon-button);
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--mesh);
  color: var(--on-mesh);
  cursor: pointer;
}
.m-send:focus-visible { outline: var(--stroke-regular) solid var(--focus); outline-offset: var(--stroke-regular); }

/* The line above the composer (ml-composer__hint: conv-too-large, conv-mic-refused): the core's words. */
.m-hint {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: var(--space-2-half) var(--space-4) var(--space-2);
  border-block-start: var(--stroke-hairline) solid var(--line);
  background: var(--surface-raised);
  color: var(--ink-muted);
  text-align: center;
  font: var(--footnote-weight) var(--footnote-size) / var(--footnote-line) var(--footnote-family);
}

/* Files dragged over an open chat (w-drop): the zone over the conversation it is mounted in. */
:has(> .m-drop:not([hidden])) { position: relative; }
.m-drop {
  position: absolute;
  inset: var(--space-3);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2-half);
  border: var(--stroke-regular) dashed var(--mesh);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--mesh-tint) 88%, transparent);
  color: var(--ink);
  text-align: center;
  pointer-events: none;
  font: var(--title-weight) var(--title-size) / var(--title-line) var(--title-family);
}
.m-drop[hidden] { display: none; }
.m-drop small { color: var(--ink-muted); font: var(--callout-weight) var(--callout-size) / var(--callout-line) var(--callout-family); }
.m-drop__mark {
  display: grid;
  place-items: center;
  inline-size: var(--space-7);
  block-size: var(--space-7);
  border-radius: var(--radius-lg);
  background: var(--mesh);
  color: var(--on-mesh);
}

/* The caption step (conv-caption): the kit's dialog over the whole window. */
.w-scrim.m-over-window { position: fixed; z-index: 7; }
.m-caption__head { display: flex; align-items: center; gap: var(--space-2); }
.m-caption__head h2 { flex: 1 1 auto; min-inline-size: 0; }
.m-caption__photo {
  display: block;
  inline-size: 100%;
  block-size: auto;
  max-block-size: 50vh;
  border-radius: var(--radius-card);
  background: var(--surface-sunken);
  object-fit: contain;
}
.w-dialog p.m-caption__size { text-align: center; font: var(--footnote-weight) var(--footnote-size) / var(--footnote-line) var(--footnote-family); }

/* The photo viewer (w-lightbox, conv-viewer): over the whole window, dark in both themes. */
.m-lightbox {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--call-bg) 94%, transparent);
  color: var(--on-call);
}
.m-lightbox__bar { display: flex; align-items: center; gap: var(--space-2); flex: none; min-block-size: var(--top-bar); padding-inline: var(--space-4); }
.m-lightbox__who { display: flex; flex-direction: column; flex: 1 1 auto; min-inline-size: 0; margin-inline-start: var(--space-1); }
.m-lightbox__when { color: var(--on-call-muted); }
.m-lightbox .icon-button { color: var(--on-call); }
.m-lightbox .icon-button:hover { background: var(--call-control); }
.m-lightbox .icon-button:focus-visible { outline: var(--stroke-regular) solid var(--on-call); outline-offset: var(--stroke-regular); }
.m-lightbox__stage { display: grid; place-items: center; flex: 1 1 auto; min-block-size: 0; padding: 0 var(--space-7) var(--space-5); }
/* As large as the stage lets it be, its proportions kept (a small photo is drawn larger). */
.m-lightbox__photo { display: block; block-size: 100%; max-inline-size: 100%; object-fit: contain; border-radius: var(--radius-md); }
.m-lightbox__wait { block-size: auto; }
.m-lightbox__wait { inline-size: min(100%, 720px); overflow: hidden; }
.m-lightbox__caption { margin: 0; padding: 0 var(--space-5) var(--space-5); text-align: center; }
