/* Knoll — workbench flat-lay. Identity: knolling (right angles, label-maker
 * tape, warm plywood bench). Space Grotesk headlines, Space Mono labels. */

@font-face { font-family: "Space Grotesk"; font-weight: 400; font-display: swap; src: url("fonts/space-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 500; font-display: swap; src: url("fonts/space-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 700; font-display: swap; src: url("fonts/space-grotesk-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Mono"; font-weight: 400; font-display: swap; src: url("fonts/space-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Mono"; font-weight: 700; font-display: swap; src: url("fonts/space-mono-latin-700-normal.woff2") format("woff2"); }

:root {
  --bench: #ccb289;          /* plywood benchtop */
  --bench-grain: rgba(122, 92, 55, .10);
  --ink: #2b2620;
  --ink-soft: #5d5348;
  --cream: #f3ead9;
  --accent: #c2452d;         /* tool red */
  --tape: #211e1a;           /* label-maker tape */
  --wood-hi: #7a5638;        /* set per-day from app.js */
  --wood-lo: #5a3d26;
  --liner: #3c3f45;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background:
    repeating-linear-gradient(92deg, transparent 0 34px, var(--bench-grain) 34px 36px),
    repeating-linear-gradient(88deg, transparent 0 89px, rgba(122, 92, 55, .07) 89px 92px),
    linear-gradient(180deg, #d4bc95, var(--bench));
  min-height: 100vh;
  padding: 18px 10px 40px;
  touch-action: manipulation;
}

.app { max-width: 560px; margin: 0 auto; }

/* ---------- masthead ---------- */
.mast { text-align: center; margin-bottom: 10px; }
.logo {
  font-weight: 700;
  font-size: clamp(2.2rem, 9vw, 3rem);
  letter-spacing: .04em;
  color: var(--ink);
}
.logo .sq {                    /* the O, knolled into a square */
  display: inline-block;
  width: .58em; height: .58em;
  border: .105em solid var(--accent);
  margin: 0 .03em;
  vertical-align: baseline;
  transform: translateY(.02em);
}
.mast-sub {
  font-family: "Space Mono", monospace;
  font-size: .72rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 2px;
}
.dateline {
  display: flex; justify-content: center; gap: 14px; flex-wrap: wrap;
  font-family: "Space Mono", monospace;
  font-size: .68rem;
  color: var(--ink-soft);
  margin-top: 8px;
}
.materials { color: var(--accent); }
.clue {
  font-size: .88rem;
  color: var(--ink-soft);
  max-width: 42ch;
  margin: 10px auto 0;
  line-height: 1.45;
}
.clue b { color: var(--ink); }

/* ---------- stage: drawer + tray ---------- */
.stage { position: relative; width: 100%; min-height: 300px; }

.drawer-frame {
  position: absolute;
  background: linear-gradient(155deg, var(--wood-hi), var(--wood-lo));
  border-radius: 10px;
  box-shadow:
    0 10px 22px rgba(43, 30, 15, .35),
    inset 0 1px 0 rgba(255, 240, 210, .25);
}
.drawer-frame::after {         /* drawer pull */
  content: "";
  position: absolute;
  left: 50%; top: -7px;
  width: 52px; height: 8px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #d9c9a8, #9a8156);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(43, 30, 15, .4);
}
.liner {
  position: absolute;
  background-color: var(--liner);
  border-radius: 4px;
  box-shadow: inset 0 3px 9px rgba(0, 0, 0, .45);
}

/* drop preview + peek outline — SVG paths traced around the piece's actual
 * cell mask, so bent shapes (scissors, headphones…) preview true to form */
#ghost, #peek-ghost { position: absolute; pointer-events: none; }
#ghost { z-index: 40; }
#peek-ghost { z-index: 5; }
#ghost svg, #peek-ghost svg { display: block; overflow: visible; }
#ghost.ok path { fill: rgba(243, 234, 217, .18); stroke: rgba(243, 234, 217, .8); stroke-width: 2; stroke-dasharray: 6 5; }
#ghost.no path { fill: rgba(194, 69, 45, .25); stroke: rgba(194, 69, 45, .9); stroke-width: 2; stroke-dasharray: 6 5; }
#peek-ghost path { fill: rgba(245, 207, 39, .09); stroke: #f5cf27; stroke-width: 2.5; stroke-dasharray: 7 5; }

/* ---------- pieces ---------- */
.piece {
  position: absolute;
  z-index: 10;
  border-radius: 6px;
  filter: drop-shadow(0 3px 4px rgba(43, 30, 15, .38));
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  pointer-events: none;         /* only the shape's own cells are grabbable… */
}
.piece:focus-visible { outline: 2px dashed var(--accent); outline-offset: 2px; }
.piece .art { position: absolute; top: 0; left: 0; transform-origin: 0 0; pointer-events: none; }
.piece .art svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.piece .hit { pointer-events: auto; cursor: grab; }   /* …via this mask-shaped path */
.piece.dragging .hit { cursor: grabbing; }
.piece.gliding { transition: left .22s ease, top .22s ease; }
.piece.dragging {
  z-index: 60;
  cursor: grabbing;
  filter: drop-shadow(0 10px 12px rgba(43, 30, 15, .45));
  transform: scale(1.05);
  transition: none;
}
.piece.wiggle { animation: wiggle .34s ease; }
@keyframes wiggle {
  20% { transform: translateX(-4px) rotate(-1.4deg); }
  45% { transform: translateX(4px) rotate(1.4deg); }
  70% { transform: translateX(-2px); }
}

/* ---------- HUD ---------- */
.hud { text-align: center; margin-top: 14px; }
.counter { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.tag {
  font-family: "Space Mono", monospace;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--tape);
  color: var(--cream);
  padding: 4px 10px;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(43, 30, 15, .35);
}
.tag--dim { background: #4a443c; }
.hud-btns { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.ctl {
  font-family: "Space Mono", monospace;
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 8px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--cream);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}
.ctl:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.ctl:disabled { opacity: .4; cursor: default; }
.ctl--hint { border-color: var(--accent); color: var(--accent); box-shadow: 0 2px 0 var(--accent); }
.note {
  font-size: .82rem;
  color: var(--ink-soft);
  margin-top: 10px;
  max-width: 44ch;
  margin-inline: auto;
}

/* ---------- result ---------- */
.result {
  margin: 22px auto 0;
  max-width: 420px;
  text-align: center;
  background: var(--cream);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  padding: 18px 16px 20px;
  box-shadow: 4px 4px 0 rgba(43, 38, 32, .8);
}
.result-head {
  font-family: "Space Mono", monospace;
  font-size: .68rem;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.score-line { font-size: 1.5rem; font-weight: 700; margin-top: 6px; }
.score-line b::before { content: "∟ "; color: var(--accent); }
.tier-sub { font-size: .85rem; color: var(--ink-soft); margin-top: 2px; }
.moves-line, .streak-line {
  font-family: "Space Mono", monospace;
  font-size: .74rem;
  color: var(--ink-soft);
  margin-top: 8px;
}
.submit {
  margin-top: 14px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: .95rem;
  padding: 10px 34px;
  background: var(--accent);
  color: var(--cream);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 3px 0 #7e2b1b;
}
.submit:active { transform: translateY(3px); box-shadow: none; }
.copied { font-size: .8rem; color: var(--accent); margin-top: 8px; }
.tomorrow { font-size: .78rem; color: var(--ink-soft); margin-top: 12px; }

body.knolled .drawer-frame { box-shadow: 0 10px 26px rgba(43, 30, 15, .45), 0 0 0 3px rgba(194, 69, 45, .5), inset 0 1px 0 rgba(255, 240, 210, .25); }

/* ---------- footer ---------- */
.foot {
  text-align: center;
  margin-top: 30px;
  font-family: "Space Mono", monospace;
  font-size: .66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  .piece.gliding { transition: none; }
  .piece.wiggle { animation: none; }
}
