/* A Bestiary of Invisible Monsters - jonathanroomer.com */

@font-face {
  font-family: "IM Fell English";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/im-fell-english-regular.woff2") format("woff2");
}

@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/eb-garamond-variable.woff2") format("woff2");
}

:root {
  color-scheme: light;
  /* the page is the green baize lining of a specimen drawer; the title page, plates and book are paper laid on it */
  --ground: #1f3a2f;
  --ground-ink: #ebe6d4;
  --ground-soft: rgba(235, 230, 212, 0.74);
  --ground-ghost: rgba(235, 230, 212, 0.18);
  --brass: #d6b86c;
  --paper: #e4e0d0;
  --plate: #ebe8db;
  --plate-hover: #efece2;
  --plate-deep: #d9d4c2;
  --ink: #2a2521;
  --ink-soft: #564e45;
  --ink-faint: rgba(42, 37, 33, 0.42);
  --ink-ghost: rgba(42, 37, 33, 0.14);
  --ultra: #2b45a0;
  --gold: #a2823a;
  --common: #6b6258;
  --rare: #2b45a0;
  --epic: #7b3c85;
  --legendary: #a8801f;
  --display: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --body: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --gutter: clamp(16px, 4vw, 56px);
}

* { box-sizing: border-box; }

html {
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html.book-open { overflow: hidden; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(1100px 700px at 50% -10%, rgba(255, 255, 255, 0.07), transparent 65%),
    radial-gradient(900px 900px at 110% 60%, rgba(0, 0, 0, 0.16), transparent 60%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.015) 0 1px, transparent 1px 3px),
    var(--ground);
  color: var(--ground-ink);
  font-family: var(--body);
  font-size: clamp(18px, 1.1vw + 13px, 19.5px);
  line-height: 1.6;
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
.front :focus-visible, dialog.book :focus-visible { outline-color: var(--ultra); }

h1, h2, h3 { font-weight: 400; }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 20;
  background: var(--plate); color: var(--ink); border: 1px solid var(--ink); padding: 8px 12px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- top bar ---------- */

.topbar {
  max-width: 980px;
  margin: 0 auto;
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  display: flex;
  justify-content: flex-end;
}

.stamp {
  margin: 0;
  font-family: var(--body);
  font-size: 14.5px;
  line-height: 1;
  color: var(--brass);
  border: 1.5px solid var(--brass);
  outline: 1px solid rgba(214, 184, 108, 0.4);
  outline-offset: 2px;
  padding: 7px 11px 6px;
  transform: rotate(-2deg);
  background: transparent;
  letter-spacing: 0.01em;
}

/* ---------- frontispiece ---------- */

.front {
  max-width: 980px;
  margin: clamp(18px, 3vw, 30px) auto 0;
  padding: clamp(34px, 5vw, 64px) clamp(18px, 5vw, 72px) clamp(30px, 4vw, 48px);
  border: 2px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: -9px;
  position: relative;
  text-align: center;
  background: var(--plate);
  color: var(--ink);
  box-shadow: 0 30px 60px -34px rgba(0, 0, 0, 0.75), 0 2px 0 rgba(0, 0, 0, 0.12);
}

.front::before,
.front::after {
  content: "❦";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -15px;
  font-size: 22px;
  line-height: 1;
  color: var(--gold);
  background: var(--ground);
  padding: 0 10px;
}

.front::after { content: "✥"; top: auto; bottom: -13px; font-size: 18px; }

.front h1 {
  font-family: var(--display);
  margin: 0 0 16px;
  font-size: clamp(42px, 9vw, 104px);
  line-height: 1;
  letter-spacing: -0.01em;
}

.front h1 span { display: block; }
.front h1 span:first-child { font-size: 0.58em; line-height: 1.2; }

.front__sub {
  font-family: var(--display);
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.35;
  margin: 0 auto;
  max-width: 34ch;
  text-wrap: balance;
}

.front__rule {
  width: min(360px, 60%);
  height: 7px;
  margin: clamp(18px, 3vw, 24px) auto;
  border-top: 1px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.front__vignette { display: block; width: min(380px, 84%); height: auto; margin: 0 auto 8px; }

.front__by { margin: 0; font-size: 19px; }
.front__by strong {
  display: block;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(26px, 3vw, 30px);
  line-height: 1.2;
}

.front__role { margin: 4px auto 0; font-size: 18px; color: var(--ink-soft); white-space: nowrap; }
.role--short { display: none; }
.front__imprint { font-family: var(--display); font-size: 16px; margin: 18px 0 0; letter-spacing: 0.08em; color: var(--ink-soft); }

/* ---------- preface ---------- */

.preface {
  max-width: 980px;
  margin: clamp(56px, 8vw, 104px) auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: clamp(14px, 4vw, 56px);
}

.preface h2,
.cabinet-title,
.closing h2 {
  font-family: var(--display);
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

.preface__text p { margin: 0 0 16px; max-width: 60ch; }

.preface__text p:first-child::first-letter {
  font-family: var(--display);
  float: left;
  font-size: 4.1em;
  line-height: 0.8;
  padding: 0.1em 0.12em 0 0;
  color: var(--brass);
}

.sig { font-family: var(--display); font-size: 22px; }

/* ---------- the plates ---------- */

.cabinet-wrap {
  max-width: 980px;
  margin: clamp(60px, 9vw, 112px) auto 0;
  scroll-margin-top: 16px;
}

.cabinet-title { margin-bottom: clamp(16px, 2.4vw, 26px); }

.cabinet {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 26px);
}

.plate {
  --r: var(--common);
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  background: var(--plate);
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow:
    inset 0 0 0 6px var(--plate),
    inset 0 0 0 7px color-mix(in srgb, var(--r) 60%, transparent),
    0 16px 32px -22px rgba(0, 0, 0, 0.8);
  padding: clamp(14px, 2vw, 20px) clamp(12px, 2vw, 18px) clamp(18px, 2.2vw, 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: background-color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.plate--rare { --r: var(--rare); }
.plate--epic { --r: var(--epic); }
.plate--legendary {
  --r: var(--legendary);
  box-shadow:
    inset 0 0 0 6px var(--plate),
    inset 0 0 0 8px var(--legendary),
    0 16px 32px -22px rgba(0, 0, 0, 0.8);
}

.plate--legendary::after {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(214, 178, 76, 0.14) 50%, transparent 65%) no-repeat;
  background-size: 250% 100%;
  background-position: 120% 0;
  transition: background-position 1.1s ease;
}

@media (hover: hover) {
  .plate:hover { background-color: var(--plate-hover); }
  .plate--legendary:hover::after { background-position: -20% 0; }
}

.plate__num {
  position: absolute;
  top: clamp(12px, 1.6vw, 16px);
  left: clamp(14px, 1.8vw, 20px);
  font-family: var(--display);
  font-size: 16px;
  color: var(--ink-soft);
}

.plate__rarity {
  position: absolute;
  top: clamp(14px, 1.8vw, 19px);
  right: clamp(14px, 1.8vw, 20px);
  display: flex;
}

.plate .illus { display: block; width: 100%; max-width: 300px; height: auto; aspect-ratio: 1; margin: 6px auto 4px; }

.plate__name {
  font-family: var(--display);
  font-size: clamp(19px, 1.9vw, 24px);
  line-height: 1.15;
  text-wrap: balance;
}

.gems { width: 44px; height: 10px; display: block; overflow: visible; }
.gems .on { fill: var(--r); }
.gems .off { fill: none; stroke: var(--r); stroke-width: 1; opacity: 0.45; }

/* the field-guide entries live in the page for search engines and no-script readers,
   and open in the book dialog for everyone else */
.entries { display: none; max-width: 980px; margin: 60px auto 0; }
.entries .entry-src { border-top: 1px solid var(--ground-ghost); padding: 24px 0; }
.entries .entry__facts, .entries .entry__facts div { border-color: var(--ground-ghost); }
.entries .entry__facts dt { color: var(--ground-soft); }

/* ---------- closing ---------- */

.closing {
  max-width: 980px;
  margin: clamp(72px, 10vw, 128px) auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(28px, 5vw, 64px);
}

.closing__col { border-top: 2px solid var(--ground-ink); padding-top: 18px; }
.closing h2 { margin-bottom: 12px; }
.closing p { margin: 0 0 16px; max-width: 46ch; }

.links { margin-top: 20px; }

.link-mail {
  font-family: var(--display);
  font-size: clamp(21px, 2.2vw, 24px);
  color: var(--brass);
  text-decoration: none;
  border-bottom: 1px solid var(--brass);
  overflow-wrap: anywhere;
}

.link-mail:hover { border-bottom-width: 2px; }

.follow { list-style: none; margin: 22px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }

.follow a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 9px 16px 8px 13px;
  border: 1px solid var(--ground-ink);
  box-shadow: inset 0 0 0 3px var(--ground), inset 0 0 0 4px var(--ground-ghost);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.04);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* the follow buttons: a creature lives behind each logo, in the manner of its network */
.follow__link { position: relative; }
.follow__label { white-space: nowrap; }
/* before a creature has appeared its label is unwritten; bestiary.js only sets this when it will animate */
.follow__link.awaiting .follow__label { clip-path: inset(0 100% 0 0); }
.critter { position: relative; display: inline-flex; flex: none; width: 22px; height: 22px; }
.critter__logo { position: relative; width: 22px; height: 22px; display: block; overflow: visible; transform-origin: 50% 100%; }
.critter__logo path {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 0.7;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 0;
}
.critter__peek {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 18px;
  height: 10px;
  margin-left: -9px;
  overflow: hidden;
  pointer-events: none;
}
.critter__peek--cross { width: 20px; height: 12px; margin-left: -10px; }
.critter__peek svg { display: block; width: 100%; height: 100%; transform: translateY(105%); }
.critter__happy { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.critter__brows { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.critter__eyes circle { fill: #fff; stroke: currentColor; stroke-width: 1.2; }
.critter__pupils circle { fill: var(--ink); }
.critter__fx { position: absolute; left: 50%; top: 50%; width: 36px; height: 22px; margin: -11px 0 0 -18px; pointer-events: none; }
.critter__fx svg { display: block; width: 100%; height: 100%; overflow: visible; opacity: 0; }
.critter__fx path { fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }


@media (prefers-reduced-motion: no-preference) {
  /* shared: the creature surfaces and the label writes itself in */
  .follow__link.play .critter__peek svg { animation: peek 3s cubic-bezier(0.3, 0.7, 0.3, 1) 0.4s both; }

  /* LinkedIn: drawn neatly, a humble nod, contented eyes, applause */
  .follow__link--in.play .critter__logo path { animation: ink-draw 1s ease-out both; }
  .follow__link--in.play .follow__label { animation: write-on 1.2s cubic-bezier(0.45, 0, 0.3, 1) 0.8s both; }
  .follow__link--in.play .critter__logo { animation: humble-nod 1.1s ease-in-out 2s both; }
  .follow__link--in.play .critter__fx svg { animation: applause 1.2s ease-out 2.1s both; }

  /* X: scribbled in, a furious shake, a glare, sparks */
  .follow__link--x.play .critter__logo path { animation: ink-draw 0.45s linear both; }
  .follow__link--x.play .follow__label { animation: write-on 0.55s steps(9, end) 0.45s both; }
  .follow__link--x.play .critter__logo { animation: rage 0.7s linear 0.5s both; }
  .follow__link--x.play .critter__fx svg { animation: sparks 1.4s steps(1, end) 0.6s both; }
  .follow__link--x.play .critter__pupils { animation: glare 3s ease-in-out 0.4s both; }

  @keyframes ink-draw {
    0% { stroke-dashoffset: 1; fill-opacity: 0; }
    62% { stroke-dashoffset: 0; fill-opacity: 0; }
    100% { stroke-dashoffset: 0; fill-opacity: 1; }
  }
  @keyframes peek {
    0% { transform: translateY(105%); }
    12%, 86% { transform: translateY(0); }
    100% { transform: translateY(105%); }
  }
  @keyframes write-on {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0 0 0); }
  }
  @keyframes humble-nod {
    0%, 100% { transform: none; }
    20% { transform: translateY(1.5px) scaleY(0.9) rotate(-4deg); }
    40% { transform: none; }
    60% { transform: translateY(1.5px) scaleY(0.9) rotate(4deg); }
    80% { transform: none; }
  }
  @keyframes applause {
    0%, 100% { opacity: 0; transform: scale(0.8); }
    12%, 30% { opacity: 1; transform: scale(1); }
    42% { opacity: 0.2; transform: scale(0.9); }
    54%, 72% { opacity: 1; transform: scale(1.08); }
  }
  @keyframes rage {
    0%, 100% { transform: none; }
    10% { transform: translateX(-1.6px) rotate(-3deg); }
    20% { transform: translateX(1.6px) rotate(3deg); }
    30% { transform: translateX(-1.4px) rotate(-2deg); }
    40% { transform: translateX(1.4px) rotate(2deg); }
    50% { transform: translateX(-1px); }
    60% { transform: translateX(1px); }
    70% { transform: none; }
  }
  @keyframes sparks {
    0% { opacity: 1; transform: scale(1); }
    20% { opacity: 0; }
    35% { opacity: 1; transform: scale(1.12) rotate(4deg); }
    55% { opacity: 0; }
    70% { opacity: 1; transform: scale(1) rotate(-3deg); }
    100% { opacity: 0; }
  }
  @keyframes glare {
    0%, 30% { transform: translateX(0); }
    40%, 70% { transform: translateX(-0.8px) translateY(0.4px); }
    100% { transform: translateX(0); }
  }
}

@media (hover: hover) {
  .follow a:hover { background: var(--ground-ink); color: var(--ground); box-shadow: none; }
}


.site-footer {
  max-width: 980px;
  margin: clamp(48px, 7vw, 80px) auto 0;
  padding: 18px 0 max(36px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--ground-ink);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 15.5px;
  color: var(--ground-soft);
}

.site-footer p { margin: 0; }

/* ---------- the open book ---------- */

dialog.book {
  width: min(1180px, calc(100vw - 32px));
  max-width: none;
  height: min(780px, calc(100dvh - 32px));
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: var(--plate);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(20, 16, 10, 0.35), 0 0 0 1px var(--ink);
  overflow: hidden;
  overscroll-behavior: contain;
}

dialog.book::backdrop { background: rgba(8, 18, 13, 0.62); }

.book__inner { position: relative; height: 100%; }

.spread { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); height: 100%; }

.page { padding: clamp(24px, 3.5vw, 48px); position: relative; min-width: 0; }

.page--left {
  background: linear-gradient(90deg, transparent 88%, rgba(60, 45, 20, 0.1)), var(--plate);
  border-right: 1px solid var(--ink-ghost);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.page--right {
  background: linear-gradient(90deg, rgba(60, 45, 20, 0.08), transparent 12%), var(--plate);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: clamp(56px, 5vw, 64px);
}

.page--left .illus { width: 100%; max-width: 500px; height: auto; aspect-ratio: 1; }

.page__caption {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-family: var(--display);
  font-size: 18px;
  color: var(--ink-soft);
}

.nowrap { white-space: nowrap; }

.book__top { position: absolute; top: 14px; right: 14px; z-index: 3; }
.book__label { display: none; margin: 0; }

.book__close {
  appearance: none;
  -webkit-appearance: none;
  background: var(--plate);
  border: 1px solid var(--ink-faint);
  border-radius: 0;
  cursor: pointer;
  font: 400 17px/1 var(--display);
  color: var(--ink);
  padding: 11px 15px 10px;
  min-height: 44px;
}

.book__close:hover { border-color: var(--ink); }

.entry__name,
.entry-src .entry__name {
  font-family: var(--display);
  font-size: clamp(32px, 3.6vw, 50px);
  line-height: 1.02;
  margin: 0 0 20px;
  text-wrap: balance;
}

.entry__facts { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--ink-ghost); }

.entry__facts div {
  display: grid;
  grid-template-columns: 8.2em minmax(0, 1fr);
  gap: 16px;
  padding: 9px 0 8px;
  border-bottom: 1px solid var(--ink-ghost);
}

.entry__facts dt { font-family: var(--display); color: var(--ink-soft); font-size: 17.5px; padding-top: 1px; }
.entry__facts dd { margin: 0; font-size: 18.5px; line-height: 1.5; }

.rarity { --r: var(--common); display: inline-flex; align-items: center; gap: 10px; color: var(--r); font-weight: 500; }
.rarity--rare { --r: var(--rare); }
.rarity--epic { --r: var(--epic); }
.rarity--legendary { --r: var(--legendary); }

.entry__note-title { font-family: var(--display); font-size: 22px; margin: 26px 0 6px; }
.entry__note { margin: 0; font-size: 19px; line-height: 1.62; max-width: 58ch; }
.entry__action { margin: 18px 0 0; }
.entry__action a { font-family: var(--display); font-size: 21px; color: var(--ultra); text-decoration: none; border-bottom: 1px solid var(--ultra); }

.book__nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--ink-ghost);
}

