/* Cloze exercise pages (standard and word bank)
   Same family as the scrambled sentence and sentence matching players:
   Open Sans, heading with tools, pill buttons, soft panels. */

.lh-cloze {
  --ink: #212529;
  --muted: #6c757d;
  --line: #dee2e6;
  --blue: #1875d0;
  --blue-dark: #0f5aa6;
  --blue-tint: #e8f2ff;
  --green: #2e8b57;
  --green-tint: #e7f7ee;
  --red: #c0392b;
  --red-tint: #fdecec;
  --gap-font: 17px;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 16px 48px;
  box-sizing: border-box;
  color: var(--ink);
  font-family: "Open Sans", sans-serif;
}

.lh-cloze [hidden] {
  display: none !important;
}

/* Undo the site-wide button style (fixed height, margins) inside the page */
.lh-cloze button {
  height: auto;
  margin: 0;
  line-height: 1.2;
  font-family: inherit;
}

/* Heading and tools */
.lh-cloze .player-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.lh-cloze h1 {
  margin: 0;
  padding: 8px 0 4px;
  color: var(--ink);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
}

.lh-cloze .player-tools {
  flex-shrink: 0;
  padding-top: 12px;
}

.lh-cloze .text-link {
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.lh-cloze .text-link:hover {
  text-decoration: underline;
}

.lh-cloze #description {
  margin: 4px 0 18px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

/* The text */
.lh-cloze .cloze-exercise {
  max-width: 760px;
  margin: 0 auto;
  font-family: "Open Sans", sans-serif;
  font-size: var(--gap-font);
  line-height: 2.1;
}

.lh-cloze .cloze-gap {
  height: auto;
  margin: 0 4px;
  padding: 2px 8px;
  border: 0;
  border-bottom: 2px solid #8eb7e8;
  border-radius: 6px 6px 2px 2px;
  background: #f3f7fc;
  color: var(--ink);
  font-family: inherit;
  font-size: var(--gap-font);
  line-height: 1.5;
  vertical-align: baseline;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.lh-cloze .cloze-gap:focus {
  outline: none;
  border-bottom-color: var(--blue);
  background: var(--blue-tint);
  box-shadow: 0 0 0 2px rgba(24, 117, 208, 0.18);
}

.lh-cloze .cloze-gap.correct {
  border-bottom-color: var(--green);
  background: var(--green-tint);
  color: #1e5a3a;
}

.lh-cloze .cloze-gap.incorrect {
  border-bottom-color: var(--red);
  background: var(--red-tint);
  color: #7a1c14;
}

/* Revealed answers: readable, but clearly not the student's own */
.lh-cloze .cloze-gap.revealed {
  border-bottom: 2px dashed #b58a00;
  background: #fdf7dc;
  color: #6b5300;
}

/* Bigger text */
body.cloze-bigger .lh-cloze {
  --gap-font: 22px;
  max-width: 1100px;
}

body.cloze-bigger .lh-cloze .cloze-exercise {
  max-width: 980px;
}

/* Buttons and messages */
.lh-cloze .cloze-controls,
.lh-cloze .cloze-result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
}

.lh-cloze .cloze-controls {
  margin: 28px 0 0;
}

.lh-cloze .check-all-btn,
.lh-cloze .hint-btn,
.lh-cloze .cloze-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  border-radius: 99px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transform: none;
  box-shadow: none;
  transition: background-color 150ms ease;
}

.lh-cloze .check-all-btn {
  border: 0;
  border-bottom: 3px solid var(--blue-dark);
  background: var(--blue);
  color: #fff;
}

.lh-cloze .check-all-btn:hover {
  border-color: var(--blue-dark);
  background: #1568b9;
  transform: none;
  box-shadow: none;
}

.lh-cloze .hint-btn,
.lh-cloze .cloze-secondary {
  margin: 0;
  border: 1px solid #ced4da;
  border-bottom: 3px solid #b7c4d4;
  background: #fff;
  color: var(--ink);
}

.lh-cloze .hint-btn:hover,
.lh-cloze .cloze-secondary:hover {
  border-color: #ced4da;
  border-bottom-color: #b7c4d4;
  background: #f1f3f5;
  transform: none;
  box-shadow: none;
}

.lh-cloze .check-all-btn:disabled,
.lh-cloze .hint-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.lh-cloze .cloze-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.lh-cloze .cloze-result {
  max-width: 560px;
  margin: 18px auto 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f9fa;
  text-align: center;
}

.lh-cloze .cloze-result-text {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
}

/* All done */
.lh-cloze .cloze-end {
  max-width: 560px;
  margin: 24px auto 0;
  padding: 24px 20px;
  border: 1px solid #e3c96a;
  border-radius: 12px;
  background: #fdf7dc;
  text-align: center;
  animation: cloze-in 260ms ease;
}

.lh-cloze .cloze-end-emoji {
  margin: 0;
  font-size: 30px;
  line-height: 1;
}

.lh-cloze .cloze-end h2 {
  margin: 6px 0 4px;
  color: var(--ink);
  font-size: 28px;
}

