/* Shared foundations for the Meridian light interface. Page compositions live in their own stylesheets. */

:root {
  /* 表面 */
  --bg: #ffffff;
  --bg-soft: #f6f4ef;
  --bg-dark: #0c0f11;
  --bg-dark-2: #12171a;

  /* 墨色 */
  --ink: #1b211d;
  --ink-2: #434d45;
  --muted: #5b645c;
  --faint: #9ba1a6;

  /* 线 */
  --line: #dadcd3;
  --line-2: #bfc7ba;
  --line-dark: #232a2e;

  /* 强调：深松绿 */
  --accent: #234639;
  --accent-2: #153429;
  --accent-soft: #e9f0ed;

  /* 状态 */
  --ok: #2a6b4f;
  --err: #a33a2a;
  --err-soft: #f6ecea;

  /* 字体 */
  --sans: "Inter var", "Segoe UI Variable Text", "Segoe UI", -apple-system,
    BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas,
    "Liberation Mono", monospace;

  --display-serif: "Meridian Serif", "Songti SC", "Noto Serif CJK SC", SimSun, serif;

  /* 字号 */
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-15: 15px;
  --fs-17: 17px;
  --fs-20: 20px;
  --fs-26: 26px;
  --fs-32: 32px;
  --fs-42: 42px;

  /* 间距（8pt） */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --s9: 96px;

  /* 容器 */
  --wrap: 1200px;
  --gut: clamp(20px, 5vw, 48px);
  --sec-y: clamp(56px, 6.6vw, 104px);

  --r: 8px;
  --r-pill: 999px;
  --h-ctl: 44px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-fast: 160ms;
  --motion-enter: 360ms;

  --z-hdr: 60;
  --z-drawer: 55;
  --z-float: 50;
}

/* Base element defaults. */
*,
*::before,
*::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-15);
  line-height: 1.6;
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 500; letter-spacing: 0; line-height: 1.2; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; }
::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Shared line icons. */
.ico {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Typography and the shared page container. */
.h2 { font-size: clamp(24px, 2.2vw, 28px); line-height: 1.2; letter-spacing: 0; }

.lead {
  font-size: var(--fs-17);
  line-height: 1.62;
  color: var(--ink-2);
  max-width: 58ch;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gut);
}
.sec { padding-block: var(--sec-y); border-top: 1px solid var(--line); }
.sec--first { border-top: 0; }

/* Buttons and action rows. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--h-ctl);
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: var(--r);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-15);
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}
.btn:hover { background: #000; border-color: #000; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn .ico { width: 18px; height: 18px; }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.btn--ghost:hover { background: var(--bg-soft); border-color: var(--ink); }

.btn--accent { background: var(--accent); border-color: var(--accent); }
.btn--accent:hover { background: var(--accent-2); border-color: var(--accent-2); }

.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }

.btnrow { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }

/* Header and responsive navigation. */
.hdr {
  position: sticky;
  top: 0;
  z-index: var(--z-hdr);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.hdr__row {
  display: flex;
  align-items: center;
  gap: var(--s5);
  min-height: 64px;
}
.hdr--stuck { border-bottom-color: var(--line-2); }

.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand__mark {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--ink);
}

.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.nav__link {
  position: relative;
  padding: 8px 12px;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink-2);
  transition: color var(--motion-fast) var(--ease-out);
}
.nav__link:hover { color: var(--ink); }
.nav__link[aria-current] { color: var(--ink); font-weight: 600; }
.nav__link[aria-current]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.hdr__actions { display: flex; align-items: center; gap: var(--s3); }
.burger {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
}
.burger:hover { border-color: var(--ink); }

.drawer {
  position: fixed;
  inset: 64px 0 0;
  z-index: var(--z-drawer);
  background: var(--bg);
  overflow-y: auto;
  display: none;
  border-top: 1px solid var(--line);
}
body.nav-open .drawer { display: block; }
body.nav-open { overflow: hidden; }
.drawer__inner { padding: var(--s5) var(--gut) var(--s8); display: grid; gap: var(--s5); }
.drawer__nav { display: grid; border-top: 1px solid var(--line); }
.drawer__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-17);
  font-weight: 500;
}
.drawer__foot { display: grid; gap: var(--s3); }

