/* Play with Type: the sandbox (pwt-sandbox.js). Blue ink on white, like the zine.
   Uses the site's tokens from style.css / home.css when present, with fallbacks so it also stands alone.
   Mount on a block element; it sizes itself (no fixed aspect ratio), so don't put it inside a .tile. */

.pwt-sandbox {
  --sb-ink: #2454ac;
  --sb-pad: 24px;
  --sb-gap: 24px;
  position: relative;
  display: grid;
  row-gap: 20px;
  padding: var(--sb-pad);
  border-radius: var(--t-radius, 8px);
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);   /* white on the page's #fafafa: a hairline edge */
  color: var(--ink, #111);
  font-size: var(--fs-body, .9375rem);
  line-height: 1.4;
}
@media (max-width: 640px) { .pwt-sandbox { --sb-pad: 16px; row-gap: 16px; } }

/* grid beside the ruler (wide), or the ruler under the grid (narrow) */
.sb-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .32fr); column-gap: var(--sb-gap); align-items: start; }
.pwt-sandbox.is-narrow .sb-main { grid-template-columns: minmax(0, 1fr); row-gap: 16px; }

.sb-board-wrap { position: relative; }
.sb-board, .sb-tray { display: block; width: 100%; height: auto; overflow: visible; }
.sb-board { aspect-ratio: var(--sb-ratio, 44 / 31); touch-action: manipulation; }   /* 44 x 31 wide, 24 x 31 narrow: two lines of letters */
.sb-tray { touch-action: manipulation; }

.sb-grid { stroke-width: var(--hair, .05); stroke-opacity: .7; }   /* Dan's Hraj! grid is 0.227 pt: kept light */
.sb-ghost { display: none; fill-opacity: .16; pointer-events: none; }
.sb-ghost path { transform-box: view-box; transform-origin: 0 0; }

/* modules on the grid */
.sb-pc { cursor: grab; outline: none; touch-action: none; -webkit-tap-highlight-color: transparent;
  transform-box: view-box; transform-origin: 0 0;
  transition: transform .16s cubic-bezier(.2, 0, 0, 1), opacity .15s ease-out; }
.pwt-sandbox.is-dragging .sb-pc { cursor: grabbing; }
.sb-pc.is-lifted { opacity: .2; }
.sb-hit { fill: transparent; }
.sb-sel { stroke: var(--sb-ink); stroke-width: var(--line, .08); opacity: 0; pointer-events: none; transition: opacity .12s ease-out; }
.sb-pc.is-instant { transition: none; }   /* batched moves that must not animate (pwt-sandbox.js jump) */
/* one selected module: its frame is drawn above everything, so the DOM (and Tab) order never has to change */
.sb-one { display: none; fill: none; stroke: var(--sb-ink); stroke-width: var(--line, .08); pointer-events: none;
  transform-box: view-box; transform-origin: 0 0; transition: transform .16s cubic-bezier(.2, 0, 0, 1); }
.sb-one.is-lifted { opacity: 0; }

/* a letter from the zine is a group: any of its parts grabs the whole letter. Its box (dashed) shows on hover,
   fully when the letter is selected, and faintly while it is open for editing its parts. */
.sb-grp { cursor: grab; outline: none; -webkit-tap-highlight-color: transparent; }
.pwt-sandbox.is-dragging .sb-grp { cursor: grabbing; }
.sb-grp-box { fill: transparent; stroke: var(--sb-ink); stroke-width: var(--line, .08); stroke-dasharray: .5 .5; opacity: 0; transition: opacity .12s ease-out; }
.sb-grp.is-hover .sb-grp-box { opacity: .5; }
.sb-grp.is-open .sb-grp-box { opacity: .4; }
.sb-grp.is-sel .sb-grp-box { opacity: 1; }
.sb-grp.is-lifted .sb-grp-box { opacity: 0; }

/* a multi-selection: one shared dashed box; each member shows its own frame faintly */
.sb-msel { display: none; fill: none; stroke: var(--sb-ink); stroke-width: var(--line, .08); stroke-dasharray: .5 .5; pointer-events: none; }
.sb-msel.is-lifted { opacity: 0; }
.sb-pc.is-in .sb-sel { opacity: .45; }
.sb-grp.is-in .sb-grp-box { opacity: .45; }
/* the marquee, while it is drawn (mouse and pen only: on touch, empty grid scrolls the page) */
.sb-marq { display: none; fill: var(--sb-ink); fill-opacity: .05; stroke: var(--sb-ink); stroke-width: var(--line, .08); stroke-dasharray: .3 .3; pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .sb-grp:hover .sb-grp-box { opacity: .5; } .sb-grp.is-sel:hover .sb-grp-box { opacity: 1; } }

