/*
 * Small accessibility-focused overrides on top of Bootstrap 5.3 defaults.
 * Bootstrap's default --bs-link-color and --bs-secondary-color sit right
 * at (or just under) the WCAG 2.2 AA contrast floor of 4.5:1 for normal
 * text on a white background. These overrides push both comfortably
 * above 4.5:1 while staying visually close to Bootstrap's own palette.
 */

:root {
  /* Serif pairing in the spirit of Stripe Press: Newsreader for titles,
     labels, and buttons; Source Serif 4 for running text. */
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --bs-body-font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --bs-link-color: #0a58ca;
  --bs-link-hover-color: #084298;
  --bs-secondary-color: #495057;
}

[data-bs-theme='dark'] {
  --bs-link-color: #6ea8fe;
  --bs-link-hover-color: #9ec5fe;
}

/* Visible focus outline that doesn't rely on Bootstrap's box-shadow alone. */
a:focus-visible,
input:focus-visible {
  outline: 3px solid #0a58ca;
  outline-offset: 2px;
}

[data-bs-theme='dark'] a:focus-visible,
[data-bs-theme='dark'] input:focus-visible {
  outline-color: #6ea8fe;
}

/* Square corners everywhere, including Bootstrap components, avatars,
   and anything rendered from README/bio markdown. */
*,
*::before,
*::after {
  border-radius: 0 !important;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1030;
  padding: 0.5rem 1rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
}

.repo-card.d-none {
  display: none !important;
}

/* Narrow, book-page-like column. Widens while the PDF pane is open so
   the index and the PDF still fit side by side. */
.page-width {
  max-width: 1040px;
}

body:has(#pdf-pane:not(.d-none)) .page-width {
  max-width: 1320px;
}

/* Menu bar directly under the header, drawn with the same 1px lines as
   the repo rows: a cell per issue link on the left, search in the right
   cell. On phones the search takes its own row below the links. */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--bs-body-color);
  font-family: var(--font-display);
}

.site-nav-search {
  flex: 1 1 100%;
  border-top: 1px solid var(--bs-body-color);
}

.site-nav-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  background: none;
  color: var(--bs-body-color);
  font: inherit;
  font-size: 0.9375rem;
}

.site-nav-input::placeholder {
  font-style: italic;
  color: var(--bs-secondary-color);
}

input.site-nav-input:focus-visible {
  outline-offset: -3px;
}

.site-nav-links {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav-links > li {
  border-right: 1px solid var(--bs-body-color);
}

.site-nav-link {
  display: block;
  padding: 0.5rem 0.9rem;
  color: var(--bs-body-color);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

.site-nav-link:hover {
  color: var(--bs-body-color);
  text-decoration: underline;
}

a.site-nav-link:focus-visible {
  outline-offset: -3px;
}

@media (min-width: 768px) {
  .site-nav-search {
    flex: 0 1 18rem;
    border-top: 0;
    border-left: 1px solid var(--bs-body-color);
  }
}

/* Room above an issue heading reached from the menu bar. */
.issue-heading {
  scroll-margin-top: 1.5rem;
}

/* Issue groups, laid out like a book listing (see renderIssue in
   assets/index.js): image on the left, title block and index on the
   right. */
.issue-group + .issue-group {
  margin-top: 5rem;
}

/* Sticky so it stays beside the index while it scrolls. */
.issue-image {
  display: block;
  width: 100%;
  height: auto;
  position: sticky;
  top: 1rem;
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.2);
}

/* On phones the image sits above the title, so keep it cover-sized. */
@media (max-width: 767.98px) {
  .issue-image {
    position: static;
    max-width: 14rem;
  }
}

/* When the PDF pane is open the index is too narrow for two columns, so
   the index takes the full width and the image is hidden. */
@media (min-width: 992px) {
  #index-pane.col-lg-5 .issue-image-col {
    display: none;
  }
  #index-pane.col-lg-5 .issue-content.col-md-7 {
    width: 100%;
  }
  /* Room below the index so even the last row can scroll to the top
     beside the PDF (see the .read-pdf-btn click handler in assets/pdf-reader.js). */
  #index-pane.col-lg-5 {
    padding-bottom: calc(100vh - 8rem);
  }
}

.issue-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.85rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-bottom: 0.15rem;
}

.issue-byline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  margin-bottom: 0;
}

/* Short rule under the title block. */
.issue-rule {
  width: 2.75rem;
  margin: 1.25rem 0 1.75rem;
  border-top: 1px solid currentColor;
  opacity: 0.6;
}

