/* ReviewStages (shared/js/review_stages.js) — the staged-reveal rail, question heading and
   Back / Next. Mobile first: the rail wraps, every button is a 44px touch target and long
   stage titles truncate (the full title stays in the accessible name and the tooltip).
   Every rule is scoped under .review-stages except the panel rule below. */

/* A listed panel the component hides must stay hidden even when the page gives it a
   display value (.card { display: flex } would otherwise beat the `hidden` attribute). */
[data-review-panel][hidden] {
  display: none !important;
}

.review-stages {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1rem;
  min-width: 0;
  color: var(--app-text, #1f2a37);
}

.review-stages[hidden] {
  display: none !important;
}

.review-stages__sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---- the rail */

.review-stages__rail {
  min-width: 0;
}

.review-stages__steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-stages__step {
  min-width: 0;
  max-width: 100%;
}

.review-stages__step-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  padding: 0.25rem 0.75rem 0.25rem 0.35rem;
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 999px;
  background: var(--app-card-bg, #ffffff);
  color: var(--app-muted, #5f6b7a);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.review-stages__step-btn:hover {
  border-color: var(--app-accent, #2a7de1);
  color: var(--app-text, #1f2a37);
}

.review-stages__step-btn:focus-visible,
.review-stages__back:focus-visible,
.review-stages__next:focus-visible {
  outline: 3px solid var(--app-accent, #2a7de1);
  outline-offset: 2px;
}

.review-stages__step-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 50%;
  background: var(--app-bg, #f5f7fb);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Narrow screens: titles shrink to a readable stub; the number always shows. */
.review-stages__step-title {
  min-width: 0;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-stages__step-btn[data-done] {
  color: var(--app-text, #1f2a37);
}

.review-stages__step-btn[data-done] .review-stages__step-num {
  border-color: var(--app-success, #2f9d58);
  color: var(--app-success, #2f9d58);
}

.review-stages__step-btn[aria-current="step"] {
  border-color: var(--app-accent, #2a7de1);
  color: var(--app-text, #1f2a37);
  font-weight: 600;
}

.review-stages__step-btn[aria-current="step"] .review-stages__step-num {
  border-color: var(--app-accent, #2a7de1);
  background: var(--app-accent, #2a7de1);
  color: var(--app-card-bg, #ffffff);
}

/* ---- the question heading (the page may restyle .review-stages__question) */

.review-stages__question {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--app-text, #1f2a37);
}

.review-stages__question:focus {
  outline: none;
}

.review-stages__question:focus-visible {
  outline: 3px solid var(--app-accent, #2a7de1);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ---- Back / Next */

.review-stages__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.review-stages__back,
.review-stages__next {
  flex: 1 1 8rem;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--app-accent, #2a7de1);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.review-stages__back {
  background: var(--app-card-bg, #ffffff);
  color: var(--app-accent-dark, #1a5fb4);
}

.review-stages__next {
  background: var(--app-accent, #2a7de1);
  color: var(--app-card-bg, #ffffff);
}

.review-stages__next:hover:not(:disabled) {
  background: var(--app-accent-dark, #1a5fb4);
  border-color: var(--app-accent-dark, #1a5fb4);
}

.review-stages__back:disabled,
.review-stages__next:disabled {
  border-color: var(--app-border, #d6dfea);
  background: var(--app-bg, #f5f7fb);
  color: var(--app-muted, #5f6b7a);
  cursor: not-allowed;
}

@media (min-width: 48rem) {
  .review-stages__step-title {
    max-width: 14rem;
  }

  .review-stages__back,
  .review-stages__next {
    flex: 0 0 auto;
  }

  .review-stages__next {
    margin-left: auto;
  }
}
