/*
  warwick.css — shared look for Town of Warwick web tools
  Version 1.2 · November 2026 · built from the "Town of Warwick Tools" design system

  One copy lives at https://tools.warwickma.org/warwick.css and every tool
  links to it:
    <link rel="stylesheet" href="https://tools.warwickma.org/warwick.css">

  A tool that prints a form, a sheet of labels or a sign imports it for the
  screen only, inside a cascade layer, so the printout never changes and the
  tool's own styles always win (see "Print previews" in the design system):
    <style>
      @import url("https://tools.warwickma.org/warwick.css") layer(warwick) screen;
    </style>

  Plain HTML elements (headings, links, buttons, inputs, selects,
  tables) are styled without any classes, so an existing tool picks up
  most of the look just by linking the file. The w- classes add the
  town header, panels, notices, status badges, paper previews and
  layout helpers.

  Light and dark follow the computer's setting. To force one, put
  data-theme="light" or data-theme="dark" on the <html> element.

  Don't edit colours or sizes here by hand: change them in the design
  system so every tool stays the same.
*/

/* ---------- Tokens: light (default) ---------- */
:root {
  color-scheme: light;
  --w-bg: #ece9e2;
  --w-surface: #f5f3ee;
  --w-sunken: #e3dfd6;
  --w-ink: #1b1b19;
  --w-muted: #4a4740;
  --w-subtle: #6a665d;
  --w-border: #6e6a61;
  --w-rule: #c9c4b8;
  --w-accent: #1d4a78;
  --w-accent-hover: #153a61;
  --w-on-accent: #f5f3ee;
  --w-accent-tint: #dce4ee;
  --w-focus: #b4500a;
  --w-ok: #24633a;
  --w-ok-tint: #dce9dd;
  --w-warn: #6e4a00;
  --w-warn-tint: #f1e2bf;
  --w-bad: #9e2a1e;
  --w-bad-tint: #f3dcd6;

  --w-space-1: 0.25rem;
  --w-space-2: 0.5rem;
  --w-space-3: 0.75rem;
  --w-space-4: 1rem;
  --w-space-5: 1.5rem;
  --w-space-6: 2rem;
  --w-space-7: 3rem;
  --w-space-8: 4rem;
  --w-radius-sm: 3px;
  --w-radius: 6px;
  --w-text-sm: 0.875rem;
  --w-text-base: 1.0625rem;
  --w-text-lg: 1.25rem;
  --w-text-xl: 1.5rem;
  --w-text-2xl: 1.875rem;
  --w-text-3xl: 2.375rem;
  --w-leading: 1.55;
  --w-leading-tight: 1.25;
  --w-line: 1px;
  --w-line-strong: 2px;
  --w-control-h: 2.75rem;
  --w-measure: 44rem;
  --w-page-max: 72rem;
  --w-gutter: 1rem;

  --w-font: system-ui, -apple-system, "Segoe UI", "Noto Sans", Cantarell, Ubuntu, "Liberation Sans", "Helvetica Neue", Arial, sans-serif;
  --w-font-mono: ui-monospace, "SF Mono", "DejaVu Sans Mono", "Liberation Mono", Menlo, Consolas, monospace;
}

/* ---------- Tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --w-bg: #17181a;
    --w-surface: #202226;
    --w-sunken: #111214;
    --w-ink: #e9e6df;
    --w-muted: #bdb8ae;
    --w-subtle: #9c978d;
    --w-border: #8d887e;
    --w-rule: #3a3c40;
    --w-accent: #8fb8e8;
    --w-accent-hover: #b3cff0;
    --w-on-accent: #111214;
    --w-accent-tint: #1c2a3a;
    --w-focus: #f0a35e;
    --w-ok: #86c99a;
    --w-ok-tint: #1e3326;
    --w-warn: #e6c26e;
    --w-warn-tint: #3a2f14;
    --w-bad: #f09a8c;
    --w-bad-tint: #3d1e1a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --w-bg: #17181a;
  --w-surface: #202226;
  --w-sunken: #111214;
  --w-ink: #e9e6df;
  --w-muted: #bdb8ae;
  --w-subtle: #9c978d;
  --w-border: #8d887e;
  --w-rule: #3a3c40;
  --w-accent: #8fb8e8;
  --w-accent-hover: #b3cff0;
  --w-on-accent: #111214;
  --w-accent-tint: #1c2a3a;
  --w-focus: #f0a35e;
  --w-ok: #86c99a;
  --w-ok-tint: #1e3326;
  --w-warn: #e6c26e;
  --w-warn-tint: #3a2f14;
  --w-bad: #f09a8c;
  --w-bad-tint: #3d1e1a;
}

/* ---------- Paper: on-screen print previews ---------- */
/* Put w-paper on the element that shows a printed page. On screen it keeps
   the light colours inside the preview, even in the dark theme, because it
   shows what will come out of the printer. Printing ignores it. */
