/* =============================================================
   DK Text Drawer — 文字编辑抽屉样式
   唯一依据：4.7/DK_Text_Drawer_Freeze_Spec_V1.md（V1.3）
   协议：4.7/DK_ARCHITECTURE_PROTOCOL.md
   只在 max-width: 768px 生效，桌面端完全不受影响。

   协议对齐：
   §4 状态驱动 —— 显隐一律 class / [data-curved] / aria-hidden / transform / opacity；
      半径行是唯一使用 display 的地方，且由 data 属性驱动（JS 内禁止 style.display）
   §5 渲染主权 —— 挂 #dkShell 内；bottom 复用 --dk-nav-h，抽屉停在四大金刚上方
   §7 性能   —— 位移只用 translate3d；will-change 由 JS 动画期动态管理

   与 Product / Templates 的关键差异（Freeze Spec §1/§11）：
   **无全屏 overlay** —— Text Drawer 是 context panel 不是 modal，
   画布必须保持可点（用户要能直接点下一段文字）。#dkShell 根节点是
   pointer-events:none（dk-shell.css L112），sheet 自身 auto，因此天然成立。

   视觉复用 Shell Token（--dk-primary 系），禁止新建第二套配色体系。
   ============================================================= */

@media (max-width: 768px) {

  /* ── 抽屉本体：底部导航上方停靠（对齐 .dk-pd-sheet 约定）。
     关闭态额外移出 nav-h + 24px 缓冲，确保完全离场不遮底部导航。 ── */
  .dk-td-sheet {
    position: absolute;
    bottom: var(--dk-nav-h);
    left: 0;
    right: 0;
    transform: translate3d(0, calc(100% + var(--dk-nav-h) + 24px), 0);
    opacity: 0;
    /* Product sheet 120 / Templates overlay 118 之上；互斥保证二者不同时出现 */
    z-index: 122;
    background: var(--dk-surface);
    border-radius: 24px 24px 0 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    max-height: 64dvh;
    overflow: hidden;
    pointer-events: none;
    box-shadow: 0 -8px 40px rgba(26, 26, 44, 0.16);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.22s ease;
    /* will-change 由 JS 动画期动态管理（协议 §8），静态不声明 */
  }
  .dk-td-sheet.dk-td-open {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    pointer-events: auto;
  }

  /* ── 手柄 ── */
  .dk-td-handle-row {
    display: flex;
    justify-content: center;
    padding: 12px 0 4px;
    flex-shrink: 0;
  }
  .dk-td-pill {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--dk-border);
  }

  /* ── Header ── */
  .dk-td-header {
    position: relative;
    padding: 2px 20px 10px;
    flex-shrink: 0;
  }
  .dk-td-kicker {
    display: block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.6px;
    color: var(--dk-primary);
  }
  .dk-td-title {
    margin-top: 2px;
    font-size: 19px;
    font-weight: 700;
    color: var(--dk-text-1);
    letter-spacing: 0.1px;
  }
  .dk-td-close {
    position: absolute;
    top: 0;
    right: 14px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--dk-primary-soft);
    color: var(--dk-text-2);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, color 0.2s, background 0.2s;
  }
  .dk-td-close:active {
    transform: scale(0.92);
    color: var(--dk-primary);
  }

  /* ── 内容区 ── */
  .dk-td-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    /* 底部安全区：色板/滑块不被 Home Indicator 压住（协议 §5） */
    padding: 0 20px calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .dk-td-section { margin-bottom: 14px; }
  .dk-td-section:last-child { margin-bottom: 0; }

  .dk-td-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--dk-text-2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
  }

  /* ── 文字内容 ── */
  #dkTextInput {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1.5px solid var(--dk-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    background: var(--dk-surface);
    color: var(--dk-text-1);
    outline: none;
    transition: border-color 0.15s;
  }
  #dkTextInput:focus { border-color: var(--dk-primary); }

  /* ── 字体下拉（选项由 Lumise 字体注册表生成，见 Freeze Spec §2） ── */
  #dkTextFont {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 30px 10px 12px;
    border: 1.5px solid var(--dk-border);
    border-radius: 10px;
    font-size: 14px;
    background-color: var(--dk-surface);
    color: var(--dk-text-1);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath fill='%238888AA' d='M6 7L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.15s;
  }
  #dkTextFont:focus { border-color: var(--dk-primary); }

  /* ── 颜色色块 ── */
  #dkTextColors {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  #dkTextColors li {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--dk-border);
    box-sizing: border-box;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  }
  #dkTextColors li:active { transform: scale(0.92); }
  #dkTextColors li.dk-td-color-active {
    border-color: var(--dk-surface);
    box-shadow: 0 0 0 2px var(--dk-primary), 0 2px 8px rgba(26, 26, 44, 0.18);
    transform: scale(1.06);
  }

  /* ── 弧形半径 ──
     Freeze Spec §5：这是全模块唯一允许的 display 用法，且由 data 属性驱动。
     JS 内禁止出现 style.display（协议 §4）。 */
  #dkTextSheet[data-curved="false"] #dkTextRadiusWrap { display: none; }

  #dkTextRadius {
    width: 100%;
    margin: 2px 0 0;
    accent-color: var(--dk-primary);
    cursor: pointer;
  }
  #dkTextRadiusVal {
    font-weight: 700;
    color: var(--dk-primary);
    margin-left: 4px;
  }

  /* ── 防御性隐藏：原生 Text Effects 工具项（承接旧 dk-text-sidebar 同款规则；
     移动端 top-tools 已被 Shell 隐藏，此条为双重保险） ── */
  #lumise-top-tools li[data-tool="text-effect"] { display: none !important; }
}
