/* The Toolbox (/toolbox): only this page loads it. Without JavaScript the categories are plain sections; with it
   (html.tb-js, set in the head) they are tiles that zoom open to a full-screen panel (web/toolbox.js). */

/* the line drawings (scripts/toolbox_graphics.py): ink follows the theme, the subject takes the accent */
.tbg { display: block; width: 100%; height: auto; color: var(--text); fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.tbg .th { stroke-width: .7; }
.tbg .cl { stroke-dasharray: 9 2.5 1.5 2.5; }
.tbg .hid { stroke-dasharray: 3 2; stroke-width: .9; }
.tbg .a { stroke: var(--accent); }
.tbg .fi { fill: currentColor; stroke: none; }
.tbg .fa { fill: var(--accent); stroke: none; }
.tbg .bgf { fill: var(--panel); }
.tbg .zone { fill: color-mix(in srgb, var(--accent) 22%, transparent); }
.tbg .zone2 { fill: color-mix(in srgb, currentColor 14%, transparent); }
.tbg .hatch1 { fill: url(#tbh-f1); }
.tbg .hatch2 { fill: url(#tbh-f2); }
.tbg .tx { fill: currentColor; stroke: none; font: 600 9px/1 Inter, 'Inter Fallback', system-ui, sans-serif; }
.tbg .tx.sm { font-size: 7px; }
.tbg .tx.big { font-size: 15px; }

.tb-tile { display: grid; gap: 12px; }
.tb-art { max-width: 420px; }
.tb-text h2 { margin: 0 0 4px; font-size: 19px; }
.tb-sub { margin: 0; color: var(--dim-hi); }
.tb-count { margin: 6px 0 0; font-size: 13px; color: var(--accent-text); }
.tb-cat { margin: 0 0 34px; }
.tb-body { margin-top: 16px; }
.tb-jump { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 16px; }
.tb-jump a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--text); text-decoration: none; background: var(--panel2); }
.tb-jump a:hover, .tb-jump a:focus-visible { border-color: var(--accent); }
.tb-tools { list-style: none; padding: 0; margin: 0; }
.tb-card { margin: 0; box-sizing: border-box; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; scroll-margin-top: 12px; }
.tb-card h3 { margin: 0 0 4px; font-size: 17px; }
.tb-line { margin: 0; color: var(--dim-hi); font-size: 14px; }
/* a working tool: full width, the guide's own widget mounted in it */
.tb-live { display: grid; gap: 16px; }
.tb-live .tb-card { padding: 18px 20px 16px; }
.tb-live .gwidget { margin: 14px 0 10px; }
.tb-live .gwidget:has(> :not(noscript)) { min-height: 0; }   /* the guide reserves room for its column; once built, a card is as tall as its tool */
.tb-how { font-size: 14px; color: var(--accent-text); }
/* the 3D tool's picture, until it is asked for */
.tb-poster { all: unset; cursor: pointer; display: block; position: relative; max-width: 720px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.tb-poster img { display: block; width: 100%; height: auto; }
.tb-poster span { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 8px 16px; border-radius: 8px; background: var(--accent); color: var(--on-accent, #06202c); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tb-poster:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tb-w[data-poster] { min-height: 0; }
/* not built yet: compact, after the working tools */
.tb-soon { display: grid; gap: 10px; margin-top: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tb-soon .tb-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.tb-soon h3 { font-size: 15px; }
.tb-soon .tb-line { flex: 1; font-size: 13px; }
.tb-tag { align-self: flex-start; margin-top: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim-hi); font-size: 12px; }

/* ---- with JavaScript: tiles */
.tb-js .tb-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tb-js .tb-cat { margin: 0; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px 18px; }
.tb-js .tb-cat:not(.open):hover, .tb-js .tb-cat:not(.open):focus-within { border-color: var(--accent); }
.tb-js .tb-cat:not(.open) .tb-body { display: none; }
.tb-open { all: unset; cursor: pointer; }
.tb-open::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }   /* the whole tile is the button */
.tb-open:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }
.tb-bar { display: none; }
.tb-ph { visibility: hidden; }

/* open: the tile, fixed where it was, grows to fill the screen (toolbox.js sets the start box and then .full) */
.tb-cat.open { position: fixed; z-index: 70; margin: 0; overflow: auto; overscroll-behavior: contain; box-sizing: border-box; }
.tb-cat.open.anim { transition: top .3s ease, left .3s ease, width .3s ease, height .3s ease, border-radius .3s ease; }
.tb-cat.open.full { top: 0 !important; left: 0 !important; width: 100vw !important; height: 100% !important; border-radius: 0; border: 0; padding: 18px max(18px, calc((100vw - 1040px) / 2)) 40px; }
.tb-cat.open .tb-open::after { display: none; }
.tb-cat.open .tb-open { cursor: default; }
.tb-cat.open .tb-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tb-crumb { all: unset; cursor: pointer; color: var(--accent-text); font-size: 14px; }
.tb-crumb:hover { text-decoration: underline; }
.tb-close { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 0; line-height: 0; padding: 0; cursor: pointer; position: relative; }
.tb-close::before, .tb-close::after { content: ''; position: absolute; left: 50%; top: 50%; width: 14px; height: 2px; margin: -1px 0 0 -7px; background: currentColor; border-radius: 1px; transform: rotate(45deg); }   /* drawn, not typed: the × glyph sits off-centre in every font */
.tb-close::after { transform: rotate(-45deg); }
.tb-close:hover, .tb-close:focus-visible { border-color: var(--accent); }
.tb-cat.full .tb-tile { grid-template-columns: minmax(180px, 300px) 1fr; align-items: center; gap: 20px; }
.tb-cat.full .tb-text h2 { font-size: 24px; }
.tb-cat .tb-body { transition: opacity .2s ease; }
.tb-cat.open:not(.shown) .tb-body { opacity: 0; }
.tb-lock { overflow: hidden; }

@media (max-width: 720px) {
  .tb-js .tb-grid { grid-template-columns: 1fr; }
  .tb-cat.full .tb-tile { grid-template-columns: 120px 1fr; gap: 12px; }
  .tb-cat.full .tb-text h2 { font-size: 19px; }
  .tb-cat.full .tb-sub { font-size: 14px; }
  .tb-cat.full .tb-count { display: none; }
  .tb-soon { grid-template-columns: 1fr; }
  .tb-jump { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }   /* one swipeable row on a phone */
  .tb-jump a { flex: none; }
  .tb-live .tb-card { padding: 14px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .tb-cat.open.anim, .tb-cat .tb-body { transition: none; }
}
