/**
 * YOS 资料站 v9 · Common CSS
 * @layer 六层架构: reset / base / layout / typography / components / utilities
 * 
 * 合约来源: 2026-08-31-YOS-Promo-v9-Contracts.md §2
 * 手机优先 · mobile-first · 320-430px 默认
 */

/* ═══════════════════════════════════════════════════════════════
 * LAYER 1: RESET · 浏览器默认样式清除
 * 不引 normalize.css CDN（依赖外站，离线会崩）
 * ═══════════════════════════════════════════════════════════════ */
@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
  }
  
  body {
    min-height: 100vh;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
  }
  
  input, button, textarea, select {
    font: inherit;
    color: inherit;
  }
  
  button {
    cursor: pointer;
    border: none;
    background: none;
  }
  
  a {
    color: inherit;
    text-decoration: none;
  }
  
  ul, ol {
    list-style: none;
  }
  
  table {
    border-collapse: collapse;
  }
  
  /* 移除 iOS 输入框圆角 */
  input, textarea {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
 * LAYER 2: BASE · 元素级默认样式
 * body 背景 = depth-1 · 文字 = foam
 * ═══════════════════════════════════════════════════════════════ */
@layer base {
  body {
    background: var(--depth-1);
    color: var(--foam);
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    padding-top: 0;
    padding-bottom: var(--safe-bottom);
    overflow-x: hidden;
  }
  
  /* 标题默认 */
  h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--foam);
  }
  
  h1 { font-size: 28px; }
  h2 { font-size: 22px; }
  h3 { font-size: 18px; }
  h4 { font-size: 16px; }
  
  p {
    margin-bottom: var(--g-md);
    color: var(--foam-mute);
  }
  
  /* 链接 */
  a {
    transition: color var(--dur-fast) var(--ease-state);
  }
  
  a:hover {
    color: var(--gold);
  }
  
  /* 按钮基础 */
  button {
    transition: all var(--dur-fast) var(--ease-state);
  }
  
  button:active {
    transform: scale(var(--press-scale));
  }
  
  /* 选中文字 */
  ::selection {
    background: var(--gold);
    color: var(--depth-1);
  }
  
  /* 滚动条 */
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  
  ::-webkit-scrollbar-track {
    background: var(--depth-2);
  }
  
  ::-webkit-scrollbar-thumb {
    background: var(--gold-deep);
    border-radius: 3px;
  }
}

/* ═══════════════════════════════════════════════════════════════
 * LAYER 3: LAYOUT · 布局容器
 * mobile-first · 默认手机样式 · 768px 平板 · 1280px 电脑
 * ═══════════════════════════════════════════════════════════════ */
