/* ==========================================================================
   site.css — design tokens, layout, components
   Minimal & typographic. System fonts only: they render instantly, work
   offline, and Iowan Old Style / New York look genuinely good on iPad.
   ========================================================================== */

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

:root {
  --font-display: ui-serif, "Iowan Old Style", "New York", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ground: #faf9f7;
  --surface: #ffffff;
  --ink: #17160f;
  --ink-soft: #57544c;
  --ink-faint: #8d8981;
  --rule: #e3dfd7;
  --accent: #8a3d1f;
  --accent-soft: #f4ece6;

  --gutter: clamp(1.25rem, 5vw, 4.5rem);
  --measure: 36rem;
  --radius: 4px;

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  /* Safe areas — iPad notch / home indicator. Fall back to 0 elsewhere. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #12110e;
    --surface: #1a1915;
    --ink: #f2efe8;
    --ink-soft: #a8a49a;
    --ink-faint: #76736b;
    --rule: #2e2c26;
    --accent: #d98b63;
    --accent-soft: #2a211b;
  }
}

:root[data-theme="dark"] {
  --ground: #12110e;
  --surface: #1a1915;
  --ink: #f2efe8;
  --ink-soft: #a8a49a;
  --ink-faint: #76736b;
  --rule: #2e2c26;
  --accent: #d98b63;
  --accent-soft: #2a211b;
}

/* --- Reset ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;   /* stop iOS inflating text in landscape */
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, video { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }

/* Visible focus for keyboard users — never removed, only shaped. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- Typography ----------------------------------------------------------- */

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.25rem, 6vw, 4rem); }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.25rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); }

p { margin: 0 0 1.15em; text-wrap: pretty; }

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

/* For headings set in caps — same reasoning as .wordmark. */
.caps { letter-spacing: 0.04em; }

.lede {
  font-size: clamp(1.1rem, 2.1vw, 1.375rem);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: var(--measure);
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 1.25rem;
}

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

/* --- Layout --------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: calc(var(--gutter) + var(--safe-l));
  padding-inline-end: calc(var(--gutter) + var(--safe-r));
}

.section { padding-block: clamp(3.5rem, 9vw, 7rem); }
.section + .section { border-top: 1px solid var(--rule); }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--ground);
  padding: 0.75rem 1.25rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
  padding-top: var(--safe-t);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.75rem;
}

/* Set in caps, so it takes positive tracking — the tight negative spacing
   that flatters mixed-case makes uppercase look jammed together. */
.wordmark {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-decoration: none;
  white-space: nowrap;
}

.nav { display: flex; gap: 0.25rem; align-items: center; }

/* 44px minimum touch target — Apple's HIG floor. Non-negotiable on iPad. */
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.7rem;
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--ink-soft);
  border-radius: var(--radius);
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}
.nav a:hover { color: var(--ink); background: var(--accent-soft); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

@media (max-width: 30rem) {
  .nav a { padding: 0 0.5rem; font-size: 0.875rem; }
}

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

.hero { padding-block: clamp(4rem, 13vw, 9rem) clamp(3rem, 8vw, 5.5rem); }
.hero h1 { max-width: 18ch; }
.hero .lede { margin-top: 1.5rem; }

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.4rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--ground);
  cursor: pointer;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.btn:hover { opacity: 0.86; color: var(--ground); }
.btn:active { transform: translateY(1px); }

.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--ghost:hover { color: var(--ink); border-color: var(--ink); background: transparent; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

/* --- Work grid ------------------------------------------------------------ */

.grid {
  display: grid;
  gap: clamp(1.5rem, 3.5vw, 2.75rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.card:hover { border-color: var(--ink-faint); }

/* Whole card is the tap target — matters a lot on a touch screen. */
.card a.card__hit {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.card a.card__hit:hover { color: inherit; }

.card__media {
  aspect-ratio: 16 / 10;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--rule);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__media .placeholder {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent);
  opacity: 0.55;
}

.card__body { padding: 1.25rem 1.35rem 1.5rem; flex: 1; }
.card__meta {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.45rem;
}
.card__title { font-size: 1.1875rem; margin: 0 0 0.4rem; }
.card__desc { font-size: 0.9375rem; color: var(--ink-soft); margin: 0; line-height: 1.55; }

/* --- Definition-style list (about page) ----------------------------------- */

.deflist { display: grid; gap: 1.75rem; margin: 2.5rem 0 0; }
@media (min-width: 46rem) {
  .deflist { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 2.5rem; }
}
.deflist h3 { font-size: 1.0625rem; margin-bottom: 0.35rem; }
.deflist p { font-size: 0.9375rem; color: var(--ink-soft); margin: 0; }

/* --- Contact list --------------------------------------------------------- */

.links { list-style: none; margin: 2rem 0 0; padding: 0; }
.links li + li { border-top: 1px solid var(--rule); }
.links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
  padding: 0.5rem 0;
  text-decoration: none;
  font-size: 1.0625rem;
}
.links a span:last-child { color: var(--ink-faint); font-size: 0.875rem; }
.links a:hover span:last-child { color: var(--accent); }

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

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: 2.5rem;
  padding-bottom: calc(2.5rem + var(--safe-b));
  font-size: 0.875rem;
  color: var(--ink-faint);
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: space-between;
  align-items: center;
}
.site-footer a { color: var(--ink-soft); }

/* --- Utilities ------------------------------------------------------------ */

.stack > * + * { margin-top: 1.25rem; }
.center-narrow { max-width: var(--measure); margin-inline: auto; text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
