/* Books by Elizabeth Devereaux: an evening reading nook. */

:root {
  --wall: #183339;
  --wall-deep: #10252a;
  --wood: #9a6438;
  --wood-dark: #6b4024;
  --wood-light: #c08a55;
  --lamp: #ffd27a;
  --paper: #fbf7ec;
  --meadow: #eaf1dc;
  --leaf: #457a25;
  --leaf-dark: #2e5418;
  --ink: #23302a;
  --cream: #fff6e3;

  --font-display: "Grandstander", "Trebuchet MS", sans-serif;
  --font-body: "Literata", Georgia, serif;
  --font-hand: "Bad Script", "Segoe Script", cursive;

  --spine-h: clamp(200px, 36vh, 320px);
}

/* Per-book colors, taken from each cover. */
.b-freddy   { --spine: #1f4a46; --spine-ink: #f6d75b; --band: #2f6a5f; --deep: #1f4a46; }
.b-andy     { --spine: #93572f; --spine-ink: #fff4e2; --band: #b67a4b; --deep: #7a4524; }
.b-franny   { --spine: #5fb0ae; --spine-ink: #0f3537; --band: #91d1c6; --deep: #1f6765; }
.b-carson   { --spine: #4b7a34; --spine-ink: #f3e98a; --band: #6c9d48; --deep: #3b6428; }
.b-beatrice { --spine: #174a6b; --spine-ink: #ffffff; --band: #2b6b8f; --deep: #174a6b; }
.b-about    { --spine: #6e3b26; --spine-ink: #ecc977; --band: #86492f; --deep: #6e3b26; }

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

html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font: 400 1.125rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body.is-reading { overflow: hidden; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--lamp); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute; left: 16px; top: -60px; z-index: 50;
  background: var(--lamp); color: var(--ink); padding: 8px 14px; border-radius: 8px;
  font-family: var(--font-display); text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  position: absolute; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 4vw, 48px);
  color: var(--cream);
}
.wordmark {
  font-family: var(--font-hand); font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  text-decoration: none; color: var(--cream); white-space: nowrap;
}
.topnav { display: flex; gap: clamp(14px, 3vw, 32px); }
.topnav a {
  font-family: var(--font-display); font-weight: 500; font-size: 1rem;
  text-decoration: none; color: rgba(255, 246, 227, .82);
}
.topnav a:hover { color: var(--lamp); }

/* ---------- The nook ---------- */
.nook {
  position: relative; overflow: hidden;
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 110px 16px 56px;
  background:
    radial-gradient(ellipse 60% 55% at 22% 8%, rgba(255, 210, 122, .30), transparent 70%),
    radial-gradient(ellipse 90% 70% at 50% 110%, rgba(0, 0, 0, .35), transparent 70%),
    var(--wall);
  color: var(--cream);
}
/* A pendant lamp hangs over the shelf. */
.nook__lamp {
  position: absolute; left: 22%; top: 0; width: 2px; height: 70px;
  background: rgba(255, 246, 227, .25);
}
.nook__lamp::after {
  content: ""; position: absolute; left: 50%; top: 70px; translate: -50% 0;
  width: 54px; height: 26px; border-radius: 54px 54px 6px 6px;
  background: linear-gradient(#2a4a50, #1b363b);
  box-shadow: 0 18px 40px 10px rgba(255, 210, 122, .35);
  border-bottom: 4px solid var(--lamp);
}

.nook__intro { position: relative; text-align: center; max-width: 48rem; margin-bottom: clamp(28px, 5vh, 48px); }
.nook__intro h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); font-weight: 800; color: var(--cream); }
.nook__intro p { margin: .7em auto 0; max-width: 30rem; color: rgba(255, 246, 227, .85); font-size: clamp(1rem, 1.6vw, 1.15rem); }
.nook__hint {
  position: relative; margin: 18px 0 0; font-style: italic; font-size: .95rem;
  color: rgba(255, 246, 227, .6);
}

/* Fireflies: the only ambient motion on the page. */
.fireflies i {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: #fff3a6; box-shadow: 0 0 10px 4px rgba(246, 215, 91, .55);
  opacity: 0; animation: drift 9s ease-in-out infinite;
}
.fireflies i:nth-child(1) { left: 12%; top: 62%; animation-duration: 11s; }
.fireflies i:nth-child(2) { left: 80%; top: 30%; animation-delay: -3s; }
.fireflies i:nth-child(3) { left: 68%; top: 72%; animation-duration: 13s; animation-delay: -6s; }
.fireflies i:nth-child(4) { left: 30%; top: 26%; animation-duration: 10s; animation-delay: -2s; }
.fireflies i:nth-child(5) { left: 90%; top: 58%; animation-duration: 12s; animation-delay: -8s; }
.fireflies i:nth-child(6) { left: 6%; top: 36%; animation-duration: 14s; animation-delay: -5s; }
.fireflies i:nth-child(7) { left: 52%; top: 16%; animation-duration: 15s; animation-delay: -10s; }
@keyframes drift {
  0%   { transform: translate(0, 0); opacity: 0; }
  20%  { opacity: .9; }
  45%  { transform: translate(28px, -22px); opacity: .2; }
  65%  { transform: translate(-10px, -48px); opacity: .85; }
  100% { transform: translate(18px, -80px); opacity: 0; }
}

/* ---------- The shelf ---------- */
.shelf {
  position: relative; width: min(100%, 720px);
  padding: 22px clamp(14px, 3vw, 34px) 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .45), rgba(0, 0, 0, 0) 30%),
    var(--wall-deep);
  border: clamp(10px, 1.6vw, 16px) solid var(--wood);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .55), 0 30px 60px -20px rgba(0, 0, 0, .6);
}
.shelf__row {
  list-style: none; margin: 0; padding: 0;
  display: flex; align-items: flex-end; justify-content: center;
  gap: clamp(2px, .5vw, 5px);
  min-height: calc(var(--spine-h) * 1.1);
}
.shelf__plank {
  position: relative;
  margin: 0 calc(-1 * clamp(24px, 4.6vw, 50px));
  height: 26px; border-radius: 3px;
  background:
    repeating-linear-gradient(92deg, rgba(0, 0, 0, .08) 0 2px, transparent 2px 14px),
    linear-gradient(var(--wood-light), var(--wood) 45%, var(--wood-dark));
  box-shadow: 0 16px 24px -8px rgba(0, 0, 0, .6);
}

