/* main.css — Calcfx 全站样式（零依赖，逻辑属性支持 RTL） */

/* ---------- 设计令牌 ---------- */
:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f0f4fa;
  --text: #131b2a;
  --text-soft: #55617a;
  --text-mute: #7b869c;
  --brand: #1f6feb;
  --brand-dark: #14509f;
  --brand-soft: #e8f0fe;
  --line: #dfe5ef;
  --line-soft: #eef2f8;
  --up: #d92d20;      /* 涨 = 红（中国市场惯例） */
  --down: #0f9960;    /* 跌 = 绿 */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --wrap: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", "Microsoft YaHei", Arial, sans-serif;
  --font-num: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { line-height: 1.28; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }
img { max-width: 100%; }
button, input, select { font: inherit; color: inherit; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }

/* 跳转主内容 */
.skip-link {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { inset-inline-start: 0; }

/* ---------- 头部 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-block-end: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 18px; min-height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--brand); }
.brand-mark { color: var(--brand); display: inline-flex; }
.brand-name { letter-spacing: -.02em; }

.main-nav { display: flex; gap: 20px; margin-inline-start: auto; font-size: 14.5px; font-weight: 500; }
.main-nav a { color: var(--text-soft); }
.main-nav a:hover { color: var(--brand); text-decoration: none; }

.lang-switch { margin-inline-start: 4px; }
.lang-details { position: relative; }
.lang-details > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 7px;
  font-size: 13.5px; font-weight: 600; color: var(--text-soft); background: var(--surface);
}
.lang-details > summary::-webkit-details-marker { display: none; }
.lang-details[open] > summary { border-color: var(--brand); color: var(--brand); }
.lang-list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 50;
  margin: 0; padding: 6px; list-style: none; min-width: 210px; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.lang-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text-soft); }
.lang-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.lang-item.is-current { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.lang-item img { border-radius: 2px; flex: none; }

/* ---------- Hero ---------- */
.hero { padding: 44px 0 30px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(340px, .95fr); gap: 40px; align-items: start; }
.hero-title { font-size: clamp(28px, 3.6vw, 40px); letter-spacing: -.025em; margin-bottom: 10px; }
.hero-sub { font-size: 17px; color: var(--text-soft); margin-bottom: 18px; }
.hero-text { color: var(--text-soft); font-size: 15.5px; }
.hero-text p:last-child { margin-bottom: 0; }

/* ---------- 计算器 ---------- */
.calc-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.calc-head { margin-bottom: 16px; }
.calc-title { font-size: 17px; margin-bottom: 4px; }
.calc-rate-line { margin: 0; font-size: 14px; color: var(--text-mute); font-family: var(--font-num); }
.calc-sep { margin-inline: 6px; opacity: .5; }

.calc-form { display: grid; gap: 14px; }
.calc-row { display: grid; gap: 6px; }
.calc-label { font-size: 12.5px; font-weight: 600; color: var(--text-mute); text-transform: uppercase; letter-spacing: .04em; }
.calc-input, .calc-select {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; background: var(--surface); font-size: 16px;
}
.calc-input:focus, .calc-select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.calc-pair-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; }
.calc-side { display: grid; gap: 6px; min-width: 0; }
.calc-select-wrap { position: relative; display: flex; align-items: center; }
.calc-flag { position: absolute; inset-inline-start: 10px; border-radius: 2px; pointer-events: none; }
.calc-select { padding-inline-start: 38px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%), linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
[dir="rtl"] .calc-select { background-position: 11px 55%, 16px 55%; }
.calc-swap {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-soft);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  transition: transform .18s ease, border-color .18s, color .18s;
}
.calc-swap:hover { border-color: var(--brand); color: var(--brand); }
.calc-swap:active { transform: rotate(180deg); }

.calc-result {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  background: var(--brand-soft); border-radius: var(--radius-sm); padding: 14px 16px;
}
.calc-result-label { font-size: 13px; font-weight: 600; color: var(--brand-dark); }
.calc-result-value { font-size: 24px; font-weight: 700; font-family: var(--font-num); color: var(--brand-dark); }
.calc-error { margin: 0; font-size: 13px; color: var(--up); }
.calc-source { margin: 0; font-size: 12.5px; color: var(--text-mute); }
.calc-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: background .16s, border-color .16s, color .16s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text-soft); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- 区块 ---------- */
.section { padding: 34px 0; }
.section-title { font-size: 21px; margin-bottom: 16px; letter-spacing: -.015em; }

/* ---------- 币种对网格 ---------- */
.pair-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px;
}
.pair-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px; font-weight: 600; color: var(--text);
  font-family: var(--font-num); transition: border-color .16s, transform .16s;
}
.pair-chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.pair-chip img { border-radius: 2px; flex: none; }
.pair-chip img + img { margin-inline-start: -4px; }

.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.link-list a {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 14px; color: var(--text); font-size: 14.5px;
}
.link-list a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

