/* UtilTools design system.

   The reusable half of the stylesheet: the colour and spacing tokens, the reset, base
   typography, the layout primitives and the form controls. Nothing here knows anything
   about this site's pages, so it can be lifted into another project whole.

   Twelve custom properties carry the entire visual language, and every one of them has
   a dark-theme counterpart. Change those and the site changes; nothing else hard-codes
   a colour.

   Loaded before app.css, which builds the site's own components on top of it. */

/* ---------------------------------------------------------------- tokens */
:root {
  --ut-bg:            #ffffff;
  --ut-surface:       #f5f5f5;
  --ut-surface-alt:   #ebebeb;
  --ut-border:        #dcdcdc;
  --ut-border-strong: #131313;

  --ut-text:          #131313;
  --ut-text-muted:    #5c5c5c;
  --ut-text-invert:   #ffffff;

  --ut-action:        #131313;
  --ut-action-hover:  #2e2e2e;
  --ut-action-text:   #ffffff;

  --ut-accent:        #c2410c;
  --ut-accent-soft:   #fdf1ea;

  --ut-success:       #0f7b32;
  --ut-warning:       #9a6200;
  --ut-danger:        #b3261e;
  --ut-info:          #14548f;

  --ut-radius:        0;
  --ut-space:         0.25rem;
  --ut-font:          Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ut-font-mono:     "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ut-maxw:          75rem;
  --ut-measure:       70ch;
  color-scheme: light;
}

