/* mm-theme.css — переключатель темы и плавная смена (облик D: плоско, без теней, рамки 1 px).
   Контрол из mm-theme.js: <span data-mm-theme="seg|cmp|auto">.
   seg — три пункта сегментом (Светлая / Тёмная / Как в системе), cmp — одна иконка с меню,
   auto — сегмент на широком экране, иконка с меню на телефоне (оболочка приложения). */

:root {
  --mtt-line: #c9bca7;
  --mtt-bg: #fffcf6;
  --mtt-fg: #665c50;
  --mtt-on-bg: #ffe3d8;
  --mtt-on-fg: #b7300f;
  --mtt-focus: #b7300f;
  --mtt-icon: #c93a14;            /* значок текущей темы — акцент облика D */
}
html.theme-light,
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] {
  --mtt-line: #3d362d;
  --mtt-bg: #1d1a16;
  --mtt-fg: #b5ab9c;
  --mtt-on-bg: #3a221a;
  --mtt-on-fg: #ff8a66;
  --mtt-focus: #ff8a66;
  --mtt-icon: #ff7a52;            /* акцент тёмной темы облика D */
  color-scheme: dark;
}
/* Echoteka: свой зелёный акцент и в переключателе */
[data-brand="echoteka"] { --mtt-on-fg: #0a7a45; --mtt-focus: #0a7a45; --mtt-on-bg: #dcf3e6; --mtt-icon: #0a7a45; }
html[data-theme="dark"][data-brand="echoteka"] { --mtt-on-fg: #7cffb2; --mtt-focus: #7cffb2; --mtt-on-bg: #16302a; --mtt-icon: #7cffb2; }

.mm-theme { display: inline-flex; align-items: center; position: relative; flex: none; }
.mm-theme svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* Сегмент: три пункта в одной пилюле */
.mm-theme__seg {
  display: inline-flex; align-items: center; gap: 0; height: 28px; padding: 1px;
  border: 1px solid var(--mtt-line); border-radius: 99px; background: var(--mtt-bg);
}
.mm-theme__opt {
  width: 30px; height: 24px; display: grid; place-items: center; padding: 0; margin: 0;
  border: 0; border-radius: 99px; background: transparent; color: var(--mtt-fg); cursor: pointer;
}
.mm-theme__opt[aria-pressed="true"] { background: var(--mtt-on-bg); color: var(--mtt-on-fg); }
.mm-theme__opt:hover { color: var(--mtt-on-fg); }

/* Компакт: одна иконка и меню из трёх пунктов */
.mm-theme__cmp { display: none; position: relative; }
.mm-theme__btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0; margin: 0; box-sizing: border-box;
  border: 1px solid var(--mtt-line); border-radius: 50%; background: var(--mtt-bg); color: var(--mtt-icon); cursor: pointer;
}
.mm-theme__btn:hover { border-color: var(--mtt-icon); }
.mm-theme__cur { display: inline-grid; place-items: center; }
.mm-theme__menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 176px; padding: 4px;
  display: grid; gap: 2px; border: 1px solid var(--mtt-line); border-radius: 12px; background: var(--mtt-bg);
}
.mm-theme__menu[hidden] { display: none; }
.mm-theme__menu button {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; margin: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--mtt-fg);
  font: 400 13px/1 var(--font-text, 'IBM Plex Sans', system-ui, sans-serif); text-align: left; cursor: pointer; white-space: nowrap;
}
.mm-theme__menu button[aria-pressed="true"] { background: var(--mtt-on-bg); color: var(--mtt-on-fg); }
.mm-theme__menu button:hover { color: var(--mtt-on-fg); }

.mm-theme :focus-visible { outline: 2px solid var(--mtt-focus); outline-offset: 2px; }

/* Режимы вывода */
.mm-theme--seg .mm-theme__cmp { display: none; }
.mm-theme--seg .mm-theme__seg { display: inline-flex; }
.mm-theme--cmp .mm-theme__seg { display: none; }
.mm-theme--cmp .mm-theme__cmp { display: block; }
@media (max-width: 599px) {
  .mm-theme--auto .mm-theme__seg { display: none; }
  .mm-theme--auto .mm-theme__cmp { display: block; }
}
@media (min-width: 600px) {
  .mm-theme--auto .mm-theme__seg { display: inline-flex; }
  .mm-theme--auto .mm-theme__cmp { display: none; }
}

/* Единый вид кнопки темы (22.10): круг 32 px, рамка 1 px, значок текущей темы — акцентом.
   В шапке сайта и в шапке беты класс theme-toggle (старые правила шапки) не даёт ей другой размер или тень. */
html body .theme-toggle.mm-theme,
html body nav.ds-header .nav-links > .theme-toggle.mm-theme {
  width: 32px; height: 32px; padding: 0; margin: 0; border: 0; border-radius: 50%;
  background: transparent; box-shadow: none; display: inline-flex; align-items: center; justify-content: center;
}
html body .theme-toggle.mm-theme .mm-theme__seg { display: none; }
html body .theme-toggle.mm-theme .mm-theme__cmp { display: block; width: 32px; height: 32px; }
html body .theme-toggle.mm-theme .mm-theme__btn { width: 32px; height: 32px; border: 1px solid var(--mtt-line); background: var(--mtt-bg); border-radius: 50%; }

/* Плавная смена: 200 мс на фон, текст и рамки; класс снимается через 260 мс после выбора */
html.mm-theme-anim,
html.mm-theme-anim body,
html.mm-theme-anim body * {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, fill 0.2s ease, stroke 0.2s ease !important;
}
@media (prefers-reduced-motion: reduce) {
  html.mm-theme-anim, html.mm-theme-anim body, html.mm-theme-anim body * { transition: none !important; }
}