@media screen {
  .w-paper {
    color-scheme: light;
    --w-bg: #ece9e2;
    --w-surface: #f5f3ee;
    --w-sunken: #e3dfd6;
    --w-ink: #1b1b19;
    --w-muted: #4a4740;
    --w-subtle: #6a665d;
    --w-border: #6e6a61;
    --w-rule: #c9c4b8;
    --w-accent: #1d4a78;
    --w-accent-hover: #153a61;
    --w-on-accent: #f5f3ee;
    --w-accent-tint: #dce4ee;
    --w-focus: #b4500a;
    --w-ok: #24633a;
    --w-ok-tint: #dce9dd;
    --w-warn: #6e4a00;
    --w-warn-tint: #f1e2bf;
    --w-bad: #9e2a1e;
    --w-bad-tint: #f3dcd6;
    background: var(--w-surface);
    color: var(--w-ink);
  }
}

/* ---------- Gutter widens on larger screens ---------- */
@media (min-width: 48rem) { :root { --w-gutter: 2rem; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--w-bg);
  color: var(--w-ink);
  font-family: var(--w-font);
  font-size: var(--w-text-base);
  line-height: var(--w-leading);
}

h1, h2, h3, h4 {
  margin: var(--w-space-6) 0 var(--w-space-3);
  line-height: var(--w-leading-tight);
  font-weight: 700;
  color: var(--w-ink);
}
h1 { font-size: var(--w-text-2xl); margin-top: 0; }
h2 { font-size: var(--w-text-xl); }
h3 { font-size: var(--w-text-lg); }
h4 { font-size: var(--w-text-base); }

p, ul, ol, dl { margin: 0 0 var(--w-space-4); }
p, li { max-width: var(--w-measure); }
li + li { margin-top: var(--w-space-1); }
small, .w-small { font-size: var(--w-text-sm); }
strong, b { font-weight: 700; }

a {
  color: var(--w-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--w-accent-hover); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--w-focus);
  outline-offset: 2px;
}

::selection { background: var(--w-accent); color: var(--w-on-accent); }

hr {
  border: 0;
  border-top: var(--w-line) solid var(--w-rule);
  margin: var(--w-space-6) 0;
}

code, kbd, samp, pre { font-family: var(--w-font-mono); font-size: 0.92em; }
code, kbd {
  background: var(--w-sunken);
  padding: 0.1em 0.35em;
  border-radius: var(--w-radius-sm);
}
pre {
  background: var(--w-sunken);
  padding: var(--w-space-4);
  border-radius: var(--w-radius);
  overflow-x: auto;
}

img, svg { max-width: 100%; height: auto; }

/* Numbers that line up: tag numbers, dates, money */
.w-num, td.num, th.num {
  font-variant-numeric: tabular-nums;
}
td.num, th.num { text-align: right; }
td.num, th.num, td.w-num, td .w-num { white-space: nowrap; }

/* ---------- Layout ---------- */
/* Content starts at the same gutter as the town header, so the page lines
   up under the title on any screen. */
.w-page {
  max-width: var(--w-page-max);
  margin: 0;
  padding: var(--w-space-5) var(--w-gutter) var(--w-space-8);
}

.w-stack > * + * { margin-top: var(--w-space-4); }
.w-stack > * { margin-bottom: 0; }

.w-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--w-space-3);
  align-items: center;
}
.w-row--end { justify-content: flex-end; }
.w-row--between { justify-content: space-between; }

.w-grid {
  display: grid;
  gap: var(--w-space-4);
  grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
}

/* ---------- Town header & footer ---------- */
.w-header {
  border-bottom: 3px solid var(--w-accent);
  background: var(--w-surface);
}
/* The town name and the tool's title sit in the same place on every page:
   the header spans the whole window and starts at the gutter, however the
   page below it is laid out. Tools don't change its width or padding. */
.w-header__inner {
  padding: var(--w-space-4) var(--w-gutter);
  display: flex;
  flex-wrap: wrap;
  gap: var(--w-space-2) var(--w-space-5);
  align-items: flex-end;
  justify-content: space-between;
}
@media (min-width: 48rem) {
  .w-header__inner { padding-top: var(--w-space-5); }
}
.w-header__town {
  display: block;
  font-size: var(--w-text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--w-muted);
  text-decoration: none;
}
a.w-header__town:hover { color: var(--w-ink); text-decoration: underline; }
.w-header__title {
  margin: var(--w-space-1) 0 0;
  font-size: var(--w-text-2xl);
  line-height: var(--w-leading-tight);
}
.w-header nav { display: flex; flex-wrap: wrap; gap: var(--w-space-1) var(--w-space-4); }
.w-header nav a { font-weight: 600; }
.w-header nav a[aria-current="page"] { color: var(--w-ink); text-decoration-thickness: 2px; }

