/* Facilitator Portal onboarding (PR 2c): the school picker. */
.portal-step {
  border-top: 1px solid var(--color-button-secondary);
  margin-top: var(--spacing-base);
  padding-top: var(--spacing-small);
}

.portal-step__form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-small);
  margin: var(--spacing-small) 0;
}

.portal-step__form label {
  flex-basis: 100%;
  font-weight: 700;
}

/* Fields include their padding and border in their width and may shrink
   below 16rem, so they stay inside the card on a phone. */
.portal-step__form .form__input {
  box-sizing: border-box;
  flex: 1 1 16rem;
  max-width: 100%;
  min-width: 0;
}

.portal-step__change {
  margin-left: var(--spacing-small);
}

.portal-step__hint {
  font-size: 0.9em;
}

.portal-choices {
  list-style: none;
  margin: var(--spacing-small) 0;
  padding: 0;
}

.portal-choices li {
  margin-bottom: var(--spacing-small);
}

.portal-choices__button {
  background: none;
  border: 1px solid currentcolor;
  border-radius: 0.5rem;
  cursor: pointer;
  font: inherit;
  padding: var(--spacing-small);
  text-align: left;
  width: 100%;
}

.portal-choices__button:hover,
.portal-choices__button:focus-visible {
  background-color: var(--color-button-secondary);
}

.portal-suggestions {
  border-left: 4px solid var(--color-button);
  margin: var(--spacing-small) 0;
  padding-left: var(--spacing-small);
}

/* "Did you mean one of these?" (PR 6 polish): a box of its own, with its
   matches and "None of these" inside, and clear space before the form so the
   two never read as one group. */
.portal-suggestions--matches {
  border: 2px solid var(--color-button);
  border-radius: 0.5rem;
  margin: var(--spacing-base) 0 var(--spacing-large);
  padding: var(--spacing-base);
}

.portal-suggestions--matches h3 {
  margin-top: 0;
}

.portal-suggestions__none {
  color: var(--color-button);
  cursor: pointer;
  font: inherit;
  padding: var(--spacing-small) 0;
  text-decoration: underline;
}

.portal-suggestions__none:hover,
.portal-suggestions__none:focus-visible {
  text-decoration-thickness: 2px;
}

.portal-step__kinds {
  border: none;
  flex-basis: 100%;
  margin: 0;
  padding: 0;
}

.portal-step__kinds legend {
  font-weight: 700;
  margin-bottom: var(--spacing-small);
}

/* Each radio button beside its label; a long label wraps beside it. */
.portal-step__kinds div {
  align-items: baseline;
  display: flex;
  gap: var(--spacing-small);
  margin-bottom: var(--spacing-small);
}

.portal-step__kinds input[type="radio"] {
  flex: none;
  margin: 0;
}

.portal-step__form .portal-step__kinds label {
  flex: 1 1 auto;
  font-weight: normal;
}

/* Onboarding step 2: the program acknowledgment fills the form's width. */
.portal-step__acknowledgment {
  box-sizing: border-box;
  flex-basis: 100%;
  max-width: 100%;
}

/* The home page's "Unlock Modules 1–8" card (docs/decisions/22). */
.portal-card {
  border: 2px solid var(--color-button-secondary);
  border-radius: 0.5rem;
  margin: var(--spacing-small) 0;
  padding: var(--spacing-base);
}

.portal-card h3 {
  margin-top: 0;
}

/* Sign out, at the foot of the pages a signed-in user lands on (PR 2h). */
.sign-out {
  margin-top: var(--spacing-base);
}

/* A module as teachers see it (PR 3a, docs/decisions/24): the episode as a
   subtitle, and the lesson activity, SEL topic and foods as labelled lines. */
.portal__module-episode {
  font-style: italic;
  margin-top: 0;
}

.portal__module-summary {
  margin: var(--spacing-small) 0;
}

.portal__module-summary div {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.5em;
}

.portal__module-summary dt {
  font-weight: 700;
}

.portal__module-summary dt::after {
  content: ":";
}

.portal__module-summary dd {
  margin: 0;
}

.portal__module-tag {
  border: 1px solid currentcolor;
  border-radius: 0.25rem;
  font-size: 0.75em;
  margin-left: 0.5em;
  padding: 0 0.4em;
  vertical-align: middle;
}

/* The portal home (PR 3c, docs/decisions/23): status strip, the Create an
   activation button (the largest on the page), classroom cards and the
   recent activations. */
.portal-status {
  border-bottom: 1px solid var(--color-button-secondary);
  padding-bottom: var(--spacing-small);
}

.portal-create {
  margin: var(--spacing-base) 0;
}

/* Two classes, to win over .button, which loads later. */
.button.portal-create__button {
  font-size: 1.4em;
  padding: 0.8em 1.6em;
}