@layer layout {
  /* 颗粒层 · 全局氛围 */
  .v9-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  }
  
  /* 海图双层网格底 */
  .v9-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: 
      linear-gradient(rgba(232, 180, 90, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(232, 180, 90, 0.03) 1px, transparent 1px),
      linear-gradient(rgba(232, 180, 90, 0.06) 1px, transparent 1px),
      linear-gradient(90deg, rgba(232, 180, 90, 0.06) 1px, transparent 1px);
    background-size: 24px 24px, 24px 24px, 96px 96px, 96px 96px;
  }
  
  /* 顶部导航 */
  .v9-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--g-md) var(--g-lg);
    padding-top: calc(var(--safe-top) - 20px);
    background: linear-gradient(180deg, var(--depth-1) 0%, transparent 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  
  .v9-nav__brand {
    display: flex;
    align-items: center;
    gap: var(--g-sm);
    font-family: "Noto Serif SC", serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--gold);
    text-decoration: none;
  }
  
  .v9-nav__logo {
    width: 24px;
    height: 24px;
    color: var(--gold);
  }
  
  .v9-nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
  }
  
  .v9-nav__links {
    display: flex;
    align-items: center;
    gap: var(--g-md);
  }
  
  .v9-nav__links a {
    color: var(--foam);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease;
  }
  
  .v9-nav__links a:hover {
    color: var(--gold);
  }
  
  .v9-nav__links a.is-active {
    color: var(--gold);
  }
  
  .v9-nav__cta {
    padding: var(--g-sm) var(--g-md);
    background: var(--gold);
    color: var(--depth-1);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-md);
  }
  
  .v9-nav__cta:hover {
    background: var(--gold-soft);
    box-shadow: var(--shadow-glow-gold);
  }
  
  /* 主容器 */
  .v9-main {
    position: relative;
    z-index: 1;
    padding: var(--g-lg);
    max-width: 100%;
  }
  
  /* 正文行宽限制（电脑端） */
  .v9-main.measure {
    max-width: var(--measure);
    margin-left: auto;
    margin-right: auto;
  }
  
  /* 封面区 */
  .v9-hero {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--g-2xl) var(--g-lg);
    text-align: center;
    overflow: hidden;
  }
  
  /* 煤油灯光晕 */
  .v9-hero__halo {
    position: absolute;
    top: 10%;
    right: 10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(232, 180, 90, 0.15) 0%, transparent 70%);
    pointer-events: none;
    animation: halo-pulse 4s ease-in-out infinite;
  }
  
  @keyframes halo-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
  }
  
  /* 底部 CTA 区 */
  .v9-cta {
    position: relative;
    z-index: 1;
    padding: var(--g-xl) var(--g-lg);
    text-align: center;
  }
  
  /* AI 披露条 */
  .v9-ai-disclosure {
    position: relative;
    z-index: 1;
    padding: var(--g-md) var(--g-lg);
    padding-bottom: var(--g-sm);
    background: var(--glass-panel);
    border-top: 1px solid var(--glass-border);
    font-size: 12px;
    color: var(--foam-dim);
    text-align: center;
  }
  
  /* 页脚 */
  .v9-footer {
    position: relative;
    z-index: 1;
    padding: var(--g-lg);
    padding-bottom: var(--safe-bottom);
    background: var(--depth-2);
    border-top: 1px solid var(--glass-border);
    text-align: center;
    font-size: 13px;
    color: var(--foam-dim);
  }
  
  /* 两栏布局（手册页） */
  .v9-layout-two-rail {
    display: flex;
    flex-direction: column;
  }
  
  .v9-chapter-rail {
    display: none;
  }
  
  /* 分栏布局（海报页） */
  .v9-layout-split {
    display: flex;
    flex-direction: column;
  }
  
  /* 平板断点 */
  @media (min-width: 768px) {
    .v9-nav {
      padding: var(--g-lg) var(--g-xl);
    }
    
    .v9-main {
      padding: var(--g-xl);
    }
    
    .v9-layout-two-rail {
      flex-direction: row;
    }
    
    .v9-chapter-rail {
      display: block;
      width: 20%;
      position: sticky;
      top: 80px;
      height: fit-content;
      padding: var(--g-lg);
    }
    
    .v9-chapter-body {
      width: 80%;
      padding: var(--g-lg);
    }
    
    .v9-layout-split {
      flex-direction: row;
    }
  }
  
  /* 电脑断点 */
  @media (min-width: 1280px) {
    .v9-hero__halo {
      width: 500px;
      height: 500px;
    }
  }
}

/* ═══════════════════════════════════════════════════════════════
 * LAYER 4: TYPOGRAPHY · 字体排版
 * 标题用衬线宋 · 正文用黑体 · 数字用 Mono
 * ═══════════════════════════════════════════════════════════════ */
@layer typography {
  /* 主标题 · 衬线宋体 */
  .v9-h1 {
    font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--foam);
  }
  
  /* 章节标题 · 带沙金下划线 */
  .v9-h2 {
    font-family: "Noto Serif SC", "Songti SC", serif;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--foam);
    padding-bottom: var(--g-sm);
    border-bottom: 2px solid var(--gold);
    display: inline-block;
  }
  
  /* 正文 */
  .v9-p {
    font-size: 15px;
    line-height: 1.8;
    color: var(--foam-mute);
    margin-bottom: var(--g-md);
  }
  
  /* Mono 数字/坐标 */
  .v9-mono {
    font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
    font-size: 14px;
    color: var(--gold);
    letter-spacing: 0.05em;
  }
  
  /* § 编号 */
  .v9-section-number {
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    font-weight: 500;
    color: var(--gold-deep);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--g-sm);
  }
  
  /* 平板以上字号调整 */
  @media (min-width: 768px) {
    .v9-h1 { font-size: 42px; }
    .v9-h2 { font-size: 28px; }
    .v9-p { font-size: 16px; }
  }
  
  @media (min-width: 1280px) {
    .v9-h1 { font-size: 56px; }
    .v9-h2 { font-size: 32px; }
  }
}

