/* Flashcards */
.flashcard-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
}

.flashcard-scope {
  min-width: 0;
}

.flashcard-scope .level-reference-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flashcard-stage {
  width: min(1000px, 100%);
  height: calc(100dvh - 91px);
  margin: 0 auto;
  border: 0;
  background: transparent;
  padding: clamp(20px, 4vh, 42px) 20px 24px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 140px;
  place-items: center;
  gap: clamp(12px, 2.5vh, 24px);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.flashcard-stage:hover .flashcard-flag {
  box-shadow:
    0 0 0 3px rgba(36, 93, 69, 0.16),
    0 18px 48px rgba(24, 35, 29, 0.18);
}

.flashcard-flag {
  width: min(720px, 82vw, 77vh);
  max-width: 100%;
  max-height:100%;
  object-fit:contain;
  align-self: center;
  box-shadow: 0 16px 42px rgba(24, 35, 29, 0.15);
  transition: box-shadow 180ms ease;
}

.flashcard-stage:focus-visible {
  outline: none;
}

.flashcard-stage:focus-visible .flashcard-flag {
  box-shadow:
    0 0 0 4px rgba(36, 93, 69, 0.48),
    0 18px 48px rgba(24, 35, 29, 0.18);
}

.flashcard-answer {
  width: 100%;
  height: 140px;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 5px;
  text-align: center;
}

.flashcard-answer strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1;
}

.flashcard-answer span {
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
}

.flashcard-answer .flashcard-relationship {
  max-width: min(680px, 92vw);
  color: var(--muted);
  font-size: clamp(12px, 1.5vw, 15px);
  line-height: 1.2;
}

.flashcard-answer .flashcard-question {
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(64px, 10vw, 104px);
  font-weight: 400;
  line-height: 1;
}

.flashcard-complete {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 110px 0 70px;
  text-align: center;
}

.flashcard-complete h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(48px, 7vw, 76px);
  font-weight: 400;
  letter-spacing: -0.045em;
}

.flashcard-complete > p:not(.kicker) {
  margin: 22px auto 34px;
  color: var(--muted);
  font-size: 18px;
}

.flashcard-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.secondary-button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  padding: 0 24px;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.secondary-button:hover {
  border-color: var(--green);
}

/* Responsive flashcards layout */
@media (max-width: 600px) {
  .quiz-active,
    .flashcard-shell {
      --phone-quiz-header-height: 66px;
      --phone-quiz-header-height: clamp(58px, 8.5dvh, 72px);
      --phone-quiz-bottom-buffer: 18px;
      --phone-quiz-bottom-buffer: max(18px, env(safe-area-inset-bottom));
    }

  .quiz-active .quiz-header,
    .flashcard-shell .quiz-header {
      min-height: var(--phone-quiz-header-height);
    }

  .flashcard-stage {
      height: calc(100vh - var(--phone-quiz-header-height) - 3px);
      height: calc(100dvh - var(--phone-quiz-header-height) - 3px);
      padding: 20px 6px max(20px, var(--phone-quiz-bottom-buffer));
      grid-template-rows: minmax(0, 1fr) 140px;
    }

  .flashcard-flag {
      width: min(90vw, 64vh);
    }

  .flashcard-answer {
      height: 140px;
      min-height: 0;
    }

  .flashcard-complete {
      padding: 70px 0 50px;
    }
}

@media (orientation: landscape) and (max-height: 599px) {
  .quiz-active,
    .flashcard-shell {
      --short-header-height: 52px;
      --short-bottom-space: max(6px, env(safe-area-inset-bottom));
      height: 100dvh;
      min-height: 0;
      overflow: hidden;
    }

  .quiz-active .quiz-header,
    .flashcard-shell .quiz-header {
      height: var(--short-header-height);
      min-height: var(--short-header-height);
    }

  .flashcard-shell {
      min-height: 0;
    }

  .flashcard-stage {
      width: min(1050px, 100%);
      height: calc(100dvh - var(--short-header-height) - 3px);
      padding: 9px 8px var(--short-bottom-space);
      grid-template-columns: minmax(0, 1.35fr) minmax(190px, 0.85fr);
      grid-template-rows: minmax(0, 1fr);
      gap: 6px clamp(14px, 3vw, 32px);
    }

  .flashcard-flag {
      grid-column: 1;
      grid-row: 1;
      width: min(100%, 72dvh);
      max-height: 100%;
    }

  .flashcard-answer {
      width: 100%;
      height: auto;
      min-height: 0;
      grid-column: 2;
      grid-row: 1;
      align-self: center;
      text-align: center;
    }

  .flashcard-answer strong {
      font-size: clamp(27px, 8.5dvh, 42px);
    }

  .flashcard-answer span {
      font-size: clamp(14px, 4dvh, 18px);
    }

  .flashcard-complete {
      height: calc(100dvh - var(--short-header-height));
      padding: 18px 0 var(--short-bottom-space);
      display: grid;
      place-content: center;
    }

  .flashcard-complete .kicker {
      margin-bottom: 7px;
    }

  .flashcard-complete h1 {
      font-size: clamp(34px, 11dvh, 52px);
    }

  .flashcard-complete > p:not(.kicker) {
      margin: 10px auto 14px;
      font-size: 15px;
    }

  .flashcard-complete .primary-button,
    .flashcard-complete .secondary-button {
      min-height: 44px;
    }
}

@media (orientation: landscape) and (max-height: 400px) {
  .quiz-active,
    .flashcard-shell {
      --short-header-height: 48px;
    }
}
