/* ============================================================
   查字典：顶栏入口 + 查询弹窗 + 全屏 iframe 结果弹窗
   全部走主题令牌，深色模式自动跟随；不重定义任何全局组件。
   ============================================================ */

/* 顶栏入口：外观与 .theme-toggle 一致，但刻意不复用它的 class。
   theme.js 会给所有 .theme-toggle 改 title/aria-label 并委托 click 换肤，
   挂上去会让「查字典」变成「切换到深色」。 */
.dict-entry {
  position: relative;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); cursor: pointer;
  display: inline-grid; place-items: center; padding: 0; flex: none;
  transition: .16s;
}
.dict-entry:hover { border-color: var(--line-strong); color: var(--brand); transform: translateY(-1px); }
.dict-entry svg { width: 18px; height: 18px; display: block; }

body.dict-open { overflow: hidden; }

.dict-layer {
  position: fixed; inset: 0; z-index: 320;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: var(--mask); backdrop-filter: blur(3px);
}
.dict-layer[hidden] { display: none !important; }

/* -------------------------------------------------- 第一级：查询弹窗 */
.dict-search {
  width: min(440px, 100%);
  background: var(--card); border-radius: 18px;
  box-shadow: var(--shadow-lg); animation: dict-pop .2s ease;
}
@keyframes dict-pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.dict-search-head {
  display: flex; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--line); font-size: 16px; color: var(--ink);
}
.dict-search-head b { font-weight: 700; }
.dict-x {
  margin-left: auto; width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--sub); font-size: 21px; line-height: 1; cursor: pointer;
}
.dict-x:hover { background: var(--line-2); color: var(--ink); }

.dict-search-body { padding: 20px; }
.dict-search-body label {
  display: block; margin-bottom: 9px; font-size: 13px; color: var(--sub);
}
.dict-input-row { display: flex; gap: 10px; }
.dict-input-row input {
  flex: 1; min-width: 0; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--card); color: var(--ink); font-size: 15px; outline: none;
}
.dict-input-row input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.dict-input-row input.bad { border-color: var(--red); animation: dict-shake .3s ease; }
@keyframes dict-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.dict-hint { margin: 12px 0 0; font-size: 12px; color: var(--sub-2); line-height: 1.6; }
.dict-hint.warn { color: var(--red); }

/* -------------------------------------------------- 第二级：全屏结果弹窗 */
.dict-panel {
  /* 原站是「主内容 + 右侧『同课生字』推荐栏」双栏。推荐栏不需要展示，
     所以弹窗只留主内容宽度；iframe 再向右多撑 390px，把推荐栏裁在可视区外。
     960px 是实机调试值：再宽一点就会露出原站右栏那一段页面背景色。 */
  width: min(960px, 100%); height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: dict-pop .22s ease;
}
.dict-panel-head {
  display: flex; align-items: center; gap: 9px; flex: none;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--card-2);
}
.dict-panel-title { font-size: 15px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.dict-panel-title b { color: var(--brand); }
.dict-spacer { flex: 1; }
.dict-tool {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); color: var(--ink-2);
  font-size: 13px; line-height: 1.4; text-decoration: none;
  cursor: pointer; white-space: nowrap;
}
.dict-tool:hover { border-color: var(--line-strong); color: var(--brand); }

/* iframe 上移 TOP_CUT 把原站页头推出可视区；底部留 FOOT_H 给来源提示条，
   提示条同时盖住原站页尾。裁切由 CSS 固定，页面里不提供「完整 / 简洁」切换。 */
