/* andreagemelli.me
   One typeface, one accent, zero radius. Everything else is space and rules. */

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #fbfaf7;
  --surface: #f1eee7;
  --line: #e2ded3;
  --line-soft: #ece8df;
  --text: #1b1a17;
  --muted: #57534a;
  --faint: #9c968a;
  --accent: #b4441f;
  --accent-soft: #f4e5de;

  --measure: 76ch;
  --pad: 2rem;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #131210;
  --surface: #1d1b17;
  --line: #302c26;
  --line-soft: #232019;
  --text: #ded9cd;
  --muted: #aca596;
  --faint: #635d53;
  --accent: #e0854f;
  --accent-soft: #2a1f17;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #131210;
    --surface: #1d1b17;
    --line: #302c26;
    --line-soft: #232019;
    --text: #ded9cd;
    --muted: #aca596;
    --faint: #635d53;
    --accent: #e0854f;
    --accent-soft: #2a1f17;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.75;
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip:focus {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  width: auto;
  height: auto;
  clip-path: none;
  background: var(--bg);
  border: 1px solid var(--accent);
  padding: 0.5rem 0.75rem;
}

/* ---------------------------------------------------------------- chrome */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  width: 100%;
  max-width: calc(var(--measure) + 8ch);
  margin-inline: auto;
  padding: 1.5rem var(--pad);
  font-size: 13.5px;
}

header.bar {
  min-height: 64px;
  border-bottom: 1px solid var(--line-soft);
}

.prompt {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5ch;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
}
.prompt .who {
  color: var(--text);
  font-weight: 700;
}
.prompt .sigil {
  color: var(--accent);
}
.prompt:hover .who {
  color: var(--accent);
}

.caret {
  display: inline-block;
  width: 0.6ch;
  height: 1.05em;
  translate: 0 0.15em;
  background: var(--accent);
  animation: blink 1.15s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

header nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
header nav a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
header nav a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

#theme {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  color: var(--faint);
  cursor: pointer;
}
#theme:hover {
  color: var(--accent);
}

footer.bar {
  margin-top: auto;
  padding-block: 2rem 3rem;
  color: var(--faint);
  border-top: 1px solid var(--line-soft);
}
footer.bar a {
  color: var(--faint);
}

main {
  width: 100%;
  max-width: calc(var(--measure) + 8ch);
  margin-inline: auto;
  padding: 4rem var(--pad) 5rem;
}

/* ---------------------------------------------------------------- prose */

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.12s ease;
}
a:hover {
  color: var(--accent);
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.35;
  text-wrap: balance;
  margin: 0;
}

h1 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

main p,
main ul,
main ol,
main blockquote,
main pre,
main table {
  max-width: var(--measure);
}

p {
  margin: 0 0 1.4em;
}

.lede {
  color: var(--muted);
  margin-bottom: 2rem;
}

strong {
  font-weight: 700;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 3rem 0;
}

/* Section heading with a hairline running to the right edge. */
.rule {
  display: flex;
  align-items: center;
  gap: 1ch;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.rule a {
  color: inherit;
  text-decoration: none;
}
.rule a:hover {
  color: var(--accent);
}
.rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.block {
  margin-top: 4.5rem;
}

/* ---------------------------------------------------------------- home */

.intro p {
  font-size: 1rem;
}
.intro p:last-child {
  margin-bottom: 0;
}

.social {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  padding: 0;
  margin: 0;
}
.social a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s ease, translate 0.12s ease;
}
.social a:hover {
  color: var(--accent);
  translate: 0 -2px;
}
.social svg {
  display: block;
  fill: currentColor;
}

/* ---------------------------------------------------------------- index */

.index {
  list-style: none;
  padding: 0;
  margin: 0;
}
.index li {
  display: grid;
  grid-template-columns: 2ch 1fr auto;
  gap: 0 1ch;
  align-items: baseline;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.index li:last-child {
  border-bottom: 0;
}
.index .bullet {
  color: var(--faint);
}
.index li > a {
  text-decoration: none;
  font-weight: 700;
}
.index li > a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.index time {
  color: var(--faint);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.index li p {
  grid-column: 2 / -1;
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.more {
  margin-top: 1.5rem;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- post */

.post header {
  margin-bottom: 3rem;
}
.post h1 {
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
}
.post .lede {
  font-size: 1rem;
  margin-bottom: 1rem;
}
.post .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--faint);
  margin: 0;
}
.post .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 1ch;
}
.post .tags span::before {
  content: '#';
  color: var(--line);
}
.post .draft {
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0 0.6ch;
}

.post h2 {
  font-size: 1.15rem;
  margin: 3.5rem 0 1rem;
}
.post h3 {
  font-size: 1rem;
  margin: 2.5rem 0 0.75rem;
}
.post h4 {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 2rem 0 0.5rem;
}

.post ul,
.post ol,
.page ul,
.page ol {
  padding-left: 3ch;
  margin: 0 0 1.4em;
}
.post li,
.page li {
  position: relative;
  margin-bottom: 0.5em;
}
.post ul,
.page ul {
  list-style: none;
}
.post ul > li::before,
.page ul > li::before {
  content: '-';
  color: var(--accent);
  position: absolute;
  left: -2ch;
}

blockquote {
  margin: 2rem 0;
  padding: 0 0 0 2ch;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}
blockquote p:last-child {
  margin-bottom: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface);
  padding: 0.1em 0.4em;
  border: 1px solid var(--line-soft);
}

