/* 写真の拡大表示と、切り抜き画面 */

/* ---------------------------------------------------------------- 拡大表示 */

.viewer {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: var(--space-3);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: zoom-out;
}

.viewer[open] {
  display: grid;
  place-items: center;
  animation: viewer-in 220ms var(--ease-out-expo);
}

.viewer::backdrop {
  background: oklch(10% 0.01 50 / 0.9);
}

@keyframes viewer-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

.viewer__figure {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  margin: 0;
  max-height: 100%;
}

.viewer__figure img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 36rem);
  max-height: calc(100dvh - 7rem);
  padding: 0.5rem;
  background: var(--mat);
  border-radius: 2px;
  box-shadow: 0 20px 50px -20px oklch(0% 0 0 / 0.8);
}

.viewer__figure figcaption {
  font-family: var(--font-plaque);
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: 0.08em;
  color: oklch(96% 0.01 80);
}

.viewer__close {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  right: 0.75rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: oklch(100% 0 0 / 0.14);
  color: oklch(98% 0 0);
  cursor: pointer;
}

/* ---------------------------------------------------------------- 切り抜き */

.cropper {
  width: min(24rem, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 1rem);
  padding: var(--space-3);
  overflow-y: auto;
}

.cropper[open] {
  display: grid;
  gap: var(--space-2);
  justify-items: center;
}

.cropper h2 {
  justify-self: start;
  margin: 0;
  font-family: var(--font-plaque);
}

.cropper__hint {
  justify-self: start;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

/* 3:4 の枠。高さは画面に収まる範囲で */
.cropper__frame {
  position: relative;
  width: min(100%, calc((100dvh - 17rem) * 0.75));
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 4px;
  background: oklch(15% 0.01 50);
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.cropper__frame:active {
  cursor: grabbing;
}

.cropper__image {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
}

/* 三分割の線と、顔の位置の目安 */
.cropper__guide {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent calc(33.33% - 0.5px), oklch(100% 0 0 / 0.35) calc(33.33% - 0.5px) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px) calc(66.66% - 0.5px), oklch(100% 0 0 / 0.35) calc(66.66% - 0.5px) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)),
    linear-gradient(0deg, transparent calc(33.33% - 0.5px), oklch(100% 0 0 / 0.35) calc(33.33% - 0.5px) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px) calc(66.66% - 0.5px), oklch(100% 0 0 / 0.35) calc(66.66% - 0.5px) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px));
  box-shadow: inset 0 0 0 2px oklch(100% 0 0 / 0.7);
}

.cropper__guide::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 38%;
  width: 46%;
  aspect-ratio: 3 / 4;
  border: 1.5px dashed oklch(100% 0 0 / 0.55);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.cropper__zoom {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  font-weight: 700;
  color: var(--ink-soft);
}

.cropper__zoom input {
  flex: 1;
  accent-color: var(--shu);
}

.cropper__actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: var(--space-2);
  width: 100%;
}

.cropper__reset {
  padding-top: 0;
}

/* ---------------------------------------------------------------- シートの写真ボタン */

.sheet__photo-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.sheet__photo-btn:has(.portrait[data-empty]) {
  cursor: pointer;
}

/* 暗い背景の上では、フォーカスの輪を白にする */
.viewer__close:focus-visible {
  outline-color: oklch(98% 0 0);
}
