/* =========================================================================
 * Online selection sheet — /select and /select/done
 *
 * Loaded only on these two pages (via main's extraHead) rather than being
 * folded into styles.css, which every page pays for. Uses the same design
 * tokens as the rest of the site: --brand, --accent, --line, --radius.
 *
 * Mobile first. Nearly all traffic here arrives from a WeChat link on a
 * phone, so the base rules are the phone layout and the media query adds
 * the desktop two-column arrangement — not the other way round.
 * ========================================================================= */

/* Branch visibility is driven by the HTML `hidden` attribute, which the UA
   stylesheet implements as `[hidden] { display: none }` — specificity 0-1-0.
   Several classes below set an explicit `display` (.sel-field is block,
   .sel-inline is flex), which matches that specificity and, being later in
   the cascade, wins. The branch then stays on screen while selection.js has
   already disabled its inputs: visible but dead to the touch.
   Restate the rule with !important so `hidden` always beats a layout class. */
[hidden] { display: none !important; }

.sel-section { padding: 0 0 72px; }

/* Exactly two grid children: .sel-main and .sel-aside. Progress bar, flash
   messages and the form all live inside .sel-main — dropping them straight
   into the grid makes each one its own item and they start eating columns. */
.sel-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* min-width:0 stops a wide child (the structure image grid) from blowing the
   column out past its track — grid items default to min-width:auto. */
.sel-main { min-width: 0; }

/* ---------- progress -------------------------------------------------- */

.sel-progress {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  margin-bottom: 4px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.sel-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.sel-progress-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width 220ms ease-out;
}
.sel-progress-text { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.sel-progress-text b { color: var(--brand); font-weight: 600; }

/* ---------- steps ----------------------------------------------------- */

.sel-form { display: grid; gap: 28px; }

.sel-step {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px 24px;
  margin: 0;
  background: var(--bg);
}
.sel-step > legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  margin-left: -8px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.sel-step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.sel-step-hint {
  margin: 4px 0 16px;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.7;
}

/* ---------- generic field -------------------------------------------- */

.sel-field { display: block; margin-bottom: 18px; }
.sel-field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}
.sel-field > span small { font-weight: 400; color: var(--ink-3); }
.sel-field .req { color: #b91c1c; font-style: normal; }

.sel-field input[type="text"],
.sel-field input[type="tel"],
.sel-field input[type="email"],
.sel-field input[type="number"],
.sel-field select,
.sel-field textarea,
.sel-inline input,
.sel-flange-inputs input {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;              /* >=16px on iOS avoids the zoom-on-focus */
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
}
.sel-field select { background-image: none; }
.sel-field input:focus,
.sel-field select:focus,
.sel-field textarea:focus,
.sel-inline input:focus,
.sel-flange-inputs input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-3);
}
.sel-field textarea { resize: vertical; min-height: 84px; }

.sel-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.65;
}

.sel-pair, .sel-triple, .sel-range { display: grid; gap: 10px; }
.sel-pair   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sel-triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Range gets a wider third column — the unit labels ("质量浓度 wt%") are
   longer than the two numeric inputs need to be. */
.sel-range  { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); }
/* Flex column with the control pushed to the bottom, so inputs in a row stay
   on the same baseline even when one label wraps to two lines and its
   neighbour doesn't. */
.sel-pair > label, .sel-triple > label, .sel-range > label {
  display: flex;
  flex-direction: column;
  margin: 0;
}
.sel-pair > label > input,
.sel-pair > label > select,
.sel-triple > label > input,
.sel-range > label > input,
.sel-range > label > select { margin-top: auto; }

/* Direct child only. These are the "正常 / 最高 / 最低" captions that sit
   immediately inside the label; a descendant selector here also caught the
   <small>（选填）</small> nested in a field's <span>, turning it into a block
   and knocking that column's input out of alignment. */
.sel-pair > label > small,
.sel-triple > label > small,
.sel-range > label > small {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--ink-3);
}

/* Unit picker — same control styling as the other selects, just narrower
   in context. Declared here so it works inside .sel-range, .sel-inline-unit
   and anywhere else it gets reused. */
.sel-unit {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
}
.sel-unit:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-3);
}
.sel-inline-unit { display: block; margin-top: 10px; max-width: 260px; }
.sel-inline-unit small {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--ink-3);
}

