/* ==========================================================================
   SIMIS · 跨浏览器兼容层 (Chrome / Edge / Safari)
   加载顺序：必须在主样式之后。

   覆盖的已知差异：
   1. Safari 15 以下不支持 :focus-visible —— 退回 :focus
   2. Safari 不支持 dvh —— 回退 vh
   3. Safari 17 以下 backdrop-filter 需要 -webkit- 前缀
   4. Safari 对 inset 简写的支持版本较新 —— 展开为 top/right/bottom/left
   5. Safari 不支持 text-wrap:balance —— 渐进增强，无需回退
   6. aspect-ratio 在旧 Safari 缺失 —— 用 padding-top 技巧兜底
   7. Edge(旧内核) 不支持 gap 于 flex —— 已在主样式用 margin 兜底
   8. Safari 表单控件 appearance 需要前缀
   9. Safari 的 position:sticky 在 body 上需配合 overflow 修正
   ========================================================================== */

/* ---- 1. 焦点可见性：旧 Safari 退回 :focus ---- */
a:focus, button:focus, input:focus, select:focus, textarea:focus, summary:focus {
  outline: 2px solid var(--red, #C1121F);
  outline-offset: 3px;
}
@supports selector(:focus-visible) {
  a:focus:not(:focus-visible),
  button:focus:not(:focus-visible),
  input:focus:not(:focus-visible),
  select:focus:not(:focus-visible),
  textarea:focus:not(:focus-visible),
  summary:focus:not(:focus-visible) {
    outline: none;
  }
  a:focus-visible,
  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  summary:focus-visible {
    outline: 2px solid var(--red, #C1121F);
    outline-offset: 3px;
  }
}

/* ---- 2. 视口高度单位：dvh 回退 vh ---- */
.primary-nav { max-height: calc(100vh - 76px); }
@supports (height: 100dvh) {
  .primary-nav { max-height: calc(100dvh - 76px); }
}

/* ---- 3. backdrop-filter：Safari 需要前缀 ---- */
.site-header {
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header { background: rgba(255, 255, 255, .98); }
}

/* ---- 4. inset 简写展开（Safari 14.1 以下不支持） ---- */
.hero-media, .hero-figure img, .hero::after, .page-hero .hero-media, .page-hero::after {
  top: 0; right: 0; bottom: 0; left: 0;
}

/* ---- 5. aspect-ratio 兜底：旧 Safari 用 padding-top 占位 ---- */
.prod-thumb { position: relative; }
.prod-thumb img { position: absolute; inset: 0; }
@supports not (aspect-ratio: 4 / 3) {
  .prod-thumb { height: 0; padding-top: 75%; }
  .cert-grid figure { height: 0; padding-top: 133.33%; }
  .cert-grid figure img { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
  .step figure { height: 0; padding-top: 66.67%; }
  .step figure img { position: absolute; inset: 0; }
  .cat figure img { height: auto; }
  .about-figure img { height: auto; }
}
.cert-grid figure, .step figure { position: relative; }

/* ---- 6. 表单控件 appearance 前缀 ---- */
input, select, textarea, button {
  -webkit-appearance: none;
  appearance: none;
}
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #5C6875 50%),
                    linear-gradient(135deg, #5C6875 50%, transparent 50%);
  background-position: calc(100% - 19px) calc(50% + 2px), calc(100% - 13px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.4rem;
}
input[type="text"], input[type="email"], input[type="tel"] {
  -webkit-appearance: none;
  appearance: none;
}

/* ---- 7. 滚动容器：避免 Safari 嵌套滚动抖动 ---- */
.table-scroll {
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  max-width: 100%;
}

/* ---- 8. sticky 头部：Safari 需避免祖先 overflow 裁剪 ---- */
.site-header { -webkit-transform: translateZ(0); }
@supports (-webkit-touch-callout: none) {
  /* iOS Safari 专属：防止毛玻璃在滚动时失效 */
  .site-header { will-change: backdrop-filter; }
}

/* ---- 9. 图片缩放：Safari 下 transform 需配合 will-change ---- */
.prod-thumb img, .cert-grid figure img {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* ---- 10. 长词与 URL 换行：避免窄屏溢出 ---- */
p, li, td, th, h1, h2, h3, h4, summary, .mono, code {
  overflow-wrap: break-word;
  word-break: normal;
}

/* ---- 11. details/summary：Safari 标记差异 ---- */
summary { display: list-item; }
summary::-webkit-details-marker { display: none; }
summary::marker { content: ""; }
details[open] summary { list-style: none; }

/* ---- 12. 打印样式：隐藏交互元素 ---- */
@media print {
  .nav-toggle, .prod-arrow, .skip { display: none !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .75em; color: #555; }
}
