/* Text panel, text toolbar, and text-audio layout. Extracted from styles.fixed.css without behavior changes. */

/* ===== Text panel surface ===== */
.text-panel {
  min-width: 360px;
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

/* ===== Text panel typography ===== */
.text-panel h3 {
  margin-top: 0;
  font-size: 1.2rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: #18233f;
  text-align: center;
}

.text-panel h4 {
  text-align: center;
}

/* ===== Text content base ===== */
.text-content {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  font-size: 1rem;
  line-height: 1.72;
  color: #24314f;
}

/* ===== Text toolbar base ===== */
/* =========================
   17. TEXT TOOLBAR
   ========================= */

.text-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 4px 0 8px;
  width: 100%;
}

.text-zoom-controls {
  position: relative;
  display: inline-flex;
  gap: 6px;
  margin-left: 0 !important;
  vertical-align: middle;
  pointer-events: auto !important;
}

.text-zoom-controls * {
  pointer-events: auto !important;
}

#textZoomOutBtn,
#textZoomResetBtn,
#textZoomInBtn {
  position: relative;
  z-index: 5;
}

.text-zoom-controls .small-btn {
  min-width: 48px;
  text-align: center;
}

@media (max-width: 800px) {
  .text-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .text-zoom-controls {
    display: flex;
    justify-content: center;
    margin-top: 0 !important;
  }

  .text-content {
    line-height: 1.62 !important;
  }
}

/* ===== Text audio controls ===== */
#speakTextBtn {
    display: none !important;
}


/* Кнопки аудиоплеера – улучшенный дизайн */
#audioPrevBtn,
#audioPlayPauseBtn,
#audioNextBtn,
#audioStopBtn {
    min-width: 80px;          /* ширина для комфортного нажатия */
    padding: 8px 12px;
    background: linear-gradient(135deg, #1e3c72, #2a5298) !important;
    color: white !important;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 40px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

#audioPrevBtn:hover,
#audioPlayPauseBtn:hover,
#audioNextBtn:hover,
#audioStopBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.audio-btn {
    transition: transform 0.1s ease, background 0.2s;
}

.audio-btn:active {
    transform: scale(0.96);
}

.current-sentence {
  display: inline;
  color: #18233f;
  font-weight: 700;

  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,0.58),
      rgba(255,255,255,0.36)
    ),
    linear-gradient(
      135deg,
      rgba(124,92,255,0.14),
      rgba(79,107,255,0.18)
    );

  border: 1px solid rgba(124, 92, 255, 0.18);
  border-radius: 10px;

  padding: 2px 6px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;

  box-shadow:
    0 6px 16px rgba(124, 92, 255, 0.10),
    inset 0 1px 0 rgba(255,255,255,0.45);

  transition: all 0.2s ease;
}
.audio-btn {
    transition: transform 0.1s ease, background 0.2s;
}
.audio-btn:active {
    transform: scale(0.96);
}
.level-badge {
    background: #4f6bff20;
    border-radius: 40px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1e3c72;
    border: 1px solid #4f6bff40;
}
.text-panel h3 {
    position: sticky;
    top: 0;
    background: inherit;         /* фон подложки */
    backdrop-filter: blur(12px); /* чтобы не просвечивал текст */
    z-index: 5;
    padding: 12px 0;
    margin-top: 0;
}
.highlight-word {
    background: #ffeb3b;
    color: #1e3c72;
    font-weight: bold;
    border-radius: 8px;
    padding: 2px 4px;
    transition: background 0.2s;
}
.text-panel-top {
  position: sticky;
  top: 0;
  z-index: 24;
  width: 100%;
  max-height: 190px;
  overflow: hidden;
  padding: 0 0 8px;
  margin: 0 0 8px;
  background: linear-gradient(
    180deg,
    rgba(248,250,255,0.94) 0%,
    rgba(248,250,255,0.84) 72%,
    rgba(248,250,255,0.00) 100%
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    max-height 0.25s ease,
    padding 0.22s ease,
    margin 0.22s ease;
}

.text-title-wrap {
  width: 100%;
  margin-bottom: 6px;
  padding: 8px 10px 6px;
  border-radius: 16px;
  background: rgba(255,255,255,0.52);
  border: 1px solid rgba(130,148,190,0.10);
  box-shadow: 0 6px 14px rgba(24,35,63,0.03);
}

.text-panel-subtitle {
  margin-top: 4px;
  font-size: 0.74rem;
  line-height: 1.3;
  color: #7d879c;
  font-weight: 600;
}

.text-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 6px;
  padding: 7px 9px;
  border-radius: 16px;
  background: rgba(255,255,255,0.62);
  border: 1px solid rgba(130,148,190,0.12);
  box-shadow: 0 6px 14px rgba(24,35,63,0.03);
}

