/* The book page (templates/book.html, under body.bk). Kept out of the Tailwind build so no other
   page changes.

   One day on the plain, painted as a 1930s gouache travel poster: dawn is the hero, a plate opens
   each part of the book, night closes the page. Between the paintings the page is the book's own
   day's light, very faint, going by behind the text (blush, cream,
   straw, apricot, then the rose of dusk; all of it warm), under a little paper tooth, set in the
   site's own faces the way the page always was, with the cover's red and gilt rules. The paintings come from
   static/private/book/paint.py. */

.bk { --paper: #fff; --paper-deep: #f5f5f5; --ink: #2a2420; --ink-soft: #51473e; --red: #930000;
  --gilt: #a9812c; --gilt-lit: #f2c063; --cream: #fbf1d8; --earth: #120818; --sky: #10283f;
  --serif: magister, Georgia, serif; --sans: transat-text, system-ui, sans-serif; --mono: lexia-mono-variable, ui-monospace, monospace; --toc: cardo, magister, serif;
  --col: 46rem;
  margin: 0; background: var(--paper); color: var(--ink); font: 400 1.5rem/1.5 var(--sans); }
html:has(.bk) { scroll-behavior: smooth; }
.bk ::selection { background: var(--gilt-lit); color: var(--ink); }
.bk :focus-visible { outline: 3px solid var(--gilt-lit); outline-offset: 3px; }

/* ---------- buttons: gold where the ground is dark, the cover's red on paper */
.bk-btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; box-sizing: border-box; height: 3.25rem; margin: 0; padding: 0 1.4rem;
  border: 0; border-radius: 3px; font: 500 1.2rem/1 var(--sans); letter-spacing: .01em; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: transform .15s, filter .15s; }