[data-theme="dark"] {
  --ut-bg:            #0e0e0e;
  --ut-surface:       #1a1a1a;
  --ut-surface-alt:   #242424;
  --ut-border:        #2e2e2e;
  --ut-border-strong: #f2f2f2;

  --ut-text:          #f2f2f2;
  --ut-text-muted:    #a3a3a3;
  --ut-text-invert:   #0e0e0e;

  --ut-action:        #f2f2f2;
  --ut-action-hover:  #d4d4d4;
  --ut-action-text:   #0e0e0e;

  --ut-accent:        #fb923c;
  --ut-accent-soft:   #2a1a10;

  --ut-success:       #4ade80;
  --ut-warning:       #fbbf24;
  --ut-danger:        #f87171;
  --ut-info:          #60a5fa;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
body {
  background: var(--ut-bg);
  color: var(--ut-text);
  font-family: var(--ut-font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-underline-offset: .2em; }
:focus-visible { outline: 2px solid var(--ut-border-strong); outline-offset: 2px; }
:target { scroll-margin-top: 5rem; }

/* ---------------------------------------------------------------- typography */
h1, h2, h3, h4 { line-height: 1.2; font-weight: 650; letter-spacing: -0.011em; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 1.35rem + 1.7vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 1.15rem + .65vw, 1.7rem); }
h3 { font-size: 1.125rem; }
p, li { text-wrap: pretty; }
code, kbd, pre, samp { font-family: var(--ut-font-mono); font-size: .875em; }
code:not(pre code) { background: var(--ut-surface-alt); padding: .1em .35em; border: 1px solid var(--ut-border); }
pre { background: var(--ut-surface); border: 1px solid var(--ut-border); padding: 1rem; overflow-x: auto; }
kbd { background: var(--ut-surface-alt); border: 1px solid var(--ut-border); padding: .1em .4em; font-size: .8em; }
hr { border: 0; border-top: 1px solid var(--ut-border); margin: 2rem 0; }

/* ---------------------------------------------------------------- layout */
.wrap { width: 100%; max-width: var(--ut-maxw); margin-inline: auto; padding-inline: 1rem; }
.prose { max-width: var(--ut-measure); }
.prose > * + * { margin-top: 1rem; }
.prose h2 { margin-top: 2.5rem; }
.prose h3 { margin-top: 1.75rem; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li + li { margin-top: .35rem; }
.stack > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: .5rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row-between { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--ut-text-muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.mono { font-family: var(--ut-font-mono); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 0; top: -3rem; z-index: 100;
  background: var(--ut-action); color: var(--ut-action-text); padding: .5rem 1rem;
}
.skip-link:focus { top: 0; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--ut-action); color: var(--ut-action-text);
  border: 1px solid var(--ut-action); padding: .5rem 1rem; text-decoration: none;
  font-weight: 550; font-size: .9375rem; border-radius: var(--ut-radius);
}
.btn:hover { background: var(--ut-action-hover); border-color: var(--ut-action-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--ut-text); border-color: var(--ut-border); }
.btn-secondary:hover { background: var(--ut-surface-alt); border-color: var(--ut-border-strong); }
.btn-danger { background: transparent; color: var(--ut-danger); border-color: var(--ut-border); }
.btn-danger:hover { background: var(--ut-surface-alt); border-color: var(--ut-danger); }
.btn-sm { padding: .3rem .6rem; font-size: .8125rem; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- forms */
.field { display: block; }
.field > label, .label { display: block; font-size: .8125rem; font-weight: 600; margin-bottom: .25rem; letter-spacing: .01em; }
.input, input[type="text"], input[type="number"], input[type="url"], input[type="email"],
input[type="password"], input[type="date"], input[type="time"], input[type="search"], select, textarea {
  width: 100%; padding: .5rem .625rem; border: 1px solid var(--ut-border);
  background: var(--ut-bg); color: var(--ut-text); border-radius: var(--ut-radius);
}
input:focus, select:focus, textarea:focus { border-color: var(--ut-border-strong); }
textarea { min-height: 9rem; resize: vertical; font-family: var(--ut-font-mono); font-size: .875rem; line-height: 1.5; }
input[type="range"] { width: 100%; accent-color: var(--ut-accent); padding: 0; border: 0; background: none; }
input[type="color"] { padding: 0; height: 2.25rem; border: 1px solid var(--ut-border); background: none; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ut-accent); width: 1rem; height: 1rem; }
.check { display: flex; gap: .5rem; align-items: center; font-size: .9375rem; }
.grid-fields { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
fieldset { border: 1px solid var(--ut-border); padding: .75rem; }
legend { font-size: .8125rem; font-weight: 600; padding-inline: .35rem; }
.seg { display: inline-flex; border: 1px solid var(--ut-border); flex-wrap: wrap; }
.seg button { background: none; border: 0; padding: .4rem .75rem; font-size: .875rem; border-right: 1px solid var(--ut-border); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ut-action); color: var(--ut-action-text); }

/* ---------------------------------------------------------------- utilities */
.hidden { display: none !important; }
.mt-0 { margin-top: 0 !important; }
.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--ut-action); color: var(--ut-action-text); padding: .5rem 1rem; font-size: .875rem;
}
@media print {
  .site-header, .site-footer, .tool-app, .skip-link { display: none !important; }
}
.thumb-fallback { display: grid; place-items: center; min-height: 5rem; font-size: .75rem; color: var(--ut-text-muted); background: var(--ut-surface-alt); text-align: center; padding: .5rem; }
.thumb button { width: 100%; }
.thumb .badge { position: absolute; top: .35rem; right: .35rem; background: var(--ut-action); color: var(--ut-action-text); font-size: .6875rem; padding: .05rem .3rem; }
.sign-pad { width: 100%; max-width: 600px; height: auto; aspect-ratio: 3 / 1; border: 1px dashed var(--ut-border-strong); background: var(--ut-bg); touch-action: none; cursor: crosshair; display: block; }
.invoice-row { display: grid; gap: .375rem; grid-template-columns: minmax(8rem, 3fr) 4.5rem 6rem 4.5rem minmax(4.5rem, auto) 2rem; align-items: center; }
.invoice-row input { min-width: 0; }
.invoice-head { font-size: .75rem; font-weight: 600; color: var(--ut-text-muted); letter-spacing: .02em; }
.kv-line { display: flex; justify-content: space-between; gap: 1rem; font-size: .875rem; }
.result-big-sm { font-size: 1.125rem; }
@media (max-width: 40rem) { .invoice-row { grid-template-columns: 1fr 1fr 1fr; } .invoice-head { display: none; } }
