/*
 * bradgessler.com. Plain CSS, no build step: native nesting and custom
 * properties. Black on white, one grid, and type tuned for reading.
 */

:root {
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --paper: #fff;
  --ink: #111;
  --text: #1d1d1d;
  --quiet: #636363;
  --line: #e6e6e6;
  --rule: #cfcfcf;
  --wash: #f4f4f4;

  /* Breakpoints (custom properties can't be used in media queries):
     56em stacks the grid, 42em is phones. */
  --gutter: 2rem;

  @media (prefers-color-scheme: dark) {
    --paper: #111;
    --ink: #f2f2f2;
    --text: #e4e4e4;
    --quiet: #a2a2a2;
    --line: #2a2a2a;
    --rule: #3a3a3a;
    --wash: #1c1c1c;
  }

  @media only screen and (max-width: 42em) {
    --gutter: 1.25rem;
  }
}

/* The root size drives every rem: 18px on desktop, 17px on phones. */
html {
  font-size: 112.5%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
  background-color: var(--paper);

  @media only screen and (max-width: 42em) {
    font-size: 106.25%;
  }
}

body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a {
  &, &:visited, &:active {
    color: var(--ink);
    text-decoration: none;
  }

  &:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
  }
}

strong, b {
  font-weight: 700;
  color: var(--ink);
}

em, i {
  font-style: italic;
}

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 700;
  text-wrap: balance;
}

img {
  max-width: 100%;
}

/*
 * The grid: a label column on the left, content on the right, rows
 * separated by a hairline. Stacks on narrow screens.
 */
.swiss {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.swiss--row {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 2rem;
  padding: 3.25rem 0;
  border-top: 1px solid var(--rule);

  &:first-child {
    border-top: none;
  }

  @media only screen and (max-width: 56em) {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 2rem 0;
  }
}

h2.swiss--label {
  padding-top: 0.3em;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--quiet);
}

p, li {
  text-wrap: pretty;
}

/* Top of every page but home: the name, and a jump to the footer's nav. */
header.site-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem var(--gutter) 0;
}

a.site-top--name {
  font-weight: 700;
}

/* Homepage intro: who Brad is, at a glance. */
header.intro {
  padding: 6rem 0 4.5rem;
  align-items: start;

  @media only screen and (max-width: 56em) {
    grid-template-columns: 6rem minmax(0, 1fr);
    gap: 1.25rem;
    padding: 3rem 0 2.5rem;
  }
}

.intro--headshot {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  filter: grayscale(1);
}

h1.intro--name {
  margin-top: -0.12em;
  font-size: clamp(2.75rem, 7vw, 5.5rem);
  line-height: 0.92;
  font-weight: 800;
  letter-spacing: -0.05em;
}

p.intro--statement {
  max-width: 34rem;
  margin-top: 1.5rem;
  font-size: clamp(1.3rem, 2.3vw, 1.85rem);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);

  a, a:visited, a:active {
    text-decoration: underline;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.16em;
  }
}

header.intro .social {
  margin-top: 2rem;
}

/* Track record: one bold fact and one quiet line per column. */
.proof--list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 2.5rem 2.5rem;
}

p.proof--label {
  font-size: 0.85rem;
  font-weight: 600;

  a, a:visited, a:active {
    color: var(--quiet);
  }
}

p.proof--fact {
  margin-top: 0.35rem;
  font-size: 1.35rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

p.proof--note {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--quiet);
}

/* Lately: what Brad is up to, like a /now page. */
p.lately {
  max-width: 36rem;
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--ink);
}

p.lately--updated {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--quiet);
}

/* On narrow screens the headshot sits beside the name; text spans below. */
@media only screen and (max-width: 56em) {
  .intro--text {
    grid-column: 1 / -1;
  }
}

/* Project cards: screenshot, name, one-liner. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 2.5rem 1.5rem;
}

a.card {
  display: block;

  &:hover {
    text-decoration: none;

    h3 {
      text-decoration: underline;
      text-decoration-thickness: 1px;
      text-underline-offset: 0.18em;
    }
  }
}

.card--image {
  display: block;
  width: 100%;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  border: 1px solid var(--line);
}

h3.card--title {
  margin-top: 0.75rem;
  font-size: 1rem;
}

.card--subtitle {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--quiet);
}

.card--year {
  margin-left: 0.5rem;
  font-weight: 400;
  color: var(--quiet);
  font-variant-numeric: tabular-nums;
}

/* Lists: a title and a quiet note, one per row. */
.list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);

  &:first-child {
    padding-top: 0;
  }

  @media only screen and (max-width: 42em) {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.list--meta {
  color: var(--quiet);
  text-align: right;
  font-variant-numeric: tabular-nums;

  @media only screen and (max-width: 42em) {
    text-align: left;
  }
}

p.more {
  margin-top: 1rem;
  font-weight: 700;
}

/* Index pages: Projects, Writing, Talks, Timeline. */
h1.page-header--title {
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.page-header--subtitle {
  max-width: 34rem;
  margin-top: 0.75rem;
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--quiet);
}

h2.timeline--year {
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.timeline li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);

  &:first-child {
    padding-top: 0;
  }
}

.timeline--kind {
  color: var(--quiet);
  font-size: 0.85rem;
  line-height: 1.75;
}

