/* ============================================================
   IDE LESSON / QUESTION PAGES - MOBILE & TABLET RESPONSIVE
   Подключается после ide-lesson.css или inline-стилей FE-вопросов.
============================================================ */

/* -- IDE mobile nav drawer -- */
.ide-mobile-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.ide-mobile-nav-overlay--open {
  opacity: 1;
  visibility: visible;
}

.ide-mobile-nav {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 100vw);
  height: 100%;
  height: 100dvh;
  z-index: 501;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary, #26282c);
  border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) 0;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
}

.ide-mobile-nav--open {
  transform: translateX(0);
}

.ide-mobile-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.ide-mobile-nav__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #fff);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ide-mobile-nav__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #aaa);
  cursor: pointer;
  font-size: 16px;
}

.ide-mobile-nav__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

.ide-mobile-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary, #e8e8e8);
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s;
  min-height: 44px;
}

.ide-mobile-nav__link:hover,
.ide-mobile-nav__link:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary, #fff);
}

.ide-mobile-nav__link--donate {
  margin-top: 8px;
  background: rgba(255, 197, 1, 0.1);
  color: #ffc501;
  border: 1px solid rgba(255, 197, 1, 0.25);
}

.ide-mobile-nav__link i {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.85;
}

.ide-mobile-nav__lang {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ide-mobile-nav__lang-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary, rgba(255, 255, 255, 0.45));
  padding: 0 4px;
}

.ide-mobile-nav__lang-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  background: transparent;
  color: var(--text-primary, #e8e8e8);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  text-align: left;
  font-family: inherit;
}

.ide-mobile-nav__lang-btn:hover,
.ide-mobile-nav__lang-btn:focus-visible {
  background: rgba(108, 124, 255, 0.12);
  outline: none;
}

.ide-mobile-nav__lang-btn.header-language-switch__option--active {
  border-color: rgba(108, 124, 255, 0.45);
  background: rgba(108, 124, 255, 0.16);
}

/* -- Frontend practice IDE: burger ≤1240px -- */
@media (max-width: 1240px) {
  body.practice-fe-header .ide-header-right .header-burger-wrapper {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0;
  }

  body.practice-fe-header .ide-header-right .header-menu-btn,
  body.practice-fe-header .ide-header-right .ide-burger-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
  }

  body.practice-fe-header .ide-header-btn--nav,
  body.practice-fe-header .ide-header-btn--donate,
  body.practice-fe-header .ide-header .header-language-switch {
    display: none !important;
  }
}

/* -- Frontend lesson header: burger ≤1300px (с FAB и компактным layout) -- */
@media (max-width: 1300px) {
  body.lesson-fe-dash-layout .ide-header-right .header-burger-wrapper {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0;
  }

  body.lesson-fe-dash-layout .ide-header-right .header-menu-btn,
  body.lesson-fe-dash-layout .ide-header-right .ide-burger-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
  }

  body.lesson-fe-dash-layout .ide-header-btn--nav,
  body.lesson-fe-dash-layout .ide-header-btn--donate,
  body.lesson-fe-dash-layout .ide-header .header-language-switch {
    display: none !important;
  }
}

/* -- Tablet (≤1024px) -- */
@media (max-width: 1024px) {
  .ide-header {
    padding: 0 12px;
    gap: 8px;
  }

  .ide-lesson-nav-btn {
    max-width: 140px;
    font-size: 12px;
    padding: 5px 8px;
  }

  .ide-task-content {
    padding: 22px 20px 16px;
  }
}

