/*
 * tools.css — the free tools (tools/<id>.js), drawn in Cover Story's paper, ink, gold and red (directions/cover-story.css
 * loads first). Inputs are 16 px so phones never zoom on focus; every control is at least 44 px tall; read-outs are
 * small text with generous space (owner rule). Every class is prefixed tl-.
 */
.tl { display: grid; gap: var(--s-6); }
.tl-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-4) var(--s-5); align-items: end; }
.tl-form[hidden] { display: none; }
.tl-fields { display: contents; }
.tl-field { display: grid; gap: 6px; min-width: 0; }
.tl-field--wide { grid-column: 1 / -1; }
.tl-field > span { font: 500 var(--fs-meta) / 1.35 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.tl-field input, .tl-field select, .tl-field textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 2px;
  background: var(--paper); color: var(--fg); font: 400 16px / 1.4 var(--font-body);
}
/* Safari draws native selects at its own height and ignores min-height: a custom appearance keeps the 44 px target. */
.tl-field select { -webkit-appearance: none; appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.tl-field textarea { min-height: 96px; resize: vertical; font-family: var(--font-mono); font-size: 16px; line-height: 1.5; }
.tl-field input:focus-visible, .tl-field select:focus-visible, .tl-field textarea:focus-visible { outline: 2px solid var(--focus, var(--red)); outline-offset: 1px; border-color: transparent; }
.tl-check { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; min-height: var(--tap); font-size: var(--fs-small); color: var(--muted); cursor: pointer; }
.tl-check input { width: 20px; height: 20px; accent-color: var(--red); flex: none; }

.tl-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tl-tabs button { min-height: var(--tap); padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 999px; background: none; color: var(--muted);
  font: 500 var(--fs-small) / 1 var(--font-ui); cursor: pointer; }
.tl-tabs button[aria-selected='true'] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.tl-out { display: grid; gap: var(--s-4); padding: var(--s-6); background: var(--paper); box-shadow: var(--shadow-paper, 0 1px 2px rgb(0 0 0 / 0.06)); border-top: 2px solid var(--gold); min-width: 0; }
.tl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-5); margin: 0; }
.tl-stats div { display: grid; gap: 4px; }
.tl-stats dt { font-size: var(--fs-meta); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.tl-stats dd { margin: 0; font: 500 var(--fs-h2) / 1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.tl-verdict { font: 500 var(--fs-lead) / 1.4 var(--font-display); color: var(--muted); }
.tl-verdict.is-yes { color: var(--fg); }
.tl-verdict.is-yes::before { content: '● '; color: var(--red); }
.tl-note { font-size: var(--fs-small); line-height: 1.65; color: var(--muted); max-width: 72ch; }
.tl-warn { margin: 0; padding-left: 1.1em; font-size: var(--fs-small); color: var(--red); display: grid; gap: 4px; }
p.tl-warn { padding-left: 0; }
.tl-tips { margin: 0; padding-left: 1.1em; font-size: var(--fs-small); color: var(--muted); display: grid; gap: 4px; }
.tl-code-label { font-size: var(--fs-meta); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tl-code-label b { color: var(--fg); text-transform: none; letter-spacing: 0; }
.tl-code { margin: 0; padding: var(--s-4); max-height: 360px; overflow: auto; background: var(--bg); border: 1px solid var(--line);
  font: 400 var(--fs-small) / 1.6 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-copy { justify-self: start; min-height: var(--tap); padding: 0 18px; cursor: pointer; }

.tl-bars { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tl-bars li { display: grid; grid-template-columns: minmax(80px, 160px) 1fr auto; gap: 12px; align-items: center; font-size: var(--fs-small); }
.tl-bars__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-bars__track { height: 6px; background: var(--line); }
.tl-bars__track i { display: block; height: 100%; width: var(--w); background: var(--gold); }
.tl-bars__val { font-family: var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.tl-checks { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.tl-checks li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
.tl-checks b { font-weight: 500; font-size: var(--fs-body); }
.tl-checks .is-pass b { color: var(--fg); }
.tl-checks .is-miss b { color: var(--muted); }
.tl-checks span { font-size: var(--fs-small); color: var(--muted); }

@media (max-width: 640px) {
  .tl-form { grid-template-columns: minmax(0, 1fr); }
  .tl-out { padding: var(--s-5) var(--s-4); }
  .tl-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tl-bars li { grid-template-columns: minmax(0, 1fr) auto; }
  .tl-bars__track { grid-column: 1 / -1; grid-row: 2; }
  .tl-copy { width: 100%; }
}
