/* ========== 27. Templates: the picker on an empty board (app/js/templates.js, docs/templates.md) ==========
   A sheet of the chrome's paper in the bottom right corner, over the guide while that is on (--tk-b, set from it): its
   name in the book serif, how many there are in mono, the scenarios as a strip of tabs, the templates (each with its
   three colours, a line of what it is for), and at its foot Use this template with Keep example content under it. */
#tplk {
  position: fixed; right: 16px; bottom: var(--tk-b, 16px); z-index: 11; width: 324px; max-width: calc(100% - 32px);
  display: flex; flex-direction: column; box-sizing: border-box; padding: 14px 14px 12px;
  max-height: min(560px, calc(100% - var(--tk-b, 16px) - 76px));
  border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: var(--raise), var(--edge), 0 0 0 1px var(--rule);
  font: 400 13px/18px var(--f-ui);
}
#tplk[hidden] { display: none; }
#tplk > header, #tplk > .tk-q, #tplk > .tk-cats, #tplk > footer { flex: none; }
#tplk header { display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px; }
#tplk h2 { margin: 0; font: 400 19px/24px var(--f-display); letter-spacing: -.005em; }
#tplk .tk-n { font: 500 10px/13px var(--f-mono); letter-spacing: .08em; color: var(--ink-3); }
#tplk .tk-x { margin-left: auto; align-self: center; width: 28px; height: 28px; padding: 6px; border: 0; border-radius: 7px; background: none; color: var(--ink-3); cursor: pointer; }
#tplk .tk-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
@media (hover: hover) { #tplk .tk-x:hover { background: var(--press-bg); color: var(--ink); } }
#tplk .tk-q { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; background: var(--press-bg); box-shadow: var(--sunk); color: var(--ink-3); }
#tplk .tk-q svg { flex: none; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
#tplk .tk-q input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); font: inherit; }
#tplk .tk-q input::placeholder { color: var(--ink-3); }
#tplk .tk-q:focus-within { box-shadow: var(--sunk), 0 0 0 1.5px var(--ink-3); }
/* the scenarios: a strip that scrolls sideways, its edge fading */
#tplk .tk-cats { display: flex; gap: 2px; margin: 10px -14px 6px; padding: 0 14px 2px; overflow-x: auto; scrollbar-width: none;
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 22px), transparent); }
#tplk .tk-cats::-webkit-scrollbar { display: none; }
#tplk .tk-cats button { flex: none; height: 26px; padding: 0 9px; border: 0; border-radius: 13px; background: none; color: var(--ink-2); font: 500 12px/26px var(--f-ui); cursor: pointer; white-space: nowrap; }
@media (hover: hover) { #tplk .tk-cats button:hover { color: var(--ink); background: var(--press-bg); } }
#tplk .tk-cats button[aria-selected="true"] { background: var(--ink); color: var(--surface); }
/* the templates */
#tplk .tk-list { flex: 1 1 auto; min-height: 96px; margin: 0 -6px; padding: 2px 0; list-style: none; overflow-y: auto; outline: none; overscroll-behavior: contain; }
#tplk .tk-list li { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; padding: 7px 8px 8px; border-radius: 8px; cursor: pointer; }
#tplk .tk-list li b { font-weight: 500; font-size: 13.5px; }
#tplk .tk-list li small { grid-column: 1 / -1; color: var(--ink-3); font-size: 11.5px; line-height: 15px; }
#tplk .tk-list li[data-id=""] { padding-block: 8px; }
@media (hover: hover) { #tplk .tk-list li[data-id]:hover { background: var(--press-bg); } }
#tplk .tk-list li[aria-selected="true"] { background: var(--press-bg); box-shadow: var(--press), inset 2px 0 0 var(--ink); }
#tplk .tk-list:focus-visible li[aria-selected="true"] { box-shadow: var(--press), inset 0 0 0 1.5px var(--ink-3); }
#tplk .tk-list .tk-none { color: var(--ink-3); cursor: default; }
/* a template's three colours, each a dot a little over the one before */
#tplk .tk-d { display: flex; align-self: center; }
#tplk .tk-d i { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--surface); }
#tplk .tk-d i + i { margin-left: -3px; }
#tplk footer { display: grid; gap: 8px; justify-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
#tplk .tk-use { width: 100%; height: 36px; border: 0; border-radius: 9px; background: var(--ink); color: var(--surface); font: 500 13.5px/36px var(--f-ui); cursor: pointer; box-shadow: var(--raise-sm); }
#tplk .tk-use:disabled { opacity: .35; cursor: default; box-shadow: none; }
@media (hover: hover) { #tplk .tk-use:not(:disabled):hover { translate: 0 -1px; } }
#tplk .tk-use:not(:disabled):active { translate: none; box-shadow: var(--press); }
#tplk .tk-keep { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 12.5px; cursor: pointer; user-select: none; -webkit-user-select: none; }
#tplk .tk-keep input { width: 14px; height: 14px; margin: 0; accent-color: var(--ink); }
#tplk.tk-wait .tk-list { opacity: .4; }
/* The question (Jarred, 2026-11-08): whether every new board should open the picker, asked until the account answers,
   near the middle of the canvas (left of the picker while that shows: tplQaPlace sets left and top); its answer then
   says where to change it. A sheet of the chrome's paper, as the picker; its two answers alike, neither pushed. */
#tplq {
  position: fixed; left: 50%; top: 45%; z-index: 12; translate: -50% -50%; width: 340px; max-width: calc(100% - 32px);
  box-sizing: border-box; padding: 18px 18px 16px; border-radius: 14px; background: var(--surface); color: var(--ink);
  box-shadow: var(--raise), var(--edge), 0 0 0 1px var(--rule); font: 400 13px/18px var(--f-ui); text-align: left;
}
#tplq[hidden] { display: none; }
#tplq h2 { margin: 0 28px 0 0; font: 400 19px/25px var(--f-display); letter-spacing: -.005em; text-wrap: pretty; }
#tplq.tq-told h2 { font-size: 17px; line-height: 23px; }
#tplq p { margin: 6px 0 0; color: var(--ink-2); font-size: 12.5px; line-height: 17px; }
#tplq .tq-x { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; padding: 6px; border: 0; border-radius: 7px; background: none; color: var(--ink-3); cursor: pointer; }
#tplq .tq-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
#tplq .tq-a { display: flex; gap: 8px; margin-top: 14px; }
#tplq .tq-a button { flex: 1; height: 36px; padding: 0 14px; border: 0; border-radius: 9px; cursor: pointer; font: 500 13.5px/36px var(--f-ui);
  background: var(--press-bg); color: var(--ink); box-shadow: var(--raise-sm), var(--edge); }
#tplq .tq-a .tq-ok { background: var(--ink); color: var(--surface); }
@media (hover: hover) { #tplq .tq-a button:hover { translate: 0 -1px; } #tplq .tq-x:hover { background: var(--press-bg); color: var(--ink); } }
#tplq .tq-a button:active { translate: none; box-shadow: var(--press); }
#tplq button:focus-visible { outline: 1.5px solid var(--ink-3); outline-offset: 1px; }
/* while it asks, the empty board says nothing under it */
body.tpl-q #empty { visibility: hidden; }
/* the way in that is always there, under "This board is empty" (the sample's button, as it looks) */
#empty .e-tpl[hidden] { display: none; }
#tplk button:focus-visible { outline: 1.5px solid var(--ink-3); outline-offset: 1px; }
/* while one shows, the empty board says nothing (it isn't, as it shows) */
body.tpl-on #empty { visibility: hidden; }
/* a template as it would be: the level's own look, never touched (it is in #aig, which is never saved) */
#aig > .tpl-pv { position: absolute; left: 0; top: 0; pointer-events: none; }
html.pocket #tplk { left: 8px; right: 8px; width: auto; max-width: none; max-height: min(420px, calc(100% - var(--tk-b, 16px) - 72px)); }