/* -- Mobile layout stack (≤768px) -- */
@media (max-width: 768px) {
  html:has(body.ide-page),
  body.ide-page {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  .ide-header {
    height: auto;
    min-height: 48px;
    padding: 6px 10px;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .ide-header-left {
    flex: 1;
    min-width: 0;
    gap: 6px;
    overflow: hidden;
  }

  .ide-logo-text {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  .ide-logo-img {
    width: 24px;
    height: 24px;
  }

  .ide-lesson-nav-btn {
    max-width: none;
    flex: 1;
    min-width: 0;
    justify-content: center;
    font-size: 11px;
    padding: 6px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ide-lesson-nav-btn i {
    flex-shrink: 0;
  }

  .ide-breadcrumb {
    display: none;
  }

  .ide-header-sep {
    display: none;
  }

  .ide-header-right {
    gap: 4px;
    flex-shrink: 0;
  }

  .ide-header-btn--donate,
  .ide-header-btn--nav {
    display: none;
  }

  .ide-theme-btn,
  .ide-burger-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .ide-burger-btn {
    display: flex;
  }

  .ide-workspace {
    flex-direction: column;
    min-height: 0;
  }

  .ide-left {
    flex: 0 0 42%;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .ide-left[style*="flex"] {
    flex: 0 0 42% !important;
  }

  .ide-resizer {
    display: none;
  }

  .ide-right {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
  }

  .ide-editor-header {
    height: 36px;
  }

  .ide-editor-tab {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .ide-editor-actions {
    padding: 0 6px;
  }

  .ide-console {
    height: 120px;
    min-height: 72px;
    max-height: 40%;
  }

  .ide-task-header {
    height: auto;
    min-height: 36px;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .ide-task-breadcrumb {
    font-size: 11px;
    flex: 1 1 100%;
    order: 2;
  }

  .ide-task-progress {
    font-size: 11px;
    margin-left: auto;
  }

  .ide-task-content {
    padding: 16px 14px 12px;
  }

  .ide-task-title {
    font-size: 18px;
    margin-bottom: 12px;
  }

  .ide-task-desc {
    font-size: 13px;
    margin-bottom: 16px;
  }

  .ide-task-box {
    padding: 14px;
    margin-bottom: 16px;
  }

  .ide-task-snippet,
  .ide-explanation-pre,
  .ide-code-block pre {
    font-size: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .ide-code-block {
    max-width: 100%;
    overflow: hidden;
  }

  .ide-task-actions {
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .ide-task-actions-right {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
  }

  .ide-btn {
    padding: 8px 12px;
    font-size: 12px;
    min-height: 40px;
  }

  .ide-btn--check {
    padding: 8px 14px;
  }

  .ide-lessons-panel {
    width: min(300px, 88vw);
  }

  .ide-lessons-panel-title {
    font-size: 13px;
    line-height: 1.35;
  }

  .ide-lesson-item {
    font-size: 13px;
    padding: 10px 14px;
  }

  .ide-task-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* -- Small phones (≤600px) -- */
@media (max-width: 600px) {
  .ide-left {
    flex: 0 0 38%;
  }

  .ide-task-title {
    font-size: 17px;
  }

  .ide-task-number {
    font-size: 12px;
  }

  .ide-task-badge {
    font-size: 10px;
    padding: 2px 8px;
  }

  .ide-explanation-toggle {
    font-size: 13px;
    padding: 10px 12px;
  }

  .ide-history-restore {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* -- Narrow phones (≤480px) -- */
@media (max-width: 480px) {
  .ide-header {
    padding: 6px 8px;
  }

  .ide-logo-text {
    display: none;
  }

  .ide-lesson-nav-btn {
    font-size: 10px;
    padding: 5px 6px;
  }

  .ide-left {
    flex: 0 0 36%;
  }

  .ide-editor-kbd-hint {
    display: none;
  }

  .ide-task-progress-dots {
    display: none;
  }

  .ide-task-content {
    padding: 14px 12px 10px;
  }

  .ide-task-title {
    font-size: 16px;
  }

  .ide-task-actions {
    padding: 6px 8px;
  }

  .ide-btn--back span,
  .ide-btn--next span {
    display: none;
  }

  .ide-btn--back,
  .ide-btn--next {
    padding: 8px 10px;
  }

  .ide-console-body {
    font-size: 12px;
    padding: 8px 10px;
  }

  .ide-lessons-panel {
    width: 100%;
    max-width: 100%;
  }
}

/* -- Very small (≤380px) -- */
@media (max-width: 380px) {
  .ide-left {
    flex: 0 0 34%;
  }

  .ide-task-actions-right {
    width: 100%;
    justify-content: stretch;
  }

  .ide-task-actions-right .ide-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .ide-btn--helper {
    display: none;
  }
}

/* -- Landscape phones -- */
@media (max-width: 896px) and (orientation: landscape) and (max-height: 500px) {
  .ide-workspace {
    flex-direction: row;
  }

  .ide-left {
    flex: 0 0 48% !important;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
    max-height: 100%;
  }

  .ide-right {
    flex: 1;
    min-width: 0;
  }

  .ide-console {
    height: 90px;
    max-height: 35%;
  }
}

/* -- Touch: disable pane resize handles -- */
@media (hover: none) and (pointer: coarse) {
  .ide-resizer,
  .ide-console-resizer {
    touch-action: none;
  }
}
