/* Fern quiz mobile refinements.
 * Kept route-specific by functions.php and mobile-only here so desktop remains untouched. */

@media (max-width: 767px) {
  /* Recommendation quiz -------------------------------------------------- */
  .tquiz {
    min-height: calc(100svh - var(--nav-h));
    overflow-x: clip;
  }

  .tquiz__progress-wrap {
    max-width: none;
    padding: 24px 20px 0;
  }

  .tquiz__progress-label {
    margin-top: 8px;
  }

  .tquiz__screen {
    max-width: none;
    padding: 32px 20px 52px;
  }

  .tquiz__screen:not(.tquiz__screen--result) {
    min-height: calc(100svh - var(--nav-h) - 56px);
  }

  .tquiz__screen--result {
    padding: 32px 20px 56px;
  }

  .tquiz__back {
    min-height: 44px;
    margin: -10px 0 12px;
  }

  .tquiz__kicker {
    margin-bottom: 12px;
  }

  .tquiz__question {
    font-size: clamp(27px, 7.5vw, 31px);
    line-height: 1.16;
    margin-bottom: 24px;
  }

  .tquiz__options {
    gap: 10px;
  }

  .tquiz__option {
    min-height: 56px;
    padding: 15px 18px;
    font-size: 15.5px;
  }

  .tquiz__option:focus-visible,
  .tquiz__back:focus-visible,
  .tquiz__restart:focus-visible,
  .tquiz__result-learn:focus-visible {
    outline: 2px solid var(--fern);
    outline-offset: 3px;
  }

  .tquiz__result-headline {
    font-size: clamp(29px, 8vw, 34px);
    margin-top: 4px;
  }

  .tquiz__result-subtext {
    font-size: 14.5px;
    line-height: 1.55;
    margin-bottom: 24px;
  }

  .tquiz__result-card {
    padding: 22px 20px;
    border-radius: 18px;
  }

  .tquiz__result-badge {
    margin-bottom: 14px;
  }

  .tquiz__result-name {
    font-size: 25px;
    overflow-wrap: anywhere;
  }

  .tquiz__result-desc {
    font-size: 14.5px;
    line-height: 1.6;
  }

  .tquiz__result-learn {
    line-height: 1.45;
    margin-bottom: 20px;
  }

  .tquiz__result-actions {
    flex-direction: column;
  }

  .tquiz__result-actions .btn,
  .tquiz__screen--result > .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
    text-align: center;
  }

  .tquiz__addon-card {
    padding: 20px;
  }

  .tquiz__result-divider {
    margin: 24px 0;
  }

  .tquiz__result-fallback {
    margin-bottom: 18px;
  }

  .tquiz__disclaimer {
    margin-top: 18px;
  }

  .tquiz__restart {
    min-height: 44px;
    margin-top: 22px;
  }

  /* Clinical intake, completion, resume, and confirmation states -------- */
  .quiz-page {
    width: 100%;
    overflow-x: clip;
  }

  .quiz-page__container {
    box-sizing: border-box;
    width: 100%;
    max-width: 560px;
    min-height: calc(100svh - var(--nav-h));
    padding: 48px 20px 64px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }

  .quiz-page__container h1 {
    max-width: 100%;
    font-size: clamp(27px, 7.5vw, 31px) !important;
    overflow-wrap: anywhere;
  }

  .quiz-page__container > p {
    max-width: 440px;
  }

  .quiz-page__container > .btn,
  .quiz-page__container > .fern-pay-trigger {
    box-sizing: border-box;
    width: 100%;
    max-width: 360px;
    min-height: 50px;
    justify-content: center;
  }

  .quiz-page--intake {
    min-height: 0;
  }

  .quiz-page--intake > #fern-quiz-frame {
    width: 100%;
    overflow: hidden;
  }

  .mdi-frame {
    width: 100%;
    height: calc(100svh - var(--nav-h));
    min-height: 560px;
  }

  /* Keep plan labels, prices, and the savings badge readable at 320–400px. */
  .plan-select {
    box-sizing: border-box;
    width: 100%;
    max-width: 440px;
    gap: 10px;
    margin-top: 24px;
  }

  .plan-select__legend {
    margin-bottom: 10px;
  }

  .plan-select__option {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 15px 14px;
  }

  .plan-select__body {
    min-width: 0;
  }

  .plan-select__name {
    font-size: 15px;
    line-height: 1.25;
  }

  .plan-select__meta {
    font-size: 12.5px;
    line-height: 1.35;
  }

  .plan-select__price {
    font-size: 16px;
  }

  .plan-select__badge {
    top: -9px;
    right: 12px;
    font-size: 10px;
  }
}

@media (max-width: 360px) {
  .tquiz__progress-wrap,
  .tquiz__screen {
    padding-left: 16px;
    padding-right: 16px;
  }

  .quiz-page__container {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .plan-select__option {
    gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }
}
