.word-codex {
  --main: #fbf8ff;
  --muted: #d5d0ed;
  --line: #3d3860;
  --bg: #101026;
  background: radial-gradient(ellipse at 65% 0%, #292448 0, transparent 36rem), var(--bg);
  font-family: Inter, system-ui, sans-serif;
}

.word-codex .wrap { width: min(65rem, calc(100% - 3rem)); }

.word-codex .codex-main { padding-block: clamp(1.75rem, 5vw, 3.5rem) 3rem; }

.codex-back {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 2.75rem;
  margin-bottom: .65rem;
  font-weight: 650;
  text-decoration: none;
}

.book-banner {
  display: grid;
  grid-template-columns: clamp(4.25rem, 15vw, 8.5rem) minmax(0, 1fr);
  align-items: center;
  gap: clamp(.8rem, 3vw, 2rem);
  padding: clamp(.9rem, 3.5vw, 2.1rem);
  margin-bottom: clamp(1.55rem, 3.5vw, 2.6rem);
  background: linear-gradient(125deg, var(--book-cover), #16142e 80%);
  border: 1px solid var(--book-accent);
  box-shadow: inset .3rem 0 0 #0b0a21a6, 0 .8rem 1.8rem #08081780;
  border-radius: .85rem;
}

.book-banner h1 { margin: 0 0 .24rem; color: #fff5db; font-size: clamp(1.55rem, 5vw, 3.6rem); line-height: 1.04; }
.book-banner p { margin: .32rem 0 .7rem; line-height: 1.4; }
.book-cover-art {
  display: grid;
  place-items: center;
  aspect-ratio: 1.16;
  padding: .35rem;
  border: 1px solid #d9b887;
  border-radius: 50%;
  background: #fff5e3;
  box-shadow: 0 0 0 .19rem #4b3a43, 0 .4rem 1rem #0a0a2170;
}
.book-cover-art img { width: 100%; height: 100%; object-fit: contain; }
.book-tags { display: flex; flex-wrap: wrap; gap: .3rem .55rem; list-style: none; padding: 0; margin: 0; }
.book-tags li {
  padding: .12rem .55rem;
  border: 1px solid #ffffff35;
  border-radius: 999px;
  background: #0e0c259c;
  color: var(--main);
  font-size: .78rem;
  font-weight: 650;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
  list-style: none;
  gap: clamp(.85rem, 2vw, 1.45rem) clamp(.55rem, 1.5vw, 1.15rem);
  padding: 0;
  margin: 0;
}

.word-grid li { min-width: 0; }
.word-grid figure {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  height: 100%;
  margin: 0;
}
.word-grid figcaption {
  display: grid;
  align-content: center;
  min-height: 2.1em;
  padding: .15rem .1rem;
  color: #fff5db;
  text-align: center;
  font-size: clamp(.71rem, 2vw, .98rem);
  font-weight: 800;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  line-height: 1.18;
}

.book-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .7rem; margin-top: 2rem; }
.book-links a {
  display: grid;
  align-content: center;
  flex: 1 1 8rem;
  min-height: 3rem;
  padding: .5rem .8rem;
  background: #1b1937;
  border: 1px solid #4e4875;
  border-radius: .7rem;
  line-height: 1.22;
  text-decoration: none;
}
.book-links span { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.book-links a:hover { border-color: var(--book-accent); }

@media (max-width: 54rem) { .word-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 40rem) {
  .word-codex .wrap { width: calc(100% - 1.4rem); }
  .word-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .book-banner p { font-size: .9rem; }
}

.word-codex .book-cover-art {
  aspect-ratio: 1.1;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.word-codex .word-grid .word-picture {
  padding: 13.8% 5.3%;
  border: 0;
  border-radius: 0;
  background: url("./native-codex/tarot-frame.png") center / 100% 100% no-repeat;
  box-shadow: none;
}

.word-codex .word-grid .word-picture::before,
.word-codex .word-grid .word-picture::after { content: none; }

@media (max-width: 26.25rem) {
  .book-banner {
    grid-template-areas:
      "cover title"
      "cover tags"
      "description description";
    row-gap: .45rem;
  }

  .book-banner > .book-cover-art { grid-area: cover; }
  .book-banner > .book-cover-art + div { display: contents; }
  .book-banner h1 { grid-area: title; align-self: end; margin: 0; }
  .book-banner .book-tags { grid-area: tags; align-self: start; }
  .book-banner p { grid-area: description; margin: .25rem 0 0; }

  .word-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.word-codex .book-cover-art {
  position: relative;
  overflow: hidden;
}

.codex-back > span { display: inline-block; }
.book-links a:focus-visible { border-color: var(--book-accent); }

@media (prefers-reduced-motion: no-preference) {
  body.word-codex:not(:has(.pon-loader)) .book-banner.pon-revealed .book-cover-art::after {
    position: absolute;
    inset: -8% auto -8% 0;
    inline-size: 39%;
    background: linear-gradient(90deg, transparent, #f8ffffa8 49%, transparent);
    pointer-events: none;
    opacity: 0;
    content: "";
    animation: pon-codex-cover-glint .72s ease-out .09s backwards;
  }

  body.word-codex:not(:has(.pon-loader)) .word-grid.pon-revealed > li:nth-child(-n + 6) .word-picture {
    animation: pon-codex-card-enter .42s cubic-bezier(.2, .65, .3, 1) var(--card-enter-delay, 60ms) backwards;
  }

  .word-codex .word-grid > li:nth-child(-n + 6):nth-child(3n + 2) { --card-enter-delay: 120ms; }
  .word-codex .word-grid > li:nth-child(-n + 6):nth-child(3n) { --card-enter-delay: 180ms; }

  .codex-back > span { transition: transform .2s ease; }
  .codex-back:is(:hover, :focus-visible) > span { transform: translateX(-.2rem); }
  .book-links a { transition: border-color .2s ease; }
}

@keyframes pon-codex-cover-glint {
  from { opacity: 0; transform: translateX(-140%) skewX(-14deg); }
  35%, 64% { opacity: .58; }
  to { opacity: 0; transform: translateX(330%) skewX(-14deg); }
}

@keyframes pon-codex-card-enter {
  from { opacity: .76; transform: translateY(.25rem) scale(.96); }
  to { opacity: 1; transform: none; }
}
