/* 絵に寄せる共通の部品：ゆれ線・紙・水彩・光・名札。
   白いカード・きっちりした角丸・強い影は使わない。
   フィルター(#pencil #watercolor #paper)は index.html に1回だけ定義してある */

.filters {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* 画面全体に1枚だけ重ねる紙のざらざら */
.grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
}

/* 仮の図形の線は、ゆれたえんぴつ線にする */
.ink {
  filter: url(#pencil);
}

/* 紙片：背景と枠だけをゆらし、文字はゆらさない */
.sketch {
  position: relative;
  isolation: isolate;
}
.sketch::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--card);
  border: 1.5px solid var(--line);
  filter: url(#pencil);
}

/* メインボタン：水彩で塗った紙片 */
.wash-btn,
.sketch-btn {
  position: relative;
  isolation: isolate;
  border: 0;
  background: none;
  padding: 0.6em 1.6em;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s;
}
.wash-btn {
  color: var(--btn-text);
}
.wash-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--btn);
  border-radius: 3px 9px 4px 10px / 10px 4px 9px 3px;
  filter: url(#watercolor);
}
.sketch-btn {
  color: var(--text);
}
.sketch-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--input);
  border: 1.5px solid var(--line);
  filter: url(#pencil);
}
.wash-btn:active,
.sketch-btn:active {
  transform: scale(0.97);
}

/* 丸い紙のボタン(戻る・歯車) */
.round-btn {
  position: relative;
  isolation: isolate;
  width: 46px;
  height: 46px;
  flex: none;
  border: 0;
  padding: 0;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}
.round-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--line);
  filter: url(#pencil);
}
.round-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.round-btn.is-glowing::after {
  content: '';
  position: absolute;
  inset: -10px;
  z-index: -2;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow), transparent);
  animation: breathe 3.2s ease-in-out infinite;
}

/* 押せる場所：うっすら光る */
.hotspot {
  position: absolute;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
.hotspot__glow {
  position: absolute;
  inset: -8%;
  border-radius: 40%;
  background: radial-gradient(closest-side, var(--glow), transparent);
  pointer-events: none;
  animation: breathe 3.2s ease-in-out infinite;
}
.hotspot:active .hotspot__glow {
  opacity: 0.9;
}

@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

/* 手書き風の名札 */
.tag {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  white-space: nowrap;
  font-weight: 600;
  font-size: clamp(13px, 3.8vw, 18px);
  line-height: 1.4;
  padding: 0.15em 0.75em;
  isolation: isolate;
}
.tag::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--card);
  border: 1.5px solid var(--line);
  filter: url(#pencil);
  opacity: 0.94;
}
.tag--bottom {
  top: calc(100% + 6px);
}
.tag--top {
  bottom: calc(100% + 6px);
}

/* えんぴつの丸で囲む */
.pencil-ring {
  position: absolute;
  inset: -8px -10px;
  width: calc(100% + 20px);
  height: calc(100% + 16px);
  fill: none;
  stroke: var(--text);
  stroke-width: 2.2;
  stroke-linecap: round;
  pointer-events: none;
  filter: url(#pencil);
  vector-effect: non-scaling-stroke;
}

/* 紙のダイアログ */
.paper-dialog {
  border: 0;
  padding: 0;
  background: none;
  color: var(--text);
  max-width: min(88vw, 380px);
  width: 100%;
}
.paper-dialog::backdrop {
  background: rgba(40, 30, 20, 0.35);
}
.paper-dialog__sheet {
  padding: 26px 22px 22px;
}
.paper-dialog__msg {
  margin: 0 0 20px;
  white-space: pre-line;
}
.paper-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

/* 仮の図形の色 */
.ph { display: block; width: 100%; height: 100%; }
.ph-wall { fill: var(--wall); }
.ph-floor { fill: var(--floor); }
.ph-wood { fill: var(--wood); }
.ph-wood-light { fill: var(--wood-light); }
.ph-paper { fill: var(--card); }
.ph-glass { fill: var(--glass); fill-opacity: 0.85; }
.ph-glass-piece { fill: #9DC9A6; opacity: 0.85; }
.ph-window-glass { fill: var(--window-glass); }
.ph-sky { fill: var(--sky); }
.ph-hill { fill: var(--hill); }
.ph-path { fill: var(--path); }
.ph-sea { fill: var(--sea); }
.ph-sand { fill: var(--sand); }
.ph-forest { fill: var(--forest); }
.ph-tree { fill: var(--tree); }
.ph-tree-dark { fill: var(--tree-dark); }
.ph-knob { fill: #E9B44C; }
.ph-lamp { fill: #FFD98A; }
.ph-crow { fill: #2E2C33; }
.ph-beak { fill: #4A4650; }
.ph-eye { fill: #F3EEDF; }
.ph-scarf { fill: #D9C29A; }
.ph-stroke { stroke: var(--line); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.ph-line { fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.ph-text { fill: var(--text); font-family: 'Klee One', sans-serif; font-weight: 600; font-size: 46px; }
.ph-text-sub { fill: var(--text-sub); font-family: 'Klee One', sans-serif; font-size: 34px; }

@media (prefers-reduced-motion: reduce) {
  .hotspot__glow,
  .round-btn.is-glowing::after {
    animation: none;
    opacity: 0.5;
  }
}