pre {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
  margin: 2rem 0;
}
pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  margin: 2rem 0 0.75rem;
}

/* Markdown convention in these posts: an italic line on the row right after an
   image, inside the same paragraph, is that image's caption. Do NOT widen this
   to any lone <em> - inline emphasis mid-sentence matches :only-child too. */
.post img + em {
  display: block;
  color: var(--faint);
  font-size: 0.82rem;
  font-style: normal;
  margin-bottom: 2rem;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  margin: 2rem 0;
  display: block;
  overflow-x: auto;
}
th,
td {
  text-align: left;
  padding: 0.5rem 1ch 0.5rem 0;
  border-bottom: 1px solid var(--line-soft);
}
th {
  color: var(--muted);
  font-weight: 700;
}

/* ---------------------------------------------------------------- toc */

.toc {
  border-left: 1px solid var(--line);
  padding-left: 2ch;
  margin: 0 0 3.5rem;
  font-size: 0.85rem;
}
.toc-label {
  color: var(--faint);
  margin: 0 0 0.5rem;
}
.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc li {
  margin-bottom: 0.2rem;
}
.toc .toc-h3 {
  padding-left: 2ch;
}
.toc a {
  color: var(--muted);
  text-decoration: none;
}
.toc a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------------------------------------------------------------- footnotes */

.footnotes {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
}
.footnotes-sep {
  display: none;
}
.footnotes ol {
  padding-left: 3ch;
}
.footnotes p {
  margin-bottom: 0.5em;
}
.footnote-backref {
  text-decoration: none;
}

/* ---------------------------------------------------------------- pager */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.pager a {
  text-decoration: none;
  color: var(--muted);
}
.pager a:hover {
  color: var(--accent);
}
.pager span {
  display: block;
  color: var(--faint);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}
.pager .next {
  text-align: right;
}

/* ---------------------------------------------------------------- about */

.citation-section blockquote {
  border-left: 2px solid var(--accent);
  margin-top: 0;
}

.timeline {
  margin: 3rem 0 0;
  border-left: 1px solid var(--line);
  padding-left: 3ch;
}
.timeline-item {
  position: relative;
  padding-bottom: 3rem;
}
.timeline-item:last-child {
  padding-bottom: 0;
}
.timeline-header {
  display: flex;
  align-items: center;
  gap: 1ch;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.timeline-dot {
  position: absolute;
  left: calc(-3ch - 4px);
  top: 0.65em;
  width: 7px;
  height: 7px;
  background: var(--accent);
}
.timeline-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border: 0;
  margin: 0;
  opacity: 0.9;
}
.timeline-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  padding: 0;
  border: 0;
}
.timeline-date {
  color: var(--faint);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.timeline-content p {
  margin-bottom: 0.9em;
}
.timeline-location {
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
  padding-top: 0.6rem;
  line-height: 1.9;
}
.location-name {
  color: var(--text);
}
.location-role {
  color: var(--faint);
}

/* Section heads on prose pages get the same hairline rule as the index pages. */
.page > h2 {
  display: flex;
  align-items: center;
  gap: 1ch;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 4.5rem 0 1.5rem;
}
.page > h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------------------------------------------------------------- publications */

.pubs > h3 {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 3.5rem 0 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.pubs > h3 + hr {
  display: none;
}
.pubs > h3 + p {
  margin-top: 1.5rem;
}
.pubs > ul {
  padding-left: 0;
}
.pubs > ul > li::before {
  display: none;
}
.pubs > ul > li {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line-soft);
  margin: 0;
}
.pubs > ul > li > a:first-child {
  font-weight: 700;
  text-decoration: none;
}
.pubs > ul > li > a:first-child:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
/* Author line, then venue line. */
.pubs > ul > li p {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.pubs > ul > li p:last-child {
  color: var(--faint);
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 640px) {
  :root {
    --pad: 1.25rem;
  }
  body {
    font-size: 14.5px;
  }
  header.bar {
    padding-block: 1rem;
    gap: 0.75rem;
  }
  header nav {
    gap: 1.25rem;
    font-size: 13px;
  }
  main {
    padding-top: 2.5rem;
  }
  .post h1 {
    font-size: 1.4rem;
  }
  .index li {
    grid-template-columns: 2ch 1fr;
  }
  .index time {
    grid-column: 2;
    grid-row: 2;
  }
  .index li p {
    grid-row: 3;
  }
  .pager {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .pager .next {
    text-align: left;
  }
  .timeline-date {
    margin-left: 0;
    width: 100%;
  }
}

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

@media print {
  header.bar,
  footer.bar,
  .pager,
  .toc {
    display: none;
  }
}
