/* ==========================================================================
   Reglynn - free tools (/tools/*). Loaded after content.css.
   Adds only what the tools need, built on content.css tokens, so both themes
   follow automatically. Flat surfaces, 1px hairlines, no gradients or glows.
   Generated pages: _build/build_tools.py. Behaviour: /assets/tools/*.js.
   ========================================================================== */

.tool-wrap { max-width: 1088px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .tool-wrap { padding: 0 16px; } }

.tool { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px;
  color: var(--soft); margin: 0 0 56px; }
.tool-narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
@media (max-width: 640px) { .tool { padding: 20px 16px; border-radius: 12px; } }

.tool-grid { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 32px; align-items: start; }
.tool-grid > * { min-width: 0; }
@media (max-width: 920px) { .tool-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; } }
.tool-out-col { display: grid; gap: 16px; }
@media (min-width: 921px) { .tool-sticky { position: sticky; top: 96px; } }

.tool-noscript { margin: 0 0 24px; }

/* ---------- fields ---------- */
.tool form { margin: 0; }
.field { margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > legend, .q-lbl, .q-legend { display: block; padding: 0; margin: 0 0 8px; color: var(--fg); font-weight: 500;
  font-size: 15.5px; line-height: 1.4; }
.q-legend { font-size: clamp(20px, 2.4vw, 24px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; margin-bottom: 10px; }
.help { margin: 6px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.q-help { margin: 0 0 18px; font-size: 15px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

.tool input[type="text"], .tool input[type="url"], .tool select {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--input-border); border-radius: 10px;
  background: var(--bg); color: var(--fg); font: 400 16px/1.3 var(--sans); }
.tool select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  /* chevron drawn with two gradients so it follows the theme's --muted (a data: SVG cannot read CSS variables) */
  background-image: linear-gradient(45deg, transparent calc(50% - .8px), var(--muted) calc(50% - .8px), var(--muted) calc(50% + .8px), transparent calc(50% + .8px)),
    linear-gradient(-45deg, transparent calc(50% - .8px), var(--muted) calc(50% - .8px), var(--muted) calc(50% + .8px), transparent calc(50% + .8px));
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.tool input::placeholder { color: var(--faint); opacity: 1; }
.tool input[type="text"]:hover, .tool input[type="url"]:hover, .tool select:hover { border-color: var(--input-border-hover); }
.tool input[aria-invalid="true"] { border-color: var(--err); }
.affix { position: relative; }
.affix > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 16px; }
.affix > input[type="text"] { padding-left: 34px; }
.field-err { margin: 6px 0 0; font-size: 14px; color: var(--err); }

/* option cards: radio and checkbox */
.opts { display: grid; gap: 8px; }
.opts-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .opts-2 { grid-template-columns: 1fr; } }
.opt { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); cursor: pointer; transition: border-color .15s; }
.opt:hover { border-color: rgba(var(--ink), .3); }
.opt input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--powder); cursor: pointer; }
.opt span { display: block; min-width: 0; }
.opt b { display: block; color: var(--fg); font-weight: 500; font-size: 15.5px; line-height: 1.4; }
.opt small { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.opt b .art { display: block; margin: 3px 0 1px; font-size: 12px; font-weight: 400; color: var(--ember); }
.opt:has(input:checked) { border-color: var(--powder); background: var(--surface-hi); }
.opt:has(input:focus-visible) { outline: 2px solid var(--powder); outline-offset: 2px; }
.opt input:focus-visible { outline: none; }
.opt-check { display: inline-flex; align-items: center; gap: 10px; color: var(--soft); font-size: 15px; cursor: pointer; }
.opt-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--powder); }

