.ryan-library {
  --library-paper: #f8f3ea;
  --library-ink: #30251e;
  --library-muted: #5b4a3e;
  --library-line: #d4c2ad;
  --library-accent: #35483b;
  --library-stage: #d4dcce;
  --library-tint: #eceee5;
  --library-serif: "Playfair Display", Georgia, serif;
  --library-sans: "DM Sans", system-ui, sans-serif;
  background: var(--library-paper);
  color: var(--library-ink);
  font-family: var(--library-sans);
  overflow-wrap: break-word;
  padding: clamp(7.5rem, 11vw, 10.5rem) 0 clamp(4rem, 8vw, 8rem);
}

.library-theme-clay {
  --library-accent: #763f2e;
  --library-stage: #e7c6af;
  --library-tint: #f1e1d4;
}

.library-theme-sage {
  --library-accent: #35483b;
  --library-stage: #d4dcce;
  --library-tint: #eceee5;
}

.library-shell {
  margin-inline: auto;
  width: min(100% - 3rem, 75rem);
}

.ryan-library h1,
.ryan-library h2 {
  color: inherit;
  font-family: var(--library-serif);
  font-weight: 500;
  letter-spacing: -.045em;
  line-height: 1.06;
}

.library-kicker {
  color: var(--library-accent);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .13em;
  line-height: 1.4;
  text-transform: uppercase;
}

.library-masthead {
  align-items: end;
  border-bottom: 1px solid var(--library-line);
  display: grid;
  gap: 2rem;
  grid-template-columns: 1.55fr 1fr;
  margin-bottom: clamp(2rem, 5vw, 4rem);
  padding-bottom: clamp(1.75rem, 4.85vw, 3.75rem);
}

.library-masthead h1,
.library-reader-lede h1 {
  font-size: clamp(3.25rem, 7vw, 6.4rem);
  margin: .65rem 0 0;
}

.library-masthead > p {
  color: var(--library-muted);
  font-size: clamp(1rem, 2vw, 1.36rem);
  line-height: 1.6;
  margin: 0 0 .5rem;
  max-width: 24rem;
}