.lh-cloze .cloze-end-text {
  margin: 0 0 16px;
  color: #495057;
}

@keyframes cloze-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Audio bar */
.lh-cloze .lh-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto 22px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.lh-cloze .lh-audio audio {
  display: none;
}

.lh-cloze .lh-audio-play {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
}

.lh-cloze .lh-audio-play:hover {
  background: #1568b9;
}

.lh-cloze .lh-audio-play svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.lh-cloze .lh-audio-back,
.lh-cloze .lh-audio-speed {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border: 1px solid #ced4da;
  border-radius: 99px;
  background: #fff;
  color: #495057;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.lh-cloze .lh-audio-back:hover,
.lh-cloze .lh-audio-speed:hover {
  background: #f1f3f5;
}

.lh-cloze .lh-audio-back svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lh-cloze .lh-audio-speed.is-slow {
  border-color: var(--blue);
  background: var(--blue-tint);
  color: var(--blue-dark);
}

.lh-cloze .lh-audio-time {
  flex: none;
  min-width: 82px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.lh-cloze .lh-audio-seek {
  --pct: 0%;
  flex: 1;
  min-width: 60px;
  height: 6px;
  margin: 0;
  border-radius: 99px;
  background: linear-gradient(to right, var(--blue) var(--pct), #dde6f0 var(--pct));
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.lh-cloze .lh-audio-seek::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  -webkit-appearance: none;
  appearance: none;
}

.lh-cloze .lh-audio-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
}

.lh-cloze .lh-audio-error {
  margin: 0;
  color: var(--red);
  font-size: 14px;
}

.lh-cloze .lh-audio.has-error > :not(.lh-audio-error) {
  display: none;
}

/* Word bank version */
.lh-cloze .word-bank-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f9fa;
  box-shadow: none;
}

.lh-cloze .word-bank-section h3 {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.lh-cloze .word-bank {
  border: 1px solid var(--line);
  border-radius: 10px;
}

.lh-cloze .word-item {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
}

/* Used words stay in the bank, crossed out */
.lh-cloze .word-item.used {
  background: #f1f3f5;
  color: #868e96;
  border-color: #dee2e6;
  opacity: 1;
  text-decoration: line-through;
}

body.cloze-bigger .lh-cloze .word-item {
  font-size: 19px;
}

/* Phones */
@media (max-width: 600px) {
  .lh-cloze .player-heading {
    flex-direction: column;
    gap: 0;
  }

  .lh-cloze .player-tools {
    padding-top: 0;
  }

  .lh-cloze h1 {
    font-size: 24px;
  }

  .lh-cloze {
    --gap-font: 16px;
  }

  body.cloze-bigger .lh-cloze {
    --gap-font: 19px;
  }

  .lh-cloze .lh-audio {
    flex-wrap: wrap;
    border-radius: 16px;
  }

  .lh-cloze .lh-audio-seek {
    order: 5;
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lh-cloze .cloze-end {
    animation: none;
  }
}

/* Word bank gaps: the word bank stylesheet forces its own colours, so these
   need the same weight to match the standard version */
body .lh-cloze #clozeContainer .cloze-gap {
  border: 0 !important;
  border-bottom: 2px solid #8eb7e8 !important;
  background: #f3f7fc !important;
}

body .lh-cloze #clozeContainer .cloze-gap.awaiting-drop,
body .lh-cloze #clozeContainer .cloze-gap.drag-over {
  border-bottom-color: var(--blue) !important;
  background: var(--blue-tint) !important;
  box-shadow: 0 0 0 2px rgba(24, 117, 208, 0.25) !important;
}

body .lh-cloze #clozeContainer .cloze-gap.filled {
  border-bottom-color: var(--blue) !important;
  background: var(--blue-tint) !important;
  color: var(--ink) !important;
}

body .lh-cloze #clozeContainer .cloze-gap.filled.correct,
body .lh-cloze #clozeContainer .cloze-gap.correct {
  border-bottom-color: var(--green) !important;
  background: var(--green-tint) !important;
  color: #1e5a3a !important;
}

body .lh-cloze #clozeContainer .cloze-gap.filled.incorrect,
body .lh-cloze #clozeContainer .cloze-gap.incorrect {
  border-bottom-color: var(--red) !important;
  background: var(--red-tint) !important;
  color: #7a1c14 !important;
}

body .lh-cloze #clozeContainer .cloze-gap.revealed {
  border-bottom: 2px dashed #b58a00 !important;
  background: #fdf7dc !important;
  color: #6b5300 !important;
}

body.homework-mode .lh-cloze #clozeContainer .cloze-gap.filled,
body .lh-cloze #clozeContainer .cloze-gap.filled.hw-filled {
  border-bottom-color: #8eb7e8 !important;
  background: var(--blue-tint) !important;
  color: var(--ink) !important;
}

body .lh-cloze #clozeContainer .cloze-gap:focus {
  border-bottom-color: var(--blue) !important;
  background: var(--blue-tint) !important;
}
