/* Apollo & Dionysus Editions
   One typeface, two voices: roman for order, italic for impulse.
   Ivory paper, black ink, one wine-red accent used sparingly. */

@font-face {
  font-family: "EB Garamond";
  src: url("fonts/EBGaramond-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("fonts/EBGaramond-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f4f0e6;
  --ink: #1c1a17;
  --ink-soft: #5d574d;
  --ink-faint: #8f887c;
  --rule: rgba(28, 26, 23, 0.16);
  --wine: #6b1f22;

  --serif: "EB Garamond", Garamond, "Garamond Premier Pro", "Times New Roman", serif;
  --wide: 76rem;
  --measure: 34rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ------------------------------------------------------------ base */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.125rem, 1.06rem + 0.25vw, 1.25rem);
  line-height: 1.5;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
h1, h2 { font-weight: 400; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.22em;
  transition: color 0.2s, text-decoration-color 0.2s;
}
a:hover { color: var(--wine); text-decoration-color: currentColor; }
a[href^="mailto:"] { white-space: nowrap; }
a:focus-visible { outline: 1px solid var(--wine); outline-offset: 4px; }

::selection { background: var(--wine); color: var(--paper); }

.amp {
  font-style: italic;
  color: var(--wine);
  text-transform: none;
  letter-spacing: 0;
}

/* Small capitals: the house voice for labels and names. */
.site-header a,
.section-head h2,
.section-head a,
.card-author,
.card-status,
.book-back,
.book-author,
.book-h2,
.incipit figcaption,
.edition dt,
.button,
.buy-forthcoming,
.book-nav span,
.house-contents h2,
.footer-name {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
}

/* ------------------------------------------------------------ header & footer */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.75rem var(--gutter);
}
.site-header a { text-decoration: none; font-size: 1.05rem; }
.site-header nav { display: flex; gap: clamp(1.25rem, 3vw, 2.5rem); }
.site-header nav a[aria-current="page"] { color: var(--wine); }
.site-header a { white-space: nowrap; }
.wordmark { letter-spacing: 0.16em !important; }

/* Main navigation, then the three languages, quieter, after a thin rule. */
.header-links { display: flex; align-items: baseline; gap: clamp(1.25rem, 3vw, 2.5rem); }
.site-header .languages {
  gap: 0.9rem;
  padding-left: clamp(1.25rem, 3vw, 2.5rem);
  border-left: 1px solid var(--rule);
}
.languages a { color: var(--ink-faint); font-size: 0.95rem !important; }
.languages a[aria-current] { color: var(--ink); }
.languages a:hover { color: var(--wine); }

@media (max-width: 520px) {
  .site-header { flex-direction: column; align-items: center; gap: 0.5rem; padding-top: 1.25rem; }
  .page-home .site-header > span { display: none; }
  .header-links { flex-wrap: wrap; justify-content: center; row-gap: 0.4rem; }
}

.site-footer {
  max-width: var(--wide);
  margin: clamp(5rem, 10vw, 9rem) auto 0;
  padding: 1.5rem var(--gutter) 3rem;
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
  font-size: 1rem;
  color: var(--ink-soft);
}
.footer-name { color: var(--ink); }
.colophon {
  margin-top: 2.5rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-faint);
}

/* ------------------------------------------------------------ sections */

.section {
  max-width: var(--wide);
  margin: 0 auto;
  padding: clamp(3.5rem, 8vw, 7rem) var(--gutter) 0;
}
.section--tight { padding-top: clamp(2rem, 4vw, 3rem); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--rule);
  padding-top: 0.9rem;
  margin-bottom: clamp(2.25rem, 5vw, 4rem);
}
.section-head h2 { font-size: 1.05rem; }
.section-head a { font-size: 1.05rem; text-decoration: none; color: var(--ink-soft); }
.section-head a:hover { color: var(--wine); }

.page-head h1 {
  font-size: clamp(2.75rem, 6vw, 4.75rem);
  line-height: 1;
  letter-spacing: -0.01em;
}
.page-sub {
  margin-top: 1rem;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.2rem;
}

/* ------------------------------------------------------------ masthead (home) */

