/* Press Start to Consult. Palette and type carried over from the print layout. */
:root {
  --navy: #002E5D;
  --navy-deep: #001A38;
  --white: #FFFFFF;
  --tan: #F5E6C8;
  --tan-deep: #E8D4AC;

  --ink: var(--navy-deep);
  --paper: #FBF6EA;
  --rule: rgba(0, 46, 93, .22);

  --display: 'Press Start 2P', 'Courier New', monospace;
  --ui: 'Silkscreen', 'Courier New', monospace;
  --body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --measure: 68ch;
  --gap: 1rem;
  --shadow: 4px 4px 0 var(--navy-deep);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
}

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

a { color: var(--navy); text-underline-offset: .18em; }
a:hover { color: var(--navy-deep); }

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--navy); color: var(--white);
  padding: .85rem 1.25rem; font-family: var(--ui);
}
.skip:focus { left: 0; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--navy);
  border-bottom: 4px solid var(--navy-deep);
}
.topbar__inner {
  max-width: 78rem; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .6rem 1.25rem;
}
.brand { display: grid; align-content: center; line-height: 1.15; text-decoration: none; padding: .55rem 0; min-height: 44px; }
.brand__press { font-family: var(--display); font-size: .68rem; color: var(--white); }
.brand__to { font-family: var(--display); font-size: .68rem; color: var(--tan); }
/* One row that scrolls sideways rather than wrapping onto a second line. The
   scrollbar is hidden because the row is short and the overflow is obvious from
   the clipped link; keyboard focus still scrolls it into view. */
.topbar__links {
  display: flex; flex-wrap: nowrap; gap: 1.1rem;
  list-style: none; margin: 0; padding: 0;
  min-width: 0; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -ms-overflow-style: none;
}
.topbar__links::-webkit-scrollbar { display: none; }
.topbar__links li { flex: 0 0 auto; }
.topbar__links a {
  display: flex; align-items: center; white-space: nowrap;
  padding: .6rem .35rem; min-height: 44px;
  font-family: var(--ui); font-size: .95rem; color: var(--tan); text-decoration: none;
  border-bottom: 3px solid transparent;
}
.topbar__links a:hover { color: var(--white); border-bottom-color: var(--tan); }
.topbar__links a[aria-current="page"] { color: var(--white); border-bottom-color: var(--white); }

