/* -------- Рецепт по шагам (food_steps.html, webapp/food_cooking.py) --------
   Обычный вид: шапка, список продуктов с галочками и лента шагов, у каждого
   снимок, продукты шага, текст и таймер. Режим «Готовлю» (html.is-cooking) —
   та же лента на весь экран, шаг на экран, листается пальцем
   (static/js/food_steps.js). */
.fs { display: grid; gap: 16px; }
.fs-head h1 { font-size: clamp(28px, 6vw, 40px); line-height: 1.1; }
/* Факты плашками: при переносе строка не начинается с висящей точки. */
.fs-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.fs-facts span, .fs-facts a {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: var(--r-pill);
  border: 1.5px solid var(--line); background: var(--card); font-size: 14px; font-weight: 700; color: var(--text-2);
}
/* Калории порции ведут на страницу блюда: там состав и откуда цифры. */
.fs-facts a { color: var(--text); }
.fs-facts a:hover { box-shadow: 3px 3px 0 var(--stamp); transform: translate(-1px, -1px); }
.fs-facts svg { width: 15px; height: 15px; color: var(--primary-600); }
.fs-head-row { margin-top: 16px; }
.fs-head-row .btn i, .fs-head-row .btn svg { width: 20px; height: 20px; }
@media (max-width: 599px) { .fs-head-row .btn { width: 100%; } }
.fs-hint { margin-top: 10px; max-width: 60ch; font-size: 13.5px; line-height: 1.5; color: var(--text-3); }