.masthead {
  min-height: min(72vh, 46rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(5rem, 14vh, 10rem) var(--gutter) clamp(3rem, 8vh, 6rem);
}
.masthead h1 { line-height: 1; }
.mast-name {
  display: block;
  font-size: clamp(2rem, 6.4vw, 5.5rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding-left: 0.14em; /* optical centring of tracked capitals */
}
.mast-name .amp { padding: 0 0.04em; }
.mast-imprint {
  display: block;
  margin-top: 1.3rem;
  font-size: clamp(0.85rem, 1.3vw, 1.1rem);
  letter-spacing: 0.62em;
  padding-left: 0.62em;
  text-transform: uppercase;
}
.mast-rule {
  display: block;
  width: 2.5rem;
  height: 1px;
  margin: clamp(2.5rem, 5vw, 3.5rem) auto;
  background: var(--ink-faint);
}
.motto {
  font-style: italic;
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  .mast-name { font-size: 2.75rem; letter-spacing: 0.12em; padding-left: 0.12em; line-height: 1.15; }
  .mast-name > span:not(.amp) { display: block; }
  .mast-name .amp { display: block; font-size: 0.8em; margin: 0.1em 0; }
}

/* ------------------------------------------------------------ covers */

/* Every cover shares one ivory ground and one layout. The tone only sets the
   title (roman for light, italic for dark and wine) and the panel shown when
   there is no painting yet. */
.cover {
  container-type: inline-size;
  position: relative;
  aspect-ratio: 5 / 8; /* the proportion of the printed covers (1600 × 2560) */
  max-width: 100%;
  overflow: hidden;
  background: #efe9dc;
  color: var(--ink);
  box-shadow:
    0 1px 1px rgba(28, 26, 23, 0.08),
    0 22px 32px -22px rgba(28, 26, 23, 0.5);
}
.cover--image { background: none; }
.cover--image img { width: 100%; height: 100%; object-fit: cover; }

.cover--light { --panel: #d8cdb6; --panel-ink: #1c1a17; }
.cover--dark  { --panel: #24201c; --panel-ink: #e8e0cd; }
.cover--wine  { --panel: #5a1b1f; --panel-ink: #efe6d3; }

.cover-frame {
  position: absolute;
  inset: 4.5cqw;
  border: max(1px, 0.25cqw) solid rgba(28, 26, 23, 0.32);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 9cqw 7cqw 6.5cqw;
}
.cover-frame > p { margin: 0; }
.cover-author {
  color: var(--wine);
  font-size: 4.1cqw;
  letter-spacing: 0.22em;
  padding-left: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
}
.cover-title {
  margin-top: 4cqw !important;
  font-size: 10.5cqw;
  line-height: 1.02;
  text-wrap: balance;
}
.cover--dark .cover-title,
.cover--wine .cover-title { font-style: italic; }

.cover-subtitle {
  margin-top: 3cqw !important;
  font-size: 3.7cqw;
  font-style: italic;
  color: var(--ink-soft);
}
.cover-apparatus {
  margin-top: 1.6cqw !important;
  font-size: 2.6cqw;
  letter-spacing: 0.24em;
  padding-left: 0.24em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.cover-art {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin: 6.5cqw 0;
  overflow: hidden;
}
.cover-art img { width: 100%; height: 100%; object-fit: cover; }
.cover-art--panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6cqw;
  background: var(--panel);
  color: var(--panel-ink);
  font-size: 5.2cqw;
  font-style: italic;
  line-height: 1.25;
}
.cover-art--panel :lang(zh-Hant) {
  font-style: normal;
  letter-spacing: 0.2em;
  font-family: var(--serif), "Noto Serif CJK TC", "Songti TC", serif;
}
.cover-mark {
  font-size: 3.2cqw;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  text-transform: uppercase;
  line-height: 1;
}
.cover-imprint {
  display: block;
  margin-top: 1.8cqw;
  font-size: 2.4cqw;
  letter-spacing: 0.6em;
  padding-left: 0.6em;
}

/* ------------------------------------------------------------ shelves */

.shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(3.5rem, 6vw, 5.5rem) clamp(1.5rem, 4.5vw, 4.5rem);
}
@media (max-width: 760px) {
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3rem 1.25rem; }
}

.card { display: block; text-decoration: none; }
.card-text { margin-top: 1.4rem; }
.card-status { color: var(--wine); font-size: 0.95rem; margin-bottom: 0.2rem; }
.card-author { color: var(--ink-soft); font-size: 1rem; line-height: 1.3; }
.card-title {
  margin-top: 0.15rem;
  font-style: italic;
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
  line-height: 1.2;
  transition: color 0.2s;
}
.card:hover .card-title { color: var(--wine); }

.card .cover {
  transition: transform 0.6s var(--ease), box-shadow 0.6s var(--ease);
}
.card:hover .cover,
.card:focus-visible .cover {
  transform: translateY(-6px);
  box-shadow:
    0 1px 1px rgba(28, 26, 23, 0.08),
    0 36px 44px -26px rgba(28, 26, 23, 0.55);
}
.cover-art img { transition: transform 1.4s var(--ease); }
.card:hover .cover-art img { transform: scale(1.035); }
.card-meta { margin-top: 0.6rem; font-size: 0.95rem; color: var(--ink-faint); }
.card-tagline { margin-top: 0.35rem; font-size: 1.02rem; color: var(--ink-soft); line-height: 1.45; max-width: 22rem; }

@media (max-width: 760px) {
  .card-text { margin-top: 1rem; }
  .card-tagline { display: none; }
}

/* ------------------------------------------------------------ home: house & index */

.house-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 46rem;
}
.house-intro p {
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.15rem);
  line-height: 1.32;
}
.house-intro a { font-style: italic; justify-self: start; }

.index {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(2rem, 6vw, 6rem);
}
.index li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}
.index-name { white-space: nowrap; }
.index-dates { margin-left: 0.4rem; font-size: 0.9rem; color: var(--ink-faint); }
.index-works { text-align: right; font-style: italic; }
.index-works a { text-decoration: none; }
.index-works a.is-forthcoming { color: var(--ink-faint); }
.index-works a:hover { color: var(--wine); }