/* Spines on the shelf, and the spine face of the 3D book, share one look. */
.spine, .face--spine {
  container-type: size;
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .28), rgba(255, 255, 255, .10) 30%, rgba(255, 255, 255, 0) 55%, rgba(0, 0, 0, .3)),
    var(--spine);
  color: var(--spine-ink);
  border-radius: 3px 3px 2px 2px;
  padding: 0;
}
.spine {
  width: calc(var(--spine-h) * .17); height: var(--spine-h);
  border: 0; cursor: pointer;
  box-shadow: 2px 0 0 rgba(0, 0, 0, .25), 0 -2px 8px rgba(0, 0, 0, .2);
  transition: transform .25s cubic-bezier(.3, .7, .2, 1), box-shadow .25s;
}
.spine::before, .spine::after, .face--spine::before, .face--spine::after {
  content: ""; position: absolute; left: 0; right: 0; height: 5cqh;
  background: var(--band);
  border-block: 1px solid color-mix(in srgb, var(--spine-ink) 45%, transparent);
}
.spine::before, .face--spine::before { top: 6cqh; }
.spine::after, .face--spine::after { bottom: 21cqh; }
.spine__title {
  writing-mode: vertical-rl;
  font-family: var(--font-display); font-weight: 800;
  font-size: min(34cqw, 6.6cqh); line-height: 1.02; text-align: center;
  margin-top: 14cqh; max-height: 58cqh;
}
.spine__by {
  writing-mode: vertical-rl;
  font-family: var(--font-display); font-weight: 500;
  font-size: min(20cqw, 3.1cqh); letter-spacing: .02em; opacity: .85;
  margin-bottom: 2.5cqh;
}
.spine:hover, .spine:focus-visible {
  transform: translateY(-12px);
  box-shadow: 2px 0 0 rgba(0, 0, 0, .25), 0 10px 18px rgba(0, 0, 0, .45), 0 0 26px rgba(255, 210, 122, .25);
}
.spine.is-out { visibility: hidden; }

