/* ============================================================
   CreateCalc — global stylesheet
   Loaded by every page (external file = cached across navigation).
   Design tokens follow createcalc-规划.md §五.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --c-primary:        #2563EB;
  --c-primary-dark:   #1D4ED8;
  --c-primary-soft:   #EFF6FF;
  --c-accent:         #F59E0B;
  --c-accent-dark:    #D97706;
  --c-accent-soft:    #FFFBEB;
  --c-bg:             #FFFFFF;
  --c-card:           #F8FAFC;
  --c-text:           #1E293B;
  --c-muted:          #64748B;
  --c-success:        #059669;
  --c-border:         #E2E8F0;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 6px 24px rgba(15, 23, 42, .09);

  --maxw: 1120px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
h1, h2, h3 { line-height: 1.25; color: var(--c-text); }
ul { padding-left: 1.25rem; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
}
.nav { display: flex; align-items: center; gap: 16px; height: 64px; }
.nav__logo { font-size: 22px; font-weight: 800; color: var(--c-text); letter-spacing: -.02em; }
.nav__logo span { color: var(--c-primary); }
.nav__logo:hover { text-decoration: none; }
.nav__spacer { flex: 1; }
.nav__menu { display: flex; align-items: center; gap: 4px; }
.nav__link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--c-text); font-weight: 600; font-size: 15px;
}
.nav__link:hover { background: var(--c-primary-soft); color: var(--c-primary); text-decoration: none; }
.nav__item { position: relative; }
.nav__caret { font-size: 10px; transition: transform .15s ease; }
.nav__item.is-open .nav__caret { transform: rotate(180deg); }
.nav__dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 240px; background: #fff;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 8px;
}
.nav__item.is-open .nav__dropdown { display: block; }
.nav__dropdown a {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--c-text); font-size: 14px; font-weight: 500;
}
.nav__dropdown a:hover { background: var(--c-card); color: var(--c-primary); text-decoration: none; }
.nav__burger { display: none; font-size: 24px; padding: 6px 10px; color: var(--c-text); }

@media (max-width: 860px) {
  .nav__burger { display: block; }
  .nav__menu {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: #fff; border-bottom: 1px solid var(--c-border);
    padding: 10px 16px 16px; box-shadow: var(--shadow-md);
  }
  .nav__menu.is-open { display: flex; }
  .nav__dropdown { position: static; box-shadow: none; border: none; padding: 4px 0 4px 12px; }
}

/* ---------- Generic sections ---------- */
.page { padding: 32px 0 64px; }
.hero { text-align: center; padding: 36px 0 24px; }
.hero h1 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -.02em; }
.hero p { color: var(--c-muted); font-size: 18px; max-width: 620px; margin: 12px auto 0; }

.breadcrumb { font-size: 13px; color: var(--c-muted); padding: 16px 0 0; }
.breadcrumb a { color: var(--c-muted); }
.breadcrumb a:hover { color: var(--c-primary); }

.section { padding: 32px 0; }
.section h2 { font-size: 26px; letter-spacing: -.01em; margin-bottom: 16px; }
.section h3 { font-size: 18px; margin: 20px 0 8px; }
.section p { margin-bottom: 12px; }
.prose { max-width: 760px; }
.prose ul { margin-bottom: 12px; }
.prose li { margin-bottom: 6px; }

/* ---------- Calculator ---------- */
.calc {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 24px;
}
.calc__panel { min-width: 0; }

.calc__modes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.calc__mode {
  padding: 9px 16px; border: 1px solid var(--c-border); background: #fff;
  border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--c-muted);
}
.calc__mode:hover { border-color: var(--c-primary); color: var(--c-primary); }
.calc__mode.is-active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