.turn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 1px solid var(--ink-faint);
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  font: 400 16px/1.25 var(--body);
  padding: 10px 14px;
  min-height: 48px;
  text-align: left;
}

.turn span { display: block; font-family: var(--display); font-size: 18px; }
.turn--next { text-align: right; }
.turn:hover { border-color: var(--ink); background: rgba(255, 255, 255, 0.4); }

/* ---------- illustration ---------- */

.illus .ink { fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.illus .ink .fine { stroke-width: 0.9; }
.illus .ink .solid { fill: var(--ink); }
.illus .ink .pap { fill: var(--plate); }
.illus .wash { mix-blend-mode: multiply; opacity: 0.62; }
.illus text { stroke: none; }
.illus .lead { stroke: var(--ultra); stroke-width: 0.8; fill: none; }
.illus .leadtext { fill: var(--ultra); font-family: var(--body); font-size: 11px; }

@media (prefers-reduced-motion: no-preference) {
  @media (hover: hover) {
    .plate:hover .tail, .plate:focus-visible .tail { animation: wag 0.35s ease-in-out infinite alternate; }
    .plate:hover .fish { animation: swim 3.2s ease-in-out infinite; }
    .plate:hover .bubble { animation: rise 2.4s ease-in infinite; }
    .plate:hover .head-peek { transform: translateX(0); transition-delay: 0.6s; }
    .plate:hover .seg { animation: crawl 1.4s ease-in-out infinite; }
    .plate:hover .fan { animation: fan 2.6s ease-in-out infinite alternate; }
    .plate:hover .bird-l { animation: bob 1.1s ease-in-out infinite alternate; }
    .plate:hover .bird-r { animation: bob 1.1s ease-in-out 0.55s infinite alternate; }
    .plate:hover .env-in { animation: post 2.4s ease-in-out infinite; }
  }
  .page .tail { animation: wag 0.35s ease-in-out infinite alternate; }
  .page .fish { animation: swim 3.2s ease-in-out infinite; }
  .page .bubble { animation: rise 2.4s ease-in infinite; }
  .page .head-peek { transform: translateX(0); transition-delay: 0.6s; }
  .page .seg { animation: crawl 1.4s ease-in-out infinite; }
  .page .fan { animation: fan 2.6s ease-in-out infinite alternate; }
  .page .bird-l { animation: bob 1.1s ease-in-out infinite alternate; }
  .page .bird-r { animation: bob 1.1s ease-in-out 0.55s infinite alternate; }
  .page .env-in { animation: post 2.4s ease-in-out infinite; }

  .tail { transform-origin: 100px 126px; }
  .bubble:nth-child(2) { animation-delay: 0.8s !important; }
  .bubble:nth-child(3) { animation-delay: 1.6s !important; }
  .head-peek { transform: translateX(14px); transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .eyes { transform-origin: 150px 136px; animation: blink 5s infinite; }
  .fan { transform-origin: 150px 214px; }
  .bird-l, .bird-r { transform-box: fill-box; transform-origin: 50% 100%; }
  .peek-eyes { animation: glance 7s ease-in-out infinite; }

  @keyframes wag { from { transform: rotate(-14deg); } to { transform: rotate(12deg); } }
  @keyframes swim { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-12px); } }
  @keyframes rise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
  @keyframes crawl { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
  @keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
  @keyframes fan { from { transform: scale(0.97); } to { transform: scale(1.03); } }
  @keyframes bob { from { transform: rotate(0deg); } to { transform: rotate(-6deg); } }
  @keyframes post { 0%, 100% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(6px, 4px) rotate(4deg); } }
  @keyframes glance { 0%, 40%, 100% { transform: translateX(0); } 50%, 70% { transform: translateX(5px); } }
}