/* The journal is taller, wider and leather-bound. */
.spine--journal { width: calc(var(--spine-h) * .22); height: calc(var(--spine-h) * 1.06); margin-left: clamp(6px, 1.4vw, 14px); }
.spine--journal, .is-journal .face--spine {
  background:
    repeating-linear-gradient(180deg, transparent 0 17cqh, rgba(0, 0, 0, .35) 17cqh 18cqh, rgba(255, 255, 255, .08) 18cqh 19cqh),
    linear-gradient(90deg, rgba(0, 0, 0, .35), rgba(255, 255, 255, .08) 35%, rgba(0, 0, 0, .35)),
    var(--spine);
}
.spine--journal .spine__title, .is-journal .face--spine .spine__title { font-weight: 700; font-size: min(30cqw, 6cqh); }

.bookend {
  width: clamp(14px, 2.4vw, 22px); height: calc(var(--spine-h) * .55);
  background: linear-gradient(90deg, var(--wood-dark), var(--wood-light) 40%, var(--wood));
  border-radius: 3px 3px 0 0; margin-right: clamp(4px, 1vw, 10px);
}
.jar {
  position: relative; width: calc(var(--spine-h) * .24); height: calc(var(--spine-h) * .38);
  margin-left: clamp(8px, 2vw, 20px);
  border: 2px solid rgba(255, 246, 227, .35); border-top-width: 0;
  border-radius: 8px 8px 14px 14px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .02) 40%, rgba(255, 255, 255, .08));
}
.jar::before { /* lid */
  content: ""; position: absolute; left: -4px; right: -4px; top: -10px; height: 12px;
  background: linear-gradient(var(--wood-light), var(--wood-dark)); border-radius: 3px;
}
.jar i {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: #fff3a6; box-shadow: 0 0 8px 3px rgba(246, 215, 91, .6);
  animation: glow 3.2s ease-in-out infinite;
}
.jar i:nth-child(1) { left: 30%; top: 40%; }
.jar i:nth-child(2) { left: 62%; top: 62%; animation-delay: -1.1s; }
.jar i:nth-child(3) { left: 44%; top: 78%; animation-delay: -2.3s; }
@keyframes glow { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* ---------- Library (readable list without JavaScript) ---------- */
.library { background: var(--paper); padding: 48px 16px; }
.library .entry { max-width: 40rem; margin: 0 auto 40px; }
.js .library { display: none; }

.entry h2 { font-size: 1.9rem; font-weight: 800; color: var(--deep); }
.entry__hook { font-style: italic; font-size: 1.1em; margin: .5em 0 .4em; }
.entry p { margin: .6em 0; }
.entry__facts { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 1em 0 1.3em; font-size: .9rem; }
.entry__facts div { display: flex; gap: 6px; }
.entry__facts dt { font-family: var(--font-display); font-weight: 700; }
.entry__facts dd { margin: 0; }

/* ---------- Buttons ---------- */
.buy {
  display: inline-block;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem; line-height: 1.2;
  text-decoration: none; color: #fff;
  background: var(--leaf); padding: 11px 18px 10px; border-radius: 10px;
  box-shadow: 0 3px 0 var(--leaf-dark);
  transition: transform .12s, box-shadow .12s;
}
.buy:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--leaf-dark); }
.buy:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--leaf-dark); }
.buy--quiet { background: var(--deep, var(--wall)); box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.buy--letter { background: var(--lamp); color: var(--ink); box-shadow: 0 3px 0 #b88d36; }

/* ---------- Series ---------- */
.series {
  background: var(--meadow);
  padding: clamp(56px, 9vw, 96px) clamp(16px, 4vw, 48px);
  text-align: center;
}
.series h2 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; color: var(--wall); }
.series__lede { margin: .6em auto 2.2em; max-width: 34rem; }
.series__grid {
  list-style: none; margin: 0 auto; padding: 0; max-width: 1100px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 36px 24px;
}
.series__grid h3 { font-size: 1.1rem; font-weight: 700; margin: 14px 0 12px; color: var(--wall); }
.series__cover {
  position: relative;
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 3px 10px 10px 3px; overflow: hidden;
  box-shadow: 0 10px 22px -8px rgba(24, 51, 57, .55);
  transition: transform .25s cubic-bezier(.3, .7, .2, 1);
}
.series__cover::after, .cover__front::after { /* binding shadow along the spine edge */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 7px 0 10px -6px rgba(0, 0, 0, .55);
}
.series__cover:hover, .series__cover:focus-visible { transform: translateY(-6px) rotate(-1deg); }

/* ---------- Contact ---------- */
.contact {
  background: var(--wall); color: var(--cream);
  padding: clamp(56px, 9vw, 96px) 16px; text-align: center;
}
.contact h2 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; }
.contact p { max-width: 34rem; margin: .8em auto 1.6em; color: rgba(255, 246, 227, .85); }

