/* The Intercusp Bite Aligner, /tools/bite-aligner. Loaded after home.css,
   pages.css and marketing-v2.css, whose pearl tokens (--blue, --blue-ink,
   --text, --text-muted, --surface-border, --shadow, --display, --mono) it uses.
   Built from stl-converter.css so the two tools look alike; every class is
   ba-* so nothing here reaches another page. The engine's own script sets a few
   plain class names on this page's elements (.has / .over on the drop boxes,
   .ghost on the run button, verdict v-ok / v-warn / v-bad); they are styled
   here only under .ba-main.

   Phone layout (no horizontal scroll at 360 px): grid children carry
   min-width:0 and file names wrap anywhere. */

.ba-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

/* `hidden` must win over any display a class sets (the result panel, the view). */
.ba-main [hidden] { display: none !important; }

.ba-main { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 5% 90px; }

.ba-tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ba-tool > * { min-width: 0; }

.ba-panel {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---- the two drop boxes ---- */
.ba-drops { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.ba-drop {
  display: grid; justify-items: center; align-content: center; gap: 4px; text-align: center;
  min-height: 150px; padding: 18px 12px;
  border: 2px dashed rgba(59,130,246,.45);
  border-radius: 16px;
  background: rgba(239,246,255,.75);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ba-drop:hover { border-color: var(--blue); }
.ba-drop:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ba-main .ba-drop.over { border-style: solid; border-color: var(--blue); background: rgba(219,234,254,.9); }
.ba-main .ba-drop.has { border-style: solid; border-color: #2563eb; background: #fff; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.ba-drop-icon { width: 38px; height: 38px; color: var(--blue); }
.ba-drop b { font-family: var(--display); font-weight: 700; font-size: 17px; color: var(--text); }
.ba-drop span { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }
.ba-main .ba-drop.has span { color: var(--text); font-weight: 600; }
.ba-drop em { font-style: normal; font-size: 12px; color: var(--text-muted); }
.ba-main .ba-drop.has em { display: none; }

.ba-private {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 14px; padding: 12px 14px;
  border-radius: 12px;
  background: rgba(22,163,74,.08);
  border: 1px solid rgba(22,163,74,.25);
  color: #14532d; font-size: 14px; line-height: 1.5;
}
.ba-private svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: #15803d; }

/* ---- check mode ---- */
.ba-label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.ba-label b { color: var(--text); }
.ba-modes { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.ba-modes legend { padding: 0; margin-bottom: 8px; }
.ba-mode {
  display: flex; gap: 10px; align-items: flex-start; min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(200,210,225,.95); border-radius: 12px;
  background: #fff; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.ba-mode:hover { border-color: var(--blue); }
.ba-mode:has(input:checked) { border-color: #2563eb; background: #eff6ff; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.ba-mode:has(input:disabled) { cursor: default; opacity: .7; }
.ba-mode input { margin: 3px 0 0; flex: none; accent-color: #2563eb; }
.ba-mode b { font-family: var(--display); font-weight: 700; color: var(--text); }
.ba-mode i { font-style: normal; font-size: 13px; color: var(--text-muted); margin-left: 4px; }
.ba-mode small { display: block; margin-top: 3px; font-size: 13px; line-height: 1.45; color: var(--text-muted); }

/* ---- power and run ---- */
.ba-run-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-top: 18px; }
.ba-power { flex: 1 1 220px; display: grid; gap: 6px; min-width: 0; }
.ba-power input[type=range] { width: 100%; accent-color: #2563eb; }
.ba-hint { margin-top: 10px; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.ba-bar { height: 8px; margin-top: 12px; border-radius: 4px; background: rgba(15,23,42,.08); overflow: hidden; }
.ba-bar > div { height: 100%; width: 0; background: #2563eb; transition: width .3s; }
.ba-status { margin-top: 8px; font-size: 14px; font-weight: 600; color: var(--text); min-height: 1.5em; overflow-wrap: anywhere; }
.ba-status-error { color: #b91c1c; }
.ba-build { margin-top: 6px; font-family: var(--mono); font-size: 11px; color: var(--text-muted); }

/* ---- buttons (AA colours as on the converter: #2563eb, hover #1d4ed8) ---- */
.ba-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 10px 18px;
  border-radius: 10px; border: 1px solid rgba(15,23,42,.14);
  background: #fff; color: var(--text);
  font-family: var(--display); font-weight: 600; font-size: 14px; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
}
.ba-btn:hover:not(:disabled) { border-color: #2563eb; }
.ba-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ba-btn:disabled { opacity: .55; cursor: default; }
.ba-btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; box-shadow: 0 6px 18px rgba(37,99,235,.26); }
.ba-btn-primary:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; transform: translateY(-1px); }
/* While solving the run button reads "Cancel" and the engine adds .ghost. */
.ba-main .ba-run.ghost { background: #fff; color: #1d4ed8; border-color: #2563eb; box-shadow: none; }
.ba-main .ba-run.ghost:hover:not(:disabled) { background: #eff6ff; transform: none; }
.ba-run { min-width: 130px; }

/* ---- result ---- */
.ba-result { position: sticky; top: 84px; }
.ba-result-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.ba-empty {
  display: grid; place-items: center; text-align: center;
  aspect-ratio: 4 / 3; padding: 24px;
  border-radius: 14px; border: 1px solid rgba(200,210,225,.8);
  background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #eef3fa 55%, #dfe7f2 100%);
  color: var(--text-muted); font-size: 14px; line-height: 1.55;
}
.ba-main .verdict + #viewWrap { margin-top: 12px; }

.ba-main .verdict { border-radius: 12px; padding: 12px 14px; font-family: var(--display); font-weight: 700; font-size: 16px; line-height: 1.35; }
.ba-main .verdict small { display: block; margin-top: 3px; font-family: var(--font); font-weight: 400; font-size: 14px; }
.ba-main .v-ok { background: rgba(22,163,74,.10); color: #14532d; border: 1px solid rgba(22,163,74,.28); }
.ba-main .v-warn { background: rgba(245,158,11,.13); color: #78350f; border: 1px solid rgba(245,158,11,.35); }
.ba-main .v-bad { background: rgba(220,38,38,.09); color: #991b1b; border: 1px solid rgba(220,38,38,.3); }

.ba-viewer {
  position: relative; overflow: hidden;
  width: 100%; aspect-ratio: 4 / 3;
  border-radius: 14px; border: 1px solid rgba(200,210,225,.8);
  background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #eef3fa 55%, #dfe7f2 100%);
}
.ba-viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
/* Under the view: the before / after switch (after a result) and the
   upper / lower checkboxes. */
.ba-view-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-top: 10px; }
.ba-switch { display: inline-flex; padding: 3px; border-radius: 10px; background: rgba(15,23,42,.06); }
.ba-switch button {
  border: 0; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: 13px; color: var(--text-muted);
}
.ba-switch button[aria-pressed="true"] { background: #fff; color: #1e40af; box-shadow: 0 1px 3px rgba(15,23,42,.15); }
.ba-switch button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.ba-view-note { margin-top: 8px; font-size: 14px; font-weight: 600; color: var(--text); }
#viewWrap .ba-hint { margin-top: 2px; }
.ba-toggles { display: flex; gap: 18px; flex-wrap: wrap; }
.ba-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); cursor: pointer; }
.ba-check input { accent-color: #2563eb; }
/* The contact map's key: the color scale the scans are painted with (overlap on
   the left, touching, gap on the right), its labels in two short lines, then the
   numbers. The strip's gradient and the label positions come from the script. */
.ba-ckey { margin-top: 12px; }
.ba-ckey-scale { height: 12px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(15,23,42,.08); }
.ba-ckey-ticks { position: relative; height: 32px; margin-top: 4px; font-size: 12px; line-height: 1.3; color: var(--text-muted); }
.ba-ckey-ticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; text-align: center; }
.ba-ckey-ticks span:first-child { transform: none; text-align: left; }
.ba-ckey-ticks span:last-child { transform: translateX(-100%); text-align: right; }
.ba-ckey-text { margin-top: 6px; font-size: 14px; line-height: 1.5; color: var(--text); }
/* Marks: pick a kind, click the scan, re-seat. The swatches are the colors the
   marks are painted with (app.js MARK_COL). */
.ba-marks { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(15,23,42,.08); }
.ba-marks-title { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--text); }
.ba-marks-title span { display: block; margin-top: 2px; font-size: 13.5px; font-weight: 400; color: var(--text-muted); }
.ba-marks-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ba-mark {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid rgba(15,23,42,.14); background: #fff; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600;
}
.ba-mark[aria-pressed="true"] { border-color: #2563eb; box-shadow: inset 0 0 0 1px #2563eb; background: #eff6ff; color: #1e40af; }
.ba-mark:disabled { opacity: .5; cursor: default; }
.ba-mark:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.ba-mark-plain { font-weight: 500; color: var(--text-muted); }
.ba-sw { display: inline-block; width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(15,23,42,.3); }
.ba-sw-touch { background: #7c3aed; }
.ba-brush { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-muted); }
.ba-brush select { font: inherit; padding: 5px 6px; border-radius: 8px; border: 1px solid rgba(15,23,42,.14); background: #fff; color: var(--text); }
.ba-marks-note { margin: 10px 0; font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-line; }
#view.marking { cursor: crosshair; }

/* "What the aligner did": plain steps, a small check before each; the last
   line (mode and time) is .meta, muted and without a check. */
.ba-steps-title { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid rgba(15,23,42,.08); font-size: 15px; font-weight: 700; color: var(--text); }
.ba-steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; font-size: 14px; line-height: 1.5; color: var(--text); }
.ba-steps li { position: relative; padding-left: 24px; overflow-wrap: anywhere; }
.ba-steps li::before {
  content: ""; position: absolute; left: 2px; top: 5px; width: 12px; height: 7px;
  border-left: 2px solid #2563eb; border-bottom: 2px solid #2563eb; transform: rotate(-45deg);
}
.ba-steps li.meta { padding-left: 0; font-size: 13px; color: var(--text-muted); }
.ba-steps li.meta::before { display: none; }
.ba-downloads { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---- copyright notice under the tool ---- */
.ba-legal { position: relative; z-index: 1; max-width: 760px; margin: 18px auto 0; text-align: center; font-size: 12.5px; line-height: 1.55; color: var(--text-muted); }
.ba-legal a { color: #1d4ed8; }

/* ---- FAQ ---- */
.ba-faq { position: relative; z-index: 1; max-width: 760px; margin: 70px auto 0; }
.ba-faq h2, .ba-cta h2 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 800; color: var(--text); margin: 6px 0 20px; }
.ba-faq .pg-eyebrow, .ba-cta .pg-eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--blue-ink); }
.ba-faq-item { background: rgba(255,255,255,.92); border: 1px solid var(--surface-border); border-radius: 14px; box-shadow: 0 4px 14px rgba(15,23,42,.05); }
.ba-faq-item + .ba-faq-item { margin-top: 10px; }
.ba-faq-item summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 18px; cursor: pointer; list-style: none;
  font-weight: 600; color: var(--text);
}
.ba-faq-item summary::-webkit-details-marker { display: none; }
.ba-faq-item summary::after { content: "+"; flex: none; font-size: 22px; line-height: 1; color: var(--blue-ink); }
.ba-faq-item[open] summary::after { content: "\2212"; }
.ba-faq-item summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 14px; }
.ba-faq-body { padding: 0 18px 16px; color: var(--text-muted); line-height: 1.65; }
.ba-faq-body p + p { margin-top: 10px; }
.ba-faq-body strong { color: var(--text); }

/* ---- call to action ---- */
.ba-cta {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: center;
  margin: 60px auto 0; padding: 34px 36px;
  border-radius: 22px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
}
.ba-cta h2 { margin-bottom: 12px; }
.ba-cta p { color: var(--text-muted); line-height: 1.65; max-width: 62ch; }
.ba-cta-actions { display: flex; flex-direction: column; gap: 12px; }
.ba-cta-actions a { justify-content: center; }
.ba-cta .hp-btn-primary { background: #2563eb; box-shadow: 0 0 20px rgba(37,99,235,.26); }
.ba-cta .hp-btn-primary:hover { background: #1d4ed8; }

@media (max-width: 960px) {
  .ba-tool { grid-template-columns: minmax(0, 1fr); }
  .ba-result { position: relative; top: auto; }
  .ba-cta { grid-template-columns: minmax(0, 1fr); }
  .ba-cta-actions { flex-direction: row; flex-wrap: wrap; }
}

@media (max-width: 600px) {
  .ba-main { padding: 0 16px 70px; }
  .ba-panel { padding: 18px 16px; border-radius: 18px; }
  .ba-modes { grid-template-columns: minmax(0, 1fr); }
  .ba-run-row .ba-run { flex: 1 1 100%; }
  .ba-cta { padding: 26px 20px; }
  .ba-cta-actions a { flex: 1 1 100%; }
}

@media (max-width: 380px) {
  .ba-drops { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .ba-btn, .ba-drop, .ba-mode, .ba-bar > div { transition: none; }
}
