/* App layout — builds on theme.css brand tokens.
   M0: minimal shell styling; component styles arrive alongside their
   milestones. */

:root {
  /* App-level tokens (theme.css lacks a neutral grey and a text-safe amber). */
  --app-text-muted: #595959; /* ~7:1 on white */
  --app-amber-text: #8a6a00; /* "partial" outcome — dark amber, ~5.9:1 on white (brand yellow fails as text) */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  line-height: 1.5;
}

/* Global visible-focus baseline so every focusable control is covered by
   default (SPEC §9); individual components can refine but not remove it. */
:focus-visible {
  outline: 3px solid var(--dl-blue);
  outline-offset: 2px;
}

/* Site header / logo lockup */
.site-header {
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid #eee;
}
.site-header__logo {
  font-family: var(--dl-font-heading);
  font-weight: 600;
  color: var(--dl-coral);
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem);
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.screen h1 {
  margin: 0;
  outline: none;
}

.screen__meta {
  color: var(--app-text-muted);
  font-weight: 600;
  margin: 0;
}

.screen__lead {
  margin: 0;
}

.screen__summary {
  margin: 0;
  color: var(--app-text-muted);
}
.screen__notice {
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--app-amber-text) 10%, var(--dl-white));
  color: var(--app-amber-text);
  font-size: 0.9rem;
}

.screen h2 {
  margin: 0.5rem 0 0.25rem;
}

/* Type legend + how-it-works */
.legend__list,
.howto__list {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Action buttons row */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.dl-btn {
  align-self: flex-start;
  min-height: 44px; /* touch target aim (SPEC §9) */
}

.app__loading {
  color: var(--app-text-muted);
}

.screen--error h1 {
  color: var(--dl-magenta);
}

/* ===================== Quiz screen ===================== */
.quiz__title {
  font-size: var(--dl-fs-subhead);
  margin: 0 0 1rem;
}

.quiz {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.quiz__main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.quiz__progress {
  margin: 0;
  color: var(--app-text-muted);
  font-weight: 600;
}

/* Question panel */
.panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 1.25rem;
}
.panel__scenario-wrap {
  background: var(--dl-bg-featured);
  color: var(--dl-text-on-dark);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.panel__scenario {
  margin: 0;
}
.panel__meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.panel__meta {
  margin: 0;
  color: var(--app-text-muted);
  font-weight: 600;
}
.panel__badge {
  flex: none;
  /* Override the default .dl-tag (teal-on-teal ~3.2:1) with a light tint so the
     small badge text clears AA (SPEC §8). */
  background: #e3f1f5;
  color: var(--dl-teal-35);
}
.panel__prompt {
  margin: 0;
  outline: none;
}
.panel__answer {
  margin-top: 0.25rem;
}

/* ---- Answer widgets ---- */
.choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
}
.choice:hover {
  border-color: var(--dl-teal);
}
.choice__input {
  margin-top: 0.15rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--dl-teal);
  flex: none;
}
.choice__label {
  line-height: 1.4;
}

