/* =========================================================
   Компоненты (БЭМ). Используются на всех страницах.
   ========================================================= */

/* ---------- Шапка страницы ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); }
.page-head__text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-head__meta { font-size: var(--fs-small); color: var(--muted); }
.page-head__title { font-size: var(--fs-hero); }
.page-head__lead { font-size: var(--fs-body-lg); line-height: 1.55; color: var(--muted); max-width: 60ch; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.eyebrow {
  font-family: var(--font-display);
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.h2 { font-size: var(--fs-h2); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 10px 24px;
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: var(--fs-body-lg); font-weight: 600; line-height: 1.2; text-align: center;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); color: #fff; }
.btn--secondary {
  min-height: var(--tap);
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--accent);
  font-size: var(--fs-body);
  border-radius: var(--r-sm);
  padding: 8px 20px;
}
.btn--secondary:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn--danger-link {
  min-height: var(--tap);
  padding: 0;
  background: none;
  color: var(--high);
  font-weight: 600;
  justify-content: flex-start;
}
.btn:disabled, .btn[aria-disabled="true"] { background: var(--line); border-color: var(--line); color: var(--muted); }
.btn--block { width: 100%; }
.btn--lg { min-height: 56px; font-size: 1.0625rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink);
}
.icon-btn:hover { border-color: var(--line-strong); }

/* ---------- Карточка ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  min-width: 0;
}
.card--lg { padding: var(--sp-6); }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.card__title { font-family: var(--font-display); font-size: var(--fs-card-title); font-weight: 600; line-height: 1.25; }
.card__sub { font-size: var(--fs-small); color: var(--muted); }
.card__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.card__value { font-size: var(--fs-small); color: var(--muted); }
.card__value strong { color: var(--ink); font-weight: 700; }

/* ---------- Плашки (риск, статусы) ---------- */
.pill {
  display: inline-flex; align-items: center; flex-shrink: 0;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-label); font-weight: 700; line-height: 1.3; white-space: nowrap;
}
.pill--high { background: var(--high-bg); color: var(--high); }
.pill--medium { background: var(--mid-bg); color: var(--mid); }
.pill--low { background: var(--low-bg); color: var(--low); }
.pill--accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: var(--fs-caption);
  padding: 5px 12px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-high {
  font-size: var(--fs-caption);
  font-weight: 600;
  background: var(--high-bg);
  color: var(--high);
  border-radius: var(--r-pill);
  padding: 5px 10px;
}