/* Что понадобится: строка — галочка, название с количеством, граммы. */
.fs-need { padding: 16px 18px; }
.fs-need h2 { font-size: 20px; }
.fs-need-sub { margin: 4px 0 6px; font-size: 13.5px; color: var(--text-3); }
.fs-list { list-style: none; display: grid; }
@media (min-width: 860px) { .fs-list { grid-template-columns: 1fr 1fr; column-gap: 28px; } }
.fs-list label {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-height: 48px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.fs-list input { position: absolute; opacity: 0; pointer-events: none; }
.fs-box {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--card); transition: background 0.15s var(--ease);
}
.fs-box svg { width: 16px; height: 16px; color: var(--btn-fg); opacity: 0; }
.fs-list input:checked + .fs-box { background: var(--btn-bg); border-color: var(--btn-bg); }
.fs-list input:checked + .fs-box svg { opacity: 1; }
.fs-list input:focus-visible + .fs-box { outline: 2px solid var(--primary); outline-offset: 2px; }
.fs-list input:checked ~ .fs-name, .fs-list input:checked ~ b { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.fs-name { font-size: 15px; font-weight: 650; color: var(--text); }
.fs-name small { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-3); }
.fs-list b { font-size: 14.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fs-gear { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; margin-top: 14px; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.fs-gear svg { width: 20px; height: 20px; color: var(--primary-600); }
.fs-gear b { color: var(--text); }

/* Лента шагов. */
.fs-steps { list-style: none; display: grid; gap: 16px; }
.fs-step {
  display: grid; overflow: hidden; scroll-margin-top: calc(var(--bar-h) + 12px);
  border-radius: var(--r-lg); border: 1.5px solid var(--line); background: var(--card);
}
@media (min-width: 860px) {
  .fs-step { grid-template-columns: minmax(0, 360px) minmax(0, 1fr); }
  .fs-step:not(:has(.fs-pic)) { grid-template-columns: minmax(0, 1fr); }
}
.fs-pic { margin: 0; aspect-ratio: 3 / 2; background: var(--bg-2); }
.fs-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.fs-body { display: grid; align-content: start; gap: 8px; padding: 16px 18px 18px; }
@media (min-width: 860px) { .fs-body { align-content: center; padding: 20px 24px; } }
/* Номер кружком, заголовок и таймер в одной строке. */
.fs-top { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.fs-num {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--btn-bg); color: var(--btn-fg); font-size: 14px; font-weight: 800;
}
.fs-body h2 { font-size: 20px; line-height: 1.2; }
.fs-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Продукты шага — строка текста, а не плашки: граммы жирным и есть разделитель. */
.fs-uses { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 14px; line-height: 1.4; color: var(--text-2); }
.fs-uses b { color: var(--text); font-variant-numeric: tabular-nums; }
.fs-uses small { font-size: 13px; color: var(--text-3); }
.fs-text { font-size: 16px; line-height: 1.5; color: var(--text); }
.fs-check { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; font-size: 14px; line-height: 1.45; color: var(--text-3); }
.fs-check svg { width: 16px; height: 16px; margin-top: 2px; color: var(--primary-600); }
.fs-timer {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px;
  border-radius: var(--r-pill); border: 1.5px solid var(--line); background: var(--card); cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 750; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.fs-timer svg { width: 18px; height: 18px; color: var(--primary-600); }
.fs-timer.is-on { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-fg); }
.fs-timer.is-on svg { color: currentColor; }
.fs-timer.is-done { background: var(--primary); border-color: var(--primary); color: #fff; animation: fs-ring 1s var(--ease) infinite; }
.fs-timer.is-done svg { color: currentColor; }
@keyframes fs-ring { 50% { transform: scale(1.04); } }
.fs-tip { margin-top: 0; }
.fs-foot a { text-decoration: underline; text-underline-offset: 3px; }

/* «Дальше» и итог блюда — только в режиме «Готовлю». */
.fs-upnext { display: none; }
html.is-cooking .fs-upnext {
  display: grid; grid-template-columns: 72px minmax(0, 1fr) 18px; align-items: center; gap: 12px;
  width: 100%; padding: 8px 12px 8px 8px; border-radius: var(--r-md); border: 1.5px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
html.is-cooking .fs-step.is-tight .fs-upnext { display: none; }
.fs-upnext img { display: block; width: 72px; height: 48px; object-fit: cover; border-radius: 8px; }
.fs-upnext > span:not(.fs-finale-ico) { display: grid; gap: 1px; min-width: 0; }
.fs-upnext small { font-size: 12px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--primary-600); }
.fs-upnext b { font-size: 15px; line-height: 1.25; }
.fs-upnext em { font-style: normal; font-size: 13px; color: var(--text-3); }
.fs-upnext > svg { width: 18px; height: 18px; color: var(--text-3); }
.fs-finale-ico { display: grid; place-items: center; width: 72px; height: 48px; border-radius: 8px; background: var(--bg-2); }
.fs-finale-ico svg { width: 22px; height: 22px; color: var(--primary-600); }

/* Идущие таймеры: плашки внизу экрана. */
.fs-dock {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60;
  display: grid; justify-items: end; gap: 8px; pointer-events: none;
}
.fs-dock button {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 0; border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg); box-shadow: 0 3px 0 var(--btn-base);
  font: inherit; font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums; cursor: pointer; pointer-events: auto;
}
.fs-dock button.is-done { background: var(--primary); color: #fff; animation: fs-ring 1s var(--ease) infinite; }
.fs-dock svg { width: 16px; height: 16px; }

/* Липкая «Начать готовить» — только на телефоне и не в режиме «Готовлю». */
.fs-sticky {
  position: fixed; left: 16px; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40; min-height: 52px; font-size: 16.5px;
}
.fs-sticky svg { width: 20px; height: 20px; }
.fs-sticky[hidden] { display: none; }
@media (min-width: 860px) { .fs-sticky { display: none; } }
html.is-cooking .fs-sticky { display: none; }
/* Таймеры над липкой кнопкой, а не под ней. */
@media (max-width: 859px) { html:not(.is-cooking) .fs-dock { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* -------- Режим «Готовлю» --------
   Телефон (владелец 02.11.2026: «на одном экране всё необходимое»): шаг
   целиком на экране без прокрутки — снимок ниже, текст плотнее, номер шага
   только в верхней полосе, таймер шага в нижней панели рядом с «Дальше».
   Длинный шаг на маленьком экране всё же прокручивается внутри себя. */
.fs-cook-top, .fs-cook-nav { display: none; }
html.is-cooking, html.is-cooking body { overflow: hidden; }
html.is-cooking .fs-steps {
  position: fixed; inset: 0; z-index: 50; display: flex; gap: 0;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none; background: var(--bg);
}
html.is-cooking .fs-steps::-webkit-scrollbar { display: none; }
html.is-cooking .fs-step {
  flex: 0 0 100%; align-content: start; overflow-y: auto; scroll-snap-align: start; scroll-snap-stop: always;
  border: 0; border-radius: 0; background: none;
  padding: calc(48px + env(safe-area-inset-top)) 0 calc(72px + env(safe-area-inset-bottom));
}
html.is-cooking .fs-pic { aspect-ratio: auto; height: clamp(130px, 34vh, 66vw); height: clamp(130px, 34svh, 66vw); }
/* Низкий экран (iPhone SE, 667 px): снимок ещё ниже, иначе длинный первый шаг
   уходит под панель. */
@media (max-height: 700px) and (max-width: 859px) {
  html.is-cooking .fs-pic { height: clamp(120px, 30vh, 66vw); height: clamp(120px, 30svh, 66vw); }
}
html.is-cooking .fs-body .fs-timer { display: none; }
html.is-cooking .fs-body { padding: 12px 16px 8px; gap: 8px; }
/* Карточка «Дальше» прижата к низу шага: занимает пустое место над панелью. */
@media (max-width: 859px) {
  html.is-cooking .fs-step { grid-template-rows: auto minmax(0, 1fr); align-content: stretch; }
  html.is-cooking .fs-body { display: flex; flex-direction: column; }
  html.is-cooking .fs-upnext { margin-top: auto; }
}
html.is-cooking .fs-body h2 { font-size: 22px; line-height: 1.15; }
html.is-cooking .fs-text { font-size: 18px; line-height: 1.45; }
@media (min-width: 860px) {
  html.is-cooking .fs-step {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; gap: 32px;
    padding: calc(64px + env(safe-area-inset-top)) max(32px, calc((100vw - 1180px) / 2)) 96px;
  }
  html.is-cooking .fs-pic { height: auto; aspect-ratio: 3 / 2; border-radius: var(--r-lg); overflow: hidden; }
  html.is-cooking .fs-body { padding: 0; gap: 12px; }
  html.is-cooking .fs-body h2 { font-size: 25px; }
  html.is-cooking .fs-uses { font-size: 15.5px; }
  html.is-cooking .fs-text { font-size: 19px; line-height: 1.55; }
  html.is-cooking .fs-check { font-size: 15.5px; }
}
html.is-cooking .fs-cook-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 55; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center; gap: 10px; padding: calc(2px + env(safe-area-inset-top)) 16px 2px 4px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
}
.fs-x {
  display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: none; color: var(--text); cursor: pointer;
}
.fs-x svg { width: 24px; height: 24px; }
.fs-progress { height: 6px; border-radius: var(--r-pill); overflow: hidden; background: color-mix(in srgb, var(--primary) 15%, transparent); }
.fs-progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--primary); transition: width 0.3s var(--ease); }
.fs-count { font-size: 14px; font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }
html.is-cooking .fs-cook-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; display: flex; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
@media (min-width: 860px) { html.is-cooking .fs-cook-nav { justify-content: center; } html.is-cooking .fs-next { flex: 0 0 300px; } }
.fs-prev {
  flex: 0 0 48px; display: grid; place-items: center; height: 48px; border-radius: var(--r-pill); border: 1.5px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer;
}
.fs-prev:disabled { opacity: 0.4; cursor: default; }
.fs-prev svg, .fs-next svg { width: 20px; height: 20px; }
.fs-nav-timer { flex: 0 0 auto; min-height: 48px; padding: 8px 14px; }
.fs-nav-timer[hidden] { display: none; }
.fs-next { flex: 1 1 auto; min-height: 48px; padding: 10px 16px; font-size: 16.5px; }
/* В режиме «Готовлю» таймеры других шагов под верхней полосой, поверх
   снимка: внизу они закрывали бы текст шага. */
html.is-cooking .fs-dock { top: calc(56px + env(safe-area-inset-top)); bottom: auto; }
@media (prefers-reduced-motion: reduce) {
  .fs-timer.is-done, .fs-dock button.is-done { animation: none; }
}
