/*
 * LVF Course Engine v0.8.0 — Visual Vocabulary Engine
 * Cache-safe, browser-only vocabulary previews for Course / Lesson / Checkpoint content.
 */

/*
 * v0.7.6 — render vocabulary triggers as neutral inline text controls.
 * The runtime converts legacy <button class="lvf-word"> markup to
 * <span role="button" tabindex="0"> so Astra/WordPress button CSS can no
 * longer enlarge the line box. Existing lesson content does not need editing.
 */
.lvf-course-engine-page .lvf-word {
  display: inline !important;
  box-sizing: border-box !important;
  position: static !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0.02em 0.18em !important;
  border: 0 !important;
  border-bottom: 2px dashed #11965b !important;
  border-radius: 3px !important;
  background: #e5f8ed !important;
  color: #087a43 !important;
  font: inherit !important;
  font-weight: 700 !important;
  line-height: inherit !important;
  letter-spacing: inherit !important;
  text-align: inherit !important;
  text-decoration: none !important;
  text-transform: none !important;
  vertical-align: baseline !important;
  white-space: normal !important;
  cursor: pointer !important;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease !important;
}

/* Kill theme-generated decoration/pseudo-elements on ordinary buttons. */
.lvf-course-engine-page .lvf-word::before,
.lvf-course-engine-page .lvf-word::after {
  content: none !important;
  display: none !important;
}

.lvf-course-engine-page .lvf-word:hover,
.lvf-course-engine-page .lvf-word:focus,
.lvf-course-engine-page .lvf-word:focus-visible,
.lvf-course-engine-page .lvf-word:active,
.lvf-course-engine-page .lvf-word[aria-expanded="true"] {
  border-color: #087a43 !important;
  background: #087a43 !important;
  color: #ffffff !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(8, 122, 67, 0.13) !important;
  transform: none !important;
}

/* A graded/assessment region can intentionally suppress vocabulary assistance. */
.lvf-course-engine-page [data-lvf-vocabulary-help="off"] .lvf-word:not([data-lvf-vocabulary-help="on"]),
.lvf-course-engine-page .lvf-word[data-lvf-vocabulary-help="off"],
.lvf-course-engine-page [data-lvf-knowledge-check] .lvf-word:not([data-lvf-vocabulary-help="on"]),
.lvf-course-engine-page [data-lvf-checkpoint-question] .lvf-word:not([data-lvf-vocabulary-help="on"]) {
  border-bottom-color: currentColor !important;
  background: transparent !important;
  color: inherit !important;
  cursor: default;
  pointer-events: none;
  box-shadow: none !important;
}

#lvf-vocabulary-popover {
  position: fixed;
  z-index: 2147483000;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #d3eadd;
  border-radius: 18px;
  background: #ffffff;
  color: #203d2c;
  box-shadow: 0 18px 50px rgba(0, 45, 20, 0.22);
  font-family: Inter, Arial, sans-serif;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}

#lvf-vocabulary-popover[hidden] {
  display: none !important;
}

#lvf-vocabulary-popover * {
  box-sizing: border-box;
}

.lvf-pop-image-wrap {
  position: relative;
  display: block;
  width: 100%;
  height: 185px;
  overflow: hidden;
  background: #eef7f0;
}

.lvf-pop-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: #eef7f0;
}

/*
 * v0.8.0 adaptive media modes.
 * Auto mode is selected in JS from the image's intrinsic aspect ratio.
 * Authors may override with data-image-fit="square|portrait|landscape|contain|cover".
 */
.lvf-pop-image-wrap.lvf-image-square {
  height: auto;
  aspect-ratio: 1 / 1;
  background: #f4faf6;
}

.lvf-pop-image-wrap.lvf-image-square .lvf-pop-image {
  object-fit: contain;
}

.lvf-pop-image-wrap.lvf-image-portrait {
  height: min(390px, 52vh);
  background: #f4faf6;
}

.lvf-pop-image-wrap.lvf-image-portrait .lvf-pop-image {
  object-fit: contain;
}

.lvf-pop-image-wrap.lvf-image-landscape {
  height: 185px;
  aspect-ratio: auto;
}

.lvf-pop-image-wrap.lvf-image-landscape .lvf-pop-image {
  object-fit: cover;
}

.lvf-pop-image-wrap.lvf-image-contain {
  height: min(340px, 48vh);
  background: #f4faf6;
}

