/* ============================================================
   Bagscalculator — shared stylesheet
   Mobile-first, semantic, no UI framework.
   ============================================================ */

:root {
  --brand: #0e6b4f;          /* deep green */
  --brand-dark: #0a4a37;
  --accent: #e8590c;         /* calculate / CTA orange */
  --accent-dark: #c74a06;
  --ink: #18201c;            /* main text */
  --ink-soft: #47524b;       /* secondary text */
  --muted: #6b756f;          /* captions */
  --line: #e2e7e3;           /* borders */
  --bg: #f5f7f6;             /* page background */
  --card: #ffffff;
  --result-bg: #0f2e24;      /* dark result panel */
  --result-text: #eafff5;
  --link: #0b6b4d;
  --link-hover: #e8590c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 8px 24px rgba(16, 24, 20, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }

img, svg { max-width: 100%; height: auto; display: block; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: #fff; padding: 8px 14px; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 60px; flex-wrap: wrap; padding: 10px 16px;
  max-width: 1080px; margin: 0 auto;
}
.logo {
  font-size: 1.28rem; font-weight: 800; letter-spacing: -.02em;
  color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.logo .logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 1rem; font-weight: 800;
}
.logo span.brand-em { color: var(--brand); }

.site-nav ul {
  list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap;
}
.site-nav a {
  display: block; padding: 7px 10px; border-radius: 8px;
  color: var(--ink-soft); text-decoration: none; font-size: .92rem; font-weight: 600;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); background: #eef3f0; }
.site-nav a[aria-current="page"] { color: var(--brand); background: #e8f2ed; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  padding: 12px 0 2px; font-size: .86rem; color: var(--muted);
}
.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb li + li::before { content: "›"; color: #b6bdb8; }
.breadcrumb a { color: var(--link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------- Hero / block 1 ---------- */
.hero { padding: 28px 0 8px; }
.hero h1 {
  margin: 0 0 10px; font-size: clamp(1.7rem, 5.5vw, 2.5rem);
  line-height: 1.12; letter-spacing: -.02em;
}
.hero .subtitle {
  margin: 0; font-size: 1.05rem; color: var(--ink-soft); max-width: 62ch;
}

/* ---------- Calculator card / block 2 ---------- */
.calculator {
  margin-top: 18px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
}
.calc-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 860px) {
  .calc-grid { grid-template-columns: 1.05fr .95fr; gap: 24px; }
}

.fieldset { border: 0; margin: 0 0 14px; padding: 0; }
.fieldset legend, .field-label {
  display: block; font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft); margin-bottom: 7px;
}

/* Segmented controls */
.segmented {
  display: inline-flex; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; background: #eef2ef;
}
.segmented button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 8px 14px; font-size: .9rem; font-weight: 700; color: var(--ink-soft);
  font-family: inherit;
}
.segmented button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.segmented button + button { border-left: 1px solid var(--line); }

.segmented.small button { padding: 6px 12px; font-size: .86rem; }

/* Input rows */
.input-row { margin-bottom: 12px; }
.input-row label {
  display: block; font-size: .9rem; font-weight: 600; margin-bottom: 5px;
}
.input-row .example { font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: 6px; }
.input-wrap { position: relative; display: flex; align-items: stretch; }
.input-wrap input {
  width: 100%; font-size: 1.05rem; padding: 11px 12px;
  border: 1px solid #cdd5cf; border-radius: 9px; font-family: inherit;
  background: #fff; color: var(--ink);
}
.input-wrap input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14, 107, 79, .15);
}
.input-wrap .unit {
  display: inline-flex; align-items: center; padding: 0 12px;
  font-size: .88rem; font-weight: 700; color: var(--ink-soft);
  background: #eef2ef; border: 1px solid #cdd5cf; border-left: 0; border-radius: 0 9px 9px 0;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* Range / waste */
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--brand); }
.waste-value { font-weight: 700; color: var(--brand); min-width: 46px; text-align: right; }