.dict-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #fff; }
.dict-frame {
  /* iframe 比舞台宽 390px：原站照旧按双栏渲染，右侧「同课生字」推荐栏
     被 .dict-stage 的 overflow:hidden 裁掉。用相对增量而不是固定宽度，
     窗口变小时主内容仍是「舞台宽 - 侧栏宽」，不会被连带裁掉。
     注意 iframe 是替换元素，不能靠 left+right+width:auto 拉伸（会退化成
     固有 300px），必须显式写 calc(100% + 390px)。
     top:-115px 把原站页头连同顶部的页面背景色一起推出可视区（实机调试值）；
     height 补偿 = 115 - 46，使 iframe 底边始终落在「舞台底 - 46px」，
     正好接住底部来源提示条，不会在提示条上方露出一条空白。 */
  position: absolute; left: 0; top: -115px;
  width: calc(100% + 390px);
  height: calc(100% + 69px); border: 0; background: #fff; display: block;
  /* 窄屏（舞台 < 960px）时 dict.js 会给 iframe 固定 1350px 的 PC 视口并
     transform: scale(s)，让整页等比缩小到舞台宽度，避免百度页面按固定宽
     度居中后被左右裁切。缩放原点必须是左上角，否则会整体偏移。
     s=1（PC）时 JS 不改任何内联样式，本条规则不产生影响。 */
  transform-origin: 0 0;
}
/* 只盖住 iframe 区域，底部 46px 永久留给来源提示条；白底与 iframe 内容一致 */
.dict-loading {
  position: absolute; inset: 0 0 46px 0; display: grid; place-items: center;
  background: #fff; color: #6b7a90; font-size: 14px;
  pointer-events: none;
}
.dict-loading[hidden] { display: none; }
.dict-source {
  position: absolute; left: 0; right: 0; bottom: 0; height: 46px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 16px; border-top: 1px solid var(--line);
  background: var(--card-2); color: var(--sub); font-size: 12.5px;
  text-align: center;
}
/* 导航守卫的提示窗口：带标题的卡片式小窗口，舞台正中，5 秒后收起。
   纯展示、pointer-events:none、不做覆盖层、不加 sandbox，不影响 iframe 内
   的选中 / 滚动 / 复制（v1.89 那套拦截层被否决就是这个原因）。
   宽度由「一行正文」的 max-content 决定，不设 max-width —— 否则长文案
   会被压成溢出；极窄屏由 dict.js 的 fitGuardTip() 整体等比缩放兜底。
   刻意不加淡入动画：一来 dict-pop 的 to 帧带 transform:none 会覆盖居中变换，
   二来某些环境（如无头虚拟时间）动画停在第一帧会让窗口整块透明。

   固定配色（v1.99）：iframe 里的查询结果页始终是浅色系，不随本站深浅色
   模式变化，所以窗口也不跟随主题令牌，全部写死：边框 #2C2C2C、
   背景 #FEEEBC、标题 #CA0000、正文 #2C2C2C、阴影固定。任何皮肤 / 模式下
   外观都一致。v1.98 那套 --ink / --card 反色已废弃。
   窗口宽度由「一行正文」的 max-content 决定；正文左右各加 25px padding，
   即整窗比 v1.98 宽 50px，所有窄屏断点自动生效，不用逐个改 padding。 */
.dict-guard-tip {
  position: absolute; left: 50%; top: 50%; z-index: 3;
  transform: translate(-50%, -50%) scale(var(--dict-tip-scale, 1));
  width: max-content;
  padding: 13px 18px 14px; border-radius: 14px;
  border: 2px solid #2C2C2C;
  background: #FFFBE6; color: #222222;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  pointer-events: none;
}
.dict-guard-tip[hidden] { display: none; }
.dict-guard-tip-title {
  text-align: left;             /* 标题栏靠左；正文仍居中 */
  padding-bottom: 9px; margin-bottom: 10px;
  border-bottom: 1px solid rgba(44, 44, 44, .28);
  font-size: 15px; font-weight: 700; color: #CA0000;
  letter-spacing: .5px; white-space: nowrap;
}
.dict-guard-tip-title::before {
  content: ''; display: inline-block; width: 4px; height: 14px;
  margin-right: 7px; border-radius: 2px;
  background: #CA0000;
  vertical-align: -2px;
}
.dict-guard-tip-body {
  height: 50px;                 /* 文本区固定高度 */
  padding: 0 25px;              /* 左右各 25px => 窗口整体 +50px */
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1.5; color: #2C2C2C;
  white-space: nowrap;          /* 硬性要求：正文一行显示、不换行 */
}
.dict-guard-tip-body strong{ color:#CA0000; }

@media (max-width: 640px) {
  .dict-layer { padding: 0; }
  .dict-panel { width: 100%; height: 100%; border-radius: 0; }
  .dict-panel-head { padding: 9px 11px; gap: 6px; }
  .dict-panel-title { font-size: 13.5px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
  .dict-tool { padding: 5px 8px; font-size: 12px; }
  .dict-search { width: calc(100% - 32px); }
  .dict-source { font-size: 11.5px; padding: 0 10px; }
  /* 不要覆盖 top / transform：提示窗口要保持在舞台正中。逐级缩字号 +
     收 padding，保证一行正文在窄屏不被 .dict-stage 的 overflow:hidden 裁掉。 */
  .dict-guard-tip { padding: 12px 12px 13px; border-radius: 12px; }
  .dict-guard-tip-title { font-size: 14px; padding-bottom: 7px; margin-bottom: 8px; }
  .dict-guard-tip-body { font-size: 11px; }
}
@media (max-width: 420px) {
  .dict-guard-tip { padding: 10px 9px 11px; }
  .dict-guard-tip-body { font-size: 10px; }
}
@media (max-width: 360px) {
  .dict-guard-tip { padding: 9px 8px 10px; }
  .dict-guard-tip-title { font-size: 13px; }
  .dict-guard-tip-body { font-size: 9px; }
}
