/* ==========================================================================
   FUYAO PACKAGING · demos/_shared/base.css
   --------------------------------------------------------------------------
   三套 Demo 共用的结构基线。**本文件不含任何配色值** ——
   所有颜色、字体族、字号、间距、时长都来自 tokens-a/b/c.css。

   引入顺序（顺序不能变）：
     1. ../_shared/tokens-x.css    ← 变量（决定这套是 A / B / C）
     2. ../_shared/base.css        ← 本文件：reset + 排版基线
     3. ./styles.css               ← 页面自己的组件

   本文件负责：
     · modern-normalize 精简版 reset
     · 排版基线（body 字号行高 / h1–h6 无 margin / 段落与列表）
     · 链接、按钮、图片、表单的**去样式化**基线（不是样式，是"清空"）
     · 焦点环与可访问性原语（sr-only / skip-link）
     · prefers-reduced-motion 全局降级
   本文件不负责：
     · 任何颜色、背景、边框色、阴影
     · 任何组件外观（按钮长什么样由各套 styles.css 决定）
   ========================================================================== */

/* ==========================================================================
   1. Reset（modern-normalize 精简版）
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* 移动端 Safari 横屏时禁止自动放大字号 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* 平滑滚动由各套自行决定是否保留（B 关掉，A/C 保留） */
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  /* 字号与字体来自 token；这里只给"基线"的兜底 */
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: var(--fs-body, 1rem);
  font-weight: var(--fw-body, 400);
  line-height: var(--lh-body, 1.6);
  letter-spacing: var(--tracking-body, 0);
  /* 关闭 iOS 上的字体合成加粗，避免浅色字重被系统加粗 */
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* 长单词 / SKU 串不撑破容器 */
  overflow-wrap: break-word;
}

/* 标题、段落、列表、图表元素的 margin 一律清零 ——
   间距由各套的布局容器用 --space-* 显式给，不依赖浏览器默认值。 */
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd,
ol,
ul,
pre,
fieldset,
legend {
  margin: 0;
}

ol[role="list"],
ul[role="list"] {
  list-style: none;
  padding: 0;
}

hr {
  box-sizing: content-box;
  height: 0;
  overflow: visible;
  border: 0;
  border-top: 1px solid currentColor;
  opacity: 0.12;
}

/* 表格：collapsed，宽度 100%，数字等宽（B 的主武器） */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

th {
  text-align: left;
  font-weight: inherit;
}

td,
th {
  padding: 0;
  vertical-align: baseline;
}

/* 代码 / 数字：等宽族 + 表格数字对齐 */
code,
kbd,
samp,
pre {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.9375em;
}

pre {
  overflow: auto;
  white-space: pre;
}

/* 上下标不撑行高 */
sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

/* 隐藏但保留在无障碍树之外的元素（模板用） */
[hidden] {
  display: none !important;
}

/* ==========================================================================
   2. 排版基线
   --------------------------------------------------------------------------
   只给"结构"（字体族归位、行高、字距、不掉行），不给字号级别的
   具体数值 —— 那些由各套 styles.css 用 --fs-* 组合出来。
   ========================================================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display, var(--font-body, system-ui, sans-serif));
  font-weight: var(--fw-display, 700);
  line-height: var(--lh-tight, 1.2);
  letter-spacing: var(--tracking-display, -0.01em);
  /* 标题不断行断在最后一个词：靠 text-wrap 平衡，
     不支持的浏览器自然退化为普通换行，不影响布局 */
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-h1, 2rem);
  line-height: var(--lh-display, 1.05);
}

h2 {
  font-size: var(--fs-h2, 1.5rem);
}

h3 {
  font-size: var(--fs-h3, 1.25rem);
}

h4 {
  font-size: var(--fs-body, 1rem);
  font-weight: var(--fw-strong, 600);
}

h5,
h6 {
  font-size: var(--fs-small, 0.875rem);
  font-weight: var(--fw-strong, 600);
}

p {
  /* 连续段落的默认间距，页面可覆盖 */
  max-width: var(--measure, 72ch);
}

p + p {
  margin-top: var(--space-md, 1rem);
}

/* 引言 / 图注 / 小字：只归位字体族，不给颜色 */
figcaption,
small,
figcaption cite {
  font-size: var(--fs-small, 0.875rem);
  line-height: var(--lh-small, 1.5);
}

