/* Folio v0.7.0 — 切り取らない写真貼り付け */
:root {
  --photo-paper: #f2ead7;
  --photo-ink: #29332d;
  --photo-moss: #506656;
  --photo-moss-pale: #dce2d4;
  --photo-mat: #c9c0ae;
  --photo-line: rgba(62, 75, 65, .24);
}

[data-photo-slot] {
  background: linear-gradient(135deg, #d7cebc, #c5baa7);
}

[data-photo-slot] img,
#photoEditorImage {
  object-fit: var(--photo-fit, contain) !important;
  object-position: center !important;
}

.photo-editor-dialog {
  width: min(980px, calc(100vw - 24px));
  max-height: calc(100dvh - 20px);
}

.photo-editor-dialog::backdrop {
  background: rgba(25, 18, 12, .7);
}

.photo-editor-paper {
  max-height: calc(100dvh - 20px);
  padding: clamp(16px, 2vw, 26px);
  overflow: auto;
  color: var(--photo-ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(76,70,56,.04) 31px 32px),
    var(--photo-paper);
}

.photo-editor-header h2 {
  font-size: clamp(25px, 2.4vw, 34px);
}

.photo-editor-header p {
  margin: 7px 0 0;
  color: #5f655d;
  font: 11px/1.6 var(--body);
}

.photo-editor-stage {
  height: min(56dvh, 520px);
  margin-top: 14px;
  border-width: 10px;
  border-bottom-width: 32px;
  background:
    linear-gradient(45deg, rgba(255,255,255,.12) 25%, transparent 25% 75%, rgba(255,255,255,.12) 75%) 0 0 / 20px 20px,
    var(--photo-mat);
}

.photo-editor-stage[data-fit="contain"] {
  cursor: default;
}

.photo-editor-stage img {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.photo-editor-stage > span {
  right: 10px;
  bottom: -25px;
  font-size: 9px;
}

.photo-fit-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
}

.photo-fit-switch button {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px 12px;
  padding: 9px 14px;
  border: 1px solid var(--photo-line);
  border-radius: 3px;
  color: var(--photo-ink);
  background: rgba(255, 252, 243, .58);
  text-align: left;
}

.photo-fit-switch button::before {
  content: "";
  grid-row: 1 / 3;
  width: 18px;
  height: 18px;
  border: 1px solid #758074;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--photo-paper);
}

.photo-fit-switch button.is-active {
  border-color: var(--photo-moss);
  background: var(--photo-moss-pale);
  box-shadow: inset 4px 0 0 var(--photo-moss);
}

.photo-fit-switch button.is-active::before {
  background: var(--photo-moss);
}

.photo-fit-switch b {
  font: 600 13px var(--display);
}

.photo-fit-switch small {
  color: #646b63;
  font: 9px var(--body);
}

.photo-editor-controls {
  grid-template-columns: auto auto auto minmax(190px, 1fr) auto;
}

.photo-editor-controls button,
.photo-editor-controls label,
.photo-editor-actions button {
  border-radius: 3px;
  font-size: 11px;
}

.photo-editor-actions .primary {
  min-width: 190px;
  background: var(--photo-moss);
}

@media (max-width: 839px) {
  .photo-editor-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 10px);
  }

  .photo-editor-paper {
    max-height: calc(100dvh - 10px);
    padding: 14px 11px 12px;
  }

  .photo-editor-header p { font-size: 10px; }
  .photo-editor-stage { height: min(45dvh, 390px); margin-top: 10px; }
  .photo-fit-switch { margin-top: 10px; }
  .photo-fit-switch button { min-height: 54px; padding: 7px 10px; }
  .photo-editor-controls { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .photo-editor-controls label { grid-column: 1 / -1; }
  .photo-editor-controls button:first-child { grid-column: 1 / -1; }
  .photo-editor-actions .primary { min-width: 0; }
}

@media (max-width: 390px) {
  .photo-editor-stage { height: 39dvh; }
  .photo-fit-switch b { font-size: 12px; }
  .photo-fit-switch small { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  [data-photo-slot] img,
  #photoEditorImage { will-change: auto; }
}