/* ═══════════════════════════════════════════════════════════════
 * LAYER 5: COMPONENTS · 11 种 allowed_blocks 组件
 * 每组件 5 态: default / hover / active / focus-visible / disabled
 * ═══════════════════════════════════════════════════════════════ */
@layer components {
  /* § cover · 封面 */
  .v9-hero__title-parchment {
    position: relative;
    padding: var(--g-xl) var(--g-xl);
    background: var(--parchment);
    border: 1px solid var(--parchment-rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    max-width: 600px;
  }
  
  .v9-hero__title-parchment h1 {
    font-family: "Noto Serif SC", serif;
    font-style: italic;
    color: var(--parchment-ink);
    margin-bottom: var(--g-md);
  }
  
  .v9-hero__title-parchment .v9-underline-gold {
    position: relative;
    display: inline-block;
  }
  
  .v9-hero__title-parchment .v9-underline-gold::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--gold-soft), var(--gold));
    border-radius: 2px;
  }
  
  /* § sct · 卷宗分节 */
  .v9-section {
    position: relative;
    padding: var(--g-xl) 0;
    margin-bottom: var(--g-xl);
  }
  
  .v9-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
  }
  
  /* § par · 羊皮纸大段 */
  .v9-parchment {
    background: var(--parchment);
    border: 1px solid var(--parchment-rule);
    border-radius: var(--radius-lg);
    padding: var(--g-xl);
    margin: var(--g-lg) 0;
  }
  
  .v9-parchment__body {
    color: var(--parchment-ink);
    font-size: 15px;
    line-height: 1.8;
  }
  
  /* 羊皮纸区域内所有文字使用深墨色 */
  .v9-parchment__body h1,
  .v9-parchment__body h2,
  .v9-parchment__body h3,
  .v9-parchment__body h4,
  .v9-parchment__body h5,
  .v9-parchment__body h6,
  .v9-parchment__body p,
  .v9-parchment__body li,
  .v9-parchment__body span {
    color: var(--parchment-ink);
  }
  
  .v9-parchment__body p {
    color: var(--parchment-ink);
    opacity: 0.85;
  }
  
  /* § rule · 羊皮纸编号提示条 */
  .v9-rule-card {
    display: flex;
    align-items: flex-start;
    gap: var(--g-md);
    padding: var(--g-md) var(--g-lg);
    background: var(--parchment);
    border-left: 3px solid var(--gold);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin: var(--g-md) 0;
  }
  
  .v9-rule-card__number {
    font-family: "JetBrains Mono", monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--gold-deep);
    flex-shrink: 0;
  }
  
  .v9-rule-card__text {
    color: var(--parchment-ink);
    font-size: 14px;
    line-height: 1.6;
  }
  
  /* § data · 玻璃态数据卡 */
  .v9-glass-float {
    background: var(--glass-float);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--g-lg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  
  .v9-glass-panel {
    background: var(--glass-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--g-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  
  .v9-glass-fill {
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--g-lg);
  }
  
  /* § toc · 档案目录 */
  .v9-toc-rail {
    padding: var(--g-xl) 0;
  }
  
  .v9-toc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--g-md);
  }
  
  .v9-toc-card {
    background: var(--glass-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--g-lg);
    transition: all var(--dur-base) var(--ease-state);
  }
  
  .v9-toc-card:hover {
    background: var(--glass-fill);
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: var(--shadow-float);
  }
  
  /* § proof · 产品证明 */
  .v9-proof-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--g-lg);
    padding: var(--g-xl) 0;
  }
  
  .v9-proof-stat {
    text-align: center;
    padding: var(--g-lg);
    background: var(--glass-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
  }
  
  .v9-proof-stat__number {
    font-family: "JetBrains Mono", monospace;
    font-size: 36px;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
    margin-bottom: var(--g-sm);
  }
  
  .v9-proof-stat__label {
    font-size: 13px;
    color: var(--foam-mute);
  }
  
  /* § roles · 角色卡片 */
  .v9-role-cards {
    display: flex;
    flex-direction: column;
    gap: var(--g-lg);
    padding: var(--g-xl) 0;
  }
  
  .v9-role-card {
    position: relative;
    padding: var(--g-xl);
    background: var(--glass-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--dur-base) var(--ease-state);
  }
  
  .v9-role-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-panel);
  }
  
  .v9-role-card--merchant {
    border-color: var(--gold);
    box-shadow: var(--shadow-glow-gold);
  }
  
  /* 商户卡呼吸动画 */
  .v9-role-card--merchant.is-highlight {
    animation: merchant-breathe 3s ease-in-out infinite;
  }
  
  @keyframes merchant-breathe {
    0%, 100% { box-shadow: 0 0 20px rgba(232, 180, 90, 0.3); }
    50% { box-shadow: 0 0 40px rgba(232, 180, 90, 0.5); }
  }
  
  /* § act · CTA 面板 */
  .v9-cta-panel {
    padding: var(--g-xl);
    background: var(--parchment);
    border-radius: var(--radius-lg);
    text-align: center;
  }
  
  /* 按钮组 */
  .v9-btn-group {
    display: flex;
    flex-direction: column;
    gap: var(--g-md);
  }
  
  /* 主 CTA 按钮 · 沙金 */
  .v9-btn-gold {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--g-sm);
    padding: var(--g-md) var(--g-xl);
    background: linear-gradient(135deg, var(--gold), var(--gold-soft));
    color: var(--depth-1);
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glow-gold);
    transition: all var(--dur-fast) var(--ease-state);
  }
  
  .v9-btn-gold:hover {
    background: linear-gradient(135deg, var(--gold-soft), var(--gold));
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(232, 180, 90, 0.4);
  }
  
  .v9-btn-gold:active {
    transform: scale(var(--press-scale));
  }
  
  /* 幽灵按钮 */
  .v9-btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--g-sm);
    padding: var(--g-md) var(--g-xl);
    background: transparent;
    color: var(--foam);
    font-size: 15px;
    font-weight: 500;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all var(--dur-fast) var(--ease-state);
  }
  
  .v9-btn-ghost:hover {
    background: var(--glass-float);
    border-color: var(--foam-mute);
  }
  
  /* 禁用态 */
  .v9-btn-gold:disabled,
  .v9-btn-ghost:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
  }
  
  /* focus-visible */
  .v9-btn-gold:focus-visible,
  .v9-btn-ghost:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
  }
  
  /* § 404 */
  .v9-404 {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--g-2xl) var(--g-lg);
  }
  
  .v9-404__compass {
    width: 120px;
    height: 120px;
    margin-bottom: var(--g-xl);
    opacity: 0.6;
    transform: rotate(-15deg);
  }
  
  /* 平板断点组件调整 */
  @media (min-width: 768px) {
    .v9-toc-grid {
      grid-template-columns: repeat(2, 1fr);
    }
    
    .v9-proof-grid {
      grid-template-columns: repeat(2, 1fr);
    }
    
    .v9-btn-group {
      flex-direction: row;
      justify-content: center;
    }
  }
  
  /* 电脑断点 */
  @media (min-width: 1280px) {
    .v9-toc-grid {
      grid-template-columns: repeat(4, 1fr);
    }
    
    .v9-proof-grid {
      grid-template-columns: repeat(4, 1fr);
    }
    
    .v9-role-cards {
      flex-direction: row;
    }
    
    .v9-role-card {
      flex: 1;
    }
  }
}

