/* ============================================================
   INTERACTIVE_CANVAS archetype — 共享 composition 层（Phase 20A3C）

   消费者：tools/signature-pad/ 以及它的 8 份 locale 派生页。

   ⚠️ 这一层**只做 composition**：不定义 token、按钮基样式、Product Page 外壳
      或 header 基样式。视觉值一律来自
      tokens.css · yq-ui.css · workspace-ui.css · product-page.css · tool-landing.css。
   ⚠️ 画布的**正确性**（笔迹模型、真实 DPR、等比 contain 重放、primary pointer）
      住在页面脚本里，由 g88 守。这里只决定画布**多大、放在哪**，
      任何尺寸都不会让签名变形 —— 那是 20A3B 已经保证的事。

   archetype 解剖（GPT 20A3C 的结构结论）：
     Tool Hero        .pp-hero           H1 · 一句说明
     Workspace        .yqw-surface.ic-workspace   ← 唯一的主工作容器（不套 card）
       Tool Bar       .ic-toolbar        Brush · Color（只放"怎么画"）
       Canvas Stage   .ic-stage          ← 页面主体
       Action Bar     .ic-actions        Export PNG · Copy · Clear（"画完之后"）
       Helper         .ic-helper         tip · 信任行
   上下流，不是左右两栏：签名是一块连续书写面，控件都服务于它。
   ============================================================ */

/* ── Shell：流式，服从 product-page.css 的页面 gutter 与 1200 上限 ──
   宽度 authority = --pp-max（== --yqw-max-width 1200），不另起第三套。 */
html.is-standalone body.ic-page { display: block; padding: 0; overflow-y: auto; }
.ic-shell {
  width: 100%;
  max-width: calc(var(--pp-max) + 2 * var(--pp-inline));
  margin: 0 auto;
  padding-inline: var(--pp-inline);
  padding-bottom: 48px;
}
html.is-standalone .ic-shell { margin: 0 auto; padding-left: var(--pp-inline); padding-right: var(--pp-inline); }
.ic-shell .pp-hero { padding-top: 40px; padding-bottom: 24px; }
@media (max-width: 640px) { .ic-shell .pp-hero { padding-top: 28px; padding-bottom: 18px; } }

/* ── Workspace：一层白色 surface，里面只是分区 ── */
.ic-workspace { gap: 16px; }
@media (max-width: 640px) { .ic-workspace { padding: 18px; gap: 14px; } }

/* ── Tool Bar：quiet strip，纯白、不画框 —— 画布才是主体 ── */
.ic-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  column-gap: 32px; row-gap: 14px;
}
.ic-group { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ic-group--color { margin-left: auto; }
.ic-label {
  font-size: var(--yqw-t3-size); font-weight: var(--yqw-t3-weight);
  color: var(--yq-text-2); white-space: nowrap;
}

/* Brush：细中性轨道 + primary 蓝拇指（范围 / 步长 / 默认值都没动） */
.ic-range {
  -webkit-appearance: none; appearance: none;
  width: 200px; height: 20px; background: transparent; cursor: pointer; margin: 0;
}
.ic-range::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: var(--yq-border); }
.ic-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--yq-primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--yq-primary);
}
.ic-range::-moz-range-track { height: 4px; border-radius: 999px; background: var(--yq-border); }
.ic-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--yq-primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--yq-primary);
}
/* 当前值：轻量 value pill，不是漂浮的裸数字。等宽数字 + 固定槽，1→16 不推动布局 */
.ic-value {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; height: 28px; padding: 0 10px;
  border-radius: 999px; background: var(--yq-bg-quiet);
  font-size: 13px; font-weight: 500; color: var(--yq-text-1);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Color：Phase 20 的圆形色板语汇（与 QRCode 同一套选中语言），
   直径 30 —— 签名板是直接操作工具，比 QRCode 的 20 更好点 */
.ic-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 4px; margin: -4px; }
.ic-swatch {
  position: relative; flex: none;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--sw-color);
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, .14);
  transition: box-shadow var(--yq-dur), transform .1s;
}
.ic-swatch:hover { box-shadow: inset 0 0 0 1px rgba(17, 24, 39, .14), 0 0 0 2px var(--yq-bg-page), 0 0 0 4px var(--yq-border-strong); }
.ic-swatch:active { transform: scale(.94); }
/* 选中：蓝环 + 中性留白 + 居中的勾（勾色由 JS 按对比度给 --sw-check） */
.ic-swatch[aria-pressed="true"],
.ic-custom.is-selected .ic-custom-dot {
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, .14), 0 0 0 2px var(--yq-bg-page), 0 0 0 4px var(--yq-primary);
}
.ic-swatch[aria-pressed="true"]::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 7px; height: 12px; margin: -8px 0 0 -3.5px;
  border: solid var(--sw-check, #fff); border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.ic-color-row { display: flex; align-items: center; gap: 10px; }

/* 自定义颜色：真实的 <input type=color id=colorPicker> 仍然在，
   只是铺满一个圆形按钮、透明 —— 点它照样打开**原生**取色器，没有自研弹层。
   外圈的彩虹环说明"这里能挑任意颜色"，中心填当前自定义色。 */
.ic-custom {
  position: relative; flex: none; width: 30px; height: 30px; border-radius: 50%;
  padding: 3px; background: conic-gradient(#e03131, #f59f00, #2f9e44, #1971c2, #7048e8, #e03131);
  cursor: pointer;
}
.ic-custom-dot {
  display: block; width: 100%; height: 100%; border-radius: 50%;
  background: var(--sw-color, #000); border: 2px solid #fff;
}
.ic-custom-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; margin: 0; cursor: pointer;
}
/* 键盘焦点落在透明 input 上，焦点环画在它的圆形外壳上 */
.ic-custom:has(.ic-custom-input:focus-visible) { outline: 2px solid var(--yq-primary); outline-offset: 3px; }
.ic-custom-input:focus-visible { outline: none; }

/* ⚠️ 这段必须写在 .ic-custom 基础规则**之后**：特异度相同，先写的会被 30px 盖掉。 */
/* 窄屏：工具条纵向。Brush 一行（滑杆吃满剩余宽）；Color 的标签单独一行，
   8 个预设 + 自定义色排成**一行**：28 × 9 + 6 × 8 = 300 ≤ 390 下的 312 可用宽。
   直径 28 仍在 §11.1 的 28–32 区间内。 */
@media (max-width: 640px) {
  /* ⚠️ nowrap：纵向 + wrap 时，stretch 按"行"的交叉尺寸拉伸 —— 那一行取的是
     最宽内容（es「Tamaño del pincel」一行 317）而不是容器宽 312，整条工具条被撑出 5px */
  .ic-toolbar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; row-gap: 16px; }
  .ic-group--brush .ic-range { flex: 1 1 auto; width: auto; min-width: 0; }
  .ic-group--color { margin-left: 0; flex-direction: column; align-items: flex-start; gap: 10px; }
  .ic-color-row, .ic-swatches { gap: 6px; }
  .ic-swatch, .ic-custom { width: 28px; height: 28px; }
}


/* ── Canvas Stage：页面主体 ──
   白纸、1px 中性边、卡片圆角；没有灰底 / 网格 / 棋盘格。
   高度**不再绑 100vh**：浏览器工具栏或窗口高度变化不会让画布忽高忽低。 */
.ic-stage {
  --ic-canvas-h: 420px;
  border: 1px solid var(--yq-border);
  border-radius: var(--yq-r-card);
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .04);
}
.ic-stage canvas {
  display: block; width: 100%; height: var(--ic-canvas-h);
  background: #fff; cursor: crosshair; touch-action: none;
}
@media (max-width: 1199px) { .ic-stage { --ic-canvas-h: 380px; } }
@media (max-width: 640px) { .ic-stage { --ic-canvas-h: 300px; } }

