/* @smartfact/bench-ui analytics (0.4.2): the one source of the own-shell tools' analytics choice
   styles. PrintBench, ScannerBench, CardBench and CountBench add their choice from
   public/analytics/client.js as #analytics-controls; AnalyticsChoiceSlot puts it right after the
   tool's header and AnalyticsSettingsSlot puts "Analytics settings" inside its footer. Then it
   behaves like BenchShell's choice: fixed over the foot of a wide screen, in the page and compact
   on a phone (so it never covers a step's main button), with Accept and Reject alike and side by
   side. Every rule is scoped to #analytics-controls or an sb-analytics- class, and it uses
   suite.css's colour tokens. It changes nothing the client sends or stores. */

#analytics-controls [hidden] {
  display: none;
}
#analytics-controls {
  color: var(--sb-ink, #193e34);
  font-size: 1rem;
  line-height: 1.5;
}

/* The choice. Wide screens: over the foot of the page, beside the content, under the suite
   drawer (z-index 20). */
#analytics-controls .analytics-banner {
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: 16px;
  box-sizing: border-box;
  width: min(34rem, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: 0;
  padding: 18px 20px;
  overflow-y: auto;
  border: 1px solid var(--sb-line, #cdd8cf);
  border-radius: 10px;
  background: #fbfcf8;
  box-shadow: 0 10px 30px rgb(25 62 52 / 18%);
}
#analytics-controls .analytics-banner h2 {
  margin: 0 0 8px;
  color: inherit;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: normal;
}
#analytics-controls .analytics-banner p {
  margin: 0 0 8px;
  color: var(--sb-muted, #4f6158);
  font-size: 0.92rem;
}
#analytics-controls .analytics-banner a {
  color: var(--sb-ink, #193e34);
  text-decoration: underline;
  text-underline-offset: 3px;
}
#analytics-controls .analytics-banner .sb-analytics-short {
  display: none;
}
/* Accept and Reject alike, the same size, neither filled; Keep current choice quieter. */
#analytics-controls .analytics-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  margin: 10px 0 0;
}
#analytics-controls .analytics-actions > button {
  min-height: 44px;
  margin: 0;
  padding: 9px 16px;
  border: 1px solid var(--sb-ink, #193e34);
  border-radius: 8px;
  background: var(--sb-paper, #ffffff);
  color: var(--sb-ink, #193e34);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
}
#analytics-controls .analytics-actions > button:hover {
  background: var(--sb-soft, #edf2e4);
}
#analytics-controls .analytics-actions > button[data-close] {
  border-color: transparent;
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#analytics-controls button:focus-visible,
#analytics-controls a:focus-visible,
.sb-analytics-settings button:focus-visible {
  outline: 3px solid var(--sb-focus, #9b6816);
  outline-offset: 2px;
}
#analytics-controls .analytics-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#analytics-controls .sb-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Analytics settings: inside the tool's footer, a text button like the footer's links. Without
   AnalyticsSettingsSlot it stays at the end of the page, as before. */
.sb-analytics-settings .analytics-settings {
  display: inline;
}
.sb-analytics-settings .analytics-settings button,
#analytics-controls > .analytics-settings button {
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
#analytics-controls > .analytics-settings {
  padding: 16px 24px;
  text-align: center;
}

@media (min-width: 601px) {
  /* While the wide choice shows, focus scrolls clear of it. */
  html:has(#analytics-controls .analytics-banner:not([hidden])) {
    scroll-padding-bottom: 17rem;
  }
}

/* Phones: in the page where AnalyticsChoiceSlot puts it (right after the header), so it never
   covers the tool or a step's main button, compact: the heading runs into the phone wording, and
   Accept and Reject stay side by side as equals. */
@media (max-width: 600px) {
  #analytics-controls .analytics-banner {
    position: static;
    width: auto;
    max-height: none;
    margin: 10px 0 0;
    padding: 10px 12px;
    overflow: visible;
    box-shadow: none;
    font-size: 0.86rem;
    line-height: 1.45;
  }
  #analytics-controls .analytics-banner h2 {
    display: inline;
    margin: 0 0.3em 0 0;
    font-size: inherit;
    line-height: inherit;
  }
  #analytics-controls .analytics-banner:has(.sb-analytics-short) > p {
    display: none;
  }
  #analytics-controls .analytics-banner > p.sb-analytics-short {
    display: inline;
    margin: 0;
    color: inherit;
    font-size: inherit;
  }
  #analytics-controls .analytics-actions {
    margin-top: 8px;
  }
  #analytics-controls .analytics-actions > button {
    flex: 1 1 0;
    padding-right: 8px;
    padding-left: 8px;
  }
  #analytics-controls .analytics-actions > button[data-close] {
    flex-basis: 100%;
  }
}
@media print {
  #analytics-controls,
  .sb-analytics-slot {
    display: none;
  }
}
