/**
 * src/css/style.css
 * --------------------------------------------------------------------------
 * Amazon Listing Byte Checker 全站核心样式表。
 * 包含：字体声明、CSS 变量设计系统、基础重置、工具组件、三色预警、
 * 联盟推荐位、广告位、Footer、语言切换器、Toast、Embed 模式、
 * 脉冲动画、风险词高亮、响应式断点、a11y 与 404 页面。
 * 所有颜色均通过 CSS 变量（var(--*)）引用，无硬编码色值。
 * BEM 命名规范，2 空格缩进，单引号，分号结尾。
 *
 * 维护者：Amazon Listing Byte Checker Team
 * 最后更新：2026-07-31
 */

/* Touch optimization: eliminate 300ms tap delay and remove tap highlight */
button, a, select, .tool-btn, .lang-switcher select {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   @font-face 字体声明
   ========================================================================== */
@font-face {
  font-family: 'InstrumentSans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/_shared/fonts/InstrumentSans-Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'InstrumentSans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/_shared/fonts/InstrumentSans-Bold.ttf') format('truetype');
}

@font-face {
  font-family: 'JetBrainsMono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/_shared/fonts/JetBrainsMono-Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'JetBrainsMono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/_shared/fonts/JetBrainsMono-Bold.ttf') format('truetype');
}

/* ==========================================================================
   :root CSS 变量（设计系统唯一数据源）
   ========================================================================== */
:root {
  /* 颜色 */
  --bg: #f4f7fc;
  --bg2: #ffffff;
  --ink: #1a2233;
  --muted: #5b6b85;
  --rule: #e3e8f0;
  --accent: #2563eb;
  --accent2: #f59e0b;
  --safe: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --accent-dark: #1d4ed8;

  /* 字体 */
  --font: 'InstrumentSans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrainsMono', 'Consolas', monospace;

  /* 布局 */
  --max: 860px;
  --radius: 10px;

  /* 间距 */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* z-index */
  --z-header: 100;
  --z-toast: 200;
  --sidebar-w: 280px;

  /* 半透明颜色变量 */
  --accent-07: rgba(37, 99, 235, 0.07);
  --accent-03: rgba(37, 99, 235, 0.03);
  --accent2-06: rgba(245, 158, 11, 0.06);
  --ink-06: rgba(26, 34, 51, 0.06);
  --danger-04: rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   基础重置
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   body 基础样式
   ========================================================================== */
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, var(--accent-07) 0%, transparent 40%),
    radial-gradient(circle at 88% 92%, var(--accent2-06) 0%, transparent 40%);
  background-attachment: fixed;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   FOUC 防护（合规页面用，字体加载后 JS 移除此类）
   ========================================================================== */
.pages-body {
  visibility: hidden;
}

/* ==========================================================================
   site-header 站点头部
   ========================================================================== */
.site-header {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}

.site-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.3rem;
}

.site-header .subtitle {
  font-size: 0.9rem;
  color: var(--muted);
}

/* ==========================================================================
   site-description 站点描述区（H2 级别）
   ========================================================================== */
.site-description {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem 1rem;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.7;
}

.site-description h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   tool-card 工具卡片容器
   ========================================================================== */
.tool-card {
  background: var(--bg2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--ink-06);
  padding: 1.5rem;
  margin: 0 auto;
  max-width: var(--max);
}

/* ==========================================================================
   site-selector 站点选择器
   ========================================================================== */
.site-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.site-selector label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.site-selector select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--bg2);
  cursor: pointer;
  transition: border-color 0.15s;
}

.site-selector select:focus {
  border-color: var(--accent);
  outline: none;
}

/* ==========================================================================
   tool-field 字段输入区
   ========================================================================== */
.tool-field {
  margin-bottom: 1.2rem;
}

.tool-field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.tool-field-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.tool-field-name .byte-hint {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.tool-field-limit {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ==========================================================================
   tool-input 文本输入框
   ========================================================================== */
.tool-input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg2);
  resize: vertical;
  transition: border-color 0.15s;
}

.tool-input:focus {
  border-color: var(--accent);
  outline: none;
}

.tool-input--sm {
  /* HTML textarea rows="2" 属性在模板中设置 */
  font-size: 0.85rem;
}

/* ==========================================================================
   tool-stats 统计信息
   ========================================================================== */
.tool-stats {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.4rem;
}

.tool-stat {
  font-size: 0.8rem;
  color: var(--muted);
}

.tool-stat b {
  font-weight: 600;
  color: var(--accent);
}

.tool-stat--bytes b {
  color: var(--accent);
}

/* ==========================================================================
   tool-bar 进度条
   ========================================================================== */
