/* Уроборос — читалка питания.
   Токены, шрифт и общие кирпичики — в nautiloid.css (подключён раньше этого файла,
   там же Inter и обе темы). Здесь только своё: блистер недели, дни, приёмы,
   таблицы чисел и нижняя панель на телефоне.
   Цвет — только для двух состояний: --ok (в порядке) и --act (внимание). */

:root {
  /* старые имена страницы держим как псевдонимы общего слоя: правила ниже
     читаются по-прежнему, а палитра одна на все страницы nautiloid */
  --paper: var(--ground);
  --surface: var(--plate);
  --ink: var(--text);
  --muted: var(--quiet);
  --line: var(--rule);
  --accent: var(--ok);
  --accent-ink: var(--ok);
  --bad: var(--act);
  --font-text: var(--sans);
  --font-display: var(--sans);
  --r: var(--r, 3px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-text);
  padding-bottom: 4.5rem;
}

/* ссылка — это текст с подчёркиванием, а не второй цвет: цвет в палитре
   зарезервирован за состояниями */
a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  z-index: 10;
}

/* --- каркас --- */

.top {
  display: flex;
  align-items: baseline;
  gap: 2rem;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
}

.brand {
  font: 600 1.05rem/1 var(--font-display);
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}
/* техническое имя сервиса — мелким моноширинным рядом с русским названием */
.brand .mono { font-weight: 400; font-size: 0.78rem; color: var(--muted); margin-left: 0.45rem; }

.menu { display: flex; gap: 1.25rem; margin-left: auto; flex-wrap: wrap; }
.menu a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.menu a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) 3rem;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; }
h1 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin: 0.15rem 0 0.4rem; }
h2 {
  font-size: 1.05rem;
  margin: 2.2rem 0 0.7rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
h3 { font-size: 0.95rem; margin: 1.2rem 0 0.4rem; }

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.lede { color: var(--muted); margin-top: 0; }

.week-head { margin-bottom: 1.5rem; }

/* --- блистер недели --- */

.blister {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}
.blister li {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  padding: 0.45rem 0.3rem;
  text-align: center;
  display: grid;
  gap: 0.05rem;
}
.blister .bd { font-size: 0.7rem; color: var(--muted); }
.blister .bn { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.blister li.filled { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border-color: var(--accent); }
.blister li.filled .bn { font-weight: 600; }
.blister .bl { position: absolute; inset: 0; border-radius: var(--r); }
.blister li.is-today { box-shadow: 0 0 0 2px var(--ink); }
.blister li.is-today::after {
  content: "";
  position: absolute;
  bottom: -0.35rem;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--ink);
}

/* --- дни недели --- */

.weekdays { list-style: none; margin: 0; padding: 0; }
.weekday {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  gap: 0.5rem 1rem;
  align-items: start;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.weekday .wd { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; padding-top: 0.1rem; }
.weekday .wm { display: grid; gap: 0.15rem; }
.weekday .wm b { font-variant-numeric: tabular-nums; }
.weekday .wm span { font-size: 0.95rem; }
.weekday .wm-i { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.weekday .wm-i b { flex: none; color: var(--muted); font-weight: 600; }
.cycle td:nth-child(2) { white-space: nowrap; }
.weekday .wdl { font-size: 0.8rem; align-self: center; }
.weekday.is-today { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.weekday.is-today .wd { color: var(--ink); font-weight: 600; }

/* --- «сегодня» --- */

.week { display: none; }
.week.is-current { display: block; }

.meals { display: grid; gap: 0.5rem; margin: 1rem 0 1.2rem; }
.dish {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--rule-strong);
  border-radius: var(--r);
  color: var(--ink);
  text-decoration: none;
}
.dish-lunch { border-left-color: var(--rule); color: var(--muted); }
.dish-name { font-size: 1rem; }
.dish-num { font-size: 0.85rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* замечание к цифрам: не украшение, а предупреждение — цвет берём из --act */
.note {
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  font-size: 0.92rem;
}

/* --- таблицы --- */

.tw { overflow-x: auto; margin: 0.5rem 0 1rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-weight: 600; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
tbody th { font-weight: 400; }
td { font-variant-numeric: tabular-nums; }

.totals td, .totals th { text-align: right; }
.totals tbody th { text-align: left; }
.totals tbody tr:last-child { font-weight: 600; }

.foods th, .foods td { white-space: nowrap; }
.foods td { text-align: right; color: var(--muted); }
.foods tbody th { color: var(--ink); white-space: normal; }

.comp td:not(:first-child) { text-align: right; }
.variants td:first-child { width: 40%; }

/* --- цифры приёма --- */

.nums {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.5rem 1.5rem;
  margin: 0.5rem 0 1rem;
  padding: 0;
}
.nums div { border-left: 2px solid var(--line); padding-left: 0.6rem; }
.nums dt { font-size: 0.78rem; color: var(--muted); }
.nums dd { margin: 0; font-variant-numeric: tabular-nums; }
.nums small { display: block; font-size: 0.75rem; color: var(--muted); }

/* --- закупка --- */

.shop-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 2rem; }
.shop { list-style: none; margin: 0; padding: 0; }
.shop li { padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.shop label { display: flex; gap: 0.55rem; align-items: start; cursor: pointer; }
.shop input { width: 1.15rem; height: 1.15rem; margin: 0.15rem 0 0; accent-color: var(--accent); flex: none; }
.shop input:checked + span { text-decoration: line-through; color: var(--muted); }

/* --- рецепты --- */

.rcards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.6rem;
}
.rcard {
  display: grid;
  gap: 0.2rem;
  height: 100%;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  text-decoration: none;
}
.rcard:hover { border-color: var(--accent); }
.rcard-kind { font-size: 0.75rem; color: var(--muted); }
.rcard-name { font-family: var(--font-display); font-size: 1.02rem; line-height: 1.25; }
.rcard-num { font-size: 0.85rem; color: var(--accent-ink); font-variant-numeric: tabular-nums; }

.portion { margin: 0.2rem 0; }
.steps li { margin-bottom: 0.5rem; }

/* --- день --- */

.meal .time { font-variant-numeric: tabular-nums; color: var(--accent-ink); }
.totals-list { padding-left: 1.1rem; }
.warn {
  border-left: 3px solid var(--bad);
  padding: 0.6rem 0.9rem;
  background: color-mix(in srgb, var(--bad) 10%, var(--surface));
  border-radius: var(--r);
}

.filter { display: inline-flex; gap: 0.5rem; align-items: center; margin: 0.5rem 0 1.5rem; color: var(--muted); }
.filter input {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  min-width: 12rem;
}

.foodgroup[hidden] { display: none; }
tr[hidden] { display: none; }

.pager { display: flex; justify-content: space-between; margin-top: 2rem; font-size: 0.9rem; }

.missing {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--bad);
}

/* --- нижняя панель --- */

.tabbar { display: none; }

@media (max-width: 44rem) {
  .menu { display: none; }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    padding: 0.65rem 0.2rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--muted);
    text-decoration: none;
  }
  .tabbar a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 2px 0 var(--accent); }
  .dish { flex-direction: column; gap: 0.15rem; }
  .dish-num { white-space: normal; }
  .weekday { grid-template-columns: 4rem 1fr; }
  .weekday .wdl { grid-column: 2; justify-self: start; }
  main { padding-bottom: 4rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