.footer {
  background: var(--wall-deep); color: rgba(255, 246, 227, .65);
  padding: 32px 16px 40px; text-align: center; font-size: .9rem;
}
.footer p { margin: .3em 0; }
.wordmark--small { font-size: 1.4rem; color: var(--cream); }

/* ---------- The stage: a book pulled out and opened ---------- */
/* Registered so the open page can grow taller on phones. */
@property --H { syntax: "<length>"; inherits: true; initial-value: 0px; }
.stage {
  position: fixed; inset: 0; z-index: 40;
  perspective: 2600px;
  overflow: hidden;
}
.stage[hidden] { display: none; }
.stage__dim {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 50% 45%, rgba(255, 210, 122, .16), transparent 70%),
    rgba(9, 22, 26, .86);
  backdrop-filter: blur(3px);
}
.book3d {
  position: absolute; left: 0; top: 0;
  width: var(--W); height: var(--H);
  transform-style: preserve-3d;
  pointer-events: none;
}
.book3d__block {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}
.face, .page, .cover { position: absolute; }
.face--back {
  inset: 0; background: var(--spine); border-radius: 8px 3px 3px 8px;
  transform: rotateY(180deg) translateZ(calc(var(--D) / 2));
}
.face--spine {
  top: 0; height: var(--H); width: var(--D);
  left: calc((var(--W) - var(--D)) / 2);
  transform: rotateY(-90deg) translateZ(calc(var(--W) / 2));
  backface-visibility: hidden;
}
.face--pages {
  top: 4px; height: calc(var(--H) - 8px); width: var(--D);
  left: calc((var(--W) - var(--D)) / 2);
  transform: rotateY(90deg) translateZ(calc(var(--W) / 2 - 4px));
  background: repeating-linear-gradient(90deg, #f1e9d4 0 2px, #ddd2b8 2px 3px);
}
.page--right {
  inset: 0;
  transform: translateZ(calc(var(--D) / 2 - 1px));
  background:
    linear-gradient(90deg, rgba(60, 40, 20, .22), rgba(60, 40, 20, 0) 9%),
    var(--paper);
  border-radius: 2px 8px 8px 2px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6);
  pointer-events: auto;
}
.page__inner {
  height: 100%; overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(22px, 8%, 46px) clamp(20px, 9%, 48px);
  font-size: clamp(.92rem, calc(var(--H) / 36), 1.08rem);
  display: flex; flex-direction: column; justify-content: safe center;
}
.page__inner:focus, .page__inner h2:focus { outline: none; }
.page__inner h2 { font-size: 1.9em; font-weight: 800; color: var(--deep); }
.page__inner .entry__hook { margin-top: .5em; }
.page__inner .entry__facts { font-size: .85em; border-top: 2px dotted color-mix(in srgb, var(--spine) 40%, transparent); padding-top: .9em; }
.page__inner .buy { align-self: flex-start; }