strong,
b {
  font-weight: var(--fw-strong, 600);
}

/* 数字排版：等宽数字用于所有数值型内容（价格 / 容量 / 计数） */
.u-tnum,
[data-tnum] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* 等宽微标签（A 的图注序号、B 的表头、C 的读数） */
.u-mono {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
}

/* 小标 / Eyebrow —— 三套的设计文档都要求用**正文字体**的 semibold + 宽字距，
   不是等宽（等宽只出现在图注、型号、读数上）。 */
.u-eyebrow {
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: var(--fs-eyebrow, 0.75rem);
  font-weight: var(--fw-strong, 600);
  letter-spacing: var(--tracking-eyebrow, 0.12em);
  text-transform: uppercase;
  line-height: 1.3;
}

/* 等宽小标（图注编号 / 表头）：A 的 `01 — Dropper bottle, 30ml` 用这个 */
.u-mono-label {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: var(--fs-micro, 0.75rem);
  font-weight: 400;
  letter-spacing: var(--tracking-mono, 0.1em);
  text-transform: uppercase;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.u-uppercase {
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow, 0.08em);
}

.u-nowrap {
  white-space: nowrap;
}

.u-balance {
  text-wrap: balance;
}

.u-pretty {
  text-wrap: pretty;
}

/* ==========================================================================
   3. 链接去样式化
   --------------------------------------------------------------------------
   只去掉浏览器默认的下划线 + 颜色，保留可识别性靠各套自己加。
   注意：不做 color: inherit 之外的任何处理 —— 颜色必须来自 token。
   ========================================================================== */

a {
  color: inherit;
  text-decoration: none;
  /* 触控目标最小高度由各套的组件保证，这里不强制 */
}

/* 正文内联链接：保留下划线，确保不靠颜色也能识别（WCAG 1.4.1） */
.u-link-inline,
.prose a {
  text-decoration: underline;
  text-decoration-thickness: var(--underline-weight, 1px);
  text-underline-offset: 0.22em;
}

/* ==========================================================================
   4. 按钮去样式化
   --------------------------------------------------------------------------
   只清空浏览器默认外观，不定义任何视觉。
   各套的 .btn 在 styles.css 里从零画。
   ========================================================================== */

button,
[type="button"],
[type="submit"],
[type="reset"] {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

/* 触控目标：所有可点元素的最低尺寸（设计系统 §10：≥44×44） */
.u-tap {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   5. 图片与媒体去样式化
   ========================================================================== */

img,
picture,
video,
canvas,
svg,
iframe {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
  border-style: none;
}

/* 图片未加载完时的占位：用当前文字色做低透明块，不引入新颜色 */
img {
  background-color: transparent;
}

/* 图片容器：比例盒 + cover（各套指定 --ratio） */
.u-media {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--ratio, 4 / 5);
}

.u-media > img,
.u-media > picture > img,
.u-media > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos, 50% 50%);
}

/* 产品图的三种标准比例（设计系统 §6 / diff doc） */
.u-ratio-portrait {
  --ratio: 4 / 5;
}

.u-ratio-9x16 {
  --ratio: 9 / 16;
}

.u-ratio-4x3 {
  --ratio: 4 / 3;
}

.u-ratio-1x1 {
  --ratio: 1 / 1;
}

.u-ratio-16x9 {
  --ratio: 16 / 9;
}

/* ==========================================================================
   6. 表单去样式化
   --------------------------------------------------------------------------
   清空 appearance，去掉浏览器默认边框与底色，但**保留焦点可见性**。
   视觉（下划线 / 方框 / 发光边）由各套 styles.css 决定。
   ========================================================================== */

input,
textarea,
select,
button {
  font: inherit;
  color: inherit;
  margin: 0;
  letter-spacing: inherit;
}

input,
textarea,
select {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  width: 100%;
}

/* select 需要保留一个小箭头位，但不用浏览器默认的（各套自己画） */
select {
  cursor: pointer;
}

/* textarea 只允许纵向拉伸 */
textarea {
  resize: vertical;
  min-height: 6em;
}

