/* ==========================================================================
   ХКМ.PRO — тёмная тема (Technical Blue Dark) + кнопка переключения темы.
   Подключается ПОСЛЕ css/styles.css. Светлая тема не меняется.
   Принцип: переопределение CSS-переменных для [data-theme="dark"] +
   точечные правила для мест, где в styles.css заданы «жёсткие» светлые цвета.
   Технические схемы (SVG-контур, диаграмма P–h, схема диагностики, график
   вакуума, экран видеолекции) остаются светлыми «приборными экранами»:
   их цвета рисуются JS-модулями, поэтому внутри них возвращается светлая палитра.
   ========================================================================== */

/* ---------- Кнопка переключения темы и адаптивная сетка (обе темы) ---------- */
:root { color-scheme: light; }

.hero-grid > *,
.cycle-visuals-grid > *,
.infographic-dual-grid > *,
.lab3d-workspace > *,
.lectures-layout > *,
.ff-grid > *,
.vc-grid > * {
  min-width: 0;
}

.hero-3d-canvas-wrap,
.lab3d-canvas-box {
  overflow: hidden;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--sky-border);
  background: var(--bg-ice);
  color: var(--blue-deep);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.theme-toggle-btn:hover { background: var(--bg-cyan-soft); border-color: var(--cyan-bright); transform: translateY(-1px); }
.theme-toggle-btn:focus-visible { outline: 2px solid var(--cyan-bright); outline-offset: 2px; }

/* ---------- Палитра тёмной темы ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-white: #0f1824;      /* поверхности карточек */
  --bg-ice: #0b131d;        /* вторичный фон, поля ввода */
  --bg-ice-2: #142233;      /* активные/выделенные поверхности */
  --bg-cyan-soft: #12304a;  /* hover-поверхности */

  --cyan-neon: #22d3ff;
  --cyan-bright: #1fb6ff;
  --sky-vivid: #38bdf8;
  --sky-light: #2b4a68;     /* используется как цвет рамок */
  --sky-border: #1e3248;    /* основной цвет рамок */

  --blue-action: #1f95e6;
  --blue-deep: #e3eefb;     /* заголовки и основной акцентный текст */
  --blue-text: #c6d7ea;     /* основной текст */
  --blue-muted: #8ea9c6;    /* вторичный текст */

  --glass-bg: rgba(15, 24, 36, 0.88);
  --glass-border: rgba(56, 189, 248, 0.18);
  --shadow-ice: 0 14px 40px -12px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 26px rgba(31, 182, 255, 0.25);
}

/* Текст на акцентных (синих) кнопках и плашках: в светлой теме он берётся из --bg-white,
   в тёмной --bg-white стал тёмным, поэтому явно возвращаем белый. */
[data-theme="dark"] .brand-cube,
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-mini:hover,
[data-theme="dark"] .hud-btn:hover,
[data-theme="dark"] .marquee-strip,
[data-theme="dark"] .tab-pill.active,
[data-theme="dark"] .install-step-btn.active,
[data-theme="dark"] .lab-tab.active,
[data-theme="dark"] .tool-toggle.active,
[data-theme="dark"] .hotspot-pin.active,
[data-theme="dark"] .part-chip:hover,
[data-theme="dark"] .chapter-chip.active,
[data-theme="dark"] .game-tab.active,
[data-theme="dark"] .ff-case-pill.active,
[data-theme="dark"] .ff-tool-btn.used,
[data-theme="dark"] .ff-option-btn.correct,
[data-theme="dark"] .vc-action-btn:hover,
[data-theme="dark"] .btn-auth-pill,
[data-theme="dark"] .prof-avatar-lg,
[data-theme="dark"] .modal-close:hover,
[data-theme="dark"] .ach-card.unlocked .ach-icon,
[data-theme="dark"] .ref-brand-btn.active,
[data-theme="dark"] .vc-scen-tab.active,
[data-theme="dark"] .vc-tool-chip.connected {
  color: #ffffff;
}

