/* ==========================================================================
   Free browser tools (/free-tools/). Loads after styles.css and pages.css and uses only their
   tokens (design-system/vault/MASTER.md). Every tool runs in the visitor's browser.
   ========================================================================== */

.tool-section { padding-block: 48px 0; }

/* The tool's workspace: the one quiet fill on the page, square like everything else. */
.tool-panel {
  display: grid;
  gap: 20px;
  max-width: 860px;
  padding: clamp(20px, 4vw, 36px);
  background: var(--panel);
}

.tool-panel h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(22px, 3vw, 28px);
  letter-spacing: -.025em;
  line-height: 1.15;
}

.tool-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
}

.tool-steps li {
  padding: 4px 10px;
  border-radius: var(--r-capsule);
  background: var(--fill);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tool-steps li[aria-current="step"] { color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }

/* File picker / drop zone. The <label> wraps a visually hidden <input type="file">. */
.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  padding: 28px 20px;
  border-radius: var(--r-group);
  border: 1.5px dashed var(--line);
  background: var(--tile);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}

.drop-zone:hover, .drop-zone.is-over { border-color: var(--text); }
.drop-zone:focus-within { outline: 2px solid var(--text); outline-offset: 3px; }
.drop-zone svg { width: 32px; height: 32px; color: var(--muted); }
.drop-zone-title { font-size: 17px; font-weight: 600; }
.drop-zone-hint { font-size: 13px; color: var(--muted); }

.visually-hidden, .drop-zone input[type="file"] {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Form controls */
.tool-fields { display: grid; gap: 14px; }

.tool-field { display: grid; gap: 6px; }
.tool-field > label, .tool-field > .tool-label { font-size: 14px; font-weight: 600; }
.tool-field small, .tool-help { font-size: 13px; color: var(--muted); }

.tool-input, .tool-select, .tool-textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--r-chip);
  background: var(--tile);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  box-shadow: inset 0 0 0 1px var(--line);
}

.tool-textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.tool-input.is-mono, .tool-textarea.is-mono { font-family: var(--font-mono); font-size: 15px; }
.tool-input:focus, .tool-select:focus, .tool-textarea:focus { outline: 2px solid var(--text); outline-offset: 2px; }

.tool-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.tool-row > .tool-field { flex: 1 1 180px; }

.tool-check { display: inline-flex; gap: 8px; align-items: center; font-size: 15px; cursor: pointer; }
.tool-check input { width: 18px; height: 18px; accent-color: var(--text); }

.tool-range { width: 100%; accent-color: var(--text); }

.tool-segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-capsule);
  background: var(--tile);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tool-segmented button {
  min-height: 36px;
  padding: 6px 14px;
  border: 0;
  border-radius: var(--r-capsule);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.tool-segmented button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }

.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Results */
.tool-output {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-group);
  background: var(--tile);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tool-output[hidden] { display: none; }

.tool-result-big {
  font-family: var(--font-mono);
  font-size: clamp(17px, 3.4vw, 22px);
  line-height: 1.4;
  word-break: break-all;
}

.tool-status { font-size: 15px; color: var(--text-2); min-height: 1.4em; }
.tool-status.is-ok { color: var(--ok); }
.tool-status.is-error { color: var(--safelight-text); }

.tool-privacy {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--muted);
}

.tool-privacy svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--ok); }

.tool-preview {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 60vh;
  border-radius: var(--r-chip);
  background: var(--stage-1);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tool-canvas-wrap { position: relative; overflow: auto; border-radius: var(--r-chip); }
.tool-canvas-wrap canvas { display: block; max-width: 100%; height: auto; touch-action: none; cursor: crosshair; }

/* Key/value list (metadata, results) */
.tool-kv { display: grid; gap: 0; margin: 0; font-size: 15px; }
.tool-kv > div {
  display: grid;
  grid-template-columns: minmax(110px, 38%) 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: .5px solid var(--line);
}
.tool-kv > div:last-child { border-bottom: 0; }
.tool-kv dt { color: var(--muted); }
.tool-kv dd { margin: 0; word-break: break-word; }
.tool-kv .is-flag { color: var(--safelight-text); font-weight: 600; }

/* Strength meter */
.tool-meter {
  height: 8px;
  border-radius: var(--r-capsule);
  background: var(--fill);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.tool-meter > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--safelight);
  transition: width .25s var(--ease-out), background .25s var(--ease-out);
}
.tool-meter[data-level="3"] > span, .tool-meter[data-level="4"] > span { background: var(--ok); }
.tool-meter[data-level="2"] > span { background: var(--text-2); }

.tool-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tool-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--r-chip);
  background: var(--fill);
  font-size: 15px;
}

.tool-list .tool-file-name { min-width: 0; overflow-wrap: anywhere; }
.tool-list .tool-file-meta { color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .tool-section { padding-block: 32px 0; }
  .tool-kv > div { grid-template-columns: 1fr; gap: 2px; }
}
