/* Native content pages. Opt-in and shared shell are owned by the route manifest.
 * Reference phone frames: delivery 451:314, flavours 605:1147,
 * FAQ 783:2106, privacy 654:678. Keep existing artwork/type at 430px;
 * below the reference width, content reflows instead of shrinking via zoom.
 */
@media (max-width: 430px) {
  body.phone-flow :is(.dp-page, .sostav-page, .faq-page, .legal-page) {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
  }

  body.phone-flow .dp-wrap {
    width: 100%;
    padding-inline: var(--phone-gutter, clamp(16px, 5.814vw, 25px));
  }

  body.phone-flow .dp-page :is(.dp-content, .dp-block, .dp-list, .dp-accent, .dp-req) {
    width: 100%;
    max-width: 379px;
    min-width: 0;
  }

  body.phone-flow .dp-title {
    width: 100%;
    max-width: 379px;
    font-size: clamp(28px, 8.837vw, 38px);
    letter-spacing: .06em;
    white-space: normal;
  }

  body.phone-flow .dp-h2 {
    max-width: 100%;
    font-size: clamp(28px, 7.907vw, 34px);
  }

  body.phone-flow .dp-list li { min-width: 0; max-width: 100%; }
  /* Десктопные <br> в списках и реквизитах на телефоне рвали фразы не по
     смыслу («передаваемых / персональных», «оплаты с помощью / банковской
     карты»). Убираем принудительные переносы — текст обтекает под ширину. */
  body.phone-flow :is(.dp-list, .dp-req) br { display: none; }
  /* Кроме точек продаж: там перенос смысловой — название заведения и
     его адрес (жирным) стоят на разных строках, как в макете. Без него
     они склеивались в одну строку. */
  body.phone-flow .dp-list--star br { display: inline; }
  /* [69] «HOFF» одно на строке — переносим весь блок «(вход со стороны «HOFF»)»
     на отдельную строку вместо разрыва посреди фразы. */
  body.phone-flow .dp-hoff-break { display: inline; }
  /* Mobile section spacing is authored on each block in content-responsive.css.
     A second flex gap doubled those margins and pushed every later section down. */
  body.phone-flow .dp-content { gap: 0; }
  /* Keep the same 46px section rhythm after the long blocks; the shared
     responsive layer compacts these three transitions for a different flow. */
  body.phone-flow .dp-block:nth-of-type(5),
  body.phone-flow .dp-block:nth-of-type(6),
  body.phone-flow .dp-block:nth-of-type(7) { margin-bottom: 46px; }
  body.phone-flow .dp-list--icon li > :last-child { min-width: 0; }
  body.phone-flow .dp-ic { flex-shrink: 0; }

  /* Both text lines occupy flow space; the handwritten line is not a canvas. */
  body.phone-flow .dp-accent {
    display: flex;
    flex-direction: column;
    gap: 7px;
    height: auto;
    min-height: 174px;
  }

  body.phone-flow .dp-accent__script {
    position: static;
    display: block;
    margin-left: 4px;
    max-width: calc(100% - 4px);
    font-size: clamp(48px, 14.884vw, 64px);
  }

  body.phone-flow .dp-accent__text {
    position: static;
    display: block;
    width: 100%;
  }

  body.phone-flow .sostav-section { width: 100%; }
  body.phone-flow .sostav-page { overflow: visible; }
  body.phone-flow .sostav-section__inner {
    width: calc(100% - 2 * var(--phone-gutter, clamp(16px, 5.814vw, 25px)));
    max-width: 380px;
    margin-inline: auto;
  }

  body.phone-flow :is(.sostav-header, .sostav-allergens__text, .sostav-list, .sostav-item, .sostav-item__text) {
    width: 100%;
    min-width: 0;
  }

  body.phone-flow .sostav-header {
    display: grid;
    height: auto;
    /* Keep the title track equal to its authored text width as the heading
       scales, so the star follows the visible «МАКАРОН» at every phone size. */
    font-size: clamp(27px, 8.605vw, 37px);
    grid-template-columns: 8.79em 23px;
    column-gap: 14px;
    max-width: 380px;
  }

  body.phone-flow .sostav-allergens { display: contents; }
  body.phone-flow .sostav-allergens__star {
    position: static;
    margin: 10px 0 0;
    justify-self: start;
  }

  body.phone-flow .sostav-title {
    min-width: 0;
    font-size: clamp(27px, 8.605vw, 37px);
    letter-spacing: .06em;
    white-space: normal;
  }

  body.phone-flow .sostav-allergens__text { width: 100%; max-width: min(100%, 343px); }
  /* [59].2 — переносы: убираем «висячие» слова в описаниях составов
     и в аллергенах. text-wrap:pretty поддержан Safari 17.4+, Chrome 117+.
     На старых движках просто игнорируется без вреда. */
  body.phone-flow .sostav-item__desc,
  body.phone-flow .sostav-item__name,
  body.phone-flow .sostav-allergens__text { text-wrap: pretty; }
  body.phone-flow .sostav-item:nth-child(n) { height: auto; min-height: 0; }
  /* The normalized image canvases share a scale, but Figma's layout slots
     include per-art shadow bounds. 52px is the common slot; group exceptions
     below follow the authored phone card frames in 605:1147. */
  body.phone-flow .sostav-item { --flavour-art-height: 52px; }
  body.phone-flow .sostav-item:nth-child(1),
  body.phone-flow .sostav-item:nth-child(11),
  body.phone-flow .sostav-item:nth-child(14),
  body.phone-flow .sostav-item:nth-child(19) { --flavour-art-height: 51px; }
  body.phone-flow .sostav-item:nth-child(2),
  body.phone-flow .sostav-item:nth-child(8) { --flavour-art-height: 54px; }
  body.phone-flow .sostav-item:nth-child(3),
  body.phone-flow .sostav-item:nth-child(5),
  body.phone-flow .sostav-item:nth-child(18) { --flavour-art-height: 53px; }
  body.phone-flow .sostav-item:nth-child(6),
  body.phone-flow .sostav-item:nth-child(28) { --flavour-art-height: 63px; }
  body.phone-flow .sostav-item:nth-child(9),
  body.phone-flow .sostav-item:nth-child(16),
  body.phone-flow .sostav-item:nth-child(17) { --flavour-art-height: 50px; }
  body.phone-flow .sostav-item:nth-child(10) { --flavour-art-height: 57px; }
  body.phone-flow .sostav-item:nth-child(12) { --flavour-art-height: 55px; }
  body.phone-flow .sostav-item:nth-child(13) { --flavour-art-height: 54.19px; }
  body.phone-flow .sostav-item:nth-child(25),
  body.phone-flow .sostav-item:nth-child(26) { --flavour-art-height: 56px; }
  body.phone-flow .sostav-item:first-child { padding-bottom: 36px; }
  body.phone-flow .sostav-item .sostav-item__photo {
    height: var(--flavour-art-height);
    min-height: var(--flavour-art-height);
  }
  body.phone-flow .sostav-item .sostav-item__photo img {
    position: static;
    width: 193.333px; height: auto; max-width: none;
    transform: none;
  }
  /* Only the first flavour has the narrower 605:1302 text wrapper. The
   * remaining Figma wrappers fill the 328px padded card interior. */
  body.phone-flow .sostav-item__text { max-width: 328px; }
  body.phone-flow .sostav-item:first-child .sostav-item__text { max-width: 297px; }
  /* Figma text boxes are 35px per line (70px for the two-line first title).
   * Browser `normal` resolves slightly shorter for the local Masvol font. */
  body.phone-flow .sostav-item__name { line-height: 35px; hyphens: none; }

  body.phone-flow :is(.faq-page, .faq-wrap) { height: auto; min-height: 0; }
  body.phone-flow .faq-wrap {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding-inline: var(--phone-gutter, clamp(16px, 5.814vw, 25px));
  }

  body.phone-flow :is(.faq-title, .faq-list, .faq-item) {
    position: relative;
    inset: auto;
    width: 100%;
    min-width: 0;
  }

  body.phone-flow .faq-title {
    max-width: 340px;
    height: auto;
    font-size: clamp(30px, 8.605vw, 37px);
  }

  body.phone-flow .faq-item { height: auto; min-height: 80px; }
  body.phone-flow .faq-item__head {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    width: 100%;
    height: auto;
    min-height: 36px;
    gap: clamp(12px, calc(18.182vw - 46.182px), 32px);
  }

  body.phone-flow .faq-item__q { min-width: 0; }
  body.phone-flow .faq-item--open .faq-item__body { max-height: none; overflow: visible; }
  body.phone-flow .faq-item__body p,
  body.phone-flow .faq-item__list {
    width: 100%;
    padding-left: clamp(0px, calc(61.818vw - 197.818px), 68px);
    /* Figma 783:2142: answer column has a 30px right inset at 430px. */
    padding-right: clamp(0px, calc(27.273vw - 87.273px), 30px);
  }

  body.phone-flow .faq-item__list li > :last-child { min-width: 0; }
  body.phone-flow .faq-item__body a { overflow-wrap: anywhere; }

  body.phone-flow .legal-page .container {
    width: 100%;
    max-width: none;
    padding-inline: clamp(16px, 6.047vw, 26px);
  }

  body.phone-flow .legal-title {
    font-size: clamp(26px, 7.442vw, 32px);
    line-height: 1.21875;
  }

  body.phone-flow .legal-h2 { font-size: clamp(28px, 8.372vw, 36px); }
  body.phone-flow .legal-section a { overflow-wrap: anywhere; }
}

