/* Break the rule: the only stylesheet of the site.
   No external fonts or frameworks: the CSP allows styles from this site only (see docs/09-security.md). */

:root {
  color-scheme: light dark;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #55524c;
  --line: #d9d5cc;
  --accent: #b8321b;
  --on-accent: #ffffff;
  --focus: #1d4ed8;
  --radius: 10px;
  --measure: 68ch;
  --wrap: 72rem;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Every color pair meets WCAG 2.2 AA (4.5:1 or more) in both themes; see docs/02-how-it-works.md. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --surface: #1e1e1e;
    --text: #f1efe9;
    --muted: #a9a59c;
    --line: #34322e;
    --accent: #ff8466;
    --on-accent: #141414;
    --focus: #93b4ff;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.5rem, 7vw, 4.75rem);
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
}

h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.25rem);
  margin: 0 0 1rem;
}

h3,
.h3 {
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
}

p {
  margin: 0 0 1rem;
  max-width: var(--measure);
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.08em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.wrap {
  width: min(100% - 2rem, var(--wrap));
  margin-inline: auto;
}

/* Hidden until focused, so keyboard users can jump past the navigation. */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
}

.skip-link:focus {
  top: 1rem;
}

/* Header and navigation */

.site-header {
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand svg {
  width: 2rem;
  height: 2rem;
}

.mark-line {
  stroke: currentColor;
}

.mark-break {
  stroke: var(--accent);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding-block: 0.4rem;
  color: var(--text);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.16em;
}

/* Language menu: short codes, the current language filled */

.lang-nav ul {
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lang-nav a {
  display: inline-block;
  min-width: 2.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
}

.lang-nav a:hover {
  border-color: var(--text);
}

.lang-nav a[aria-current="true"] {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

/* On a phone the language menu sits next to the logo and the main menu takes the next line. */
@media (max-width: 40rem) {
  .lang-nav {
    order: 1;
  }

  .site-nav {
    order: 2;
    width: 100%;
  }

  .lang-nav a {
    min-width: 0;
    padding: 0.3rem 0.45rem;
    font-size: 0.78rem;
  }
}

/* Sections */

.section {
  padding-block: clamp(3rem, 8vw, 6rem);
  border-bottom: 1px solid var(--line);
}

.section:last-child {
  border-bottom: 0;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  font-size: clamp(1.2rem, 2.4vw, 1.5rem);
  line-height: 1.45;
  max-width: 40ch;
}

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

/* A second level heading inside a page section, such as "How we choose" on /projects. */
.subhead {
  margin-top: 2.5rem;
  font-size: 1.5rem;
}

/* The hero sits on ruled lines, and the drawing on the right breaks one of them: the idea of the site. */
.hero {
  background-image: repeating-linear-gradient(to bottom, transparent 0 2.4rem, var(--line) 2.4rem calc(2.4rem + 1px));
}

.hero .wrap {
  position: relative;
}

.hero-break {
  position: absolute;
  right: 0;
  top: 50%;
  width: min(32vw, 20rem);
  height: auto;
  transform: translateY(-50%);
  color: var(--text);
}

.hero-text {
  position: relative;
  max-width: 44rem;
}

/* The home headline is a full sentence, so it is set smaller than a one-line title. */
.hero-title {
  font-size: clamp(2.1rem, 5.2vw, 3.6rem);
}

/* A solid background behind the text keeps the ruled lines from lowering its contrast. */
.hero-text > * {
  width: fit-content;
  background: var(--bg);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.6rem 1.25rem;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  text-decoration: underline;
}

.button.secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--text);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* The four steps of the cycle */

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 2rem 0 1rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.steps li::before {
  content: "Step " counter(step);
  display: block;
  margin-bottom: 0.5rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.steps li:last-child {
  border: 2px solid var(--accent);
}

.steps p {
  margin: 0;
}

/* Cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.card {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card p:last-child {
  margin-bottom: 0;
}

.card h3 a {
  color: var(--text);
  text-decoration-color: var(--accent);
}

.tag {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 2rem 3rem;
  align-items: start;
}

.rules {
  margin: 0;
  padding-left: 1.25rem;
}

.rules li {
  margin-bottom: 0.6rem;
  max-width: var(--measure);
}

.rules li::marker {
  color: var(--accent);
  font-weight: 700;
}

.callout {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  background: var(--surface);
  border: 2px solid var(--text);
  border-radius: var(--radius);
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Text pages (guides, contribute, privacy) */

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

.prose h2 {
  margin-top: 2.5rem;
  font-size: 1.5rem;
}

.prose ul {
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

/* Contact form */

.form {
  display: grid;
  gap: 0.75rem;
  max-width: 40rem;
}

.form label {
  font-weight: 600;
}

.form textarea {
  width: 100%;
  min-height: 10rem;
  padding: 0.75rem;
  border: 2px solid var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.form textarea:focus-visible {
  border-color: var(--focus);
}

.form .button {
  justify-self: start;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.form-status {
  min-height: 1.6em;
  margin: 0;
  font-weight: 600;
}

/* Home page search: a dark band in both themes, so the search bar is the first thing anyone sees.
   The tokens are redefined here, so every color pair inside still meets WCAG 2.2 AA. */

.search-hero {
  --bg: #141414;
  --surface: #1e1e1e;
  --text: #f1efe9;
  --muted: #a9a59c;
  --line: #2e2c29;
  --accent: #ff8466;
  --on-accent: #141414;
  --focus: #93b4ff;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(to bottom, transparent 0 2.4rem, var(--line) 2.4rem calc(2.4rem + 1px));
  color: var(--text);
  border-bottom: 0;
}

.search-hero .hero-title {
  max-width: 18ch;
  font-size: clamp(2.4rem, 6.4vw, 4.6rem);
  font-weight: 800;
}

.search-hero .lede {
  max-width: 46ch;
  color: var(--muted);
}

/* "Legally." sits on a broken, rising underline: the rule, broken. */
.accent-word {
  color: var(--accent);
  white-space: nowrap;
  background-image: linear-gradient(-8deg, transparent 0 40%, var(--accent) 40% 52%, transparent 52%);
  background-size: 100% 0.5em;
  background-repeat: no-repeat;
  background-position: 0 100%;
  padding-bottom: 0.08em;
}

.search input::placeholder {
  color: #55524c;
}

.results {
  margin-top: 1rem;
}

.card {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.12);
  transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card:hover {
    transition: none;
    transform: none;
  }
}

/* Home page search */

.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;
}

.search {
  display: flex;
  gap: 0.5rem;
  max-width: 44rem;
  margin: 2rem 0 0.75rem;
}

.search input {
  flex: 1;
  min-width: 0;
  min-height: 3.25rem;
  padding: 0.6rem 1.25rem;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #ffffff;
  color: #1a1a1a;
  box-shadow: 0 0.75rem 2.5rem rgb(0 0 0 / 0.35);
  font: inherit;
  font-size: 1.1rem;
}

.search input:focus-visible {
  outline-offset: 2px;
}

.search .button {
  min-height: 3.25rem;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 1.25rem 0 1.5rem;
}

.examples ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  min-height: 2.5rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--muted);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

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

.results .actions {
  gap: 0.5rem;
  margin-top: 1rem;
}

.results .button {
  min-height: 2.5rem;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

details p {
  margin-top: 0.5rem;
}

@media (max-width: 30rem) {
  .search {
    flex-direction: column;
  }
}

/* Footer */

.site-footer {
  padding-block: 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.site-footer p {
  margin: 0;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

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

@media (max-width: 52rem) {
  .hero-break {
    display: none;
  }
}

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

@media print {
  .site-nav,
  .lang-nav,
  .skip-link,
  .actions,
  .hero-break {
    display: none;
  }

  .hero {
    background: none;
  }
}