/* ── Action Bar：三个按钮同高同宽同圆角，主次只靠颜色 ──
   宽度 168 = 平台标准字段宽（--yqw-field-w）；9 locale 标签实测装得下（g89 守）。 */
.ic-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.ic-actions .yqw-btn {
  width: var(--yqw-field-w); height: var(--yqw-h-primary); padding: 0 14px;
  font-size: var(--yqw-t2-size); font-weight: 600; border-radius: var(--yq-r-ctl);
}
/* 空态 Clear：中性禁用色，不是半透明的淡蓝 */
.ic-actions .yqw-btn:disabled {
  opacity: 1; background: var(--yq-bg-quiet); border-color: var(--yq-border); color: var(--yq-text-3);
}
@media (max-width: 640px) {
  .ic-actions { flex-direction: column; }
  .ic-actions .yqw-btn { width: 100%; }
}

/* ── Helper：tip · 信任行，轻量 ── */
.ic-helper { display: flex; flex-direction: column; gap: 4px; }
.ic-helper .ic-tip, .ic-helper .ic-trust {
  margin: 0; padding: 0; text-align: left; font-size: 12.5px; line-height: 1.6; color: var(--yq-text-3);
}

/* ── Header 焦点可见（本 archetype 作用域）──
   共享 header 的默认焦点只有一圈 12% 透明度的淡蓝，几乎看不见。 */
body.ic-page .tl-nav:focus-visible,
body.ic-page .tl-locale-trigger:focus-visible { outline: 2px solid var(--yq-primary); outline-offset: 2px; }

/* ============================================================
   G1 warm gold「All tools」（与 FILE_PROCESSOR / FORM_UTILITY 逐条相同，
   只是作用域换成 body.ic-page）。
   ⚠️ GLOBAL_HEADER_GOLD_ROLLOUT 仍是 BACKLOG：只有挂了 .ic-page 的页面变金色。
   ⚠️ 选择器与 token **都**限定在 body.ic-page 上（20A1B 实测过：只放开选择器，
      var() 在别的页上求值失败、背景直接变成 none —— 两半必须一起守）。
   #F2D57D → #C7A344，ink #2A2205，20A1B 实测三点都过 AA。
   ============================================================ */
body.ic-page {
  --ic-gold-top: #F2D57D;
  --ic-gold-mid: #E8C86C;
  --ic-gold-bot: #C7A344;
  --ic-gold-edge: #B8902F;
  --ic-gold-ink: #2A2205;
}
body.ic-page .tl-nav {
  display: inline-flex; align-items: center;
  height: 32px; padding: 0 14px;
  background: linear-gradient(180deg, var(--ic-gold-top) 0%, var(--ic-gold-bot) 100%);
  border: 1px solid var(--ic-gold-edge);
  border-radius: var(--yq-r-ctl);
  color: var(--ic-gold-ink);
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
body.ic-page .tl-nav:hover {
  background: linear-gradient(180deg, var(--ic-gold-mid) 0%, #BE9835 100%);
  color: #221B04;
}
body.ic-page .tl-actions { gap: 10px; }
body.ic-page .tl-brand { cursor: default; user-select: none; }
@media (max-width: 640px) {
  body.ic-page .tl-nav { padding: 0 12px; }
  body.ic-page .tl-actions { gap: 8px; }
}