/* ---------- 文章 ---------- */
.article-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.article-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: box-shadow .18s, transform .18s; }
.article-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.article-link { display: grid; grid-template-columns: 108px 1fr; gap: 0; color: inherit; }
.article-link:hover { text-decoration: none; }
.article-thumb { display: block; background: var(--surface-2); }
.article-thumb img { width: 100%; height: 100%; min-height: 84px; object-fit: cover; display: block; }
.article-meta { display: grid; gap: 5px; padding: 13px 14px; align-content: start; }
.article-title { font-weight: 700; font-size: 15px; line-height: 1.38; color: var(--text); }
.article-desc { font-size: 13px; color: var(--text-mute); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.article-col { padding-block: 26px 44px; max-width: 780px; }
.page-title { font-size: clamp(25px, 3vw, 34px); letter-spacing: -.02em; margin-bottom: 12px; }
.article-meta-line { color: var(--text-mute); font-size: 13.5px; margin-bottom: 18px; }
.article-figure { margin: 0 0 24px; }
.article-figure img { border-radius: var(--radius); display: block; }

.crumbs { font-size: 13px; color: var(--text-mute); margin-bottom: 14px; }
.crumbs a { color: var(--text-soft); }
.crumbs span[aria-hidden] { margin-inline: 6px; opacity: .5; }

.prose { font-size: 16px; color: #2a3446; }
.prose h2 { font-size: 20px; margin-top: 30px; color: var(--text); }
.prose h3 { font-size: 17px; margin-top: 22px; color: var(--text); }
.prose p { margin-bottom: 15px; }

.scenario-line {
  background: var(--surface); border-inline-start: 3px solid var(--brand);
  border-radius: var(--radius-sm); padding: 13px 16px; font-size: 14.5px; color: var(--text-soft);
  margin-bottom: 22px;
}

/* ---------- 汇率卡片 ---------- */
.rate-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 22px;
}
.rate-main { display: grid; gap: 6px; justify-items: center; text-align: center; }
.rate-pair { display: inline-flex; align-items: center; gap: 8px; }
.rate-flag { border-radius: 2px; }
.rate-code { font-family: var(--font-num); font-weight: 700; font-size: 17px; }
.rate-arrow { color: var(--text-mute); }
.rate-value { font-size: clamp(28px, 4.4vw, 38px); font-weight: 800; font-family: var(--font-num); letter-spacing: -.02em; color: var(--brand-dark); }
.rate-label { font-size: 12.5px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }
.rate-meta { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); display: grid; gap: 3px; text-align: center; }
.rate-meta p { margin: 0; font-size: 13px; color: var(--text-mute); }
.rate-inverse { font-family: var(--font-num); }

/* ---------- FAQ ---------- */
.faq { display: grid; gap: 9px; }
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.faq-item summary {
  cursor: pointer; padding: 13px 16px; font-weight: 600; font-size: 15px;
  list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 19px; color: var(--text-mute); font-weight: 400; flex: none; }
.faq-item[open] summary::after { content: "−"; }
.faq-item summary:hover { color: var(--brand); }
.faq-item p { margin: 0; padding: 0 16px 15px; font-size: 14.5px; color: var(--text-soft); }

/* ---------- 广告位 ---------- */
.ad-slot {
  background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius-sm);
  display: grid; place-items: center; min-height: 96px; margin: 22px 0;
  position: relative; color: var(--text-mute); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
}
.ad-leaderboard { min-height: 108px; }
.ad-footer { min-height: 82px; }
.ad-label { position: absolute; inset-block-start: 6px; inset-inline-start: 10px; font-size: 9.5px; opacity: .65; }

/* ---------- 页脚 ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 40px; padding: 36px 0 30px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 28px; }
.footer-brand { font-weight: 800; font-size: 17px; margin-bottom: 6px; }
.footer-h { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-mute); margin-bottom: 10px; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 14px; }
.footer-note { font-size: 13px; color: var(--text-mute); margin-bottom: 8px; max-width: 52ch; }
.footer-legal { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }

/* ---------- 同意管理横幅 ---------- */
.consent {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(16, 24, 40, .12);
}
.consent[hidden] { display: none; }
.consent-inner {
  max-width: var(--wrap); margin-inline: auto; padding: 16px 20px;
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
}
.consent-text { flex: 1 1 320px; min-width: 0; }
.consent-title { font-size: 15px; margin: 0 0 4px; }
.consent-body { margin: 0; font-size: 13.5px; color: var(--text-soft); }
.consent-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 26px; }
  .hero { padding-top: 30px; }
  .article-link { grid-template-columns: 92px 1fr; }
}

@media (max-width: 620px) {
  .main-nav { display: none; }
  .lang-switch { margin-inline-start: auto; }
  .calc-pair-row { grid-template-columns: 1fr; }
  .calc-swap { justify-self: center; transform: rotate(90deg); }
  .calc-swap:active { transform: rotate(270deg); }
  .article-link { grid-template-columns: 1fr; }
  .article-thumb img { min-height: 150px; }
  .wrap { padding-inline: 16px; }
}

/* ---------- RTL ---------- */
[dir="rtl"] .crumbs span[aria-hidden] { margin-inline: 6px; }
[dir="rtl"] .rate-arrow { transform: scaleX(-1); }
[dir="rtl"] .calc-swap svg { transform: scaleX(-1); }

/* ---------- 打印 ---------- */
@media print {
  .site-header, .site-footer, .ad-slot, .calc-actions, .lang-switch { display: none !important; }
  body { background: #fff; }
  .calc-card, .rate-card { box-shadow: none; border-color: #ccc; }
}

/* ---------- 减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
