/*
  Two patterns app.css does not already carry, shared by the GST calculator and
  the HSN lookup: a pressable option (the segmented direction switch and the
  rate chips) and a rule-separated result row (the tax ledger and the code
  hits). Everything below is built from the same variables, rules and mono
  captions as app.css - no new colours, so dark mode keeps working for free.
*/

/* A left-aligned version of .stage-intro: these tools read as a form, not as a
   poster, so the heading lines up with the results underneath it. */
.toolintro { max-width: 58ch; margin: 0 0 26px; }
.toolintro h1 {
  font-family: var(--mono);
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}
.toolintro p { color: var(--ink-2); margin: 0; }

/* ---------- pressable options: segments and chips ---------- */

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-bottom: 14px;
}

/* The input sits before .seg-body so the checked state is a plain sibling
   selector - no :has(), which keeps this working in older browsers too. */
.seg-opt { display: block; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; }

.seg-body {
  display: block;
  background: var(--card);
  padding: 10px 12px;
  height: 100%;
  transition: background 120ms ease;
}
.seg-body b {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
}
.seg-body small { display: block; font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.seg-opt:hover .seg-body b { color: var(--ink); }

.seg-opt input:checked + .seg-body { background: var(--ink); }
.seg-opt input:checked + .seg-body b { color: var(--card); }
.seg-opt input:checked + .seg-body small { color: var(--card); opacity: 0.72; }
.seg-opt input:focus-visible + .seg-body { outline: 2px solid var(--signal); outline-offset: -2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span {
  display: inline-block;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 6px 11px;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.chip:hover span { color: var(--signal); border-color: var(--signal); }
.chip input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--card);
}
.chip input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }

/* app.css styles .hint inside .setting but not inside .setting-row, where these
   pages use it. Same treatment, so the two read alike. */
.setting-row .hint {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 5px;
  margin-bottom: 0;
}

/* ---------- the tax ledger ---------- */

.ledger {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--rule);
  margin-bottom: 16px;
}
.ledger th,
.ledger td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule-2);
  font-weight: 400;
  font-size: 14px;
}
.ledger td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ledger tr:last-child th,
.ledger tr:last-child td { border-bottom: 0; }

.ledger .is-total th,
.ledger .is-total td {
  border-top: 1px solid var(--rule);
  font-weight: 600;
  font-size: 15px;
}
.ledger .is-total td { color: var(--signal); }

.workings {
  font-size: 13px;
  color: var(--ink-2);
  max-width: 62ch;
  margin: 0 0 18px;
}

.calcnote { font-size: 13px; color: var(--ink-3); max-width: 62ch; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }

/* ---------- lookup: search bar, hits, recents ---------- */

.searchbar { margin-bottom: 14px; }
.searchbar input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.searchbar input[type="search"]:focus { border-color: var(--signal); }
.searchbar input[type="search"]:disabled { color: var(--ink-3); }

.searchstatus {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 14px;
  min-height: 1.2em;
}

.hitlist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.hitlist:empty { border: 0; }

.hit {
  background: var(--card);
  padding: 13px 15px 15px;
  border-left: 2px solid transparent;
}
.hit:hover { border-left-color: var(--signal); }

.hit-head { display: flex; align-items: baseline; gap: 8px; }
.hit-code {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  letter-spacing: 0.04em;
}
.hit-type {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 1px 4px;
  color: var(--ink-3);
}
.hit-type--sac { color: var(--warn); }
.hit-rate {
  margin-left: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.hit-desc { margin: 7px 0 0; font-size: 13.5px; line-height: 1.45; }

.hit-foot { margin-top: 8px; }
.hit-cat {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.hit-note {
  margin: 8px 0 0;
  padding-top: 7px;
  border-top: 1px solid var(--rule-2);
  font-size: 12px;
  color: var(--warn);
  line-height: 1.45;
}

.recents { margin-bottom: 20px; }
.recents .eyebrow { margin-bottom: 9px; }
.recent-list { display: flex; flex-wrap: wrap; gap: 6px; }

.recent-item {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.recent-go,
.recent-drop {
  font: inherit;
  font-size: 12px;
  background: transparent;
  color: var(--ink-2);
  border: 0;
  padding: 5px 9px;
  cursor: pointer;
}
.recent-go:hover { color: var(--signal); }
.recent-drop {
  border-left: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1;
  padding: 5px 8px;
}
.recent-drop:hover { color: var(--signal); }

.emptystate {
  background: var(--card);
  border: 1px dashed var(--rule);
  padding: 26px 22px;
  text-align: center;
}
.emptystate p { margin: 0 0 8px; font-size: 14px; }
.emptystate p:last-child { margin-bottom: 0; }
.emptystate .muted { color: var(--ink-3); font-size: 13px; max-width: 54ch; margin-inline: auto; }

/* The provenance warning. Deliberately the loudest thing on the page after the
   results themselves - a rate list nobody checks is worse than no rate list. */
.provenance {
  border-left: 3px solid var(--warn);
  background: var(--card);
  border-top: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 15px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
  max-width: 78ch;
}
.provenance b { color: var(--warn); }
.provenance a { color: inherit; }
.provenance .src {
  display: block;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

@media (max-width: 520px) {
  .seg { grid-template-columns: 1fr; }
}
