/*
 * alchemie · philosophers-stones-truffles.com
 * 1. Concept: an early-modern printed treatise on alchemy (c. 1650 to 1700): engraved frontispiece, title page in red
 *    and black, printer's device and imprint, chapters with an italic "argument", marginal glosses and woodcut initials.
 * 2. Type: IM Fell English (the Fell types, Oxford 1670s) for titles, numerals, glosses' labels and initials;
 *    Cardo for reading text. Both OFL, self-hosted as woff2.
 * 3. Palette: desk #e3dfd3, rag #eeebe2, leaf #f7f5ef, iron-gall ink #29231d, carmine rubric #8e2b3a,
 *    orpiment #9a7420 (rules and ornaments only).
 * 4. Layout signature: home is a title page (a single framed leaf: kicker, title in red capitals, black italic
 *    subtitle, engraved frontispiece, printer's device, imprint line), then "The Contents" with CHAP. numerals and
 *    arguments. Articles are leaves with running head, chapter opener, one text column and marginal glosses in
 *    their own grid column (never beside tables or product rows, which span the full measure).
 * 5. Finishing detail: a catchword and a signature mark (A, B, C ...) at the foot of every leaf; products shown in
 *    oval engraved medallions with a double orpiment rule.
 */

@font-face { font-family: "Cardo"; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/cardo-italic-400-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Cardo"; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/cardo-italic-400-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cardo"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/cardo-normal-400-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Cardo"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/cardo-normal-400-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cardo"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/cardo-normal-700-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Cardo"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/cardo-normal-700-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IM Fell English"; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/im-fell-english-italic-400-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IM Fell English"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/im-fell-english-normal-400-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --desk: #e3dfd3;
  --rag: #eeebe2;
  --leaf: #f7f5ef;
  --ink: #29231d;
  --ink-soft: #574e45;
  --rubric: #8e2b3a;
  --orpiment: #9a7420;
  --rule: #c9c1b0;
  --fell: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --text: "Cardo", "Iowan Old Style", Georgia, serif;
  --measure: 36rem;
  --gloss: 9.5rem;
  --gutter: 2.25rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 400 1.125rem/1.62 var(--text);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--rubric); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--rubric); outline-offset: 3px; }
