/* =====================================================
   L1 «Тарелка на рентгене».

   Поверх темы дома (landing_perek.css): токены, кнопки,
   шапка и подвал общие, здесь — только механика.

   Мобильный порядок первый и не по вкусу: 98,7 % рекламных
   кликов приходят со смартфонов, поэтому одна колонка —
   основной макет, а две — исключение для широкого экрана.

   Главный герой — еда. Интерфейс поверх снимка графитовый
   и полупрозрачный, чтобы читался на любой тарелке, а не
   только на светлой.
   ===================================================== */

/* --------------------------------------------------- */
/*  Экран 1: заголовок и тарелка.                       */
/* --------------------------------------------------- */
/* Поля страницы намеренно узкие. На 375 px (а это почти весь рекламный
   трафик) три вложенные рамки съедали 104 px из 375 — 28 % экрана уходило на
   воздух вместо еды и чисел. Широкие поля возвращаются только там, где экран
   это позволяет, см. медиазапрос в конце файла. */
.l1-hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 12px 8px;
  display: grid;
  gap: 18px;
}

.l1-copy { display: grid; gap: 12px; justify-items: start; }

.l1-title {
  margin: 0;
  font-size: clamp(28px, 7.4vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.l1-sub {
  margin: 0;
  max-width: 34ch;
  font-size: clamp(15.5px, 4vw, 18px);
  line-height: 1.5;
  color: var(--text-2);
}

.l1-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 0;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--text-2);
}
.l1-badge i { font-size: 15px; color: var(--primary-600); }

/* Тарелка: снимок, сканирующая линия и подписи поверх еды. */
.l1-plate { display: grid; gap: 16px; }

.l1-photo {
  position: relative;
  margin: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 8px 0 var(--stamp);
  background: var(--bg-2);
}

.l1-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.l1-cap {
  position: absolute;
  inset: auto 0 0 0;
  padding: 26px 14px 12px;
  font-size: 13px;
  color: #fdf6e7;
  background: linear-gradient(transparent, rgba(24, 14, 6, 0.82));
}

/* Сканирующая линия. Не украшение: она объясняет, откуда взялся разбор, и
   даёт разбору появиться после объяснения, а не до него. */
.l1-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  box-shadow: 0 0 18px 4px rgba(198, 124, 46, 0.55);
}
.is-scanning .l1-scan { animation: l1-sweep 0.9s var(--ease) 1; }

/* Гоняем линию по top в процентах: процент разрешается от самой фигуры.
   Контейнерные запросы тут не подходят — container-type: size включает
   contain: size, и фигура начинает считать свою высоту без снимка, то есть
   схлопывается в ноль вместе с ним. */
@keyframes l1-sweep {
  0% { opacity: 0; top: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0; top: 100%; }
}

.l1-tags { position: absolute; inset: 0; pointer-events: none; }

.l1-tag {
  position: absolute;
  display: grid;
  gap: 1px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(24, 14, 6, 0.78);
  backdrop-filter: blur(6px);
  color: #fdf6e7;
  font-size: 11.5px;
  line-height: 1.25;
  max-width: 42%;
  opacity: 0;
  transform: translateY(6px) scale(0.94);
  animation: l1-pop 0.4s var(--ease) forwards;
  animation-delay: var(--delay, 0ms);
}
.l1-tag b { font-weight: 650; }
.l1-tag i { font-style: normal; color: var(--amber); font-weight: 700; }
/* То, что обычно не считают, подсвечено — это и есть ответ страницы. */
.l1-tag.is-hidden-tag { box-shadow: inset 0 0 0 1.5px var(--amber); }

@keyframes l1-pop {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Угадайка. */
.l1-game[hidden] { display: none; }
.l1-game {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 0 var(--stamp);
}

.l1-ask { margin: 0; font-size: 17px; font-weight: 700; }

.l1-answers { display: grid; gap: 8px; }

.l1-answer {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s var(--ease), border-color 0.16s var(--ease);
}
.l1-answer:hover { border-color: var(--primary); transform: translateY(-1px); }
.l1-answer.is-picked { border-color: var(--primary); background: var(--bg-2); }

.l1-skip {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--primary-600);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.l1-skip i { font-size: 16px; }

/* Разбор. */
.l1-reveal[hidden] { display: none; }
.l1-reveal {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 0 var(--stamp);
}

/* Подпись отдельной строкой над числом: в одну строку «Здесь примерно
   550–670 ккал» на 375 px не влезает, и «ккал» отрывалось от числа, к которому
   относится. Число и единица держатся вместе всегда. */
.l1-total { display: grid; gap: 2px; }
.l1-total-cap { font-size: 13.5px; color: var(--text-2); }
.l1-total-num { font-size: clamp(30px, 9vw, 40px); font-weight: 800; letter-spacing: -0.02em; }
.l1-total-unit { font-size: 15px; color: var(--text-2); }
.l1-total-num + .l1-total-unit { margin-left: 6px; }

.l1-parts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.l1-part {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name kcal" "amount kcal";
  gap: 0 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--bg);
  overflow: hidden;
}