/* ---------- Метка секции ---------- */
.section-label { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.section-label--low { color: var(--low); }
.section-label--info { color: var(--info); }
.section-label--high { color: var(--high); }
.section { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Списки ---------- */
.dot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dot-list li { position: relative; padding-left: 16px; line-height: 1.45; }
.dot-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.rows { list-style: none; margin: 0; padding: 0; }
.rows__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.rows__item:last-child { border-bottom: 0; }
.rows__label { color: var(--muted); }
.rows__value { font-weight: 600; text-align: right; }

/* ---------- Инфо-блоки в карточке нутриента ---------- */
.note { border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.note__title { font-size: var(--fs-body); font-weight: 700; }
.note__text { font-size: var(--fs-small); line-height: 1.45; }
.note--together { background: var(--low-bg); }
.note--together .note__title { color: var(--low-ink); }
.note--avoid { background: var(--high-bg); }
.note--avoid .note__title { color: var(--high-ink); }
.note--care { background: var(--mid-bg); }
.note--care .note__title { color: var(--mid); font-size: var(--fs-caption); }
.note--care .note__text { color: var(--mid-ink); }
.note--care .note__text + .note__text { margin-top: 6px; }

.pause { background: var(--info-bg); border-radius: var(--r-sm); padding: 2px 12px; list-style: none; margin: 0; }
.pause__item {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 9px 0;
  border-bottom: 1px solid var(--info-line);
  font-size: var(--fs-small);
  color: #1B2B45;
}
.pause__item:last-child { border-bottom: 0; }
.pause__hours { flex-shrink: 0; font-size: var(--fs-caption); font-weight: 700; color: var(--info); white-space: nowrap; }

/* ---------- Прогресс ---------- */
.progress { height: 8px; background: var(--line-soft); border-radius: var(--r-pill); overflow: hidden; }
.progress--thin { height: 6px; background: var(--line); }
.progress--water { height: 10px; background: var(--water-track); }
.progress__bar { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .25s ease; }
.progress--water .progress__bar { background: var(--info); }

/* ---------- Плитки с цифрами ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat__value { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; line-height: 1.2; }
.stat__label { font-size: var(--fs-caption); color: var(--muted); }

/* ---------- Сетки ---------- */
.grid { display: grid; gap: var(--sp-3); grid-template-columns: minmax(0, 1fr); align-items: start; }

/* ---------- Аккордеон-кнопка ---------- */
.disclosure {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  width: 100%; min-height: var(--tap); padding: 10px 0 0;
  border: 0; border-top: 1px solid var(--line-soft); background: none;
  color: var(--accent); font-size: var(--fs-body); font-weight: 600; text-align: left;
}
.disclosure .icon { transition: transform .2s; }
.disclosure[aria-expanded="true"] .icon { transform: rotate(180deg); }
.disclosure-panel { font-size: var(--fs-small); line-height: 1.6; color: var(--ink-2); }

/* ---------- Кнопка «принято» ---------- */
.check {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: var(--tap); height: var(--tap); flex-shrink: 0;
  border: 2px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--surface); color: #C9C4B8;
}
.check[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }
.check__text { display: none; font-size: var(--fs-small); font-weight: 600; }

/* ---------- Вариант ответа ---------- */
.answers { display: flex; flex-direction: column; gap: 10px; border: 0; margin: 0; padding: 0; min-width: 0; }
.answer { position: relative; display: block; }
.answer input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.answer__box {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: 58px; padding: 12px 18px 12px 20px;
  border: 2px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  font-size: 1.0625rem; font-weight: 600;
  transition: border-color .15s, background-color .15s;
}
.answer__radio { width: 20px; height: 20px; flex-shrink: 0; border: 2px solid #C9C4B8; border-radius: 50%; background: var(--surface); }
.answer:hover .answer__box { border-color: var(--line-strong); }
.answer input:checked + .answer__box { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.answer input:checked + .answer__box .answer__radio { border: 6px solid var(--accent); }
.answer input:focus-visible + .answer__box { box-shadow: var(--focus-ring); }

/* ---------- Чипы-переключатели (напитки) ---------- */
.toggle-group { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.toggle {
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink); font-size: var(--fs-small); font-weight: 600;
}
.toggle[aria-pressed="true"] { border-color: var(--info); background: var(--info); color: #fff; }

/* ---------- Совет ---------- */
.tip { background: var(--accent-soft); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.tip__title { font-size: var(--fs-small); font-weight: 700; color: var(--accent-ink); }
.tip__text { font-size: var(--fs-small); line-height: 1.45; color: #2B2F45; }

/* ---------- Подсказка, дисклеймер ---------- */
.hint {
  font-size: var(--fs-small);
  line-height: 1.5;
  color: #2B2F45;
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.disclaimer { font-size: var(--fs-label); line-height: 1.5; color: var(--muted); max-width: 760px; }

/* ---------- Аватар ---------- */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
}

/* ---------- Поля формы ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-caption); font-weight: 600; color: var(--muted); }
.field__input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
  font-size: var(--fs-body-lg);
}
.field__input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: var(--r-sm); }
.field__input[aria-invalid="true"] { border-color: var(--high); }
.field__error { font-size: var(--fs-caption); color: var(--high); }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Пустое состояние ---------- */
.empty { text-align: left; align-items: flex-start; }
.empty__title { font-family: var(--font-display); font-size: var(--fs-card-title); font-weight: 600; }
.empty__text { color: var(--muted); }

/* ---------- Скелетон ---------- */
.skeleton { background: var(--line-soft); border-radius: var(--r-lg); min-height: 120px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
  transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: var(--r-sm);
  background: var(--ink); color: #fff; font-size: var(--fs-small);
}

/* =========================================================
   Адаптив компонентов
   ========================================================= */
@media (max-width: 359px) {
  .stats { gap: 6px; }
  .stat { padding: 10px; }
  .stat__value { font-size: 1.0625rem; }
  .card { padding: 16px; }
}

@media (min-width: 768px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .field--wide { grid-column: 1 / -1; }
}

@media (min-width: 1024px) {
  .card { border-radius: 22px; padding: 22px; }
  .card--lg { padding: var(--sp-7); border-radius: 24px; }
  .grid--cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
  .grid--tiles { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
  .avatar { width: 72px; height: 72px; font-size: 1.375rem; }
  .check { width: auto; height: 40px; padding: 0 14px; border-width: 1px; color: var(--ink-2); }
  .check[aria-pressed="true"] { color: #fff; }
  .check__text { display: inline; }
  .toast { bottom: 24px; }
}
