/* Global, reusable component styles (unlayered to outrank Bootstrap) */
/* Width token (local). Consider moving to design-tokens.css if reused broadly */
:root { --btn-token-fixed-width: 18rem; }
/* Primary button using semantic tokens */
button.btn-primary-token,
a.btn-primary-token {
  font-size: var(--font-size-base);
  font-family: var(--font-family-sans);
  display: inline-block;
  margin: 0.5rem;
  padding: var(--space-4) var(--space-4);
  border-radius: var(--radius-round, 32px);
  background: var(--color-primary, #165C84);
  color: var(--color-surface, #ffffff);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(20, 26, 51, 0.06), 0 2px 6px rgba(20, 26, 51, 0.05));
  transition: transform 20ms ease, filter var(--transition-base, 150ms ease);
  width: var(--btn-token-fixed-width); /* ensure consistent width on wider screens */
  text-align: center;
}
.btn-primary-token:hover { background: var(--color-primary-hover, #124A69); }
.btn-primary-token:active { transform: translateY(1px); }
.btn-primary-token:focus-visible { outline: 2px solid rgba(22,92,132,0.3); outline-offset: 2px; }

/* Secondary button on neutral surface */
button.btn-secondary-token,
a.btn-secondary-token {
  font-size: var(--font-size-base);
  font-family: var(--font-family-sans);
  display: inline-block;
  margin: 0.5rem;
  padding: var(--space-4) var(--space-4);
  border-radius: var(--radius-round, 32px);
  background: var(--color-surface, #ffffff);
  color: var(--color-primary, #165C84);
  border: 1px solid var(--color-border, #DADEF2);
  text-decoration: none;
  font-weight: 600;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(20, 26, 51, 0.06), 0 2px 6px rgba(20, 26, 51, 0.05));
  width: var(--btn-token-fixed-width);
  text-align: center;
}
.btn-secondary-token:hover { background: var(--color-surface, #FAFBFE); }
.btn-secondary-token:focus-visible { outline: 2px solid rgba(22,92,132,0.25); outline-offset: 2px; }

.dropdown-item {
  font-family: var(--font-family-sans);
  font-size: var(--font-size-base);
}

/* Persistent "sample data" banner shown to logged-out visitors previewing a page.
   Stays pinned to the bottom of the viewport while they scroll the sample content. */
.sample-data-banner {
  position: fixed;
  left: 50%;
  bottom: var(--space-4, 16px);
  transform: translateX(-50%);
  z-index: 1050;
  width: calc(100% - 2rem);
  max-width: 720px;
}
.sample-data-banner__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3, 12px);
  padding: var(--space-3, 12px) var(--space-4, 16px);
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #DADEF2);
  border-left: 4px solid var(--color-primary, #165C84);
  border-radius: var(--radius-md, 12px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(20, 26, 51, 0.12));
}
.sample-data-banner__text { flex: 1 1 260px; min-width: 0; }
.sample-data-banner__title { margin: 0 0 0.15rem; }
.sample-data-banner__sub {
  margin: 0;
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-text-muted, #6c757d);
}
.sample-data-banner__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}
/* Shrink the shared token buttons so they fit comfortably in the banner. */
.sample-data-banner__actions .btn-primary-token,
.sample-data-banner__actions .btn-secondary-token {
  width: auto;
  margin: 0.25rem;
  padding: var(--space-2, 8px) var(--space-4, 16px);
}

/* Sit above the fixed mobile bottom nav (shown at <= 767px) so both stay visible. */
@media (max-width: 767px) {
  .sample-data-banner { bottom: 96px; }
}

/* On a phone this banner was taking roughly half the viewport: a column layout
   with a two-line title, a three-line explanation and two full-width stacked
   buttons, all sitting above the 80px bottom nav. It is a notice about the page,
   not the page, so on small screens it collapses to two tight rows — the claim
   that matters, and the two ways out of it.

   The long explanation is NOT removed, only taken out of the visual flow: the
   text still reaches screen readers, and it is the title that carries the thing
   a patient must not miss (these numbers are not theirs). It returns in full
   above 600px, where there is room for it. */
@media (max-width: 600px) {
  .sample-data-banner { width: calc(100% - 1rem); }
  .sample-data-banner__inner {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2, 8px);
    padding: var(--space-2, 8px) var(--space-3, 12px);
    border-left-width: 3px;
  }
  /* Centred over the two buttons below it: left-aligned, the title sat off to
     one side of a symmetrical two-button row and read as unfinished. */
  .sample-data-banner__text { flex: 0 0 auto; text-align: center; }
  .sample-data-banner__title { font-size: var(--font-size-sm, 0.875rem); margin: 0; }

  .sample-data-banner__sub {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Side by side, not stacked — two rows total instead of four. */
  .sample-data-banner__actions { flex-wrap: nowrap; gap: var(--space-2, 8px); }
  .sample-data-banner__actions .btn-primary-token,
  .sample-data-banner__actions .btn-secondary-token {
    flex: 1 1 0;
    width: auto;
    margin: 0;
    padding: var(--space-2, 8px) var(--space-2, 8px);
    font-size: var(--font-size-sm, 0.875rem);
    white-space: nowrap;
  }
}

/* Mobile: make buttons span full width for easier tapping */
@media (max-width: 600px) {
  button.btn-primary-token,
  a.btn-primary-token,
  button.btn-secondary-token,
  a.btn-secondary-token {
    display: block;              /* stack */
    width: 100%;                 /* mobile still full-width for accessibility */
    margin: var(--space-2) 0; /* vertical rhythm, no horizontal gap */
  }
}


/* ---------------------------------------------------------------------------
   Results-screen action block

   Shared by every assessment results screen (fingers, thumb, wrist, dexterity).
   The rules these screens follow:

     - exactly one primary button, and it is the genuine next step - the
       untested hand when there is one, otherwise leaving the screen;
     - the redo controls sit together as one labelled cluster, so "redo one
       hand" and "redo everything" read as one choice at two scales;
     - whatever action is not primary drops to a quiet link.

   The token buttons carry a fixed 18rem width; inside this block they fill
   their own column instead, so a screen shows one button width rather than the
   three ragged ones these stacks used to have.
   --------------------------------------------------------------------------- */
.results-actions {
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.results-actions .btn-primary-token,
.results-actions .btn-secondary-token {
  width: 100%;
  margin: 0;
}

/* A secondary action directly under the primary one, with no cluster between. */
.results-actions .results-action-secondary { margin-top: 0.75rem; }

.results-redo-group {
  margin-top: var(--space-5, 1.25rem);
  /* The label sits close under the rule on purpose: the rule and the question are one
     unit ("here ends the result, here begins the offer to redo"), and a full space-4 gap
     read as the rule belonging to the results above it instead. */
  padding-top: var(--space-2, 0.5rem);
  border-top: 1px solid var(--color-border);
}

.results-redo-label {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

/* Two hands sit side by side with the whole-assessment restart spanning
   underneath. With only one hand recorded there is no pair to form, and both
   buttons stack full width. */
.results-redo-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.5rem;
}

/* With both hands recorded, the pair fills the row and the whole-assessment restart
   spans beneath them. With one hand there are only two buttons, and they share the row
   rather than leaving a half-width button on its own. */
.results-redo-buttons--wide-last .results-redo-all { grid-column: 1 / -1; }

/* Set smaller than the primary action above them: these are corrections, not the next
   step, and at the token's full size the labels wrap inside a two-up row. */
.results-redo-buttons .btn-secondary-token {
  padding: 0.625rem 0.75rem;
  font-size: var(--font-size-sm, 0.875rem);
}

.results-quiet-link {
  display: inline-block;
  margin-top: 1rem;
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.results-quiet-link:hover { color: var(--color-primary); }

/* ---------------------------------------------------------------------------
   Results-screen utility bar

   Controls that act on the results above them - explain them, or show more of
   them - rather than navigating away. They sit directly under the results as
   one compact row, deliberately smaller than the navigation buttons below: a
   reader clicks these once or twice, not on every visit.
   --------------------------------------------------------------------------- */
.results-utility-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-4, 1rem) var(--space-5, 1.5rem);
  padding: var(--space-3, 0.75rem) 0 var(--space-4, 1rem);
}

/* Switch, not a button: "exact measurements" is a state of the results, and a
   button that renames itself ("Show" / "Hide") makes the reader work out which
   state they are currently in. */
.results-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-text, #1c2b23);
  cursor: pointer;
  user-select: none;
}

.results-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.results-switch__track {
  position: relative;
  flex: none;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: var(--color-border, #c3d0c8);
  transition: background 150ms ease;
}

.results-switch__track::after {
  content: "";
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms ease;
}

.results-switch input:checked + .results-switch__track { background: var(--color-primary, #165C84); }
.results-switch input:checked + .results-switch__track::after { transform: translateX(1rem); }
.results-switch input:focus-visible + .results-switch__track { outline: 2px solid rgba(22, 92, 132, 0.35); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .results-switch__track,
  .results-switch__track::after { transition: none; }
}
