/* ---------------------------------------------------------------------------
   The pieces neither cosmo nor darkly brings along.

   Everything here works through Bootstrap variables (var(--bs-…)) rather than
   fixed colours. That way every rule holds in both modes, and the toggle only
   has to swap the theme — not this stylesheet as well.
   --------------------------------------------------------------------------- */

/* --- Front-page header --------------------------------------------------- */
.intro {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 2.25rem;
  align-items: start;
  margin: .5rem 0 3rem;
}
.intro img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 50%;
}
.intro h1 { margin-top: 0; font-size: 1.9rem; }
.intro .role {
  color: var(--bs-secondary-color);
  font-size: 1.05rem;
  margin-bottom: 1rem;
}
.intro .elsewhere {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .5rem;
}
.intro .elsewhere a {
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  padding: .18rem .8rem;
  font-size: .88rem;
  text-decoration: none;
}
.intro .elsewhere a:hover {
  border-color: var(--bs-primary);
  color: var(--bs-primary);
}

/* On a phone the portrait sits above the text, not beside it. */
@media (max-width: 620px) {
  .intro { grid-template-columns: 1fr; gap: 1.25rem; }
  .intro img { width: 130px; height: 130px; }
}

/* --- The three works ----------------------------------------------------- */
.works {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin: 1.25rem 0 2.5rem;
}
@media (max-width: 820px) { .works { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .works { grid-template-columns: 1fr; } }

.work-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bs-body-bg);
  transition: border-color .15s ease, transform .15s ease;
}
.work-card:hover { border-color: var(--bs-primary); transform: translateY(-2px); }

.work-card .cover {
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bs-tertiary-bg);
}
.work-card .cover img { width: 100%; height: 100%; object-fit: cover; }

/* countimp has no cover — a wordmark stands in its place. */
.work-card .cover.code {
  background: linear-gradient(160deg, var(--bs-primary) 0%, var(--bs-body-bg) 165%);
  color: #fff;
  font-family: var(--bs-font-monospace);
  font-size: 1.45rem;
  letter-spacing: .02em;
  flex-direction: column;
  gap: .35rem;
}
.work-card .cover.code .sub {
  font-size: .78rem;
  opacity: .85;
  font-family: var(--bs-body-font-family);
  letter-spacing: 0;
}

.work-card .body { padding: .9rem 1rem 1.1rem; flex: 1 1 auto; }
.work-card .body .kind {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--bs-secondary-color);
}
.work-card .body h3 {
  font-size: 1.02rem;
  margin: .3rem 0 .35rem;
  line-height: 1.35;
}
.work-card .body h3 a { text-decoration: none; }
.work-card .body p {
  font-size: .87rem;
  color: var(--bs-secondary-color);
  margin: 0;
}

/* --- Small helpers ------------------------------------------------------- */
.section-rule {
  border: 0;
  border-top: 1px solid var(--bs-border-color);
  margin: 2.75rem 0 1.25rem;
}
.lead-note {
  font-size: .9rem;
  color: var(--bs-secondary-color);
  border-left: 3px solid var(--bs-border-color);
  padding-left: .9rem;
  margin: 1rem 0 1.75rem;
}
.more-link { font-size: .92rem; }

/* Publication list: years as quiet markers rather than large headings — with
   36 entries the page otherwise turns into a staircase. */
.pub-list h3 {
  font-size: .8rem;
  letter-spacing: .09em;
  text-transform: none;
  color: var(--bs-secondary-color);
  border-bottom: 1px solid var(--bs-border-color);
  padding-bottom: .3rem;
  margin: 2rem 0 1rem;
}
.pub-list p { margin-bottom: .85rem; }

/* --- Book pages ---------------------------------------------------------- */
.book-head {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 2rem;
  align-items: start;
  margin-bottom: 2rem;
}
.book-head img {
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 14px rgba(0,0,0,.16);
}
@media (max-width: 620px) {
  .book-head { grid-template-columns: 1fr; }
  .book-head img { max-width: 210px; }
}
.book-head .meta {
  font-size: .9rem;
  color: var(--bs-secondary-color);
  margin: .75rem 0 1rem;
}
/* --- Button row ----------------------------------------------------------
   Used on the book pages, the countimp page and under Teaching. Deliberately
   NOT scoped to .book-head: it was once, and the same markup then rendered as
   bare links everywhere else. */
.buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.5rem; }
.buttons a {
  border: 1px solid var(--bs-primary);
  color: var(--bs-primary);
  border-radius: 5px;
  padding: .3rem .9rem;
  font-size: .9rem;
  text-decoration: none;
  white-space: nowrap;
}
.buttons a:hover { background: var(--bs-primary); color: var(--bs-body-bg); }
.book-head .buttons { margin: 0; }

.intro-text, .book-text { min-width: 0; }

/* --- BibTeX buttons in the reference lists --------------------------------
   Hidden until assets/bibtex.js sets .js-bibtex on <html>. A button that
   cannot do anything is worse than no button. */
.bibtex-btn { display: none; }
.js-bibtex .bibtex-btn {
  display: inline;
  border: 1px solid var(--bs-border-color);
  background: transparent;
  color: var(--bs-secondary-color);
  border-radius: 4px;
  padding: 0 .42rem;
  margin-left: .35rem;
  font-size: .72rem;
  line-height: 1.5;
  letter-spacing: .03em;
  vertical-align: .08em;
  cursor: pointer;
  /* The list is the content; the button is a tool. It should be reachable,
     not loud — so it only takes on the accent colour under the cursor. */
  transition: color .12s ease, border-color .12s ease;
}
.js-bibtex .bibtex-btn:hover,
.js-bibtex .bibtex-btn:focus-visible {
  color: var(--bs-primary);
  border-color: var(--bs-primary);
}
.js-bibtex .bibtex-btn.is-done {
  color: var(--bs-primary);
  border-color: var(--bs-primary);
}

/* Shown only when every copy route was refused. */
.bibtex-fallback {
  margin: .5rem 0 1rem;
  padding: .65rem .8rem;
  font-size: .78rem;
  border-left: 3px solid var(--bs-primary);
  background: var(--bs-tertiary-bg);
  white-space: pre-wrap;
  user-select: all;
}
