/* css/exercise-types/reading-type5.css */
/* Multiple choice text - Part 5 */

/* B1 Part 1 notices: poster-style text beside the question (desktop) or above (mobile) */
.reading-type5-with-notice {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin: 0 0 18px;
}

.reading-type5-with-notice .reading-type5-question {
  margin: 0;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 2px solid var(--ex-duo-border, #e5e5e5);
  border-radius: 16px;
  padding: 16px 18px 18px;
  box-shadow: 0 3px 0 var(--ex-duo-border, #e5e5e5);
}

/* Source text card (notice, email, advert, message, generic text) — Duolingo 3D cards */
.reading-type5-notice-card {
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 16px 18px 18px;
  border-radius: 16px;
  border: 2px solid var(--rt5-card-border);
  background: var(--rt5-card-bg);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--rt5-card-border) 55%, #000);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 4.5rem;
  position: relative;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;

  /* Default / notice — brand orange */
  --rt5-card-border: var(--ex-duo-orange, #f47417);
  --rt5-card-bg: linear-gradient(165deg, #fff8f3 0%, var(--ex-duo-orange-light, #fff0e6) 45%, #ffe8d9 100%);
  --rt5-label-color: var(--ex-duo-orange-dark, #d45f0a);
  --rt5-heading-color: #a34d0c;
  --rt5-body-color: var(--ex-duo-text, #3c3c3c);
  --rt5-accent-bar: var(--ex-duo-orange, #f47417);
}

.reading-type5-notice-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--rt5-accent-bar);
  border-radius: 16px 0 0 16px;
  pointer-events: none;
}

.reading-type5-notice-card[data-reading-type5-source='text_message'],
.reading-type5-notice-card[data-reading-type5-source='email'] {
  --rt5-card-border: var(--ex-duo-blue, #1cb0f6);
  --rt5-card-bg: linear-gradient(180deg, #f0f9ff 0%, var(--ex-duo-blue-light, #ddf4ff) 100%);
  --rt5-label-color: var(--ex-duo-blue-dark, #1899d6);
  --rt5-heading-color: #0c6a96;
  --rt5-body-color: var(--ex-duo-text, #3c3c3c);
  --rt5-accent-bar: var(--ex-duo-blue, #1cb0f6);
}

.reading-type5-notice-card[data-reading-type5-source='advert'] {
  --rt5-card-border: var(--ex-duo-orange, #f47417);
  --rt5-card-bg: linear-gradient(180deg, #fff8f3 0%, #ffe8d9 100%);
  --rt5-label-color: var(--ex-duo-orange-dark, #d45f0a);
  --rt5-heading-color: #a34d0c;
  --rt5-body-color: var(--ex-duo-text, #3c3c3c);
  --rt5-accent-bar: var(--ex-duo-orange, #f47417);
}

.reading-type5-notice-card[data-reading-type5-source='text'] {
  --rt5-card-border: var(--ex-duo-blue, #1cb0f6);
  --rt5-card-bg: linear-gradient(180deg, #f5fbff 0%, #e8f6ff 100%);
  --rt5-label-color: var(--ex-duo-blue-dark, #1899d6);
  --rt5-heading-color: #0c6a96;
  --rt5-body-color: var(--ex-duo-text, #3c3c3c);
  --rt5-accent-bar: var(--ex-duo-blue, #1cb0f6);
}

.reading-type5-notice-label {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: var(--rt5-label-color);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.reading-type5-notice-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.55;
  color: var(--rt5-body-color);
  text-align: justify;
  hyphens: auto;
}

.reading-type5-passage-heading {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--rt5-heading-color);
  margin-bottom: 10px;
}

.reading-type5-passage-body {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.55;
  color: var(--rt5-body-color);
  white-space: pre-wrap;
  text-align: justify;
  hyphens: auto;
}

@media (min-width: 900px) {
  .reading-type5-with-notice {
    flex-direction: row;
    align-items: stretch;
    gap: 20px;
  }

  .reading-type5-notice-card {
    flex: 0 0 38%;
    max-width: 360px;
    align-self: stretch;
  }
}

.reading-type5-container {
  background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 100%);
  border-radius: 20px;
  padding: 24px;
  border: 1px solid #ddd6fe;
}

.reading-type5-question {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

.reading-type5-question-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ex-duo-blue, #1cb0f6);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  text-align: center;
  line-height: 1;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
  box-shadow: 0 3px 0 var(--ex-duo-blue-dark, #1899d6);
}

.reading-type5-question-number.correct {
  background: var(--ex-duo-practice, #58cc02);
  box-shadow: 0 3px 0 var(--ex-duo-practice-dark, #58a700);
}

.reading-type5-question-number.incorrect,
.reading-type5-question-number.unanswered-checked {
  background: #ff4b4b;
  box-shadow: 0 3px 0 #ea2b2b;
}

.reading-type5-question-number.show-correct {
  background: var(--ex-duo-purple, #ce82ff);
  box-shadow: 0 3px 0 var(--ex-duo-purple-dark, #a855f7);
}

.reading-type5-question-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.reading-type5-question-text {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1.05rem;
  color: var(--ex-duo-text, #4b4b4b);
  font-weight: 600;
  line-height: 1.45;
}

.reading-type5-content-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.reading-type5-content-subtitle {
  font-size: 1.1rem;
  font-style: italic;
  color: #64748b;
  margin-bottom: 16px;
  line-height: 1.5;
}

.reading-type5-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reading-type5-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.1s, transform 0.1s;
  border: 2px solid var(--ex-duo-border, #e5e5e5);
  background: #fff;
  box-shadow: 0 3px 0 var(--ex-duo-border, #e5e5e5);
  font-size: 1.05rem;
  line-height: 1.55;
  font-weight: 600;
  color: var(--ex-duo-text, #4b4b4b);
}

.reading-type5-option:hover:not(.disabled) {
  background: var(--ex-duo-blue-light, #ddf4ff);
  border-color: var(--ex-duo-blue, #1cb0f6);
  box-shadow: 0 3px 0 var(--ex-duo-blue-dark, #1899d6);
}

.reading-type5-option:active:not(.disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ex-duo-border, #e5e5e5);
}

.reading-type5-option input[type="radio"] {
  accent-color: var(--ex-duo-blue, #1cb0f6);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
}

.reading-type5-option > span {
  flex: 1;
  min-width: 0;
}

@supports selector(:has(*)) {
  .reading-type5-option:has(input:checked):not(.disabled) {
    border-color: var(--ex-duo-blue, #1cb0f6);
    background: var(--ex-duo-blue-light, #ddf4ff);
    box-shadow: 0 3px 0 var(--ex-duo-blue-dark, #1899d6);
  }

  @media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
    .reading-type5-option input[type="radio"] {
      position: absolute;
      opacity: 0;
      width: 0;
      height: 0;
      margin: 0;
      pointer-events: none;
    }

    .reading-type5-option {
      position: relative;
      padding-left: 14px;
    }
  }
}

.reading-type5-option.correct {
  background: var(--ex-feedback-bg, #fff);
  border-color: #58cc02;
  box-shadow: 0 3px 0 #58a700;
  color: #3c3c3c;
}

.reading-type5-option.incorrect {
  background: var(--ex-feedback-bg, #fff);
  border-color: #ff4b4b;
  box-shadow: 0 3px 0 #ea2b2b;
}

/* B1 Reading Part 5 — Questions row: highlight key option when showing correct answers */
.reading-type5-option.reading-type5-option-key {
  background: var(--ex-feedback-bg, #fff);
  border-color: #7c3aed;
  color: #5b21b6;
}

.reading-type5-option.reading-type5-option-key .reading-type5-opt-word {
  color: #5b21b6;
}

.reading-type5-option.disabled {
  cursor: not-allowed;
  opacity: 0.85;
}

/* B1 (and reading) Part 5 cloze: inline tap-to-choose gap in the passage */
.reading-type5-gap-wrap {
  position: relative;
  display: inline-block;
  vertical-align: baseline;
  margin: 0 1px;
  max-width: 100%;
}

/* Inline gap chip — Duolingo 3D pill (matches .reading-type5-option / type7 gap pills) */
.reading-type5-gap-trigger {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 0.95em;
  font-weight: 700;
  line-height: 1.35;
  padding: 3px 10px 4px;
  margin: 0;
  border-radius: 12px;
  border: 2px solid var(--ex-duo-border, #e5e5e5);
  background: #fff;
  color: var(--ex-duo-text, #4b4b4b);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ex-duo-border, #e5e5e5);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.1s, transform 0.1s, color 0.15s;
}

.reading-type5-gap-trigger:hover:not(:disabled) {
  background: var(--ex-duo-blue-light, #ddf4ff);
  border-color: var(--ex-duo-blue, #1cb0f6);
  box-shadow: 0 2px 0 var(--ex-duo-blue-dark, #1899d6);
  color: var(--ex-duo-blue-dark, #1899d6);
}

.reading-type5-gap-trigger:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ex-duo-blue-dark, #1899d6);
}

.reading-type5-gap-trigger.filled:not(:disabled) {
  border-style: solid;
  border-color: var(--ex-duo-blue, #1cb0f6);
  background: var(--ex-duo-blue-light, #ddf4ff);
  box-shadow: 0 2px 0 var(--ex-duo-blue-dark, #1899d6);
  color: var(--ex-duo-blue-dark, #1899d6);
}

.reading-type5-gap-trigger:disabled {
  cursor: default;
  opacity: 0.92;
}

.reading-type5-gap-trigger.correct {
  background: var(--ex-feedback-bg, #fff);
  border-color: #58cc02;
  border-style: solid;
  box-shadow: 0 2px 0 #58a700;
  color: #3c3c3c;
}

.reading-type5-gap-trigger.incorrect {
  background: var(--ex-feedback-bg, #fff);
  border-color: #ff4b4b;
  border-style: solid;
  box-shadow: 0 2px 0 #ea2b2b;
  color: #3c3c3c;
}

.reading-type5-gap-trigger.unanswered-checked {
  background: var(--ex-feedback-bg, #fff);
  border-color: #ffc800;
  border-style: solid;
  box-shadow: 0 2px 0 #e5b400;
  color: #3c3c3c;
}

/* Hover label: correct word for wrong or unanswered gaps (B1 Reading Part 5) */
.reading-type5-gap-wrap[data-correct] {
  position: relative;
}

.reading-type5-gap-wrap[data-correct]::after {
  content: attr(data-correct);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  display: none;
  z-index: 110;
  pointer-events: none;
  white-space: nowrap;
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
  padding: 2px 8px;
  border-radius: 8px;
  color: var(--ex-duo-purple-dark, #7c3aed);
  background: var(--ex-duo-purple-light, #f3e8ff);
}

.reading-type5-gap-wrap[data-correct]:hover::after {
  display: block;
}

/* "Show correct answers" mode: gap number + key word */
.reading-type5-gap-trigger.reading-type5-gap-trigger-show-correct {
  background: var(--ex-feedback-bg, #fff);
  border-color: var(--ex-duo-purple, #ce82ff);
  color: var(--ex-duo-purple-text, #5b21b6);
  border-style: solid;
  font-weight: 800;
  box-shadow: 0 2px 0 var(--ex-duo-purple-dark, #a855f7);
}

.reading-type5-gap-wrap.reading-type5-gap-open {
  z-index: 21001;
}

.reading-type5-gap-panel {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  min-width: 0;
  max-width: min(280px, calc(100vw - 24px));
  z-index: 21001;
  padding: 0;
  border-radius: 16px;
  border: 2px solid var(--ex-duo-blue, #1cb0f6);
  background: #ffffff;
  box-shadow:
    0 6px 0 color-mix(in srgb, var(--ex-duo-blue-dark, #1899d6) 30%, #e5e5e5),
    0 16px 40px rgba(15, 23, 42, 0.14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px) scale(0.98);
  transform-origin: top left;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  overflow: visible;
  pointer-events: none;
}

.reading-type5-gap-panel.reading-type5-gap-panel--fixed {
  position: fixed;
  left: auto;
  top: auto;
  margin: 0;
  min-width: 0;
  box-sizing: border-box;
  z-index: 21001;
}

.reading-type5-gap-wrap.reading-type5-gap-open .reading-type5-gap-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.reading-type5-gap-wrap.reading-type5-gap-open .reading-type5-gap-panel.reading-type5-gap-panel--above {
  transform-origin: bottom left;
}

.reading-type5-gap-panel-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  max-height: min(320px, 50vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 14px;
  background: #fff;
}

.reading-type5-gap-choice {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
  border-radius: 12px;
  border: 2px solid var(--ex-duo-border, #e5e5e5);
  background: #fff;
  color: var(--ex-duo-text, #4b4b4b);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ex-duo-border, #e5e5e5);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.1s, transform 0.1s;
}

/* B1 Reading Part 5: option word only in popover / row (no A/B/C/D prefix in the label) */
.reading-type5-opt-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.reading-type5-opt-word {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-weight: 600;
}

.reading-type5-gap-choice:hover:not(:disabled) {
  background: var(--ex-duo-blue-light, #ddf4ff);
  border-color: var(--ex-duo-blue, #1cb0f6);
  box-shadow: 0 2px 0 var(--ex-duo-blue-dark, #1899d6);
}

.reading-type5-gap-choice:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ex-duo-blue-dark, #1899d6);
}

.reading-type5-gap-choice.selected:not(:disabled) {
  border-color: var(--ex-duo-blue, #1cb0f6);
  background: var(--ex-duo-blue-light, #ddf4ff);
  box-shadow: 0 2px 0 var(--ex-duo-blue-dark, #1899d6);
  color: var(--ex-duo-blue-dark, #1899d6);
}

.reading-type5-gap-choice.correct {
  background: var(--ex-feedback-bg, #fff);
  border-color: var(--correct);
}

.reading-type5-gap-choice.incorrect {
  background: var(--ex-feedback-bg, #fff);
  border-color: var(--incorrect);
}

.reading-type5-gap-choice:disabled {
  cursor: default;
  opacity: 0.95;
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .reading-type5-gap-panel {
    min-width: 0;
    max-width: calc(100vw - 24px);
  }

  .reading-type5-gap-panel-options {
    max-height: min(280px, 45vh);
  }
}

/* “Questions” tab: number + A–D (or A–E) on one row */
.reading-type5-cloze-row {
  margin: 10px 0;
}

.reading-type5-cloze-row-inner {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 12px;
  width: 100%;
}

.reading-type5-cloze-row .reading-type5-question-number {
  flex-shrink: 0;
  align-self: center;
}

.reading-type5-options-row {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}

.reading-type5-options-row .reading-type5-option {
  flex: 1 1 140px;
  min-width: 120px;
  margin: 0;
}

.reading-type5-cloze-row.reading-type5-question {
  background: #fff;
  border: 2px solid var(--ex-duo-border, #e5e5e5);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--ex-duo-border, #e5e5e5);
  padding: 14px 16px;
  margin: 8px 0;
}

/* ── Layout inside .reading-text-enhanced (B1 Reading Part 1) ───────────── */

/* B1 Reading Part 1: all source cards use blue theme (notice, advert, email, etc.) */
.dashboard-layout--exercise .reading-text-enhanced .reading-type5-notice-card {
  --rt5-card-border: var(--ex-duo-blue, #1cb0f6);
  --rt5-card-bg: linear-gradient(180deg, #f0f9ff 0%, var(--ex-duo-blue-light, #ddf4ff) 100%);
  --rt5-label-color: var(--ex-duo-blue-dark, #1899d6);
  --rt5-heading-color: #0c6a96;
  --rt5-body-color: var(--ex-duo-text, #3c3c3c);
  --rt5-accent-bar: var(--ex-duo-blue, #1cb0f6);
}

.dashboard-layout--exercise .reading-text-enhanced .reading-type5-with-notice {
  gap: 14px;
  margin: 0 0 18px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ex-duo-border, #e5e5e5);
}

.dashboard-layout--exercise .reading-text-enhanced .reading-type5-with-notice:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

@media (min-width: 900px) {
  .dashboard-layout--exercise .reading-text-enhanced .reading-type5-with-notice {
    gap: 18px;
  }

  .dashboard-layout--exercise .reading-text-enhanced .reading-type5-notice-card {
    flex: 0 0 38%;
    max-width: 360px;
  }
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .dashboard-layout--exercise .reading-text-enhanced .reading-type5-with-notice {
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
  }

  .dashboard-layout--exercise .reading-text-enhanced .reading-type5-notice-card {
    border-radius: 14px;
    padding: 14px 16px 16px;
  }

  .dashboard-layout--exercise .reading-text-enhanced .reading-type5-with-notice .reading-type5-question {
    border-radius: 14px;
    padding: 14px 16px 16px;
  }

  .dashboard-layout--exercise .reading-text-enhanced .reading-type5-option {
    border-radius: 12px;
    padding: 11px 12px;
  }
}

/* B1 Reading Part 5 — extra line spacing in the cloze passage */
.reading-text-enhanced--b1r-plain.b1-reading5 .toggle-text-section p {
  line-height: 2.25;
}

.b1-reading5-mobile-spacer {
  display: none;
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .reading-text-enhanced--b1r-plain.b1-reading5 .toggle-text-section p {
    line-height: 2.05;
  }

  /* Reserve scroll space below the passage so the fixed bottom stack
     covers this spacer instead of the last lines of reading-text-enhanced.
     Height is synced from the real bottom stack in exercise-renderer.js. */
  .dashboard-layout--exercise .b1-reading5-mobile-spacer {
    display: block;
    width: 100%;
    flex-shrink: 0;
    min-height: 88px;
    pointer-events: none;
  }
}
