/* Twiggy's own styles. Everything shared lives in kit.css. */

#view #gl {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
}
#busy {
  position: absolute;
  left: 12px;
  bottom: 12px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  pointer-events: none;
}

/* --- viewport bar, stats, pieces ------------------------------------------- */
/* The bar sits under the view, styled like the tool column. On a phone in
   portrait the tool column already sits at the bottom of the view, so the
   bar becomes a column on the right. */
#viewbar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
}
#viewbar button {
  width: 30px;
  height: 30px;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
}
#viewbar button:hover { color: var(--text); background: var(--raise); border-color: var(--line); }
#viewbar button[aria-pressed=true] { color: var(--ink); background: var(--accent); border-color: var(--accent); }
#viewbar button svg { width: 17px; height: 17px; display: block; }
#viewbar .vbsep { width: 1px; height: 20px; margin: 0 3px; background: var(--line); }
#busy { left: 12px; bottom: 56px; }
html.sheet #viewbar {
  left: auto;
  right: calc(8px + env(safe-area-inset-right));
  top: var(--sheet-top);
  bottom: auto;
  transform: none;
  flex-direction: column;
  /* Above the sheet: a column that wraps into another to its left when the
     view left above the sheet is short (half sheet, keyboard open). */
  flex-wrap: wrap-reverse;
  align-content: flex-start;
  max-height: calc(100% - var(--sheet-top) - var(--sheet-h, 0px) - 10px);
}
html.sheet #viewbar button { width: 38px; height: 38px; }
html.sheet #viewbar button svg { width: 20px; height: 20px; }
html.sheet #viewbar .vbsep { width: 20px; height: 1px; margin: 3px 0; }
html.sheet #busy { left: 54px; top: calc(var(--sheet-top) + 8px); bottom: auto; }

#statpanel {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 3;
  max-width: min(340px, 60%);
  max-height: calc(100% - 80px);
  overflow: auto;
  padding: 7px 10px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 10px;
}
#statpanel dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
#statpanel dt { color: var(--dim); }
#statpanel dd { margin: 0; color: var(--text); text-align: right; }
#statpanel dd.warn { color: var(--warn); }
#statpanel .tip { margin: 6px 0 0; }
#statpanel .paneltitle {
  margin: 0 0 6px;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
}
html.sheet #statpanel { right: 58px; top: var(--sheet-top); max-width: calc(100% - 120px); max-height: 40%; }

#piecelabels { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.piecelabel {
  position: absolute;
  left: 0;
  top: 0;
  padding: 1px 5px;
  white-space: nowrap;
  font-size: 9px;
  color: var(--text);
  background: color-mix(in srgb, var(--ink) 75%, transparent);
  border-radius: 3px;
}
html.compact #statpanel, html.sheet #statpanel { font-size: 9px; line-height: 1.35; padding: 5px 8px; }
html.compact #statpanel .tip, html.sheet #statpanel .tip { display: none; }
html.compact #statpanel { max-width: 260px; }

/* Species picker headings: the fold-summary style of a subfold. */
.speccat { margin: 8px 0 3px; color: var(--dim); font-size: 9px; letter-spacing: .16em; text-transform: uppercase; }
.speccat:first-of-type { margin-top: 2px; }

/* --- batch -------------------------------------------------------------------- */
#batchpanel {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: var(--ink);
}
#batchpanel .batchtop { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
#batchpanel .batchhead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 18px; }
#batchpanel .batchhead > * { margin: 0; }
#batchpanel .batchhead > .row, #batchpanel .batchhead > div:not(.btnrow) { min-width: 150px; }
#batchpanel .batchgrid {
  flex: 1;
  overflow: auto;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  align-content: start;
}
#batchpanel .batchgrid > p { grid-column: 1 / -1; }
.batchcard {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}
.batchcard.off { opacity: 0.45; }
.batchcard .batchimg {
  aspect-ratio: 240 / 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1013;
  border-radius: 3px;
  overflow: hidden;
}
.batchcard .batchimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.batchcard .batchname { margin: 6px 0 0; font-weight: 600; }
.batchcard .tip { margin: 2px 0 6px; }
.batchcard .btnrow button { padding: 5px 4px; }
#batchpanel .batchfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
#batchpanel .batchfoot .btnrow { flex: 0 1 420px; }
html.sheet #batchpanel { position: fixed; z-index: 60; padding-top: var(--sheet-top); }
html.sheet #batchpanel .batchgrid { grid-template-columns: repeat(2, 1fr); }

/* Wind gizmo: the speed at the arrow's tip. */
.windlabel {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
  padding: 1px 5px; font-size: 10px; white-space: nowrap; color: var(--ink);
  background: var(--accent); border-radius: 3px;
}

/* Grass: its own view buttons; no bones, no hand-edit tools. */
html:not(.grass) .vb-grass { display: none !important; }
html.grass #vb-bones, html.grass #tool-draw, html.grass #tool-prune { display: none !important; }
#viewbar button.vbtext { width: auto; min-width: 30px; padding: 0 6px; font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; font-variant-numeric: tabular-nums; }

/* Species buttons: a grid of equal cells, three across; a long name wraps. */
.specgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-bottom: 4px; }
#g-species .specgrid button { width: 100%; height: 34px; margin: 0; padding: 2px 4px; font-size: 11px; line-height: 1.12; white-space: normal; text-align: center; overflow: hidden; }
@media (pointer: coarse) { #g-species .specgrid button { height: 38px; } }
