/* =====================================================================
   style.css — внешний вид приложения
   ---------------------------------------------------------------------
   Все цвета заданы переменными в начале файла (--bg, --ink и т. д.).
   Чтобы поменять цвет во всём приложении, достаточно поправить его здесь.
   Есть две палитры: светлая (по умолчанию) и тёмная (включается сама,
   если у пользователя тёмная тема в системе).

   ВАЖНО: цвета самой плеяды (шарики, линии) задаются не здесь,
   а в js/state.js, в объекте SETTINGS.
   ===================================================================== */


/* ---------- Светлая палитра ---------- */
:root {
  --bg:        #edf0ec;   /* фон страницы */
  --surface:   #fafbf9;   /* фон панелей */
  --surface-2: #e2e7e2;   /* шапки таблиц */
  --ink:       #1b2320;   /* основной текст */
  --muted:     #57635d;   /* второстепенный текст */
  --line:      #cbd3cc;   /* рамки и разделители */

  --accent:      #23577b; /* фирменный цвет: кнопки, активная вкладка */
  --accent-ink:  #ffffff; /* текст на фирменном цвете */
  --accent-soft: #d9e6ee; /* бледный фирменный: выбранные кнопки */

  --sig:      #a8231b;    /* значимо (p < 0,01) */
  --sig-soft: #f5dcd8;
  --ok:       #2d6a3e;    /* «нормальное распределение» */
  --ok-soft:  #dcebdf;

  /* «Лист бумаги» под плеядой всегда белый — и в тёмной теме тоже,
     чтобы картинка выглядела так же, как в дипломе */
  --paper:     #ffffff;
  --paper-ink: #1a1a1a;

  /* Шрифты: заголовки — Literata, интерфейс — Golos Text.
     Если шрифты не загрузятся, подставятся следующие по списку. */
  --f-display: "Literata", "PT Serif", Georgia, serif;
  --f-ui:      "Golos Text", "Segoe UI", system-ui, -apple-system, sans-serif;

  --radius: 10px;
}

/* ---------- Тёмная палитра (по настройке системы) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #121614;
    --surface:   #1a1f1d;
    --surface-2: #262d2a;
    --ink:       #e1e7e2;
    --muted:     #9aa59f;
    --line:      #333c37;
    --accent:      #8cb7d7;
    --accent-ink:  #0d1820;
    --accent-soft: #1c3140;
    --sig:      #ff8f84;
    --sig-soft: #3b2220;
    --ok:       #8fd09f;
    --ok-soft:  #1d3324;
    color-scheme: dark;
  }
}


/* ---------- Основа ---------- */
* { box-sizing: border-box; }

html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
img { max-width: 100%; }

h1, h2, h3 { font-family: var(--f-display); font-weight: 600; margin: 0; text-wrap: balance; }
h2 { font-size: 1.2rem; line-height: 1.3; }
h3 { font-size: 1rem; }
p  { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.err   { color: var(--sig); font-weight: 500; }

button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Центральная колонка с полями по бокам */
.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}


/* ---------- Шапка ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  padding-block: 22px 14px;
}
.brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px; min-width: 0; }
.brand h1 { font-size: 2rem; line-height: 1; letter-spacing: -.01em; }
.brand p { color: var(--muted); max-width: 44ch; }
.top-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Плашка «48 респондентов · 13 шкал» */
.ds-chip {
  font-size: .86rem;
  color: var(--muted);
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.ds-chip b { color: var(--ink); font-weight: 500; }


/* ---------- Вкладки ---------- */
.tabs {
  position: sticky;           /* вкладки «прилипают» к верху при прокрутке */
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs-in { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs-in::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  border: 0;
  background: none;
  padding: 12px 14px 11px;
  white-space: nowrap;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }


/* ---------- Панели и сетка ---------- */
main { padding-block: 20px 48px; display: flex; flex-direction: column; gap: 18px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }

/* Две колонки на вкладке «Данные»; на узком экране — одна */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 18px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.spread { justify-content: space-between; }

/* Пояснение с полоской слева */
.note { font-size: .86rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; }


/* ---------- Кнопки и поля ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  line-height: 1.2;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: .86rem; }
.btn.bottom { align-self: flex-end; }

select, input[type=text], textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  max-width: 100%;
}
textarea { width: 100%; resize: vertical; font-size: .9rem; }

/* Поле с подписью сверху */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .86rem; color: var(--muted); }
label.field select { color: var(--ink); font-size: .95rem; }

/* Галочка с подписью */
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.check.bottom { align-self: flex-end; padding-bottom: 6px; }

/* Переключатель «Независимые / Зависимые» */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { appearance: none; border: 0; background: none; padding: 7px 12px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); }