/* ---------- outputs ---------- */
.out { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 18px; min-width: 0; }
.out-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 8px; }
.out-head h3, .out h3 { margin: 0; font-size: 16.5px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg); }
.out > .help { margin: 0 0 12px; }
@media (max-width: 640px) { .preview-frame { height: 300px; } .out { padding: 14px; } .out-text { padding: 12px 14px; } .checklist li { padding: 12px; } }
.out-text { margin: 0; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--surface);
  color: var(--fg); font-size: 15.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.code { margin: 12px 0 0; padding: 14px 16px; max-height: 300px; overflow: auto; border: 1px solid var(--line-soft); border-radius: 8px;
  background: var(--band); color: var(--soft); font: 12.5px/1.6 var(--mono); white-space: pre; tab-size: 2;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.code:focus-visible { outline: 2px solid var(--powder); outline-offset: 2px; }
.out-note { border-left: 3px solid var(--powder); }
.out-note p { margin: 0 0 10px; font-size: 15px; }
.out-note p:last-child { margin-bottom: 0; }

.btn-copy { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid rgba(var(--ink), .22); background: transparent; color: var(--fg); font: 500 14px/1 var(--sans); cursor: pointer;
  transition: border-color .15s, color .15s; }
.btn-copy:hover { border-color: rgba(var(--ink), .5); }
.btn-copy svg { width: 14px; height: 14px; }
.btn-copy.is-done { color: var(--s-done); border-color: color-mix(in srgb, var(--s-done) 50%, transparent); }

.tool-key { margin: 0; }
.tool-key p { font-size: 15px; }
.preview-frame { display: block; width: 100%; height: 260px; border: 1px solid var(--line); border-radius: 10px; background: var(--band); }

/* segmented control (preview theme) */
.seg { flex: none; display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.seg-b { min-height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font: 500 13.5px/1 var(--sans); cursor: pointer; transition: background-color .15s, color .15s; }
.seg-b:hover { color: var(--fg); }
.seg-b[aria-pressed="true"] { background: var(--surface-hi); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
.seg-b:focus-visible { outline: 2px solid var(--powder); outline-offset: 2px; }
.out-head { flex-wrap: wrap; }

/* Article 50 checklist */
.checklist { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.checklist li { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-soft);
  border-radius: 10px; background: var(--surface); }
.checklist input { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--powder); cursor: pointer; }
.checklist input:focus-visible { outline: 2px solid var(--powder); outline-offset: 2px; }
.checklist label { display: block; min-width: 0; cursor: pointer; }
.ck-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 4px; }
.ck-meta .art { font-size: 12.5px; color: var(--ember); }
.ck-when { font-size: 13px; color: var(--faint); }
.ck-role { padding: 0 7px; border: 1px solid var(--line); border-radius: 5px; font-size: 12.5px; line-height: 20px; color: var(--soft); }
.check-after { margin: 14px 0 0; }
.ck-text { display: block; color: var(--soft); font-size: 15px; line-height: 1.55; }
.checklist li:has(input:checked) .ck-text { color: var(--muted); }

.tool .btn-ghost { min-height: 48px; }
.tool .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- wizard ---------- */
.wiz-segs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 14px; }
.wiz-segs i { display: block; height: 3px; border-radius: 2px; background: rgba(var(--ink), .1); transition: background-color .25s var(--ease); }
.wiz-segs i.on { background: var(--powder); }
.wiz-label { margin: 0 0 12px; font-size: 13.5px; font-weight: 500; color: var(--faint); min-height: 1.4em; }
.wiz-back { background: none; border: 0; padding: 10px 0; color: var(--muted); font: 500 15px var(--sans); cursor: pointer; }
.wiz-back:hover { color: var(--fg); }
.wiz-nav .wiz-back:only-child, .wiz-nav .wiz-back[hidden] + .btn { margin-left: auto; }
.step { margin: 0; padding: 0; border: 0; min-width: 0; }
.step:focus { outline: none; }
.substep { margin: 0; padding: 0; border: 0; min-width: 0; }
.q-legend-2 { float: left; width: 100%; margin-top: 30px; padding-top: 26px !important; border-top: 1px solid var(--line-soft); }
.q-legend-2 + .q-help { clear: both; }
.opts-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .opts-3 { grid-template-columns: 1fr; } }
.res-link { align-self: center; color: var(--soft); font-size: 15px; }
.wiz-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.wiz-nav .btn { min-width: 120px; }
.form-err { margin: 14px 0 0; color: var(--err); font-size: 15px; }
[hidden] { display: none !important; }