.issue-description {
  font-size: 0.9375rem;
  line-height: 1.6;
  max-width: 34rem;
  margin-bottom: 2.25rem;
}

/* Italic serif label above each section's index. */
.section-group + .section-group {
  margin-top: 1.75rem;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.7rem;
  margin-bottom: 0.6rem;
}

/* Section color from data/issues.json, as a small swatch before the
   label. */
.section-swatch {
  width: 0.6rem;
  height: 0.6rem;
  background: var(--section-color);
}

/* Condensed index of repos within a section (see renderCard in
   assets/index.js): a stack of bordered rows, each a disclosure button
   with an arrow cell on the right. */
.repo-index {
  max-width: 34rem;
  border: 1px solid var(--bs-body-color);
}

/* Breathing room when a row is scrolled to the top on opening its PDF
   (see the .read-pdf-btn click handler in assets/pdf-reader.js). */
.repo-card {
  scroll-margin-top: 1rem;
}

.repo-card + .repo-card {
  border-top: 1px solid var(--bs-body-color);
}

.repo-heading {
  margin: 0;
  font-size: 0.875rem;
}

.repo-toggle {
  display: flex;
  align-items: stretch;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bs-body-color);
  font-family: var(--font-display);
  text-align: left;
}

.repo-toggle-title {
  padding: 0.5rem 0 0.5rem 0.75rem;
  font-weight: 600;
}

.repo-toggle-authors {
  flex: 1 1 auto;
  padding: 0.5rem 0.75rem 0.5rem 0.6rem;
  font-weight: 400;
}

.repo-toggle:hover,
.repo-card.is-expanded .repo-toggle {
  background: var(--bs-tertiary-bg);
}

.is-expanded h4.repo-heading {
  border-bottom: 1px solid #000;
}

.repo-toggle:focus-visible {
  outline: 3px solid #0a58ca;
  outline-offset: -3px;
}

[data-bs-theme='dark'] .repo-toggle:focus-visible {
  outline-color: #6ea8fe;
}

/* Right-hand arrow cell. The inner span is a small chevron that points
   down when collapsed and up when expanded. */
.repo-toggle-icon {
  flex: 0 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--bs-body-color);
}

.repo-toggle-icon > span {
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.1rem) rotate(45deg);
  transition: transform 0.15s ease;
}

.repo-toggle[aria-expanded='true'] .repo-toggle-icon > span {
  transform: translateY(0.1rem) rotate(-135deg);
}

@media (prefers-reduced-motion: reduce) {
  .repo-toggle-icon > span {
    transition: none;
  }
}

.repo-panel {
  padding: 0.75rem 0.75rem 1rem;
  border-top: 1px solid var(--bs-border-color);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Minimal outline buttons (Read the PDF, View on GitHub), matching the
   bordered repo rows: label on the left, arrow in its own cell. */
.outline-btn {
  display: inline-flex;
  align-items: stretch;
  padding: 0;
  border: 1px solid var(--bs-body-color);
  background: none;
  color: var(--bs-body-color);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
}

.outline-btn-label {
  padding: 0.35rem 0.75rem;
}

.outline-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  border-left: 1px solid var(--bs-body-color);
}

.outline-btn-icon svg {
  fill: currentColor;
}

.outline-btn:hover {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
}

.outline-btn:hover .outline-btn-label {
  text-decoration: underline;
}

.outline-btn:focus-visible {
  outline: 3px solid #0a58ca;
  outline-offset: 2px;
}

[data-bs-theme='dark'] .outline-btn:focus-visible {
  outline-color: #6ea8fe;
}

.repo-toggle .badge {
  font-size: 0.65em;
  vertical-align: middle;
}

header {
  background-color: #fff;
}

body {
  background-color: #fff;
}

/* Keep display-math typeset by MathJax from overflowing narrow panels. */
.repo-panel mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

/* Highlights the repo row whose "Read the PDF" button opened the
   currently-open PDF pane. Cleared as soon as the pane closes (see
   assets/pdf-reader.js), so at most one row ever carries this class. */
.repo-card.is-reading {
  box-shadow: inset 4px 0 0 var(--bs-primary);
}

/* Transitions when the PDF pane opens and closes (see withTransition in
   assets/pdf-reader.js). The pane slides in from the right and back out;
   the row being read keeps the default glide to its new position; the
   rest of the page cross-fades. Skipped entirely under reduced motion. */
#pdf-pane {
  view-transition-name: pdf-pane;
}