.lvf-pop-image-wrap.lvf-image-contain .lvf-pop-image {
  object-fit: contain;
}

.lvf-pop-image-wrap.lvf-image-cover {
  height: 185px;
}

.lvf-pop-image-wrap.lvf-image-cover .lvf-pop-image {
  object-fit: cover;
}

.lvf-pop-image[hidden],
.lvf-pop-image-wrap[hidden] {
  display: none !important;
}

.lvf-pop-content {
  padding: 17px;
}

.lvf-pop-label {
  margin: 0 0 6px;
  color: #088348;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.lvf-pop-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 4px;
}

.lvf-pop-title {
  margin: 0 !important;
  color: #17233b !important;
  font-size: 23px !important;
  font-weight: 800 !important;
  line-height: 1.25 !important;
  letter-spacing: -0.01em;
}

.lvf-pop-speak {
  display: inline-flex !important;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid rgba(8, 122, 67, 0.12) !important;
  border-radius: 50% !important;
  background: #e1f6e9 !important;
  box-shadow: none !important;
  color: #087a43 !important;
  font: inherit;
  font-size: 18px !important;
  line-height: 1 !important;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.lvf-pop-speak:hover,
.lvf-pop-speak:focus,
.lvf-pop-speak:focus-visible,
.lvf-pop-speak:active {
  border-color: rgba(8, 122, 67, 0.28) !important;
  background: #087a43 !important;
  color: #ffffff !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(8, 122, 67, 0.13) !important;
  transform: none !important;
}

.lvf-pop-pos {
  display: none;
  margin: 0 0 10px;
  color: #087a43;
  font-size: 12px;
  font-weight: 750;
  text-transform: lowercase;
}

.lvf-pop-pos:not(:empty) {
  display: block;
}

.lvf-pop-definition,
.lvf-pop-example,
.lvf-pop-meta-row {
  margin: 0;
  color: #586a60;
  font-size: 13px;
  line-height: 1.62;
}

.lvf-pop-definition {
  color: #40554a;
}

.lvf-pop-example,
.lvf-pop-meta-row {
  display: none;
  margin-top: 9px;
}

.lvf-pop-example:not(:empty),
.lvf-pop-meta-row[data-has-content="true"] {
  display: block;
}

.lvf-pop-meta-label {
  color: #253c31;
  font-weight: 800;
}

.lvf-pop-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e7efea;
}

.lvf-pop-link,
.lvf-pop-close {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin: 0 !important;
  padding: 5px 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #087a43 !important;
  font: inherit;
  font-size: 12px !important;
  font-weight: 800 !important;
  line-height: 1.25 !important;
  text-decoration: none !important;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.lvf-pop-link[hidden] {
  display: none !important;
}

.lvf-pop-link:hover,
.lvf-pop-link:focus-visible,
.lvf-pop-close:hover,
.lvf-pop-close:focus-visible {
  background: transparent !important;
  color: #075f34 !important;
  text-decoration: underline !important;
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
}

/* Mobile: use a stable bottom sheet instead of trying to anchor beside inline text. */
@media (max-width: 700px) {
  #lvf-vocabulary-popover {
    right: 10px !important;
    bottom: 10px !important;
    left: 10px !important;
    top: auto !important;
    width: auto;
    max-width: none;
    max-height: min(78vh, 620px);
    border-radius: 20px;
    box-shadow: 0 -10px 42px rgba(0, 45, 20, 0.22);
  }

  .lvf-pop-image-wrap {
    height: min(210px, 27vh);
  }

  .lvf-pop-image {
    height: 100%;
  }

  .lvf-pop-image-wrap.lvf-image-square,
  .lvf-pop-image-wrap.lvf-image-portrait,
  .lvf-pop-image-wrap.lvf-image-contain {
    height: min(360px, 42vh);
    aspect-ratio: auto;
  }

  .lvf-pop-image-wrap.lvf-image-landscape,
  .lvf-pop-image-wrap.lvf-image-cover {
    height: min(210px, 27vh);
  }

  .lvf-pop-content {
    padding: 16px;
  }

  .lvf-pop-title {
    font-size: 22px !important;
  }

  .lvf-pop-actions {
    align-items: stretch;
  }

  .lvf-pop-link,
  .lvf-pop-close {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lvf-course-engine-page .lvf-word {
    transition: none;
  }
}
