/* Awaited Book - design tokens
   Palette drawn from the logo: marmalade cat, oxblood cloth binding, cream paper, sepia ink. */
:root {
  /* Color */
  --desk: #24160f;            /* walnut reading desk behind the book */
  --cover: #6e161c;           /* oxblood cloth binding */
  --cover-deep: #4b0e13;
  --paper: #f6eedc;           /* cream laid paper */
  --paper-shade: #ecdfc2;
  --edge-light: #efe5cd;      /* page block edge */
  --edge-dark: #cdbd9a;
  --ink: #3b1f0e;             /* sepia ink, body text */
  --ink-soft: #6a4630;        /* secondary text */
  --accent: #d9772b;          /* the cat's orange: ribbon, ornaments, large type */
  --accent-ink: #a34e12;      /* orange deep enough for small text on paper */
  --gilt: #b8893a;            /* gold tooling */

  /* Type */
  --font-display: "Cormorant Garamond", "EB Garamond", Garamond, "Times New Roman", serif;
  --font-body: "EB Garamond", Garamond, "Times New Roman", serif;

  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.84rem + 0.2vw, 0.95rem);
  --text-base: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  --text-lg: clamp(1.2rem, 1.1rem + 0.5vw, 1.4rem);
  --text-xl: clamp(1.6rem, 1.3rem + 1.2vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.5rem + 2vw, 3rem);
  --text-hero: clamp(2.75rem, 1.9rem + 3.6vw, 4.75rem);

  /* Space (4px scale) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  --page-pad-x: clamp(1.5rem, 1rem + 3vw, 4.25rem);
  --page-pad-y: clamp(2.5rem, 2rem + 2.5vw, 4.5rem);
  --measure: 34em;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-height: 100vh; line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }

/* Desk */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink);
  background-color: var(--desk);
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(120, 70, 35, 0.35), transparent 65%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.55), transparent 60%);
  background-attachment: fixed;
  padding: clamp(1rem, 3vw, 3.5rem) clamp(0.5rem, 2.5vw, 2.5rem);
  font-variant-numeric: oldstyle-nums;
  font-kerning: normal;
  font-feature-settings: "liga", "kern";
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--paper); color: var(--ink); padding: var(--space-2) var(--space-4);
}
.skip:focus { left: var(--space-4); top: var(--space-4); z-index: 10; }

/* The book */
.book {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  gap: clamp(2rem, 5vw, 4.5rem);
}

/* A spread is an open book: the cloth cover peeks around two facing pages */
.spread {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 12px 14px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, transparent 49.2%, rgba(0, 0, 0, 0.35) 50%, transparent 50.8%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='c'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .22 0'/></filter><rect width='100%' height='100%' filter='url(%23c)'/></svg>"),
    linear-gradient(180deg, var(--cover), var(--cover-deep));
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.04) inset,
    0 30px 60px -20px rgba(0, 0, 0, 0.7),
    0 12px 24px -12px rgba(0, 0, 0, 0.6);
  animation: open 900ms cubic-bezier(.2, .7, .2, 1) both;
}
.spread + .spread { animation-delay: 120ms; }