.bk-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.bk-btn:active { transform: none; }
.bk-buy { color: var(--cream); background: var(--red); box-shadow: inset 0 0 0 3px var(--red), inset 0 0 0 4px rgba(242, 192, 99, .7); }
.bk-buy b { font-weight: 500; }
.bk-gold { color: #1c0f12; background: var(--gilt-lit); box-shadow: inset 0 0 0 3px var(--gilt-lit), inset 0 0 0 4px rgba(28, 15, 18, .45); }
.bk-line { color: var(--cream); background: rgba(16, 8, 24, .28); box-shadow: inset 0 0 0 1px rgba(251, 241, 216, .7); backdrop-filter: blur(3px); }
.bk-acts { display: flex; flex-wrap: wrap; gap: .8rem; margin: 0; }
.bk-sale { margin: .9rem 0 0; font: italic 400 1.15rem/1.4 var(--serif); }

/* ---------- the two paintings that fill the window: dawn above, night below */
.bk-hero, .bk-after { position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; color: var(--cream); background: var(--earth); }
.bk-art, .bk-art img { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; }
.bk-art img { object-fit: cover; object-position: 50% 100%; }

/* The hero is never wider than the painting can stand: the words keep to the sky above the gnu. */
.bk-hero { min-height: max(100svh, 44rem, 54vw); }
.bk-hero-in { flex: 1; width: 100%; max-width: 86rem; margin: 0 auto; padding: clamp(3rem, 9vh, 6rem) clamp(1.25rem, 5vw, 4.5rem) 0; }
.bk-words { max-width: 44rem; text-shadow: 0 1px 18px rgba(16, 40, 63, .55); }
.bk-hero h1 { margin: 0 0 1.1rem; font: italic 700 clamp(2.7rem, 5.1vw, 5.4rem)/1.05 var(--serif); letter-spacing: .03em; text-indent: -.42em; text-wrap: balance; }
.bk-promise { max-width: 30rem; margin: 0 0 2rem; font: 400 clamp(1.3rem, 1.9vw, 1.75rem)/1.35 var(--sans); text-wrap: balance; }
.bk-hero .bk-acts { text-shadow: none; }

/* Where it can, bookhero.js paints the dawn moving on a canvas. Until that is ready the hero is the dawn sky's
   own colours and the still painting is held back (html.bk-live, set in the head), so only one picture is ever
   seen; the canvas waits, all but invisible, until it runs smoothly, and is then faded in with its paper grain. */
.bk-live .bk-hero { background: linear-gradient(#10283f, #253c5c 20%, #5d4a72 38%, #b05a6e 52%, #e5805a 64%, #57294f 78%, var(--earth) 90%); }
.bk-live .bk-hero .bk-art img { opacity: 0; }
.bk-alive, .bk-tooth { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; transition: opacity .9s; }
.bk-alive { opacity: .01; }
.bk-tooth { opacity: 0; background-size: 100% 100%, 160px; pointer-events: none; }
.bk-alive.bk-on, .bk-alive.bk-on ~ .bk-tooth, .bk-alive.bk-on ~ .bk-book { opacity: 1; }
/* the book, sharp, over the canvas's own; and the light that catches its cover now and then */
.bk-book { position: absolute; z-index: -1; opacity: 0; transition: opacity .9s; pointer-events: none; background: var(--pic) 0 0 / 100% 100% no-repeat;
  -webkit-mask-image: linear-gradient(#000 85%, transparent 94%); mask-image: linear-gradient(#000 85%, transparent 94%); }
.bk-book::after { content: ''; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 42%, rgba(255, 241, 200, .38) 50%, transparent 58%) 150% 0 / 300% 100% no-repeat;
  -webkit-mask: var(--pic) 0 0 / 100% 100% no-repeat; mask: var(--pic) 0 0 / 100% 100% no-repeat; }
.bk-alive.bk-on ~ .bk-book::after { animation: bk-glint 14s 5.5s infinite; }
@keyframes bk-glint { 0% { background-position: 150% 0; } 10%, 100% { background-position: -50% 0; } }
@media (prefers-reduced-motion: no-preference) {
  .bk-words { animation: bk-arrive 1.4s .5s cubic-bezier(.2, .6, .2, 1) both; }
}
@keyframes bk-arrive { from { opacity: 0; transform: translateY(14px); } }

/* ---------- the same dawn on the site's front page (templates/index.html): a still band under the menu */
.bk.bk-home { min-height: 0; margin-bottom: 4rem; }
.bk-scene { position: relative; display: flex; flex-direction: column; min-height: max(30rem, 42vw); }
.bk-home .bk-hero-in { flex: 1; padding-top: clamp(2rem, 3.4vw, 3.5rem); }
.bk-home h1 { margin-bottom: .8rem; text-indent: 0; font-style: normal; letter-spacing: .01em; }
.bk-home h1 span { display: block; margin-bottom: .1em; font: italic 400 .5em/1.2 var(--serif); letter-spacing: .02em; }
.bk-home .bk-promise { margin: 0; }
.bk-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem; box-sizing: border-box; width: 100%; max-width: 86rem; margin: 0 auto;
  padding: 1.4rem clamp(1.25rem, 5vw, 4.5rem) 1.6rem; }
.bk-out { margin: 0; font: 400 1.25rem/1.4 var(--sans); }
.bk-out strong { font-weight: 500; color: var(--gilt-lit); }
.bk-out .bk-sale { display: block; margin: .15rem 0 0; color: var(--gilt-lit); }
.bk-timer { margin-left: .6em; color: var(--cream); font: 400 1.05rem var(--sans); font-variant-numeric: tabular-nums; }
.bk-timer b { font-weight: 500; }

/* ---------- what you get, set on the dark of the hill the gnu stands on */
.bk-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem 0; margin: 0; padding: 1.15rem 1.25rem 1.3rem; list-style: none;
  color: var(--cream); background: var(--earth); font: 400 1.1rem/1.4 var(--sans); letter-spacing: .02em; text-align: center; }
.bk-facts strong { font-weight: 500; color: var(--gilt-lit); }
.bk-facts li + li::before { content: ''; display: inline-block; width: .42em; height: .42em; margin: 0 1.1em .12em; background: var(--gilt-lit); transform: rotate(45deg); }

/* ---------- the text */
.bk-main { padding: 1px 0 5rem;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .2 0 0 0 .5 -.2'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 220px,
    linear-gradient(#fcf3ee, #fdf7ea 20%, #fbf5e0 40%, #fdefdf 60%, #fbe9e2 82%, #f7e6e4); }
.bk-col { max-width: calc(var(--col) + 2.5rem); margin: 0 auto; padding: 0 1.25rem; }
.bk-col p { margin: 0 0 1.15em; text-wrap: pretty; }
.bk-col a:not(.bk-btn) { color: var(--red); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
.bk-col strong, .bk-after strong { font-weight: 500; }
/* code: the site's is pink on cold grey, which is wrong on this ground; here, ink on a warm chip */
.bk .bk-col code { font: 400 .86em var(--mono); padding: .12em .38em; color: var(--ink) !important; background: rgba(169, 129, 44, .15); border: 0; border-radius: 3px; }
.bk-lede { margin: 4.5rem 0 0 !important; font-size: clamp(1.5rem, 2.4vw, 1.75rem); line-height: 1.45; text-align: center; text-wrap: balance; }
.bk-main h2, .bk-after h2 { margin: 4.5rem 0 1.6rem; font: italic 700 clamp(2.1rem, 4.4vw, 3rem)/1.08 var(--serif); text-align: center; text-wrap: balance; }
.bk-roman { font-style: normal; white-space: nowrap; }
.bk-part h2 { margin-top: 3rem; }

/* What each part teaches. The pointing hand before each term is the site's own. */
.bk-col dl { margin: 2.4rem 0 0; }
.bk-col dt { margin: 2.1rem 0 .5rem; color: var(--red); font: 500 1.5rem/1.25 var(--sans); }
.bk-col dd { margin: 0; padding-left: 1.4rem; border-left: 1px solid var(--gilt); }
.bk-col dd > p:last-child { margin-bottom: 0; }

/* ---------- plates: the paintings tipped in, each in the cover's double gilt rule */
.bk-plate { width: min(100% - 2.5rem, 78rem); margin: 6rem auto 0; padding: 7px; border: 1px solid var(--gilt); outline: 1px solid var(--gilt); outline-offset: 5px; background: var(--paper); }
.bk-plate img { display: block; width: 100%; height: auto; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; aspect-ratio: 2.4; object-fit: cover; object-position: var(--focus, 50%) 50%; background: var(--paper-deep); }
@media (max-width: 720px) {
  .bk-plate { margin-top: 4.5rem; }
  .bk-plate img { aspect-ratio: 1.45; }
}

/* ---------- readers */
.bk-quote { position: relative; margin: 3.4rem 0; padding: 0 0 0 3.2rem; }
.bk-quote::before { content: '“'; position: absolute; left: -.3rem; top: -.9rem; color: var(--red); font: 700 6rem/1 var(--serif); }
.bk-quote blockquote { margin: 0; color: var(--ink); font: italic 400 1.6rem/1.45 var(--serif); text-wrap: pretty; }
.bk-quote blockquote em { font-style: normal; font-weight: inherit; color: inherit; text-decoration: none; }   /* undo the site's teal */
.bk-quote blockquote p { margin: 0 0 .8em; }
.bk-quote figcaption { margin-top: .8rem; text-align: left; color: var(--ink); font: 500 1.125rem/1.4 var(--sans); }
.bk-quote figcaption a { margin-left: .9em; font-weight: 400; white-space: nowrap; }
.bk-quote-last { margin: 5rem 0 0; }

/* ---------- a place to buy, between gilt rules */
.bk-break { display: flex; flex-direction: column; align-items: center; gap: 1.4rem; margin: 4rem 0 0; text-align: center; }
.bk-break .bk-sale { margin: -.5rem 0 0; }
.bk-rule { position: relative; display: block; width: min(22rem, 80%); height: 11px; background: linear-gradient(var(--gilt), var(--gilt)) center / 100% 1px no-repeat; }
.bk-rule::before, .bk-rule::after { content: ''; position: absolute; top: 50%; left: 50%; width: 9px; height: 9px; background: #fff; border: 1px solid var(--gilt); transform: translate(-50%, -50%) rotate(45deg); }
.bk-rule::after { width: 3px; height: 3px; background: var(--gilt); border: 0; }

/* ---------- the free sample: a card in the same double gilt rule as the plates */
.bk-sample { width: min(100% - 2.5rem, 52rem); box-sizing: border-box; margin: 6rem auto 0; padding: 2.4rem clamp(1.25rem, 5vw, 3rem) 2.6rem;
  border: 1px solid var(--gilt); outline: 1px solid var(--gilt); outline-offset: 5px; background: rgba(255, 255, 255, .6); text-align: center; }
.bk-sample h3 { margin: 0 0 .5rem; font: 700 clamp(1.7rem, 3.2vw, 2.2rem)/1.15 var(--serif); }
.bk-sample p { margin: 0 auto 1.5rem; max-width: 36rem; text-wrap: balance; }
.bk-sample form { display: flex; flex-wrap: wrap; gap: .7rem; max-width: 36rem; margin: 0 auto; }
.bk-sample input[type=email] { flex: 1 1 16rem; min-height: 3.25rem; padding: 0 1rem; color: var(--ink); background: #fff; border: 1px solid var(--gilt); border-radius: 3px; font: 400 1.15rem var(--sans); }
.bk-sample input[type=email]::placeholder { color: #7b7064; }

/* ---------- questions */
.bk-faq { border-top: 1px solid var(--gilt); }
.bk-faq details { border-bottom: 1px solid var(--gilt); }
.bk-faq summary { display: flex; align-items: baseline; gap: 1rem; padding: 1.05rem 0; cursor: pointer; list-style: none; font: 400 1.5rem/1.3 var(--sans); }
.bk-faq summary::-webkit-details-marker { display: none; }
.bk-faq summary::before { content: '+'; flex: none; width: 1.1rem; color: var(--red); font: 400 1.5rem/1 var(--sans); text-align: center; transition: transform .2s; }
.bk-faq details[open] summary::before { transform: rotate(45deg); }
.bk-faq summary em { font-style: italic; }
.bk-faq details > div { padding: 0 0 1.3rem 2.1rem; font-family: var(--serif); }
.bk-faq details > div > p:last-child { margin-bottom: 0; }

/* ---------- the table of contents (_toc.html), brought down to reading size and onto paper */
.bk #toc { position: relative; margin-top: 1rem; }
.bk #expand[hidden] { display: none; }   /* the site's display: flex would keep it on screen */
.bk .toc { font: 400 1.3rem/1.4 var(--toc); }
.bk .toc > li { margin: .3rem 0 .3rem 1.3rem; }
.bk #toc > .toc { columns: 2 17rem; column-gap: 3rem; }
.bk #toc > .toc > li { break-inside: avoid-column; margin: 0 0 1.4rem; }
.bk .toc-entry-main { color: var(--red); font: 700 1.5rem/1.3 var(--toc); }
.bk .toc-collapsed { height: 22rem; }
.bk .toc-collapsed > .toc { width: 100%; }
.bk .toc-fade { background: none; }
/* Faded out by lengths, not percentages: the list is far taller than the window it shows through. */
.bk .toc-collapsed > .toc { -webkit-mask-image: linear-gradient(#000 7rem, transparent 17.5rem); mask-image: linear-gradient(#000 7rem, transparent 17.5rem); }
.bk #expand { font-size: 1.15rem; justify-content: center; align-items: flex-end; }
.bk #expand > a { margin: 0; padding: .8rem 1.3rem; color: var(--cream); background: var(--red); border-radius: 3px; text-decoration: none; }

/* ---------- night: after the book */
.bk-after { min-height: max(100svh, 46rem, 56vw); }
.bk-after .bk-art img { object-position: 32% 100%; }
.bk-after-in { flex: 1; width: 100%; max-width: calc(var(--col) + 2.5rem); margin: 0 auto; padding: clamp(3.5rem, 9vh, 6rem) 1.25rem 22rem; text-shadow: 0 1px 14px rgba(6, 11, 34, .9); }
.bk-after h2 { margin-top: 0; }
.bk-after p { margin: 0 0 1.15em; text-wrap: pretty; }
.bk-after strong { color: var(--gilt-lit); }
.bk-after .bk-quote { margin: 2rem 0 0; }
.bk-after .bk-quote::before { color: var(--gilt-lit); }
.bk-after .bk-quote blockquote, .bk-after .bk-quote figcaption { color: var(--cream); }
.bk-after .bk-quote a { color: var(--gilt-lit); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
.bk-after .bk-acts { justify-content: center; margin-top: 2.2rem; text-shadow: none; }
.bk-after .bk-sale { text-align: center; }
.bk-foot { margin: 0; padding: 1rem 1.25rem 1.2rem; font-size: .95rem; text-align: center; color: rgba(251, 241, 216, .75); text-shadow: 0 1px 6px #040818; }
.bk-foot a { color: inherit; text-decoration: underline; }

/* ---------- narrow: the tall cut of the dawn */
@media (max-aspect-ratio: 4/5) {
  .bk-hero { min-height: max(100svh, 150vw); }
  .bk-hero .bk-art img { object-position: 42% 100%; }
}
@media (max-width: 640px) {
  .bk { font-size: 1.2rem; }
  .bk-hero h1 { text-indent: 0; }
  .bk-facts { flex-direction: column; gap: .15rem; }
  .bk-facts li + li::before { display: none; }
  .bk-quote { padding-left: 0; padding-top: 2.6rem; }
  .bk-quote::before { left: -.2rem; top: -.6rem; }
  .bk-quote blockquote { font-size: 1.35rem; }
  .bk-col dt, .bk-faq summary { font-size: 1.25rem; }
  .bk-col dd { padding-left: 1rem; }
  .bk-after-in { padding-bottom: 27rem; }
}
