/* Promotion instructions, gallery, and editor. Loaded from promo-howto-assets
 * beside main.css in layouts/main. Remove that include with the public
 * promo-howto templates and promo-gallery.js when retiring the public component. */
.promo-bottom-sheet__content:has(> .promo-howto) { touch-action: pan-y; }

@media (min-width: 769px) {
  .promo-bottom-sheet__dialog:has(.promo-howto) { width: min(600px, 90vw); }
}

.promo-howto {
  /* No global white card surface token. */
  --promo-howto-paper: white;
  --promo-howto-padding: 28px;
  color: var(--text-main);
  background: var(--promo-howto-paper);
  font: 400 15px/1.45 var(--font-sans);
  overflow-wrap: anywhere;
}

.promo-howto__body { display: grid; gap: 16px; padding: 24px var(--promo-howto-padding) 12px; }
.promo-howto__header { padding-inline-end: 40px; }
.promo-howto__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font: 600 11px/1.4 var(--font-mono);
}

.promo-howto__type {
  padding: 4px 8px;
  border-radius: calc(var(--ds-control-radius) / 2);
  background: var(--brand-tint);
  color: var(--brand-ink);
  text-transform: uppercase;
}

.promo-howto__name {
  margin: 12px 0 0;
  color: var(--text-main);
  font: 700 20px/1.35 var(--font-display);
  text-transform: uppercase;
}

.promo-howto__need {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--ds-island-radius);
  background: var(--brand-tint);
}

.promo-howto__need svg { flex: none; color: var(--brand-ink); }
.promo-howto__need h3 { margin: 0 0 2px; color: var(--text-muted); font: 500 12px/1.3 var(--font-sans); }
.promo-howto__need p { margin: 0; font-weight: 600; }
.promo-howto__title { margin: 0 0 12px; font: 700 12px/1.4 var(--font-display); text-transform: uppercase; }
.promo-howto__steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.promo-howto__step { display: flex; align-items: flex-start; gap: 12px; }
.promo-howto__number {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--text-main);
  color: var(--promo-howto-paper);
  font-weight: 700;
}

.promo-howto__step[aria-current="true"] .promo-howto__number { background: var(--brand-ink); }
.promo-howto__gallery { position: relative; min-width: 0; }
.promo-howto__track {
  position: relative;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x;
}

/* Картинка любой формы (квадрат, 16:9, 9:16) видна целиком: вписывается в постоянную область по центру. */
.promo-howto__frame {
  --promo-howto-image-height: 260px;
  display: grid;
  grid-template-rows: var(--promo-howto-image-height);
  place-items: center;
  flex: 0 0 100%;
  min-width: 0;
  margin: 0;
  padding: 14px;
  border-radius: 20px;
  background: var(--surface-body);
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.promo-howto__frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-control-radius);
  background: var(--promo-howto-paper);
  box-shadow: 0 6px 20px rgb(13 14 18 / 8%);
}

/* Управление галереей как в макете: белые круглые стрелки по бокам картинки, точки под ней */
.promo-howto__arrow {
  position: absolute;
  top: 144px; /* середина картинки: 14px поля рамки + 260px / 2 */
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--promo-howto-paper);
  box-shadow: 0 4px 14px rgb(13 14 18 / 18%);
  color: var(--text-main);
  cursor: pointer;
  translate: 0 -50%;
  transition: opacity .15s ease, transform .15s ease;
}
.promo-howto__arrow svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.promo-howto__arrow--prev { inset-inline-start: -12px; }
.promo-howto__arrow--next { inset-inline-end: -12px; }
.promo-howto__arrow:disabled { opacity: 0; pointer-events: none; }
.promo-howto__dots { display: flex; justify-content: center; gap: 2px; margin-top: 8px; }
.promo-howto__dot {
  display: grid;
  place-items: center;
  height: 24px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.promo-howto__dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 4px;
  background: var(--ds-line);
  transition: width .2s ease, background-color .2s ease;
}
.promo-howto__dot[aria-current="true"]::before { width: 20px; background: var(--text-main); }
.promo-howto__terms { border-top: 1px solid var(--ds-line); color: var(--text-muted); font: 400 13px/1.65 var(--font-sans); }
.promo-howto__terms summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  gap: 8px;
  list-style: none;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}

.promo-howto__terms summary::-webkit-details-marker { display: none; }
.promo-howto__terms summary::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  margin-inline-end: 4px;
  border-inline-end: 2px solid currentColor;
  border-block-end: 2px solid currentColor;
  transform: rotate(45deg);
}
.promo-howto__terms[open] summary::after { transform: rotate(225deg); }
.promo-howto__terms p { margin: 0 0 8px; white-space: pre-line; }
.promo-howto__terms--open { padding-top: 16px; }
.promo-howto__terms-title { margin: 0 0 10px; color: var(--text-main); font: 700 12px/1.3 var(--font-display); text-transform: uppercase; }

.promo-howto__footer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding: 12px var(--promo-howto-padding) max(20px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--ds-line);
  background: var(--promo-howto-paper);
}

.promo-howto__action { width: 100%; }
.promo-howto__action svg { flex: none; }
.promo-howto :is(button, summary):focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 2px; }

