/* Home page */

html {
  padding: var(--margin) var(--gutter);
}

body {
  position: relative;
  max-width: 1200px;
  margin-inline: auto;
  box-shadow: 0px 0px 48px rgba(0, 0, 0, 0.8);
}

h1 {
  font-family: "Editorial New", serif;
  font-size: 80px;
  font-style: normal;
  font-weight: 300;
  line-height: 80px;
  letter-spacing: 0;
  margin-top: -9px;
}

h2 {
  font-family: "Neue Haas Grotesk Text", "Helvetica Neue", sans-serif;
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 24px;
  letter-spacing: -0.14px;
  margin-top: 4px;
}

.grid > div > p {
  margin-top: 4px;
}

.display-text {
  font-family: "Editorial New", serif;
  font-size: 18px;
  font-style: normal;
  font-weight: 300;
  line-height: 32px;
  letter-spacing: 0;
  margin-bottom: -12px;
}

.grid > .display-container {
  padding-top: 12px;
}

.display-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Buttons carry 3px of padding above the line so their hover shape is
   centred on the capitals; the margin keeps the text on the baseline */
.display-container button {
  margin-top: -3px;
}

.display-link {
  font-family: "Editorial New", serif;
  font-size: 18px;
  font-style: normal;
  font-weight: 300;
  line-height: 32px;
  letter-spacing: 0;
  position: relative;
}

.display-link:focus-visible, .content-link:focus-visible {
  outline: unset;
}

/* Icons beside display text. Being empty boxes, their bottom edge
   sits on the text baseline */
.display-link::after,
.theme-icon,
.grid-icon,
.contact-icon {
  --icon: none;
  width: 10px;
  height: 10px;
  background-color: currentColor;
  -webkit-mask: var(--icon) no-repeat center / contain;
  mask: var(--icon) no-repeat center / contain;
}

.display-link::after {
  --icon: url(link-arrow.svg);
  content: "";
  display: inline-block;
  margin-left: 6px;
}

/* The page controls get larger icons, about the height of the capitals */
.display-button > span {
  width: 14px;
  height: 14px;
}

.theme-icon {
  --icon: url(theme-circle.svg);
}

.grid-icon {
  --icon: url(grid.svg);
}

.contact-icon {
  --icon: url(email.svg);
}

.display-link:hover::before,
.display-link:focus-visible::before,
.display-button:hover,
.display-button:focus-visible,
.content-link:hover::before,
.content-link:focus-visible::before {
  -moz-box-shadow:
    inset -1px -1px 1px 0 var(--hover-highlight),
    inset 1px 1px 4px 0 var(--hover-shadow);
  -webkit-box-shadow:
    inset -1px -1px 1px 0 var(--hover-highlight),
    inset 1px 1px 4px 0 var(--hover-shadow);
  box-shadow:
    inset -1px -1px 1px 0 var(--hover-highlight),
    inset 1px 1px 4px 0 var(--hover-shadow);
}

.display-link:focus-visible::before,
.display-button:focus-visible,
.content-link:focus-visible::before {
  outline: 1px solid rgb(var(--ink));
}

.display-link:hover::before,
.display-link:focus-visible::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -12px;
  right: -12px;
  bottom: 0;
  border-radius: 32px;
  z-index: 0;
}

.display-button {
  font-family: "Editorial New", serif;
  font-size: 18px;
  font-style: normal;
  font-weight: 300;
  line-height: 32px;
  letter-spacing: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  position: relative;
  color: currentColor;
  background-color: unset;
  border: unset;
  padding: 3px 12px 0;
  margin-left: -12px;
  border-radius: 32px;
  cursor: pointer;
}

.grid-active {
  color: rgb(var(--red));
}

/* Layout */


/* The page uses the same columns as the grid overlay in base.css */
.grid {
  --min-height: var(--module);
  display: grid;
  grid-template-columns: var(--columns);
  column-gap: var(--gutter);
  padding-inline: var(--margin);
  padding-block: var(--margin);
  background-color: rgb(var(--paper));
  border-radius: 4px;
}

/* Blocks are at least one module tall and grow with their content */
.grid > div {
  min-height: var(--min-height);
  padding-top: 10px;
}

/* Where supported, grown blocks snap up to the next baseline */
@supports (min-height: calc-size(fit-content, size)) {
  .grid > div {
    min-height: calc-size(
      fit-content,
      round(up, max(size, var(--min-height)), var(--baseline))
    );
  }
}

