/* Raptortron catalogue (catalogue.html, generated by build.ps1): a full-screen flipbook reader
   (js/catalogue.js) with a bar of its own instead of the site's header and footer.
   Self-contained: this page does not load styles.css, it only repeats the site's tokens (keep them
   in step with css/styles.css), and follows the same theme switch (html[data-theme="dark"],
   localStorage "rt-theme"). */

:root {
  --font: "Montserrat", Helvetica, Arial, sans-serif;
  --font-display: "Teko", "Montserrat", Helvetica, Arial, sans-serif;

  --c-text: #2b2f45;
  --c-text-2: #5d6075;
  --c-title: #1a214f;
  --s-1: #ffffff;
  --s-2: #f7f5f4;
  --c-border: #ece7e3;
  --c-border-2: #d2d2d2;
  --c-accent: #8e6a35;

  /* The table the book lies on. */
  --stage-top: #f7f5f4;
  --stage-bottom: #e3ddd7;

  --radius: 0.25rem;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --c-text: #dcdcdc;
  --c-text-2: #a8a8a8;
  --c-title: #f4efe7;
  --s-1: #0a0a0a;
  --s-2: #121212;
  --c-border: #262626;
  --c-border-2: #3a3a3a;
  --c-accent: #d0a466;
  --stage-top: #1a1a1a;
  --stage-bottom: #050505;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--s-1);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- Frame: bar, stage, toolbar ---- */

.cat {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(var(--stage-top), var(--stage-bottom));
}

.cat-bar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex: none;
  height: 3.5rem;
  padding: 0 0.5rem;
  border-bottom: 1px solid var(--c-border);
  background: var(--s-1);
}

.cat-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.75rem;
  padding: 0 0.5rem;
  border: 0;
  background: none;
  color: var(--c-text-2);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .2s;
}
.cat-back:hover { color: var(--c-title); }
.cat-back svg { transition: transform .2s var(--ease); }
.cat-back:hover svg { transform: translateX(-3px); }
.cat-back span { display: none; }

.cat-brand { display: inline-flex; align-items: center; gap: 0.6rem; min-height: 2.75rem; }
.cat-brand img { width: 2rem; height: 2rem; object-fit: contain; }
.cat-brand__word { font-size: 0.9rem; font-weight: 500; letter-spacing: 0.22em; color: var(--c-title); white-space: nowrap; }
.cat-brand__sep { display: none; width: 1px; height: 1.25rem; background: var(--c-border-2); }
.cat-brand__tag { display: none; font-size: 0.72rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--c-accent); }

.cat-bar__actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; }

.lang-switch { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; white-space: nowrap; }
.lang-switch a { display: inline-block; padding: 0.5rem 0.1rem; color: var(--c-text-2); font-weight: 500; letter-spacing: 0.06em; }
.lang-switch a:hover { color: var(--c-text); }
.lang-switch a[aria-current] { color: var(--c-title); font-weight: 600; text-decoration: underline; text-underline-offset: 0.35em; text-decoration-thickness: 1px; }
.lang-switch__sep { color: var(--c-border-2); }

.cat-theme .cat-theme__sun { display: none; }
:root[data-theme="dark"] .cat-theme .cat-theme__sun { display: block; }
:root[data-theme="dark"] .cat-theme .cat-theme__moon { display: none; }

@media (max-width: 26rem) {
  .cat-brand__word { display: none; }
}
@media (min-width: 40rem) {
  .cat-bar { height: 4rem; padding: 0 1rem; }
  .cat-back span { display: inline; }
  .cat-brand__sep, .cat-brand__tag { display: block; }
  .cat-bar__actions { gap: 0.75rem; }
}
@media (min-width: 64rem) { .cat-bar { padding: 0 1.5rem; } }
@media (max-height: 500px) { .cat-bar { height: 3rem; } }

.cat-body { position: relative; display: flex; flex: 1; min-height: 0; }
.cat-gesture { position: relative; display: flex; flex: 1; min-width: 0; }

