/**
 * Task Sidebar — сворачиваемая навигационная панель заданий ЕГЭ
 * Push-layout: контент сдвигается вправо при открытой панели
 */

:root {
  --sidebar-width: 260px;
  --sidebar-width-compact: 4.5rem;
  --sidebar-premium-border: rgba(5, 184, 125, 0.22);
  --sidebar-premium-inset: rgba(255, 255, 255, 0.045);
  --sidebar-premium-shadow: 0 6px 28px rgba(0, 0, 0, 0.32);
}

[data-theme="light"] {
  --sidebar-premium-border: rgba(5, 184, 125, 0.2);
  --sidebar-premium-inset: rgba(255, 255, 255, 0.9);
  --sidebar-premium-shadow: 0 4px 20px rgba(26, 36, 48, 0.08);
}

.task-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 900;
  display: flex;
  pointer-events: none;
}

.task-sidebar__toggle {
  position: fixed;
  top: 0.55rem;
  left: 0.45rem;
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.68rem;
  height: 2.68rem;
  background: rgba(22, 26, 30, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(79, 70, 229, 0.55);
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s, border-color 0.2s, box-shadow 0.2s ease;
  pointer-events: auto;
  z-index: 901;
  box-shadow: 0 10px 26px rgba(79, 70, 229, 0.25), 0 2px 10px rgba(6, 182, 212, 0.2);
  padding: 0.2rem;
}

.task-sidebar__toggle:hover {
  transform: translateY(-1px) scale(1.02);
  background: rgba(26, 31, 44, 0.96);
  border-color: rgba(6, 182, 212, 0.9);
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.32), 0 3px 14px rgba(6, 182, 212, 0.3);
}

.task-sidebar__toggle-icon {
  width: 2.12rem;
  height: 2.12rem;
  overflow: visible;
}

.task-sidebar--open .task-sidebar__toggle {
  display: none;
}

[data-theme="light"] .task-sidebar__toggle {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(79, 70, 229, 0.35);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.16), 0 2px 10px rgba(6, 182, 212, 0.14);
}

[data-theme="light"] .task-sidebar__toggle:hover {
  background: rgba(245, 248, 255, 0.98);
  border-color: rgba(6, 182, 212, 0.75);
}

/* Panel */
.task-sidebar__panel {
  width: var(--sidebar-width-compact);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(26, 31, 37, 0.98) 0%, rgba(14, 18, 23, 0.97) 100%);
  backdrop-filter: blur(16px) saturate(1.06);
  -webkit-backdrop-filter: blur(16px) saturate(1.06);
  border-right: 1px solid var(--sidebar-premium-border);
  box-shadow: var(--sidebar-premium-shadow), inset -1px 0 0 var(--sidebar-premium-inset);
  transform: translateX(0);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  pointer-events: auto;
}

.task-sidebar--open .task-sidebar__panel {
  width: var(--sidebar-width);
}

[data-theme="light"] .task-sidebar__panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 250, 247, 0.96) 100%);
}