::view-transition-group(*) {
  animation-duration: 0.55s;
  animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

::view-transition-old(pdf-pane) {
  animation: 0.45s cubic-bezier(0.4, 0, 1, 1) both pdf-pane-out;
}

::view-transition-new(pdf-pane) {
  animation: 0.55s cubic-bezier(0, 0, 0.2, 1) both pdf-pane-in;
}

/* Moving from one open PDF to another: swap the pane in place, no slide
   (.pdf-swap is set by withTransition). */
.pdf-swap::view-transition-old(pdf-pane) {
  display: none;
}

.pdf-swap::view-transition-new(pdf-pane) {
  animation: none;
}

@keyframes pdf-pane-in {
  from {
    opacity: 0;
    transform: translateX(3rem);
  }
}

@keyframes pdf-pane-out {
  to {
    opacity: 0;
    transform: translateX(3rem);
  }
}

/* Right-hand PDF reading pane, opened by a repo card's "Read the PDF"
   button. Sticky so it stays in view while the (now-narrower) index
   scrolls beside it. */
#pdf-pane {
  position: sticky;
  top: 1rem;
  height: calc(100vh - 2rem);
}

.pdf-pane-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Full-screen PDF pane (see toggleFullscreen in assets/pdf-reader.js):
   the browser's full screen, or the .is-fullscreen fallback pinned over
   the window. */
#pdf-pane:fullscreen,
#pdf-pane.is-fullscreen {
  padding: 1rem 1.5rem;
  background: var(--bs-body-bg);
}

#pdf-pane.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1055;
  width: 100% !important;
  height: 100dvh;
}

/* Holds one <canvas> per rendered PDF page (see assets/pdf-reader.js). */
.pdf-pages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--bs-border-color);
  padding: 0.5rem;
  background: var(--bs-secondary-bg);
}

.pdf-page {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 0.75rem;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.pdf-page:last-child {
  margin-bottom: 0;
}

/* Author bio modal (see openBio in assets/index.js). A native <dialog>,
   so focus trapping and Escape-to-close come from the browser. */
.bio-modal {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--bs-body-color);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.3);
}

/* Padding lives here, not on the <dialog>, so a click on the dialog
   element itself is always a backdrop click. */
.bio-modal-inner {
  position: relative;
  padding: 2.5rem;
}

@media (max-width: 575.98px) {
  .bio-modal-inner {
    padding: 2.5rem 1.25rem 1.5rem;
  }
}

.bio-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

/* Title block matches the issue heading: bold serif name, italic
   byline, short rule (.issue-rule), then the bio text. */
.bio-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.85rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.15rem;
}

.bio-byline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  margin-bottom: 0;
}

.bio-byline:empty {
  display: none;
}

.bio-content {
  font-size: 0.9375rem;
  line-height: 1.6;
}

.bio-content h1,
.bio-content h2,
.bio-content h3 {
  font-family: var(--font-display);
  font-weight: 700;
}

.bio-modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.bio-content > :last-child {
  margin-bottom: 0;
}

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

.bio-image {
  display: block;
  width: 100%;
  height: auto;
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.2);
}

.site-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Masthead (see the header in index.html): shield and title block on the
   left, the interactive surface plot from assets/math-logo.js on the
   right, framed with the same 1px lines as the menu bar. Stacks on
   phones. */
.masthead-inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.masthead-lockup {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
}

.masthead-shield {
  flex: none;
  width: auto;
  height: 4.5rem;
}

.masthead-text {
  padding-left: 1.25rem;
  border-left: 1px solid var(--bs-body-color);
  min-width: 0;
}

.masthead-eyebrow {
  margin-bottom: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.masthead .site-title {
  margin-bottom: 0.4rem;
  font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem);
  line-height: 1.1;
}

.masthead-tagline {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--bs-secondary-color);
}

.math-logo {
  flex: none;
  width: 100%;
  max-width: 20rem;
  margin: 0;
  /* border: 1px solid var(--bs-body-color); */
  background: #fff;
  cursor: crosshair;
}

.math-logo:focus-visible {
  outline: 3px solid #0a58ca;
  outline-offset: 2px;
}

.math-logo-svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 340 / 205;
  padding: 0.5rem 0.5rem 0;
}

.math-logo-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 0.75rem;
  padding: 0.35rem 0.6rem;
  border-top: 1px solid var(--bs-body-color);
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}

.math-logo-readout {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .masthead-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .math-logo {
    width: 17.5rem;
  }
}
