/* 画像トリミングツール固有の見た目（共通部分は assets/image-tool.css） */

/* 画像を置く面。ここでの指の動きを画面のスクロールにしない（枠の操作に使う） */
.panes {
  cursor: crosshair;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 表示している画像と同じ大きさの面。切り抜き枠は、この上に % で重ねる */
.crop-area {
  position: relative;
  flex: none;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(27, 31, 51, 0.1), 0 12px 32px -12px rgba(27, 31, 51, 0.35);
}
.crop-area img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 枠の外を暗くする層（大きな影を、画像の範囲で切る）。つまみは切られないように、枠とは別の層にしている */
.crop-shade {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.crop-hole {
  position: absolute;
  box-shadow: 0 0 0 9999px rgba(12, 15, 31, 0.55);
}
.crop-hole.is-circle { border-radius: 50%; }

/* 切り抜き枠: 白い線と三分割の補助線、角と辺のつまみ */
.crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(12, 15, 31, 0.35);
  cursor: move;
  outline: none;
}
.crop-box:focus-visible { border-color: #c7cbff; box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.7); }
.crop-box.is-circle { border-radius: 50%; }
/* 円形のとき、四角の範囲も薄い点線で見せる（つまみの位置が分かるように） */
.crop-box.is-circle::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border: 1px dashed rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
.crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  background:
    linear-gradient(to right, transparent calc(33.333% - 0.5px), rgba(255, 255, 255, 0.55) calc(33.333% - 0.5px), rgba(255, 255, 255, 0.55) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px), rgba(255, 255, 255, 0.55) calc(66.666% - 0.5px), rgba(255, 255, 255, 0.55) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px)),
    linear-gradient(to bottom, transparent calc(33.333% - 0.5px), rgba(255, 255, 255, 0.55) calc(33.333% - 0.5px), rgba(255, 255, 255, 0.55) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px), rgba(255, 255, 255, 0.55) calc(66.666% - 0.5px), rgba(255, 255, 255, 0.55) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px));
}
.crop-box.is-active .crop-grid { opacity: 1; }
.crop-box.is-circle .crop-grid { border-radius: 50%; }

/* つまみ: 見た目は小さく、触れる範囲は大きく（::before で 40px 四方） */
.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--color-primary), 0 2px 6px rgba(12, 15, 31, 0.4);
  z-index: 1;
}
.crop-handle::before {
  content: "";
  position: absolute;
  inset: -13px;
}
.crop-handle[data-handle="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.crop-handle[data-handle="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.crop-handle[data-handle="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.crop-handle[data-handle="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-edge { width: 22px; height: 8px; margin: -4px 0 0 -11px; border-radius: 4px; }
.crop-edge[data-handle="n"] { left: 50%; top: 0; cursor: ns-resize; }
.crop-edge[data-handle="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.crop-edge[data-handle="e"] { left: 100%; top: 50%; width: 8px; height: 22px; margin: -11px 0 0 -4px; cursor: ew-resize; }
.crop-edge[data-handle="w"] { left: 0; top: 50%; width: 8px; height: 22px; margin: -11px 0 0 -4px; cursor: ew-resize; }
/* 縦横比を決めているときは、角だけで大きさを変える */
.crop-box.is-fixed .crop-edge { display: none; }

/* 左上に、保存される大きさ（px） */
.crop-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 3;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(12, 15, 31, 0.82);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* 縦横比・形（5択）。狭い画面でも1行に収める */
.shape-switch span { padding: 8px 2px; font-size: 0.86rem; white-space: nowrap; }
.swap-btn { gap: 5px; min-height: 28px; padding: 2px 8px; font-size: 0.8rem; }
.swap-btn svg { width: 15px; height: 15px; }
.swap-btn[aria-pressed="true"] { background: var(--color-primary-soft); }

/* 切り抜き後のプレビュー */
.crop-result {
  display: grid;
  place-items: center;
  min-height: 96px;
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--color-border);
}
.crop-result:not(.checker) { background: var(--color-surface-2); }
.crop-result canvas { display: block; max-width: 100%; }

.segmented label.is-disabled { cursor: not-allowed; }
.segmented label.is-disabled span { opacity: 0.4; }

@media (max-width: 860px) {
  .editor { --stage-h: 40vh; }
  .crop-badge { left: 10px; top: 10px; }
  .crop-result { min-height: 72px; padding: 8px; }
}