/* Page content shift */
.task-solve-page,
.neuroege-hf-task-root {
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              padding-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-sidebar ~ .page.task-solve-page,
.task-sidebar ~ .neuroege-hf-task-root {
  margin-left: var(--sidebar-width-compact);
}

.task-sidebar--open ~ .page.task-solve-page,
.task-sidebar--open ~ .neuroege-hf-task-root {
  margin-left: var(--sidebar-width);
}

/* На страницах HF-задач бейдж "назад" держим немного правее и одинаково */
body.neuroege-hyperformula-page .header.header--task .header__task-badge,
body.neuroege-python-task2-page .header.header--task .header__task-badge {
  margin-left: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
  padding: 0.36rem 0.72rem 0.38rem 0.66rem;
  border-radius: 12px;
  text-decoration: none;
  border: 1px solid rgba(5, 184, 125, 0.3);
  background: linear-gradient(140deg, rgba(22, 28, 34, 0.9) 0%, rgba(15, 19, 24, 0.86) 100%);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

body.neuroege-hyperformula-page .header.header--task .header__task-badge:hover,
body.neuroege-python-task2-page .header.header--task .header__task-badge:hover {
  transform: translateY(-1px);
  border-color: rgba(5, 184, 125, 0.55);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(5, 184, 125, 0.16);
}

body.neuroege-hyperformula-page .header.header--task .header__task-arrow,
body.neuroege-python-task2-page .header.header--task .header__task-arrow {
  font-size: 1rem;
  line-height: 1;
  color: rgba(5, 184, 125, 0.95);
  transform: translateY(-1px);
}

body.neuroege-hyperformula-page .header.header--task .header__task-num,
body.neuroege-python-task2-page .header.header--task .header__task-num {
  display: inline-flex;
  flex-direction: column;
  gap: 0.08rem;
  line-height: 1.15;
}

body.neuroege-hyperformula-page .header.header--task .header__task-num-meta,
body.neuroege-python-task2-page .header.header--task .header__task-num-meta {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.82;
  color: rgba(236, 245, 242, 0.86);
}

body.neuroege-hyperformula-page .header.header--task .header__task-num-title,
body.neuroege-python-task2-page .header.header--task .header__task-num-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.012em;
  color: rgba(246, 252, 250, 0.98);
}

[data-theme="light"] body.neuroege-hyperformula-page .header.header--task .header__task-badge,
[data-theme="light"] body.neuroege-python-task2-page .header.header--task .header__task-badge {
  border-color: rgba(5, 184, 125, 0.28);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.95) 0%, rgba(245, 250, 248, 0.95) 100%);
  box-shadow: 0 4px 14px rgba(26, 36, 48, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

[data-theme="light"] body.neuroege-hyperformula-page .header.header--task .header__task-badge:hover,
[data-theme="light"] body.neuroege-python-task2-page .header.header--task .header__task-badge:hover {
  border-color: rgba(5, 184, 125, 0.48);
  box-shadow: 0 7px 16px rgba(26, 36, 48, 0.12), 0 0 0 1px rgba(5, 184, 125, 0.14);
}

[data-theme="light"] body.neuroege-hyperformula-page .header.header--task .header__task-num-meta,
[data-theme="light"] body.neuroege-python-task2-page .header.header--task .header__task-num-meta {
  color: rgba(25, 35, 46, 0.68);
}

[data-theme="light"] body.neuroege-hyperformula-page .header.header--task .header__task-num-title,
[data-theme="light"] body.neuroege-python-task2-page .header.header--task .header__task-num-title {
  color: rgba(14, 24, 33, 0.95);
}

/* Header */
.task-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.task-sidebar--open .task-sidebar__header {
  padding: 0.8rem 0.85rem;
  background: linear-gradient(
    165deg,
    rgba(5, 184, 125, 0.14) 0%,
    rgba(5, 184, 125, 0.04) 48%,
    transparent 100%
  );
  border-bottom-color: rgba(5, 184, 125, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .task-sidebar__header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .task-sidebar--open .task-sidebar__header {
  background: linear-gradient(
    165deg,
    rgba(5, 184, 125, 0.1) 0%,
    rgba(5, 184, 125, 0.03) 50%,
    transparent 100%
  );
  border-bottom-color: rgba(5, 184, 125, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.task-sidebar__title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
  min-width: 0;
}

.task-sidebar__title-accent {
  flex-shrink: 0;
  width: 3px;
  height: 1.35rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #6ee7b7 0%, #05b87d 55%, #047857 100%);
  box-shadow: 0 0 12px rgba(5, 184, 125, 0.45);
}

.task-sidebar__title-text {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.2;
  color: rgba(236, 252, 245, 0.96);
  text-shadow: 0 1px 14px rgba(5, 184, 125, 0.25);
}

[data-theme="light"] .task-sidebar__title-text {
  color: rgba(14, 42, 32, 0.92);
  text-shadow: none;
}

.task-sidebar__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(5, 184, 125, 0.22);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.task-sidebar__close:hover {
  background: rgba(5, 184, 125, 0.12);
  border-color: rgba(5, 184, 125, 0.45);
  color: rgba(236, 252, 245, 0.98);
  box-shadow: 0 4px 14px rgba(5, 184, 125, 0.2);
  transform: translateY(-1px);
}

.task-sidebar__expand {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  background: linear-gradient(
    165deg,
    rgba(5, 184, 125, 0.16) 0%,
    rgba(5, 184, 125, 0.06) 100%
  );
  border: 1px solid rgba(5, 184, 125, 0.28);
  border-radius: 8px;
  color: rgba(236, 252, 245, 0.88);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.task-sidebar__expand:hover {
  background: linear-gradient(
    165deg,
    rgba(5, 184, 125, 0.28) 0%,
    rgba(5, 184, 125, 0.12) 100%
  );
  border-color: rgba(5, 184, 125, 0.55);
  color: #ecfdf5;
  box-shadow: 0 4px 16px rgba(5, 184, 125, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

[data-theme="light"] .task-sidebar__expand {
  background: linear-gradient(
    165deg,
    rgba(209, 250, 229, 0.95) 0%,
    rgba(236, 253, 245, 0.9) 100%
  );
  border-color: rgba(5, 184, 125, 0.28);
  color: rgba(14, 42, 32, 0.82);
  box-shadow: 0 2px 10px rgba(26, 36, 48, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .task-sidebar__expand:hover {
  background: linear-gradient(
    165deg,
    rgba(167, 243, 208, 0.98) 0%,
    rgba(209, 250, 229, 0.95) 100%
  );
  border-color: rgba(5, 184, 125, 0.45);
  color: #047857;
  box-shadow: 0 4px 14px rgba(5, 184, 125, 0.14);
}

/* Компактный режим — только номера (как variant-exam__nav) */
.task-sidebar:not(.task-sidebar--open) .task-sidebar__expand {
  display: inline-flex;
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__title,
.task-sidebar:not(.task-sidebar--open) .task-sidebar__close {
  display: none;
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__header {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  padding: 0.65rem 0.35rem 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .task-sidebar:not(.task-sidebar--open) .task-sidebar__header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.4rem;
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__item {
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 0;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border-left: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(5, 184, 125, 0.45);
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__item--active {
  background: var(--green, #05b87d);
  border-color: var(--green, #05b87d);
  color: #0a0a0a;
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__item--active:hover {
  background: #04a070;
  border-color: #04a070;
  color: #0a0a0a;
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__item--active .task-sidebar__num {
  background: transparent;
  color: inherit;
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__text {
  display: none;
}

.task-sidebar:not(.task-sidebar--open) .task-sidebar__num {
  width: auto;
  height: auto;
  min-width: 0;
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  background: transparent;
  border-radius: 0;
}

[data-theme="light"] .task-sidebar:not(.task-sidebar--open) .task-sidebar__item {
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.72);
}

[data-theme="light"] .task-sidebar:not(.task-sidebar--open) .task-sidebar__item:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .task-sidebar__close {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(5, 184, 125, 0.22);
  color: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .task-sidebar__close:hover {
  background: rgba(5, 184, 125, 0.1);
  border-color: rgba(5, 184, 125, 0.4);
  color: rgba(14, 42, 32, 0.9);
  box-shadow: 0 4px 12px rgba(5, 184, 125, 0.12);
}

/* Nav list */
.task-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.35rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.task-sidebar__nav::-webkit-scrollbar {
  width: 4px;
}

.task-sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

[data-theme="light"] .task-sidebar__nav {
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

[data-theme="light"] .task-sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
}

.task-sidebar__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.75);
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.task-sidebar__item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.95);
}

.task-sidebar__item--active {
  background: rgba(5, 184, 125, 0.12);
  color: var(--green, #05b87d);
  border-left-color: var(--green, #05b87d);
}

.task-sidebar__item--active:hover {
  background: rgba(5, 184, 125, 0.18);
  color: var(--green, #05b87d);
}

.task-sidebar__item--locked {
  opacity: 0.45;
}

.task-sidebar__item--locked:hover {
  opacity: 0.65;
}

[data-theme="light"] .task-sidebar__item {
  color: rgba(0, 0, 0, 0.65);
}

[data-theme="light"] .task-sidebar__item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: rgba(0, 0, 0, 0.9);
}

[data-theme="light"] .task-sidebar__item--active {
  background: rgba(5, 184, 125, 0.08);
  color: var(--green, #05b87d);
}

.task-sidebar__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.task-sidebar__item--active .task-sidebar__num {
  background: rgba(5, 184, 125, 0.2);
  color: var(--green, #05b87d);
}

[data-theme="light"] .task-sidebar__num {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .task-sidebar__item--active .task-sidebar__num {
  background: rgba(5, 184, 125, 0.15);
}

.task-sidebar__text {
  min-width: 0;
}

.task-sidebar__task-title {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-sidebar__task-sub {
  font-size: 0.65rem;
  opacity: 0.55;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
