/* buchkegel.de
   Two colours only: ink and paper. One typeface in three weights.
   Times New Roman ships Regular and Bold; where it has no Light face the
   light weight shows as Regular. */

:root {
  --ink: #000;
  --paper: #fff;
  --light: 300;
  --normal: 400;
  --heavy: 700;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --measure: 38rem;
  color-scheme: only light;
}

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

html {
  background: var(--paper);
  color: var(--ink);
  font-family: "Times New Roman", Times, serif;
  font-weight: var(--normal);
  font-size: clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

h1,
h2,
h3,
h4 {
  font-weight: var(--heavy);
}

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

.footer ::selection,
.leave ::selection {
  background: var(--paper);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* ---------- Landing page: sky, surface, the books ---------- */

.home main {
  display: flex;
  flex-direction: column;
}

.sky {
  flex: none;
  min-height: 56vh;
  min-height: 56svh;
  display: flex;
  flex-direction: column;
}

.sky__title {
  margin: auto;
  padding: 3rem var(--gutter) 0.5rem;
  text-align: center;
  text-wrap: balance;
  font-size: clamp(2.5rem, min(7.5vw, 14vh), 6.5rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
}

/* The animated strip, 170px high with the calm water line at 118px. The
   waves are pictures that repeat (assets/img); each strip is one period wider
   than the page, and boat.js shifts it by at most that period. Shifting a
   strip and moving the boat only changes transforms, so the browser paints
   nothing anew while the animation runs. */
.surface {
  position: relative;
  flex: none;
  height: 170px;
  overflow: hidden;
}

.surface__strip {
  position: absolute;
  left: 0;
  background-repeat: repeat-x;
  will-change: transform;
}

.surface__swell {
  top: 95px;
  width: calc(100% + 448px);
  height: 24px;
  background-image: url("/assets/img/swell.svg");
  background-size: 448px 24px;
}

/* Two layers of sea that drift against each other. What shows is the higher
   of the two, so the water line changes its shape. */
.surface__sea {
  top: 102px;
  height: 68px;
}

.surface__sea--a {
  width: calc(100% + 384px);
  background-image: url("/assets/img/sea-a.svg");
  background-size: 384px 68px;
}

.surface__sea--b {
  width: calc(100% + 256px);
  background-image: url("/assets/img/sea-b.svg");
  background-size: 256px 68px;
}

.surface__ripple {
  width: calc(100% + 292px);
  height: 8px;
  background-image: url("/assets/img/ripple.svg");
  background-size: 292px 8px;
}

.surface__ripple--a {
  top: 138px;
}

.surface__ripple--b {
  top: 153px;
  background-position: 146px 0;
}

/* The point of the boat that sits on the water is at 70px 78px of its box.
   The transform here is the still picture; boat.js replaces it. */
.surface__boat {
  position: absolute;
  left: 0;
  top: 0;
  width: 140px;
  height: 92px;
  overflow: visible;
  transform-origin: 70px 78px;
  transform: translate(calc(62vw - 70px), 43px);
  will-change: transform;
}

.boat__sail,
.boat__hull {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.boat__shade {
  fill: var(--ink);
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

/* The water below the strip, and how it ends: fade.svg draws its underside
   and wavy lines that get thinner and further apart, so the page turns to
   paper again without a grey. */
.deep {
  position: relative;
  flex: none;
  height: 3.25rem;
  margin: -1px 0 141px; /* overlaps the strip, so no paper shows between them */
  background: var(--ink);
}

.deep::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  height: 142px;
  background: url("/assets/img/fade.svg") repeat-x center top / 96px 142px;
}

/* The books: a row that scrolls sideways and snaps, one book to a page. */
.shelf {
  padding: clamp(1.5rem, 5vw, 3rem) 0 clamp(3rem, 8vw, 5.5rem);
}

.shelf__head[hidden] {
  display: none;
}

.shelf__head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  min-height: 2.75rem;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  padding: 0 var(--gutter);
}

.shelf__label {
  margin: 0;
  min-width: 8em;
  text-align: center;
}

.shelf__turn {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.shelf__turn:hover,
.shelf__turn:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.shelf__row {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
}

/* With the buttons there, the scroll bar is not needed to get along. */
.shelf--live .shelf__row {
  scrollbar-width: none;
}

.shelf--live .shelf__row::-webkit-scrollbar {
  display: none;
}

.shelf__book {
  flex: none;
  width: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: grid;
  grid-template-columns: minmax(0, 16rem) minmax(0, 32rem);
  justify-content: center;
  align-items: center; /* cover and text share one middle line */
  gap: clamp(2rem, 5vw, 4rem);
  padding: 0.5rem var(--gutter) 1.5rem;
}

.shelf__cover {
  display: block;
  box-shadow: 0.5rem 0.5rem 0 var(--ink);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.shelf__cover:hover {
  transform: scale(1.03);
}

.shelf__cover img {
  display: block;
  width: 100%;
  height: auto;
}

.shelf__title {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.shelf__title a {
  text-decoration: none;
}

.shelf__title a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.shelf__kind {
  margin: 0.5rem 0 1.4rem;
  font-size: 1.15rem;
  font-weight: var(--light);
}

.shelf__blurb {
  margin: 0 0 1em;
  hyphens: auto;
}

.shelf__more {
  margin: 1.4rem 0 0;
  font-weight: var(--heavy);
}

.shelf__more a::after {
  content: "\00a0\2192"; /* arrow to the right */
  font-weight: var(--normal);
}

/* Narrow pages: the cover on top, title and blurb below it. */
@media (max-width: 44rem) {
  .shelf__book {
    grid-template-columns: minmax(0, 32rem);
    justify-items: center;
  }

  .shelf__cover {
    width: min(58vw, 14rem);
  }

  .shelf__text {
    width: 100%;
  }

  .shelf__title,
  .shelf__kind {
    text-align: center;
  }
}

/* ---------- Footer: the sea at the bottom of every page ---------- */

.footer {
  position: relative;
  margin-top: 16px;
  padding: 1.5rem var(--gutter) 1.75rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85rem;
  font-weight: var(--light);
  text-align: center;
}

.footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% - 1px);
  height: 16px;
  background: url("/assets/img/wave.svg") repeat-x left bottom / 96px 16px;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1.6rem;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
}

.footer a {
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer__note {
  margin: 0;
}

/* ---------- Pages below the landing page ---------- */

.masthead {
  padding: 1.25rem var(--gutter);
}

.masthead__home {
  display: inline-block;
  font-size: 1.15rem;
  text-decoration: none;
}

.masthead__name {
  font-weight: var(--heavy);
}

.masthead__tld {
  font-weight: var(--light);
}

.masthead__home:hover .masthead__name {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

.page {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(1.5rem, 6vw, 4rem) var(--gutter) clamp(4rem, 10vw, 7rem);
}

.label {
  margin: 0 0 0.7rem;
  font-size: 0.8rem;
  font-weight: var(--light);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Legal texts */
.prose {
  hyphens: auto;
  hyphenate-limit-chars: 10 4 4; /* short words such as "Social" stay whole */
  overflow-wrap: break-word;
}

.prose h1 {
  margin: 0 0 0.7em;
  font-size: clamp(2.25rem, 7vw, 3.75rem);
  line-height: 1;
  letter-spacing: -0.015em;
  hyphens: manual;
}

.prose h2 {
  margin: 2.4em 0 0.5em;
  font-size: 1.6rem;
  line-height: 1.15;
}

.prose h3 {
  margin: 2em 0 0.4em;
  font-size: 1.2rem;
  line-height: 1.25;
}

.prose h4 {
  margin: 1.6em 0 0.3em;
  font-size: 1rem;
}

.prose p,
.prose ul {
  margin: 0 0 1em;
}

.prose ul {
  padding-left: 1.2em;
}

.prose li {
  margin-bottom: 0.4em;
}

.prose a {
  overflow-wrap: anywhere;
}

/* Book page */
.book__title {
  margin: 0 0 0.3em;
  font-size: clamp(2.6rem, 9vw, 5.25rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.book__author {
  margin: 0 0 clamp(2.5rem, 7vw, 4rem);
  font-size: 1.3rem;
  font-weight: var(--light);
}

.book__section {
  margin: 0 0 clamp(2.5rem, 7vw, 4rem);
}

.book__blurb p {
  margin: 0 0 1em;
  hyphens: auto;
}

.book__editions {
  margin: 0;
  font-size: 1.2rem;
}

/* Shop links, one row each. Not in use while the book page names no shop. */
.shops {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--ink);
}

.shops li {
  border-bottom: 1px solid var(--ink);
}

.shops a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.6rem;
  font-size: 1.45rem;
  font-weight: var(--heavy);
  line-height: 1.2;
  text-decoration: none;
}

.shops a::after {
  content: "\2192"; /* arrow to the right */
  font-weight: var(--normal);
}

.shops a:hover,
.shops a:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

/* The reading sample, set like a page of the book: justified, a small gap
   between paragraphs, no indent. */
.sample {
  padding: clamp(1.5rem, 5vw, 2.5rem) 0 clamp(1rem, 4vw, 1.75rem);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.sample__chapter {
  margin: 0 0 0.5em;
  font-size: 1.6rem;
  line-height: 1.15;
  text-align: center;
}

.sample p {
  margin: 0 0 0.73em;
  text-align: justify;
  hyphens: auto;
}

.sample p.sample__date {
  margin-bottom: 1.85em;
  font-size: 1.15rem;
  font-style: italic;
  text-align: center;
}

.sample__end {
  margin: 1rem 0 0;
  font-weight: var(--light);
}

.back {
  margin: 0;
}

/* 404 */
.lost {
  text-align: center;
}

.lost h1 {
  margin: 0 0 0.5em;
  font-size: clamp(2.25rem, 7vw, 3.75rem);
  line-height: 1;
  text-wrap: balance;
}

/* ---------- Leaving the site: the page turns to ink ---------- */

html:has(.leave[open]) {
  overflow: hidden;
}

.leave {
  width: min(34rem, 100%);
  max-width: 100%;
  margin: auto;
  padding: 2rem var(--gutter);
  border: 0;
  background: var(--ink);
  color: var(--paper);
  text-align: center;
}

.leave::backdrop {
  background: var(--ink);
}

.leave__title {
  margin: 0 0 0.5em;
  font-size: clamp(1.9rem, 6vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.leave__text {
  margin: 0 0 1.8em;
}

.leave__host {
  font-weight: var(--heavy);
  overflow-wrap: anywhere;
}

.leave__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 2px solid var(--paper);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: var(--heavy);
  text-decoration: none;
  cursor: pointer;
}

.button--solid {
  background: var(--paper);
  color: var(--ink);
}

.button:hover {
  background: var(--paper);
  color: var(--ink);
}

.button--solid:hover {
  background: var(--ink);
  color: var(--paper);
}

@media (prefers-reduced-motion: reduce) {
  .shelf__cover {
    transition: none;
  }
}