/* ---------- results ---------- */
.result:focus { outline: none; }
.verdict { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 6px; }
.verdict .sq { flex: none; width: 12px; height: 12px; margin-top: 10px; border-radius: 2px; background: var(--faint); }
.verdict h2, .verdict h3 { margin: 0; font-size: clamp(24px, 3vw, 30px); font-weight: 600; letter-spacing: -0.03em; line-height: 1.2; color: var(--fg); }
.verdict-sub { margin: 0 0 22px 24px; color: var(--muted); font-size: 15.5px; }
.result h4 { margin: 22px 0 8px; font-size: 13.5px; font-weight: 500; letter-spacing: .01em; color: var(--faint); }
.result ul, .result ol { margin: 0; padding-left: 20px; }
.result li { margin-bottom: 8px; font-size: 15.5px; }
.result li::marker { color: var(--faint); }
.result ol.why li { padding-left: 4px; }
.result em { font-style: normal; color: var(--fg); }
.deadline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 0; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); }
.deadline b { color: var(--fg); font-weight: 600; font-size: 18px; white-space: nowrap; }
.deadline span { color: var(--muted); font-size: 15px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.result-actions .btn { color: var(--on-coral); text-decoration: none; }
.result-actions .btn-ghost { color: var(--fg); }

.sq-high { background: var(--t-high) !important; }
.sq-lim { background: var(--t-lim) !important; }
.sq-partial { background: var(--s-partial) !important; }
.sq-done { background: var(--s-done) !important; }

/* ---------- fine calculator ---------- */
.figure-label { margin: 0 0 4px; font-size: 14px; color: var(--faint); }
.figure { margin: 0 0 4px; font-size: clamp(36px, 6vw, 52px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; color: var(--fg);
  overflow-wrap: anywhere; }
.figure-sub { margin: 0 0 18px; color: var(--muted); font-size: 15px; }
.maths { width: 100%; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; border-collapse: separate; border-spacing: 0;
  overflow: hidden; background: var(--bg); font-size: 15px; }
.maths th { width: 42%; background: transparent; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-weight: 400; font-size: 14.5px; vertical-align: top; }
.maths td { border-bottom: 1px solid var(--line-soft); color: var(--fg); overflow-wrap: anywhere; }
.maths tr:last-child th, .maths tr:last-child td { border-bottom: 0; }
.maths tr.total td, .maths tr.total th { color: var(--fg); font-weight: 600; }
@media (max-width: 480px) { .maths th, .maths td { display: block; width: auto; padding: 10px 14px; }
  .maths th { border-bottom: 0; padding-bottom: 0; } }
.calc-own { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 16px 18px; }
.calc-own > summary { cursor: pointer; color: var(--fg); font-weight: 500; font-size: 16px; list-style: none; display: flex; align-items: center; gap: 10px; }
.calc-own > summary::-webkit-details-marker { display: none; }
.calc-own > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s; }
.calc-own[open] > summary::before { transform: rotate(45deg); }
.calc-own-body { margin-top: 16px; }
.own-figure { margin: 0 0 4px; font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; color: var(--fg); overflow-wrap: anywhere; }
.own-maths { margin: 0 0 10px; font-size: 15px; color: var(--soft); overflow-wrap: anywhere; }
#own-out .figure-label { margin-bottom: 2px; }
.tool-sources { margin-top: 0; }
.tool-sources li { font-size: 14.5px; }
.own-label { display: inline-block; margin: 0 0 10px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px; color: var(--muted); }

/* ---------- hub ---------- */
.tool-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 0 0 40px; }
.tool-card { display: flex; flex-direction: column; gap: 10px; padding: 24px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--soft); text-decoration: none; transition: border-color .18s; }
article .tool-card { color: var(--soft); text-decoration: none; }
.tool-card:hover { border-color: rgba(var(--ink), .35); color: var(--soft); }
.tool-card .art { align-self: flex-start; font-size: 12.5px; color: var(--muted); }
.tool-card b { color: var(--fg); font-weight: 600; font-size: 18px; letter-spacing: -0.02em; line-height: 1.3; }
.tool-card span { color: var(--muted); font-size: 15px; line-height: 1.55; }
.tool-card .go { margin-top: auto; padding-top: 6px; color: var(--ember); font-size: 15px; font-weight: 500; }

/* FAQ */
.faq { margin: 0 0 24px; }
.faq h3 { margin: 28px 0 8px; }

@media (prefers-reduced-motion: reduce) {
  .wiz-segs i, .opt, .btn-copy, .seg-b, .tool-card, .calc-own > summary::before { transition: none; }
}
@media print { .tool .btn, .btn-copy, .wiz-nav { display: none !important; } }