.sel-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.sel-inline small { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ---------- medium quick-fill chips ----------------------------------- */

.sel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.sel-tag {
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 120ms, background 120ms, color 120ms;
}
.sel-tag:hover { border-color: var(--brand); color: var(--brand); }
.sel-tag.is-on {
  border-color: var(--brand);
  background: var(--brand-3);
  color: var(--brand-2);
}

.sel-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.sel-check input { width: 18px; height: 18px; accent-color: var(--brand); }

.sel-rule { border: 0; border-top: 1px solid var(--line); margin: 26px 0 22px; }

/* ---------- pill radio / checkbox groups ------------------------------ */

.sel-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.sel-pills-col { flex-direction: column; align-items: stretch; }
.sel-pills label { position: relative; margin: 0; cursor: pointer; }
.sel-pills input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.sel-pills span {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  transition: border-color 120ms, background 120ms, color 120ms;
}
.sel-pills input:checked + span {
  border-color: var(--brand);
  background: var(--brand-3);
  color: var(--brand-2);
  font-weight: 500;
}
.sel-pills input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-3); }
.sel-pills-sm span { padding: 6px 12px; font-size: 13px; }

/* Eight output options stacked full-width is a lot of scrolling on a phone
   and a lot of dead space on a desktop — auto-fit keeps them tidy at both
   ends without a breakpoint. */
.sel-pills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.sel-pills-grid label { display: block; }
.sel-pills-grid span { height: 100%; }
.sel-pills span small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-3);
}
.sel-pills input:checked + span small { color: var(--brand); }

/* ---------- principle cards ------------------------------------------ */

/* Equal-height cards. Grid stretches the items, but the <span> inside was a
   plain block and stayed its content's height, so a short card left a void in
   its row. Stretch the label and make the body a full-height flex column. */
.sel-choice-grid { display: grid; gap: 10px; align-items: stretch; }
.sel-choice { position: relative; margin: 0; cursor: pointer; display: flex; }
.sel-choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.sel-choice-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  /* Border width changes on select; compensate in padding so the card
     doesn't jump by 1px when the customer clicks it. */
  padding: 14px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  transition: border-color 120ms, background 120ms;
}
.sel-choice-body b {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.sel-choice-body em {
  margin-top: 2px;
  font-size: 12.5px;
  font-style: normal;
  color: var(--brand);
}
.sel-choice-body small {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.65;
}
.sel-choice input:checked + .sel-choice-body {
  border-color: var(--brand);
  border-width: 2px;
  padding: 13px 15px;
  background: var(--brand-3);
}
.sel-choice input:focus-visible + .sel-choice-body {
  box-shadow: 0 0 0 3px var(--brand-3);
}
.sel-choice-unsure .sel-choice-body { border-style: dashed; }

/* ---------- callouts -------------------------------------------------- */

.sel-callout {
  padding: 12px 14px;
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-2);
  background: var(--bg-alt);
  border-left: 3px solid var(--line-2);
  border-radius: 0;
}
.sel-callout b { font-weight: 600; color: var(--ink); }
.sel-callout-warn {
  background: #fdf6e6;
  border-left-color: var(--accent);
  color: #6b4d0f;
}
.sel-callout-warn b { color: #4a3508; }
.sel-callout-danger {
  background: #fdecec;
  border-left-color: #b91c1c;
  color: #7f1d1d;
}
.sel-callout-danger b { color: #641414; }

/* ---------- flange dimensions ---------------------------------------- */

.sel-flange {
  padding: 16px;
  margin-bottom: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
/* Standard-flange shortcut sits above the drawing — it's the path we want
   most customers to take, and the five manual fields become the fallback. */
.sel-flange-std {
  padding: 14px;
  margin-bottom: 16px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}
.sel-flange-std-head {
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}
.sel-flange-std .sel-callout { margin: 12px 0 0; }
.sel-flange-std select {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
}
.sel-flange-std select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-3);
}

.sel-flange-fig { margin: 0 0 16px; text-align: center; }
.sel-flange-fig img { max-width: 100%; height: auto; mix-blend-mode: multiply; }
.sel-flange-fig figcaption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-3);
}
.sel-flange-inputs { display: grid; gap: 12px; }
.sel-flange-inputs label { display: block; margin: 0; }
.sel-flange-inputs span {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--ink-2);
}
.sel-flange-inputs b {
  display: inline-block;
  margin-right: 4px;
  color: var(--brand);
  font-weight: 600;
}

