/* Book wikis hub — the library doorway.
   Shares the Starfield tokens with exodus-the-archimedes-engine/assets/css/wiki.css
   so the hub and the wiki read as one site. The two files are separate on purpose:
   a book wiki must stay self-contained, and the hub must not depend on any one
   book's assets. Keep the palettes in step by hand.

   There is no theme button here. The hub is a doorway you pass through in a
   couple of seconds, and the toggle lives where the reading happens. It still
   honours a choice made in a wiki: same origin, same localStorage key, and the
   inline stamp in index.html applies it before first paint. */

:root {
  color-scheme: dark;

  --bg: #0a0e14;
  --panel: #111823;
  --raised: #1a2431;
  --line: #293849;
  --text: #dce3ed;
  --muted: #8493a8;
  --dim: #7f8b9c;
  --accent: #4fc3d9;
  --accent-dim: #2b7f92;
  --accent-soft: rgba(79, 195, 217, 0.1);
  --warn: #e8b25c;
  --warn-bg: rgba(232, 178, 92, 0.07);
  --warn-line: rgba(232, 178, 92, 0.24);

  --content-max: 56rem;
  --radius: 0.55rem;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* Declared twice, as in wiki.css: once for an explicit choice, once for readers
   who have not made one — including readers with JavaScript off. Keep identical. */
[data-theme="light"] {
  color-scheme: light;

  --bg: #f7f8fa;
  --panel: #ffffff;
  --raised: #eef1f5;
  --line: #d6dce4;
  --text: #151a21;
  --muted: #5a6472;
  --dim: #666e7a;
  --accent: #10627a;
  --accent-dim: #8fc0cd;
  --accent-soft: rgba(16, 98, 122, 0.07);
  --warn: #8a5d10;
  --warn-bg: #fdf6e6;
  --warn-line: #e4c98c;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;

    --bg: #f7f8fa;
    --panel: #ffffff;
    --raised: #eef1f5;
    --line: #d6dce4;
    --text: #151a21;
    --muted: #5a6472;
    --dim: #666e7a;
    --accent: #10627a;
    --accent-dim: #8fc0cd;
    --accent-soft: rgba(16, 98, 122, 0.07);
    --warn: #8a5d10;
    --warn-bg: #fdf6e6;
    --warn-line: #e4c98c;
  }
}

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

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 1.125rem;
  color: var(--text);
  background: var(--bg);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
}

a:hover {
  border-bottom-color: var(--accent);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  padding: 0.9rem 1.25rem;
  padding-top: calc(0.9rem + env(safe-area-inset-top, 0px));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-title {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  border: 0;
}

.site-title:visited {
  color: var(--text);
}

.site-title:hover {
  color: var(--accent);
}

.layout {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 3rem 1.25rem 3rem;
  padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
}

.intro {
  margin-bottom: 2.6rem;
}

.intro h1 {
  margin: 0 0 0.8rem;
  font-size: 2.6rem;
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 600;
}

.intro .lead {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 42rem;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Two up only once a card can hold a cover and a readable column of text
   beside it. Below that the covers would squeeze the blurb to a ribbon. */
@media (min-width: 52rem) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.book-card {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  min-width: 0;
  padding: 1.35rem 1.45rem 1.45rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.book-card:hover,
.book-card:focus-within {
  border-color: var(--accent-dim);
  background: var(--raised);
}

.book-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
}

/* ---- cover ----
   The jacket keeps its own colours in both themes: a book is an object sitting on
   the page, not a surface that follows it. The ratio is the slot's, not the file's
   — jackets vary, and a row of covers that do not share a baseline looks broken. */
.book-card__cover {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 0;
  border-radius: 0.15rem 0.35rem 0.35rem 0.15rem;
  background: #05080e;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(143, 192, 205, 0.14);
}

/* The board edge, so it reads as a book rather than a tile. */
.book-card__cover::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.06));
  pointer-events: none;
}

.book-card__cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.book-card__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.25;
}

.book-card__title a {
  color: var(--text);
  border: 0;
}

.book-card__title a:visited {
  color: var(--text);
}

.book-card__title a:hover {
  color: var(--accent);
}

.book-card__meta {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--dim);
}

.book-card__blurb {
  margin: 0;
  flex: 1;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.book-card__spoiler {
  display: inline-block;
  align-self: flex-start;
  margin: 0;
  padding: 0.2rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 0.3rem;
}

.book-card__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  margin-top: 0.35rem;
  min-height: 2.75rem;
  padding: 0.55rem 1.05rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-dim);
  border-radius: 0.4rem;
}

.book-card__cta:visited {
  color: var(--accent);
}

.book-card__cta:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.site-footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  font-size: 0.875rem;
  color: var(--dim);
}

.site-footer p {
  margin: 0;
}

.site-footer__credit {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  max-width: 44rem;
}

/* Headings that label a region for assistive tech without appearing on screen. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

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

@media (max-width: 720px) {
  body {
    font-size: 1.0625rem;
  }

  .intro h1 {
    font-size: 2.1rem;
  }

  .book-card {
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: 1rem;
    padding: 1.1rem 1.15rem 1.25rem;
  }

}