@media (max-width: 760px) {
  .index { grid-template-columns: minmax(0, 1fr); }
  .index li { flex-direction: column; gap: 0.1rem; }
  .index-works { text-align: left; }
}

/* ------------------------------------------------------------ book page */

.book {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(2.5rem, 7vw, 7.5rem);
  max-width: var(--wide);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) var(--gutter) 0;
}
.book-cover { position: sticky; top: 2.5rem; align-self: start; }
.book-body { max-width: var(--measure); padding-top: 0.5rem; }

.book-back { font-size: 1rem; color: var(--ink-faint); text-decoration: none; }
.book-author { margin-top: clamp(2rem, 5vw, 4rem); font-size: 1.15rem; color: var(--ink-soft); }
.book-title {
  margin-top: 0.4rem;
  font-size: clamp(2.6rem, 5.2vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.book-original { margin-top: 0.9rem; font-style: italic; color: var(--ink-soft); }

.book-body > p { margin-top: 1.4rem; }
.book-body .lede {
  margin-top: 2.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
  font-size: 1.22em;
  line-height: 1.45;
}

.buy { margin: 2.5rem 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 1rem 1.75rem; }
.button {
  display: inline-block;
  padding: 0.55rem 1.6rem 0.7rem;
  border: 1px solid var(--ink);
  font-size: 1.1rem;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}
.button:hover { background: var(--ink); color: var(--paper); }
.buy-more { font-size: 1rem; color: var(--ink-soft); font-style: italic; }
.buy-forthcoming { color: var(--wine); font-size: 1.1rem; }

.incipit { margin: 3.5rem 0 0; }
.incipit figcaption { color: var(--wine); font-size: 1rem; }
.incipit blockquote {
  margin-top: 0.6rem;
  font-style: italic;
  font-size: 1.3em;
  line-height: 1.4;
  text-indent: -0.42em; /* hang the opening quotation mark */
}
.incipit blockquote p::before { content: "“"; }
.incipit blockquote p::after { content: "”"; }

.book-h2 { margin-top: 3.5rem; font-size: 1rem; color: var(--ink-soft); }
.edition { margin-top: 0.8rem; border-top: 1px solid var(--rule); }
.edition div {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 1.02rem;
}
.edition dt { color: var(--ink-faint); }

.book-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: var(--wide);
  margin: clamp(5rem, 10vw, 8rem) auto 0;
  padding: 0 var(--gutter);
}
.book-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  text-decoration: none;
}
.book-nav span { color: var(--ink-faint); font-size: 0.95rem; }
.book-nav em { font-size: 1.35rem; transition: transform 0.5s var(--ease); }
.book-nav-prev:hover em { transform: translateX(-5px); }
.book-nav-next:hover em { transform: translateX(5px); }
.book-nav-next { text-align: right; grid-column: 2; }