.w-footer {
  max-width: var(--w-page-max);
  margin: 0;
  padding: var(--w-space-5) var(--w-gutter) var(--w-space-6);
  /* a rule that lines up with the page content, not the padding */
  background: linear-gradient(var(--w-rule), var(--w-rule)) no-repeat center top / calc(100% - 2 * var(--w-gutter)) var(--w-line);
  color: var(--w-muted);
  font-size: var(--w-text-sm);
}

/* ---------- Toolbar: actions that stay in view under the header ---------- */
.w-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--w-bg);
  border-bottom: var(--w-line) solid var(--w-rule);
}
.w-toolbar__inner {
  max-width: var(--w-page-max);
  margin: 0;
  padding: var(--w-space-3) var(--w-gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--w-space-3) var(--w-space-5);
}
.w-toolbar__hint {
  flex: 1 1 18rem;
  max-width: none;
  margin: 0;
  color: var(--w-muted);
  font-size: var(--w-text-sm);
}
.w-toolbar .w-notice { margin: 0; flex: 1 1 100%; max-width: none; }
/* On a phone the bar scrolls away with the page instead of covering it. */
@media (max-width: 47.99rem) {
  .w-toolbar { position: static; }
}

/* ---------- Disclosure (details / summary) ---------- */
summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--w-accent);
  padding: var(--w-space-2) 0;
}
summary:hover { color: var(--w-accent-hover); text-decoration: underline; }

/* ---------- Panel ---------- */
.w-panel {
  background: var(--w-surface);
  border: var(--w-line) solid var(--w-rule);
  border-radius: var(--w-radius);
  padding: var(--w-space-5);
}
.w-panel > :first-child { margin-top: 0; }
.w-panel > :last-child { margin-bottom: 0; }
.w-panel__title { font-size: var(--w-text-lg); margin: 0 0 var(--w-space-3); }

/* ---------- Buttons (plain <button> is the secondary style) ---------- */
button, .w-btn, input[type="submit"], input[type="button"], input[type="reset"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--w-space-2);
  min-height: var(--w-control-h);
  padding: 0 var(--w-space-4);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  color: var(--w-ink);
  background: var(--w-surface);
  border: var(--w-line-strong) solid var(--w-ink);
  border-radius: var(--w-radius);
  cursor: pointer;
  text-decoration: none;
}
button:hover, .w-btn:hover, input[type="submit"]:hover, input[type="button"]:hover {
  background: var(--w-sunken);
  color: var(--w-ink);
}
.w-btn--primary, button[type="submit"], input[type="submit"] {
  background: var(--w-accent);
  border-color: var(--w-accent);
  color: var(--w-on-accent);
}
.w-btn--primary:hover, button[type="submit"]:hover, input[type="submit"]:hover {
  background: var(--w-accent-hover);
  border-color: var(--w-accent-hover);
  color: var(--w-on-accent);
}
button.w-btn--danger, .w-btn--danger { background: var(--w-surface); color: var(--w-bad); border-color: var(--w-bad); }
button.w-btn--danger:hover, .w-btn--danger:hover { background: var(--w-bad-tint); color: var(--w-bad); }
button.w-btn--quiet, .w-btn--quiet { border-color: transparent; background: transparent; color: var(--w-accent); text-decoration: underline; text-underline-offset: 0.18em; }
button.w-btn--quiet:hover, .w-btn--quiet:hover { background: var(--w-accent-tint); color: var(--w-accent-hover); }
.w-btn--small { min-height: 2.25rem; padding: 0 var(--w-space-3); font-size: var(--w-text-sm); }

button:disabled, .w-btn[aria-disabled="true"], input:disabled, select:disabled, textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Form fields ---------- */
.w-field { display: flex; flex-direction: column; gap: var(--w-space-1); margin-bottom: var(--w-space-4); }
label, .w-label { font-weight: 600; }
.w-hint { color: var(--w-muted); font-size: var(--w-text-sm); margin: 0; }
.w-error-text { color: var(--w-bad); font-weight: 600; font-size: var(--w-text-sm); margin: 0; }
.w-required { color: var(--w-bad); font-weight: 700; }

input:where(:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="reset"], [type="file"], [type="color"], [type="range"], [type="hidden"])),
select,
textarea {
  width: 100%;
  max-width: 32rem;
  min-height: var(--w-control-h);
  padding: var(--w-space-2) var(--w-space-3);
  font: inherit;
  color: var(--w-ink);
  background: var(--w-surface);
  border: var(--w-line-strong) solid var(--w-border);
  border-radius: var(--w-radius-sm);
}
textarea { min-height: 7rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--w-subtle); opacity: 1; }
input:where(:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="reset"])):hover, select:hover, textarea:hover { border-color: var(--w-ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--w-ink);
  outline: 3px solid var(--w-focus);
  outline-offset: 1px;
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--w-bad);
  border-width: 3px;
}
.w-input--short { max-width: 10rem; }
.w-input--medium { max-width: 18rem; }
.w-input--full { max-width: none; }