/* [58] / КБЖУ: the reference pill hugs its text with 19px left and 17px
   right insets. Let the all-flavour pill size to its longest line instead
   of centering a short line in the old fixed 308px box. */
@media (max-width: 430px) {
  body.phone-flow .sostav-item__kbzhu {
    box-sizing: border-box;
    width: max-content;
    max-width: calc(100vw - 24px);
    padding-left: 19px;
    padding-right: 17px;
    justify-content: flex-start;
  }
}

@media (max-width: 379px) {
  body.phone-flow .sostav-item { padding-inline: 20px; }
  body.phone-flow .sostav-item__text { padding-inline: 0; }
}

/* [scaling.5] на 320 итоговая ширина текста была ~230 (gutter 18 +
   карточка 20 + внутренние). Ослабляем gutter секции и карточку
   до 12/14, ширина .sostav-item__desc растёт на ~35px. */
@media (max-width: 340px) {
  body.phone-flow .sostav-section__inner {
    width: calc(100% - 24px);
  }
  body.phone-flow .sostav-item { padding-inline: 14px; }
}

/* Узкие телефоны ≤374: страницы FAQ и «Политики» резиновые, при 320–360
   комбинация 25px внешних паддингов + 68px внутренней колонки для номера
   ужимала ответы до 3 слов в строке. Сжимаем боковые поля и кегль текста. */