.portal-cards {
  display: grid;
  gap: var(--spacing-small);
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}

.portal-classroom__term {
  margin-top: 0;
}

.portal-table {
  border-collapse: collapse;
  width: 100%;
}

.portal-table th,
.portal-table td {
  border-bottom: 1px solid var(--color-button-secondary);
  padding: 0.4em 0.5em 0.4em 0;
  text-align: left;
}

/* Create your classroom (PR 3c). */
.portal-terms {
  border: 0;
  margin: 0;
  padding: 0;
}

.portal-terms legend,
.portal-classroom-form label.portal-classroom-form__label {
  font-weight: 700;
}

/* The radio button beside its label, as .input__radio-button does. */
.portal-terms label {
  align-items: center;
  display: grid;
  gap: 0.5em;
  grid-template-columns: 1.15em auto;
  margin: 0.4em 0;
}

.portal-classroom-form .field {
  margin-bottom: var(--spacing-base);
}

.portal-classroom-form input[type="text"],
.portal-classroom-form input[type="number"],
.portal-classroom-form select {
  box-sizing: border-box;
  display: block;
  max-width: 100%;
  width: 24rem;
}

/* "What should we call you?" on the portal home (PR 3c-2). */
.portal-name-prompt h2 {
  margin-top: 0;
}

/* The grocer partner offer (docs/decisions/32 §5, PR 6d): like the name
   card, with Yes, No and Ask me later side by side, wrapping on a phone. */
.portal-grocer-card h2 {
  margin-top: 0;
}

.portal-grocer-card__answers {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-small);
  margin: var(--spacing-small) 0;
}

/* "Before your first activation" (PR 3d-1). */
.portal-guide__key {
  background-color: var(--color-button-secondary);
  border-radius: 0.5rem;
  margin: var(--spacing-base) 0;
  padding: var(--spacing-small) var(--spacing-base);
}

.portal-guide__key p {
  margin: 0.25em 0;
}

.portal-guide__link {
  font-size: 1.4em;
  font-weight: 700;
}

.portal-guide__form {
  margin: var(--spacing-base) 0;
}

/* The module choices on the activation form (PR 3d-1). */
.portal-module-choices {
  border: 0;
  padding: 0;
}

.portal-module-choices legend {
  font-weight: 700;
}

.portal-module-choice__card {
  border: 2px solid var(--color-button-secondary);
  border-radius: 0.5rem;
  display: grid;
  gap: 0.5em;
  grid-template-columns: 1.15em auto;
  margin: var(--spacing-small) 0;
  padding: var(--spacing-small);
}

label.portal-module-choice__card {
  cursor: pointer;
}

label.portal-module-choice__card:has(input:checked) {
  border-color: var(--color-button);
}

.portal-module-choice--locked .portal-module-choice__card {
  display: block;
  opacity: 0.75;
}

.portal-module-choice__title {
  display: block;
  font-weight: 700;
}

.portal-module-choice__card .portal__module-episode {
  display: block;
}

/* The template choices on the activation form (PR 3d-2). */
.portal-template-choices__heading {
  font-weight: 700;
  margin: var(--spacing-small) 0 0;
}

/* Customize slides (PR 3d-2): wide enough for the slide thumbnails. */
.portal-customizer {
  max-width: 64rem;
  width: 100%;
}

.portal-customizer__actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-base);
  margin-top: var(--spacing-base);
}

/* A module's templates on the Modules page (PR 3d-2). */
.portal-templates {
  margin: var(--spacing-small) 0 0;
}

.portal-templates li {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-small);
  margin: 0.25em 0;
}

.portal-templates form {
  display: inline;
}

.portal-templates__delete {
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

/* Past classrooms on the home page (PR 3e). */
.portal-past-classrooms {
  padding-left: 1.25rem;
}

/* Help → "Take the tour" (Phase 4, PR 4a): the button on laptops and
   desktops, a note on narrow screens, where the tour doesn't run. */
.portal-tour-launch__narrow {
  display: none;
}

/* Open lesson and See results (PR 5f): separate buttons with a clear gap,
   side by side when the column has room; when it doesn't (a narrow table
   column, a phone), the second moves below as a whole. */
.portal-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-small);
}

@media (max-width: 899px) {
  /* Tables get narrow before the phone layout starts at 600px: smaller
     Open lesson and See results buttons keep them inside the screen. */
  .portal-row-actions {
    gap: 0.5em;
  }

  .portal-row-actions .button {
    font-size: 0.875em;
    padding: 0.5em 0.75em;
  }

  /* The Results tab's table has six columns; its one button is a little
     tighter still so the table fits from 601px. */
  .results-activations .portal-row-actions .button {
    font-size: 0.8em;
    padding: 0.4em 0.5em;
  }

  .portal-tour-launch__button {
    display: none;
  }

  .portal-tour-launch__narrow {
    display: block;
  }
}

