/* ==========================================================================
   FreeUsefulApps.ca — Direction 1d, Quiet Civic
   Warm paper neutrals, one civic blue accent, Public Sans throughout,
   borders only where a boundary matters, no shadow, generous spacing.
   All values come from "Design System.dc.html". Do not add new colours.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Surfaces */
  --surface:          #F6F3EE;  /* page background */
  --surface-raised:   #FFFFFF;  /* panels, table body */
  --surface-sunken:   #E6E1D8;  /* footer, ad well */

  /* Borders */
  --border:           #DAD4C8;  /* 1px hairline, all edges */
  --border-strong:    #C6BFB0;  /* inputs, table heads */
  --border-hover:     #9A9285;  /* hovered input / chip edge */

  /* Text */
  --text:             #23211D;  /* headings, body */
  --text-body:        #3A362F;  /* paragraphs */
  --text-muted:       #6E675C;  /* labels, meta, specs */
  --text-disabled:    #7C7566;  /* disabled controls only */

  /* Accent */
  --accent:           #1F4E6B;  /* download, links */
  --accent-pressed:   #163A50;  /* hover */
  --accent-active:    #12303F;  /* active */

  /* Status */
  --ok:               #2F6B4F;  /* verified, collects nothing */
  --caution:          #8A6A1F;  /* stores data locally, [CHECK] flags */
  --error:            #9B3A2E;  /* field errors */

  /* Interaction fills */
  --row-zebra:        #FBF9F5;
  --row-hover:        #F1EDE5;
  --soft-hover:       #EBE6DC;
  --disabled-fill:    #DAD4C8;

  /* Ads — used nowhere else on the site */
  --ad-well:          #EFEBE2;
  --ad-border:        #B5AC9C;

  /* Placeholder hatch (screenshots, ad creative) */
  --hatch:            repeating-linear-gradient(135deg, #EBE6DC 0 6px, #E6E1D8 6px 12px);
  --hatch-ad:         repeating-linear-gradient(135deg, #E7E1D6 0 6px, #DED7CA 6px 12px);

  /* Spacing — 4px base, nothing between values */
  --sp-xs:   4px;
  --sp-sm:   8px;
  --sp-md:  12px;
  --sp-lg:  16px;   /* panel padding */
  --sp-xl:  20px;   /* section padding */
  --sp-2xl: 32px;   /* between sections */
  --sp-3xl: 48px;   /* tool-page breathing room only */

  /* Grid */
  --max-width:    1120px;
  --gutter:       20px;
  --content-width: 680px;   /* tool page / about / contact copy cap */

  --radius: 6px;            /* buttons, chips, inputs, ad wells only */

  --font: 'Public Sans', system-ui, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;          /* body · 15/1.55 · 400 */
  line-height: 1.55;
}

/* Page shell: header and footer are full bleed, content caps at the grid. */
.wrap {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

a { color: var(--accent); }
a:hover { color: var(--accent-pressed); }

img { max-width: 100%; height: auto; display: block; }

/* Focus is a 2px solid outline, never a glow. */
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

h1, h2, h3 { margin: 0; font-weight: 700; }

/* Type scale */
.page-title { font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; }
.tool-title { font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; }
h2, .section-title { font-size: 20px; line-height: 1.3; }
h3, .sub-title    { font-size: 17px; line-height: 1.3; }
.lead { font-size: 16px; line-height: 1.55; color: var(--text-body); margin: 0; }
.spec { font-size: 14px; line-height: 1.5; color: var(--text-body); }
.meta {
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.label {
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  /* A 64-character checksum has no spaces to break at. */
  overflow-wrap: anywhere;
}

/* Unfilled real detail. Every one of these is listed in CLAUDE.md. */
.check {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--caution);
}

/* --------------------------------------------------------------------------
   3. Header and footer — identical on every page
   -------------------------------------------------------------------------- */

.site-header {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.site-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  gap: var(--sp-lg);
  font-size: 14px;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--text-body);
  text-decoration: none;
}

.site-nav a:hover { text-decoration: underline; }

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
}

.site-footer {
  background: var(--surface-sunken);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-body);
  margin-top: var(--sp-2xl);
}