.timeline--started .timeline--body > a {
  font-weight: 700;
}

.timeline--note {
  display: block;
  color: var(--quiet);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Reading pages: articles, About, talks, chapters. */
.page-header--reading h1.page-header--title {
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  max-width: 22em;
}

.page-header--date {
  display: block;
  color: var(--quiet);
  font-size: 0.9rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.feature-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: 1.25rem;
  font-weight: 700;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 1px solid var(--rule);
  font-weight: 700;
}

/* Project pages */
.project-hero--role {
  color: var(--quiet);
  font-size: 0.9rem;
  line-height: 1.4;
}

h1.project-hero--title {
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.project-hero--tagline {
  max-width: 36rem;
  margin-top: 0.75rem;
  font-size: 1.25rem;
  line-height: 1.45;
}

a.project-hero--cta, .project-hero--visit a {
  display: inline-block;
  margin-top: 1.25rem;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.project-hero--image {
  img {
    display: block;
    width: 100%;
    max-width: none;
    border: 1px solid var(--line);
  }

  figcaption {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--quiet);
  }
}

/*
 * Prose: an article body. ~66 characters a line, 1.7 leading, generous
 * space above headings, and links underlined so they're easy to spot.
 */
.prose {
  max-width: 66ch;
  color: var(--text);
  line-height: 1.7;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;

  & > * {
    margin-bottom: 1.25em;
  }

  & > p:first-child {
    font-size: 1.2rem;
    line-height: 1.6;
  }

  h2 {
    margin: 2.25em 0 0.6em;
    font-size: 1.5rem;
    line-height: 1.25;
    letter-spacing: -0.015em;
  }

  h3 {
    margin: 1.9em 0 0.5em;
    font-size: 1.2rem;
    line-height: 1.35;
  }

  h4 {
    margin: 1.6em 0 0.4em;
    font-size: 1rem;
  }

  a, a:visited, a:active {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  }

  a:hover {
    text-decoration-color: currentColor;
  }

  ul, ol {
    padding-left: 1.5em;

    li {
      margin: 0.4em 0;
      padding-left: 0.25em;
    }

    li::marker {
      color: var(--quiet);
    }
  }

  ul li {
    list-style-type: disc;
  }

  ol li {
    list-style-type: decimal;
    font-variant-numeric: tabular-nums;
  }

  li > ul, li > ol {
    margin: 0.4em 0;
  }

  blockquote {
    padding-left: 1.25em;
    border-left: 3px solid var(--rule);
    color: var(--quiet);

    p {
      margin-bottom: 0.75em;
    }

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

  code {
    padding: 0.12em 0.35em;
    background-color: var(--wash);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 0.85em;
    overflow-wrap: anywhere;
  }

  pre {
    margin: 1.75em 0;
    padding: 1.25em 1.5em;
    background-color: var(--wash);
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    overflow-wrap: normal;

    code {
      padding: 0;
      background: none;
      font-size: inherit;
      overflow-wrap: normal;
    }
  }

  img, video, iframe {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2em 0;
  }

  iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
  }

  hr {
    margin: 3em 0;
    border: none;
    border-top: 1px solid var(--rule);
  }

  table {
    width: 100%;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;

    th, td {
      padding: 0.5em 0.75em 0.5em 0;
      border-bottom: 1px solid var(--line);
      vertical-align: top;
      text-align: left;
    }

    th {
      font-weight: 700;
      color: var(--ink);
    }
  }
}

/* Site nav and social icons, used in the footer. */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;

  a.is-current {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.25em;
  }
}

.social {
  display: flex;
  gap: 1.25rem;
  margin-top: 1.25rem;

  a {
    display: inline-flex;

    &:hover {
      color: var(--quiet);
    }
  }
}

/* Footer: on every page. Brad's mug, a short bio, socials, and the nav. */
footer.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
}

.site-footer--inner {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr) 10rem;
  gap: 2rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 4rem;

  @media only screen and (max-width: 56em) {
    grid-template-columns: 4.5rem minmax(0, 1fr);
    gap: 1.25rem;

    .site-nav {
      grid-column: 2;
    }
  }
}

.site-footer--mug {
  width: 6rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  filter: grayscale(1);

  @media only screen and (max-width: 56em) {
    width: 100%;
  }
}

p.site-footer--bio {
  max-width: 30rem;
  line-height: 1.5;
}

a.site-footer--more {
  display: inline-block;
  margin-top: 0.5rem;
  font-weight: 700;
}

footer.site-footer .site-nav {
  flex-direction: column;
  gap: 0.35rem;

  @media only screen and (max-width: 56em) {
    flex-direction: row;
    gap: 0.25rem 1.25rem;
  }
}

/*
 * Phones: the headshot and name center on the page. The statement stays
 * left-aligned (centered paragraphs are hard to read), as a block that
 * shares the page's center line.
 */
@media only screen and (max-width: 42em) {
  header.intro {
    display: flex;
    flex-direction: column;
    align-items: center;

    .intro--headshot {
      width: 7.5rem;
      border-radius: 50%;
    }

    .intro--text {
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    h1.intro--name {
      text-align: center;
    }

    p.intro--statement {
      text-align: left;
    }
  }
}
