.archives-page {
  background:
    radial-gradient(circle at 50% 0, rgb(80 44 18 / 19%), transparent 32rem),
    linear-gradient(180deg, #080706, #020303 72%);
}

.archives-shell {
  position: relative;
  isolation: isolate;
  width: min(100%, var(--content-max));
  min-height: 100svh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(20px + env(safe-area-inset-top))
    calc(10px + env(safe-area-inset-right))
    calc(18px + env(safe-area-inset-bottom))
    calc(10px + env(safe-area-inset-left));
  overflow: hidden;
  border-inline: 1px solid rgb(216 187 128 / 15%);
  background:
    linear-gradient(180deg, rgb(0 0 0 / 12%), rgb(0 0 0 / 72%)),
    repeating-linear-gradient(90deg, rgb(52 31 16 / 12%) 0 1px, transparent 1px 31px),
    linear-gradient(90deg, #080604, #120b07 50%, #080604);
  box-shadow: 0 0 50px #000;
}

.archives-shell::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: -1;
  border: 1px solid rgb(216 187 128 / 25%);
  pointer-events: none;
}

.archives-header {
  position: relative;
  display: grid;
  justify-items: center;
  min-height: clamp(170px, 25svh, 240px);
  align-content: start;
  padding-top: 8px;
  text-align: center;
}

.asset-slot--archive-crest {
  width: clamp(44px, 10vw, 70px);
  aspect-ratio: 1;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 5px 11px rgb(0 0 0 / 58%));
}

.archives-brand {
  margin: 9px 0 0;
  color: var(--muted);
  font: clamp(11px, 2.8vw, 16px)/1 Georgia, serif;
  letter-spacing: .2em;
}

.archives-header h1 {
  margin: 4px 0 0;
  color: var(--paper);
  font: 500 clamp(38px, 12vw, 76px)/.95 Georgia, "Times New Roman", serif;
  letter-spacing: .08em;
  text-shadow: 0 3px 16px #000;
}

