/* 사진 오리기 도구 — 사이트 바탕(site.css 바인더 글래스: 점 모눈 종이·유리 카드·무채색) 위에 도구 칸만. 페이지는 site/tool-pages.mjs */
.tool { padding: 26px 20px 22px; }
.tool h1 { font-size: 30px; }

/* 한 화면에 지금 단계의 것만 — #cutout data-state(pick·tap·working·done·error)와 data-show 가 맞는 것만 보인다 */
.tool [data-show] { display: none; }
.tool[data-state="pick"] [data-show~="pick"],
.tool[data-state="tap"] [data-show~="tap"],
.tool[data-state="working"] [data-show~="working"],
.tool[data-state="done"] [data-show~="done"],
.tool[data-state="error"] [data-show~="error"] { display: var(--d, block); }

.stage { margin-top: 22px; text-align: center; }

.btn {
  --d: inline-flex;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; text-decoration: none;
  color: var(--ink); background: rgba(255, 255, 255, 0.9); box-shadow: inset 0 0 0 1px var(--line);
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--ink); color: #fff; box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.55); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .photo canvas:focus-visible, .pick:focus-within .btn { outline: 3px solid #4a90e2; outline-offset: 3px; }

/* 1. 사진 고르기 — 점선 판 한가운데 단추 하나 */
.pick {
  --d: flex;
  position: relative; flex-direction: column; align-items: center; justify-content: center;
  min-height: 260px; padding: 28px 16px; border-radius: 22px; cursor: pointer;
  background: rgba(255, 255, 255, 0.55);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.4px); background-size: 14px 14px;
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.14);
}
.pick input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.pick .btn { min-height: 56px; padding: 0 30px; font-size: 17px; pointer-events: none; }
/* 사진 여는 중(app.js setOpening) — 바로 다시 고르기를 막고, 120ms 뒤(shown)부터 단추가 천천히 깜빡인다 */
.tool[data-opening] { cursor: progress; }
.tool[data-opening] .pick, .tool[data-opening] .actions { pointer-events: none; }
.tool[data-opening="shown"] .pick .btn { background: rgba(255, 255, 255, 0.95); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); animation: cutout-opening 1.1s ease-in-out infinite; }
.tool[data-opening="shown"] .actions .btn { opacity: 0.5; }
@keyframes cutout-opening { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .tool[data-opening="shown"] .pick .btn { animation: none; } }

/* 2. 누르기 — 사진 위 누른 자리에 둥근 표시 */
.photo { --d: inline-block; position: relative; max-width: 100%; line-height: 0; border-radius: 18px; }
.photo canvas {
  display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto;
  border-radius: 18px; cursor: crosshair; touch-action: manipulation;
  box-shadow: 0 18px 40px -26px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--line);
}
.ring {
  position: absolute; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; pointer-events: none;
  border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.3);
}
.tool[data-state="working"] .photo canvas { filter: saturate(0.6) brightness(1.06); }
.tool[data-state="working"] .ring { animation: cutout-pulse 1s ease-in-out infinite; }
@keyframes cutout-pulse { 50% { transform: scale(0.82); opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) { .tool[data-state="working"] .ring { animation: none; } }
.hint { margin: 14px 0 0; min-height: 1.6em; font-size: 16px; font-weight: 600; }

/* 3. 결과 — 투명한 곳이 보이게 체크 무늬 위에 */
.result {
  --d: flex; align-items: center; justify-content: center;
  padding: 18px; border-radius: 22px; min-height: 200px;
  background: #fff repeating-conic-gradient(#ececec 0 25%, #fff 0 50%) 0 0 / 20px 20px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.result img { display: block; max-width: 100%; max-height: 56vh; width: auto; height: auto; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.18)); }

.error { margin: 0; padding: 18px 16px; border-radius: 18px; background: var(--sunk); font-weight: 600; text-align: left; }
noscript .error { display: block; margin-top: 12px; }

.actions { --d: flex; flex-direction: column; align-items: stretch; gap: 10px; margin-top: 16px; }
.actions .more { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.actions .more .btn { flex: 1 1 auto; min-height: 44px; font-size: 15px; font-weight: 600; }

.private { margin: 16px 0 0; font-size: 13px; color: var(--soft); text-align: center; text-wrap: balance; }
.private svg { display: inline-block; vertical-align: -3px; margin-right: 4px; }

.app {
  --d: flex; align-items: center; gap: 12px; margin: 18px 0 0; padding: 14px 16px; border-radius: 18px;
  font-size: 14px; line-height: 1.5; background: rgba(255, 255, 255, 0.8); box-shadow: inset 0 0 0 1px var(--line); text-align: left;
}
.app img { flex: none; }
.app span { min-width: 0; }
/* 일본어는 낱말 사이 빈칸이 없어 keep-all(site.css)이면 줄이 넘친다 — 이 도구 칸은 보통 줄바꿈 */
html:lang(ja) .tool, html:lang(ja) .tool-info { word-break: normal; line-break: strict; }
html:lang(ja) .tool h1 { word-break: keep-all; }
.app a { font-weight: 700; white-space: nowrap; }

/* 쓰는 법·자주 묻는 질문·더 보기 */
.tool-info h2, .tool-more h2 { margin: 0 0 10px; font-size: 20px; letter-spacing: -0.02em; }
.tool-info h2 + * { margin-top: 0; }
.tool-info h2:not(:first-child) { margin-top: 26px; }
.tool-info h3 { margin: 16px 0 4px; font-size: 16px; }
.tool-info p { margin: 0; color: var(--soft); }
.steps { margin: 0; padding-left: 1.4em; }
.steps li + li { margin-top: 6px; }
.oss { margin: 22px 0 0; font-size: 12px; }
.oss a { color: var(--faint); }
.tool-more a { display: flex; align-items: center; gap: 12px; padding: 10px 4px; text-decoration: none; color: var(--soft); }
.tool-more strong { color: var(--ink); margin-right: 4px; }
.tool-more a.read { padding: 12px 4px; color: var(--ink); font-weight: 600; box-shadow: inset 0 1px 0 var(--line); }

@media (min-width: 640px) {
  .tool { padding: 32px 28px 26px; }
  .tool h1 { font-size: 34px; }
  .pick { min-height: 300px; }
  .actions { flex-direction: row; align-items: center; justify-content: center; }
  .actions .btn.primary { min-width: 200px; }
  .actions .more { flex-wrap: nowrap; }
  .actions .more .btn { flex: none; }
}