@media (hover: hover) {
  .promo-howto__arrow:hover { transform: scale(1.06); }
  .promo-howto__dot:not([aria-current="true"]):hover::before { background: var(--text-muted); }
}

@media (max-width: 768px) {
  .promo-howto { --promo-howto-padding: 20px; }
  .promo-howto__body { gap: 12px; padding-top: 4px; }
  .promo-howto__name { font-size: 17px; }
  .promo-howto__frame { --promo-howto-image-height: 240px; }
  .promo-howto__arrow { display: none; }
}

/* Admin editor: one compact line per step, image tiles for illustrations. */
.promo-howto__editor { display: grid; gap: 16px; min-width: 0; margin-top: 16px; }
.promo-howto__editor-section { min-width: 0; }
.promo-howto__editor [hidden] { display: none; }
.promo-howto__editor-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

.promo-howto__editor-row--step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 44px auto;
  align-items: start;
  gap: 8px 12px;
}
.promo-howto__editor-number {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: 10px;
  border-radius: 50%;
  background: var(--ds-ink);
  color: #fff;
  font: 600 12px/1 var(--ds-text);
  font-variant-numeric: tabular-nums;
}
.promo-howto__editor-fields { min-width: 0; }
.promo-howto__editor-text { --ds-textarea-height: 44px; --admin-textarea-padding: 10px 14px; }
/* Поле растёт по тексту само (field-sizing), ручка изменения размера в одну строку не нужна. */
.promo-howto__editor-row .promo-howto__editor-text.form-control { resize: none; }
.promo-howto__editor-row-note { grid-column: 2 / -1; margin: 0; }

.promo-howto__editor-image { position: relative; width: 44px; }
.promo-howto__editor-slot {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1.5px dashed var(--admin-input-border, #dde1ea);
  border-radius: 12px;
  color: var(--ds-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.promo-howto__editor-slot:hover { border-color: var(--admin-input-border-hover, #b5bdcc); color: var(--ds-ink); }
.promo-howto__editor-slot:focus-within { outline: 2px solid var(--ds-accent); outline-offset: 2px; }
.promo-howto__editor-slot:has(img:not([hidden])) { border-style: solid; }
.promo-howto__editor svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.promo-howto__editor-slot input, .promo-howto__editor-slot img { position: absolute; inset: 0; width: 100%; height: 100%; }
.promo-howto__editor-slot input { opacity: 0; cursor: pointer; }
.promo-howto__editor-slot input:disabled { cursor: default; }
.promo-howto__editor-slot img { border-radius: 10px; object-fit: cover; object-position: top; background: var(--surface-body); }

.promo-howto__editor-remove-image {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ds-ink);
  color: #fff;
  cursor: pointer;
}
.promo-howto__editor-remove-image::before { content: ""; position: absolute; inset: -8px; }

.promo-howto__editor-tools { display: flex; gap: 2px; padding-top: 6px; }
.promo-howto__editor-tool {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ds-muted);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s, color .15s;
}
.promo-howto__editor-tool:hover:not(:disabled) { background: #e9ecf2; color: var(--ds-ink); }
.promo-howto__editor-delete:hover:not(:disabled) { background: #fff2f0; color: var(--ds-danger); }
.promo-howto__editor-tool:disabled { opacity: .35; cursor: default; }
:is(.promo-howto__editor-tool, .promo-howto__editor-remove-image, .promo-howto__editor-add-tile):focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; }

.promo-howto__editor-add { width: auto; margin-top: 8px; margin-left: 36px; }

.promo-howto__editor-group--illustrations { display: flex; flex-wrap: wrap; gap: 8px; }
.promo-howto__editor-group--illustrations .promo-howto__editor-list { display: contents; }
.promo-howto__editor-row--tile { position: relative; width: 88px; }
.promo-howto__editor-row--tile .promo-howto__editor-number { display: none; }
.promo-howto__editor-row--tile .promo-howto__editor-image { width: 88px; }
.promo-howto__editor-row--tile .promo-howto__editor-row-note { margin-top: 4px; }
.promo-howto__editor-add-tile {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  padding: 0;
  border: 1.5px dashed var(--admin-input-border, #dde1ea);
  border-radius: 12px;
  background: transparent;
  color: var(--ds-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.promo-howto__editor-add-tile:hover { border-color: var(--admin-input-border-hover, #b5bdcc); color: var(--ds-ink); }

.promo-howto__editor-error { margin: 4px 0 0; color: var(--ds-danger); font: 400 12px/16px var(--ds-text); }
.promo-howto__editor-undo { display: flex; align-items: center; gap: 10px; font: 400 13px/18px var(--ds-text); color: var(--ds-muted); }

@media (max-width: 767px) {
  .promo-howto__editor-row--step { grid-template-columns: 24px minmax(0, 1fr) 44px; }
  .promo-howto__editor-row--step .promo-howto__editor-tools { grid-column: 2 / -1; justify-content: flex-end; padding: 0; margin-block: -8px -4px; }
  .promo-howto__editor-row--step .promo-howto__editor-tool { width: 44px; height: 44px; }
}