/* the ruler */
.sb-ruler { stroke-width: var(--line, .12); }
.sb-mod { cursor: grab; outline: none; touch-action: none; -webkit-tap-highlight-color: transparent; }
.sb-mod path { transition: opacity .15s ease-out; }
.sb-mod .sb-sel { stroke-width: var(--line, .12); }
.sb-mod:focus-visible .sb-sel { opacity: 1; }
@media (hover: hover) and (pointer: fine) { .sb-mod:hover path { opacity: .72; } }

.sb-empty {
  position: absolute; inset: 0; margin: 0;
  display: grid; place-items: center; padding: 16px;
  color: var(--muted, #737373); font-size: var(--fs-small, .8125rem); text-align: center; text-wrap: balance;
  pointer-events: none;
}
.sb-empty[hidden] { display: none; }
.sb-empty > span { background: #fff; padding: 2px 6px; border-radius: 4px; }
.sb-empty-narrow, .pwt-sandbox.is-narrow .sb-empty-wide { display: none; }
.pwt-sandbox.is-narrow .sb-empty-narrow { display: inline; }

/* one line of hints under the grid; the touch version on coarse pointers */
.sb-hint { margin: -8px 0 0; color: var(--muted, #737373); font-size: var(--fs-small, .8125rem); line-height: 1.4; text-wrap: balance; }
.sb-hint-touch { display: none; }
@media (pointer: coarse) { .sb-hint-fine { display: none; } .sb-hint-touch { display: inline; } }

/* tools */
.sb-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; }
.sb-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.sb-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sb-label { color: var(--muted, #737373); font-size: var(--fs-small, .8125rem); }
.sb-preset-list { display: flex; flex-wrap: wrap; gap: 4px; }

.sb-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: var(--pill-h, 36px); padding: 0 12px;
  border: 0; border-radius: var(--r, 8px);
  background: var(--pill-light, #ececec); color: var(--ink, #111);
  font: inherit; font-feature-settings: var(--font-features, normal); line-height: 1; white-space: nowrap;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease-out, opacity .15s ease-out, scale .15s ease-out;
}
.sb-btn kbd { font: inherit; font-size: var(--fs-small, .8125rem); color: var(--muted, #737373); }
.sb-btn:disabled { opacity: .4; cursor: default; }
.sb-btn[hidden] { display: none; }   /* Edit parts, Group, Ungroup show only when they apply */
.sb-btn:not(:disabled):active { scale: .96; }
.sb-btn:focus-visible { outline: none; box-shadow: var(--focus, 0 0 0 2px #fff, 0 0 0 4px #111); }
.sb-btn-quiet { background: transparent; box-shadow: inset 0 0 0 1px #e0e0e0; }
.sb-btn[aria-pressed="true"] { background: var(--pill-dark, #222); color: #fff; }   /* Edit parts, on: the label reads Done */
@media (hover: hover) and (pointer: fine) {
  .sb-btn:not(:disabled):hover { background: var(--pill-light-hover, #e0e0e0); }
  .sb-btn[aria-pressed="true"]:hover { background: var(--pill-dark-hover, #383838); }
  .sb-btn-quiet:not(:disabled):hover { background: #f4f4f4; }
}
@media (hover: none), (pointer: coarse) { .sb-btn kbd { display: none; } }

.sb-letter { width: 40px; padding: 4px; justify-content: center; background: #f4f4f4; }
.sb-letter svg { display: block; width: 100%; height: 100%; }
@media (pointer: coarse) { .sb-letter { width: 44px; height: 44px; } }
/* no room for that letter: a short shake (the status line says why) */
.sb-letter.is-nope { animation: sb-nope .32s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes sb-nope { 20%, 60% { translate: -3px 0; } 40%, 80% { translate: 3px 0; } }

.sb-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* the module in the hand: above the page, at the grid's scale; faint once it is off the grid (let go = removed) */
.pwt-sandbox-float { position: fixed; inset: 0; z-index: 60; display: none; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.pwt-sandbox-float g { transform-box: view-box; transform-origin: 0 0; }
.pwt-sandbox-float path { transform-box: view-box; transform-origin: 0 0; opacity: .9; transition: opacity .12s ease-out; }
.pwt-sandbox-float.is-out path { opacity: .3; }

@media (prefers-reduced-motion: reduce) {
  .sb-pc, .sb-sel, .sb-one, .sb-grp-box, .sb-btn, .pwt-sandbox-float path { transition: none; }
  .sb-letter.is-nope { animation: none; }
}
