/* Photo dialog (photo.js): a card like Share's, not modal, beside the stage; and the frame it shows on the stage. */
.sv-photo {
  position: fixed;
  inset: 44px 16px auto auto; /* under the stats line (stats.css) */
  width: min(360px, calc(100% - 32px));
  max-height: calc(100dvh - 44px - 8px);
  overflow-y: auto;
  margin: 0;
  padding: 18px 20px 20px;
  border: 1px solid var(--sv-border);
  border-radius: 12px;
  color: var(--sv-ink);
  background: var(--sv-surface);
  box-shadow: var(--sv-shadow);
  z-index: 30;
}

.sv-photo[open] {
  animation: sv-dialog-in 140ms ease-out; /* keyframes and reduced motion: base.css */
}

.sv-photo form {
  margin: 0;
}

.sv-photo__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sv-photo__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
}

.sv-photo__sizes {
  display: grid;
  gap: 2px;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}

.sv-photo__sizes legend {
  margin-bottom: 4px;
  padding: 0;
  color: var(--sv-muted);
  font-size: 12px;
}

.sv-photo__sizes label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  cursor: pointer;
}

.sv-photo__sizes label:hover {
  background: var(--sv-hover);
}

.sv-photo__px {
  margin-left: auto;
  color: var(--sv-muted);
  font-variant-numeric: tabular-nums;
}

.sv-photo__hint,
.sv-photo__note,
.sv-photo__error {
  margin: 10px 0 0;
  font-size: 12px;
}

.sv-photo__hint,
.sv-photo__note {
  color: var(--sv-muted);
}

.sv-photo__error {
  color: var(--sv-danger);
}

.sv-photo__progress {
  display: grid;
  gap: 4px;
  margin-top: 12px;
}

.sv-photo__progress progress {
  width: 100%;
  height: 8px;
  accent-color: var(--sv-accent);
}

.sv-photo__status {
  color: var(--sv-muted);
  font-size: 12px;
}

.sv-photo__result {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.sv-photo__result canvas {
  width: 96px;
  height: 64px;
  border: 1px solid var(--sv-border);
  border-radius: 6px;
  object-fit: contain;
  background: var(--sv-viewport-bg);
}

.sv-photo__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

#viewer .sv-photo__primary {
  border-color: var(--sv-accent);
  color: #fff;
  background: var(--sv-accent);
}

#viewer .sv-photo__primary:hover:not(:disabled) {
  background: #1f3bb8;
}

/* What the photo covers: the stage's height, centred; the rest of the video dimmed (the overlays
   after it in the stage paint above). Clicks go through. */
.sv-photo-frame {
  position: absolute;
  top: 0;
  bottom: 0;
  box-sizing: border-box;
  border: 2px dashed rgb(255 255 255 / 0.9);
  box-shadow: 0 0 0 1px rgb(23 23 26 / 0.35), 0 0 0 100vmax rgb(23 23 26 / 0.25);
  pointer-events: none;
}

/* Phones, portrait and landscape: a compact sheet above the toolbar (sizes in a grid of names, each
   on one line with its pixels small under it; no note), so the frame and the model above it stay
   in view. */
@media (max-width: 760px), (max-width: 1023px) and (max-height: 520px) and (min-aspect-ratio: 301/200) {
  .sv-photo {
    inset: auto max(8px, env(safe-area-inset-right)) calc(max(12px, env(safe-area-inset-bottom)) + 60px) max(8px, env(safe-area-inset-left));
    width: auto;
    max-height: calc(100dvh - max(10px, env(safe-area-inset-top)) - 50px - max(12px, env(safe-area-inset-bottom)) - 60px);
    padding: 6px 12px 12px 16px;
  }

  .sv-photo__sizes {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    margin-top: 4px;
  }

  /* radio | name over pixels; a name too long for its cell is clipped, never wrapped */
  .sv-photo__sizes label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: center;
    column-gap: 6px;
    padding: 2px 6px;
    overflow: hidden;
    font-size: 13px;
    white-space: nowrap;
  }

  .sv-photo__sizes input {
    grid-row: span 2;
    align-self: center;
    margin: 0;
  }

  .sv-photo__px {
    margin-left: 0;
    font-size: 11px;
  }

  .sv-photo__note {
    display: none;
  }

  .sv-photo__actions {
    margin-top: 10px;
  }
}

/* Short landscape screens: a side sheet on the right, like the card's (panel.css), so the model
   and the frame stay in view on the left. */
@media (max-width: 1023px) and (max-height: 520px) and (min-aspect-ratio: 301/200) {
  .sv-photo {
    left: auto;
    width: min(45%, 360px);
    max-height: calc(100dvh - max(8px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)) - 60px);
  }
}

/* Touch: 44px rows and buttons. */
@media (pointer: coarse) {
  .sv-photo__sizes label,
  #viewer .sv-photo button {
    min-height: 44px;
  }
}