/* ---------- Глобальный фон и шапка ---------- */
[data-theme="dark"] body {
  background: linear-gradient(180deg, #080e16 0%, #0a121c 45%, #080e16 100%);
}
[data-theme="dark"] .site-header { background: rgba(9, 15, 23, 0.9); }
[data-theme="dark"] .xp-pill { background: linear-gradient(135deg, #0f1824, var(--bg-ice-2)); }
[data-theme="dark"] input[type="range"]::-webkit-slider-thumb { border-color: #0f1824; }

@media (max-width: 760px) {
  [data-theme="dark"] .main-nav { background: rgba(9, 15, 23, 0.98); }
}

/* ---------- Hero ---------- */
[data-theme="dark"] .hero-section {
  background: radial-gradient(circle at 80% 20%, rgba(0, 150, 220, 0.18), transparent 45%),
              radial-gradient(circle at 12% 75%, rgba(56, 189, 248, 0.10), transparent 42%),
              #080e16;
}
[data-theme="dark"] .hero-glow-1 { background: rgba(0, 170, 255, 0.14); }
[data-theme="dark"] .hero-glow-2 { background: rgba(56, 189, 248, 0.10); }
[data-theme="dark"] .hero-3d-frame { background: linear-gradient(155deg, #0f1824 0%, #0c1a2a 100%); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
[data-theme="dark"] .hero-3d-topbar { background: rgba(12, 20, 31, 0.9); }
[data-theme="dark"] .hero-3d-hud { background: rgba(12, 20, 31, 0.92); }

/* ---------- Секции ---------- */
[data-theme="dark"] .section-alt { background: linear-gradient(180deg, #0b131d 0%, #080e16 55%, #0b131d 100%); }
[data-theme="dark"] .legend-pill.high-p { background: #12304a; }
[data-theme="dark"] .legend-pill.low-p { background: #0f1f30; }
[data-theme="dark"] .formula-box { background: linear-gradient(135deg, #0f1c2b, #12263a); }
[data-theme="dark"] .ff-thermo-box { background: linear-gradient(135deg, #0f1c2b, #12263a); }

/* 3D-лаборатория (сами 3D-сцены стоят на собственном синем «стенде» и не меняются) */
[data-theme="dark"] .lab3d-viewport-wrap { background: radial-gradient(circle at center, #10203a 0%, #0b131d 100%); }
[data-theme="dark"] .lab3d-toolbar { background: rgba(12, 20, 31, 0.94); }
[data-theme="dark"] .hotspot-pin { background: rgba(12, 20, 31, 0.94); }
[data-theme="dark"] .hotspot-dot { border-color: #0f1824; }

/* Лекции */
[data-theme="dark"] .lecture-nav-item.active { background: linear-gradient(135deg, var(--bg-ice-2), #0f1824); }
[data-theme="dark"] .lecture-quiz-status.err { background: #2a1214; border-color: #7f1d1d; color: #fecaca; }

/* Справочник и обратная связь */
[data-theme="dark"] .ref-row-highlight { background: #12304a; }
[data-theme="dark"] .ref-row-edu { background: #2a2210; }
[data-theme="dark"] .ff-feedback.ff-feedback-warn { background: #2a2210; border-color: #b45309; color: #fde68a; }

/* Уведомления, модальные окна, профиль */
[data-theme="dark"] .toast-msg { background: linear-gradient(135deg, #0f1824, var(--bg-ice-2)); }
[data-theme="dark"] .modal-backdrop { background: rgba(2, 8, 16, 0.7); }
[data-theme="dark"] .modal-card { box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6); }
[data-theme="dark"] .profile-hero-card { background: linear-gradient(135deg, var(--bg-ice), #0f1824); }
[data-theme="dark"] .ach-card.unlocked { background: linear-gradient(135deg, #0f1824, var(--bg-ice-2)); }

/* Поля ввода (на случай стилей браузера) */
[data-theme="dark"] input:not([type="range"]):not([type="radio"]):not([type="checkbox"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  color: var(--blue-deep);
}

/* ---------- Светлые «приборные экраны» внутри тёмной темы ----------
   Внутри этих контейнеров возвращается светлая палитра, т.к. JS-модули
   (infographics.js, games.js, video-player.js) рисуют схемы светлыми цветами. */
[data-theme="dark"] .svg-wrapper,
[data-theme="dark"] .mollier-stage,
[data-theme="dark"] .ff-unit-svg-wrap,
[data-theme="dark"] .vc-vac-svg,
[data-theme="dark"] .video-screen-wrap {
  color-scheme: light;
  --bg-white: #ffffff;
  --bg-ice: #f4fbff;
  --bg-ice-2: #e6f7ff;
  --bg-cyan-soft: #d9f3ff;
  --cyan-neon: #00d4ff;
  --cyan-bright: #00b4ff;
  --sky-vivid: #38bdf8;
  --sky-light: #7dd3fc;
  --sky-border: #bae6fd;
  --blue-action: #0284c7;
  --blue-deep: #0369a1;
  --blue-text: #064e7a;
  --blue-muted: #2874a6;
  color: var(--blue-text);
}
[data-theme="dark"] .svg-wrapper {
  background: #f7fcff;
  border-radius: 14px;
}
[data-theme="dark"] .vc-vac-svg { border-radius: 10px; }

/* ==========================================================================
   HERO FRIDGE 2D → 3D TRANSFORMATION STAGE (LIGHT & DARK TECHNICAL BLUE)
   ========================================================================== */
.hero-fridge-stage {
  position: relative;
  overflow: hidden;
  user-select: none;
  background:
    linear-gradient(rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 50% 42%, #f0f7ff 0%, #dbeafe 62%, #bfdbfe 100%);
  background-size: 28px 28px, 28px 28px, 100% 100%;
  --bp-stroke-main: #2563eb;
  --bp-stroke-accent: #0284c7;
  --bp-stroke-dim: #3b82f6;
  --bp-text-color: #1e40af;
}

[data-theme="dark"] .hero-fridge-stage {
  background:
    linear-gradient(rgba(59, 130, 246, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.11) 1px, transparent 1px),
    radial-gradient(circle at 50% 42%, #102341 0%, #091426 60%, #050b16 100%);
  background-size: 28px 28px, 28px 28px, 100% 100%;
  --bp-stroke-main: #3b82f6;
  --bp-stroke-accent: #38bdf8;
  --bp-stroke-dim: #60a5fa;
  --bp-text-color: #93c5fd;
}

.hero-fridge-webgl-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hero-blueprint-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  color: var(--bp-stroke-dim);
  transition: opacity 0.12s linear;
}

.hero-blueprint-svg .bp-draw {
  fill: none;
  stroke: var(--bp-stroke-main);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero-blueprint-svg .bp-strong {
  stroke-width: 1.55;
  stroke: var(--bp-stroke-main);
}

.hero-blueprint-svg .bp-thin {
  stroke-width: 0.9;
  stroke: var(--bp-stroke-dim);
  opacity: 0.85;
}

.hero-blueprint-svg .bp-accent {
  stroke-width: 1.35;
  stroke: var(--bp-stroke-accent);
}

.hero-blueprint-svg .bp-centerline {
  stroke-width: 0.85;
  stroke: var(--bp-stroke-accent);
  stroke-dasharray: 8 4 2 4;
}

.hero-blueprint-svg .bp-dashed {
  stroke-width: 0.95;
  stroke: var(--bp-stroke-accent);
  opacity: 0.72;
}

.hero-blueprint-svg .bp-dim-ext {
  stroke-width: 0.75;
  stroke: var(--bp-stroke-dim);
  opacity: 0.75;
}

.hero-blueprint-svg .bp-dim-line {
  stroke-width: 1.0;
  stroke: var(--bp-stroke-dim);
}

.hero-blueprint-svg .bp-text {
  fill: var(--bp-text-color);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0;
}

.hero-blueprint-svg .bp-text-sm {
  font-size: 7.5px;
  font-weight: 600;
}

.hero-blueprint-svg .bp-text-stamp {
  font-size: 7px;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

.hero-fridge-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.hero-stage-pill {
  position: absolute;
  top: 10px;
  left: 12px;
  padding: 0.24rem 0.62rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #1d4ed8;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(37, 99, 235, 0.35);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

[data-theme="dark"] .hero-stage-pill {
  color: #93c5fd;
  background: rgba(9, 18, 34, 0.86);
  border-color: rgba(59, 130, 246, 0.42);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.hero-fridge-label {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.22rem 0.52rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.90);
  border: 1px solid rgba(37, 99, 235, 0.35);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  will-change: transform, opacity;
}

[data-theme="dark"] .hero-fridge-label {
  background: rgba(11, 20, 36, 0.88);
  border-color: rgba(56, 189, 248, 0.38);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.hero-fridge-label .hfl-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
  flex-shrink: 0;
}

[data-theme="dark"] .hero-fridge-label .hfl-dot {
  background: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.hero-fridge-label .hfl-body {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.hero-fridge-label .hfl-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: #0f172a;
}

[data-theme="dark"] .hero-fridge-label .hfl-title {
  color: #f1f5f9;
}

.hero-fridge-label .hfl-sub {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: #2563eb;
}

[data-theme="dark"] .hero-fridge-label .hfl-sub {
  color: #7dd3fc;
}

.hud-btn.active {
  background: var(--blue-action);
  color: #ffffff;
  border-color: var(--blue-action);
}

@media (max-width: 760px) {
  .hero-fridge-label .hfl-sub {
    display: none;
  }
  .hero-fridge-label {
    padding: 0.16rem 0.4rem;
  }
}

/* ==========================================================================
   ГОЛОСОВАЯ ОЗВУЧКА ЛЕКЦИЙ И ВИДЕОПЛЕЕРА (Web Speech API)
   ========================================================================== */
.lecture-voice-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
  border-radius: 12px;
  background: var(--bg-ice);
  border: 1.5px solid var(--sky-border);
}

.voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.85rem;
  border-radius: 9px;
  border: 1.5px solid var(--sky-light);
  background: var(--bg-white);
  color: var(--blue-deep);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.voice-btn:hover {
  border-color: var(--cyan-bright);
  background: var(--bg-cyan-soft);
}

.voice-btn-primary,
.voice-btn.active {
  background: linear-gradient(135deg, var(--blue-action), var(--cyan-bright));
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.24);
}

.voice-btn-toggle.active {
  background: var(--bg-ice-2);
  color: var(--blue-action);
  border-color: var(--cyan-bright);
  box-shadow: none;
}

[data-theme="dark"] .voice-btn-toggle.active {
  color: #38bdf8;
}

.voice-status-note {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--blue-muted);
}

.lecture-voice-reading {
  outline: 2px solid var(--cyan-bright);
  outline-offset: 4px;
  border-radius: 8px;
  background: rgba(0, 180, 255, 0.08);
  transition: background 0.2s ease, outline-color 0.2s ease;
}