@keyframes open {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* Pages */
.page {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: min(88vh, 860px);
  padding: var(--page-pad-y) var(--page-pad-x) calc(var(--page-pad-y) + var(--space-4));
  background-color: var(--paper);
  isolation: isolate;
}

/* Paper grain */
.page::before {
  content: "";
  position: absolute; inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .32  0 0 0 0 .15  0 0 0 .18 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
}

/* Left page: gutter shadow on the right, page block edge on the left */
.page--verso {
  border-radius: 4px 0 0 4px;
  background-image:
    linear-gradient(to left, rgba(70, 40, 15, 0.28), rgba(70, 40, 15, 0.08) 3.5%, transparent 11%),
    linear-gradient(to right, rgba(255, 255, 255, 0.35), transparent 6%),
    radial-gradient(ellipse at 40% 45%, var(--paper) 55%, var(--paper-shade));
  box-shadow:
    -1px 0 0 var(--edge-light), -2px 0 0 var(--edge-dark),
    -3px 1px 0 var(--edge-light), -4px 1px 0 var(--edge-dark),
    -5px 2px 0 var(--edge-light), -6px 2px 0 var(--edge-dark);
}

/* Right page: gutter shadow on the left, page block edge on the right */
.page--recto {
  border-radius: 0 4px 4px 0;
  background-image:
    linear-gradient(to right, rgba(70, 40, 15, 0.28), rgba(70, 40, 15, 0.08) 3.5%, transparent 11%),
    linear-gradient(to left, rgba(255, 255, 255, 0.35), transparent 6%),
    radial-gradient(ellipse at 60% 45%, var(--paper) 55%, var(--paper-shade));
  box-shadow:
    1px 0 0 var(--edge-light), 2px 0 0 var(--edge-dark),
    3px 1px 0 var(--edge-light), 4px 1px 0 var(--edge-dark),
    5px 2px 0 var(--edge-light), 6px 2px 0 var(--edge-dark);
}

/* Running heads and folios */
.running-head {
  position: absolute;
  top: calc(var(--page-pad-y) * 0.45);
  left: var(--page-pad-x); right: var(--page-pad-x);
  font-size: var(--text-xs);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
  text-align: center;
}
.running-head span { font-size: 1.15em; }

.folio {
  position: absolute;
  bottom: calc(var(--page-pad-y) * 0.45);
  left: 0; right: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}
.folio::before, .folio::after { content: "\2014"; color: var(--gilt); margin: 0 0.6em; }

/* Ribbon bookmark in the cat's orange */
.ribbon {
  position: absolute;
  top: 4px;
  right: calc(var(--page-pad-x) + 14px);
  width: 22px;
  height: 128px;
  z-index: 2;
  background: linear-gradient(90deg, #b85f1c, var(--accent) 35%, #e78a3c 55%, #c2671f);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
  filter: drop-shadow(1px 3px 2px rgba(60, 25, 5, 0.35));
  transform-origin: top center;
  animation: ribbon 1.6s 400ms cubic-bezier(.3, .8, .3, 1) both;
}
@keyframes ribbon {
  from { height: 0; }
  to { height: 128px; }
}

/* Title page */
.page--title { justify-content: center; text-align: center; }
.title-block { display: grid; justify-items: center; gap: var(--space-3); }

.mark {
  width: clamp(190px, 26vw, 330px);
  margin-bottom: var(--space-2);
  filter: drop-shadow(0 6px 10px rgba(90, 45, 10, 0.12));
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-hero);
  line-height: 1;
  letter-spacing: 0.005em;
  color: var(--ink);
}

.fleuron-rule {
  display: flex; align-items: center; gap: var(--space-3);
  width: min(240px, 70%);
  color: var(--accent);
  font-size: var(--text-lg);
  line-height: 1;
}
.fleuron-rule::before, .fleuron-rule::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gilt));
}
.fleuron-rule::after { background: linear-gradient(90deg, var(--gilt), transparent); }

.subtitle {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 500;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.28em;
  color: var(--accent-ink);
}

.imprint {
  margin-top: var(--space-8);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Chapter pages */
.chapter-label {
  margin-top: var(--space-8);
  font-size: var(--text-sm);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.3em;
  color: var(--accent-ink);
  text-align: center;
}

h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-2xl);
  line-height: 1.12;
  text-align: center;
  text-wrap: balance;
  max-width: 16em;
  margin: var(--space-3) auto var(--space-8);
  color: var(--ink);
}
h2::after {
  content: "\2766";
  display: block;
  margin-top: var(--space-4);
  font-size: var(--text-base);
  color: var(--accent);
}

.page p:not(.chapter-label):not(.subtitle):not(.imprint):not(.fleuron-rule):not(.aside):not(.letter) {
  max-width: var(--measure);
  hyphens: auto;
  -webkit-hyphens: auto;
  text-align: justify;
  text-wrap: pretty;
}
.page p + p { text-indent: 1.5em; }
.page p.dropcap + p { text-indent: 1.5em; }