/* ---------- velocity structure picker -------------------------------- */

.sel-struct-grid { display: grid; gap: 10px; }
.sel-struct { position: relative; margin: 0; cursor: pointer; }
.sel-struct input { position: absolute; opacity: 0; width: 0; height: 0; }
.sel-struct-body {
  display: block;
  padding: 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  transition: border-color 120ms, background 120ms, opacity 120ms;
}
.sel-struct-body img {
  display: block;
  max-width: 100%;
  max-height: 110px;
  margin: 0 auto 10px;
  mix-blend-mode: multiply;
}
.sel-struct-body b { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.sel-struct-body em {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-style: normal;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.sel-struct-body small {
  display: block;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.6;
}
.sel-struct input:checked + .sel-struct-body {
  border-color: var(--brand);
  border-width: 2px;
  padding: 13px;
  background: var(--brand-3);
}
/* Bore-based guidance: fitting structures keep full contrast, the rest
   fade but stay selectable — seeing what was ruled out is informative. */
.sel-struct.is-fit .sel-struct-body { border-color: var(--brand); }
.sel-struct.is-unfit .sel-struct-body { opacity: 0.45; }
.sel-struct.is-unfit:hover .sel-struct-body { opacity: 0.8; }

/* ---------- missing-field flash -------------------------------------- */

.is-missing input,
.is-missing select,
.is-missing textarea,
.is-missing .sel-pills span {
  border-color: #b91c1c;
}
.is-missing > span { color: #b91c1c; }

/* ---------- submit ---------------------------------------------------- */

.sel-submit { margin-top: 26px; }
.sel-submit .btn { width: 100%; justify-content: center; }
.sel-privacy {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.7;
}

.sel-aside { display: grid; gap: 12px; }

/* =========================================================================
 * Confirmation page
 * ========================================================================= */

.sel-done-section { padding: 56px 0 88px; }
.sel-done { max-width: 620px; margin: 0 auto; text-align: center; }
.sel-done-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand-3);
  color: var(--brand);
  font-size: 26px;
  line-height: 1;
}
.sel-done-title { margin: 0 0 8px; font-size: 26px; font-weight: 600; color: var(--ink); }
.sel-done-lead { margin: 0 0 28px; font-size: 15px; color: var(--ink-3); }

.sel-done-no {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.sel-done-no-label { font-size: 12px; color: var(--ink-3); }
.sel-done-no strong {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--brand);
}
.sel-copy {
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.sel-copy:hover { border-color: var(--brand); color: var(--brand); }
.sel-copy.is-done { color: var(--brand); border-color: var(--brand); background: var(--brand-3); }

.sel-done-hint {
  margin: 12px 0 32px;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.75;
}

.sel-done-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  margin-bottom: 28px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
/* The button is a flex item next to a paragraph of text, so it shrinks and
   the label breaks mid-phrase ("查看回 / 执"). Stop it shrinking and stop the
   label wrapping — the description column is the one that should reflow. */
.sel-done-card .btn { flex-shrink: 0; white-space: nowrap; }
.sel-done-card-text { min-width: 0; }
.sel-done-card-text b { display: block; font-size: 15px; font-weight: 600; color: var(--ink); }
.sel-done-card-text small {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.7;
}
.sel-done-contact { margin-bottom: 24px; text-align: left; }
.sel-done-links { font-size: 13px; color: var(--ink-3); }
.sel-done-links a { color: var(--brand); }
.sel-done-links span { margin: 0 8px; }

/* =========================================================================
 * Desktop
 * ========================================================================= */

@media (min-width: 860px) {
  .sel-wrap { grid-template-columns: minmax(0, 1fr) 280px; gap: 40px; }
  .sel-aside { position: sticky; top: 80px; }
  .sel-step { padding: 26px 28px 28px; }
  .sel-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sel-struct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sel-flange { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
  .sel-flange > .sel-step-hint { grid-column: 1 / -1; margin-bottom: 0; }
  .sel-flange-fig { margin-bottom: 0; }
  .sel-submit .btn { width: auto; }
  .sel-done-card { flex-direction: row; align-items: center; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  .sel-progress-bar i { transition: none; }
}
