/*
 * NumShelf Calculators — calculator styles.
 * Every colour and font comes from a --ns-* custom property, so the theme can restyle
 * calculators without touching this file. Fallbacks give a usable light look on their own.
 */
.ns-calculator {
  --_ink: var(--ns-ink, #14202b);
  --_muted: var(--ns-muted, #56636d);
  --_line: var(--ns-line, #d5dcd8);
  --_field: var(--ns-field, #ffffff);
  --_panel: var(--ns-panel, #f1f5f2);
  --_display: var(--ns-display, #e3f0eb);
  --_accent: var(--ns-accent, #0e6b57);
  --_on-accent: var(--ns-on-accent, #ffffff);
  --_danger: var(--ns-danger, #b42318);
  --_focus: var(--ns-focus, #f2b33d);
  --_mono: var(--ns-mono, ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace);
  --_radius: var(--ns-radius, 10px);

  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--_line);
  border-radius: var(--_radius);
  overflow: hidden;
  color: var(--_ink);
  background: var(--_field);
}
@media (max-width: 760px) {
  .ns-calculator { grid-template-columns: minmax(0, 1fr); }
}

.ns-form { display: flex; flex-direction: column; gap: 16px; padding: 20px; min-width: 0; }
.ns-field { display: flex; flex-direction: column; gap: 6px; }
.ns-field label { font-weight: 600; font-size: 0.875rem; }
.ns-control { position: relative; display: flex; align-items: center; }
.ns-control input,
.ns-control select,
.ns-control textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--_ink);
  background: var(--_field);
  border: 1px solid var(--_line);
  border-radius: calc(var(--_radius) - 4px);
  padding: 10px 12px;
  min-height: 44px;
}
.ns-control textarea { resize: vertical; line-height: 1.55; min-height: 160px; }
.ns-control--number input { font-family: var(--_mono); font-variant-numeric: tabular-nums; padding-right: 36px; }
.ns-suffix { position: absolute; right: 12px; color: var(--_muted); font-family: var(--_mono); pointer-events: none; }
.ns-suffix:empty { display: none; }
.ns-control :is(input, select, textarea):focus-visible { outline: 3px solid var(--_focus); outline-offset: 1px; border-color: var(--_accent); }
.ns-control [aria-invalid] { border-color: var(--_danger); }
.ns-error { margin: 0; color: var(--_danger); font-size: 0.8125rem; }

.ns-result {
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px; min-width: 0;
  background: var(--_panel);
  border-left: 1px solid var(--_line);
}
@media (max-width: 760px) {
  .ns-result { border-left: 0; border-top: 1px solid var(--_line); }
}
.ns-idle { margin: 0; color: var(--_muted); padding: 18px; border: 1px dashed var(--_line); border-radius: calc(var(--_radius) - 4px); }
.ns-result-body { display: flex; flex-direction: column; gap: 4px; }
.ns-primary-label { margin: 0; font-size: 0.8125rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--_muted); }
.ns-primary-value {
  display: block;
  font-family: var(--_mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  line-height: 1.15;
  font-weight: 600;
  padding: 12px 14px;
  background: var(--_display);
  border-radius: calc(var(--_radius) - 4px);
  overflow-wrap: anywhere;
}
.ns-rows { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 12px 0 0; }
.ns-rows dt { color: var(--_muted); font-size: 0.875rem; }
.ns-rows dd { margin: 0; text-align: right; font-family: var(--_mono); font-variant-numeric: tabular-nums; font-size: 0.875rem; overflow-wrap: anywhere; }

.ns-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.ns-btn {
  font: inherit; font-size: 0.875rem; font-weight: 600;
  min-height: 44px; padding: 10px 16px;
  border-radius: calc(var(--_radius) - 4px);
  border: 1px solid var(--_line);
  background: var(--_field); color: var(--_ink);
  cursor: pointer;
}
.ns-btn--primary { background: var(--_accent); border-color: var(--_accent); color: var(--_on-accent); }
.ns-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ns-btn:focus-visible { outline: 3px solid var(--_focus); outline-offset: 2px; }
.ns-status { margin: 0; min-height: 1.25em; font-size: 0.8125rem; color: var(--_accent); }
.ns-copy-fallback { width: 100%; font-family: var(--_mono); font-size: 0.8125rem; }

/* Extras: chart and table sit under the calculator */
.ns-extras { display: flex; flex-direction: column; gap: 20px; margin-top: 20px; }
.ns-extras:empty { display: none; }
.ns-figure { margin: 0; padding: 16px; border: 1px solid var(--ns-line, #d5dcd8); border-radius: var(--ns-radius, 10px); }
.ns-figure figcaption { font-weight: 600; margin-bottom: 6px; }
.ns-chart { width: 100%; height: auto; display: block; }
.ns-chart .ns-grid { stroke: var(--ns-line, #d5dcd8); stroke-width: 1; }
.ns-chart .ns-tick { fill: var(--ns-muted, #56636d); font-size: 11px; font-family: var(--ns-mono, ui-monospace, monospace); }
.ns-s0 { fill: var(--ns-series-a, #9fc3b8); background: var(--ns-series-a, #9fc3b8); }
.ns-s1 { fill: var(--ns-series-b, #0e6b57); background: var(--ns-series-b, #0e6b57); }
.ns-legend { display: flex; flex-wrap: wrap; gap: 16px; list-style: none; padding: 0; margin: 0 0 8px; font-size: 0.8125rem; color: var(--ns-muted, #56636d); }
.ns-legend li { display: flex; align-items: center; gap: 6px; }
.ns-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.ns-table-wrap { border: 1px solid var(--ns-line, #d5dcd8); border-radius: var(--ns-radius, 10px); padding: 12px 16px; }
.ns-table-wrap summary { cursor: pointer; font-weight: 600; }
.ns-scroll { overflow-x: auto; margin-top: 10px; }
.ns-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.ns-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ns-table th, .ns-table td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--ns-line, #d5dcd8); white-space: nowrap; }
.ns-table thead th { color: var(--ns-muted, #56636d); font-weight: 600; }
.ns-table th[scope='row'], .ns-table thead th:first-child { text-align: left; }
.ns-table td { font-family: var(--ns-mono, ui-monospace, monospace); }

@media (prefers-reduced-motion: no-preference) {
  .ns-primary-value { transition: background-color 0.2s ease; }
}

/* Search box, related tools and ad slots (shortcodes) */
.nsc-search { position: relative; display: flex; flex-direction: column; gap: 10px; }
.nsc-search label { font-weight: 700; font-size: 1.5rem; }
.nsc-search input[type="search"] { font: inherit; font-size: 1.125rem; padding: 14px 18px; min-height: 56px; border: 2px solid var(--ns-ink, #14202b); border-radius: 12px; background: var(--ns-field, #fff); color: var(--ns-ink, #14202b); }
.nsc-search input[type="search"]:focus-visible { outline: 3px solid var(--ns-focus, #f2b33d); outline-offset: 2px; }
.nsc-search__list { position: absolute; z-index: 50; left: 0; right: 0; top: 100%; margin: 6px 0 0; padding: 6px; list-style: none; background: var(--ns-field, #fff); border: 1px solid var(--ns-line, #d5dcd8); border-radius: 12px; box-shadow: 0 12px 32px rgb(0 0 0 / 0.14); }
.nsc-search__list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 8px; }
.nsc-search__list li[aria-selected="true"] { background: var(--ns-display, #e3f0eb); }
.nsc-search__list small { color: var(--ns-muted, #56636d); }
/* Tool cards: homepage, category pages and related tools */
.nsc-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.nsc-cards li { display: flex; margin: 0; }
.nsc-card { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--ns-field, #fff); border: 1px solid var(--ns-line, #d5dcd8); border-radius: var(--ns-radius, 10px); color: var(--ns-ink, #14202b); text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.nsc-card:hover, .nsc-card:focus-visible { border-color: var(--ns-accent, #0e6b57); color: var(--ns-ink, #14202b); }
.nsc-card:focus-visible { outline: 3px solid var(--ns-focus, #f2b33d); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) { .nsc-card:hover { transform: translateY(-2px); } }
.nsc-card__cat { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ns-muted, #56636d); }
.nsc-card__name { font-family: var(--ns-display-font, inherit); font-weight: 700; font-size: 1.125rem; line-height: 1.25; }
.nsc-card__desc { color: var(--ns-muted, #56636d); font-size: 0.9375rem; line-height: 1.5; }

/* Category grid */
.nsc-cats { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.nsc-cats li { margin: 0; }
.nsc-cat { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border: 1px solid transparent; border-radius: var(--ns-radius, 10px); color: var(--ns-ink, #14202b); text-decoration: none; }
.nsc-cat:hover, .nsc-cat:focus-visible { background: var(--ns-field, #fff); border-color: var(--ns-line, #d5dcd8); color: var(--ns-ink, #14202b); }
.nsc-cat:focus-visible { outline: 3px solid var(--ns-focus, #f2b33d); outline-offset: 2px; }
.nsc-cat__glyph { flex: none; width: 64px; height: 48px; display: grid; place-items: center; font-family: var(--ns-mono, ui-monospace, monospace); font-weight: 600; font-size: 0.875rem; background: var(--ns-field, #fff); border: 1px solid var(--ns-line, #d5dcd8); border-radius: 8px; color: var(--ns-accent, #0e6b57); }
.nsc-cat__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.4; }
.nsc-cat__name { font-weight: 700; }
.nsc-cat__blurb { color: var(--ns-muted, #56636d); font-size: 0.9375rem; }
.nsc-cat__count { font-family: var(--ns-mono, ui-monospace, monospace); font-size: 0.75rem; color: var(--ns-muted, #56636d); }

/* Recently added */
.nsc-recent { list-style: none; padding: 0; margin: 0; }
.nsc-recent li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; margin: 0; border-bottom: 1px solid var(--ns-line, #d5dcd8); }
.nsc-recent span { color: var(--ns-muted, #56636d); font-size: 0.875rem; white-space: nowrap; }

/* Compact search for the site header */
.nsc-search--compact { gap: 0; }
.nsc-search--compact input[type="search"] { font-size: 1rem; min-height: 42px; padding: 8px 16px; border-width: 1px; border-color: var(--ns-line, #d5dcd8); border-radius: 999px; }
.nsc-search__list a { color: inherit; text-decoration: none; font-weight: 600; }
.nsc-search__list li[aria-selected="true"] a { color: var(--ns-accent, #0e6b57); }
.nsc-ad { display: block; width: 100%; margin: 24px 0; overflow: hidden; }
.nsc-ad:empty { background: transparent; }
@media (max-width: 980px) { .nsc-ad--side { display: none; } }

/* Space held for a calculator until its script has drawn it, so the page does not jump (0.4.0). */
.nsc-calculator[data-pending] { min-height: var(--nsc-reserve, 480px); }

/* Longer introduction on a category page, below its one-line description (0.4.0). */
.nsc-cat-intro { margin: 16px 0 28px; max-width: 68ch; }
.nsc-cat-intro p { margin: 0 0 12px; }