/* ---------- tablet ---------- */

@media (max-width: 900px) {
  .preface { grid-template-columns: 1fr; }
  .cabinet { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  dialog.book {
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    margin: 0;
    box-shadow: none;
  }

  .book__inner { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .spread { grid-template-columns: 1fr; height: auto; min-height: 100%; }

  .page--left {
    border-right: 0;
    border-bottom: 1px solid var(--ink-ghost);
    background: var(--plate);
    padding-top: 20px;
    padding-bottom: 18px;
  }

  .page--left .illus { max-width: min(340px, 78vw); }
  .page--right { overflow: visible; padding-top: 24px; padding-bottom: max(32px, env(safe-area-inset-bottom, 0px)); background: var(--plate); }

  .book__top {
    position: sticky;
    top: 0;
    right: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(18px, env(safe-area-inset-left, 0px));
    background: var(--plate);
    border-bottom: 1px solid var(--ink-ghost);
  }

  .book__label { display: block; font-family: var(--display); font-size: 18px; color: var(--ink-soft); }
  .page__caption { display: none; }
}

/* ---------- phone ---------- */

@media (max-width: 640px) {
  body { font-size: 18px; }
  .front { outline-offset: -7px; padding-inline: 12px; }
  .front h1 span:first-child { font-size: 0.56em; }
  /* the descriptor stays on one line: shorter wording, sized to the screen */
  .role--long { display: none; }
  .role--short { display: inline; }
  .front__role { font-size: min(18px, calc((100vw - 68px) / 22.3)); }
  .closing { grid-template-columns: 1fr; }
  .stamp { font-size: 13.5px; }

  .plate { padding: 12px 8px 16px; box-shadow: inset 0 0 0 4px var(--plate), inset 0 0 0 5px color-mix(in srgb, var(--r) 60%, transparent); }
  .plate--legendary { box-shadow: inset 0 0 0 4px var(--plate), inset 0 0 0 6px var(--legendary); }
  .plate--legendary::after { inset: 6px; }
  .plate__num { top: 10px; left: 11px; font-size: 14px; }
  .plate__rarity { top: 12px; right: 11px; }
  .gems { width: 34px; height: 8px; }
  .plate .illus { margin-top: 12px; }
  .plate__name { font-size: clamp(16px, 4.6vw, 19px); }

  .entry__facts div { grid-template-columns: 1fr; gap: 0; }
  .entry__facts dt { font-size: 16px; }
  .book__nav { grid-template-columns: 1fr; }
  .turn--next { text-align: left; }
}

@media (min-width: 360px) and (max-width: 900px) {
  /* nine plates in two columns: let the last one close the collection at full width */
  .cabinet .plate:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .cabinet .plate:last-child:nth-child(odd) .illus { max-width: 280px; }
}

@media (max-width: 359px) {
  .cabinet { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
