/* <x-template>: the lines of a text template, each with bold, a size (klein / groot on a screen, mm or pt on paper)
   and remove. */
x-template {
  display: block;
  max-width: 720px;

  /* Above the lines: the colours (screen) and the alignment of the whole template. */
  .template-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
  .head-field { display: flex; flex-direction: column; gap: 6px; }
  .head-field .input.number { width: 100px; }
  .input.color { width: 72px; height: 40px; padding: 4px; cursor: pointer; }
  .aligns { display: flex; gap: 4px; }
  .toggle.align { width: 40px; height: 40px; }
  .toggle.align .ic { width: 18px; height: 18px; }
  .toggle.align.on { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }

  .lines { display: flex; flex-direction: column; gap: 6px; }

  .line { display: flex; align-items: center; gap: 6px; }

  .text {
    flex: 1;
    min-width: 0;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--input-bg);
    line-height: 20px;
    outline: none;
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);

    &:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  }
  .line.bold .text { font-weight: 700; }
  .line.large .text { font-size: 19px; line-height: 24px; }
  .line.small .text { font-size: 12px; }

  kbd {
    display: inline-block;
    padding: 0 6px;
    margin: 0 1px;
    border-radius: 4px;
    background: var(--muted-soft);
    color: var(--fg);
    font-family: inherit;
    font-size: 0.9em;
    line-height: 1.5;
    user-select: all;
  }

  .toggle {
    width: 36px;
    height: 36px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--fg-3);
    font-weight: 700;
    display: grid;
    place-items: center;
    transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);

    &:hover { color: var(--fg); border-color: var(--line-strong); }
    .ic { width: 16px; height: 16px; }
  }
  .toggle.large { font-size: 17px; }
  .toggle.small { font-size: 11px; }
  .line.bold .toggle.bold, .line.large .toggle.large, .line.small .toggle.small { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }

  /* The size on paper: a number with its unit and a list to choose from. */
  .size { position: relative; flex: none; display: flex; align-items: center; }
  .size-input { width: 104px; height: 36px; padding: 0 56px 0 10px; text-align: right; }
  .size .unit { position: absolute; right: 32px; color: var(--fg-3); font-size: 12px; pointer-events: none; }
  .size-open { position: absolute; right: 2px; width: 26px; height: 32px; border: 0; background: none; color: var(--fg-3); display: grid; place-items: center; }
  .size-open:hover { color: var(--fg); }
  .size-open .ic { width: 14px; height: 14px; }
  .size-list {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 10;
    width: 104px;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
  }
  .size-list[hidden] { display: none; }
  .size-list button { height: 30px; padding: 0 10px; border: 0; border-radius: 4px; background: none; color: var(--fg); text-align: right; }
  .size-list button:hover { background: var(--zebra); }

  .tools { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
  .tools .variable { width: auto; min-width: 200px; }

  /* The preview: the sheet has the ratio of the screen, label or A4 page; the text scales with its width (cqw). */
  .preview { margin-top: 28px; }
  .preview-title { font-size: 13px; font-weight: 600; color: var(--fg-2); margin-bottom: 8px; }
  .sheet {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: #111111;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }
  .sheet-lines { padding: 4cqw 5cqw; }
  .sheet-line { line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sheet-line.bold { font-weight: 700; }

  /* The screen: relative sizes, the same as the screen of the badgestation (badgestation/pi badgestation/web). */
  .sheet.screen { cursor: pointer; }
  .sheet.screen { width: 360px; max-width: 100%; aspect-ratio: 800 / 480; background: #10161d; color: #ffffff; border: 8px solid #2a2f36; border-radius: 10px; }
  .sheet.screen .sheet-line { font-size: 4.5cqw; }
  .sheet.screen .sheet-line.small { font-size: 3cqw; }
  .sheet.screen .sheet-line.large { font-size: 8cqw; }

  .sheet.label { width: 340px; max-width: 100%; border-radius: 6px; }

  .sheet.a4 { width: 340px; max-width: 100%; aspect-ratio: 210 / 297; justify-content: flex-start; border-radius: 2px; }
  .sheet.a4 .sheet-lines { padding: 10cqw 9cqw; }
}