.site-footer-inner {
  display: flex;
  justify-content: space-between;
  gap: var(--gutter);
  flex-wrap: wrap;
  padding-top: 14px;
  padding-bottom: 14px;
}

.site-footer-links {
  display: flex;
  gap: 14px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   4. Panels and tables
   -------------------------------------------------------------------------- */

/* Panels stay square so the grid reads clearly. */
.panel {
  border: 1px solid var(--border);
  background: var(--surface-raised);
  padding: var(--sp-lg);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}
.stack-sm { gap: var(--sp-sm); }
.stack-lg { gap: var(--sp-xl); }
.stack-section { gap: var(--sp-2xl); }

/* Key/value spec table — download panel, about page, changelog. */
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.spec-table th,
.spec-table td {
  padding: 8px 0;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid var(--surface-sunken);
  font-weight: 400;
}

.spec-table th {
  color: var(--text-muted);
  width: 38%;
  font-variant-numeric: tabular-nums;
}

.spec-table--roomy { font-size: 15px; }
.spec-table--roomy th,
.spec-table--roomy td {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

/* "Sends" row on a web tool's page: what leaves the device, to whom, when. */
.sends-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.value-ok      { color: var(--ok);      font-weight: 600; }
.value-caution { color: var(--caution); font-weight: 600; }

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */

/* The one primary action on any page. 44px minimum target. */
.btn-download,
.btn-secondary,
.btn-quiet {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 13px var(--sp-lg);
  border-radius: var(--radius);
  text-align: center;
  text-decoration: none;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 80ms linear;
}

.btn-download {
  background: var(--accent);
  color: #FFFFFF;
  border: 1px solid var(--accent);
  font-weight: 700;
}
.btn-download:hover  { background: var(--accent-pressed); border-color: var(--accent-pressed); color: #FFFFFF; }
.btn-download:active { background: var(--accent-active);  border-color: var(--accent-active); }

.btn-download--large { padding: 15px var(--sp-lg); font-size: 17px; }

.btn-secondary {
  background: var(--surface-raised);
  color: var(--accent);
  border: 1px solid var(--border-strong);
  font-weight: 600;
  padding: 12px var(--sp-lg);
}
.btn-secondary:hover { background: var(--row-hover); border-color: var(--border-hover); }

.btn-quiet {
  background: transparent;
  color: var(--text-body);
  border: 1px solid var(--border);
  padding: 12px var(--sp-lg);
  font-size: 15px;
}
.btn-quiet:hover { background: var(--soft-hover); }

/* Disabled — build not ready. */
.btn-download[aria-disabled="true"],
.btn-download:disabled {
  background: var(--disabled-fill);
  border-color: var(--disabled-fill);
  color: var(--text-disabled);
  cursor: default;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   6. Fields
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  font-size: 15px;
  color: var(--text-body);
}

.field--inline { font-size: 14px; gap: var(--sp-xs); }

input[type="text"],
input[type="email"],
input[type="search"],
select,
textarea {
  font-family: inherit;
  font-size: 16px;          /* 16px keeps phones from zooming on focus */
  padding: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  width: 100%;
  min-height: 44px;
}

textarea { resize: vertical; min-height: 96px; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

input:disabled,
textarea:disabled,
select:disabled {
  border-color: var(--border);
  background: var(--soft-hover);
  color: var(--text-disabled);
}

.field-error input,
.field-error textarea { border: 2px solid var(--error); }

.field-error-text { font-size: 14px; color: var(--error); }

/* --------------------------------------------------------------------------
   7. Category chips
   -------------------------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
}

.chip {
  font-family: inherit;
  font-size: 14px;
  padding: 7px var(--sp-md);
  min-height: 34px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 80ms linear;
}

.chip:hover {
  border-color: var(--border-hover);
  background: var(--row-hover);
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #FFFFFF;
}

/* An empty category is shown, but it is not a live filter. */
.chip--empty {
  border-style: dashed;
  background: var(--surface);
  color: var(--text-disabled);
  cursor: default;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   8. Notices
   -------------------------------------------------------------------------- */

.notice {
  border: 1px solid var(--border);
  background: var(--surface-raised);
  padding: 10px var(--sp-md);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-body);
}

.notice strong { font-weight: 700; }
.notice-ok strong      { color: var(--ok); }
.notice-caution strong { color: var(--caution); }

/* --------------------------------------------------------------------------
   9. Ad slot — must never resemble a panel or a button
   -------------------------------------------------------------------------- */

.ad {
  border: 1px dashed var(--ad-border);
  background: var(--ad-well);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

/* Always labelled above the creative, never below. */
.ad-label {
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ad-creative {
  height: 200px;
  background: var(--hatch-ad);
}

.ad-note {
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   10. Catalog — dense, scannable
   -------------------------------------------------------------------------- */

.catalog-hero {
  padding-top: var(--sp-2xl);
  padding-bottom: var(--sp-xl);
}

.catalog-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.catalog-filters .field { flex: 0 1 auto; }
.catalog-filters input { width: 170px; }
.catalog-filters select { width: auto; }

.catalog-count {
  font-size: 14px;
  color: var(--text-muted);
  border-top: 1px solid var(--surface-sunken);
  padding-top: var(--sp-md);
  font-variant-numeric: tabular-nums;
}

.catalog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: var(--gutter);
  align-items: start;
  padding-bottom: var(--sp-xl);
}

.catalog-panel {
  border: 1px solid var(--border);
  background: var(--surface-raised);
}

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.catalog-table thead tr {
  text-align: left;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface);
}

.catalog-table th {
  padding: var(--sp-sm);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.catalog-table tbody {
  font-variant-numeric: tabular-nums;
}

.catalog-table tbody tr {
  border-bottom: 1px solid var(--surface-sunken);
  background: var(--surface-raised);
}

.catalog-table tbody tr:nth-child(even) { background: var(--row-zebra); }

/* With JS on, rows can be filtered out, so nth-child stops lining up and
   main.js applies .is-zebra to the visible rows instead. */
.catalog-table tbody.js-zebra tr:nth-child(even) { background: var(--surface-raised); }
.catalog-table tbody.js-zebra tr.is-zebra { background: var(--row-zebra); }

.catalog-table tbody tr:hover,
.catalog-table tbody.js-zebra tr:hover,
.catalog-table tbody.js-zebra tr.is-zebra:hover { background: var(--row-hover); }

.catalog-table td {
  padding: var(--sp-sm);
  vertical-align: top;
}

.catalog-table .col-name a { font-weight: 600; text-decoration: none; }
.catalog-table .col-name a:hover { text-decoration: underline; }
.catalog-table .col-dl { text-align: right; white-space: nowrap; }

.dl-size { display: none; }

.catalog-empty {
  padding: var(--sp-lg);
  font-size: 15px;
  color: var(--text-body);
  border-top: 1px solid var(--surface-sunken);
}

/* --------------------------------------------------------------------------
   11. Tool page — sparse, one job, one action
   -------------------------------------------------------------------------- */

.breadcrumb {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
}

.breadcrumb-inner {
  padding-top: var(--sp-md);
  padding-bottom: var(--sp-md);
}

.breadcrumb .sep { color: var(--border-strong); padding: 0 var(--sp-xs); }

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--content-width)) 1fr;
  gap: var(--sp-3xl);
  justify-content: center;
  align-items: start;
  padding-top: var(--sp-3xl);
  padding-bottom: var(--sp-3xl);
}

.tool-main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2xl);
}

.download-panel .meta-row {
  display: flex;
  justify-content: flex-end;
}

/* Placeholder for a real screenshot. Swap the <img> src, keep the ratio. */
.screenshot {
  border: 1px solid var(--border);
  background: var(--hatch);
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
}

.how-to-use {
  margin: 0;
  padding-left: var(--sp-xl);
  color: var(--text-body);
  line-height: 1.7;
}

/* --------------------------------------------------------------------------
   12. Single-column pages — about, contact
   -------------------------------------------------------------------------- */

.page-column {
  max-width: var(--content-width);
  margin: 0 auto;
  padding-top: var(--sp-3xl);
  padding-bottom: var(--sp-3xl);
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.page-column--tight { gap: var(--sp-2xl); }

/* --------------------------------------------------------------------------
   13. Tool picker on the contact form
   -------------------------------------------------------------------------- */

.combo { position: relative; }

.combo-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  max-height: 200px;
  overflow: auto;
}

.combo-list li {
  padding: 10px var(--sp-md);
  border-bottom: 1px solid var(--soft-hover);
  font-size: 15px;
  cursor: pointer;
}

.combo-list li:last-child { border-bottom: none; }
.combo-list li:hover,
.combo-list li[aria-selected="true"] { background: var(--row-hover); }

.combo-empty { color: var(--text-muted); font-size: 14px; cursor: default; }

/* --------------------------------------------------------------------------
   14. Toast — fired by the form handler once one is connected
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(560px, calc(100vw - 32px));
  display: flex;
  align-items: flex-start;
  gap: var(--sp-md);
  padding: 14px var(--sp-lg);
  border-radius: var(--radius);
  border: 1px solid var(--ok);
  background: #EDF1EC;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.toast[hidden] { display: none; }
.toast--error { border-color: var(--error); background: #F6EAE7; }
.toast strong { font-weight: 700; }

.toast-dismiss {
  margin-left: var(--sp-sm);
  font: inherit;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   15. Utilities
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   16. Responsive
   Catalog drops its sidebar below 1100px; everything else stacks below 900px.
   -------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .catalog-layout { grid-template-columns: 1fr; }

  /* Rows become cards: name, what it does, one meta line, one download button. */
  .catalog-table thead { display: none; }

  .catalog-table,
  .catalog-table tbody,
  .catalog-table tr,
  .catalog-table td { display: block; }

  .catalog-table tbody tr {
    padding: 14px;
    border-bottom: 1px solid var(--surface-sunken);
  }

  .catalog-table td { padding: 0; }

  .catalog-table .col-name a { font-size: 17px; font-weight: 700; }
  .catalog-table .col-does { font-size: 15px; line-height: 1.45; padding-top: var(--sp-xs); }

  /* The five spec cells collapse into one dotted meta line. */
  .catalog-table .col-meta {
    display: inline;
    font-size: 14px;
    color: var(--text-muted);
  }
  .catalog-table .col-meta:first-of-type { padding-top: var(--sp-xs); }
  .catalog-table .col-meta + .col-meta::before { content: " · "; }

  /* Same specificity as the separator rule above, and later, so these win.
     Reads: "Events & planning · 180 KB · v1.3 · 6 Aug 2026 · collects None". */
  .catalog-table .col-meta + .col-version::before { content: " · v"; }
  .catalog-table .col-meta + .col-data::before { content: " · collects "; }

  .catalog-table .col-dl {
    text-align: center;
    padding-top: 10px;
  }

  .catalog-table .col-dl a {
    display: block;
    min-height: 44px;
    background: var(--accent);
    color: #FFFFFF;
    border-radius: var(--radius);
    padding: 13px var(--sp-lg);
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    transition: background-color 80ms linear;
  }
  .catalog-table .col-dl a:hover { background: var(--accent-pressed); }

  .dl-size { display: inline; }
}

@media (max-width: 900px) {
  :root { --gutter: 14px; }

  .site-header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .site-nav { gap: var(--sp-lg); }

  /* 44px minimum target on a phone. */
  .site-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
  }

  .site-footer-inner { flex-direction: column; gap: 10px; }

  .page-title { font-size: 24px; }

  .catalog-hero { padding-top: 24px; padding-bottom: var(--sp-lg); }

  .tool-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .page-column { padding-top: 24px; padding-bottom: 24px; gap: var(--sp-2xl); }

  .catalog-filters { flex-direction: column; align-items: stretch; }
  .catalog-filters input,
  .catalog-filters select { width: 100%; }

  /* Key/value tables stack rather than squeeze. */
  .spec-table th,
  .spec-table td { display: block; width: auto; }
  .spec-table td { border-top: none; padding-top: 0; }
  .spec-table th { padding-bottom: var(--sp-xs); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