@media (max-width: 374px) {
  body.phone-flow :is(.faq-wrap, .legal-page .container) {
    padding-inline: 12px;
  }
  body.phone-flow .faq-item { padding: 18px 12px; min-height: 0; }
  body.phone-flow .faq-item__head { gap: 8px; grid-template-columns: 28px minmax(0, 1fr) 28px; }
  body.phone-flow .faq-item__num { font-size: 14px; }
  body.phone-flow .faq-item__q { font-size: 13px; line-height: 1.25; }
  body.phone-flow .faq-item__body p,
  body.phone-flow .faq-item__list {
    padding-left: 36px;
    padding-right: 4px;
    font-size: 13px;
    line-height: 1.4;
  }
  body.phone-flow .legal-title { font-size: 24px; line-height: 1.2; }
  body.phone-flow .legal-h2 { font-size: 22px; line-height: 1.2; }
  body.phone-flow .legal-section p,
  body.phone-flow .legal-list li { font-size: 13px; line-height: 1.4; }
}

/* At native 500% on a 1280px window the CSS viewport is 256px. Keep the
   allergen star inside the header grid and let long display words wrap at
   narrow widths without clipping or changing the authored type scale. */
@media (max-width: 319px) {
  body.phone-flow .sostav-header { grid-template-columns: minmax(0, 1fr) 23px; }
  body.phone-flow .dp-h2 { overflow-wrap: anywhere; }
  body.phone-flow .dp-accent__text { overflow-wrap: anywhere; }
}
