:root {
  --bg: #fff;
  --ink: #111;
  --muted: #555;
  --line: #e5e5e5;
  --header: #111;
  --header-ink: #fff;
  --link: #0b57d0;
  --focus: #111;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max: 70rem;
  --measure: 42rem;
  --radius: 0.4rem;
}

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

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--serif);
  font-size: clamp(1.05rem, 0.95rem + 0.35vw, 1.175rem);
  line-height: 1.7;
  font-weight: 400;
  overflow-x: clip;
  max-width: 100vw;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 40;
  background: #fff;
  color: #111;
  border: 2px solid #111;
  padding: 0.5rem 0.75rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header);
  color: var(--header-ink);
  border-bottom: 1px solid #000;
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.brand {
  min-width: 0;
  flex: 1 1 auto;
}

.brand-mark {
  margin: 0;
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: clamp(0.72rem, 0.65rem + 0.5vw, 0.9rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.brand-sub {
  margin: 0.15rem 0 0;
  color: #cfcfcf;
  font-family: var(--sans);
  font-size: 0.75rem;
}

.toolbar {
  display: flex;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.lang-btn {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.85rem;
  border: 1px solid #666;
  background: transparent;
  color: #fff;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}

.lang-btn[aria-pressed="true"] {
  background: #fff;
  color: #111;
  border-color: #fff;
}

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  display: grid;
  grid-template-columns: minmax(10.5rem, 14rem) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  width: 100%;
  min-width: 0;
}

.toc-wrap {
  position: sticky;
  top: 3.6rem;
  max-height: calc(100vh - 4.2rem);
  overflow: auto;
  padding-right: 0.25rem;
  border-right: 1px solid var(--line);
}

.toc-label {
  margin: 0 0 0.4rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc {
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.35;
}

.toc a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 0.28rem 0.35rem;
  border-radius: 0.25rem;
}

.toc a:hover,
.toc a:focus {
  color: var(--ink);
  background: #f3f3f3;
  outline: none;
}

.anthology {
  max-width: calc(var(--measure) + 9rem);
  min-width: 0;
  width: 100%;
  padding: 0.25rem 0 1rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.anthology > :first-child { margin-top: 0; }

.anthology h1 {
  font-family: var(--sans);
  font-size: clamp(1.35rem, 1.05rem + 1.2vw, 2rem);
  line-height: 1.25;
  margin: 0 0 0.85rem;
  letter-spacing: -0.02em;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.anthology h2 {
  font-family: var(--sans);
  font-size: clamp(1.28rem, 1.1rem + 0.75vw, 1.65rem);
  line-height: 1.28;
  margin: 2.15rem 0 0.85rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: 4.25rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* Markdown --- before ## would double the section rule */
.anthology hr:has(+ h2) {
  display: none;
}

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

.anthology h3 {
  font-family: var(--sans);
  font-size: 1.05rem;
  margin: 1.4rem 0 0.5rem;
  font-weight: 700;
}

.anthology p,
.anthology li {
  max-width: var(--measure);
  overflow-wrap: break-word;
}

.anthology blockquote {
  margin: 0 0 1.1rem;
  padding: 0.65rem 0.85rem;
  border-left: 3px solid #111;
  background: #f7f7f7;
  color: var(--muted);
  max-width: var(--measure);
  overflow-wrap: break-word;
}

.anthology a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

.anthology a.person-jump {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: #bbb;
}

.anthology a.person-jump:hover {
  color: var(--link);
  text-decoration-color: var(--link);
}

.anthology table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
  margin: 1rem 0 1.4rem;
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.anthology th,
.anthology td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.5rem;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.anthology th {
  font-family: var(--sans);
  background: #f5f5f5;
  text-align: left;
}

.person-card {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.85rem 1rem;
  align-items: start;
  margin: 1.25rem 0;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
  max-width: calc(var(--measure) + 9rem);
  min-width: 0;
}

.context-card {
  margin: 1.25rem 0;
  padding: 0.85rem 0 0.85rem;
  border-top: 1px solid var(--line);
  max-width: calc(var(--measure) + 9rem);
}

.context-card > p {
  margin: 0;
  max-width: var(--measure);
}

.context-card > p > strong:first-child {
  font-family: var(--sans);
}

.person-card + .person-card {
  margin-top: 0;
}

.person-card:last-child {
  border-bottom: 1px solid var(--line);
}

.person-media {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.person-media-item {
  min-width: 0;
  scroll-margin-top: 4.25rem;
}

.person-body {
  min-width: 0;
}

.person-body > :first-child { margin-top: 0; }
.person-body > :last-child { margin-bottom: 0; }
.person-body p,
.person-body li {
  max-width: none;
}

.person-body ul,
.person-body ol {
  margin: 0.45rem 0 0;
  padding-left: 1.15rem;
}

.portrait {
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.portrait-name {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.portrait-zoom {
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: #ececec;
  cursor: zoom-in;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
  position: relative;
  flex: 0 0 auto;
}

.portrait-zoom:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
}

.portrait figcaption {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-family: var(--sans);
  font-size: 0.65rem;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.portrait figcaption a {
  color: inherit;
}

.portrait-credit {
  margin: 0;
}

.portrait-missing {
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  border: 1px dashed #ccc;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.45rem;
  font-family: var(--sans);
  font-size: 0.68rem;
  color: var(--muted);
  background: #fafafa;
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.portrait-missing-label {
  display: block;
}

.photos-note {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0 1rem;
  max-width: var(--measure);
}

.quick-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  margin: 0 0 1.15rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.82rem;
  background: #fafafa;
  max-width: calc(var(--measure) + 2rem);
}

.quick-nav-label {
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}

.quick-nav a {
  color: var(--link);
}

.table-wrap {
  margin: 1rem 0 1.4rem;
  max-width: 100%;
  min-width: 0;
}

.table-wrap .anthology table,
.table-wrap table {
  margin: 0;
}

.table-rotate-hint {
  display: none;
  margin: 0 0 0.45rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  align-items: center;
  gap: 0.35rem;
}

.table-rotate-icon {
  display: inline-flex;
  width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border: 1px solid #bbb;
  border-radius: 0.3rem;
  font-size: 0.95rem;
  line-height: 1;
}

.grades-details {
  margin: 0.5rem 0 1.2rem;
  max-width: var(--measure);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem 0.75rem;
  background: #fafafa;
}

.grades-details summary {
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.45rem 0;
  list-style: none;
}

.grades-details summary::-webkit-details-marker {
  display: none;
}

.grades-details summary::before {
  content: "▸ ";
  color: var(--muted);
}

.grades-details[open] summary::before {
  content: "▾ ";
}

.grades-details p,
.grades-details li {
  max-width: none;
}

.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: 1px solid #333;
  background: #111;
  color: #fff;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.18);
}

.back-to-top[hidden] {
  display: none !important;
}

.back-to-top:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.lightbox-meta .portrait-name {
  color: #fff;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.loading {
  color: var(--muted);
  font-family: var(--sans);
}

.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  overflow-wrap: anywhere;
}

.site-footer a { color: var(--link); }

/* Lightbox */
.lightbox[hidden] { display: none !important; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.88);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.lightbox-dialog {
  width: min(96vw, 56rem);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.lightbox-img {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  background: #000;
  border-radius: 0.25rem;
}

.lightbox-meta {
  color: #ddd;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.lightbox-meta a { color: #fff; }

.lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: 1px solid #777;
  background: #111;
  color: #fff;
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}

.lightbox-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .page {
    grid-template-columns: 1fr;
    padding: 0.85rem 0.85rem 2rem;
  }

  /* Mobile: hide section TOC — it crowds the UI */
  .toc-wrap {
    display: none !important;
  }

  .anthology {
    max-width: none;
  }

  .person-card {
    max-width: none;
    grid-template-columns: 6.25rem minmax(0, 1fr);
    gap: 0.7rem;
  }

  .anthology p,
  .anthology li,
  .anthology blockquote {
    max-width: none;
  }

  .table-rotate-hint {
    display: flex;
  }

  .quick-nav {
    max-width: none;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 1.02rem;
    line-height: 1.65;
  }

  .header-inner {
    padding: 0.65rem 0.75rem;
    align-items: flex-start;
  }

  .brand-mark {
    font-size: 0.72rem;
    letter-spacing: 0.01em;
  }

  .person-card {
    grid-template-columns: 1fr;
    gap: 0.65rem;
    padding: 0.9rem 0;
  }

  .person-media {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
    gap: 0.65rem;
    max-width: 16rem;
  }

  .person-card--multi .person-media {
    max-width: none;
  }

  .portrait-zoom,
  .portrait-missing {
    aspect-ratio: 3 / 4;
  }

  .anthology h2 {
    scroll-margin-top: 3.8rem;
  }

  .person-media-item {
    scroll-margin-top: 3.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