@media (max-width: 820px) {
  .book { grid-template-columns: minmax(0, 1fr); }
  .book-cover { position: static; width: min(100%, 22rem); margin: 0 auto; }
  .book-back { display: none; }
  .book-author { margin-top: 0; }
  .book-body { margin: 0 auto; }
}

/* ------------------------------------------------------------ house page */

.house {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(3rem, 8vw, 8rem);
}
.house-text { max-width: var(--measure); }
.house-text p + p { margin-top: 1.25rem; }
.house-text .lede { font-size: 1.45em; line-height: 1.35; margin-bottom: 2.25rem; }

.house-contents h2 {
  font-size: 1.05rem;
  color: var(--ink-soft);
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule);
}
.contents li {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}
.contents .num { grid-row: span 2; color: var(--wine); font-variant-caps: all-small-caps; letter-spacing: 0.06em; }
.contents .entry { font-size: 1.2rem; }
.contents .note { font-style: italic; color: var(--ink-soft); font-size: 1rem; }


@media (max-width: 820px) {
  .house { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------ legal */

.legal-text { max-width: var(--measure); }
.legal-text h2 {
  margin: 2.5rem 0 0.8rem;
  font-size: 1rem;
  color: var(--ink-soft);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
}
.legal-text h2:first-child { margin-top: 0; }
.legal-text p + p { margin-top: 1rem; }
.legal-updated { margin-top: 2.5rem; font-style: italic; color: var(--ink-faint); font-size: 1rem; }

/* ------------------------------------------------------------ 404 */

.notfound { min-height: 50vh; }
.notfound p:last-child { margin-top: 2rem; font-style: italic; }

/* ------------------------------------------------------------ motion */

/* Navigation: a fine rule draws itself under the link. */
.site-header nav:not(.languages) a,
.section-head a {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  padding-bottom: 2px;
  transition: color 0.3s, background-size 0.45s var(--ease);
}
.site-header nav:not(.languages) a:hover,
.section-head a:hover { background-size: 100% 1px; }

.index li .index-name { transition: color 0.3s; }
.index li:hover .index-name { color: var(--wine); }

/* Home: the two names, then the ampersand between them, then the rest. */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes appear { from { opacity: 0; } }
@keyframes draw { from { transform: scaleX(0); } }

.mast-name > span:not(.amp) { animation: appear 1.3s ease both; }
.mast-name > span:last-child { animation-delay: 0.15s; }
.mast-name .amp { animation: appear 1.4s ease 0.8s both; }
.mast-imprint { animation: appear 1.2s ease 1.1s both; }
.mast-rule { animation: draw 1s var(--ease) 1.35s both; }
.motto { animation: rise 1.1s var(--ease) 1.5s both; }

/* Inner pages settle in. */
.page-head, .book-cover, .book-body { animation: rise 0.9s var(--ease) both; }
.book-body { animation-delay: 0.12s; }

/* Scroll reveal, set up by site.js only when motion is welcome. */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s ease, transform 0.9s var(--ease);
  transition-delay: var(--reveal-delay, 0s);
}
.reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------------------ print */

@media print {
  .site-header nav, .book-nav, .buy { display: none; }
  .cover { box-shadow: none; }
  .reveal { opacity: 1; transform: none; }
}