input[type="checkbox"], input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--w-accent);
  flex: none;
}
.w-check { display: flex; gap: var(--w-space-2); align-items: center; min-height: var(--w-control-h); font-weight: 400; }

fieldset {
  border: var(--w-line) solid var(--w-rule);
  border-radius: var(--w-radius);
  padding: var(--w-space-4) var(--w-space-5);
  margin: 0 0 var(--w-space-5);
}
legend { font-weight: 700; padding: 0 var(--w-space-2); }

/* ---------- Tables ---------- */
.w-table-wrap {
  overflow-x: auto;
  border: var(--w-line) solid var(--w-rule);
  border-radius: var(--w-radius);
  background: var(--w-surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
caption {
  text-align: left;
  font-weight: 700;
  padding: var(--w-space-3) var(--w-space-4);
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: var(--w-space-2) var(--w-space-3);
  border-bottom: var(--w-line) solid var(--w-rule);
}
thead th {
  background: var(--w-sunken);
  font-size: var(--w-text-sm);
  font-weight: 700;
  border-bottom: var(--w-line-strong) solid var(--w-ink);
  white-space: nowrap;
}
.w-table--sticky thead th { position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: var(--w-sunken); }
tbody tr:last-child td { border-bottom: 0; }
.w-table--compact th, .w-table--compact td { padding: var(--w-space-1) var(--w-space-2); }

/* ---------- Notices ---------- */
.w-notice {
  padding: var(--w-space-3) var(--w-space-4);
  border: var(--w-line-strong) solid var(--w-accent);
  border-radius: var(--w-radius);
  background: var(--w-accent-tint);
  color: var(--w-ink);
  margin: 0 0 var(--w-space-4);
  max-width: var(--w-measure);
}
.w-notice > :last-child { margin-bottom: 0; }
.w-notice:empty { display: none; }  /* an empty live region takes no room */
.w-notice__title { font-weight: 700; margin: 0 0 var(--w-space-1); }
.w-notice--ok   { border-color: var(--w-ok);   background: var(--w-ok-tint); }
.w-notice--warn { border-color: var(--w-warn); background: var(--w-warn-tint); }
.w-notice--bad  { border-color: var(--w-bad);  background: var(--w-bad-tint); }

/* ---------- Status badges ---------- */
.w-badge {
  display: inline-block;
  padding: 0.1em 0.55em;
  font-size: var(--w-text-sm);
  font-weight: 700;
  line-height: 1.5;
  border: var(--w-line) solid currentColor;
  border-radius: var(--w-radius-sm);
  white-space: nowrap;
  color: var(--w-muted);
  background: var(--w-surface);
}
.w-badge--ok   { color: var(--w-ok);   background: var(--w-ok-tint); }
.w-badge--warn { color: var(--w-warn); background: var(--w-warn-tint); }
.w-badge--bad  { color: var(--w-bad);  background: var(--w-bad-tint); }
.w-badge--info { color: var(--w-accent); background: var(--w-accent-tint); }

/* ---------- Definition list (record details) ---------- */
.w-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--w-space-2) var(--w-space-5);
}
.w-details dt { color: var(--w-muted); font-weight: 600; }
.w-details dd { margin: 0; }
@media (max-width: 30rem) {
  .w-details { grid-template-columns: 1fr; gap: 0; }
  .w-details dd { margin-bottom: var(--w-space-2); }
}

/* ---------- Helpers ---------- */
.w-muted { color: var(--w-muted); }
.w-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.w-skip-link {
  position: absolute; left: var(--w-space-4); top: -10rem;
  background: var(--w-surface); padding: var(--w-space-2) var(--w-space-3);
  border: var(--w-line-strong) solid var(--w-ink); z-index: 10;
}
.w-skip-link:focus { top: var(--w-space-2); }

/* ---------- Windows high-contrast & print ---------- */
@media (forced-colors: active) {
  .w-badge, .w-notice, button, .w-btn { border-color: CanvasText; }
}

@media print {
  :root { --w-bg: #FFFFFF; --w-surface: #FFFFFF; --w-sunken: #EEEEEE; --w-ink: #000000; --w-muted: #333333; --w-rule: #999999; }
  body { font-size: 11pt; }
  .w-header { border-bottom-color: #000000; background: none; }
  .w-no-print, .w-header nav, .w-toolbar, button, .w-btn { display: none !important; }
  .w-table-wrap { overflow: visible; border: 0; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  a { color: inherit; }
}
