/* アクリルキーホルダーの部品の見た目(サイズ選び・進み具合・手直し・向きと明るさ・カット線)。
   本体の style.css・post.css のクラスは変えない。アクキーに要るものだけをここに足す(クラス名は akey- で始める) */

/* display を指定した要素は、hidden 属性だけでは消えない(指定のほうが勝つ)。消したいものは明示する */
.akey-sizes[hidden],
.akey-resume[hidden],
.akey-progress[hidden] { display: none; }

/* ---------- サイズ選び ---------- */
.akey-sizes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 6px;
}
.akey-size {
  min-height: 60px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
}
.akey-size b { font-size: 17px; }
.akey-size span { font-size: 12px; color: var(--muted); }
.akey-size[aria-checked="true"] { border-color: var(--accent); background: #eef3f0; color: var(--accent-dark); }
.akey-size[aria-checked="true"] span { color: var(--accent-dark); }

.akey-pick { margin-top: 18px; }

/* ---------- 前回の続き ---------- */
.akey-resume {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: #f3f7f5;
  font-size: 13.5px;
}
.akey-resume .btn { min-height: 44px; font-size: 14px; margin-top: 8px; }

/* ---------- 進み具合 ---------- */
.akey-progress {
  height: 10px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
  margin: 18px 0 6px;
}
.akey-progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s;
}
/* サーバーの返事を待っているあいだ(どれだけ残っているか分からない)は、ゆっくり光らせる */
.akey-progress.waiting > span { animation: akey-pulse 1.2s ease-in-out infinite; }
/* 最後まで伸ばした棒(ページに style="…" を書かないため。CSP) */
.akey-progress > span.akey-progress-full { width: 100%; }
@keyframes akey-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- 市松模様(透明な所を見せる背景) ---------- */
.akey-checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e6e2da 25%, transparent 25%),
    linear-gradient(-45deg, #e6e2da 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e2da 75%),
    linear-gradient(-45deg, transparent 75%, #e6e2da 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ---------- 全画面の画面(手直し・向きと明るさ・カット線) ----------
   画面いっぱいに出す。ページの見出しや流れの説明の下に置くと、指で操作する場所が画面の外へ押し出されるため。
   スクロールせずに、操作するところが親指の届く下半分に収まるようにする(位置決めの試作の placement.css と同じ作り) */
.akey-screen.active {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  margin: 0;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
}
.akey-screen > * {
  width: 100%;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  flex: 0 0 auto;
}
.akey-screen .akey-title { margin: 0 auto 6px; font-size: 16px; text-align: center; }
.akey-notice { margin: 0 auto 6px; padding: 6px 10px; border-radius: 8px; background: #faf3e3; color: var(--warn); font-size: 12.5px; }
.akey-notice[hidden] { display: none; }

/* ステージ。残りの高さをすべて使う */
.akey-stage-wrap {
  flex: 1 1 auto;
  min-height: 220px;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #1f1c18;
}
.akey-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: crosshair;
  /* 指の動きを、ページのスクロールや拡大に取られないようにする */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.akey-stage:focus-visible { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.55); }
.akey-tip,
.akey-loading {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  color: #fff;
  pointer-events: none;
}
.akey-tip { top: 6px; left: 50%; right: auto; transform: translateX(-50%); padding: 2px 10px; border-radius: 99px; background: rgba(38, 35, 31, 0.72); font-size: 12px; white-space: nowrap; }
.akey-loading { top: 50%; transform: translateY(-50%); font-size: 14px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.akey-tip[hidden],
.akey-loading[hidden] { display: none; }

/* つまみとボタン。どれも指で押しやすい 44px 以上 */
.akey-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; min-height: 44px; }
.akey-row[hidden] { display: none; }
.akey-cap { flex: 0 0 3.3em; font-size: 13px; font-weight: 700; }
.akey-range {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  margin: 0;
  accent-color: var(--accent);
  touch-action: manipulation;
}
.akey-val {
  flex: 0 0 4.2em;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.akey-size-dot {
  flex: 0 0 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* ブラシの太さの見本(画面の上の実際の大きさ。44px を超える太さは 44px で表す) */
.akey-size-dot::after { content: ""; display: block; width: var(--d, 16px); height: var(--d, 16px); border-radius: 50%; border: 2px solid var(--accent-dark); box-sizing: border-box; }
.akey-tools { gap: 8px; }
.akey-tool {
  flex: 1 1 0;
  min-height: 44px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.akey-tool[aria-pressed="true"] { border-color: var(--accent); background: #eef3f0; color: var(--accent-dark); }
.akey-act {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation; /* 続けて押しても、画面が拡大しないように */
}
.akey-act:disabled { color: #c5c0b5; cursor: default; }
.akey-step {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: #fff;
  color: var(--accent-dark);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.akey-step:disabled { border-color: var(--line); color: #c5c0b5; cursor: default; }
.akey-screen .btn-row { margin-top: 8px; }
.akey-screen .btn { touch-action: manipulation; }

/* ---------- ④ 向きと明るさ・⑤ カット線とキー穴 ---------- */
.akey-stage-light { background: #ece8df; }
.akey-stage-hole { cursor: pointer; }
.akey-loading-dark { color: var(--accent-dark); text-shadow: none; font-weight: 700; }
.akey-hint { margin: 0 auto 6px; font-size: 12.5px; color: var(--muted); text-align: center; }
.akey-hint-small { font-size: 11.5px; margin-top: 4px; }
.akey-sizes-compact { margin: 8px auto 0; gap: 6px; }
.akey-sizes-compact .akey-size { min-height: 44px; }
.akey-sizes-compact .akey-size b { font-size: 14px; }
.akey-sizes-compact .akey-size span { font-size: 11px; }
.akey-val-wide { flex: 0 0 5.5em; font-size: 12px; }
.akey-info { list-style: none; margin: 6px auto 0; padding: 0; font-size: 13px; min-height: 1.6em; }
.akey-info li { margin: 2px 0; }
.akey-info .akey-warn { color: var(--warn); font-size: 12.5px; }
.akey-error { margin-top: 6px; }
.akey-error[hidden] { display: none; }

/* ⑥ 完成イメージ */
.akey-preview-box {
  background: #ece8df;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.akey-preview-box img { display: block; width: 100%; max-width: 360px; max-height: 56vh; margin: 0 auto; }
.akey-files a { font-weight: 700; }
