/* Vocabulary SunePlay shell — layout overrides (load after sune-play-lesson.css) */

.sp-lesson-mount--enter {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.38s ease, transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.sp-lesson-mount--enter.sp-lesson-mount--enter-active {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .sp-lesson-mount--enter {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) {
  min-height: 100dvh;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) #app,
body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) .app-container,
body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) #main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) .dashboard-layout--lesson-focus {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0 !important;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) .dashboard-layout--lesson-focus > .dashboard-center.course-center--lesson-focus {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100dvh;
  overflow: hidden;
  width: 100%;
  min-width: 0;
  max-width: 880px;
  margin-inline: auto;
  margin-left: auto;
  padding: 0;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) #feCenterSection.fe-section--vocab-exercise {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) #feCenterSection .sp-lesson-mount,
body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) #feCenterSection .sp-lesson,
body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) #feCenterSection .sp-practice-session {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  height: 100%;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) #feCenterSection .sp-practice-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-screen--conversation-gap) #feCenterSection .sp-practice-main,
body:has(#feCenterSection.fe-section--vocab-exercise .pv-conv-story-wrap--fill) #feCenterSection .sp-practice-main,
body:has(#feCenterSection.fe-section--vocab-exercise .pv-conv-story-wrap--drag) #feCenterSection .sp-practice-main,
body:has(#feCenterSection.fe-section--vocab-exercise .pv-conv-story-wrap--listen) #feCenterSection .sp-practice-main {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-screen--conversation-gap) #feCenterSection .sp-practice-body,
body:has(#feCenterSection.fe-section--vocab-exercise .pv-conv-story-wrap--drag) #feCenterSection .sp-practice-body,
body:has(#feCenterSection.fe-section--vocab-exercise .pv-conv-story-wrap--listen) #feCenterSection .sp-practice-body {
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body:has(#feCenterSection.fe-section--vocab-exercise .sp-screen--conversation-gap) #feCenterSection .sp-exercise-card,
body:has(#feCenterSection.fe-section--vocab-exercise .pv-conv-story-wrap--drag) #feCenterSection .sp-exercise-card,
body:has(#feCenterSection.fe-section--vocab-exercise .pv-conv-story-wrap--listen) #feCenterSection .sp-exercise-card {
  overflow: hidden;
  flex: 1 1 0;
  height: 0;
  min-height: 0;
}

@media (min-width: 768px) {
  body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) .dashboard-layout--lesson-focus > .dashboard-center.course-center--lesson-focus {
    max-width: 960px;
  }
}

@media (max-width: 768px) {
  body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson-mount) .dashboard-center.course-center--lesson-focus.fe-vocab-sp-center {
    min-height: 0;
    max-height: 100dvh;
  }
}

/* Key Word Transformation theory — one visual grammar for every case */
.sp-theory-card--kwt {
  --kwt-violet: #7c3aed;
  --kwt-violet-dark: #5b21b6;
  --kwt-violet-soft: #f5f3ff;
  --kwt-violet-border: #ddd6fe;
  --kwt-clue: #d85a30;
  --kwt-structure-bg: #e1f5ee;
  --kwt-structure-text: #085041;
  border-color: rgba(124, 58, 237, 0.38);
  background:
    radial-gradient(circle at 100% 0%, rgba(237, 233, 254, 0.92), transparent 34%),
    #fff;
}

.sp-theory-card--kwt .sp-theory-card-eyebrow,
.sp-theory-card--kwt .sp-theory-section-title .material-symbols-outlined {
  color: var(--kwt-violet);
}

.sp-theory-card--kwt .sp-theory-card-title {
  color: var(--kwt-violet-dark);
}

.sp-theory-card--kwt .sp-theory-card-body {
  border-top-color: var(--kwt-violet-border);
}

.sp-theory-card--kwt .sp-theory-section {
  border-color: #e9e3fb;
  background: rgba(250, 248, 255, 0.78);
}

.sp-theory-card--kwt .sp-theory-explanation {
  position: relative;
  padding-left: 20px;
  background: #fff;
}

.sp-theory-card--kwt .sp-theory-explanation::before {
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 0;
  width: 4px;
  border-radius: 0 99px 99px 0;
  background: linear-gradient(180deg, var(--kwt-violet), #a78bfa);
  content: '';
}

.sp-theory-card--kwt .sp-form-table-row {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 16px 18px 17px 20px;
  border-color: var(--kwt-violet-border);
  border-radius: 16px;
  background:
    linear-gradient(105deg, rgba(245, 243, 255, 0.92) 0, rgba(255, 255, 255, 0) 42%),
    #fff;
  box-shadow:
    0 1px 2px rgba(76, 29, 149, 0.04),
    0 8px 24px rgba(76, 29, 149, 0.06);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.sp-theory-card--kwt .sp-form-table-row::before {
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: 16px 0 0 16px;
  background: linear-gradient(180deg, var(--kwt-violet), #a78bfa);
  content: '';
}

@media (hover: hover) {
  .sp-theory-card--kwt .sp-form-table-row:hover {
    border-color: #c4b5fd;
    box-shadow:
      0 2px 4px rgba(76, 29, 149, 0.05),
      0 12px 28px rgba(76, 29, 149, 0.1);
    transform: translateY(-2px);
  }
}

.sp-theory-card--kwt .sp-form-table-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 12px;
  padding: 4px 9px;
  border: 1px solid #fed7c7;
  border-radius: 999px;
  background: #fff4ee;
  color: #b94321;
  font-size: 0.7rem;
  letter-spacing: 0.025em;
  line-height: 1.2;
  text-decoration: none;
}

.sp-theory-card--kwt .sp-form-table-cols {
  display: grid;
  grid-template-columns: minmax(210px, 0.95fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 42px;
}

.sp-theory-card--kwt .sp-form-table-left {
  display: flex;
  align-items: center;
  width: auto;
  min-width: 0;
  padding: 10px 13px;
  border: 1px solid #b9e5d6;
  border-radius: 11px;
  background: linear-gradient(135deg, #ddf5ec, #edf9f5);
  color: var(--kwt-structure-text);
  font-weight: 700;
  box-shadow: inset 3px 0 0 #43a98b;
}

.sp-theory-card--kwt .sp-form-table-right {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  color: #3f4770;
}

.sp-theory-card--kwt .sp-form-table-right::before {
  position: absolute;
  left: -30px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--kwt-violet-border);
  border-radius: 50%;
  background: #fff;
  color: var(--kwt-violet);
  content: '→';
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(76, 29, 149, 0.1);
}

.sp-theory-card--kwt .sp-remember-box--watchout {
  border-color: #fed7aa;
  background: #fff7ed;
}

.sp-theory-card--kwt .sp-transform-guide {
  border-color: var(--kwt-violet-border);
  border-left-color: var(--kwt-violet);
  background: var(--kwt-violet-soft);
}

.sp-theory-card--kwt .sp-transform-guide-icon,
.sp-theory-card--kwt .sp-transform-guide-title,
.sp-theory-card--kwt .sp-transform-arrow {
  color: var(--kwt-violet);
}

.sp-theory-card--kwt .sp-transform-sentence--active {
  border-color: #cbd5e1;
  background: #fff;
}

.sp-theory-card--kwt .sp-transform-sentence--active .sp-transform-label {
  color: #64748b;
}

.sp-theory-card--kwt .sp-transform-sentence--passive {
  border-color: #86efac;
  background: #f0fdf4;
}

.sp-theory-card--kwt .sp-transform-step-num {
  background: var(--kwt-violet);
  color: #fff;
}

.sp-theory-card--kwt .sp-transform-step--final {
  border-color: #86efac;
  background: #f0fdf4;
}

.sp-theory-card--kwt .sp-transform-build--final {
  border-color: #86efac;
  background: #fff;
}

.sp-theory-card--kwt .sp-kwt-worked {
  display: grid;
  gap: 16px;
  min-width: 0;
  border: 0;
  background: transparent;
}

.sp-kwt-exam,
.sp-kwt-solution,
.sp-kwt-why {
  min-width: 0;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
}

.sp-kwt-block-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--kwt-violet-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sp-kwt-block-heading .material-symbols-outlined {
  font-size: 20px;
}

.sp-kwt-exam-sentence {
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.sp-kwt-field-label {
  display: block;
  margin-bottom: 7px;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sp-kwt-exam-sentence p,
.sp-kwt-solution-sentence {
  margin: 0;
  color: #1f2937;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.sp-kwt-given-word {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
  padding: 0 8px;
  color: #64748b;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sp-kwt-given-word strong {
  padding: 6px 13px;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  background: var(--kwt-violet-soft);
  color: var(--kwt-violet-dark);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.sp-kwt-exam-sentence--target {
  border-color: var(--kwt-violet-border);
  background: #faf8ff;
}

.sp-kwt-clue-highlight {
  padding: 1px 3px;
  border-radius: 4px;
  background: #fff0e8;
  color: #a43d1f;
  font-weight: 750;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.sp-kwt-solution {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.sp-kwt-block-heading--solution {
  color: #15803d;
}

.sp-kwt-solution-sentence {
  padding: 14px 16px;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  background: #fff;
}

.sp-kwt-answer-build {
  white-space: nowrap;
}

.sp-kwt-answer-keyword,
.sp-kwt-answer-support,
.sp-kwt-answer-auxiliary,
.sp-kwt-answer-tone,
.sp-kwt-structure-highlight {
  display: inline;
  padding: 3px 7px;
  border-radius: 6px;
  font-weight: 800;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.sp-kwt-answer-keyword,
.sp-kwt-answer-tone-0 {
  background: #ede9fe;
  color: #5b21b6;
}

.sp-kwt-answer-auxiliary,
.sp-kwt-answer-tone-1 {
  background: #dbeafe;
  color: #1d4ed8;
}

.sp-kwt-answer-support,
.sp-kwt-answer-tone-2,
.sp-kwt-structure-highlight {
  background: var(--kwt-structure-bg);
  color: var(--kwt-structure-text);
}

.sp-kwt-answer-tone-3 {
  background: #ffedd5;
  color: #c2410c;
}

.sp-kwt-answer-tone-4 {
  background: #fce7f3;
  color: #be185d;
}

.sp-kwt-answer-key {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.sp-kwt-answer-key-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.sp-kwt-answer-key-item > span {
  flex-shrink: 0;
  white-space: nowrap;
}

.sp-kwt-answer-key-item small {
  color: #475569;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
}

.sp-kwt-why {
  border-color: var(--kwt-violet-border);
  background: var(--kwt-violet-soft);
}

.sp-kwt-rule-map {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  background: #fff;
}

.sp-kwt-rule-clue,
.sp-kwt-rule-formula {
  min-width: 0;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.45;
}

.sp-kwt-rule-clue {
  background: #fff0e8;
  color: #a43d1f;
}

.sp-kwt-rule-formula {
  background: var(--kwt-structure-bg);
  color: var(--kwt-structure-text);
}

.sp-kwt-rule-arrow {
  flex: 0 0 auto;
  color: var(--kwt-violet);
  font-size: 20px;
}

.sp-kwt-why-copy,
.sp-kwt-use-when {
  margin: 12px 2px 0;
  color: #334155;
  font-size: 1.05rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.sp-kwt-use-when {
  padding-top: 10px;
  border-top: 1px solid #ddd6fe;
}

.sp-kwt-use-when strong {
  color: var(--kwt-violet-dark);
}

@media (max-width: 520px) {
  .sp-theory-card--kwt .sp-form-table-cols {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .sp-theory-card--kwt .sp-form-table-right {
    padding: 10px 2px 0;
    border-top: 1px dashed #d8d0ee;
  }

  .sp-theory-card--kwt .sp-form-table-right::before {
    display: none;
  }

  .sp-theory-card--kwt {
    padding: 14px;
  }

  .sp-theory-card--kwt .sp-theory-card-body {
    gap: 12px;
    padding: 14px 6px 8px 0;
  }

  .sp-theory-card--kwt .sp-kwt-worked {
    gap: 12px;
  }

  .sp-kwt-exam,
  .sp-kwt-solution,
  .sp-kwt-why {
    padding: 14px;
    border-radius: 13px;
  }

  .sp-kwt-exam-sentence p,
  .sp-kwt-solution-sentence {
    font-size: clamp(0.96rem, 4.2vw, 1rem);
    line-height: 1.6;
  }

  .sp-kwt-answer-build {
    white-space: normal;
  }

  .sp-kwt-rule-map {
    align-items: stretch;
    flex-direction: column;
  }

  .sp-kwt-rule-arrow {
    align-self: center;
    transform: rotate(90deg);
  }
}

/* KWT theory — mobile-only layout and navigation fixes */
@media (max-width: 767px) {
  body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson--theory) #feCenterSection.fe-section--vocab-exercise {
    overflow: hidden;
  }

  body:has(#feCenterSection.fe-section--vocab-exercise .sp-lesson--theory) .dashboard-layout--lesson-focus > .dashboard-center.course-center--lesson-focus {
    min-height: 0;
    max-height: 100dvh;
    padding-inline: max(8px, env(safe-area-inset-left, 0px)) max(8px, env(safe-area-inset-right, 0px));
  }

  .sp-theory-flow:has(.sp-theory-card--kwt) {
    gap: 8px;
    min-height: 0;
  }

  /* Keep card dots visible so every theory section is reachable on touch devices */
  .sp-theory-flow:has(.sp-theory-card--kwt) .sp-theory-progress {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "copy"
      "dots"
      "track";
    gap: 6px;
    padding-inline: 2px;
  }

  .sp-theory-flow:has(.sp-theory-card--kwt) .sp-theory-progress .sp-theory-dots {
    display: flex;
    grid-area: dots;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 2px 0 4px;
    margin: 0 -2px;
  }

  .sp-theory-flow:has(.sp-theory-card--kwt) .sp-theory-progress .sp-theory-dots::-webkit-scrollbar {
    display: none;
  }

  .sp-theory-flow:has(.sp-theory-card--kwt) .sp-theory-progress .sp-theory-dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
  }

  .sp-theory-flow:has(.sp-theory-card--kwt) .sp-theory-progress .sp-theory-dot--active {
    width: 24px;
  }

  .sp-theory-flow:has(.sp-theory-card--kwt) .sp-theory-progress-track {
    height: 6px;
  }

  .sp-theory-flow:has(.sp-theory-card--kwt) .sp-theory-progress-fill {
    background: linear-gradient(90deg, var(--kwt-violet, #7c3aed), #a78bfa);
  }

  .sp-theory-card--kwt {
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
    min-height: 0;
  }

  .sp-theory-card--kwt .sp-theory-card-title {
    font-size: 1.1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .sp-theory-card--kwt .sp-theory-card-subtitle {
    font-size: 0.82rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .sp-theory-card--kwt .sp-theory-card-body {
    gap: 12px;
    padding: 12px 6px 8px 0;
  }

  .sp-theory-card--kwt .sp-theory-section {
    padding: 12px;
    border-radius: 14px;
  }

  .sp-theory-card--kwt .sp-theory-explanation {
    padding-left: 16px;
  }

  .sp-theory-card--kwt .sp-theory-explanation::before {
    top: 12px;
    bottom: 12px;
    width: 3px;
  }

  .sp-theory-card--kwt .sp-transform-guide {
    border: 1px solid var(--kwt-violet-border);
    border-left: 3px solid var(--kwt-violet);
    border-radius: 14px;
    padding: 12px;
    background: var(--kwt-violet-soft);
  }

  .sp-theory-card--kwt .sp-transform-comparison {
    gap: 8px;
    margin-bottom: 12px;
  }

  .sp-theory-card--kwt .sp-transform-sentence {
    padding: 10px;
    border-radius: 12px;
  }

  .sp-theory-card--kwt button.sp-transform-sentence-text.sp-speakable,
  .sp-theory-card--kwt button.sp-transform-build-text.sp-speakable {
    font-size: 0.88rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .sp-theory-card--kwt .sp-transform-steps {
    gap: 10px;
    padding-left: 0;
  }

  .sp-theory-card--kwt .sp-transform-step {
    gap: 10px;
    align-items: flex-start;
  }

  .sp-theory-card--kwt .sp-transform-step-num {
    width: 26px;
    height: 26px;
    font-size: 0.78rem;
    flex-shrink: 0;
  }

  .sp-theory-card--kwt .sp-transform-step-text {
    font-size: 0.86rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  .sp-theory-card--kwt .sp-transform-build {
    padding: 10px;
    border-radius: 10px;
    font-size: 0.86rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .sp-theory-card--kwt .sp-theory-scroll-progress {
    top: 96px;
    right: 4px;
    bottom: 18px;
  }

  .sp-theory-card--kwt .sp-theory-scroll-hint {
    right: 12px;
    bottom: 10px;
    font-size: 0.62rem;
    padding: 4px 8px;
  }

  .sp-lesson--theory:has(.sp-theory-card--kwt) .sp-theory-nav--next {
    border-color: var(--kwt-violet, #7c3aed);
    color: #fff;
    background: var(--kwt-violet, #7c3aed);
    box-shadow: 0 3px 0 var(--kwt-violet-dark, #5b21b6);
  }

  .sp-lesson--theory:has(.sp-theory-card--kwt) .sp-theory-nav--next:active:not(:disabled) {
    box-shadow: 0 1px 0 var(--kwt-violet-dark, #5b21b6);
  }

  .sp-lesson--theory:has(.sp-theory-card--kwt) .sp-theory-nav--prev {
    min-height: 46px;
  }

  .sp-lesson--theory:has(.sp-theory-card--kwt) .sp-theory-nav--next {
    min-height: 46px;
  }
}