#textPanelTitle {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  color: #22304d;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.text-zoom-controls {
  display: inline-flex;
  gap: 6px;
  margin-left: 0 !important;
  vertical-align: middle;
  pointer-events: auto !important;
}


.text-panel.leaderboard-mode .text-panel-top {
  opacity: 0;
  transform: translateY(-10px);
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  pointer-events: none;
}
#textContent {
  width: 100%;
  padding: 6px 4px 2px;
  line-height: 1.72;
  color: #2a3550;
}

#textContent br + br {
  content: "";
}

.text-panel-top {
  position: sticky;
  top: 0;
  z-index: 24;
  width: 100%;
  max-height: none;
  overflow: visible;
  padding: 0 0 4px;
  margin: 0 0 4px;
  background: linear-gradient(
    180deg,
    rgba(248,250,255,0.92) 0%,
    rgba(248,250,255,0.78) 62%,
    rgba(248,250,255,0.00) 100%
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    max-height 0.25s ease,
    padding 0.22s ease,
    margin 0.22s ease;
}

.text-title-wrap {
  width: 100%;
  margin-bottom: 4px;
  padding: 5px 8px 4px;
  border-radius: 14px;
  background: rgba(255,255,255,0.42);
  border: 1px solid rgba(130,148,190,0.08);
  box-shadow: 0 4px 10px rgba(24,35,63,0.02);
}

#textPanelTitle {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.18;
  color: #22304d;
  font-weight: 800;
  letter-spacing: 0;
}

.text-title-separator {
  color: #7d879c;
  font-weight: 700;
}

.text-title-ru {
  font-size: 0.86em;
  font-weight: 700;
  color: #4d5c7f;
}

.text-panel-subtitle {
  margin-top: 2px;
  font-size: 0.62rem;
  line-height: 1.2;
  color: #8a94a8;
  font-weight: 600;
}

.text-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 4px;
  padding: 5px 7px;
  border-radius: 14px;
  background: rgba(255,255,255,0.50);
  border: 1px solid rgba(130,148,190,0.10);
  box-shadow: 0 4px 10px rgba(24,35,63,0.02);
}

.text-toolbar .audio-dock-toggle,
.text-toolbar .report-btn {
  flex: 0 0 auto;
}

.text-toolbar .sound-toggle-btn {
  opacity: 0.72;
}

.text-toolbar .report-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
}


#textContent {
  width: 100%;
  padding: 2px 4px 2px;
  line-height: 1.68;
  color: #2a3550;
}
.text-toolbar {
  position: relative;
}

.audio-dock-toggle {
  min-width: 40px;
  min-height: 34px;
  font-size: 0.95rem;
  border-radius: 12px !important;
}

.text-audio-toggle {
  width: 44px;
  min-width: 44px;
  gap: 0;
  justify-content: center;
  padding-inline: 0 !important;
  font-weight: 800;
  color: #fff !important;
  background: linear-gradient(135deg, #4f9fa6, #657bd8) !important;
  border: 1px solid rgba(65, 104, 170, 0.42) !important;
  box-shadow:
    0 9px 20px rgba(65, 104, 170, 0.22),
    inset 0 1px 0 rgba(255,255,255,0.36);
}

.text-audio-toggle:hover,
.text-audio-toggle[aria-expanded="true"] {
  background: linear-gradient(135deg, #428b93, #536bc7) !important;
  box-shadow:
    0 11px 24px rgba(65, 104, 170, 0.28),
    inset 0 1px 0 rgba(255,255,255,0.32);
}

.audio-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: inherit;
  background: transparent;
  box-shadow: none;
  font-size: 0.78rem;
  line-height: 1;
}

.audio-toggle-label {
  font-size: 0.82rem;
  line-height: 1;
}

.audio-dock {
  width: 100%;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  margin: 0;
  transition:
    max-height 0.28s ease,
    opacity 0.2s ease,
    transform 0.2s ease,
    margin 0.2s ease;
}

.audio-dock.open {
  max-height: 260px;
  opacity: 1;
  transform: translateY(0);
  margin: 6px 0 0;
}

.starter-nav-row {
  justify-content: space-between;
  margin-top: 12px;
}

.audio-dock-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(130,148,190,0.14);
  box-shadow:
    0 6px 14px rgba(24,35,63,0.04),
    inset 0 1px 0 rgba(255,255,255,0.82);
}