/* Form controls, step navigation and generated receipts. */
.fcard {
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--bg);
  overflow: hidden;
}
.fcard__hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.fcard__hd h3 { font-size: var(--fs-17); }
.fcard__body { padding: var(--s5); }

.fsteps { display: flex; align-items: center; gap: var(--s3); }
.fstep {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-11);
  letter-spacing: 0;
  color: var(--faint);
}
.fstep__n {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
}
.fstep--on { color: var(--ink); }
.fstep--on .fstep__n { border-color: var(--accent); color: var(--accent); }
.fstep--done .fstep__n { background: var(--accent); border-color: var(--accent); color: #fff; }

.fs { display: none; }
.fs--on { display: block; animation: fade var(--motion-enter) var(--ease-out) both; }

.field { margin-top: var(--s4); }
.field:first-child { margin-top: 0; }
.field > label {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 8px;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink);
}
.field .hint { margin-top: 4px; font-size: var(--fs-12); color: var(--muted); }
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--h-ctl);
  padding: 10px 12px;
  font-family: inherit;
  font-size: var(--fs-15);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  transition: border-color var(--motion-fast) var(--ease-out);
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23767d84' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.field textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
.field input::placeholder,
.field textarea::placeholder { color: var(--faint); }
.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--ink-2); }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
.field--err input,
.field--err select,
.field--err textarea { border-color: var(--err); box-shadow: 0 0 0 1px var(--err); }
.field__err { display: none; margin-top: 4px; font-size: var(--fs-12); color: var(--err); }
.field--err .field__err { display: block; }

.frow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.frow > .field { margin-top: var(--s4); }

.consent {
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
  margin-top: var(--s4);
  font-size: var(--fs-12);
  color: var(--muted);
  line-height: 1.55;
}
.consent input { width: 15px; height: 15px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.consent a { color: var(--ink-2); border-bottom: 1px solid var(--line-2); }
.consent a:hover { color: var(--accent); border-color: var(--accent); }

.fnav { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s5); }
.fnav .btn { flex: 1; }
.fnav__back {
  flex: none;
  min-height: var(--h-ctl);
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: var(--fs-13);
  color: var(--muted);
  cursor: pointer;
}
.fnav__back:hover { color: var(--ink); border-color: var(--ink-2); }

.receipt { display: grid; gap: var(--s4); }

.receipt__id {
  font-family: var(--mono);
  font-size: var(--fs-26);
  letter-spacing: 0.02em;
  color: var(--ink);
}

/* Footer foundations. */
.ftr { background: var(--bg-dark); color: #8f989d; font-size: var(--fs-13); padding-block: var(--s7) var(--s5); border-top: 1px solid var(--line-dark); }
.ftr a { color: #a4adb2; transition: color var(--motion-fast) var(--ease-out); }
.ftr a:hover { color: #fff; }

/* Not-found page. */
.errpage { display: grid; justify-items: start; gap: var(--s5); padding-block: clamp(56px, 8vw, 120px); }
.errpage__code {
  font-family: var(--mono);
  font-size: clamp(64px, 11vw, 120px);
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--line-2);
}

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.no-motion *,
.no-motion *::before,
.no-motion *::after {
  animation: none !important;
  transition: none !important;
}

@media (max-width: 1120px) {
  .nav { display: none; }
  .burger { display: inline-flex; margin-left: auto; }
  .hdr__actions { margin-left: 0; }
}

@media (max-width: 760px) {
  :root { --sec-y: 56px; }
  .hdr__row { min-height: 58px; gap: var(--s3); }
  .hdr__actions .btn { display: none; }
  .drawer { inset: 58px 0 0; }
  .frow { grid-template-columns: 1fr; gap: 0; }
  .fnav { flex-wrap: wrap; }
  .fnav .btn { flex: 1 1 100%; }
  .fnav__back { width: 100%; }
}

@media (max-width: 420px) {
  :root { --gut: 16px; }
  .btnrow .btn { width: 100%; }
  .fcard__body { padding: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .hdr, .drawer { display: none !important; }
  body { background: #fff; }
}
