/* =========================================================
   Max's Website — one tool from the toolbox
   A sheet of paper clipped to the shed wall, same as the
   workbench room (toolbox.css). Stands alone: no style.css.
   ========================================================= */

:root {
  --px: 3;
  --ink: #2a1d14;
  --paper: #fbf3de;
  --paper-2: #f1e6c6;
  --line: #e2d5b0;
  --accent: #3f8fd6;
  --good: #2f7a2e;
  --warn: #b5651d;
  --bad: #b02c1e;
}
@media (max-width: 700px) { :root { --px: 2; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { overflow-y: scroll; }
body.tool-page {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #5a4636 url("../assets/sprites/toolbox-wall.png") repeat 0 0 /
    calc(160px * var(--px)) calc(64px * var(--px));
  image-rendering: pixelated;
}

/* ---------- header: back sign + the tool's name ---------- */
.tool-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 26px 16px 0;
}
.back-sign, .btn {
  display: inline-block;
  padding: 6px 14px;
  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);
  cursor: pointer;
}
.back-sign:hover, .btn:hover { background: #fff8e6; }
.back-sign:active, .btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 var(--ink); }
.btn.go { background: #f2c94c; }
.btn.go:hover { background: #ffe28a; }
.btn.small { padding: 3px 9px; font-size: 12px; box-shadow: 2px 2px 0 var(--ink); }

.tool-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 8px 20px;
  font: 700 clamp(20px, 4vw, 28px) "Courier New", Courier, monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #3a2210;
  background: #c08549;
  border: 4px solid var(--ink);
  box-shadow: inset 0 3px 0 #d79a58, inset 0 -4px 0 #7a4a22, 5px 6px 0 rgba(0, 0, 0, 0.35);
}
.tool-title img { width: calc(20px * var(--px)); height: auto; }

/* ---------- the sheet ---------- */
.sheet {
  position: relative;
  width: min(880px, calc(100% - 24px));
  margin: 34px auto 60px;
  padding: 34px clamp(16px, 4vw, 36px) 26px;
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 8px 10px 0 rgba(0, 0, 0, 0.35);
  image-rendering: auto;
}
/* a bulldog clip holding it to the wall */
.sheet::before {
  content: "";
  position: absolute;
  top: -16px;
  left: 50%;
  width: 90px;
  height: 26px;
  transform: translateX(-50%);
  background: linear-gradient(#cfd6dc 0 40%, #8f989f 40% 100%);
  border: 3px solid var(--ink);
  border-radius: 4px 4px 0 0;
}
.lede { margin: 0 0 18px; font-size: 15px; line-height: 1.5; }
.sheet h2 {
  margin: 26px 0 10px;
  font: 700 17px "Trebuchet MS", sans-serif;
  border-bottom: 3px solid var(--line);
}
.sheet h2:first-of-type { margin-top: 6px; }

/* the "nothing leaves your computer" note at the bottom of each sheet */
.privacy {
  margin: 26px 0 0;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  background: #e3efd8;
  border: 2px dashed var(--good);
}
.privacy b { color: var(--good); }

/* ---------- form bits ---------- */
label { font-weight: 700; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field small, .hint { font-weight: 400; font-size: 12px; color: #6b5a48; }
.row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin: 10px 0; }
.row > .grow { flex: 1 1 220px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

input[type="text"], input[type="number"], input[type="password"], input[type="url"],
input[type="datetime-local"], input[type="search"], select, textarea {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  font: 15px Consolas, "Courier New", monospace;
  color: var(--ink);
  background: #fffdf6;
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: inset 2px 2px 0 var(--paper-2);
}
select { font-family: "Trebuchet MS", sans-serif; cursor: pointer; }
textarea { resize: vertical; min-height: 90px; line-height: 1.4; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible,
.back-sign:focus-visible, .tabs button:focus-visible, .drop:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
input[type="color"] {
  width: 54px;
  height: 40px;
  padding: 2px;
  background: #fffdf6;
  border: 3px solid var(--ink);
  cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: #c08549; }
input[type="checkbox"], input[type="radio"] { accent-color: #c08549; width: 16px; height: 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 14px; cursor: pointer; }
.out { background: #f6f0dc; }
.mono { font-family: Consolas, "Courier New", monospace; }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.tabs button {
  padding: 5px 12px;
  font: 700 13px "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: var(--paper-2);
  border: 3px solid var(--ink);
  cursor: pointer;
}
.tabs button[aria-pressed="true"], .tabs button[aria-selected="true"] { background: #f2c94c; box-shadow: inset 0 -3px 0 #c2962a; }

/* ---------- dropping files ---------- */
.drop {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 130px;
  padding: 18px;
  text-align: center;
  font-size: 15px;
  background: repeating-linear-gradient(-45deg, #fffaea 0 10px, #f8efd4 10px 20px);
  border: 3px dashed var(--ink);
  cursor: pointer;
}
.drop.over { background: #fff1b8; border-style: solid; }
.drop b { font-size: 17px; }
.drop input { display: none; }

/* ---------- results ---------- */
.status { min-height: 1.3em; margin: 8px 0; font-size: 14px; }
.status.bad { color: var(--bad); font-weight: 700; }
.status.good { color: var(--good); font-weight: 700; }
.chip { display: inline-block; padding: 1px 7px; font: 700 12px "Trebuchet MS", sans-serif; border: 2px solid var(--ink); background: #fff; }
table.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
table.kv th, table.kv td { padding: 6px 8px; text-align: left; border-bottom: 2px solid var(--line); vertical-align: top; }
table.kv th { width: 34%; font-weight: 700; white-space: nowrap; }
table.kv td { font-family: Consolas, "Courier New", monospace; overflow-wrap: anywhere; }
table.kv td .btn { margin-left: 6px; font-family: "Trebuchet MS", sans-serif; }

/* a checkered backdrop, so transparent pictures look transparent */
.checker {
  background: repeating-conic-gradient(#e6dcc0 0 25%, #fffaea 0 50%) 0 0 / 16px 16px;
  border: 3px solid var(--ink);
}

.footer-note { margin: 0 auto 40px; width: min(880px, calc(100% - 24px)); text-align: center; font-size: 12px; color: #f1e6c6; }

@media (max-width: 520px) {
  .sheet { padding-top: 30px; }
  table.kv th, table.kv td { display: block; width: auto; white-space: normal; }
  table.kv th { padding-bottom: 0; border-bottom: 0; }
}

/* =========================================================
   per-tool bits
   ========================================================= */

/* ---- QR ---- */
.qr-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 26px; align-items: start; }
.qr-out { margin: 0; position: sticky; top: 12px; }
.qr-frame { display: grid; place-items: center; aspect-ratio: 1; padding: 10px; }
.qr-frame canvas { width: 100%; height: auto; image-rendering: pixelated; }
.qr-buttons { justify-content: center; }
.qr-out .status { font-size: 13px; text-align: center; }
@media (max-width: 720px) {
  .qr-layout { grid-template-columns: 1fr; }
  .qr-out { position: static; width: min(320px, 100%); margin: 0 auto; grid-row: 1; }
}

/* ---- converter: the list of pictures ---- */
.files { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.file {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  background: #fffaea;
  border: 2px solid var(--ink);
}
.thumb-box { display: grid; place-items: center; width: 78px; height: 78px; border-width: 2px; }
.thumb { max-width: 72px; max-height: 72px; }
.file-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
.file-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info small { font-size: 12.5px; color: #5b4a3a; overflow-wrap: anywhere; }
.chip.smaller { background: #d9f0cf; }
.chip.bigger { background: #f8d9cf; }
.bad { color: var(--bad); font-weight: 700; }
@media (max-width: 520px) {
  .file { grid-template-columns: 60px minmax(0, 1fr); }
  .thumb-box { width: 60px; height: 60px; }
  .thumb { max-width: 54px; max-height: 54px; }
  .file .dl { grid-column: 1 / -1; justify-self: start; }
}

/* ---- pixel-art resizer ---- */
.px-preview { display: grid; place-items: center; min-height: 160px; padding: 10px; margin: 12px 0; overflow: auto; }
.px-preview canvas { image-rendering: pixelated; max-width: 100%; height: auto; }

/* ---- encode & hash ---- */
#hashes tr.match th, #hashes tr.match td { background: #d9f0cf; }
.codec-buttons { justify-content: center; }

/* ---- password checker ---- */
.meter { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 14px 0 8px; }
.meter i { height: 14px; background: var(--paper-2); border: 2px solid var(--ink); }
.meter[data-level="0"] i:nth-child(-n+1) { background: #d9534f; }
.meter[data-level="1"] i:nth-child(-n+2) { background: #e8833a; }
.meter[data-level="2"] i:nth-child(-n+3) { background: #f2c94c; }
.meter[data-level="3"] i:nth-child(-n+4) { background: #7cc46b; }
.meter[data-level="4"] i:nth-child(-n+5) { background: #2f9a44; }
.verdict { margin: 0 0 14px; font-size: 15px; }
.parts, .tips { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.parts code { padding: 0 5px; background: #fff; border: 2px solid var(--line); font-size: 14px; }
.parts span { color: #6b5a48; }
.gen-out { font-size: 17px; }
code { font-family: Consolas, "Courier New", monospace; }

/* ---- colour picker ---- */
.colour-top { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: stretch; margin-bottom: 14px; }
.big-swatch {
  display: flex;
  align-items: flex-end;
  min-height: 150px;
  padding: 10px 12px;
  font: 700 15px Georgia, serif;
  border: 3px solid var(--ink);
  box-shadow: 5px 6px 0 rgba(42, 29, 20, 0.25);
}
.small-drop { min-height: 90px; }
.pick-box { margin: 10px 0; text-align: center; }
.pick-box canvas { max-width: 100%; max-height: 420px; cursor: crosshair; border: 3px solid var(--ink); image-rendering: auto; }
.harmony { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px; align-items: center; margin: 6px 0; font-size: 14px; font-weight: 700; }
.sws { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 40px; height: 32px; padding: 0; border: 3px solid var(--ink); cursor: pointer; }
.sw:hover { transform: translateY(-2px); }
.sw:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.contrast-sample { padding: 16px 18px; font-size: 18px; border: 3px solid var(--ink); }
.palette { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 10px; padding: 0; list-style: none; }
.palette li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; font: 12px Consolas, monospace; }
.palette .sw { width: 54px; height: 44px; }
.palette .x {
  position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; padding: 0;
  font: 700 14px/14px "Trebuchet MS", sans-serif; background: #fff; border: 2px solid var(--ink); border-radius: 50%; cursor: pointer;
}
@media (max-width: 600px) {
  .colour-top { grid-template-columns: 1fr; }
  .big-swatch { min-height: 110px; }
  .harmony { grid-template-columns: 1fr; gap: 4px; }
}

/* ---- unit converter ---- */
.unit-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: center; }
.unit-pair .field { gap: 6px; }
.unit-pair input { font-size: 22px; }
.swap { font-size: 20px; padding: 4px 12px; }
@media (max-width: 560px) {
  .unit-pair { grid-template-columns: 1fr; }
  .swap { justify-self: center; transform: rotate(90deg); }
  .swap:active { transform: rotate(90deg) translate(3px, -3px); }
}

/* ---- timestamp converter ---- */
.now {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px; background: #fffaea; border: 3px solid var(--ink);
}
.now span { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: #6b5a48; }
.now b { font: 700 26px Consolas, "Courier New", monospace; margin-right: auto; }

/* ---- YouTube to MP3 ---- */
.progress { height: 18px; margin: 6px 0 12px; background: var(--paper-2); border: 3px solid var(--ink); }
.progress i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(-45deg, #f2c94c 0 8px, #e0a830 8px 16px); transition: width 0.4s; }
