/* =========================================================
   Max's Website — the toolbox: a workbench in the shed,
   each tool a thing sitting on it (art: tools/toolbox_art.py)
   ========================================================= */

:root { --px: 3; --ink: #2a1d14; }
@media (min-width: 1100px) { :root { --px: 4; } }
@media (max-width: 700px) { :root { --px: 2; } }

* { box-sizing: border-box; }
html { overflow-y: scroll; }
[hidden] { display: none !important; }

body.toolbox {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #5c4433 url("assets/sprites/toolbox-wall.png") repeat 0 0 /
    calc(160px * var(--px)) calc(64px * var(--px));
  image-rendering: pixelated;
}

/* ---------- header ---------- */
.tb-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 28px 16px 10px;
}
.back-sign {
  padding: 6px 16px;
  font: 700 14px "Trebuchet MS", sans-serif;
  color: var(--ink);
  text-decoration: none;
  background: #e8dcb9;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.back-sign:hover { background: #fbf3de; }
.back-sign:active { transform: translate(3px, 3px); box-shadow: none; }
.back-sign:focus-visible, .tb-item:focus-visible { outline: 3px solid #9cd2ff; outline-offset: 4px; }

/* the same burnt-in plank sign as the projects workshop */
.tb-sign {
  display: grid;
  place-items: center;
  width: calc(120px * var(--px));
  height: calc(28px * var(--px));
  margin: 0;
  font: 700 calc(11px * var(--px)) "Courier New", Courier, monospace;
  letter-spacing: calc(1.5px * var(--px));
  text-transform: uppercase;
  color: #3a2210;
  text-shadow: 0 2px 0 #d79a58;
  background: url("assets/sprites/workshop-sign.png") no-repeat 0 0 / 100% 100%;
  filter: drop-shadow(calc(2px * var(--px)) calc(3px * var(--px)) 0 rgba(0, 0, 0, 0.4));
}

/* a note pinned to the wall */
.tb-note {
  max-width: 460px;
  margin: 4px 0 0;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  background: #fbf3de;
  border: 3px solid var(--ink);
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.35);
  transform: rotate(-1deg);
}

/* ---------- the bench ---------- */
.bench {
  margin-top: auto;
  padding-top: 40px;
}
.bench-items {
  display: flex;
  flex-wrap: wrap;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 0;
  list-style: none;
}
/* each tool brings its own stretch of plank, so a row of them makes one long bench top / shelf */
.bench-items li {
  flex: 1 1 230px;
  display: flex;
  flex-direction: column;
}
.tb-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}
.obj {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: calc(40px * var(--px));
  padding-top: 14px;
}
.obj img {
  display: block;
  width: calc(var(--w) * 1px * var(--px));
  height: auto;
  margin-bottom: calc(-1px * var(--px));          /* sits on the plank, not above it */
  filter: drop-shadow(calc(2px * var(--px)) 0 0 rgba(0, 0, 0, 0.22));
  transition: transform 0.15s;
}
.tb-item::after {
  content: "";
  order: 1;
  align-self: stretch;
  height: calc(10px * var(--px));
  background: url("assets/sprites/toolbox-plank.png") repeat-x 0 0 / calc(64px * var(--px)) 100%;
}
.tag {
  order: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 200px;
  margin: 8px 10px 26px;
  padding: 5px 10px 6px;
  text-align: center;
  background: #fbf3de;
  border: 3px solid var(--ink);
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.3);
  transform: rotate(var(--tilt, -1.5deg));
  transition: transform 0.15s, background 0.15s;
}
.bench-items li:nth-child(3n + 2) .tag { --tilt: 1.2deg; }
.bench-items li:nth-child(3n) .tag { --tilt: -0.4deg; }
.tag b { font-size: 15px; }
.tag small { font-size: 12px; color: #5b4a3a; }

.tb-item:hover .obj img, .tb-item:focus-visible .obj img { transform: translateY(calc(-3px * var(--px))) rotate(-2deg); }
.tb-item:hover .tag, .tb-item:focus-visible .tag { transform: rotate(0deg); background: #fff3b8; }
.tb-item:active .obj img { transform: translateY(calc(-1px * var(--px))); }

/* the front of the workbench: drawers, legs, floor */
.apron {
  position: relative;
  height: calc(48px * var(--px));
  background: url("assets/sprites/workshop-bench.png") repeat-x 0 0 / calc(128px * var(--px)) 100%;
}
.apron img {                                     /* a coffee mug left on the bench */
  position: absolute;
  left: 14%;
  bottom: calc(100% - 4px * var(--px));
  width: calc(11px * var(--px));
}

@media (max-width: 520px) {
  .bench-items li { flex-basis: 150px; }
  .tag { margin: 6px 4px 20px; padding: 4px 6px; }
  .tag b { font-size: 13px; }
  .tag small { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .obj img, .tag { transition: none; }
}