.calc__fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--c-muted); }
.field__wrap { position: relative; display: flex; }
.field__wrap input {
  width: 100%; height: 48px; font-size: 18px; color: var(--c-text);
  padding: 0 52px 0 14px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: #fff; font-variant-numeric: tabular-nums;
}
.field__wrap input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.field__wrap input.is-invalid { border-color: #DC2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.field__wrap select {
  width: 100%; height: 48px; font-size: 16px; color: var(--c-text);
  padding: 0 38px 0 13px; cursor: pointer;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background-color: #fff; -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748B' stroke-width='2' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.field__wrap select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.field__unit {
  position: absolute; right: 1px; top: 1px; bottom: 1px;
  display: flex; align-items: center; padding: 0 12px;
  color: var(--c-muted); font-size: 13px; font-weight: 600;
  background: var(--c-card); border-left: 1px solid var(--c-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; pointer-events: none;
}
.field__error { font-size: 12px; color: #DC2626; min-height: 0; }

.calc__go {
  margin-top: 20px; width: 100%; height: 52px;
  background: var(--c-primary); color: #fff;
  font-size: 17px; font-weight: 700; border-radius: var(--radius-sm);
  transition: background .15s ease;
}
.calc__go:hover { background: var(--c-primary-dark); }
.calc__go:active { transform: translateY(1px); }

/* result panel */
.result {
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 20px; height: 100%; display: flex; flex-direction: column;
}
.result__empty {
  margin: auto; text-align: center; color: var(--c-muted); font-size: 15px; padding: 24px 8px;
}
.result__empty svg { margin: 0 auto 10px; }
.result__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.result__head h3 { font-size: 16px; }
.unit-toggle { display: inline-flex; border: 1px solid var(--c-border); border-radius: 999px; overflow: hidden; }
.unit-toggle button { padding: 5px 12px; font-size: 12px; font-weight: 700; color: var(--c-muted); }
.unit-toggle button.is-active { background: var(--c-primary); color: #fff; }

.result__rows { display: flex; flex-direction: column; gap: 2px; }
.result__row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px dashed var(--c-border);
}
.result__row:last-child { border-bottom: none; }
.result__label { font-size: 14px; color: var(--c-muted); }
.result__value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result__value em { font-size: 13px; font-weight: 600; color: var(--c-muted); font-style: normal; margin-left: 3px; }
.result__row--primary {
  background: var(--c-accent-soft); border: 1px solid #FDE68A;
  border-radius: var(--radius-sm); padding: 16px; margin-bottom: 8px;
}
.result__row--primary .result__label { color: var(--c-accent-dark); font-weight: 600; font-size: 13px; }
.result__row--primary .result__value { font-size: 30px; color: var(--c-success); }
.result__row--primary .result__value em { color: var(--c-success); }
.result__note { font-size: 12px; color: var(--c-muted); margin-top: 2px; }

.result.is-shown .result__rows { animation: fade-up .35s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.result__actions { display: flex; gap: 10px; margin-top: auto; padding-top: 18px; }
.btn-ghost {
  flex: 1; height: 42px; border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: #fff; font-weight: 600; font-size: 14px; color: var(--c-text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-ghost:hover { border-color: var(--c-primary); color: var(--c-primary); }

/* ---------- CTA button + support box ---------- */
.btn-cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--c-accent); color: #fff; font-weight: 700; font-size: 16px;
  padding: 13px 24px; border-radius: var(--radius-sm);
}
.btn-cta:hover { background: var(--c-accent-dark); color: #fff; text-decoration: none; }
.support-box {
  background: var(--c-accent-soft); border: 1px solid #FDE68A;
  border-radius: var(--radius); padding: 22px 24px; max-width: 760px;
}
.support-box p { margin-bottom: 0; }

@media (max-width: 1023px) {
  .calc { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .calc { padding: 16px; }
  .calc__fields { grid-template-columns: 1fr; }
}

/* ---------- Ad slot ---------- */
.ad-slot {
  margin: 28px 0; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--c-border); border-radius: var(--radius);
  color: #94A3B8; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
}

/* ---------- FAQ accordion ---------- */
.faq__item { border-bottom: 1px solid var(--c-border); }
.faq__q {
  width: 100%; text-align: left; padding: 16px 32px 16px 0; position: relative;
  font-size: 16px; font-weight: 600; color: var(--c-text);
}
.faq__q::after {
  content: '+'; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  font-size: 22px; font-weight: 400; color: var(--c-primary);
}
.faq__item.is-open .faq__q::after { content: '\2013'; }
.faq__a { display: none; padding: 0 0 16px; color: var(--c-muted); }
.faq__item.is-open .faq__a { display: block; }

/* ---------- Calculator cards (home / related) ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.calc-card {
  display: block; background: #fff; border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 18px; transition: border-color .15s ease, transform .15s ease;
}
.calc-card:hover { border-color: var(--c-primary); transform: translateY(-2px); text-decoration: none; }
.calc-card__icon {
  width: 38px; height: 38px; border-radius: var(--radius-sm); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-primary-soft); font-size: 20px;
}
.calc-card__name { display: block; font-weight: 700; font-size: 16px; color: var(--c-text); }
.calc-card__desc { display: block; font-size: 13px; color: var(--c-muted); margin-top: 4px; }
.calc-card--soon { opacity: .6; pointer-events: none; }
.badge-soon {
  display: inline-block; margin-top: 10px; font-size: 11px; font-weight: 700;
  color: var(--c-muted); background: var(--c-card);
  border: 1px solid var(--c-border); border-radius: 999px; padding: 2px 9px;
}
.badge-live {
  display: inline-block; margin-top: 10px; font-size: 11px; font-weight: 700;
  color: var(--c-success); background: #ECFDF5;
  border: 1px solid #A7F3D0; border-radius: 999px; padding: 2px 9px;
}

.cat-block { margin-bottom: 36px; }
.cat-block h2 { font-size: 20px; margin-bottom: 4px; }
.cat-block p { color: var(--c-muted); font-size: 14px; margin-bottom: 14px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--c-card); border-top: 1px solid var(--c-border); padding: 40px 0 28px; margin-top: 48px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; }
.site-footer h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); margin-bottom: 10px; }
.site-footer a { display: block; color: var(--c-text); font-size: 14px; padding: 3px 0; }
.site-footer a:hover { color: var(--c-primary); }
.footer-brand { font-size: 20px; font-weight: 800; color: var(--c-text); }
.footer-brand span { color: var(--c-primary); }
.footer-tag { color: var(--c-muted); font-size: 14px; margin-top: 8px; max-width: 280px; }
.footer-legal {
  margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--c-border);
  font-size: 13px; color: var(--c-muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.footer-legal a { display: inline; color: var(--c-muted); }

@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand-col { grid-column: 1 / -1; }
}

/* ---------- Disclaimer ---------- */
.disclaimer {
  font-size: 13px; color: var(--c-muted); background: var(--c-primary-soft);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 16px;
}

/* ---------- Print: show only the result ---------- */
.print-only { display: none; }
@media print {
  .site-header, .site-footer, .ad-slot, .nav, .calc__panel--input,
  .breadcrumb, .hero p, .section, .result__actions, .unit-toggle { display: none !important; }
  body { background: #fff; }
  .print-only { display: block; }
  .calc { grid-template-columns: 1fr; border: none; padding: 0; background: #fff; }
  .result { border: none; padding: 0; }
  .print-head { margin-bottom: 12px; }
  .print-head .footer-brand { font-size: 18px; }
  .print-head small { color: #64748B; }
}