.library-shelf {
  display: grid;
  gap: clamp(1.7rem, 4vw, 3.5rem);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.library-volume-stage {
  aspect-ratio: 1.28;
  background: radial-gradient(ellipse at 38% 12%, var(--library-tint), var(--library-stage) 80%);
  display: grid;
  overflow: hidden;
  padding: 8% 0 9%;
  place-items: center;
}

.library-volume-door {
  box-shadow: .7rem 1rem 1.1rem #30251e35;
  display: block;
  max-width: 16rem;
  position: relative;
  width: 52%;
}

.library-volume-door::before {
  background: repeating-linear-gradient(#faf5eb 0 2px, #ebdeca 3px 4px);
  content: "";
  inset: .2rem -.24rem -.25rem .25rem;
  position: absolute;
}

.library-cover {
  aspect-ratio: .735;
  background: var(--library-tint);
  border: 1px solid #30251e2b;
  border-left-width: 3px;
  color: var(--library-accent);
  container-type: inline-size;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.library-cover-type {
  padding: 8% 8% 6%;
}

.library-cover .library-kicker {
  font-size: clamp(.39rem, 3.4cqi, .85rem);
  letter-spacing: .15em;
}

.ryan-library .library-cover-title {
  font-family: var(--library-serif);
  font-size: 12.1cqi;
  font-weight: 600;
  letter-spacing: -.054em;
  line-height: .99;
  margin: .38em 0 .2em;
  max-width: 9.3ch;
}

.library-cover-subtitle {
  font-size: 4.05cqi;
  font-weight: 500;
  line-height: 1.25;
  max-width: 34ch;
}

.library-cover-image {
  height: 100%;
  object-fit: cover;
  object-position: center 52%;
  width: 100%;
}

.library-cover-imprint {
  display: flex;
  font-size: 3.5cqi;
  font-weight: 600;
  gap: .3rem;
  justify-content: space-between;
  padding: 3% 8%;
}

.library-volume-door .library-cover {
  transform-origin: left;
  transition: transform .42s cubic-bezier(.2,.72,.28,1);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .library-volume-door:hover .library-cover,
  .library-volume-door:focus-visible .library-cover {
    transform: perspective(52rem) rotateY(-27deg) translateY(-.3rem);
  }
}

.library-volume-details {
  border-bottom: 1px solid var(--library-line);
  padding: clamp(1.3rem, 3vw, 2.4rem) 0;
}

.library-volume-details h2,
.library-editor-note h2,
.library-colophon h2 {
  font-size: clamp(2rem, 4.1vw, 3.65rem);
  margin: .45rem 0 .75rem;
}

.library-volume-details > p:not(.library-kicker),
.library-editor-note p,
.library-colophon > p:not(.library-kicker) {
  color: var(--library-muted);
  font-size: 1.04rem;
  line-height: 1.65;
  max-width: 35rem;
}

.library-actions,
.library-colophon-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.1rem;
  margin-top: 1.2rem;
}

.library-button,
.library-text-link,
.library-colophon-links a {
  align-items: center;
  display: inline-flex;
  font-size: .94rem;
  font-weight: 700;
  gap: .5rem;
  min-height: 44px;
  padding-block: .45rem;
}

.library-button {
  background: var(--library-accent);
  border: 1px solid var(--library-accent);
  color: #fffaf2;
  justify-content: center;
  padding-inline: 1em;
}

.library-button:hover { filter: brightness(.86); }

.library-text-link,
.library-colophon-links a {
  color: var(--library-accent);
  text-decoration: underline;
  text-underline-offset: .24em;
}

.ryan-library :focus-visible {
  outline: 2px solid var(--library-accent);
  outline-offset: 4px;
}

.library-editor-note {
  align-items: center;
  display: grid;
  gap: clamp(1.25rem, 4vw, 3.25rem);
  grid-template-columns: clamp(7rem, 22vw, 14rem) minmax(0, 1fr);
  margin: clamp(3rem, 8vw, 6rem) auto 0;
  max-width: 53rem;
}

.library-editor-note img {
  aspect-ratio: .95;
  height: auto;
  object-fit: cover;
  object-position: 50% 25%;
  width: 100%;
}

.library-editor-note .library-text-link { margin-top: .6rem; }

.library-reader-hero {
  align-items: center;
  column-gap: clamp(1.5rem, 5vw, 5.5rem);
  display: grid;
  grid-template-columns: minmax(12rem, .66fr) minmax(0, 1.34fr);
  padding-bottom: clamp(2.8rem, 5vw, 5rem);
  row-gap: clamp(.75rem, 3vw, 2rem);
}

.library-back { grid-column: 1 / -1; justify-self: start; }
.library-reader-cover {
  background: var(--library-stage);
  padding: 8% 15% 10%;
}

.library-reader-cover .library-cover {
  box-shadow: .4rem .6rem 0 #f8f3ea, .6rem 1rem 1.2rem #30251e38;
}

@media (prefers-reduced-motion: no-preference) {
  .library-reader-cover .library-cover {
    animation: library-opening .54s ease-out both;
    transform-origin: left;
  }
  @keyframes library-opening {
    from { transform: perspective(55rem) rotateY(-20deg); }
    to { transform: perspective(55rem) rotateY(0); }
  }
}

.library-reader-lede h1 { font-size: clamp(3rem, 6.4vw, 5.75rem); }

.library-reader-lede .library-reader-subtitle {
  color: var(--library-ink);
  font-family: var(--library-serif);
  font-size: clamp(1.28rem, 2.4vw, 1.95rem);
  letter-spacing: -.025em;
  line-height: 1.3;
  margin: .75rem 0 1rem;
}

.library-reader-lede > p:not(.library-kicker) { max-width: 33rem; }
.library-reader-lede > p:not([class]) { color: var(--library-muted); line-height: 1.7; }

.library-reader-grid {
  align-items: start;
  border-top: 1px solid var(--library-line);
  display: grid;
  gap: clamp(2rem, 7vw, 6rem);
  grid-template-columns: minmax(12rem, .65fr) minmax(0, 1.35fr);
  padding-top: clamp(2rem, 5vw, 4rem);
}

.library-contents { scroll-margin-top: 8rem; }
.library-contents h2 { font-size: 2.2rem; margin-bottom: .8rem; }
.library-contents ol { list-style: none; margin: 0; padding: 0; }
.library-contents li { border-bottom: 1px solid var(--library-line); }
.library-contents a {
  align-items: center;
  color: var(--library-accent);
  display: flex;
  font-size: .94rem;
  font-weight: 650;
  min-height: 34px;
  padding: .4rem 0;
}
.library-contents a:hover { text-decoration: underline; text-underline-offset: .22em; }

.library-chapter {
  border-bottom: 1px solid var(--library-line);
  font-size: clamp(1rem, 1.7vw, 1.12rem);
  line-height: 1.75;
  margin-bottom: 2.3rem;
  padding-bottom: 2.3rem;
  scroll-margin-top: 7rem;
}
.library-chapter:last-child { margin-bottom: 0; }
.library-chapter h2 { font-size: clamp(2rem, 4.2vw, 3.3rem); margin: .38rem 0 1.15rem; }
.library-chapter > p + p { margin-top: .95em; }
.library-chapter > ul { list-style-type: disc; margin: .9em 0; padding-left: 1.3em; }
.library-chapter > ul li + li { margin-top: .28em; }

.library-chapter a {
  color: var(--library-accent);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: .19em;
}

.library-table-region { margin: 1.15em 0; overflow-x: auto; }
.library-table-region table {
  background: #fbf7f0;
  border-collapse: collapse;
  font-size: .86em;
  line-height: 1.35;
  width: 100%;
}
.library-table-region th,
.library-table-region td {
  border: 1px solid var(--library-line);
  min-width: 4rem;
  padding: .6em;
  text-align: left;
}
.library-table-region th { background: var(--library-tint); font-weight: 700; }
.library-table-region td:first-child { min-width: 6.75rem; }
.library-chapter[id^="worksheet"] .library-table-region td { height: 2.6rem; }

.library-figure {
  background: var(--library-tint);
  font-size: .86em;
  line-height: 1.35;
  margin: 1.2em 0 0;
  padding: 1.15em 1.4em;
}
.library-figure figcaption { font-weight: 750; margin-bottom: .6em; }
.library-figure dl > div {
  align-items: center;
  display: grid;
  gap: .3em .8em;
  grid-template-columns: minmax(0, 1fr) auto;
}
.library-figure dl > div + div { margin-top: .65em; }
.library-figure dd { font-variant-numeric: tabular-nums; font-weight: 750; }
.library-chart-track { background: #30251e17; display: block; grid-column: 1 / -1; height: .3em; }
.library-chart-track > span { background: var(--library-accent); display: block; height: 100%; }

.library-colophon {
  background: var(--library-tint);
  margin-top: clamp(2.7rem, 6vw, 5.5rem);
  padding: clamp(1.8rem, 5vw, 4rem);
}
.library-colophon .library-button { margin-top: 1.1rem; }
.library-colophon > .library-imprint { font-size: .85rem; margin-top: 1.5em; }
.library-print-only { display: none; }

@media (max-width: 700px) {
  .library-masthead,
  .library-reader-grid { grid-template-columns: minmax(0, 1fr); }
  .library-masthead { gap: 1.1rem; }
  .library-title-break { display: none; }
  .library-reader-grid { gap: 2.8rem; }
  .library-contents ol { columns: 2; column-gap: 1.1rem; }
  .library-contents li { break-inside: avoid; }
}

@media (max-width: 520px) {
  .library-shell { width: calc(100% - 2rem); }
  .library-shelf { grid-template-columns: minmax(0, 1fr); }
  .library-volume-door { width: 51%; }
  .library-editor-note { grid-template-columns: minmax(0, 1fr); }
  .library-editor-note img { width: min(10rem, 50%); }
  .library-reader-hero { grid-template-columns: minmax(0, 1fr); }
  .library-reader-cover { grid-row: 3; margin-top: .8rem; padding: 6% 24% 7%; }
  .library-reader-hero { padding-bottom: 2rem; }
  .library-contents h2 { margin-bottom: .55rem; }
  .library-contents a { min-height: 44px; line-height: 1.35; }
  .library-chapter { margin-bottom: 1.75rem; padding-bottom: 1.75rem; }
}

@page libraryBook { size: 7.5in 10in; margin: 0; }

@media print {
  body:has(.library-reader) {
    background: #f8f3ea;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body:has(.library-reader) .ryan-site > :not(main),
  body:has(.library-reader) .ryan-site ~ *,
  body:has(.library-reader) .library-screen-only {
    display: none !important;
  }
  body:has(.library-reader) .ryan-site,
  body:has(.library-reader) .ryan-site > main {
    display: block;
    min-height: 0;
    padding: 0;
  }
  .library-reader {
    overflow: visible;
    page: libraryBook;
    padding: 0;
  }
  .library-reader .library-shell { margin: 0; width: auto; }
  .library-reader-grid { border: 0; display: block; padding: 0; }
  .library-print-only { display: block; }
  .library-print-page {
    break-after: page;
    margin: 0;
    min-height: 10in;
    padding: .62in .7in .72in;
    position: relative;
  }
  .library-print-cover { padding: 0; }
  .library-print-cover .library-cover { aspect-ratio: auto; border: 0; height: 10in; width: 7.5in; }
  .library-print-cover .library-cover-type { padding: .4in .64in .34in; }
  .library-print-cover .library-kicker { font-size: 11pt; }
  .library-print-cover .library-cover-title { font-size: 55pt; letter-spacing: -.016em; max-width: 10ch; }
  .library-print-cover .library-cover-subtitle { font-size: 16pt; }
  .library-print-cover .library-cover-imprint { font-size: 9pt; padding: .18in .64in; }
  .library-contents h2 { font-size: 32pt; margin: .06in 0 .2in; }
  .library-contents ol { columns: 1; }
  .library-contents a { font-size: 11pt; justify-content: space-between; min-height: 0; padding: .054in 0; }
  .library-chapter { border: 0; font-size: 11.2pt; line-height: 1.52; }
  .library-chapter h2 { font-size: 31pt; letter-spacing: -.012em; margin: .07in 0 .21in; }
  .library-chapter > p + p { margin-top: .92em; }
  .library-chapter .library-table-region { overflow: visible; }
  .library-figure { break-inside: avoid; }
  .library-folio {
    border-top: 1px solid var(--library-line);
    bottom: .3in;
    color: var(--library-muted);
    display: flex;
    font-family: var(--library-sans);
    font-size: 8.5pt;
    justify-content: space-between;
    left: .7in;
    padding-top: .1in;
    position: absolute;
    right: .7in;
  }
  .library-colophon {
    break-after: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .library-colophon h2 { font-size: 39pt; }
  .library-colophon .library-button { align-self: flex-start; }
}

/* Writable worksheet columns and two annotated chapter figures. */
#worksheet-compare-the-properties table,
#worksheet-compare-the-money table,
#worksheet-compare-proceeds table,
#worksheet-diagnose-the-listing table {
  table-layout: fixed;
}

#worksheet-compare-the-properties th:first-child { width: 30%; }
#worksheet-compare-the-properties td:last-child { min-width: 0; }
#worksheet-compare-the-properties tr:last-child td {
  height: 4rem;
  vertical-align: top;
}

:is(#worksheet-compare-the-money, #worksheet-compare-proceeds) th:first-child { width: 44%; }
:is(#worksheet-compare-the-money, #worksheet-compare-proceeds) :is(th, td) { min-width: 0; }
#worksheet-diagnose-the-listing .library-table-region:first-of-type th:first-child { width: 35%; }
#worksheet-diagnose-the-listing .library-table-region:first-of-type th:last-child { width: 28%; }
#worksheet-diagnose-the-listing .library-table-region:nth-of-type(2) th:nth-child(1) { width: 15%; }
#worksheet-diagnose-the-listing .library-table-region:nth-of-type(2) th:nth-child(2) { width: 26%; }
#worksheet-diagnose-the-listing :is(th, td) { min-width: 0; }
#worksheet-diagnose-the-listing .library-table-region:nth-of-type(2) td { height: 3.25rem; }

#worksheet-diagnose-the-listing h3 {
  color: var(--library-accent);
  font-size: 1em;
  font-weight: 700;
  margin: 1.1em 0 .3em;
}
#worksheet-diagnose-the-listing h3 + p { margin-top: 0; }

.library-negotiation-figure {
  background: var(--library-tint);
  border-top: 2px solid var(--library-accent);
  color: var(--library-ink);
  font-size: .9em;
  line-height: 1.4;
  margin: 1.35em 0 0;
  padding: 1em 1.2em;
}

.library-negotiation-figure figcaption span { display: block; margin-bottom: .3em; }
.library-negotiation-figure figcaption strong {
  display: block;
  font-family: var(--library-serif);
  font-size: 1.55em;
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.17;
}

.library-counter-terms { margin: .75em 0 0; }
.library-counter-terms > div {
  border-top: 1px solid var(--library-line);
  display: grid;
  gap: .2em .9em;
  grid-template-columns: 13ch 1fr;
  padding: .48em 0;
}
.library-counter-terms dt { color: var(--library-accent); font-weight: 700; }
.library-counter-terms dd span { color: var(--library-muted); display: block; }

.library-closing-calendar {
  display: grid;
  gap: .8em;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
  margin: .95em 0 0;
  padding: 0;
}
.library-closing-calendar li { border-top: 2px solid var(--library-accent); padding-top: .4em; }
.library-closing-calendar span {
  color: var(--library-accent);
  display: block;
  font-size: .9em;
  font-weight: 700;
  margin-bottom: .3em;
}
.library-closing-calendar p { color: var(--library-muted); margin-top: .22em; }

.library-negotiation-takeaway {
  border-top: 1px solid var(--library-line);
  margin-top: .55em;
  padding-top: .55em;
}

@media screen and (max-width: 700px) {
  .library-chapter {
    content-visibility: auto;
    contain-intrinsic-block-size: auto 34rem;
  }
  :is(#worksheet-compare-the-money, #worksheet-compare-proceeds, #worksheet-diagnose-the-listing) table { min-width: 28rem; }
  .library-closing-calendar { grid-template-columns: 1fr; gap: .45em; }
  .library-closing-calendar li {
    border-left: 2px solid var(--library-accent);
    border-top: 0;
    padding: .1em 0 .45em .65em;
  }
}

@media print {
  :is(#worksheet-compare-the-properties, #worksheet-compare-the-money, #worksheet-compare-proceeds, #worksheet-diagnose-the-listing) .library-table-region {
    margin-block: .125in;
  }
  .library-chapter#worksheet-compare-the-money .library-table-region td,
  .library-chapter#worksheet-compare-proceeds .library-table-region td,
  .library-chapter#worksheet-compare-the-properties .library-table-region td {
    height: .345in;
  }
  .library-chapter#worksheet-compare-the-properties .library-table-region tr:last-child td {
    height: .63in;
  }
  .library-chapter#worksheet-diagnose-the-listing .library-table-region:first-of-type td { height: .34in; }
  .library-chapter#worksheet-diagnose-the-listing .library-table-region:first-of-type tr:first-child td { height: .52in; }
  .library-chapter#worksheet-diagnose-the-listing .library-table-region:nth-of-type(2) td { height: .42in; }
  .library-negotiation-figure {
    break-inside: avoid;
    margin-top: .125in;
    padding: .105in .18in;
  }
  .library-counter-terms > div { padding-block: .3em; }
  .library-counter-terms dd span { display: inline; margin-inline-start: .45em; }
  :is(#worksheet-compare-the-properties, #worksheet-compare-the-money) > p + p { margin-top: .55em; }
}