/* The tour's cards: a dialog in a right-hand column the page leaves free
   while the tour is open, level with the control it describes, which is
   outlined. The column means a card never covers its control (PR 4b). */
.tour-card {
  background: white;
  border: 1px solid var(--color-button);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  position: fixed;
  width: var(--tour-card-width);
  z-index: 1000;
  padding: var(--spacing-base);
}

:root {
  --tour-card-width: 20rem;
  --tour-column: calc(var(--tour-card-width) + 3rem);
}

.tour-open .page-body {
  padding-right: var(--tour-column);
}

.tour-card__dot--done {
  background: var(--color-button-secondary);
}

/* Stops 2–5: the sample activation's screens framed to the left of the
   cards' column. */
.tour-page {
  padding-right: var(--tour-column);
}

.tour-page__viewport {
  border-right: 1px solid var(--color-button);
  height: calc(100vh - 7rem);
  overflow: hidden;
}

/* Laid out at a laptop's width, then shrunk to the viewport's
   (--tour-frame-scale, set by the tour controller). */
.tour-page__frame {
  --tour-frame-width: 1280px;

  border: 0;
  display: block;
  height: calc((100vh - 7rem) / var(--tour-frame-scale, 1));
  transform: scale(var(--tour-frame-scale, 1));
  transform-origin: 0 0;
  width: var(--tour-frame-width);
}

.tour-card__count {
  font-size: 0.875rem;
  margin: 0;
}

.tour-card__title {
  font-size: 1.25rem;
  margin: var(--spacing-small) 0;
}

.tour-card__dots {
  display: flex;
  gap: var(--spacing-small);
  list-style: none;
  margin: var(--spacing-base) 0;
  padding: 0;
}

.tour-card__dot {
  border: 2px solid var(--color-button);
  border-radius: 50%;
  height: 0.75rem;
  width: 0.75rem;
}

.tour-card__dot--current {
  background: var(--color-button);
}

.tour-card__actions {
  align-items: center;
  display: flex;
  gap: var(--spacing-small);
  justify-content: flex-end;
}

.tour-card__skip {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  margin-right: auto;
  padding: 0;
  text-decoration: underline;
}

/* Burnt orange with a white ring, so it shows on the teal facilitator view,
   white pages and the classroom view's slides alike. */
.tour-target {
  box-shadow: 0 0 0 4px white;
  outline: 4px solid var(--color-base-alt);
  outline-offset: 4px;
}

/* The arrow from a tour card to its control (decision 29, PR 4c), in the
   outline's burnt orange with a white halo so it shows on any screen. */
.tour-arrow {
  height: 100vh;
  left: 0;
  pointer-events: none;
  position: fixed;
  top: 0;
  width: 100vw;
  z-index: 999;

  & .tour-arrow__line {
    stroke: var(--color-base-alt);
    stroke-width: 3;
  }

  & .tour-arrow__halo {
    stroke: white;
    stroke-width: 7;
  }

  & marker path {
    fill: var(--color-base-alt);
  }
}

/* An activation's results (Phase 5, PR 5a): bars drawn with CSS, no charts
   library; the by-student table scrolls sideways inside its own box when a
   lesson has many questions, so the page itself never does. */
.results-page {
  box-sizing: border-box;
  max-width: 1100px;
  min-width: 0; /* lets the by-student table scroll inside the card */
  width: 90%;
}

.results-questions {
  list-style: none;
  padding: 0;
}

.results-question {
  border-top: 1px solid var(--color-button-secondary);
  padding: var(--spacing-small) 0;
}

.results-question__heading {
  font-size: 1em;
  margin: 0;
}

.results-question__number {
  color: var(--color-button-hover);
}

.results-question__summary {
  font-size: 0.9em;
  margin: 0.25em 0;
}

.results-bars {
  border: 0;
  border-collapse: collapse;
  width: 100%;
}

.results-bars th,
.results-bars td {
  border: 0;
  font-weight: normal;
  padding: 0.15em 0.5em 0.15em 0;
  text-align: left;
  vertical-align: middle;
}

.results-bars__choice {
  width: 40%;
}

.results-bars__row--correct .results-bars__choice {
  font-weight: bold;
}

.results-bars__correct {
  color: var(--color-success-dark);
  white-space: nowrap;
}

.results-bars__bar {
  width: auto;
}

.results-bars__fill {
  background: var(--color-button-secondary);
  display: block;
  height: 1em;
  min-width: 2px;
}

.results-bars__row--correct .results-bars__fill {
  background: var(--color-success-dark);
}

.results-bars .results-bars__count,
.results-bars .results-bars__share {
  text-align: right;
  white-space: nowrap;
  width: 3.5em;
}