/* Область выбора файла */
.drop {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  background: var(--bg);
}
.drop:hover { border-color: var(--accent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop strong { color: var(--accent); }
.drop span { font-size: .86rem; color: var(--muted); }


/* ---------- Таблицы ---------- */
.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; font-weight: 500; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.name { min-width: 9rem; }

/* Подсветка значимости в таблицах результатов */
.res td.sig1 { background: var(--sig-soft); color: var(--sig); font-weight: 600; } /* p < 0,01 */
.res td.sig2 { color: var(--ink); font-weight: 600; }                              /* p < 0,05 */
.res td.ns   { color: var(--muted); }                                              /* не значимо */

/* Корреляционная матрица */
.matrix td, .matrix th { text-align: center; padding: 6px 8px; }
.matrix td.rowname, .matrix th.rowname { text-align: left; white-space: nowrap; }
.matrix td.diag { color: var(--line); }

/* Метки «да / нет», «число», «группы» */
.pill { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; white-space: nowrap; font-weight: 500; }
.pill.ok      { background: var(--ok-soft);   color: var(--ok); }
.pill.no      { background: var(--sig-soft);  color: var(--sig); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

/* Пояснение под названием критерия: «почему выбран» */
.why { font-size: .8rem; color: var(--muted); }

/* Цветной кружок методики */
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .35); vertical-align: -1px; flex: none; }

/* Кнопки-«таблетки» методик */
.methods { display: flex; flex-wrap: wrap; gap: 6px; }
.mchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px 3px 6px;
  font-size: .86rem;
  background: var(--surface);
  cursor: pointer;
}
.mchip[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }


/* ---------- Вкладка «Плеяда» ---------- */
/* Слева рисунок, справа панель настроек; на узком экране — друг под другом */
.plei { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .plei { grid-template-columns: minmax(0, 1fr); } }
.plei-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* Полоса над рисунком: подсказка или выбранный шарик */
.selbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: .9rem;
}
.selbar b { font-weight: 600; }

/* Белый лист с плеядой */
.paper {
  background: var(--paper);
  color: var(--paper-ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 6px 24px rgba(20, 30, 25, .08);
}
.paper svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;          /* чтобы на телефоне перетаскивание не прокручивало страницу */
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--f-ui);
}
.paper svg .node { cursor: grab; }
.paper svg .node:active { cursor: grabbing; }

/* Легенда под рисунком */
.plegend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .86rem; color: var(--muted); padding: 2px 4px; }
.plegend span { display: inline-flex; align-items: center; gap: 6px; }
.plegend svg { flex: none; color: var(--ink); }

/* Группы настроек в правой панели */
.side-group { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.side-group:last-child { border-bottom: 0; padding-bottom: 0; }
.side-group h3 {
  font-family: var(--f-ui);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.hidden-list { display: flex; flex-wrap: wrap; gap: 6px; }


/* ---------- Всплывающие сообщения и окно с картинкой ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .55);
}
.overlay .panel { max-width: min(900px, 100%); max-height: 100%; overflow: auto; }
.overlay img { border: 1px solid var(--line); background: #fff; }


/* ---------- Узкие экраны и доступность ---------- */
@media (max-width: 520px) {
  .brand h1 { font-size: 1.6rem; }
  .panel { padding: 14px; }
  th, td { padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* =====================================================================
   САЙТ: меню, подвал и текстовые страницы
   (В помощь студенту, Литература, О проекте)
   ===================================================================== */

/* Меню разделов сайта — под названием в шапке */
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .92rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding-block: 2px; border-bottom: 1.5px solid transparent; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.brand-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.brand h1 a { color: inherit; text-decoration: none; }

/* Подвал */
.site-footer { border-top: 1px solid var(--line); padding-block: 18px 28px; font-size: .86rem; color: var(--muted); }
.footer-in { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; }
.site-footer a { color: var(--accent); }
.selectable { user-select: all; }

/* Ссылка «скачать пример таблицы» */
.link { color: var(--accent); font-weight: 500; }

/* Текстовая страница: одна колонка удобной ширины */
.doc { max-width: 74ch; display: flex; flex-direction: column; gap: 14px; padding-block: 26px 48px; }
.doc h1 { font-size: 1.9rem; line-height: 1.2; }
.doc h2 { font-size: 1.3rem; margin-top: 18px; }
.doc h3 { font-size: 1.02rem; margin-top: 6px; }
.doc p, .doc li { line-height: 1.62; }
.doc ul, .doc ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.doc a { color: var(--accent); }
.lead { font-size: 1.06rem; color: var(--muted); }

/* Оглавление страницы */
.toc { display: flex; flex-wrap: wrap; gap: 6px; }
.toc a { font-size: .86rem; text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; color: var(--ink); background: var(--surface); }
.toc a:hover { border-color: var(--accent); }

/* Шаблон текста для диплома с кнопкой «Скопировать» */
.template { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.template-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-2); font-size: .84rem; color: var(--muted); font-weight: 500; }
.template-body { padding: 12px 14px; font-family: var(--f-display); font-size: .98rem; line-height: 1.6; }
.template-body mark { background: var(--accent-soft); color: var(--ink); padding: 0 3px; border-radius: 3px; }

/* Таблица «какой критерий выбрать» */
.doc .tablebox table td, .doc .tablebox table th { white-space: normal; }

/* Список литературы */
.biblio { counter-reset: none; }
.biblio li { padding-left: 2px; }
.biblio .why { font-size: .88rem; margin-top: 2px; }

/* Блок «Поддержать проект» */
.support { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
