/* The whole site's styles. Project pages (src/projects/) bring their own. */

:root {
  --bg: #ffffff;
  --ink: #111111;
  --body: #444444;
  --muted: #555555;
  --rule: #d4d4d4;
  --accent: #c2361c;
  --code-bg: #f3f3f1;
  --sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --ink: #f2f2f2;
    --body: #c4c4c4;
    --muted: #a3a3a3;
    --rule: #333333;
    --accent: #ff7a5c;
    --code-bg: #1d1d1d;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
a:focus-visible {
  color: var(--accent);
}

.wrap {
  max-width: 1200px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 24px 64px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Top bar */

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font: 13px var(--mono);
}

.topbar nav {
  display: flex;
  gap: 24px;
}

.topbar nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Homepage hero */

.hero {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 24px;
  align-items: end;
}

.hero h1 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: clamp(72px, 14vw, 168px);
  font-weight: 800;
  line-height: 0.85;
  letter-spacing: -0.05em;
}

.intro {
  grid-column: 1 / span 6;
  margin: 0;
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.25;
  font-weight: 500;
}

/* Page heading (every page but the homepage) */

.page-head {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.page-intro {
  margin: 0;
  max-width: 640px;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.3;
  font-weight: 500;
  color: var(--body);
}

.eyebrow {
  margin: 0;
  font: 13px var(--mono);
  color: var(--muted);
}

/* The project list: one section per kind */

.work {
  display: flex;
  flex-direction: column;
  gap: 56px;
}

.work-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.work-heading {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* Row lists: projects (homepage) and posts (/writing) */

.works {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 2px solid var(--ink);
}

.works li {
  border-bottom: 1px solid var(--rule);
}

.project,
.entries a {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) minmax(0, 1.4fr) 200px 24px;
  gap: 16px;
  align-items: baseline;
  padding: 14px 0;
}

/* A project row is one big link: the title's link stretches over the row. */
.project {
  position: relative;
}

.project .title::after {
  content: '';
  position: absolute;
  inset: 0;
}

.project .title:focus-visible {
  outline: none;
}

.project .title:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.project:hover .title,
.project:hover .arrow {
  color: var(--accent);
}

.works .no {
  font: 13px var(--mono);
  color: var(--muted);
}

/* The project's picture: src/img/thumbs/<image>.jpg, or an empty tile when it has none. */
.project {
  grid-template-columns: 56px 128px minmax(0, 1.2fr) minmax(0, 1.2fr) 180px 24px;
}

.works .thumb {
  display: block;
  align-self: center;
  width: 100%;
  height: auto;
  aspect-ratio: 40 / 21;
  object-fit: cover;
  border-radius: 4px;
  background: var(--code-bg);
  box-shadow: 0 0 0 1px var(--rule);
}

.works .title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.works .blurb {
  font-size: 16px;
  color: var(--body);
}

.works .blurb p {
  margin: 0;
}

.works .kind {
  font: 12px/1.5 var(--mono);
  color: var(--muted);
  text-transform: uppercase;
}

.works .arrow {
  font-size: 18px;
  transition: transform 0.15s ease;
}

.project:hover .arrow,
.project:focus-within .arrow,
.entries a:hover .arrow,
.entries a:focus-visible .arrow {
  transform: translateX(4px);
}

.entries a {
  grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1.4fr) 24px;
}

/* Prose: about, posts, 404 */

.prose {
  max-width: 680px;
  font-size: 18px;
  line-height: 1.65;
  color: var(--body);
}

.prose > :first-child {
  margin-top: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 1.8em 0 0.5em;
}

.prose h1 { font-size: 34px; }
.prose h2 { font-size: 28px; }
.prose h3 { font-size: 22px; }
.prose h4 { font-size: 18px; }

.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.prose a:hover,
.prose a:focus-visible {
  color: var(--accent);
}

.prose strong {
  color: var(--ink);
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.3em;
}

.prose blockquote {
  margin: 1.5em 0;
  padding-left: 20px;
  border-left: 2px solid var(--ink);
  color: var(--muted);
}

.prose code {
  font: 0.85em var(--mono);
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.prose pre {
  background: var(--code-bg);
  padding: 16px 18px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.5;
}

.prose pre code {
  background: none;
  padding: 0;
}

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

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5em 0;
}

.prose table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  font-size: 16px;
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--rule);
  padding: 8px 12px 8px 0;
  text-align: left;
}

.post {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.back {
  margin: 0;
  font: 13px var(--mono);
}

/* Footer */

.foot {
  font: 13px var(--mono);
  color: var(--muted);
}

/* Phones */

@media (max-width: 760px) {
  .wrap {
    padding: 24px 16px 48px;
    gap: 32px;
  }

  .intro {
    grid-column: 1 / -1;
  }

  .project,
  .entries a {
    grid-template-columns: 36px minmax(0, 1fr) 20px;
    gap: 4px 12px;
  }

  /* On a phone the picture takes the number's column. */
  .project {
    grid-template-columns: 96px minmax(0, 1fr) 20px;
  }

  .project .no { display: none; }
  .works .thumb { grid-column: 1; grid-row: 1 / span 3; align-self: start; margin-top: 3px; }

  .works .no { grid-column: 1; grid-row: 1; }
  .works .title { grid-column: 2; grid-row: 1; font-size: 20px; }
  .works .arrow { grid-column: 3; grid-row: 1; }
  .works .blurb { grid-column: 2; grid-row: 2; font-size: 15px; }
  .works .kind { grid-column: 2; grid-row: 3; }

  /* Dates are too wide for the number column, so they get their own row. */
  .entries a {
    grid-template-columns: minmax(0, 1fr) 20px;
  }

  .entries .no { grid-column: 1; grid-row: 1; }
  .entries .title { grid-column: 1; grid-row: 2; }
  .entries .arrow { grid-column: 2; grid-row: 2; }
  .entries .blurb { grid-column: 1; grid-row: 3; }
}
