/* The work is the subject; enlarging it is a quiet square in the corner, with the
   full label kept on the control for assistive technology and tooltips. */
.photo-open {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  display: inline-flex;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  border: 0;
  background: rgba(251, 251, 250, 0.9);
  color: var(--graphite);
  line-height: 1.3;
  text-decoration: none;
  transition: background-color var(--motion-base) var(--ease-out), color var(--motion-base) var(--ease-out);
}

.photo-open:hover,
.photo-open:focus-visible {
  background: var(--frost-bright);
}

.photo-open:active {
  background: var(--frost);
}

.photo-open svg,
.photo-toolbar svg {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.photo-toolbar svg { width: 1.25rem; height: 1.25rem; }

.photo-open svg {
  transition: transform var(--motion-fast) var(--ease-out);
}

.photo-open:hover svg,
.photo-open:focus-visible svg {
  transform: scale(1.08);
}

.photo-dialog {
  position: fixed;
  inset: 0;
  width: min(100%, 110rem);
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: auto;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow: auto;
  border: 0;
  background: var(--graphite);
  color: var(--frost-bright);
}

.photo-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.photo-dialog::backdrop {
  background: rgba(23, 23, 25, 0.94);
}

.photo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.photo-toolbar h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 450;
  line-height: 1.4;
}

.photo-toolbar button {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem;
  border: 1px solid var(--silver-dark);
  background: var(--graphite);
  color: var(--frost-bright);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background-color var(--motion-base) var(--ease-out), border-color var(--motion-base) var(--ease-out);
}

.photo-toolbar button:hover,
.photo-toolbar button:focus-visible {
  border-color: var(--silver);
  background: var(--graphite-soft);
}

.photo-toolbar button:active {
  background: var(--text-muted);
}

.photo-stage {
  display: flex;
  min-height: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
}

.photo-stage img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}

.photo-status {
  margin: 0;
  color: var(--silver);
  font-size: 0.9375rem;
  line-height: 1.45;
  text-align: center;
}

.photo-open:focus-visible,
.photo-toolbar button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

body.photo-is-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  .photo-dialog {
    opacity: 0;
    transform: scale(0.985);
    transition:
      opacity var(--motion-base) var(--ease-out),
      transform var(--motion-base) var(--ease-out),
      display var(--motion-base) allow-discrete,
      overlay var(--motion-base) allow-discrete;
  }

  .photo-dialog[open] {
    opacity: 1;
    transform: none;
  }

  .photo-dialog::backdrop {
    opacity: 0;
    transition:
      opacity var(--motion-base) var(--ease-out),
      display var(--motion-base) allow-discrete,
      overlay var(--motion-base) allow-discrete;
  }

  .photo-dialog[open]::backdrop {
    opacity: 1;
  }

  @starting-style {
    .photo-dialog[open] {
      opacity: 0;
      transform: scale(0.985);
    }

    .photo-dialog[open]::backdrop {
      opacity: 0;
    }
  }
}