/* Grouping / matching: pool + bins, click-to-place */
.pickplace {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.pickplace__hint {
  margin: 0;
  color: var(--app-text-muted);
  font-size: 0.9rem;
}
/* Unplaced pool for grouping: loose chips, no box or label */
.pool {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pool__item {
  display: flex;
}
.bins {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
}
.bin {
  flex: 1 1 12rem;
  min-width: 0;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
/* Grouping group boxes are drop targets — the whole box is clickable */
.bins .bin {
  cursor: pointer;
}
.bins .bin:hover {
  border-color: var(--dl-teal);
}
/* Group title: centered plain text, no dashed box (the outer box is the target) */
.bins .bin__target {
  text-align: center;
  border: none;
  background: transparent;
}
.bin__target {
  width: 100%;
  text-align: left;
  font-weight: 600;
  min-height: 44px;
  padding: 0.4rem 0.6rem;
  border: 1px dashed #b5b5b5;
  border-radius: 8px;
  background: var(--dl-white);
  font-family: inherit;
  cursor: pointer;
}
.bin__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 1.75rem;
}
.chip {
  min-height: 44px;
  padding: 0.4rem 0.8rem;
  border: 1px solid #bbb;
  border-radius: 8px; /* boxy, matching the group target boxes */
  background: var(--dl-white);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.chip--selected {
  /* selection shown with the same teal as the scenario banner (--dl-bg-featured)
     + a tint derived from it (no bold, so the text doesn't reflow) */
  border-color: var(--dl-teal);
  box-shadow: inset 0 0 0 2px var(--dl-teal);
  background: color-mix(in srgb, var(--dl-teal) 12%, var(--dl-white));
}
/* Placed chip with a corner × (overlaid, no box of its own) */
.placed {
  position: relative;
  display: inline-flex;
}
.placed .chip {
  padding-right: 1.6rem; /* room so text clears the corner × */
}
.chip__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--app-text-muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.chip__remove:hover {
  color: var(--dl-magenta);
  background: color-mix(in srgb, var(--dl-magenta) 10%, var(--dl-white));
}
.chip__remove:focus-visible {
  outline-offset: -2px; /* keep the ring inside the chip bounds, not clipped */
}

/* Matching: two columns (items | options) */
.match {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}
.match__col {
  flex: 1 1 14rem;
  min-width: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.match__row {
  display: block;
}
.match__holder {
  position: relative;
  display: block;
}
.match__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0.6rem;
  border: 1px solid #bbb;
  border-radius: 8px;
  background: var(--dl-white);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.match__holder .match__item {
  padding-right: 1.7rem; /* room for the corner × */
}
.match__item--selected {
  border-color: var(--dl-teal);
  box-shadow: inset 0 0 0 2px var(--dl-teal);
  background: color-mix(in srgb, var(--dl-teal) 12%, var(--dl-white));
}
.match__num {
  flex: none;
  min-width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--dl-teal);
  color: var(--dl-white);
  font-size: 0.8rem;
  font-weight: 600;
}
.match__label {
  flex: 1 1 auto;
  line-height: 1.4;
}

/* Ordering: up/down list */
.ordering {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  counter-reset: none;
}
.ordering__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 8px;
}
.ordering__pos {
  flex: none;
  min-width: 1.5rem;
  font-weight: 600;
  color: var(--dl-teal);
}
.ordering__label {
  flex: 1 1 auto;
  line-height: 1.4;
}
.ordering__btn {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #bbb;
  border-radius: 8px;
  background: var(--dl-white);
  font-size: 1.1rem;
  cursor: pointer;
}
.ordering__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.controls .dl-btn:first-child {
  margin-right: auto; /* keep Back on the left; the forward action sits on the right */
}
.dl-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Navigator — compact horizontal bar across the top. Small buttons + tight
   spacing so all questions fit without horizontal scrolling; wraps to more
   rows on narrow screens. */
.navigator {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem 0.4rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid #eee;
  border-radius: 12px;
}
.navigator__group {
  flex: 1 1 0; /* groups share the full width evenly (no white space on the right) */
  min-width: 0;
}
.navigator__group + .navigator__group {
  border-left: 1px solid #eee;
  padding-left: 0.4rem;
}
.navigator__group-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0 0 0.3rem;
  color: var(--app-text-muted);
  white-space: nowrap;
}
.navigator__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap; /* last-resort wrap so buttons never overflow/clip at very narrow widths */
  gap: 0.3rem;
}
.navigator__item {
  flex: 1 1 0; /* each list item grows so its button fills the group width */
  min-width: 0;
  display: flex;
}
.nav-item {
  display: inline-flex;
  flex: 1 1 0; /* buttons stretch to fill their group's width */
  flex-direction: column; /* icon on top, number below */
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  min-width: 1.65rem; /* floor for narrow screens; buttons stretch wider on desktop */
  min-height: 2.6rem; /* ~42px tall — comfortable target + room for the stacked icon/number */
  padding: 0.25rem 0.2rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: var(--dl-white);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.15;
  cursor: pointer;
}
.nav-item--active {
  border-color: var(--dl-teal);
  font-weight: 600;
  background: color-mix(in srgb, var(--dl-teal) 12%, var(--dl-white)); /* teal tint */
  box-shadow: inset 0 0 0 2px var(--dl-teal); /* 2px ring with no layout shift */
}
.nav-item__icon {
  font-weight: 700; /* bolder glyph for legibility (status dots/shapes) */
  font-size: 1em; /* at least as large as the number so ○ / ◐ / ✓ stay distinguishable */
}
.nav-item__icon--not-answered {
  color: var(--app-text-muted);
}
.nav-item__icon--in-progress {
  color: var(--app-amber-text); /* amber ◐ — distinct from the teal answered dot and matches results "partial" */
}
.nav-item__icon--answered {
  color: var(--dl-teal);
}

/* ===================== Submit modal ===================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--dl-white);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 28rem;
  width: 100%;
  outline: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.modal__title {
  margin: 0;
}
.modal__message {
  margin: 0;
}
.modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ===================== Results screen ===================== */
.results-summary {
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.results-summary__score {
  margin: 0;
  font-family: var(--dl-font-heading);
  font-weight: 600;
  font-size: var(--dl-fs-subhead);
}
.results-summary__counts {
  margin: 0;
  color: var(--app-text-muted);
}
.results-summary__challenges {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
  color: var(--app-text-muted);
}
.results-jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
.results-jump__label {
  color: var(--app-text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.results-jump__link {
  font-size: 0.9rem;
}
.results-challenge {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
}
.results-challenge h2 {
  outline: none;
}
.results-challenge__scenario {
  margin: 0;
  background: var(--dl-bg-featured);
  color: var(--dl-text-on-dark);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
}
.rcard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid #eee;
  border-left: 4px solid #ccc;
  border-radius: 8px;
  padding: 0.85rem 1rem;
}
.rcard__prompt {
  margin: 0;
  font-weight: 600;
}
.rcard__outcome {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}
.rcard__icon {
  font-weight: 700;
}
.rcard--correct {
  border-left-color: var(--dl-teal);
}
.rcard--correct .rcard__outcome {
  color: var(--dl-teal);
}
.rcard--partial {
  border-left-color: var(--app-amber-text);
}
.rcard--partial .rcard__outcome {
  color: var(--app-amber-text);
}
.rcard--incorrect {
  border-left-color: var(--dl-magenta);
}
.rcard--incorrect .rcard__outcome {
  color: var(--dl-magenta);
}
.rcard--not-answered {
  border-left-color: var(--app-text-muted);
}
.rcard--not-answered .rcard__outcome {
  color: var(--app-text-muted);
}
.rcard__answer-title {
  margin: 0 0 0.2rem;
  font-size: 0.85rem;
  color: var(--app-text-muted);
}
.rcard__answer-list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.rcard__behavior {
  margin: 0;
  font-size: 0.85rem;
  color: var(--app-text-muted);
}

/* Accessibility helpers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--dl-teal);
  color: var(--dl-white);
  padding: 8px 12px;
  border-radius: 0 0 8px 0;
  z-index: 10;
}
.skip-link:focus {
  left: 0;
}

/* Respect reduced-motion for any transitions (e.g. the submit modal). */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