strong { font-weight: 700; }
em, i { font-style: italic; }
.skip { position: absolute; left: -999px; top: 0; z-index: 10; background: var(--ink); color: var(--leaf); padding: .5rem 1rem; }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- Bar: device and chapters ---------- */
.bar { background: var(--ink); color: var(--rag); }
.bar-in { max-width: 72rem; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.device { display: flex; align-items: center; gap: .6rem; color: var(--rag); text-decoration: none; font: 400 1.25rem/1 var(--fell); letter-spacing: .01em; }
.device img { width: 36px; height: 36px; background: var(--rag); border-radius: 50%; padding: 3px; }
.device:hover { color: #fff; }
.chapters { display: none; }
.menu { position: relative; font: italic 400 1.05rem/1 var(--fell); }
.menu summary { cursor: pointer; list-style: none; padding: .45rem .8rem; border: 1px solid #6b6156; color: var(--rag); }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ""; display: inline-block; width: .4em; height: .4em; margin-left: .55em; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-.15em) rotate(45deg); }
.menu[open] summary { background: var(--rag); color: var(--ink); }
.menu ol { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 5; margin: 0; padding: .4rem 0; list-style: none; width: min(19rem, calc(100vw - 2rem)); background: var(--leaf); border: 1px solid var(--ink); }
.menu li a { display: block; padding: .55rem 1rem; color: var(--ink); text-decoration: none; font: 400 1.05rem/1.3 var(--text); }
.menu li a:hover, .menu li a[aria-current] { background: var(--rag); color: var(--rubric); }
.menu .num { display: inline-block; min-width: 4.6rem; font: italic 400 .95rem/1 var(--fell); color: var(--rubric); }
.langs a { color: var(--rag); margin-left: .5rem; font: .85rem var(--text); }

@media (min-width: 64rem) {
  .menu { display: none; }
  .chapters { display: flex; gap: .2rem 1.15rem; flex-wrap: wrap; justify-content: flex-end; }
  .chapters a { color: #d9d2c4; text-decoration: none; font: 400 1.02rem/1.6 var(--text); padding: .15rem 0; border-bottom: 1px solid transparent; }
  .chapters a:hover { color: #fff; }
  .chapters a[aria-current] { color: #fff; border-bottom-color: var(--orpiment); }
  .chapters .num { font: italic 400 .92rem/1 var(--fell); color: #c9a65a; margin-right: .1rem; }
}

/* ---------- The printed leaf ---------- */
.leaf {
  position: relative;
  max-width: 54rem;
  margin: 1rem auto 2rem;
  padding: 1.25rem 1rem 2.5rem;
  background: var(--leaf);
  border: 1px solid var(--rule);
}
@media (min-width: 40rem) {
  .leaf { margin: 2rem auto 3rem; padding: 2rem 2.5rem 3rem; outline: 1px solid var(--rule); outline-offset: 5px; }
}
.runhead {
  display: flex; justify-content: space-between; gap: 1rem;
  margin: 0 0 1.75rem; padding-bottom: .4rem;
  border-bottom: 1px solid var(--ink);
  font: 400 .82rem/1.2 var(--fell); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft);
}
.runhead span:last-child { color: var(--rubric); }
.signature { margin: 2.5rem 0 0; text-align: center; font: italic 400 1rem/1 var(--fell); color: var(--ink-soft); letter-spacing: .2em; }

/* Chapter opener */
.opener { text-align: center; max-width: 40rem; margin: 0 auto 2.25rem; }
.opener-num { margin: 0 0 .6rem; font: 400 1rem/1 var(--fell); letter-spacing: .22em; text-transform: uppercase; color: var(--rubric); }
.opener h1 { margin: 0; font: italic 400 clamp(1.95rem, 1.3rem + 2.6vw, 3rem)/1.12 var(--fell); color: var(--ink); text-wrap: balance; }
.argument {
  margin: 1.4rem auto 0; padding: .9rem 0; max-width: 34rem;
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  font: italic 400 1.06rem/1.55 var(--text); color: var(--ink-soft);
}
.argument-label { font-style: normal; font-family: var(--fell); letter-spacing: .08em; text-transform: uppercase; font-size: .85rem; color: var(--rubric); margin-right: .2rem; }
.opener-date { margin: .8rem 0 0; font: italic .9rem/1.3 var(--text); color: var(--ink-soft); }

/* ---------- The text column with marginal glosses ---------- */
.text { max-width: var(--measure); margin: 0 auto; }
.text > * { margin-top: 0; }
.text p, .text ul, .text ol { margin: 0 0 1.05rem; }
.text ul, .text ol { padding-left: 1.3rem; }
.text li { margin-bottom: .4rem; }
.text li::marker { color: var(--rubric); }
.text h2 {
  margin: 2.4rem 0 1rem;
  font: 400 1.6rem/1.2 var(--fell); color: var(--ink);
}
.text h2::before {
  content: ""; display: block; width: 2.2rem; height: 0; margin-bottom: .8rem;
  border-top: 3px double var(--rubric);
}
.text h3 { margin: 1.6rem 0 .5rem; font: italic 400 1.25rem/1.25 var(--fell); }
.text code { font-size: .9em; }

/* Woodcut initial: the first letter of the first paragraph in a ruled carmine block. */
.has-initial > p:first-of-type::first-letter {
  float: left;
  margin: .32rem .6rem 0 0;
  padding: .32rem .5rem .22rem;
  font: 400 4.3rem/0.8 var(--fell);
  color: var(--leaf);
  background: var(--rubric);
  border: 3px double var(--leaf);
  outline: 1px solid var(--rubric);
}

.gloss {
  margin: 0 0 .9rem;
  padding: .1rem 0 .1rem .75rem;
  border-left: 2px solid var(--rubric);
  font: italic 400 .93rem/1.45 var(--text);
  color: var(--ink-soft);
}
.gloss p { margin: 0; }
.gloss em { font-style: normal; }

@media (min-width: 56rem) {
  .text {
    max-width: calc(var(--gloss) + var(--gutter) + var(--measure));
    display: grid;
    grid-template-columns: [gloss-start] var(--gloss) [gloss-end] var(--gutter) [main-start] minmax(0, var(--measure)) [main-end];
    align-items: start;
  }
  .text > * { grid-column: main; }
  .text > .gloss {
    grid-column: gloss;
    margin: .25rem 0 0;
    padding: 0 .9rem 0 0;
    border-left: 0;
    border-right: 1px solid var(--rubric);
    text-align: right;
    font-size: .88rem;
  }
  .text > .gloss + h2 { margin-top: 2.4rem; }
  /* Wide blocks span the whole measure; glosses never stand beside them. */
  .text > .table, .text > .products, .text > .product-feature, .text > figure { grid-column: gloss-start / main-end; }
  .opener { margin-left: auto; margin-right: auto; }
}

/* Tables: ruled like a printed table */
.table { overflow-x: auto; margin: .6rem 0 1.8rem; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.table table { width: 100%; border-collapse: collapse; font: 400 .98rem/1.45 var(--text); }
.table th { text-align: left; font: 400 .82rem/1.3 var(--fell); letter-spacing: .1em; text-transform: uppercase; color: var(--rubric); padding: .65rem .7rem .45rem; border-bottom: 1px solid var(--ink); vertical-align: bottom; }
.table td { padding: .55rem .7rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td:first-child { font-style: italic; white-space: nowrap; }

figure { margin: 1.5rem 0; }
figure img { margin: 0 auto; }
.text img[src*="mascot"] { width: 9rem; }

/* ---------- Products: oval medallions ---------- */
.products, .product-feature { display: grid; gap: 1.25rem; margin: 1rem 0 2rem; }
.products { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.medallion {
  display: flex; flex-direction: column; align-items: center; gap: .8rem;
  padding: 1.3rem 1rem 1.1rem;
  text-decoration: none; color: var(--ink); text-align: center;
  border: 1px solid var(--rule); background: var(--rag);
}
.medallion:hover { border-color: var(--rubric); }
.medallion:hover .medallion-name { color: var(--rubric); }
.medallion-oval {
  display: block; width: 9.5rem; aspect-ratio: 4 / 5; overflow: hidden;
  border-radius: 50%; background: #fff;
  border: 1px solid var(--ink); outline: 3px double var(--orpiment); outline-offset: 4px;
}
.medallion-oval img { width: 100%; height: 100%; object-fit: contain; padding: 12% 8%; }
.medallion-label { display: flex; flex-direction: column; gap: .3rem; }
.medallion-name { font: italic 400 1.15rem/1.25 var(--fell); }
.medallion-meta { font: 400 .9rem/1.3 var(--text); color: var(--ink-soft); }
.medallion-price { color: var(--ink); font-weight: 700; margin-right: .35rem; }
.medallion-shop { font-variant-caps: all-small-caps; letter-spacing: .06em; }
@media (min-width: 40rem) {
  .medallion.is-single { max-width: 32rem; flex-direction: row; text-align: left; gap: 1.6rem; padding: 1.2rem 1.6rem; }
  .medallion.is-single .medallion-oval { width: 8rem; flex: none; }
}

/* Chapter turns: catchword */
.turn {
  max-width: calc(var(--gloss) + var(--gutter) + var(--measure));
  margin: 2.8rem auto 0; padding-top: 1rem;
  border-top: 1px solid var(--ink);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem 2rem;
}
.turn a { text-decoration: none; color: var(--ink); max-width: 20rem; }
.turn a:hover { color: var(--rubric); }
.turn-label { display: block; font: 400 .78rem/1.3 var(--fell); letter-spacing: .14em; text-transform: uppercase; color: var(--rubric); margin-bottom: .2rem; }
.turn-next { margin-left: auto; text-align: right; }
.catchword { font: italic 400 1.35rem/1.2 var(--fell); }
.turn-full { display: block; font: italic .92rem/1.35 var(--text); color: var(--ink-soft); }
.turn-prev { font: 400 1rem/1.35 var(--text); }

/* ---------- Home: the title page ---------- */
.titlepage { padding: 1rem 1rem 0; }
.tp-leaf {
  max-width: 44rem; margin: 0 auto; padding: 1.75rem 1.1rem 1.6rem;
  background: var(--leaf); text-align: center;
  border: 1px solid var(--ink); outline: 1px solid var(--ink); outline-offset: -7px;
}
@media (min-width: 40rem) {
  .titlepage { padding: 2.5rem 1rem 0; }
  .tp-leaf { padding: 2.75rem 3.25rem 2.25rem; outline-offset: -9px; }
}
.tp-kicker { margin: 0; font: italic 400 1.15rem/1.2 var(--fell); color: var(--ink-soft); letter-spacing: .03em; }
.titlepage h1 { margin: .7rem 0 0; font-weight: 400; }
.tp-main {
  display: block;
  font: 400 clamp(2rem, .9rem + 5.2vw, 3.85rem)/1 var(--fell);
  color: var(--rubric); letter-spacing: 0; text-transform: uppercase; overflow-wrap: anywhere;
}
.tp-sub {
  display: block; margin: 1rem auto 0; padding-top: .9rem; max-width: 26rem;
  border-top: 1px solid var(--ink);
  font: italic 400 clamp(1.3rem, 1rem + 1.3vw, 1.85rem)/1.2 var(--fell); color: var(--ink);
}
.tp-desc { margin: 1rem auto 1.6rem; max-width: 31rem; font: 400 1.02rem/1.55 var(--text); color: var(--ink-soft); }
.frontispiece { margin: 0 auto; max-width: 37rem; }
.frontispiece img { width: 100%; border: 1px solid var(--ink); outline: 1px solid var(--rule); outline-offset: 6px; }
.frontispiece figcaption { margin-top: .9rem; font: italic .9rem/1.4 var(--text); color: var(--ink-soft); }
.tp-device { display: flex; justify-content: center; margin: 1.6rem 0 .9rem; }
.tp-device img { width: 72px; height: 72px; }
.tp-imprint { margin: 0; padding-top: .9rem; border-top: 1px solid var(--ink); display: flex; flex-direction: column; gap: .25rem; font: 400 .8rem/1.45 var(--fell); letter-spacing: .14em; text-transform: uppercase; color: var(--ink); }
.tp-imprint span:last-child { color: var(--rubric); }

/* Home: the contents */
.contents { max-width: 54rem; margin: 2.5rem auto 0; padding: 0 1rem; }
.contents-title { margin: 0 0 1.2rem; text-align: center; font: 400 1.05rem/1 var(--fell); letter-spacing: .3em; text-transform: uppercase; color: var(--ink); }
.contents-title::after { content: ""; display: block; width: 3rem; margin: .8rem auto 0; border-top: 3px double var(--rubric); }
.contents-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0 2.5rem; border-top: 1px solid var(--ink); }
.contents-list li { border-bottom: 1px solid var(--rule); }
.contents-list a { display: grid; grid-template-columns: 5.2rem 1fr; gap: .15rem 1rem; padding: 1rem 0; text-decoration: none; color: var(--ink); }
.contents-list a:hover .c-title { color: var(--rubric); }
.c-num { grid-row: span 2; font: italic 400 1.05rem/1.35 var(--fell); color: var(--rubric); }
.c-title { font: 400 1.22rem/1.3 var(--fell); }
.c-arg { font: italic .95rem/1.45 var(--text); color: var(--ink-soft); }
@media (min-width: 56rem) {
  .contents-list { grid-template-columns: 1fr 1fr; }
}
.reader { margin-top: 2.5rem; }
.reader-title { margin: 0 0 1.75rem; text-align: center; font: italic 400 2rem/1.1 var(--fell); }
.specimen-row { max-width: calc(var(--gloss) + var(--gutter) + var(--measure)); margin: 1.5rem auto 0; padding-top: 1.4rem; border-top: 1px solid var(--rule); }
.specimen-note { margin: 0 0 .9rem; font: italic 1rem/1.45 var(--text); color: var(--ink-soft); }

/* ---------- Colophon ---------- */
.colophon { background: var(--ink); color: #ddd6c8; margin-top: 3rem; }
.colophon-in { max-width: 54rem; margin: 0 auto; padding: 2.2rem 1rem 2.5rem; display: grid; gap: 1.3rem; font: 400 .98rem/1.55 var(--text); }
.colophon a { color: #e8c98a; }
.colophon a:hover { color: #fff; }
.colophon-pub { display: flex; gap: 1.1rem; align-items: center; }
.colophon-mascot { width: 88px; height: 88px; flex: none; object-fit: contain; background: var(--rag); border-radius: 50%; padding: 6px; }
.colophon-pub p { margin: 0; }
.colophon-title { font: 400 .85rem/1.2 var(--fell) !important; letter-spacing: .25em; text-transform: uppercase; color: #c9a65a; margin-bottom: .35rem !important; }
.colophon-disclaimer { margin: 0; padding: .9rem 0; border-top: 1px solid #5a5148; border-bottom: 1px solid #5a5148; font-style: italic; }
.colophon-nav { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.colophon-nav a { text-decoration: none; }
.colophon-set { margin: 0; font: italic .85rem var(--text); color: #a69d8f; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print { .bar, .colophon, .turn { display: none; } body, .leaf { background: #fff; } }
