/* Free tools (/tools/*). Builds on the tokens and components in /styles.css. */

/* ---------- hero: dark band over a faint ledger grid ---------- */
.tool-hero { position: relative; overflow: clip; padding-block: clamp(1.75rem, 5vw, 3.25rem) clamp(2.5rem, 6vw, 4rem); }
.tool-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, rgb(255 255 255 / .05) 1px, transparent 1px) 0 0 / 7.5rem 100%,
    linear-gradient(to bottom, rgb(255 255 255 / .05) 1px, transparent 1px) 0 0 / 100% 2.25rem;
  -webkit-mask-image: linear-gradient(105deg, transparent 35%, #000 85%);
  mask-image: linear-gradient(105deg, transparent 35%, #000 85%);
}
.tool-hero::after { content: ""; position: absolute; inset: auto -10% -60% 45%; height: 120%; background: radial-gradient(closest-side, rgb(94 224 168 / .14), transparent); pointer-events: none; }
.tool-hero .wrap { position: relative; z-index: 1; }
.tool-hero h1 { max-width: 20ch; margin-bottom: 1.1rem; }
.tool-hero h1 { font-size: clamp(2rem, 1.2rem + 3.4vw, 3.6rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; text-wrap: balance; }
.tool-hero .lede { max-width: 40rem; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .5rem; margin-bottom: 1rem; font-size: .88rem; color: var(--band-ink-3); }
.crumbs a { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--band-ink-2); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--accent); }
.tool-facts { list-style: none; display: flex; flex-wrap: wrap; gap: .45rem; margin: 1.5rem 0 0; padding: 0; }
.tool-facts li { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .8rem; border: 1px solid var(--band-line); border-radius: 999px; background: rgb(255 255 255 / .03); color: var(--band-ink-2); font-size: .82rem; font-weight: 600; }
.tool-facts li::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: var(--accent); }

/* ---------- workbench ---------- */
.tool { padding-top: clamp(2rem, 5vw, 3rem); }
.panel { padding: clamp(1.1rem, 3vw, 1.75rem); min-width: 0; }
.panel + .panel, .panel + .results, .results > * + * { margin-top: 1rem; }
.panel-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1.1rem; }
.panel-head > div { min-width: 0; }
.panel-title { display: flex; align-items: center; gap: .65rem; margin: 0; font: 700 clamp(1.2rem, 1.05rem + .6vw, 1.45rem)/1.15 var(--font-display); letter-spacing: -0.03em; }
.panel-title .no { flex: none; display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); font: 800 .85rem/1 var(--font-display); letter-spacing: 0; }
.panel-head p { margin: .35rem 0 0; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }

/* ---------- fields ---------- */
.fields { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.flabel { font-size: .8rem; font-weight: 700; color: var(--ink-2); line-height: 1.3; }
.input {
  width: 100%; min-height: 2.75rem; padding: .55rem .8rem;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font: 500 1rem/1.2 var(--font-sans); font-variant-numeric: tabular-nums;
  transition: border-color .15s, background-color .15s;
}
.input.num { text-align: right; }
.input:hover { border-color: var(--ink-3); }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; border-radius: 12px; }
.input[aria-invalid="true"] { border-color: var(--neg); background: color-mix(in srgb, var(--neg) 7%, var(--card)); }
textarea.input { min-height: 7.5rem; resize: vertical; font: 500 .88rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
input[type="date"].input { min-width: 0; }
.select { position: relative; display: block; }
.select select { appearance: none; -webkit-appearance: none; padding-right: 2.2rem; cursor: pointer; }
.select::after { content: ""; position: absolute; right: .95rem; top: 50%; width: .45rem; height: .45rem; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.hint { margin: 0; font-size: .8rem; line-height: 1.4; color: var(--ink-3); }
.err { margin: 0; font-size: .82rem; line-height: 1.4; font-weight: 600; color: var(--neg); }
.err:empty, .warn:empty { display: none; }
.tool [hidden] { display: none !important; }
.paste > summary { list-style: none; }
.paste > summary::-webkit-details-marker { display: none; }
.warn { margin: 0; font-size: .82rem; line-height: 1.4; font-weight: 600; color: var(--elim); }

/* ---------- row editor ----------
   Rows are cards of labelled fields. A container query turns them into table-like rows
   when there's room; labels then show on the first row only (still read by screen readers). */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; container-type: inline-size; }
.erow { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem .75rem; padding: .9rem; border: 1px solid var(--line); border-radius: 16px; background: var(--card-2); }
.erow .f-wide { grid-column: 1 / -1; }
.erow .f-wide:first-child { padding-right: 3.25rem; }
.erow .rm { position: absolute; top: .55rem; right: .55rem; }
.erow > .row-msg { grid-column: 1 / -1; display: grid; gap: .2rem; }
.erow.is-bad { border-color: color-mix(in srgb, var(--neg) 45%, var(--line)); }
.rm { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink-3); cursor: pointer; font: 500 1.3rem/1 var(--font-sans); }
.rm:hover { color: var(--neg); border-color: var(--neg); }
.rm:disabled { opacity: .4; cursor: not-allowed; }

