/*
 * One stylesheet. No imports, no external fonts, no CDN links of any kind — everything
 * the page needs comes from this site's own files. That is the house rule the Peige
 * generator works to (`src/services/anthropic/prompts/build.ts`), and following it here
 * means a page written by hand and a page written by the agent are the same kind of
 * thing. It also happens to be what makes the site trivially cacheable offline.
 */

/* ── Tokens ────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light dark;

  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #1a1a19;
  --text-muted: #5d5c58;
  --border: #e3e0da;
  --accent: #1f5f4f;
  --accent-text: #ffffff;
  --focus: #1f5f4f;

  --measure: 34rem;
  --gap: 1.5rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14150f;
    --surface: #1c1e17;
    --text: #ece9e1;
    --text-muted: #a5a396;
    --border: #2f322a;
    --accent: #7fd0b4;
    --accent-text: #0e1712;
    --focus: #7fd0b4;
  }
}

/* ── Base ──────────────────────────────────────────────────────────────────── */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  /*
   * Belt and braces for iOS Safari, which still lets a long unbroken token (a URL in
   * body copy, say) widen the whole document and produce a horizontal scrollbar that
   * no amount of max-width fixes.
   */
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem);
}

h2 {
  font-size: clamp(1.35rem, 1.15rem + 0.9vw, 1.75rem);
  margin-top: 2.5rem;
}

h3 {
  font-size: 1.1rem;
  margin-top: 1.75rem;
}

p,
ul,
ol {
  margin: 0 0 1.1em;
  max-width: var(--measure);
}

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

a:hover {
  text-decoration-thickness: 2px;
}

/*
 * `:focus-visible` rather than `:focus` so a mouse click does not leave a ring behind,
 * but every keyboard tab stop is unmistakable. The outline is offset so it never sits
 * on top of the thing it is pointing at.
 */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 3px;
}

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

/* ── Layout ────────────────────────────────────────────────────────────────── */

.shell {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/*
 * A skip link that is genuinely reachable: hidden off-screen until focused, then
 * pinned where a keyboard user is already looking. `clip-path` rather than
 * `display: none`, because a display-none element cannot receive focus at all.
 */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.6rem 1rem;
  z-index: 10;
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-bottom: 2.5rem;
}

.site-header .shell {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.wordmark {
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

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

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

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/*
 * `aria-current="page"` is the accessible signal; this is only its visual echo. Marking
 * the current page with colour ALONE would leave a screen-reader user with no cue at
 * all, which is why the attribute is what the pages actually carry.
 */
.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

main {
  padding-bottom: 3.5rem;
}

.lede {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: var(--measure);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0 2.5rem;
  color: var(--text-muted);
  font-size: 0.925rem;
}

.site-footer p {
  margin: 0;
}

/* ── Components ────────────────────────────────────────────────────────────── */

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--gap);
  max-width: none;
}

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

.card h3 {
  margin-top: 0;
}

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

.meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
}

.button:hover {
  text-decoration: none;
  filter: brightness(1.08);
}

/*
 * The offline notice. Hidden by default and revealed by `sw.js` only when a navigation
 * has actually been served from the cache — so it states a fact rather than guessing
 * from `navigator.onLine`, which reports "online" for a captive portal that serves
 * nothing.
 */
.offline-note {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: var(--measure);
}

.offline-note[data-visible="true"] {
  display: block;
}

/* ── Motion ────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