/* Полоса вклада — фоном внутри строки: отдельный элемент рядом с текстом
   съедал бы ширину, которой на телефоне нет. */
.l1-part-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--share, 0%);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
}
.is-hidden-part .l1-part-bar {
  background: color-mix(in srgb, var(--amber) 26%, transparent);
}

.l1-part-name { grid-area: name; position: relative; font-weight: 650; font-size: 15px; }
.l1-part-amount { grid-area: amount; position: relative; font-size: 12.5px; color: var(--text-3); }
.l1-part-kcal {
  grid-area: kcal;
  position: relative;
  align-self: center;
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
}

.l1-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-2);
}
/* Lucide replaces <i> with <svg>; size the resulting icon without shrinking. */
.l1-note > [data-lucide] {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  color: var(--primary-600);
}

.l1-go { justify-self: start; }

/* --------------------------------------------------- */
/*  Экран 2: свой разбор.                               */
/* --------------------------------------------------- */
.l1-section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 12px;
}

.l1-section-head { display: grid; gap: 8px; margin-bottom: 18px; }
.l1-section-head h2 { margin: 0; font-size: clamp(22px, 5.6vw, 32px); letter-spacing: -0.015em; }
.l1-section-head p { margin: 0; color: var(--text-2); font-size: 15px; }

/* На телефоне «сканер» — просто контейнер без своей рамки: внутри него уже
   есть рамка у карточки результата, и вложенные обводки с отступами воровали
   ширину, ничего не объясняя. Рамка возвращается на широком экране. */
.l1-scanner { padding: 0; }

.l1-inputs[hidden] { display: none; }
.l1-inputs { display: grid; gap: 14px; }

.l1-drop {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 22px 14px;
  border-radius: var(--r-md);
  border: 2px dashed var(--line);
  background: var(--bg);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s var(--ease);
}
.l1-drop:hover { border-color: var(--primary); }
/* Куда смотреть после «Теперь моя тарелка»: короткая подсветка рамки вместо
   самопроизвольного диалога выбора файла. */
.l1-drop.is-called { border-color: var(--primary); animation: l1-call 1.2s var(--ease); }
@keyframes l1-call {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 28%, transparent); }
}
.l1-drop i { font-size: 30px; color: var(--primary-600); }
.l1-drop b { font-size: 15.5px; }
.l1-drop span { font-size: 12.5px; color: var(--text-3); }

.l1-or {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-3);
}
.l1-or::before, .l1-or::after { content: ""; height: 1px; background: var(--line); }

.l1-text { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.l1-text input {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* меньше 16px — Safari зумит страницу на фокусе */
}
.l1-text input:focus { outline: none; border-color: var(--primary); }
.l1-send { grid-column: 1 / -1; justify-content: center; }

/* Кнопку диктовки показывает скрипт — только там, где распознавание речи в
   браузере есть. Скрытое состояние держит атрибут hidden, а не стили: иначе
   пришлось бы дублировать раскладку для двух состояний одной кнопки. */
.l1-mic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.l1-mic[hidden] { display: none; }
.l1-mic.is-live { border-color: var(--primary); color: var(--primary-600); }
.l1-mic i { font-size: 18px; }

/* Кнопка первого экрана: ведёт к главному действию страницы, поэтому на
   мобильном занимает всю ширину — она и есть первый шаг. */
.l1-hero-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  min-height: 52px;
  padding: 0 26px;
  font-size: 16px;
}
.l1-hero-cta i { font-size: 18px; }
@media (max-width: 719px) {
  .l1-hero-cta { width: 100%; }
}

.l1-quota { margin: 0; font-size: 12.5px; color: var(--text-3); }

/* Ожидание разбора живёт в scan_progress.css: тот же экран, что в веб-версии.
   Здесь остаётся только место под него. */
#scan-progress[hidden] { display: none; }

/* Карточка результата. */
.l1-result[hidden] { display: none; }
.l1-result { display: grid; gap: 18px; }

.l1-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--line);
}

.l1-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.l1-card-head b { font-size: 17px; }
.l1-conf { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

.l1-card-total { display: flex; align-items: baseline; gap: 7px; }
.l1-card-total strong { font-size: clamp(30px, 9vw, 42px); font-weight: 800; letter-spacing: -0.02em; }
.l1-card-total span { font-size: 15px; color: var(--text-2); }

/* Три макроса обязаны уложиться в одну строку даже на 360 px: перенос «У» на
   отдельную строку выглядит как ошибка вёрстки и отодвигает состав вниз. */
.l1-macros { display: flex; justify-content: space-between; gap: 10px; }
.l1-macro { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--text-2); white-space: nowrap; }
.l1-macro b { color: var(--text); }
.l1-macro i { width: 9px; height: 9px; border-radius: 50%; }
.m-p { background: var(--sky); }
.m-f { background: var(--amber); }
.m-c { background: var(--primary); }

.l1-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.l1-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name kcal" "note kcal";
  gap: 0 12px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
}
.l1-item span { grid-area: name; font-weight: 600; }
.l1-item em { grid-area: note; font-style: normal; font-size: 12.5px; color: var(--text-3); }
.l1-item b { grid-area: kcal; align-self: center; white-space: nowrap; }