@container (min-width: 760px) {
  .rows:not(.rows-xl) .erow { grid-template-columns: var(--cols); align-items: end; padding: .55rem .6rem; }
  .rows:not(.rows-xl) .erow .f-wide { grid-column: auto; }
  .rows:not(.rows-xl) .erow .f-wide:first-child { padding-right: 0; }
  .rows:not(.rows-xl) .erow .rm { position: static; }
  .rows:not(.rows-xl) .erow:not(:first-child) .flabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@container (min-width: 980px) {
  .rows-xl .erow { grid-template-columns: var(--cols); align-items: end; padding: .55rem .6rem; }
  .rows-xl .erow .f-wide { grid-column: auto; }
  .rows-xl .erow .f-wide:first-child { padding-right: 0; }
  .rows-xl .erow .rm { position: static; }
  .rows-xl .erow:not(:first-child) .flabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.actions .spacer { flex: 1; }
.btn-plus::before { content: "+"; font-size: 1.15rem; font-weight: 500; margin-right: -.1rem; }
.btn-dl::before { content: ""; width: .8rem; height: .8rem; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5v9m-4-4 4 4 4-4M2 14.5h12' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5v9m-4-4 4 4 4-4M2 14.5h12' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }
@media (max-width: 479.98px) { .actions .btn { flex: 1 1 auto; } .actions .spacer { display: none; } }

/* ---------- results ---------- */
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.5rem), 1fr)); }
.stat { margin: 0; padding: 1.1rem 1.2rem; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); min-width: 0; }
.stat dt { margin: 0 0 .4rem; font-size: .8rem; font-weight: 600; color: var(--ink-3); }
.stat dd { margin: 0; }
.stat .v { display: block; font: 800 clamp(1.55rem, 1.15rem + 1.5vw, 2.15rem)/1.05 var(--font-display); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .s { display: block; margin-top: .4rem; font-size: .82rem; color: var(--ink-3); }
.stat.is-dark { background: #111; color: #fff; }
.stat.is-dark dt, .stat.is-dark .s { color: #b9b9b3; }
.stat.is-dark .v { color: var(--accent); }
.stat.is-bad .v { color: var(--neg); }
.stat.is-ok .v { color: var(--accent-strong); }
:root[data-theme="dark"] .stat.is-dark { box-shadow: inset 0 0 0 1px #2f5c48; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stat.is-dark { box-shadow: inset 0 0 0 1px #2f5c48; } }

.live { margin: 0; padding: .75rem 1rem; border-radius: 14px; background: var(--accent-soft); color: var(--ink); font-weight: 600; font-size: .92rem; }
.live.is-bad { background: var(--elim-soft); color: var(--elim); }

/* data tables scroll inside their wrapper, never the page */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.table-wrap:focus-visible { outline-offset: 2px; }
.dtable { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.dtable caption { text-align: left; }
.dtable th, .dtable td { padding: .62rem .85rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.dtable th:first-child, .dtable td:first-child, .dtable .l { text-align: left; }
.dtable thead th { background: var(--card-2); font-size: .74rem; font-weight: 700; color: var(--ink-3); vertical-align: bottom; }
.dtable tbody th { font-weight: 600; }
.dtable tbody th.l, .dtable tfoot th.l { white-space: normal; min-width: 8rem; }
@media (max-width: 559.98px) { .dtable th, .dtable td { padding: .55rem .6rem; } .dtable .wrap-cell { min-width: 9rem; } }
.dtable tbody tr:last-child > * { border-bottom: 0; }
.dtable .neg { color: var(--neg); }
.dtable .dim { color: var(--ink-3); }
.dtable tr.is-low > * { background: var(--accent-soft); }
.dtable tr.is-below td.closing { color: var(--neg); font-weight: 700; }
.dtable tfoot > tr > * { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 700; }
.dtable tr.total > * { font-weight: 700; background: var(--card-2); }
.dtable tr.grand > * { background: #111; color: #fff; font-weight: 700; }
.dtable tr.grand td:last-child { color: var(--accent); }
.dtable .wrap-cell { white-space: normal; min-width: 12rem; }
.tag-mark { display: inline-block; margin-left: .4rem; padding: .1rem .45rem; border-radius: 999px; font-size: .68rem; font-weight: 700; vertical-align: .1em; background: var(--card); color: var(--accent-strong); border: 1px solid currentColor; }

.status { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.status.ok { background: var(--accent-soft); color: var(--accent-strong); }
.status.gap { background: var(--elim-soft); color: var(--elim); }
.status.one { background: color-mix(in srgb, var(--neg) 12%, var(--card)); color: var(--neg); }

.block-title { margin: 0 0 .75rem; font: 700 1.1rem/1.2 var(--font-display); letter-spacing: -0.02em; }
.block-title + .hint { margin: -.4rem 0 .75rem; }

/* chart */
.chart-card { padding: clamp(1rem, 3vw, 1.5rem); }
.chart-box { position: relative; width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-box text { fill: var(--ink-3); font: 600 11px/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.chart-box .grid { stroke: var(--line); stroke-width: 1; }
.chart-box .area { fill: var(--accent); opacity: .16; }
.chart-box .line { fill: none; stroke: var(--ink); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart-box .pt { fill: var(--card); stroke: var(--ink); stroke-width: 1.75; }
.chart-box .min { stroke: var(--neg); stroke-width: 1.5; stroke-dasharray: 6 5; }
.chart-box text.min-label { fill: var(--neg); font-weight: 700; }
.chart-box .low { fill: var(--accent-strong); stroke: var(--card); stroke-width: 3; }
.chart-box text.low-label { fill: var(--ink); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin: .75rem 0 0; padding: 0; list-style: none; font-size: .8rem; color: var(--ink-3); font-weight: 600; }
.legend li { display: inline-flex; align-items: center; gap: .45rem; }
.legend i { width: 1.1rem; height: 0; border-top: 2.5px solid var(--ink); }
.legend i.min { border-top: 2px dashed var(--neg); }
.legend i.low { width: .65rem; height: .65rem; border: 0; border-radius: 50%; background: var(--accent-strong); }

/* translation steps */
.steps-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; counter-reset: step; }
.tstep { min-width: 0; counter-increment: step; padding: clamp(1rem, 3vw, 1.5rem); }
.tstep h3 { display: flex; align-items: center; gap: .65rem; margin: 0 0 .5rem; font-size: 1.2rem; font-weight: 800; letter-spacing: -0.03em; }
.tstep h3::before { content: counter(step); flex: none; display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 10px; background: #111; color: var(--accent); font: 800 .85rem/1 var(--font-display); }
:root[data-theme="dark"] .tstep h3::before { background: var(--accent); color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tstep h3::before { background: var(--accent); color: var(--accent-ink); } }
.tstep > p { color: var(--ink-2); max-width: 46rem; }
.formula { margin: .75rem 0 0; padding: .7rem .9rem; border-radius: 12px; background: var(--card-2); font-size: .88rem; color: var(--ink-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.formula b { color: var(--ink); }

/* one-sided list */
.one-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.one-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; padding: .75rem 1rem; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: .92rem; }
.one-list b { font-variant-numeric: tabular-nums; }

/* ---------- method + what Halfkit automates ---------- */
.method { display: grid; gap: 1.5rem; }
@media (min-width: 960px) { .method { grid-template-columns: 1.15fr 1fr; gap: 3.5rem; align-items: start; } }
.method h2 { margin-bottom: 1rem; }
.method .prose p, .method .prose li { color: var(--ink-2); }
.method .prose ol { margin: 0 0 1rem; padding-left: 1.25rem; display: grid; gap: .45rem; }
.method .prose h3 { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; margin: 1.5rem 0 .5rem; }
.auto-box { padding: clamp(1.4rem, 3vw, 2rem); border-radius: var(--radius); background: #111; color: #fff; --focus: var(--accent); }
:root[data-theme="dark"] .auto-box { box-shadow: inset 0 0 0 1px #2f5c48; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auto-box { box-shadow: inset 0 0 0 1px #2f5c48; } }
.auto-box .kicker { color: var(--accent); }
.auto-box h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); font-weight: 800; letter-spacing: -0.035em; margin-bottom: 1rem; }
.auto-box ul { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: .75rem; }
.auto-box li { position: relative; padding-left: 1.75rem; color: #d6d6d1; font-size: .95rem; }
.auto-box li::before { content: ""; position: absolute; left: 0; top: .2em; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #10291f url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2 7 10.5l4.5-5' fill='none' stroke='%235ee0a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; }
.auto-box .cta-row { margin: 0; }
.disclaimer { margin: 2rem 0 0; padding: .9rem 1.1rem; border-left: 3px solid var(--line-strong); font-size: .85rem; color: var(--ink-3); max-width: 48rem; }
.disclaimer strong { color: var(--ink-2); }

.tool-final { padding-block: clamp(3.5rem, 8vw, 5.5rem); }
.section.method-section { padding-bottom: clamp(3rem, 7vw, 5rem); }

/* ---------- hub ---------- */
.hub-grid { display: grid; gap: 1rem; padding-bottom: 1.5rem; }
@media (min-width: 760px) { .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .hub-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.hub-card { position: relative; display: flex; flex-direction: column; padding: 1.6rem; min-width: 0; transition: transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .25s; }
.hub-card:hover { transform: translateY(-4px); }
.hub-card:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.hub-card h2 { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.035em; margin-bottom: .6rem; }
.hub-card h2 a { text-decoration: none; }
.hub-card h2 a:focus-visible { outline: none; }
.hub-card h2 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.hub-card p { color: var(--ink-2); }
.hub-card .go { margin-top: auto; padding-top: .5rem; font-weight: 700; color: var(--accent-strong); }
.hub-art { height: 7.5rem; margin-bottom: 1.25rem; padding: .9rem 1rem; border-radius: 16px; background: var(--card-2); }
.hub-art svg { display: block; width: 100%; height: 100%; }
.hub-art .ink { stroke: var(--ink); fill: none; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.hub-art .mint { fill: var(--accent); }
.hub-art .dash { stroke: var(--neg); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.hub-art .bar { fill: var(--line-strong); }
.hub-art .bar-ink { fill: var(--ink); }
.hub-art .elim { fill: var(--elim); }
.hub-note { max-width: 46rem; margin: 0; padding-bottom: clamp(3rem, 7vw, 5rem); }
@media (prefers-reduced-motion: reduce) { .hub-card:hover { transform: none; } }
