/* Photos attached to entries: the card's, and the body field's camera button, menu and previews. */

/* A tall phone photo would push the next entries far down; the full image opens on tap. */
.entry-photo,
.current-photo-image {
  display: block;
  inline-size: fit-content;
  max-inline-size: 100%;
}

/* Top right with the body wrapping around it, like a picture in a word processor. */
.entry-photo {
  float: inline-end;
  max-inline-size: 40%;
  margin-block-end: var(--space-2);
  margin-inline-start: var(--space-3);
  border-radius: var(--radius);
  overflow: hidden;
}

.entry-photo img,
.photo-preview img {
  display: block;
  max-inline-size: 100%;
  max-block-size: 20rem;
  object-fit: contain;
}

.entry-photo img {
  max-block-size: 10rem;
}

/* Bordered boxes would run under the photo; they start below it instead. */
.entry-main > .link-preview,
.entry-main > .entry-translation {
  clear: both;
}

.photo-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Room at the end of the text so the last line is not under the button. */
.photo-body {
  position: relative;
}

.photo-body textarea {
  padding-inline-end: 3rem;
}

.photo-open {
  position: absolute;
  inset-block-end: var(--space-2);
  inset-inline-end: var(--space-2);
  box-shadow: var(--shadow-card);
}

/* Out of the way while the body is being written; back once the field loses focus. Not on an
   empty focused field, where the composer starts (autofocus). */
.photo-body:has(textarea:focus:not(:placeholder-shown)) .photo-open {
  opacity: 0;
  visibility: hidden;
  scale: 0.8;
}

@media (prefers-reduced-motion: no-preference) {
  /* Outranks the shared button transition in interactions.css, which loads later. */
  .photo-body .photo-open {
    transition:
      opacity 0.3s var(--ease-out),
      scale 0.3s var(--ease-out),
      visibility 0.3s,
      background-color 0.2s ease,
      color 0.2s ease,
      box-shadow 0.2s ease;
  }
}

/* The input is visually hidden inside the label, so the label shows its keyboard focus. */
.photo-open:has(:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.photo-status:empty {
  display: none;
}

.photo-preview {
  position: relative;
  inline-size: fit-content;
  max-inline-size: 100%;
  border-radius: var(--radius);
  overflow: hidden;
}

.photo-preview[hidden],
.current-photo:has(:checked) {
  display: none;
}

.photo-preview img {
  max-block-size: 12rem;
}

/* On the photo itself, so it stays visible whatever the picture's colors. */
.photo-clear {
  position: absolute;
  inset-block-start: var(--space-1);
  inset-inline-end: var(--space-1);
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
}
