:root {
  color-scheme: light;
  --paper: #f6f2eb;
  --card: #fffdf9;
  --ink: #292521;
  --muted: #665f57;
  --line: #ded5c9;
  --accent: #7e3038;
  --sidebar: #eee7dd;
  --sidebar-width: 275px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.7 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: #4f1620; }
a:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
h1, h2, h3, h4 { font-family: Georgia, "Times New Roman", serif; line-height: 1.2; font-weight: 500; }
h1 { font-size: clamp(2.5rem, 6vw, 4.3rem); letter-spacing: -.035em; margin: .4rem 0 1rem; }
h2 { font-size: 1.85rem; margin: 0 0 1rem; }
h3 { font-size: 1.45rem; margin: .25rem 0 .65rem; }
h4 { font-size: 1.2rem; margin: 1.7rem 0 .65rem; font-weight: 600; }
p { margin: 0 0 1rem; }
img { display: block; max-width: 100%; height: auto; }
.page { max-width: 1200px; margin: auto; padding: 2.5rem 1.5rem 2rem; }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; margin: 0 0 .5rem; }
.intro { font-size: 1.05rem; color: var(--muted); max-width: 850px; }
.context, .note { border-left: 3px solid var(--line); padding-left: 1rem; color: var(--muted); font-size: .88rem; }
.breadcrumbs, .file-links, .asset-links, .links, .nav { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; font-size: .85rem; }
.breadcrumbs, .nav { margin-bottom: 2rem; }
.file-links, .links { margin-top: 1rem; }
.skip-link { position: absolute; top: -5rem; left: 1rem; background: var(--card); padding: .6rem 1rem; z-index: 3; }
.skip-link:focus { top: 1rem; }
figure { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 3px 15px #30251a08; break-inside: avoid; }
figure img { width: 100%; }
figcaption { padding: 1.25rem; color: var(--muted); font-size: .9rem; }
figcaption h3 { color: var(--ink); }
figcaption > p:not(.eyebrow) { font-size: .9rem; }
.artwork { display: block; background: #1e1c1b; }
footer { border-top: 1px solid var(--line); margin-top: 2.5rem; padding-top: 1.25rem; color: var(--muted); font-size: .82rem; }
.section-nav { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; border-block: 1px solid var(--line); padding: 1rem 0; margin: 0 0 2rem; font-size: .84rem; }
article h3 { font-size: 1.65rem; color: var(--accent); margin: 2.3rem 0 1rem; }
article ul, article ol { padding-left: 1.4rem; }
article li { padding-left: .2rem; margin-bottom: .75rem; }
article strong { font-weight: 650; }
article a { overflow-wrap: anywhere; }
.overview-page article h2 { margin-top: 2.5rem; color: var(--accent); }
.table-scroll { max-width: 100%; overflow-x: auto; margin: 1.25rem 0 2rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.house-overview { width: auto; table-layout: auto; }
.house-overview th:first-child, .house-overview td:first-child { white-space: nowrap; }
.house-overview td:first-child a { overflow-wrap: normal; word-break: normal; hyphens: none; }
.house-overview td:nth-child(2) > strong { white-space: nowrap; }
th, td { padding: .85rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--sidebar); font-weight: 650; }
tbody tr:nth-child(even) { background: #ffffff60; }

/* Profile reading editions. */
.profile-page { --profile-image-size: 150px; }
.profile-page article { max-width: none; }
.profile-page article > p, .profile-page article > ul, .profile-page article > ol { max-width: none; }
.masthead { display: grid; grid-template-columns: minmax(0, 1fr) var(--profile-image-size); align-items: center; gap: 2rem; margin-bottom: 2rem; }
.masthead h2 { font-size: 1.45rem; color: var(--muted); margin: 0; }
.sigil img { width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.house-member { display: grid; grid-template-columns: minmax(0, 1fr) var(--profile-image-size); column-gap: 2rem; align-items: start; margin-top: 1.7rem; }
.house-member > :not(.member-portrait) { grid-column: 1; min-width: 0; }
.house-member h4 { margin-top: 0; }
.house-member p { max-width: none; }
.member-portrait { grid-column: 2; grid-row: 1 / span 3; width: var(--profile-image-size); margin: 0; }
.member-portrait img { aspect-ratio: 1; object-fit: cover; }
.visuals { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1.5rem; }
.image-grid, .portraits { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 1.25rem; align-items: start; }

/* Portrait and sigil galleries. */
.portrait-gallery-page header { max-width: 850px; margin-bottom: 2rem; }
.family-jump { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; margin: 2rem 0 3rem; }
.family-jump a, .profile-button { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; text-align: center; text-decoration: none; border: 1px solid var(--line); border-radius: 5px; padding: .55rem .75rem; background: var(--card); font-size: .9rem; }
.family-jump a:hover, .profile-button:hover { border-color: var(--accent); background: var(--sidebar); }
@media (max-width: 600px) { .family-jump { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.house { margin: 0 0 3.5rem; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .6rem 1.5rem; border-top: 1px solid var(--line); padding-top: 1.2rem; margin-bottom: 1.2rem; }
.section-heading h2 { margin: 0; }
.section-heading > a { font-size: .85rem; }
.sigil-card { display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr); align-items: center; margin-top: 1.25rem; }
.sigil-card img { aspect-ratio: 1; object-fit: contain; }

/* Individual gallery cards follow household order. */
.gallery-thumbnails { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; align-items: stretch; }
.gallery-thumbnail img { aspect-ratio: 1; object-fit: cover; }
.gallery-thumbnail figcaption { padding: .65rem .5rem; text-align: center; color: var(--ink); font-family: Georgia, serif; font-size: 1.1rem; }
.gallery-thumbnail figcaption strong { font-weight: 700; }
.household-portrait figcaption p { margin-bottom: 0; }
@media (max-width: 600px) {
  .gallery-thumbnails { gap: .4rem; }
  .gallery-thumbnail figcaption { padding: .5rem .15rem; font-size: clamp(.6rem, 2.6vw, 1.1rem); overflow-wrap: anywhere; }
}

/* Site home and shell navigation. */
.home-page section { margin: 2.5rem 0; }
.house-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; }
.house-link { display: flex; flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 7px; text-decoration: none; }
.house-link img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; border: 0; border-radius: 0; }
.house-link strong { font-family: Georgia, serif; font-size: 1.25rem; font-weight: 500; display: block; padding: .65rem .75rem; }
.house-link:hover { border-color: var(--accent); }
.overview-page > .page > .sigil-bar { margin-bottom: 2rem; }
.resource-list { padding-left: 1.3rem; }
.resource-list li { margin-bottom: .8rem; }
.sidebar { padding: 1.6rem 1rem; background: var(--sidebar); border-right: 1px solid var(--line); overflow-y: auto; }
.brand { display: block; color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-size: 1.4rem; line-height: 1.15; padding: 0 .1rem .6rem; }
.nav-heading { font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.1rem .1rem .3rem; }
.sidebar nav { display: grid; gap: .12rem; margin-left: .6rem; }
.nav-link { display: block; color: var(--ink); text-decoration: none; font-size: .88rem; line-height: 1.35; padding: .22rem .65rem .22rem 1.25rem; text-indent: -.6rem; border-radius: 5px; }
.nav-link:hover { background: #ffffff75; }
.nav-link[aria-current="page"] { color: var(--accent); background: var(--card); box-shadow: inset 3px 0 var(--accent); font-weight: 600; }
.sidebar-note { font-size: .73rem; color: var(--muted); padding: 1.4rem .6rem 0; margin: 1.4rem 0 0; border-top: 1px solid var(--line); }

/* Shared full-size image viewer, also usable on standalone pages. */
html.image-lightbox-open { overflow: hidden; }
.image-lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 3.5rem 1.5rem 1.5rem;
  background: transparent;
  color: white;
}
.image-lightbox[open] { display: grid; place-items: center; overflow: hidden; }
.image-lightbox::backdrop { background: rgb(12 10 9 / 88%); }
.image-lightbox-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 5rem);
  max-height: calc(100dvh - 5rem);
  object-fit: contain;
  transform-origin: center;
  user-select: none;
  touch-action: none;
  box-shadow: 0 8px 40px #0008;
}
.image-lightbox-close {
  z-index: 2;
  position: absolute;
  top: .5rem;
  right: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #000;
  color: #ef3038;
  font-family: Arial, "Segoe UI Symbol", sans-serif;
  font-size: 1.65rem;
  font-weight: 900;
  -webkit-text-stroke: .6px currentColor;
  line-height: 1;
  cursor: pointer;
}
.image-lightbox-close:hover { background: #000; color: #ff4d55; }
.image-lightbox-close:focus-visible { outline: 3px solid white; outline-offset: 3px; }
.image-lightbox-image.is-zoomed { cursor: grab; }
.image-lightbox-image.is-panning { cursor: grabbing; }
.image-lightbox-hint {
  position: absolute;
  z-index: 2;
  bottom: .25rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: .15rem .65rem;
  border-radius: 4px;
  background: #151210bb;
  color: #fff;
  font-size: .75rem;
  white-space: nowrap;
  pointer-events: none;
}
.image-lightbox-error { text-align: center; }
.image-lightbox [hidden] { display: none; }

@media (max-width: 1000px) {
  .house-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .page { padding: 1.8rem 1rem; }
  .portraits, .image-grid { grid-template-columns: 1fr; }
  .profile-page { --profile-image-size: 95px; }
  .masthead { grid-template-columns: minmax(0, 1fr) var(--profile-image-size); gap: 1rem; }
  .house-member { column-gap: 1rem; }
  .house { margin-bottom: 2.5rem; }
}
@media (max-width: 600px) {
  .house-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .house-grid { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .sigil-card { grid-template-columns: 1fr; }
  .sigil-card .artwork { max-width: 220px; margin: 1rem auto 0; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  body { background: white; font-size: 10pt; line-height: 1.45; }
  .page { max-width: none; padding: 0; }
  .breadcrumbs, .section-nav, .file-links, .family-jump, .skip-link, .sidebar { display: none; }
  figure { box-shadow: none; }
  .masthead { display: block; margin-bottom: 1rem; }
  .profile-page .visuals, .profile-page .sigil, .profile-page footer { display: none; }
  .profile-page article { max-width: none; }
  h1 { font-size: 25pt; }
  h2 { font-size: 17pt; }
  article h3 { font-size: 15pt; break-after: avoid; margin-top: 1.3rem; }
  article h4 { font-size: 12pt; break-after: avoid; }
  .house { break-before: page; }
  .table-scroll { overflow: visible; }
  a { color: inherit; }
}

/* Unified document layout: one sidebar and normal document scrolling. */
.site-layout { min-height: 100dvh; padding-left: var(--sidebar-width); }
.site-layout > .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 3; }
.site-layout > .content-panel { min-width: 0; }
.mobile-header { display: none; }
.table-responsive { width: 100%; overflow-x: auto; margin: 1.25rem 0 2rem; }
.encyclopedia-content h2 { margin-top: 2.5rem; color: var(--accent); }
.encyclopedia-content blockquote { margin: 1.5rem 0; padding: .75rem 1.25rem; border-left: 3px solid var(--accent); background: var(--sidebar); }
.encyclopedia-content code { padding: .1em .3em; background: var(--sidebar); border-radius: 3px; font-size: .9em; }
.encyclopedia-content pre { overflow-x: auto; padding: 1rem; background: var(--sidebar); }
.encyclopedia-content hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
@media (max-width: 760px) {
  .site-layout { padding-left: 0; }
  .mobile-header { display: flex; position: sticky; top: 0; z-index: 4; align-items: center; justify-content: space-between; gap: 1rem; height: 64px; padding: .65rem 1rem; background: var(--sidebar); border-bottom: 1px solid var(--line); }
  .mobile-brand { font: 1.1rem Georgia, serif; text-decoration: none; color: var(--ink); }
  .menu-button { padding: .5rem .8rem; border: 1px solid var(--accent); border-radius: 5px; background: var(--card); color: var(--accent); font: inherit; cursor: pointer; }
  .site-layout > .sidebar { display: none; inset: 64px 0 0; width: auto; max-height: none; border: 0; padding: 1.25rem 1rem; }
  .site-layout > .sidebar.is-open { display: block; }
  .sidebar .brand { display: none; }
  html.menu-open { overflow: hidden; }
  html { scroll-padding-top: 80px; }
}
@media print {
  .site-layout { padding-left: 0; }
  .mobile-header { display: none; }
}
