.codex-page {
  --codex-line: #6a5140;
  --codex-trim: #c09b76;
  background: radial-gradient(ellipse at 50% 18rem, #291f1b, #161413 53rem);
}
.codex-page .sub-hero { min-height: 0; border-color: #84654e; }
.codex-page .sub-hero__art { object-position: center 37%; }
.codex-page .sub-hero--art::after {
  background: linear-gradient(90deg, #131316 5%, #141416c9 40%, #1715191f 87%), linear-gradient(0deg, #181413ab, transparent 65%);
}
.codex-page .sub-hero__copy { padding-block: clamp(1.35rem, 4vw, 3.25rem); }
.codex-page .sub-hero h1 { margin: 0 0 .5rem; font-size: clamp(2.65rem, 6.5vw, 6rem); }
.codex-page .sub-hero__lead { max-width: 37ch; color: #e1d6ca; }
.codex-lookup-link { display: inline-flex; align-items: center; min-height: 2.75rem; margin-top: .35rem; }
.codex { padding-block: clamp(.85rem, 2vw, 1.65rem) clamp(2.6rem, 6vw, 5.5rem); }
.codex :is(#wiki-guides, #wiki-item-lookup) { scroll-margin-block-start: .65rem; }
.codex :is(#wiki-guides, #wiki-item-lookup):focus-visible { outline: 2px solid var(--codex-trim); outline-offset: .3rem; }

.codex-chapters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(.45rem, 1.15vw, .95rem); }
.codex-chapter {
  --chapter-tone: #c49a70;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--codex-line);
  border-block-start-color: var(--chapter-tone);
  background: linear-gradient(145deg, color-mix(in srgb, var(--chapter-tone) 13%, #281c17), #201a18 88%);
  text-decoration: none;
}
.codex-chapter--skills { --chapter-tone: #8d9db1; }
.codex-chapter--crafting { --chapter-tone: #c78b65; }
.codex-chapter--raids { --chapter-tone: #b6a288; }
.codex-chapter__art {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(4.5rem, 10.8vw, 9rem);
  overflow: hidden;
  border-block-end: 1px solid var(--codex-line);
  background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--chapter-tone) 24%, #211b19), #171312 85%);
}
.codex-chapter__cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.codex-chapter--items .codex-chapter__cover { object-position: center 40%; }
.codex-chapter--raids .codex-chapter__cover { object-position: 75% 45%; }
.codex-chapter__art:has(.codex-chapter__cover)::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, #1b1513a6, transparent 76%); }
.codex-chapter__copy { display: grid; gap: .38rem; min-width: 0; padding: clamp(.55rem, 1.4vw, 1.05rem); }
.codex-chapter__copy strong { color: #f2e6d7; font: 400 clamp(1.25rem, 2.6vw, 2.15rem)/1.08 var(--serif); }
.codex-chapter__copy span { color: #d8c9bb; font-size: clamp(.84rem, 1.2vw, .96rem); line-height: 1.36; }
.codex-chapter:is(:hover, :focus-visible), .codex-guide:is(:hover, :focus-visible) { border-color: #d2a789; }
.codex-chapter:is(:hover, :focus-visible) strong, .codex-guide:is(:hover, :focus-visible) h3 { color: #ffdab6; }

.codex-sigils, .codex-recipe { position: relative; display: flex; align-items: center; justify-content: center; width: 84%; gap: clamp(.28rem, .85vw, .8rem); }
.codex-sigils::before, .codex-recipe::before { position: absolute; inset: 50% 0 auto; height: 1px; background: linear-gradient(90deg, transparent, var(--chapter-tone), transparent); content: ""; }
.codex-sigils img, .codex-recipe img {
  position: relative;
  width: min(29%, 3.8rem);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid color-mix(in srgb, var(--chapter-tone) 63%, #211b19);
  padding: .12rem;
  background: #191513;
  box-shadow: 0 .15rem .45rem #0f0b0a9c;
}
.codex-sigils img:nth-child(2) { width: min(34%, 4.55rem); border-color: var(--chapter-tone); }
.codex-recipe__materials { display: flex; gap: .22rem; width: 65%; }
.codex-recipe__materials img { width: min(calc((100% - .44rem) / 3), 2.75rem); flex: 0 0 auto; }
.codex-recipe__result { position: relative; width: min(30%, 4.2rem); }
.codex-recipe__result img { width: 100%; border-color: var(--chapter-tone); }

.codex-lookup {
  display: grid;
  align-items: center;
  gap: .65rem 1.25rem;
  margin-block: clamp(.95rem, 2.2vw, 1.75rem) clamp(1.5rem, 3.5vw, 2.7rem);
  padding: clamp(.7rem, 1.7vw, 1.35rem);
  border: 1px solid var(--codex-line);
  background: linear-gradient(135deg, #32241d, #211a17 82%);
}
.codex-lookup:target, .codex-raids:target h2::after { border-color: var(--codex-trim); }
.codex-lookup__title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .38rem .8rem; }
.codex-lookup__title h2 { font: 400 clamp(1.45rem, 2.8vw, 2rem)/1.12 var(--serif); }
.codex-lookup__title a, .codex-equipment-links a { display: inline-flex; align-items: center; min-height: 2.75rem; font-size: .88rem; }
.codex-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; }
.codex-search input { width: 100%; min-width: 0; padding: .55rem .62rem; border: 1px solid #96755c; border-radius: 0; background: #171411; color: var(--text); }
.codex-search input::placeholder { color: #cec0b3; opacity: 1; }
.codex-search button { min-height: 2.75rem; padding: .48rem .75rem; cursor: pointer; }
.codex-equipment-links { display: flex; flex-wrap: wrap; gap: .15rem 1.15rem; }

.codex-raids h2 { display: flex; align-items: center; gap: .8rem; margin-bottom: .7rem; font-size: clamp(1.9rem, 3.9vw, 3.2rem); }
.codex-raids h2::after { content: ""; flex: 1; border-block-start: 1px solid var(--codex-line); }
.codex-guide-grid { display: grid; gap: .55rem .82rem; }
.codex-guide {
  display: grid;
  grid-template-columns: clamp(4.45rem, 11vw, 7.1rem) minmax(0, 1fr);
  min-width: 0;
  border: 1px solid var(--codex-line);
  background: #241c18;
  text-decoration: none;
}
.codex-guide__art { position: relative; min-height: 4.7rem; background: #171516; }
.codex-guide__art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.codex-guide__copy { align-self: center; padding: .7rem clamp(.7rem, 1.35vw, 1.1rem); }
.codex-guide h3 { font: 400 clamp(1.25rem, 2.35vw, 1.83rem)/1.12 var(--serif); }
.codex-guide p { margin-top: .28rem; color: #d8c9bb; font-size: .91rem; line-height: 1.43; }
.codex-guide--lead { position: relative; isolation: isolate; grid-template-columns: minmax(0, 1fr); align-items: end; min-height: clamp(12rem, 26vw, 20.5rem); }
.codex-guide--lead .codex-guide__art { position: absolute; inset: 0; z-index: -1; }
.codex-guide--lead .codex-guide__art img { object-position: 76% 50%; }
.codex-guide--lead .codex-guide__art::after { position: absolute; inset: 0; background: linear-gradient(0deg, #100d0df7 2%, #100d0d28 82%); content: ""; }
.codex-guide--lead .codex-guide__copy { align-self: end; padding: clamp(.85rem, 2vw, 1.55rem); }
.codex-guide--lead h3 { font-size: clamp(1.8rem, 3.65vw, 3.15rem); }
.codex-guide--lead p { color: #f0e1d3; }

@media (min-width: 52rem) {
  .codex-chapters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .codex-guide-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-auto-rows: minmax(min-content, 1fr); }
  .codex-guide--lead { grid-row: span 3; }
}
@media (min-width: 71rem) {
  .codex-lookup { grid-template-columns: auto minmax(0, 1fr) auto; }
  .codex-lookup__title { display: grid; gap: 0; }
  .codex-lookup__title a { min-height: 1.85rem; }
  .codex-equipment-links { justify-content: end; }
}
@media (max-width: 42rem) {
  .codex-page .sub-hero__art { object-position: 72% 36%; }
  .codex-page .sub-hero--art::after { background: linear-gradient(90deg, #161419bf, #1b171a38), linear-gradient(0deg, #171413e8, #18171c35 88%); }
  .codex-page .sub-hero__lead { max-width: 29ch; }
  .codex-lookup__title a { align-self: center; }
  .codex-search button { padding-inline: .5rem; font-size: .85rem; }
}