.l1-fixes { display: grid; gap: 8px; padding-top: 4px; }
.l1-fixes-cap { font-size: 13.5px; color: var(--text-2); }
/* Все кнопки правок в одной сетке и с равными строками: «Порция меньше»
   переносится на две строки, «Был соус» — нет, и без grid-auto-rows: 1fr
   нижний ряд оказывался заметно ниже верхнего. */
.l1-fix-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 8px;
}

/* Одна высота на все четыре кнопки правок: «Порция меньше» переносится на две
   строки, «Был соус» — нет, и без общей высоты ряды выглядели съехавшими. */
.l1-fix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 8px 10px;
  line-height: 1.25;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.l1-fix:hover:not(:disabled) { border-color: var(--primary); }
.l1-fix:disabled { opacity: 0.45; cursor: default; }
.l1-fix i { font-size: 15px; }

.l1-hint { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }

/* Квалифицирующий вопрос. */
.l1-need { display: grid; gap: 10px; }
.l1-need-ask { margin: 0; font-size: 16px; font-weight: 700; }
.l1-need-row { display: grid; gap: 8px; }

.l1-need-btn {
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.l1-need-btn:hover { border-color: var(--primary); }
.l1-need-btn.is-picked { border-color: var(--primary); background: var(--bg-2); font-weight: 650; }

/* Переход. */
.l1-cta { display: grid; gap: 10px; justify-items: start; }
.l1-cta .btn-lg { width: 100%; justify-content: center; }
/* Пока создаётся аккаунт: кнопка занята, второй тап ничего не начинает. */
.l1-cta .btn-lg.is-busy { opacity: 0.6; pointer-events: none; }
.l1-cta-alt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--primary-600);
}
.l1-cta-note { margin: 0; font-size: 12.5px; color: var(--text-3); }

.l1-again {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.l1-again i { font-size: 15px; }

.l1-error[hidden] { display: none; }
.l1-error {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  justify-items: start;
  gap: 10px 12px;
}
.l1-error > [data-lucide] {
  grid-column: 1;
  grid-row: 1;
  width: 28px;
  height: 28px;
  color: var(--amber);
}
.l1-error > p, .l1-error > .l1-again { grid-column: 2; }
.l1-error p { margin: 0; font-size: 15px; line-height: 1.5; }

/* --------------------------------------------------- */
/*  Экран 3: три шага.                                  */
/* --------------------------------------------------- */
.l1-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.l1-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--card);
  border: 1px solid var(--line);
}
.l1-step h3 { margin: 0 0 4px; font-size: 16.5px; }
.l1-step p { margin: 0; font-size: 14.5px; color: var(--text-2); }

.l1-step-num {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--dark);
  color: var(--cream);
  font-weight: 700;
  font-size: 15px;
}

/* --------------------------------------------------- */
/*  Широкий экран: две колонки только там, где есть место. */
/* --------------------------------------------------- */
@media (min-width: 620px) {
  /* Экран уже не тесный — возвращаем поля и внешнюю рамку сканера. */
  .l1-hero { padding: 26px 18px 8px; }
  .l1-section { padding: 34px 18px; }
  .l1-scanner {
    padding: 18px;
    border-radius: var(--r-lg);
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: 0 6px 0 var(--stamp);
  }
  .l1-game, .l1-reveal, .l1-card { padding: 18px; }
}

@media (min-width: 880px) {
  .l1-hero {
    grid-template-columns: 1fr 1fr;
    align-items: start;
    padding-top: 44px;
    gap: 40px;
  }
  .l1-copy { position: sticky; top: 84px; }
  /* L1: the question/result fills the left column beside the photo. The
     mobile DOM order and the guess -> reveal -> own meal steps stay intact. */
  .l1-hero-scan {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "copy photo" "interaction photo";
    grid-template-rows: auto 1fr;
    gap: 24px 40px;
  }
  .l1-hero-scan .l1-copy { grid-area: copy; position: static; }
  .l1-hero-scan .l1-plate { display: contents; }
  .l1-hero-scan .l1-photo {
    grid-area: photo;
    position: sticky;
    top: 84px;
    align-self: start;
  }
  .l1-hero-scan .l1-game, .l1-hero-scan .l1-reveal { grid-area: interaction; }
  .l1-hero-scan .l1-parts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .l1-hero-scan .l1-part {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "name" "amount" "kcal";
  }
  .l1-hero-scan .l1-part-kcal { margin-top: 4px; }
  .l1-text { grid-template-columns: 1fr auto auto; }
  .l1-text input { grid-column: 1; }
  .l1-send { grid-column: auto; }
  .l1-need-row { grid-template-columns: 1fr 1fr; }
  .l1-steps { grid-template-columns: repeat(3, 1fr); }
  .l1-cta .btn-lg { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .is-scanning .l1-scan { animation: none; }
  .l1-tag { animation: none; opacity: 1; transform: none; }
}