.results-first-seen {
  margin: var(--spacing-small) 0;
}

.results-students {
  max-width: 100%;
  overflow-x: auto;
  /* Holds the screen-reader-only words in its cells, which are positioned
     absolutely; otherwise they widen the page on a phone (PR 5d). */
  position: relative;
}

.results-students__table th,
.results-students__table td {
  white-space: nowrap;
  width: auto;
}

.results-seat-label {
  align-items: center;
  display: flex;
  gap: 0.4em;
}

.results-seat-label__status {
  font-size: 0.85em;
}

.results-mark {
  text-align: center;
}

.results-mark--correct {
  color: var(--color-success-dark);
}

.results-mark--wrong {
  color: var(--color-danger-dark);
}

.results-mark--answer {
  font-size: 0.85em;
  text-align: left;
}

/* The classroom page's tabs, Activations and Results (PR 5b). */
.portal-tabs {
  border-bottom: 2px solid var(--color-button-secondary);
  display: flex;
  gap: var(--spacing-small);
  margin-bottom: var(--spacing-small);
}

.portal-tabs__tab {
  border-bottom: 4px solid transparent;
  color: var(--color-button-hover);
  font-weight: bold;
  margin-bottom: -2px;
  padding: 0.4em 0.75em;
  text-decoration: none;
}

.portal-tabs__tab:hover {
  border-bottom-color: var(--color-button-secondary);
}

.portal-tabs__tab[aria-current="page"] {
  border-bottom-color: var(--color-button);
  color: var(--black);
}

/* The Results tab's Term and Module filters (PR 5b). */
.results-filters {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-small);
  margin-bottom: var(--spacing-small);
}

.results-filters__field {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  max-width: 100%;
}

.results-filters__field select {
  max-width: 100%;
}

.results-activations td {
  width: auto;
}

/* Archive this classroom (PR 5c). */
.portal-archive {
  border-top: 1px solid var(--color-button-secondary);
  margin-top: var(--spacing-base);
  padding-top: var(--spacing-small);
}

.portal-archive__reason {
  box-sizing: border-box;
  max-width: 100%;
  width: 100%;
}

/* Portal pages at phone widths (decision 30, PR 5d): the card fills the
   screen with a 16px gutter; buttons wrap rather than run off the edge; long
   links, codes and addresses break; lists of activations become one block
   per activation with each field labelled; wide tables scroll inside their
   own box (.results-students), never the page. */
@media (max-width: 600px) {
  .page-body {
    align-items: flex-start;
    box-sizing: border-box;
    max-width: 100vw;
    padding: 0 16px;
  }

  .page-body > .well,
  .page-body .width-60,
  .page-body .results-page {
    box-sizing: border-box;
    margin: var(--spacing-base) 0;
    max-width: 100%;
    min-width: 0;
    padding: var(--spacing-base);
    width: 100%;
  }

  .page-body a,
  .page-body strong,
  .page-body code,
  .page-body p,
  .page-body li,
  .page-body dd {
    overflow-wrap: anywhere;
  }

  .page-body .button {
    box-sizing: border-box;
    line-height: 1.2;
    max-width: 100%;
    text-align: center;
    white-space: normal;
  }

  /* Never broken mid-label ("Open / lesson"); the row wraps instead. */
  .page-body .portal-row-actions .button {
    overflow-wrap: normal;
    white-space: nowrap;
  }

  .page-body .button.portal-create__button {
    display: block;
    font-size: 1.2em;
    padding: 0.7em 1em;
  }

  .page-body select,
  .page-body input,
  .page-body textarea {
    max-width: 100%;
  }

  .portal-cards {
    grid-template-columns: 1fr;
  }

  /* One block per row; each cell shows its column's name (data-label). */
  .portal-table--stack,
  .portal-table--stack tbody,
  .portal-table--stack tr,
  .portal-table--stack td {
    border: 0;
    display: block;
    width: auto;
  }

  .portal-table--stack thead {
    height: 1px;
    left: -10000px;
    overflow: hidden;
    position: absolute;
    width: 1px;
  }

  .portal-table--stack tr {
    border: 2px solid var(--color-button-secondary);
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--spacing-small);
    padding: var(--spacing-small);
  }

  .portal-table--stack td {
    display: grid;
    gap: 0.5em;
    grid-template-columns: 9.5em 1fr;
    padding: 0.2em 0;
  }

  .portal-table--stack td::before {
    content: attr(data-label);
    font-weight: bold;
  }

  .portal-table--stack td[data-label=""] {
    display: block;
    padding-top: var(--spacing-small);
  }

  .portal-table--stack td[data-label=""]::before {
    content: none;
  }

  .results-filters {
    align-items: stretch;
    flex-direction: column;
  }
}