.dropcap::first-letter {
  float: left;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 5.1em;
  line-height: 0.76;
  padding: 0.08em 0.1em 0 0;
  color: var(--accent);
}
.dropcap .lead {
  font-variant-caps: small-caps;
  letter-spacing: 0.05em;
}

.page p.aside {
  max-width: 24em;
  margin-top: var(--space-8);
  text-indent: 0;
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--ink-soft);
  margin-left: auto; margin-right: auto;
}

/* Table of contents style list */
.contents {
  list-style: none;
  padding: 0;
  margin-top: var(--space-10);
  max-width: var(--measure);
  border-top: 1px solid rgba(184, 137, 58, 0.55);
}
.contents li {
  display: grid;
  grid-template-columns: 2.6em 1fr;
  align-items: baseline;
  padding: var(--space-3) 0;
  border-bottom: 1px solid rgba(184, 137, 58, 0.35);
}
.contents .num {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent-ink);
}
.contents strong {
  font-weight: 500;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.12em;
  font-size: 1.08em;
}

/* Colophon */
.details {
  max-width: var(--measure);
  width: 100%;
  margin: 0 auto;
}
.details div {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}
.details dt {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  white-space: nowrap;
}
/* dot leaders */
.details dd {
  order: 2;
  margin-left: auto;
  text-align: right;
}
.details div::before {
  content: "";
  order: 1;
  flex: 1;
  min-width: 1.5em;
  border-bottom: 2px dotted rgba(106, 70, 48, 0.45);
  transform: translateY(-0.3em);
}
.details dt { order: 0; }

.page a {
  color: var(--accent-ink);
  text-decoration-color: rgba(163, 78, 18, 0.4);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}
.page a:hover { color: var(--ink); text-decoration-color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.page p.letter {
  margin: var(--space-10) auto 0;
  text-align: center;
  text-indent: 0;
}

.finis {
  margin-top: auto;
  padding-top: var(--space-10);
  display: grid;
  justify-items: center;
  gap: var(--space-1);
}
.finis img { width: 64px; opacity: 0.9; }
.finis p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--ink-soft);
  letter-spacing: 0.06em;
}

.site-foot {
  text-align: center;
  margin-top: var(--space-10);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  font-variant-caps: all-small-caps;
  color: rgba(246, 238, 220, 0.72);
}
.site-foot p { font-size: 1.2em; }
.site-foot a { color: rgba(246, 238, 220, 0.9); text-underline-offset: 0.2em; }

/* Single page on narrow screens: the book is held closed to one leaf */
@media (max-width: 860px) {
  .spread {
    grid-template-columns: 1fr;
    padding: 8px 8px 8px 10px;
    background:
      url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='c'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .22 0'/></filter><rect width='100%' height='100%' filter='url(%23c)'/></svg>"),
      linear-gradient(180deg, var(--cover), var(--cover-deep));
  }
  .page {
    min-height: auto;
    border-radius: 2px 4px 4px 2px;
    background-image:
      linear-gradient(to right, rgba(70, 40, 15, 0.22), rgba(70, 40, 15, 0.05) 4%, transparent 12%),
      radial-gradient(ellipse at 55% 40%, var(--paper) 55%, var(--paper-shade));
    box-shadow:
      1px 0 0 var(--edge-light), 2px 0 0 var(--edge-dark),
      3px 1px 0 var(--edge-light), 4px 1px 0 var(--edge-dark);
  }
  .page + .page { margin-top: 10px; }
  .page--title { padding-top: calc(var(--page-pad-y) + var(--space-6)); }
  .page p:not(.chapter-label):not(.subtitle):not(.imprint):not(.fleuron-rule):not(.aside):not(.letter) { text-align: left; }
  .ribbon { right: 28px; height: 96px; }
  @keyframes ribbon { from { height: 0; } to { height: 96px; } }
  .mark { width: min(62vw, 260px); }
}

@media (max-width: 420px) {
  .details div { flex-wrap: wrap; }
  .details div::before { display: none; }
  .details dd { margin-left: 0; text-align: left; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .spread, .ribbon { animation: none; }
}

.page .title-block p { text-indent: 0; }
