/* demo-2026 diagrams: the strip "Start from a template" under the diagram (index.html, main.js).
   index.html links this file after styles.css. Like styles.css it reads only the kit's --uk-*
   variables, so both themes follow from the kit. */

/* Компонента нет в uikit 1.3.1, собран из переменных кита.
   Задача для uikit: полоса предложений uk-suggest-strip. Группа (role="group", aria-labelledby) у
   нижнего края области содержимого, в потоке, а не поверх него: над ней строка с подписью слева
   и справа тихой кнопкой "все варианты" и кнопкой-иконкой закрытия, под ней строки кнопок одной
   высоты --uk-control-height, сгруппированные под метками групп; кнопки сохраняют подписи целиком,
   а не влезающие в отведённые строки прячутся целиком; полоса не выходит за свой контейнер. Состояния: скрыта (hidden), видна, наведение на кнопку (--uk-hover), фокус с
   клавиатуры. Здесь это шаблоны первого входа под схемой: --dg-strip-size задаёт высоту полосы, и
   кнопки, которые стоят у нижнего края панели схемы, поднимаются над ней. */
#panel-preview {
  --dg-strip-size: 0px;
}

/* Padding, the row of the heading, the gap, the row of templates and the line on top: whole
   pixels, so the buttons stand on whole pixels under a panel that ends on one. */
#panel-preview:has(> .template-strip:not([hidden])) {
  --dg-strip-size: calc(2 * var(--uk-control-height) + 3 * var(--uk-space-2) + var(--uk-line-width));
}

/* The strip stands in the column of the panel under .preview, which is flex: 1 1 auto with
   min-height: 0: the preview gives up the height and the strip never covers the diagram. */
.template-strip {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: var(--uk-space-2);
  box-sizing: border-box;
  block-size: var(--dg-strip-size);
  min-inline-size: 0;
  padding: var(--uk-space-2) var(--uk-space-3);
  border-block-start: var(--uk-line-width) solid var(--uk-line);
  background: var(--uk-surface);
}

.template-strip__head {
  display: flex;
  align-items: center;
  gap: var(--uk-space-2);
  min-inline-size: 0;
}

.template-strip__title {
  flex: 1 1 auto;
  min-inline-size: 0;
  max-inline-size: none;
  margin: 0;
  overflow: hidden;
  color: var(--uk-text-muted);
  font-size: var(--uk-text-sm);
  line-height: calc(var(--uk-space-4) + var(--uk-space-1));
  white-space: nowrap;
  text-overflow: ellipsis;
}

.template-strip .uk-button {
  flex: none;
}

.template-strip .uk-button:not(.uk-button--icon) {
  padding-inline: var(--uk-space-3);
}

/* The tiles flow in rows and keep their whole names; the list is as tall as the rows the strip has
   room for (one, two on a phone), and main.js hides whole the tiles that fall below them. The
   tiles of a row share its width. */
.template-strip__list {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: var(--uk-space-2);
  min-inline-size: 0;
  min-block-size: 0;
  overflow: hidden;
}

.template-strip__list > [hidden] {
  display: none;
}

.template-strip .template-strip__btn {
  flex: 1 0 auto;
  justify-content: center;
  font-size: var(--uk-text-sm);
}

/* The engine's name and the first tile of its group: one piece, so the name never
   stays alone at the end of a row. Its tile is the one that may end with an ellipsis, when a name
   is wider than the whole row. */
.template-strip__lead {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: var(--uk-space-2);
  min-inline-size: 0;
}

.template-strip__lead .template-strip__btn {
  flex: 1 1 auto;
  min-inline-size: 0;
}

/* The engine's name is a quiet label, not a button: muted text without a frame. The second group
   stands a little apart from the first. */
.template-strip__engine {
  flex: none;
  color: var(--uk-text-muted);
  font-size: var(--uk-text-sm);
  font-weight: 700;
}

.template-strip__lead:not(:first-child) {
  margin-inline-start: var(--uk-space-2);
}

.template-strip__name {
  min-inline-size: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* A tablet and a computer: the Colors & layout button and its popover in the bottom left corner
   of the diagram panel stand above the strip. */
@media (width >= 768px) {
  #panel-preview > .dg-view-btn {
    inset-block-end: calc(var(--uk-space-3) + var(--dg-strip-size));
  }

  #panel-preview > .dg-view {
    inset-block-end: calc(var(--uk-space-3) + var(--uk-control-height) + var(--uk-space-1) + var(--dg-strip-size));
    max-block-size: calc(100% - var(--uk-control-height) - var(--uk-space-3) * 2 - var(--uk-space-1) - var(--dg-strip-size));
  }
}

/* A phone: two rows of tiles, so the strip is one row of buttons taller. Zoom and Export at the
   bottom of the diagram panel stand above it. */
@media (width < 768px) {
  #panel-preview:has(> .template-strip:not([hidden])) {
    --dg-strip-size: calc(3 * var(--uk-control-height) + 4 * var(--uk-space-2) + var(--uk-line-width));
  }

  #panel-preview .zoom {
    inset-block-end: calc(var(--uk-space-3) + var(--dg-strip-size));
  }

  #panel-preview .dg-export {
    inset-block-end: calc(var(--uk-space-3) + var(--uk-control-height) + var(--uk-space-1) + var(--dg-strip-size));
  }
}

/* A short phone (#2158): below 720 px of window height two rows of tiles would leave the diagram
   under 300 px between the top bar and the Export row (375x812 leaves 400 px, 375x667 255 px), so
   the strip keeps one row, as tall as on a computer; 375x812 and 390x844 keep two. */
@media (width < 768px) and (height < 720px) {
  #panel-preview:has(> .template-strip:not([hidden])) {
    --dg-strip-size: calc(2 * var(--uk-control-height) + 3 * var(--uk-space-2) + var(--uk-line-width));
  }
}