.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* Results panel */
.results {
  background: var(--result-bg); color: var(--result-text);
  border-radius: var(--radius); padding: 16px;
}
.results h2 {
  margin: 0 0 4px; font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: #a9d6c2;
}
.results .results-note { margin: 0 0 12px; font-size: .82rem; color: #bfd8cd; }
.big-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-number { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 12px; }
.big-number .num { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.big-number .lbl { font-size: .76rem; color: #a9d6c2; margin-top: 3px; }

.bag-results { margin-top: 14px; }
.bag-results .bag-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #a9d6c2; margin: 0 0 6px; }
.bag-list { display: flex; flex-direction: column; gap: 8px; }
.bag-item {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px; padding: 9px 12px;
}
.bag-item .bag-size { font-size: .9rem; color: #d8ece3; }
.bag-item .bag-count { font-size: 1.15rem; font-weight: 800; color: #fff; }
.bag-item .bag-count small { font-size: .75rem; font-weight: 600; color: #a9d6c2; }

/* Formula replay (复算) */
.formula-replay {
  margin-top: 14px; background: #f4f8f6; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: .88rem; color: var(--ink-soft);
}
.formula-replay strong { color: var(--ink); }
.formula-replay code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85rem; background: #e8efe9; padding: 1px 5px; border-radius: 5px; color: #0a4a37;
}
.formula-replay .step { margin: 5px 0; }

/* ---------- Ad slot (placeholder only, reserved height) ---------- */
.ad-slot {
  min-height: 250px;
  margin: 22px 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: .78rem; background: #eef2ef;
}
.ad-slot::after { content: "Advertisement"; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Content sections ---------- */
.section { padding: 22px 0 4px; }
.section h2 {
  font-size: 1.35rem; letter-spacing: -.01em; margin: 0 0 12px;
  border-bottom: 2px solid var(--line); padding-bottom: 8px;
}
.section h3 { font-size: 1.05rem; margin: 18px 0 6px; }
.section p { margin: 0 0 12px; color: var(--ink-soft); }
.section ul, .section ol { margin: 0 0 12px; padding-left: 22px; color: var(--ink-soft); }
.section li { margin-bottom: 5px; }
.lead { font-size: 1.02rem; color: var(--ink) !important; }

/* Formula callout */
.formula-box {
  background: #fbfcfb; border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: 9px; padding: 14px 16px; margin: 12px 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .95rem; color: #0a4a37; overflow-x: auto;
}

/* ---------- Coefficient tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; background: #fff; }
table.data caption { text-align: left; font-size: .82rem; color: var(--muted); padding-bottom: 6px; }
table.data th, table.data td {
  border: 1px solid var(--line); padding: 9px 11px; text-align: left; vertical-align: top;
}
table.data thead th { background: #eef3f0; font-weight: 700; color: var(--ink); }
table.data tbody th { background: #f8faf9; font-weight: 600; color: var(--ink); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.source-note {
  font-size: .78rem; color: var(--muted); margin-top: 8px; line-height: 1.5;
}
.source-note a { color: var(--link); }
.source-note .date { color: var(--muted); font-weight: 600; }

/* ---------- FAQ ---------- */
.faq details {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  margin-bottom: 10px; overflow: hidden;
}
.faq summary {
  cursor: pointer; padding: 13px 16px; font-weight: 700; color: var(--ink);
  list-style: none; position: relative; padding-right: 40px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 1.3rem; color: var(--brand); font-weight: 700;
}
.faq details[open] summary::after { content: "–"; }
.faq .faq-body { padding: 0 16px 14px; color: var(--ink-soft); }
.faq .faq-body p { margin: 0 0 8px; }

/* ---------- Related / link cards ---------- */
.link-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .link-grid { grid-template-columns: 1fr 1fr; } }
.link-card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 15px; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.link-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.link-card .t { font-weight: 700; color: var(--ink); font-size: .98rem; }
.link-card .d { color: var(--muted); font-size: .85rem; margin-top: 3px; }

/* ---------- Footer ---------- */
.site-footer { background: #102019; color: #c7d6ce; margin-top: 40px; padding: 32px 0 26px; }
.site-footer a { color: #dbe9e1; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 640px) { .footer-grid { grid-template-columns: 1.1fr 1fr; } }
.footer-brand .logo { color: #fff; margin-bottom: 8px; }
.footer-brand p { margin: 6px 0 0; font-size: .86rem; color: #9fb3a8; max-width: 40ch; }
.footer-cols h3 {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: #8fa89c; margin: 0 0 12px;
}
.footer-cols ul { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 28px; }
.footer-cols li { margin-bottom: 9px; break-inside: avoid; }
.footer-cols a { font-size: .92rem; }
.footer-bottom {
  border-top: 1px solid #253a30; margin-top: 24px; padding-top: 18px;
  font-size: .8rem; color: #82968b; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
}
.footer-bottom a { color: #9fb3a8; }

/* ---------- New badge ---------- */
.badge-new {
  display: inline-block; background: var(--accent); color: #fff; font-size: .68rem;
  font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (min-width: 860px) {
  .hero { padding: 36px 0 10px; }
  .calculator { padding: 22px; }
}