.tool-bar {
  flex: 1;
  height: 8px;
  background: var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

.tool-bar-fill {
  height: 100%;
  background: var(--safe);
  border-radius: 4px;
  transition: width 0.3s ease, background-color 0.3s ease;
  width: 0%;
}

/* ==========================================================================
   三色预警状态类（safe 绿 / near 黄 / over 红）
   ========================================================================== */
.tool-safe .tool-bar-fill {
  background: var(--safe) !important;
}

.tool-near .tool-bar-fill {
  background: var(--warn) !important;
}

.tool-near .tool-stat--bytes b {
  color: var(--warn);
}

.tool-over .tool-bar-fill {
  background: var(--danger) !important;
}

.tool-over .tool-stat--bytes b {
  color: var(--danger);
}

.tool-over .tool-field-limit {
  color: var(--danger);
  font-weight: 600;
}

/* ==========================================================================
   tool-field-group 字段分组（五点描述容器）
   ========================================================================== */
.tool-field-group {
  border: 1px dashed var(--rule);
  background: var(--accent-03);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.2rem;
}

/* ==========================================================================
   tool-bullets 五点描述网格
   ========================================================================== */
.tool-bullets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

/* ==========================================================================
   bullet-total 五点描述总计
   ========================================================================== */
.bullet-total {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bullet-total .label {
  font-size: 0.82rem;
  color: var(--muted);
}

.bullet-total .value {
  font-size: 0.82rem;
  font-family: var(--font-mono);
}

.bullet-total--over .value {
  color: var(--danger);
}

.bullet-total--near .value {
  color: var(--warn);
}

/* ==========================================================================
   tool-actions 操作按钮栏
   ========================================================================== */
.tool-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   tool-btn 按钮
   ========================================================================== */
.tool-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--ink);
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}

.tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tool-btn--primary {
  background: var(--accent);
  color: var(--bg2);
  border-color: var(--accent);
}

.tool-btn--primary:hover {
  background: var(--accent-dark);
  color: var(--bg2);
}

/* Disabled state for primary button (e.g., Copy Results when no content) */
.tool-btn--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================================================
   recommendation 联盟推荐位
   ========================================================================== */
.recommendation {
  display: none;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  background: var(--accent-03);
}

.recommendation--active {
  display: block;
}

.sponsored-label {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.recommendation-text {
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  color: var(--ink);
}

.recommendation-product {
  font-weight: 600;
  color: var(--accent);
}

.recommendation-link {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.3rem 0.8rem;
  background: var(--accent);
  color: var(--bg2);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.82rem;
  transition: background 0.15s;
}

.recommendation-link:hover {
  background: var(--accent-dark);
}

/* ==========================================================================
   ad-slot 广告位（V1.0 隐藏，不占位）
   ========================================================================== */
.ad-slot {
  display: none;
  min-height: 90px;
  margin-top: 1rem;
  text-align: center;
}

/* ==========================================================================
   disclaimer 免责声明
   ========================================================================== */
.disclaimer {
  margin-top: 1rem;
  padding: 0.8rem;
  border: 1px dashed var(--rule);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ==========================================================================
   site-footer 站点底部
   ========================================================================== */
.site-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--accent);
}

.footer-feedback {
  margin-top: 0.5rem;
}

/* ==========================================================================
   lang-switcher 语言切换器
   ========================================================================== */
.lang-switcher {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.lang-switcher label {
  font-size: 0.78rem;
  color: var(--muted);
}

.lang-switcher select {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg2);
  cursor: pointer;
}

/* ==========================================================================
   flash-toast 提示消息
   ========================================================================== */
.flash-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: var(--bg2);
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: var(--z-toast);
  opacity: 0;
  transition: all 0.3s ease;
}

.flash-toast--show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   embed-mode 嵌入模式（隐藏非核心元素）
   ========================================================================== */
body.embed-mode .site-header,
body.embed-mode .site-footer,
body.embed-mode .ad-slot,
body.embed-mode .recommendation,
body.embed-mode .lang-switcher {
  display: none !important;
}

/* ==========================================================================
   pulse 动画（Search Terms 超限脉冲）
   ========================================================================== */
@keyframes pulse-danger {
  0%, 100% {
    box-shadow: 0 0 0 0 var(--danger-04);
  }
  50% {
    box-shadow: 0 0 0 6px transparent;
  }
}

.tool-over.tool-field--pulse .tool-bar-fill {
  animation: pulse-danger 1s infinite;
}

/* ==========================================================================
   风险词高亮
   ========================================================================== */
.risk-word {
  text-decoration: underline wavy var(--danger);
  text-underline-offset: 2px;
  cursor: help;
}

/* ==========================================================================
   风险词 tooltip
   ========================================================================== */
.risk-tooltip {
  position: absolute;
  background: var(--ink);
  color: var(--bg2);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.78rem;
  z-index: var(--z-toast);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.risk-tooltip--show {
  opacity: 1;
}

/* ==========================================================================
   forbidden-warn 禁止字符提示
   ========================================================================== */
.forbidden-warn {
  color: var(--warn);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

/* ==========================================================================
   响应式（移动端 640px）
   ========================================================================== */
@media (max-width: 640px) {
  .tool-bullets {
    grid-template-columns: 1fr;
  }

  .tool-actions {
    flex-direction: column;
  }

  .site-header h1 {
    font-size: 1.3rem;
  }

  .tool-card {
    padding: 1rem;
  }

  .lang-switcher {
    position: static;
    justify-content: center;
    margin-bottom: 0.5rem;
  }
}

/* ==========================================================================
   a11y 无障碍焦点样式
   ========================================================================== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   404 页面样式
   ========================================================================== */
.not-found {
  text-align: center;
  padding: 4rem 1rem;
}

.not-found h1 {
  font-size: 3rem;
  color: var(--accent);
}

.not-found__content {
  max-width: var(--max);
  margin: 0 auto;
}

.not-found__title {
  font-size: 3rem;
  color: var(--accent);
}

.not-found__message {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0.5rem 0 1.5rem;
}

.not-found__link {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  background: var(--accent);
  color: var(--bg2);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.15s;
}

.not-found__link:hover {
  background: var(--accent-dark);
}