/* 数字输入框去掉 spinner（B 的数量输入不需要） */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* placeholder 只用透明度区分，不写死颜色（否则会串味） */
::placeholder {
  color: inherit;
  opacity: 0.45;
}

/* 复选框 / 单选框保留原生可识别形态，各套只改尺寸与强调色 */
input[type="checkbox"],
input[type="radio"] {
  appearance: auto;
  -webkit-appearance: auto;
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="file"] {
  cursor: pointer;
}

fieldset {
  border: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
}

label {
  display: inline-block;
}

/* 表单错误：颜色 + 文字 + 图标三重编码（设计系统 §10），
   这里只提供结构，颜色由各套给 */
.field-error {
  display: flex;
  gap: var(--space-xs, 0.25rem);
  align-items: baseline;
}

/* ==========================================================================
   7. 焦点与可访问性
   --------------------------------------------------------------------------
   设计系统 §10：不允许 outline: none。
   用 currentColor 保证不引入配色，任何一套都能直接工作。
   ========================================================================== */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* 鼠标点击不留焦点环，键盘仍然有 */
:focus:not(:focus-visible) {
  outline: none;
}

/* 屏幕阅读器专用 */
.sr-only,
.u-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 跳转链接：默认藏在视口外，聚焦时出现 */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-sm, 0.5rem);
  z-index: 999;
  padding: 12px 20px;
  background: var(--bg-elev, transparent);
  color: var(--ink, currentColor);
  border: 1px solid var(--border, currentColor);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: var(--fs-small, 0.875rem);
}

.skip-link:focus-visible {
  top: var(--space-sm, 0.5rem);
}

/* 锁滚动（抽屉 / 全屏菜单打开时加到 <html> 上） */
.u-no-scroll,
html.is-locked {
  overflow: hidden;
}

/* 不可交互状态 */
.u-disabled,
[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

/* ==========================================================================
   8. 布局基元（无配色，只有几何）
   ========================================================================== */

.u-container {
  width: 100%;
  max-width: var(--container-max, 1200px);
  margin-inline: auto;
  padding-inline: var(--container-pad, 24px);
}

/* 全宽但左右仍留边距（C 的全视口区块用） */
.u-bleed {
  width: 100%;
  padding-inline: var(--container-pad, 24px);
}

/* 区块垂直节奏：唯一来源是 --section-gap，各套数值不同 */
.u-section {
  padding-block: var(--section-gap, 96px);
}

.u-stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--space-md, 1rem));
}

.u-row {
  display: flex;
  align-items: center;
  gap: var(--row-gap, var(--space-md, 1rem));
}

/* 常用网格：列数由内联样式或修饰类给 */
.u-grid {
  display: grid;
  gap: var(--grid-gap, var(--space-md, 1rem));
}

/* ==========================================================================
   9. 动效基元 —— 交给 motion.js 驱动的元素初始态
   --------------------------------------------------------------------------
   这些类只声明"初始不可见"，具体过渡在 motion.js 里通过 Web Animations
   API 播放。之所以用 CSS 类而不是内联样式，是为了在 JS 失败时能优雅降级
   （见下方 :where 的 no-js 兜底）。
   ========================================================================== */

/* 需要 JS 才能显现的元素：默认可见，加了 .js 之后才隐藏。
   这样 JS 挂掉/被拦截时内容不会永久消失。 */
:root:not(.js) [data-reveal] {
  opacity: 1 !important;
  transform: none !important;
  clip-path: none !important;
}

[data-reveal] {
  /* 初始态由 JS 在首帧前设置；这里只给 will-change 提示 */
  will-change: opacity, transform;
}

@media (prefers-reduced-motion: reduce) {
  /* 全局降级：所有过渡与动画立即到终态（设计系统 §9：0.01ms） */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  html {
    scroll-behavior: auto !important;
  }

  /* 视差与磁吸在减少动效时必须归零，否则会留下偏移 */
  [data-parallax],
  [data-magnetic] {
    transform: none !important;
  }
}

/* ==========================================================================
   10. 打印（B 的规格表要能打印）
   ========================================================================== */

@media print {
  .u-print-hide,
  [data-print="hide"] {
    display: none !important;
  }

  html,
  body {
    /* 打印用系统色，不引入任何品牌色（本文件不含配色） */
    background: Canvas;
    color: CanvasText;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.875em;
  }
}
