/* =========================================
   Benri Kit: 解説セクション・操作アニメーション共通パーツ
   doc/デザイン.html のパーツを .bk-* に移植。
   色はページ側の変数を優先し、配色が大きく異なるページは
   --bk-primary / --bk-primary-hover / --bk-accent / --bk-rgb を上書きする。
   ========================================= */
:root {
    --bk-primary: var(--primary-color, #00AEEF);
    --bk-primary-hover: var(--primary-hover, #0095cd);
    --bk-accent: var(--accent-yellow, #FFD93D);
    --bk-rgb: 0, 174, 239;
    --bk-text: var(--text-main, #333);
    --bk-sub: var(--text-sub, #666);
    --bk-bg: #fff;
    --bk-bg-light: var(--bg-light, #f4f9fc);
    --bk-line: #eee;
    --bk-safe-bg: #e6fffa; --bk-safe: #2c7a7b; --bk-safe-line: #b2f5ea;
    --bk-warning-bg: #fffaf0; --bk-warning: #c05621; --bk-warning-line: #fbd38d;
    --bk-danger-bg: #fff5f5; --bk-danger: #c53030; --bk-danger-line: #feb2b2;
    --bk-shadow-card: 0 10px 30px rgba(0, 0, 0, .05);
}

/* ---------- 解説エリア ---------- */
.bk-guide { max-width: 1000px; margin: 0 auto; padding: 0 20px 64px; color: var(--bk-text); text-align: left; line-height: 1.8; }
.bk-guide *, .bk-guide *::before, .bk-guide *::after { box-sizing: border-box; }
.bk-nav { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 24px 0; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--bk-line); }
.bk-nav a { padding: 6px 0; border-bottom: 2px solid transparent; color: var(--bk-text); text-decoration: none; transition: color .2s, border-color .2s; }
.bk-nav a:hover { color: var(--bk-primary); border-color: var(--bk-accent); }
.bk-section { padding: 38px 0 46px; border-bottom: 1px solid var(--bk-line); scroll-margin-top: 100px; }
.bk-section:last-child { border-bottom: 0; }
.bk-head { display: flex; gap: 18px; align-items: baseline; margin: 0 0 12px; }
.bk-no { font: 700 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--bk-primary); }
.bk-head h2 { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.5; color: var(--bk-text); }
.bk-head h2 small { font-size: 13px; font-weight: 400; color: var(--bk-sub); margin-left: 12px; }
.bk-desc { color: var(--bk-sub); font-size: 14px; line-height: 1.9; margin: 0 0 24px; }
.bk-guide h3 { font-size: 17px; font-weight: 700; margin: 28px 0 12px; color: var(--bk-text); }
.bk-guide p { margin: 0 0 12px; font-size: 15px; }
.bk-guide .bk-note { font-size: 12px; color: var(--bk-sub); margin-top: 10px; }
.bk-guide a:where(:not(.btn):not(.tm-btn-primary)) { color: var(--bk-primary); text-decoration: underline; text-underline-offset: 4px; }
.bk-guide .bk-nav a { color: var(--bk-text); text-decoration: none; }
.bk-guide .bk-nav a:hover { color: var(--bk-primary); }
.bk-highlight { color: var(--bk-primary); background: linear-gradient(transparent 70%, var(--bk-accent) 70%); padding: 0 4px; }
.bk-stage { background: var(--bk-bg-light); padding: 24px; border-radius: 16px; }
.bk-panel { background: var(--bk-bg-light); border-radius: 12px; padding: 20px 22px; }
.bk-panel > :last-child { margin-bottom: 0; }

/* カード */
.bk-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.bk-cards.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bk-cards.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.bk-card { min-width: 0; border-radius: 16px; background: var(--bk-bg); padding: 22px; box-shadow: var(--bk-shadow-card); }
.bk-card h3 { margin: 0 0 8px; font-size: 16px; }
.bk-card p { font-size: 13px; line-height: 1.9; color: var(--bk-sub); margin: 0 0 6px; }
.bk-card .bk-icon { color: var(--bk-primary); font-size: 22px; margin-bottom: 14px; display: block; }
.bk-card.result { border: 2px solid var(--bk-line); box-shadow: none; text-align: center; }
.bk-card.result .value { font-size: 30px; font-weight: 800; line-height: 1.3; margin: 8px 0; color: var(--bk-text); }
.bk-card.featured { background: linear-gradient(135deg, var(--bk-primary), var(--bk-primary-hover)); color: #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, .1); }
.bk-card.featured h3, .bk-card.featured p, .bk-card.featured .value { color: #fff; }
.bk-card figure { margin: 0 0 12px; }
.bk-card figure img { display: block; width: 100%; max-width: 320px; height: auto; margin: 0 auto; border-radius: 10px; background: #fff; }
.bk-card figcaption { font-size: 12px; color: var(--bk-sub); margin-top: 6px; }

/* 表 */
.bk-table-wrap { overflow-x: auto; border: 1px solid var(--bk-line); border-radius: 12px; background: var(--bk-bg); -webkit-overflow-scrolling: touch; }
.bk-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
.bk-table th, .bk-table td { padding: 12px 14px; border-bottom: 1px solid var(--bk-line); text-align: left; vertical-align: top; }
.bk-table thead th { background: var(--bk-bg-light); font-size: 13px; color: var(--bk-sub); white-space: nowrap; }
.bk-table tbody tr:last-child th, .bk-table tbody tr:last-child td { border-bottom: 0; }
.bk-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bk-table tbody th { font-weight: 700; }

/* 手順 */
.bk-steps { list-style: none; padding: 0; margin: 0; counter-reset: bkstep; }
.bk-steps li { counter-increment: bkstep; display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--bk-line); align-items: flex-start; }
.bk-steps li:last-child { border-bottom: 0; }
.bk-steps li::before { content: counter(bkstep, decimal-leading-zero); display: grid; place-items: center; flex: 0 0 34px; height: 34px; background: var(--bk-accent); color: #333; border-radius: 50%; font-size: 12px; font-weight: 800; }
.bk-steps strong { display: block; font-size: 14px; }
.bk-steps p { font-size: 13px; color: var(--bk-sub); margin: 4px 0 0; line-height: 1.8; }

/* 箇条書き */
.bk-list { margin: 0 0 12px; padding-left: 1.3em; list-style: disc; }
.bk-list li { margin: 4px 0; font-size: 14px; color: var(--bk-sub); }
.bk-list li strong { color: var(--bk-text); }

/* FAQ */
.bk-faq { border: 1px solid var(--bk-line); border-radius: 16px; overflow: hidden; background: var(--bk-bg); }
.bk-faq details { border-bottom: 1px solid var(--bk-line); transition: background-color .2s; }
.bk-faq details:last-child { border-bottom: 0; }
.bk-faq summary { display: flex; align-items: center; gap: 14px; padding: 18px 22px; cursor: pointer; list-style: none; font-size: 14px; font-weight: 700; color: var(--bk-text); }
.bk-faq summary::-webkit-details-marker { display: none; }
.bk-faq summary .q { color: var(--bk-primary); font-size: 18px; }
.bk-faq summary::after { content: ''; width: 12px; height: 12px; margin-left: auto; flex-shrink: 0; background: linear-gradient(#666, #666) center/12px 2px no-repeat, linear-gradient(#666, #666) center/2px 12px no-repeat; transition: transform .25s ease; }
.bk-faq details[open] { background: var(--bk-bg-light); }
.bk-faq details[open] summary::after { background: linear-gradient(#666, #666) center/12px 2px no-repeat; transform: rotate(180deg); }
.bk-faq details > div, .bk-faq details > p { margin: 0 22px 20px 50px; font-size: 14px; line-height: 1.9; color: var(--bk-sub); }
.bk-faq details[open] > div, .bk-faq details[open] > p { animation: bk-fade-down .25s ease; }

/* 通知 */
.bk-alert { display: flex; align-items: flex-start; gap: 12px; border: 1px solid; padding: 16px 18px; border-radius: 8px; font-size: 13px; line-height: 1.8; margin: 0 0 16px; }
.bk-alert strong { display: block; font-size: 14px; margin-bottom: 2px; }
.bk-alert i { margin-top: 4px; }
.bk-alert p { font-size: 13px; margin: 0; }
.bk-alert.safe { background: var(--bk-safe-bg); color: var(--bk-safe); border-color: var(--bk-safe-line); }
.bk-alert.warning { background: var(--bk-warning-bg); color: var(--bk-warning); border-color: var(--bk-warning-line); }
.bk-alert.danger { background: var(--bk-danger-bg); color: var(--bk-danger); border-color: var(--bk-danger-line); }

/* コピーできる作例 */
.bk-examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.bk-example { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--bk-line); border-radius: 16px; background: var(--bk-bg); overflow: hidden; }
.bk-example-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 16px 0; }
.bk-example-head strong { font-size: 14px; }
.bk-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--bk-bg-light); color: var(--bk-sub); font-size: 11px; font-weight: 700; }
.bk-example pre { margin: 12px 16px; padding: 14px; background: var(--bk-bg-light); border-radius: 10px; font-family: inherit; font-size: 14px; line-height: 1.5; white-space: pre; overflow-x: auto; color: var(--bk-text); }
.bk-example .bk-meta { padding: 0 16px; font-size: 12px; color: var(--bk-sub); margin: 0 0 12px; }
.bk-example-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--bk-line); }
.bk-copy { border: 2px solid var(--bk-primary); background: var(--bk-bg); color: var(--bk-primary); border-radius: 9999px; padding: 6px 16px; font: 700 13px inherit; font-family: inherit; cursor: pointer; transition: transform .2s, background-color .2s, color .2s, box-shadow .2s; }
.bk-copy:hover { background: var(--bk-primary); color: #fff; transform: translateY(-1px); }
.bk-copy:active { transform: translateY(1px); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
.bk-copy:focus-visible, .bk-guide :is(a, summary, button):focus-visible { outline: 3px solid var(--bk-primary); outline-offset: 3px; }

/* ステータスピル（完了時に光が流れる） */
.bk-pill { display: inline-block; padding: 4px 9px; border-radius: 4px; background: var(--bk-safe-bg); color: var(--bk-safe); font-size: 11px; white-space: nowrap; font-weight: 700; }
.bk-pill.wait { background: #eee; color: #666; }
.bk-pill.complete { position: relative; overflow: hidden; isolation: isolate; background: var(--bk-primary); color: #fff; }
.bk-pill.complete::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(115deg, transparent 25%, rgba(255, 255, 255, .95) 50%, transparent 75%); transform: translateX(-140%); animation: bk-shine 3s ease-in-out infinite; }
.bk-pill[hidden] { display: none; }

/* 関連リンク */
.bk-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.bk-links a { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border: 1px solid var(--bk-line); border-radius: 12px; background: var(--bk-bg); color: var(--bk-text) !important; text-decoration: none !important; transition: border-color .2s, transform .2s, box-shadow .2s; }
.bk-links a:hover { border-color: var(--bk-primary); transform: translateY(-2px); box-shadow: var(--bk-shadow-card); }
.bk-links a i { color: var(--bk-primary); font-size: 18px; margin-top: 3px; }
.bk-links strong { display: block; font-size: 14px; }
.bk-links small { display: block; font-size: 12px; color: var(--bk-sub); line-height: 1.7; }

/* スクロールで表示 */
.bk-reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.bk-reveal.is-visible { opacity: 1; transform: none; }

/* ---------- 操作アニメーション（body.bk-motion 内の既存UIに適用） ---------- */
.bk-motion .btn:not(:disabled):active { transform: translateY(1px); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
.bk-motion input[type=checkbox]:checked:not(.bk-no-motion) { animation: bk-bounce .3s cubic-bezier(.4, 0, .2, 1); }
.bk-motion input[type=radio]:checked:not(.bk-no-motion) { animation: bk-bounce .3s cubic-bezier(.4, 0, .2, 1); }
.bk-motion .bk-pop { animation: bk-pop .3s cubic-bezier(.4, 0, .2, 1); }
.bk-motion input[type=range] { --bk-handle-scale: 1; --bk-handle-motion: transform .42s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s ease; cursor: grab; }
.bk-motion input[type=range]::-webkit-slider-thumb { transform: scale(var(--bk-handle-scale)); transition: var(--bk-handle-motion); }
.bk-motion input[type=range]::-moz-range-thumb { transform: scale(var(--bk-handle-scale)); transition: var(--bk-handle-motion); }
@media (hover: hover) { .bk-motion input[type=range]:hover { --bk-handle-scale: 1.05; } }
.bk-motion input[type=range].is-grabbing { cursor: grabbing; --bk-handle-scale: 1.35; --bk-handle-motion: transform .16s ease-out, box-shadow .2s ease; }
.bk-registered { animation: bk-upload-flash 1s ease-out; }
/* 標準スライダーをデザイン見本の形にそろえる（進捗は --bk-progress） */
input[type=range].bk-range { -webkit-appearance: none; appearance: none; height: 32px; margin: 0; padding: 0; background: transparent; }
input[type=range].bk-range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--bk-range-color, var(--bk-primary)) 0 var(--bk-progress, 50%), #ddd var(--bk-progress, 50%) 100%); }
input[type=range].bk-range::-moz-range-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--bk-range-color, var(--bk-primary)) 0 var(--bk-progress, 50%), #ddd var(--bk-progress, 50%) 100%); }
input[type=range].bk-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -7px; border: 0; border-radius: 50%; background: var(--bk-range-color, var(--bk-primary)); box-shadow: 0 2px 5px rgba(0, 0, 0, .12); }
input[type=range].bk-range::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--bk-range-color, var(--bk-primary)); box-shadow: 0 2px 5px rgba(0, 0, 0, .12); }
input[type=range].bk-range:focus-visible { outline: 3px solid var(--bk-primary); outline-offset: 4px; border-radius: 4px; }

/* ロード中 */
.bk-loading-bars { display: inline-flex; justify-content: center; align-items: center; height: 48px; gap: 5px; }
.bk-loading-bars span { width: 4px; height: 40px; border-radius: 999px; background: var(--bk-primary); animation: bk-wave .9s ease-in-out infinite; }
.bk-loading-bars span:nth-child(2) { background: var(--accent-pink, #FF6B6B); animation-delay: -.8s; }
.bk-loading-bars span:nth-child(3) { background: var(--bk-accent); animation-delay: -.7s; }
.bk-loading-bars span:nth-child(4) { background: var(--accent-pink, #FF6B6B); animation-delay: -.6s; }
.bk-loading-bars span:nth-child(5) { animation-delay: -.5s; }

@keyframes bk-bounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes bk-pop { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes bk-fade-down { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes bk-shine { 0%, 15% { transform: translateX(-140%); opacity: 0; } 25% { opacity: 1; } 55% { transform: translateX(140%); opacity: 1; } 65%, 100% { transform: translateX(140%); opacity: 0; } }
@keyframes bk-wave { 0%, 40%, 100% { transform: scaleY(.05); } 20% { transform: scaleY(1); } }
@keyframes bk-upload-flash {
    0% { outline: 2px solid var(--bk-primary); outline-offset: -2px; box-shadow: 0 0 0 0 rgba(var(--bk-rgb), .42); }
    45% { outline: 2px solid var(--bk-primary); outline-offset: -2px; box-shadow: 0 0 0 10px rgba(var(--bk-rgb), .16), 0 14px 36px rgba(var(--bk-rgb), .22); }
    100% { outline: 2px solid transparent; outline-offset: -2px; box-shadow: 0 0 0 0 rgba(var(--bk-rgb), 0); }
}

@media (max-width: 1000px) {
    .bk-cards.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .bk-guide { padding: 0 16px 40px; }
    .bk-section { padding: 28px 0 34px; }
    .bk-head { gap: 12px; }
    .bk-head h2 { font-size: 20px; }
    .bk-head h2 small { display: block; margin: 2px 0 0; }
    .bk-cards, .bk-cards.cols-2, .bk-cards.cols-4, .bk-examples, .bk-links { grid-template-columns: 1fr; }
    .bk-stage { padding: 16px; }
    .bk-faq summary { padding: 16px; }
    .bk-faq details > div, .bk-faq details > p { margin-left: 44px; margin-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .bk-reveal { opacity: 1; transform: none; transition: none; }
    .bk-guide *, .bk-motion .bk-pop, .bk-registered { animation: none !important; transition: none !important; }
    .bk-motion input[type=checkbox], .bk-motion input[type=radio] { animation: none !important; }
    .bk-motion input[type=range] { --bk-handle-motion: none; }
    .bk-pill.complete::before { animation: none; opacity: 0; }
    .bk-loading-bars span { animation: none; transform: scaleY(.45); }
}

/* 加工前後の比較 */
.bk-compare-list { display: grid; gap: 18px; }
.bk-compare-card h3 { display: flex; align-items: center; flex-wrap: wrap; }
.bk-compare-card .bk-ba { max-width: 720px; margin: 0 auto; }

/* 前後比較スライダー（左＝加工前、右＝加工後。.bk-ba-range を左右に動かして比較） */
.bk-ba { position: relative; overflow: hidden; border-radius: 10px; --bk-ba-pos: 50%; user-select: none; -webkit-user-select: none; background: #111; }
.bk-ba > img, .bk-ba > canvas { display: block; width: 100%; height: auto; }
.bk-ba > .bk-ba-after { position: absolute; inset: 0; width: 100%; height: 100%; clip-path: inset(0 0 0 var(--bk-ba-pos)); }
.bk-ba-handle { position: absolute; top: 0; bottom: 0; left: var(--bk-ba-pos); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12), 0 0 12px rgba(0, 0, 0, .35); pointer-events: none; }
.bk-ba-handle::after { content: ''; position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l-6 6 6 6M15 6l6 6-6 6'/%3E%3C/svg%3E") center / 20px no-repeat; box-shadow: 0 2px 10px rgba(0, 0, 0, .3); transition: transform .42s cubic-bezier(.34, 1.56, .64, 1); }
.bk-ba.is-dragging .bk-ba-handle::after { transform: scale(1.18); transition-duration: .16s; }
.bk-ba:has(.bk-ba-range:focus-visible) .bk-ba-handle::after { outline: 3px solid var(--bk-primary); outline-offset: 3px; }
.bk-ba-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: ew-resize; -webkit-appearance: none; appearance: none; background: transparent; touch-action: pan-y; }
.bk-ba-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 44px; height: 100vh; }
.bk-ba-range::-moz-range-thumb { width: 44px; height: 100vh; border: 0; }
.bk-ba-label { position: absolute; top: 10px; padding: 3px 9px; border-radius: 4px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .04em; pointer-events: none; }
.bk-ba-label.is-before { left: 10px; }
.bk-ba-label.is-after { right: 10px; }
@media (prefers-reduced-motion: reduce) { .bk-ba-handle::after { transition: none; } }