.archives-header h1::after {
  content: "";
  display: block;
  width: min(58vw, 260px);
  height: 1px;
  margin: 10px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.archives-message {
  margin: 12px 0 0;
  color: var(--gold);
  font-size: clamp(9px, 2.65vw, 14px);
  letter-spacing: .08em;
}

.continue-reading {
  width: min(100% - 12px, 680px);
  margin: 0 auto 12px;
}

.continue-reading__card {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 92px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 13px 16px 12px;
  overflow: hidden;
  border: 1px solid rgb(216 187 128 / 52%);
  background:
    linear-gradient(90deg, rgb(111 18 32 / 20%), transparent 34%),
    linear-gradient(145deg, #1c100b, #080706 78%);
  color: var(--paper);
  box-shadow: 0 9px 22px rgb(0 0 0 / 48%), inset 0 0 0 3px rgb(216 187 128 / 5%);
  text-align: left;
  cursor: pointer;
}

.continue-reading__card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgb(216 187 128 / 16%);
  pointer-events: none;
}

.continue-reading__card:hover,
.continue-reading__card:focus-visible {
  border-color: rgb(216 187 128 / 76%);
  filter: brightness(1.06);
  outline: 2px solid rgb(216 187 128 / 28%);
  outline-offset: 2px;
}

.continue-reading__label,
.continue-reading__book,
.continue-reading__title,
.continue-reading__position {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.continue-reading__label {
  grid-column: 1 / -1;
  color: var(--gold-bright);
  font: 10px/1.2 Georgia, serif;
  letter-spacing: .14em;
}

.continue-reading__book {
  grid-column: 1;
  color: var(--gold);
  font-size: clamp(9px, 2.5vw, 12px);
  letter-spacing: .05em;
}

.continue-reading__title {
  grid-column: 1;
  display: -webkit-box;
  overflow: hidden;
  font: 600 clamp(13px, 3.8vw, 18px)/1.35 "Yu Mincho", "Hiragino Mincho ProN", serif;
  line-break: strict;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.continue-reading__position {
  grid-column: 2;
  grid-row: 2 / 4;
  align-self: end;
  padding-left: 10px;
  border-left: 1px solid rgb(216 187 128 / 24%);
  color: #d8c497;
  font-size: clamp(9px, 2.4vw, 12px);
  line-height: 1.45;
  white-space: nowrap;
}

.archives-reader-destination {
  position: fixed;
  inset: 0;
  z-index: 900;
  overflow: hidden;
  background: #d8c7a1;
  opacity: .001;
  visibility: visible;
  transform: translate3d(0, 0, 0) scale(1.006);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: opacity .22s ease, transform .22s cubic-bezier(.22, .61, .36, 1);
  pointer-events: none;
}

.archives-reader-destination.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.archives-reader-destination.is-formal-reader {
  pointer-events: auto;
}

.archives-reader-destination__frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #d8c7a1;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

:root[data-page-turn="false"] .archives-reader-destination {
  transition: none;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.archives-top-link {
  display: grid;
  width: fit-content;
  min-width: 112px;
  min-height: 44px;
  place-items: center;
  margin: 15px auto 0;
  border: 1px solid rgb(216 187 128 / 32%);
  color: var(--gold);
  font-size: 12px;
  letter-spacing: .12em;
  text-decoration: none;
}

.archives-top-link:hover,
.archives-top-link:focus-visible {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.shelf {
  --shelf-accent: #671322;
  --shelf-glow: rgb(103 19 34 / 28%);
  --shelf-books-image: url("../assets/official/ui/archives-main-spines.webp");
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(52px, 1fr) auto auto;
  min-width: 0;
  min-height: clamp(205px, 27svh, 300px);
  overflow: hidden;
  padding: 14px 10px 11px;
  border: 1px solid rgb(216 187 128 / 38%);
  background:
    linear-gradient(180deg, rgb(4 4 4 / 30%), rgb(2 3 3 / 85%)),
    radial-gradient(circle at 40% 10%, var(--shelf-glow), transparent 58%);
  box-shadow:
    inset 0 0 0 5px rgb(0 0 0 / 42%),
    inset 0 0 34px #000,
    0 8px 16px rgb(0 0 0 / 34%);
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  transition: border-color .16s ease, filter .16s ease, box-shadow .16s ease;
}

.shelf:hover,
.shelf:focus-visible {
  border-color: rgb(216 187 128 / 68%);
  filter: brightness(1.06);
  box-shadow:
    inset 0 0 0 5px rgb(0 0 0 / 42%),
    inset 0 0 34px #000,
    0 10px 20px rgb(0 0 0 / 42%),
    0 0 0 2px rgb(216 187 128 / 22%);
  outline: none;
}

.shelf::before,
.shelf::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.shelf::before {
  inset: 0;
  z-index: 4;
  box-sizing: border-box;
  border: 12px solid transparent;
  border-image: url("../assets/official/ui/archives-shelf-frame.png") 82 / 12px stretch;
}

.shelf::after {
  right: 0;
  bottom: 35px;
  left: 0;
  height: 8px;
  border-block: 1px solid rgb(216 187 128 / 25%);
  background: #170f09 url("../assets/official/ui/shelf-board.webp") center / 100% 100% no-repeat;
  box-shadow: 0 5px 10px #000;
}

.shelf--sub {
  --shelf-accent: #173a53;
  --shelf-glow: rgb(23 58 83 / 28%);
  --shelf-books-image: url("../assets/official/ui/archives-sub-spines.webp");
}

.shelf--if {
  --shelf-accent: #164531;
  --shelf-glow: rgb(22 69 49 / 28%);
  --shelf-books-image: url("../assets/official/ui/archives-if-empty-shelf.webp");
}

.shelf--artbook {
  --shelf-accent: #47204f;
  --shelf-glow: rgb(71 32 79 / 28%);
  --shelf-books-image: url("../assets/official/ui/archives-artbook-spines.webp");
}

.shelf__banner {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 22px;
  height: 72px;
  background: linear-gradient(180deg, var(--shelf-accent), #17070a);
  clip-path: polygon(0 0, 100% 0, 100% 88%, 50% 100%, 0 88%);
  box-shadow: 0 5px 8px #000;
}

.shelf__heading {
  position: relative;
  z-index: 1;
  min-height: 88px;
  padding: 12px 2px 0 34px;
  text-align: center;
}

.shelf__heading h2 {
  margin: 0;
  color: var(--paper);
  font: 500 clamp(18px, 6vw, 36px)/.96 Georgia, "Times New Roman", serif;
  letter-spacing: .04em;
  text-shadow: 0 2px 8px #000;
}

.shelf__heading p {
  margin: 7px 0 0;
  color: var(--gold);
  font-size: clamp(7px, 2vw, 11px);
  letter-spacing: .06em;
}

.shelf__books {
  position: relative;
  align-self: end;
  height: clamp(60px, 11svh, 104px);
  margin: 0 5px;
  border-bottom: 7px solid #1b100a;
  background:
    linear-gradient(180deg, rgb(0 0 0 / 2%), rgb(0 0 0 / 18%)),
    var(--shelf-books-image) center bottom / cover no-repeat;
  box-shadow: inset 0 0 18px #000, 0 6px 9px #000;
}

.shelf__books::before {
  content: "";
  position: absolute;
  inset: 9px 0 8px;
  background: linear-gradient(180deg, rgb(216 187 128 / 5%), transparent 34%, rgb(0 0 0 / 16%));
  opacity: .55;
}

.shelf__books--artbook {
  background:
    linear-gradient(180deg, rgb(0 0 0 / 2%), rgb(0 0 0 / 18%)),
    var(--shelf-books-image) center bottom / cover no-repeat;
}

.shelf__description {
  position: relative;
  z-index: 1;
  min-height: 43px;
  margin: 9px 5px 0;
  color: var(--paper);
  font-size: clamp(8px, 2.15vw, 12px);
  line-height: 1.65;
  text-align: center;
}

.shelf__status {
  position: relative;
  z-index: 1;
  min-height: 16px;
  margin: 2px 4px 7px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font: 8px/1.4 "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  text-align: center;
}

.new-marker {
  position: absolute;
  z-index: 6;
  top: 6px;
  right: 8px;
  min-width: 46px;
  padding: 7px 8px 10px;
  border: 1px solid rgb(229 200 139 / 82%);
  background: linear-gradient(180deg, #8a1b2d, #480911);
  color: #fae5ba;
  box-shadow: 0 5px 10px rgb(0 0 0 / 58%), inset 0 1px rgb(255 231 177 / 16%);
  font: 10px/1 Georgia, serif;
  letter-spacing: .12em;
  clip-path: polygon(0 0, 100% 0, 100% 86%, 50% 100%, 0 86%);
  pointer-events: none;
}

@media (min-width: 768px) and (max-width: 1180px) and (min-height: 600px) {
  .new-marker {
    min-width: 54px;
    padding: 8px 10px 12px;
    font-size: 12px;
  }
}

.phase-note {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.archives-error {
  margin: 14px 10px 0;
  color: #e6b2aa;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 350px) {
  .archives-shell {
    padding-inline: 7px;
  }

  .archive-grid {
    gap: 5px;
  }

  .shelf {
    min-height: 196px;
    padding-inline: 7px;
  }

  .shelf__heading {
    padding-left: 26px;
  }

  .shelf__banner {
    left: 10px;
    width: 18px;
  }

  .archives-message {
    letter-spacing: .035em;
  }

  .shelf__description {
    line-height: 1.48;
  }

  .continue-reading {
    width: 100%;
  }

  .continue-reading__card {
    gap: 3px 8px;
    padding-inline: 12px;
  }

  .continue-reading__position {
    white-space: normal;
  }
}

@media (min-width: 700px) {
  .archives-shell {
    padding-inline: 18px;
  }

  .archive-grid {
    gap: 12px;
  }

  .shelf {
    min-height: 360px;
    padding: 22px 18px 16px;
  }

  .shelf__banner {
    left: 24px;
    width: 30px;
    height: 96px;
  }

  .shelf__heading {
    min-height: 118px;
    padding-left: 42px;
  }

}

@media (min-width: 768px) and (max-width: 1180px) and (min-height: 600px) {
  .archives-shell {
    width: max(92vw, min(100%, 760px));
    max-width: 100%;
    padding-inline: 22px;
  }

  .archive-grid {
    gap: 16px;
  }

  .continue-reading {
    width: min(100%, 860px);
    margin-bottom: 18px;
  }

  .continue-reading__card {
    min-height: 112px;
    padding: 17px 22px 16px;
  }

  .continue-reading__label {
    font-size: 13px;
  }

  .continue-reading__book {
    font-size: 14px;
  }

  .continue-reading__title {
    font-size: 21px;
  }

  .continue-reading__position {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .archives-reader-destination {
    transform: translate3d(0, 0, 0);
    transition-duration: .1s;
  }
}

@media (min-width: 768px) and (max-width: 1180px) and (min-height: 600px) and (orientation: landscape) {
  .archives-shell {
    width: max(95vw, min(100%, 760px));
  }
}