/* ═══════════════════════════════════════════════════════════════
 * LAYER 6: UTILITIES · 工具类（≤15 条）
 * ═══════════════════════════════════════════════════════════════ */
@layer utilities {
  /* 屏幕阅读器专用 */
  .sr-only,
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  
  /* 行宽限制 */
  .measure {
    max-width: var(--measure);
    margin-left: auto;
    margin-right: auto;
  }
  
  /* 隐藏滚动条 */
  .no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  
  .no-scrollbar::-webkit-scrollbar {
    display: none;
  }
  
  /* 沙金发光 */
  .glow-gold {
    box-shadow: var(--shadow-glow-gold);
  }
  
  /* 安全区 */
  .safe-top {
    padding-top: var(--safe-top);
  }
  
  .safe-bottom {
    padding-bottom: var(--safe-bottom);
  }
  
  /* 文字对齐 */
  .text-center { text-align: center; }
  .text-left { text-align: left; }
  .text-right { text-align: right; }
  
  /* 显示控制 */
  .hidden { display: none; }
  .block { display: block; }
  .flex { display: flex; }
  .grid { display: grid; }
  
  /* 平板以上显示 */
  .hidden-md {
    display: none;
  }
  
  @media (min-width: 768px) {
    .hidden-md {
      display: block;
    }
    
    .visible-md {
      display: none;
    }
  }
}