.label,
.body {
  border-top: 1px solid rgb(var(--ink));
}

.body {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.body > p {
  padding-bottom: var(--baseline);
}

.body:has(.talks) {
  padding-top: 0;
}

.tall {
  --min-height: calc(2 * var(--module));
}

.footer {
  --min-height: calc(6 * var(--baseline));
  display: flex;
  align-items: flex-end;
}

.footer .display-link {
  margin-bottom: -12px;
}

/* A heading at the bottom of a block, introducing the next group.
   Its text sits on the last baseline before the next rule. */
.group-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: var(--gutter);
}

.group-heading h2 {
  margin-top: -1px;
  margin-bottom: 9px;
}

/* Cancel the link's own padding so it lines up with the heading beside it */
.group-heading .content-link {
  margin-block: -13px -11px;
}

/* Links */
.content-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 11px 0;
  position: relative;
}

.content-link:hover::before,
.content-link:focus-visible::before {
  content: "";
  position: absolute;
  top: 4px;
  left: -12px;
  right: -12px;
  bottom: 4px;
  border-radius: 24px;
  z-index: 0;
}

/* Talks & writing */
.talks {
  container-type: inline-size;
  list-style: none;
}

.talks li:not(:first-child) {
  border-top: 1px solid rgb(var(--ink));
}

.talk {
  display: grid;
  grid-template-areas: "title source meta";
  grid-template-columns: minmax(0, auto) minmax(max-content, 1fr) auto;
  gap: 0 8px;
}

.talk-title {
  grid-area: title;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.talk-source {
  grid-area: source;
}

.talk-meta {
  grid-area: meta;
}

.talk-meta::after {
  content: "";
  display: inline-block;
  height: 12px;
  width: 12px;
  margin-left: 8px;
  background-color: currentColor;
  -webkit-mask: url(content-link-arrow.svg) no-repeat center;
  mask: url(content-link-arrow.svg) no-repeat center;
}

/* When the list is narrow, each talk becomes a small copy of a section:
   the type and year as a label, then the title and source as running text */
@container (width < 640px) {
  .talk,
  .talk-meta {
    display: block;
  }

  /* Two or more lines: sit them on the baseline rather than centring */
  .talk {
    padding-block: 14px 17px;
  }

  /* A tighter corner suits the taller hover shape */
  .talk:hover::before,
  .talk:focus-visible::before {
    border-radius: 12px;
  }

  .talk-title {
    white-space: normal;
  }
}

/* Small screens: one column, blocks as tall as their content */
@media (width < 800px) {
  html {
    padding: calc(2 * var(--baseline));
  }

  .grid {
    padding-inline: var(--gutter);
  }

  .grid > div {
    grid-column: auto;
  }

  .grid > div:not(.footer) {
    --min-height: 0px;
  }

  /* The name and the two link lists: padded up to a whole 8px step.
     The lists end up 40px apart, one baseline more than a display line */
  .grid > div:first-child {
    padding-bottom: 7px;
  }

  .display-container {
    padding-bottom: 4px;
  }

  .display-container:has(.display-button) {
    padding-bottom: 20px;
  }

  /* A section is one rule, its label, then its text. The offsets make
     every block a multiple of the 24px line height, so each line of text
     sits on a baseline with or without calc-size() */
  .label {
    padding-bottom: 9px;
  }

  .grid > .body {
    border-top: 0;
    padding-top: 11px;
  }

  .grid > .body:has(.talks) {
    padding-top: 0;
  }

  .body > p {
    padding-bottom: calc(4 * var(--baseline) + 1px);
  }

  .talks li:first-child {
    border-top: 1px solid rgb(var(--ink));
  }

  .group-heading {
    margin-top: calc(3 * var(--baseline));
  }

  .group-heading .content-link {
    margin-top: -12px;
  }

  .grid-display > div:not(:first-child) {
    display: none;
  }
}

/* The narrowest phones: "Daggett" at 80px is wider than the column.
   At 70px the capitals are 56px tall, seven baselines */
@media (width < 340px) {
  h1 {
    font-size: 70px;
    line-height: 72px;
    margin-top: -2px;
  }

  .grid > div:first-child {
    padding-bottom: 0;
  }
}