.cover {
  inset: 0;
  transform-origin: left center;
  transform: translateZ(calc(var(--D) / 2));
  transform-style: preserve-3d;
}
.cover__front, .cover__inside {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 3px 8px 8px 3px; overflow: hidden;
}
.cover__front img { width: 100%; height: 100%; object-fit: cover; }
.cover__label { display: none; }
.cover__inside {
  transform: rotateY(180deg);
  border-radius: 8px 3px 3px 8px;
  background:
    radial-gradient(circle at 25% 25%, var(--band) 0 9%, transparent 10%) 0 0 / 46px 46px,
    radial-gradient(circle at 75% 75%, var(--band) 0 6%, transparent 7%) 0 0 / 46px 46px,
    var(--spine);
  display: grid; place-items: center;
  box-shadow: inset -12px 0 18px -8px rgba(0, 0, 0, .45);
}
.bookplate {
  width: 68%; padding: 9% 7%; text-align: center;
  background: var(--paper); color: var(--ink);
  border: 3px double var(--spine); outline: 6px solid var(--paper);
  border-radius: 4px;
  font-size: clamp(.8rem, calc(var(--H) / 40), 1rem);
}
.bookplate p { margin: 0; }
.bookplate__lead { font-family: var(--font-hand); font-size: 1.5em; }
.bookplate__line { height: 2.2em; border-bottom: 1.5px solid currentColor; opacity: .5; margin: .2em 0 .8em !important; }
.bookplate__from { font-family: var(--font-display); font-weight: 500; font-size: .8em; opacity: .75; }
.bookplate__photo { width: 62%; margin: 0 auto .7em; border-radius: 50%; border: 3px solid var(--spine); filter: sepia(.15); }
.is-journal .bookplate__lead { font-size: 1.7em; }
/* The journal's opening page is longer, so set it a touch smaller. */
.is-journal .page__inner { font-size: clamp(.85rem, calc(var(--H) / 42), 1rem); }

/* The journal cover: leather, an oval portrait and gold lettering. */
.is-journal .cover__front {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, .10), transparent 60%),
    linear-gradient(135deg, #7a432c, var(--spine) 50%, #4f2919);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7%;
}
.is-journal .cover__front img {
  width: 54%; height: auto; aspect-ratio: 4 / 5; border-radius: 50%;
  border: 4px solid var(--spine-ink); box-shadow: 0 0 0 6px rgba(0, 0, 0, .25);
  filter: sepia(.15);
}
.is-journal .cover__label {
  display: block; font-family: var(--font-display); font-weight: 700;
  font-size: calc(var(--H) / 13); color: var(--spine-ink);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .5);
}
.is-journal .cover__inside {
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .12) 0 2px, transparent 2px 10px),
    #86492f;
}

.stage__controls {
  position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
  translate: -50% 0;
  display: flex; gap: 8px; flex-wrap: nowrap;
}
.ctl {
  font-family: var(--font-display); font-weight: 700; font-size: .95rem;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
  background: rgba(255, 246, 227, .12); color: var(--cream);
  border: 1.5px solid rgba(255, 246, 227, .35);
  white-space: nowrap;
}
.ctl:hover { background: rgba(255, 246, 227, .2); }
.ctl--main { background: var(--lamp); color: var(--ink); border-color: var(--lamp); }
.ctl--main:hover { background: #ffe0a0; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .topbar { flex-direction: column; gap: 6px; padding-top: 14px; }
  .topnav a { font-size: .95rem; }
  .nook { padding-top: 120px; }
  .nook__lamp { left: 12%; }
  .ctl { padding: 10px 12px; font-size: .88rem; }
}
@media (max-width: 420px) {
  .jar { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fireflies, .jar i { animation: none; }
  .fireflies i { display: none; }
  .spine, .series__cover, .buy { transition: none; }
}
