/*
 * Brewed Software site styles.
 * Tokens are copied from design/tokens.css (spec: design/tokens.md). Keep them in step.
 * Light is the default; dark follows the OS.
 */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light;
  --color-bg: #faf6ef;            /* crema */
  --color-surface: #f3eadb;       /* cream (logo) */
  --color-text: #1f1a17;          /* ink (logo) */
  --color-text-muted: #5e524a;
  --color-accent: #7a4a24;        /* coffee (logo) */
  --color-accent-contrast: #faf6ef;
  --color-border: #ddd0bc;        /* decorative dividers only */
  --color-border-strong: #8a7a6c; /* outlines that must be seen (3:1) */
  --logo-ink: #1f1a17;
  --logo-coffee: #7a4a24;

  /* Type: system stacks only, no web-font requests */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Type scale, ratio 1.25 on a 16px root; display sizes are fluid */
  --text-sm: 0.875rem;                                   /* 14 */
  --text-base: 1.0625rem;                                /* 17, body */
  --text-lead: 1.25rem;                                  /* 20, hero subhead */
  --text-h3: 1.25rem;                                    /* 20 */
  --text-h2: clamp(1.625rem, 1.3rem + 1.4vw, 2.125rem);  /* 26 → 34 */
  --text-h1: clamp(2.25rem, 1.6rem + 3vw, 3.5rem);       /* 36 → 56 */
  --leading-tight: 1.15;
  --leading-body: 1.6;
  --tracking-tight: -0.02em;
  --weight-regular: 400;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Spacing, 4px base */
  --space-1: 0.25rem;  /* 4 */
  --space-2: 0.5rem;   /* 8 */
  --space-3: 0.75rem;  /* 12 */
  --space-4: 1rem;     /* 16 */
  --space-5: 1.5rem;   /* 24 */
  --space-6: 2rem;     /* 32 */
  --space-7: 3rem;     /* 48 */
  --space-8: 4rem;     /* 64 */
  --space-9: 6rem;     /* 96, between page sections on desktop */

  /* Layout */
  --width-content: 68rem;  /* 1088, page container */
  --width-prose: 40rem;    /* 640, paragraphs */
  --gutter: clamp(1rem, 4vw, 2rem);

  /* Shape */
  --radius-sm: 6px;   /* buttons */
  --radius-md: 12px;  /* cards */
  --radius-full: 999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --color-bg: #17120f;            /* dark roast */
    --color-surface: #221b17;
    --color-text: #f3eadb;          /* cream (logo) */
    --color-text-muted: #b8a998;
    --color-accent: #c08552;        /* dark-mode coffee (logo) */
    --color-accent-contrast: #17120f;
    --color-border: #3b312a;
    --color-border-strong: #7d6d60;
    --logo-ink: #f3eadb;
    --logo-coffee: #c08552;
  }
}

/* ---------- Base ---------- */

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

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  overflow-wrap: break-word;
}

main {
  flex: 1;
}

h1,
h2,
h3 {
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--weight-bold);
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: var(--color-accent);
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

[id] {
  scroll-margin-top: var(--space-5);
}

.wrap {
  max-width: var(--width-content);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Hidden visually, still read by screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-5)));
}

.skip-link:focus {
  transform: none;
}

/* ---------- Header ---------- */

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  padding-block: var(--space-5);
}

/* Lockup: inline mark + wordmark (see design/tokens.md) */
.lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.lockup svg {
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
}

.lockup .ink { fill: var(--logo-ink); }
.lockup .coffee { fill: var(--logo-coffee); }
.lockup b { font-weight: var(--weight-bold); }
.lockup span { font-weight: var(--weight-regular); }

.site-header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}

.site-header nav a {
  display: inline-block;
  padding-block: var(--space-2);
  color: var(--color-text-muted);
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ---------- Hero ---------- */

.hero {
  padding-block: var(--space-8) var(--space-9);
}

.hero h1 {
  font-size: var(--text-h1);
  max-width: 18ch;
  margin-bottom: var(--space-5);
}

.accent {
  color: var(--color-accent);
}

.lead {
  font-size: var(--text-lead);
  color: var(--color-text-muted);
  max-width: var(--width-prose);
  margin-bottom: var(--space-6);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-5);
}