.cat-stage {
  position: relative;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.cat-stage::-webkit-scrollbar { display: none; }

/* The book is centred with auto margins, not with justify/align: a flex item centred the other
   way loses the overflow on its leading side, so half of a zoomed page could not be scrolled to. */
.cat-pad { display: flex; min-width: 100%; min-height: 100%; padding: 16px; }
.cat-book { position: relative; flex: none; margin: auto; }

.cat-slot {
  position: absolute;
  top: 0;
  overflow: hidden;
  box-shadow: 0 10px 30px -12px rgb(0 0 0 / 0.35), 0 1px 3px rgb(0 0 0 / 0.12);
}
/* Until the page image has arrived, its small preview stands in for it. */
.cat-slot__paper { position: absolute; inset: 0; background: #fff center / 100% 100% no-repeat; }
.cat-slot img {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.cat-crease { position: absolute; top: 0; bottom: 0; width: 7%; pointer-events: none; }

.cat-sheet { position: absolute; top: 0; pointer-events: none; transform-style: preserve-3d; }
.cat-sheet__strip { position: absolute; top: 0; transform-style: preserve-3d; will-change: transform; }
.cat-sheet__face { position: absolute; top: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.cat-sheet__shade { position: absolute; inset: 0; opacity: 0; }
.cat-sheet__shadow { position: absolute; top: 0; opacity: 0; pointer-events: none; }

.cat-arrow {
  position: absolute;
  top: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--c-border-2);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--s-1) 90%, transparent);
  color: var(--c-title);
  cursor: pointer;
  transform: translateY(-50%);
  transition: background-color .2s, color .2s, opacity .2s, border-color .2s;
}
.cat-arrow:hover { border-color: var(--c-title); background: var(--c-title); color: var(--s-1); }
.cat-arrow:active { transform: translateY(-50%) scale(.95); }
.cat-arrow:disabled { opacity: 0; pointer-events: none; }
.cat-arrow--prev { left: 0.5rem; }
.cat-arrow--next { right: 0.5rem; }
@media (min-width: 40rem) {
  .cat-arrow--prev { left: 1rem; }
  .cat-arrow--next { right: 1rem; }
}

/* ---- Toolbar ---- */

.cat-tools {
  position: relative;
  z-index: 20;
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 3.5rem;
  padding: 0.5rem 0.5rem max(0.5rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--c-border);
  background: var(--s-1);
}

.cat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--c-title);
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s, opacity .2s;
}
.cat-btn:hover { border-color: var(--c-border-2); }
.cat-btn:active { transform: translateY(1px); }
.cat-btn:disabled { opacity: .3; pointer-events: none; }
.cat-btn[aria-pressed="true"] { border-color: var(--c-title); background: var(--c-title); color: var(--s-1); }
.cat-btn--wide { display: none; }

.cat-pager { display: flex; align-items: center; gap: 0.75rem; margin: 0 0.4rem; }
.cat-pager__label {
  min-width: 5.25rem;
  padding-top: 0.15em;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--c-title);
  white-space: nowrap;
}
.cat-pager__label span { color: var(--c-text-2); font-weight: 400; }
.cat-pager input { width: 4.5rem; margin: 0; accent-color: var(--c-accent); }

@media (min-width: 40rem) {
  .cat-tools { gap: 0.375rem; }
  .cat-btn--wide { display: flex; }
  .cat-pager { margin: 0 0.75rem; }
  .cat-pager input { width: 12rem; }
}
@media (min-width: 64rem) { .cat-pager input { width: 16rem; } }
@media (max-height: 500px) {
  .cat-tools { min-height: 0; padding-top: 0.25rem; padding-bottom: max(0.25rem, env(safe-area-inset-bottom)); }
  .cat-btn { width: 2.25rem; height: 2.25rem; }
}

/* ---- Side panel: page list, search ---- */

.cat-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 100%;
  border-left: 1px solid var(--c-border);
  background: var(--s-1);
  animation: cat-panel-in .25s var(--ease);
}
@media (min-width: 40rem) { .cat-panel { width: 24rem; } }
@keyframes cat-panel-in { from { opacity: 0; transform: translateX(1rem); } }

.cat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
}
.cat-panel__head h2 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-title);
}
.cat-panel__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1.25rem; }

.cat-thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 0.75rem; }
.cat-thumb { display: block; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.cat-thumb img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.18);
  transition: opacity .2s;
}
.cat-thumb:hover img { opacity: .85; }
.cat-thumb span { display: block; margin-top: 0.35rem; font-size: 0.75rem; font-variant-numeric: tabular-nums; color: var(--c-text-2); }
.cat-thumb[aria-current] img { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.cat-thumb[aria-current] span { font-weight: 600; color: var(--c-title); }

.cat-search {
  width: 100%;
  min-height: 3rem;
  margin-bottom: 1rem;
  padding: 0 1rem;
  border: 1px solid var(--c-border-2);
  border-radius: var(--radius);
  background: var(--s-1);
  color: var(--c-text);
  font: inherit;
  outline: none;
  transition: border-color .2s;
}
.cat-search::placeholder { color: var(--c-text-2); opacity: .7; }
.cat-search:focus { border-color: var(--c-title); }
@media (min-width: 40rem) { .cat-search { font-size: 0.875rem; } }

.cat-results { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--c-border); }
.cat-results li { border-bottom: 1px solid var(--c-border); font-size: 0.875rem; }
.cat-results li.is-empty { padding: 0.75rem 0; color: var(--c-text-2); }
.cat-results button { display: block; width: 100%; padding: 0.75rem 0; border: 0; background: none; text-align: left; cursor: pointer; }
.cat-results b { display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-title); }
.cat-results button:hover b { color: var(--c-accent); }
.cat-results span { display: block; margin-top: 0.25rem; color: var(--c-text-2); }

/* Shown only without JavaScript (the reader removes it when it starts). */
.cat-noscript { margin: auto; padding: 2rem; text-align: center; }
.js .cat-noscript { display: none; }
.cat-noscript a { color: var(--c-accent); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .cat-panel { animation: none; }
  * { transition-duration: 0s !important; }
}