/* ---------------------------------------------------------------- home */
.home { max-width: 72rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
.home:focus:not(:focus-visible) { outline: none; }

.hero { border: 4px solid var(--navy); background: var(--navy); color: var(--white); padding: 2.5rem 1.5rem; box-shadow: var(--shadow); }
.hero__kicker { font-family: var(--ui); color: var(--tan); margin: 0 0 1rem; letter-spacing: .06em; }
.hero__title { font-family: var(--display); font-size: clamp(1.35rem, 5.2vw, 2.6rem); line-height: 1.5; margin: 0 0 1.25rem; color: var(--white); }
.hero__sub { max-width: 52ch; margin: 0 0 1.75rem; color: var(--tan); }
.hero__hud { display: grid; gap: .5rem; max-width: 24rem; }
.bar { display: grid; gap: .3rem; font-family: var(--ui); font-size: .78rem; color: var(--tan); }
.bar b { font-weight: 400; letter-spacing: .04em; }
.bar__track { display: block; position: relative; height: .75rem; background: var(--navy-deep); border: 2px solid var(--white); }
.bar i { position: absolute; inset: 0; background: var(--tan); }

/* search */
.search { margin: 2.5rem 0 0; }
.search__label { display: block; font-family: var(--ui); font-size: .95rem; margin-bottom: .4rem; }
.search__input {
  width: 100%; font-family: var(--body); font-size: 1rem; padding: .8rem .9rem; min-height: 48px;
  border: 3px solid var(--navy); background: var(--white); color: var(--ink);
}
.search__help { font-size: .85rem; margin: .4rem 0 0; color: rgba(0, 26, 56, .75); }
.results { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }
.results li { border: 2px solid var(--rule); background: var(--white); }
.results a { display: block; padding: .8rem .9rem; text-decoration: none; }
.results a:hover, .results a:focus-visible { background: var(--tan); }
.results .r__book { font-family: var(--ui); font-size: .75rem; color: var(--navy); display: block; }
.results .r__head { font-weight: 700; display: block; }
.results .r__snip { font-size: .9rem; color: rgba(0, 26, 56, .8); display: block; }
.results mark { background: var(--tan-deep); color: var(--ink); }

/* cards */
.cards { display: grid; gap: 1.25rem; margin: 2.5rem 0 0; grid-template-columns: 1fr; }
@media (min-width: 46rem) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card {
  display: grid; gap: .5rem; align-content: start;
  border: 3px solid var(--navy); background: var(--white); padding: 1.25rem;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: transform 180ms ease-out, background 180ms ease-out;
}
.card:hover, .card:focus-visible { background: var(--tan); transform: translate(-2px, -2px); }
.card__tag { font-family: var(--ui); font-size: .75rem; color: var(--navy); }
.card__title { font-family: var(--display); font-size: .95rem; line-height: 1.5; color: var(--navy); }
.card__blurb { font-size: .95rem; }
.card__go { font-family: var(--ui); color: var(--navy); }

.how { margin: 3rem 0 0; max-width: var(--measure); }
.how h2 { font-family: var(--ui); font-size: 1.35rem; }

/* ---------------------------------------------------------------- book shell */
.shell { max-width: 78rem; margin: 0 auto; padding: 0 1.25rem; }
@media (min-width: 64rem) {
  .shell { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 3rem; align-items: start; }
}

.toc-toggle {
  display: block; width: 100%; margin: 1rem 0 0; min-height: 48px;
  font-family: var(--ui); font-size: 1rem;
  background: var(--navy); color: var(--white); border: 3px solid var(--navy-deep);
  padding: .7rem 1rem; cursor: pointer; text-align: left;
}
.toc-toggle::after { content: " \25BC"; }
.toc-toggle[aria-expanded="true"]::after { content: " \25B2"; }
@media (min-width: 64rem) { .toc-toggle { display: none; } }

.toc {
  border: 3px solid var(--navy); background: var(--white); padding: 1rem;
  margin: .75rem 0 0;
}
.toc[hidden] { display: none; }
@media (min-width: 64rem) {
  .toc { position: sticky; top: 5.5rem; max-height: calc(100dvh - 7rem); overflow-y: auto; margin: 2rem 0 0; }
}
.toc__head { font-family: var(--display); font-size: .7rem; line-height: 1.6; color: var(--navy); margin: 0 0 .75rem; }
.toc__list { list-style: none; margin: 0; padding: 0; font-family: var(--ui); font-size: .92rem; counter-reset: none; }
.toc__list a { display: flex; align-items: center; padding: .5rem .4rem; min-height: 44px; text-decoration: none; border-left: 3px solid transparent; }
.toc__list a:hover { background: var(--tan); }
.toc__list a[aria-current="true"] { border-left-color: var(--navy); background: var(--tan); font-weight: 700; }
.toc__l3 a { padding-left: 1.1rem; font-size: .85rem; color: rgba(0, 26, 56, .82); }

/* ---------------------------------------------------------------- book body */
.book { max-width: var(--measure); padding: 2rem 0 4rem; }
.book:focus:not(:focus-visible) { outline: none; }
.book__tag { font-family: var(--ui); color: var(--navy); margin: 0 0 .5rem; }
.book__title { font-family: var(--display); font-size: clamp(1.15rem, 4.4vw, 1.9rem); line-height: 1.55; color: var(--navy); margin: 0 0 .75rem; }
.subtitle { font-family: var(--ui); color: var(--navy); font-size: 1.05rem; margin: 0 0 2rem; }

.book h2, .book h3 { position: relative; scroll-margin-top: 6rem; }
.book h2 {
  font-family: var(--ui); font-size: clamp(1.3rem, 3.6vw, 1.7rem); line-height: 1.35;
  color: var(--white); background: var(--navy);
  margin: 3.5rem 0 1.25rem; padding: .7rem .9rem;
  border: 3px solid var(--navy-deep);
}
.book h3 { font-family: var(--ui); font-size: 1.18rem; margin: 2.5rem 0 .6rem; color: var(--navy); border-bottom: 2px solid var(--rule); padding-bottom: .35rem; }
.book h2 .anchor, .book h3 .anchor {
  position: absolute; left: -1.4rem; width: 1.4rem; text-align: center;
  opacity: 0; text-decoration: none; font-family: var(--ui);
}
.book h2 .anchor { color: var(--tan); left: auto; right: .6rem; }
.book h2:hover .anchor, .book h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
@media (max-width: 63.99rem) { .book h2 .anchor, .book h3 .anchor { display: none; } }

.book p { margin: 0 0 1.1rem; }
.book ul, .book ol { margin: 0 0 1.25rem; padding-left: 1.4rem; }
.book li { margin: 0 0 .5rem; }

/* panels: an h4 plus the table or list it titles */
.panel { border: 3px solid var(--navy); background: var(--white); margin: 1.75rem 0; box-shadow: var(--shadow); }
.panel__title {
  font-family: var(--ui); font-size: 1rem; margin: 0;
  background: var(--navy); color: var(--white); padding: .55rem .8rem;
  scroll-margin-top: 6rem;
}
.panel .table-wrap { border: 0; }
.panel__list { margin: .9rem 1rem .9rem 2.2rem; }

/* tables */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; border: 3px solid var(--navy); background: var(--white); }
.table-wrap:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { background: var(--navy); color: var(--white); font-family: var(--ui); font-weight: 400; position: sticky; top: 0; }
tbody th { font-weight: 700; }
tbody tr:nth-child(even) { background: rgba(245, 230, 200, .5); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
thead th.num { text-align: right; }

/* dialogue */
.dialogue { margin: 1.75rem 0; display: grid; gap: .75rem; }
.say { border: 3px solid var(--navy); padding: .75rem .9rem; }
.say--p2 { background: var(--navy); color: var(--white); }
.say--cosmo { background: var(--white); color: var(--ink); }
.say__who { font-family: var(--ui); font-size: .78rem; margin: 0 0 .3rem; letter-spacing: .05em; }
.say--p2 .say__who { color: var(--tan); }
.say--cosmo .say__who { color: var(--navy); }
.say__line { margin: 0; }
.say--p2 .say__line::after {
  content: "\25B8"; margin-left: .4rem; color: var(--tan);
  animation: blink 1.1s steps(1, end) infinite;
}
@keyframes blink { 0%, 60% { opacity: 1 } 61%, 100% { opacity: 0 } }
.stage { font-family: var(--ui); font-size: .85rem; text-align: center; color: rgba(0, 26, 56, .72); margin: .25rem 0; }

/* trophies */
.trophies { list-style: none; margin: 1.5rem 0; padding: 0; display: grid; gap: .5rem; }
.trophy { display: grid; grid-template-columns: 1.6rem 1fr; gap: .6rem; align-items: start; margin: 0; border: 2px solid var(--rule); background: var(--white); padding: .6rem .7rem; }
.trophy__box { width: 1.1rem; height: 1.1rem; border: 3px solid var(--navy); margin-top: .25rem; }

/* art */
.art { margin: 2rem 0; }
.art img { display: block; width: 100%; height: auto; border: 3px solid var(--navy); image-rendering: pixelated; background: var(--navy); }
.art--pending .art__slot {
  aspect-ratio: var(--ar);
  border: 3px dashed var(--navy); background: repeating-linear-gradient(45deg, var(--white), var(--white) 10px, var(--tan) 10px, var(--tan) 20px);
  display: grid; align-content: center; justify-items: center; gap: .35rem; padding: 1rem; text-align: center;
}
.art__id { font-family: var(--ui); font-size: .85rem; color: var(--navy); word-break: break-all; }
.art__ar { font-family: var(--ui); font-size: .75rem; color: var(--navy); background: var(--white); border: 2px solid var(--navy); padding: .1rem .4rem; }
.art__gist { font-size: .82rem; max-width: 42ch; color: rgba(0, 26, 56, .82); }

/* ---------------------------------------------------------------- footer */
.foot { border-top: 4px solid var(--navy); background: var(--navy); color: var(--tan); margin-top: 3rem; padding: 2rem 1.25rem; }
.foot p { max-width: 60ch; margin: 0 auto .6rem; font-size: .9rem; }
.foot a { color: var(--white); }

@media print {
  .topbar, .toc, .toc-toggle, .search, .skip { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .shell { display: block; }
  .book { max-width: none; }
  .say--p2 .say__line::after { animation: none; }
}

/* ---------------------------------------------------------------- downloads */
.downloads { margin: 3rem 0 0; max-width: var(--measure); }
.downloads h2 { font-family: var(--ui); font-size: 1.35rem; margin: 0 0 .5rem; }
.dl-list { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: .75rem; }
.dl { border: 3px solid var(--navy); background: var(--white); box-shadow: var(--shadow); }
.dl__link, .dl--soon {
  display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; align-items: baseline;
  padding: .9rem 1rem; min-height: 44px; text-decoration: none; color: var(--ink);
}
.dl__link { transition: background 180ms ease-out; }
.dl__link:hover, .dl__link:focus-visible { background: var(--tan); }
.dl__name { font-family: var(--ui); font-size: 1rem; color: var(--navy); }
.dl__note { grid-column: 1; font-size: .9rem; }
.dl__meta { grid-column: 2; grid-row: 1 / span 2; font-family: var(--ui); font-size: .8rem; color: var(--navy); white-space: nowrap; }
.dl--soon { border-style: dashed; opacity: .72; }
.dl--soon .dl__meta { color: rgba(0, 26, 56, .8); }
.dl:has(.dl--soon) { border-style: dashed; box-shadow: none; }

/* the set cover beside the hero */
@media (min-width: 52rem) {
  .hero { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 2.5rem; align-items: center; padding: 2.5rem; }
  .hero__sub, .hero__hud { max-width: none; }
}
.hero__cover { margin: 2rem 0 0; }
@media (min-width: 52rem) { .hero__cover { margin: 0; } }
.hero__cover img { display: block; width: 100%; height: auto; border: 3px solid var(--white); image-rendering: pixelated; }

/* ------------------------------------------------------- in-book search */
.toc__search { margin: 0 0 .85rem; }
.toc__search-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.toc__search-input {
  width: 100%; min-height: 44px; padding: .5rem .6rem;
  font-family: var(--body); font-size: .95rem;
  border: 2px solid var(--navy); background: var(--white); color: var(--ink);
}
.toc__search-input::placeholder { color: rgba(0, 26, 56, .6); }
.toc__search-status { font-family: var(--ui); font-size: .75rem; margin: .35rem 0 0; color: var(--navy); min-height: 1em; }
.toc__search-status:empty { margin: 0; }

.toc__results { list-style: none; margin: 0; padding: 0; }
.toc__results[hidden] { display: none; }
.toc__results a {
  display: block; padding: .5rem .4rem; min-height: 44px;
  text-decoration: none; border-left: 3px solid transparent;
  font-family: var(--ui); font-size: .88rem;
}
.toc__results a:hover, .toc__results a:focus-visible { background: var(--tan); border-left-color: var(--navy); }
.toc__results .r__snip {
  display: block; font-family: var(--body); font-size: .78rem;
  color: rgba(0, 26, 56, .8); margin-top: .15rem;
}
.toc__results mark { background: var(--tan-deep); color: var(--ink); }
.toc__results .r__none { display: block; padding: .6rem .4rem; font-size: .85rem; font-family: var(--body); }

/* ------------------------------------------------- books menu (narrow only) */
.books-toggle {
  display: none; align-items: center; gap: .5rem;
  margin-left: auto; min-height: 44px; padding: .4rem .7rem;
  font-family: var(--ui); font-size: .95rem;
  background: transparent; color: var(--tan);
  border: 2px solid var(--tan); cursor: pointer;
}
.books-toggle:hover { color: var(--white); border-color: var(--white); }
.books-toggle__bars { display: grid; gap: 3px; width: 18px; }
.books-toggle__bars i { display: block; height: 3px; background: currentColor; }
.books-toggle[aria-expanded="true"] { color: var(--white); border-color: var(--white); background: var(--navy-deep); }

@media (max-width: 47.99rem) {
  .books-toggle { display: flex; }
  .topbar__inner { flex-wrap: wrap; }
  /* The links become a panel under the bar rather than a row beside the logo. */
  .topbar__links {
    flex: 1 0 100%; flex-direction: column; gap: 0;
    overflow-x: visible; margin-top: .6rem;
    border-top: 2px solid rgba(245, 230, 200, .35);
  }
  .topbar__links[hidden] { display: none; }
  .topbar__links a { padding: .75rem .25rem; border-bottom: 0; border-left: 3px solid transparent; }
  .topbar__links a[aria-current="page"] { border-bottom: 0; border-left-color: var(--white); padding-left: .6rem; }
}

/* ------------------------------------------------- this book's PDF, in the rail */
.toc__pdf {
  display: grid; gap: .1rem; margin-top: .9rem; padding: .7rem .6rem; min-height: 44px;
  border: 2px solid var(--navy); background: var(--navy); color: var(--white);
  text-decoration: none;
}
.toc__pdf:hover, .toc__pdf:focus-visible { background: var(--navy-deep); color: var(--white); }
.toc__pdf-label { font-family: var(--ui); font-size: .88rem; }
.toc__pdf-meta { font-family: var(--ui); font-size: .72rem; color: var(--tan); }

/* Keep the rail's own furniture in view while only the list scrolls. */
@media (min-width: 64rem) {
  .toc { display: flex; flex-direction: column; }
  .toc__list, .toc__results { overflow-y: auto; min-height: 0; }
  .toc__pdf { flex: 0 0 auto; }
}