.btn {
  display: inline-block;
  padding: var(--space-3) var(--space-5);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.btn:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.link {
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.link:hover {
  text-decoration-thickness: 2px;
}

.link-lg {
  font-size: var(--text-lead);
}

/* ---------- Sections ---------- */

.section {
  padding-block: var(--space-8);
  border-top: 1px solid var(--color-border);
}

.section h2 {
  font-size: var(--text-h2);
  margin-bottom: var(--space-6);
}

/* What we do */
.cards {
  display: grid;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.card h3 {
  font-size: var(--text-h3);
  margin-bottom: var(--space-2);
}

.card p {
  color: var(--color-text-muted);
}

/* How we work */
.steps {
  display: grid;
  gap: var(--space-6) var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  padding-top: var(--space-4);
  border-top: 2px solid var(--color-border-strong);
  color: var(--color-text-muted);
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-accent);
}

.steps strong {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-h3);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
}

/* Contact */
.contact {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}

.contact h2 {
  margin-bottom: var(--space-4);
}

.contact p {
  max-width: var(--width-prose);
  margin-inline: auto;
  color: var(--color-text-muted);
}

.contact p + p {
  margin-top: var(--space-5);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.site-footer .wrap {
  padding-block: var(--space-6);
}

.site-footer a {
  color: inherit;
  text-underline-offset: 0.2em;
}

.site-footer a:hover {
  color: var(--color-text);
}

/* ---------- Text pages (about, privacy) ---------- */

.hero-page {
  padding-block: var(--space-8) var(--space-6);
}

.prose > * {
  max-width: var(--width-prose);
}

.legal h2 {
  font-size: var(--text-lead);
  margin-block: var(--space-6) var(--space-3);
}

.legal h2:first-child {
  margin-top: 0;
}

.prose p {
  margin-bottom: var(--space-4);
}

/* About: text plus a map that links out to Google Maps. The map is inline SVG generated from
   OpenStreetMap data by scripts/salem-map.py, so the page makes no third-party requests. */
.about {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

.map-figure {
  max-width: 28rem;
  margin: 0;
}

.map {
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.map:hover {
  border-color: var(--color-accent);
}

.map svg {
  display: block;
  width: 100%;
  height: auto;
}

.map-water,
.map-pond { fill: color-mix(in srgb, #5b7f95 24%, var(--color-bg)); }
.map-land { fill: var(--color-surface); stroke: color-mix(in srgb, #5b7f95 45%, var(--color-bg)); stroke-width: 0.75; stroke-linejoin: round; }
.map-roads { fill: none; stroke: var(--color-bg); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.map-pin path { fill: var(--color-accent); }
.map-pin circle { fill: var(--color-bg); }
.map-tag { fill: var(--color-bg); stroke: var(--color-border-strong); stroke-width: 1; }

.map-label,
.map-place {
  font-family: var(--font-sans);
  fill: var(--color-text);
}

.map-label {
  font-size: 15px;
  font-weight: var(--weight-semibold);
}

.map-place {
  font-size: 11px;
  fill: var(--color-text-muted);
  paint-order: stroke;
  stroke: var(--color-surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.map-place-water {
  font-style: italic;
  fill: color-mix(in srgb, #5b7f95 70%, var(--color-text));
  stroke: none;
}

.map-credit {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.map-credit a {
  color: inherit;
}

.updated {
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ---------- 404 ---------- */

.hero-404 {
  padding-block: var(--space-8);
}

/* HTCPCP joke (RFC 2324): the response is still a 404. */
.eyebrow {
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.eyebrow s {
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
}

/* ---------- Larger screens ---------- */

@media (min-width: 48em) {
  .section {
    padding-block: var(--space-9);
  }

  .contact {
    padding: var(--space-8) var(--space-6);
  }

  .steps {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 60em) {
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .steps {
    grid-template-columns: repeat(4, 1fr);
  }

  .about {
    grid-template-columns: minmax(0, 1fr) minmax(0, 28rem);
  }
}