#audioPrevBtn,
#audioPlayPauseBtn,
#audioNextBtn,
#audioStopBtn {
  min-width: 44px;
  min-height: 34px;
  padding: 6px 10px;
  background: linear-gradient(135deg, #1e3c72, #2a5298) !important;
  color: white !important;
  border: 1px solid rgba(79,107,255,0.18) !important;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 999px !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  transition: all 0.2s ease;
}

#audioPrevBtn:hover,
#audioPlayPauseBtn:hover,
#audioNextBtn:hover,
#audioStopBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.18);
}

.audio-btn {
  transition: transform 0.1s ease, background 0.2s;
}

.audio-btn:active {
  transform: scale(0.96);
}

/* ===== Mobile text panel top ===== */
/* ===== на мобильном улучшаем верхний хвост чтоб не мешал читать текст ===== */
@media (max-width: 800px) {
  .text-panel-top {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    max-height: none !important;
    overflow: visible !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 0 8px !important;
    margin: 0 0 10px !important;
  }

  .text-panel.leaderboard-mode .text-panel-top {
    opacity: 1 !important;
    transform: none !important;
    max-height: none !important;
    pointer-events: auto !important;
    margin: 0 0 10px !important;
    padding: 0 0 8px !important;
  }

  .text-toolbar {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }

  .text-zoom-controls {
    display: inline-flex !important;
    justify-content: flex-start !important;
  }

  .text-audio-toggle {
    width: 46px !important;
    min-width: 46px !important;
    min-height: 42px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    font-size: 1rem !important;
  }

  .audio-toggle-label {
    font-size: 0.96rem !important;
  }

  .audio-dock.open {
    order: 9;
    flex: 1 0 100%;
    margin-top: 8px !important;
  }

  .audio-dock-inner {
    justify-content: space-between !important;
    padding: 10px !important;
    border-radius: 18px !important;
    background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(238,244,255,0.92)) !important;
    border-color: rgba(113,129,255,0.18) !important;
    box-shadow:
      0 12px 26px rgba(31,43,79,0.08),
      inset 0 1px 0 rgba(255,255,255,0.92) !important;
  }

  #audioControlsWrap {
    gap: 6px !important;
  }

  #audioPlayPauseBtn {
    min-width: 64px !important;
  }

  #textContent {
    padding-top: 0 !important;
  }
}

/* ===== Focus mode text panel ===== */
body.practice-focus-mode .text-panel {
  border-radius: 10px !important;
  padding: 14px !important;
}

body.practice-focus-mode .question-card {
  min-height: 0 !important;
  margin: 8px 0 !important;
  padding: 14px !important;
  border-radius: 10px !important;
}

body.practice-focus-mode .question-text {
  margin-bottom: 10px !important;
  padding-left: 8px !important;
  line-height: 1.42 !important;
}

body.practice-focus-mode .options {
  gap: 6px !important;
  margin: 10px 0 !important;
}

body.practice-focus-mode .option {
  min-height: 36px !important;
  padding: 8px 10px !important;
  border-radius: 8px !important;
}

body.practice-focus-mode .text-panel {
  gap: 8px !important;
}

body.practice-focus-mode .text-panel-top {
  display: block !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 24 !important;
  padding: 0 0 4px !important;
  margin: 0 0 4px !important;
  background: linear-gradient(180deg, rgba(248,250,255,0.9), rgba(248,250,255,0.0)) !important;
  pointer-events: auto !important;
}

body.practice-focus-mode .text-title-wrap {
  display: none !important;
}

body.practice-focus-mode .text-toolbar {
  display: flex !important;
  width: fit-content !important;
  max-width: 100% !important;
  margin-left: auto !important;
  padding: 4px 5px !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,0.62) !important;
  box-shadow: 0 6px 14px rgba(24,35,63,0.04) !important;
}

body.practice-focus-mode .text-zoom-controls {
  display: inline-flex !important;
}

body.practice-focus-mode #textContent {
  line-height: 1.5 !important;
  padding: 0 !important;
}

.text-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.text-title-row .text-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.text-title-row .text-toolbar {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

.text-title-row .text-toolbar.practice-settings-host {
  justify-content: flex-end !important;
}

.text-title-row .text-panel-subtitle {
  display: none !important;
}

@media (max-width: 800px) {
  .text-title-row {
    align-items: flex-start;
  }

  .text-title-row .text-toolbar {
    flex-direction: row;
    align-items: center;
  }
}


.text-panel-top:has(.text-toolbar.settings-open) > .audio-dock.open {
  margin-top: 58px;
}

@media (max-width: 800px) {
  .text-panel-top:has(.text-toolbar.settings-open) > .audio-dock.open {
    margin-top: 66px !important;
  }
}
