/* Ratio-aware IP archive and proposal reader. Loaded after styles.css. */

.shelf-haze {
  display: none;
}

.shelf-viewport:focus-visible::after {
  display: none;
}

.shelf-viewport:focus-visible .caption-title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.series-browser {
  width: 100vw;
  height: 100dvh;
  margin: 0;
}

.series-browser::backdrop,
.proposal-reader::backdrop {
  background: rgba(25, 23, 19, 0.5);
  backdrop-filter: none;
}

.series-shell,
.reader-shell {
  border: 0;
  box-shadow: none;
}

.series-content {
  grid-template-rows: clamp(150px, 23%, 210px) minmax(0, 1fr);
}

.series-overview {
  padding: clamp(24px, 3vw, 44px) clamp(30px, 4.6vw, 72px);
  align-items: end;
  border-bottom-color: rgba(19, 18, 15, 0.11);
}

.series-overview::before {
  top: auto;
  bottom: 0;
  width: min(22%, 280px);
  height: 3px;
}

.series-hero-copy h2 {
  margin: 8px 0 14px;
  font-size: clamp(42px, 4.3vw, 70px);
  line-height: 0.94;
}

.series-overview > p {
  flex-basis: 390px;
  padding-bottom: 2px;
  font-size: 13px;
  line-height: 1.8;
}

.series-index-panel {
  padding: 22px clamp(30px, 4.5vw, 72px) 22px;
  grid-template-rows: 32px minmax(260px, 1fr) 48px;
  background: var(--paper);
}

.series-index-panel > header {
  align-items: start;
  border-bottom: 0;
}

.series-volume-stage {
  isolation: isolate;
  overflow: hidden;
}

.series-volume-caption {
  left: 0;
  bottom: 8px;
  max-width: min(54%, 620px);
  padding: 8px 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  background: transparent;
  backdrop-filter: none;
}

.series-volume-caption strong {
  font-size: 14px;
}

.series-deck-list {
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(19, 18, 15, 0.12);
}

.series-deck {
  height: 31px;
  border-radius: 0;
  border-color: transparent;
  border-bottom-color: rgba(19, 18, 15, 0.2);
}

.series-deck:hover,
.series-deck:focus-visible {
  border-color: transparent;
  border-bottom-color: var(--ink);
}

.series-deck.is-active {
  border-color: var(--ink);
  color: var(--paper);
  background: var(--ink);
}

.proposal-reader {
  width: 100vw;
  height: 100dvh;
  margin: 0;
}

.proposal-reader[open] .reader-shell {
  animation: readerEnter 320ms cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.reader-shell {
  grid-template-rows: 58px minmax(0, 1fr);
}

.reader-content {
  min-height: 0;
  padding: clamp(24px, 3vw, 44px) clamp(24px, 3.5vw, 58px) clamp(30px, 3.5vw, 54px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 20vw, 330px);
  align-items: stretch;
  gap: clamp(34px, 4vw, 68px);
  background: var(--paper);
}

.reader-book-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0 12px 10px 0;
}

.reader-book {
  --reader-aspect: 16 / 9;
  --reader-accent: #25241f;
  width: 100%;
  max-width: 1180px;
  min-width: 0;
  display: grid;
  grid-template-columns: clamp(34px, 3.2vw, 48px) minmax(0, 1fr);
  align-items: stretch;
  filter: drop-shadow(0 24px 26px rgba(20, 18, 14, 0.16));
}

.reader-spine {
  min-height: 0;
  height: 100%;
  padding: 14px 0;
  border: 0;
  border-radius: 3px 0 0 3px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent 20%, transparent 74%, rgba(0, 0, 0, 0.2)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, rgba(0,0,0,0.025) 1px 2px),
    var(--reader-accent);
  box-shadow:
    inset -6px 0 9px rgba(0, 0, 0, 0.14),
    inset 2px 0 3px rgba(255, 255, 255, 0.12);
}

.reader-stage {
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: var(--reader-aspect);
  position: relative;
  padding: 0;
  display: block;
  overflow: visible;
  background: #fff;
  box-shadow: none;
  transform: none;
}

.reader-stage iframe {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  outline: 0;
  background: #fff;
  box-shadow: none;
  transform: none;
}

.reader-stage iframe[hidden],
.reader-cover-preview[hidden] {
  display: none;
}

.reader-cover-preview {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #fff;
}

.reader-page-edge {
  position: absolute;
  z-index: 0;
  display: block;
  pointer-events: none;
}

.reader-page-edge-right {
  top: 6px;
  right: -10px;
  bottom: -7px;
  width: 10px;
  background: repeating-linear-gradient(0deg, #eee9df 0 1px, #fff 1px 3px, #e5dfd4 3px 4px);
  box-shadow: 3px 2px 5px rgba(22, 19, 15, 0.13);
}

.reader-page-edge-bottom {
  left: 8px;
  right: -10px;
  bottom: -8px;
  height: 8px;
  background: repeating-linear-gradient(90deg, #eee9df 0 1px, #fff 1px 4px, #e6e0d5 4px 5px);
  box-shadow: 1px 4px 5px rgba(22, 19, 15, 0.12);
}

.reader-binding-crease {
  position: absolute;
  z-index: 3;
  inset: 0 auto 0 0;
  width: clamp(24px, 4.2%, 48px);
  background: linear-gradient(90deg,
    rgba(0, 0, 0, 0.2) 0,
    rgba(255, 255, 255, 0.1) 15%,
    rgba(0, 0, 0, 0.12) 40%,
    rgba(255, 255, 255, 0.08) 62%,
    transparent 100%);
  mix-blend-mode: multiply;
  opacity: 0.42;
  pointer-events: none;
}

.reader-loading {
  inset: 0;
  z-index: 4;
  background: #f7f4ec;
}

.reader-loading.is-error {
  inset: auto 18px 18px auto;
  width: auto;
  min-height: 0;
  padding: 10px 13px;
  color: var(--paper);
  background: rgba(19, 18, 15, 0.9);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.reader-details {
  min-width: 0;
  padding: clamp(14px, 2vh, 24px) 0 0 clamp(24px, 2.5vw, 38px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-left: 1px solid rgba(19, 18, 15, 0.14);
}

.reader-kicker {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.reader-details h2 {
  margin: 20px 0 14px;
  font-family: "Songti SC", Georgia, serif;
  font-size: clamp(30px, 2.6vw, 46px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.reader-details > p {
  margin: 0 0 clamp(24px, 4vh, 46px);
  color: var(--muted);
  font-family: "Songti SC", Georgia, serif;
  font-size: 12px;
  line-height: 1.75;
}

.reader-details dl {
  margin: 0;
  border-top: 1px solid rgba(19, 18, 15, 0.14);
}

.reader-details dl > div {
  min-height: 42px;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(19, 18, 15, 0.11);
}

.reader-details dt,
.reader-details dd {
  margin: 0;
}

.reader-details dt {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.reader-details dd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 650;
}

.reader-details > a {
  min-height: 44px;
  margin-top: auto;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--ink);
  color: var(--paper);
  background: var(--ink);
  text-decoration: none;
  text-transform: uppercase;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.reader-details > a:hover,
.reader-details > a:focus-visible {
  color: var(--ink);
  background: transparent;
  outline: 0;
}

.reader-details > a.is-unavailable {
  opacity: 0.38;
  pointer-events: none;
}

.reader-details > small {
  margin-top: 12px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

@media (max-width: 980px) {
  .reader-content {
    padding: 22px 22px 28px;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 30px;
  }

  .reader-details {
    padding-left: 24px;
  }

  .reader-details h2 {
    font-size: clamp(26px, 3.5vw, 36px);
  }
}

@media (max-width: 820px) {
  .series-content {
    grid-template-rows: minmax(116px, auto) minmax(0, 1fr);
  }

  .series-index-panel {
    padding: 16px 18px max(16px, env(safe-area-inset-bottom));
    grid-template-rows: 28px clamp(230px, 43svh, 360px) 46px;
  }

  .series-index-panel > header span:last-child {
    display: none;
  }

  .proposal-reader {
    width: 100vw;
    height: 100svh;
  }

  .reader-shell {
    height: 100%;
    grid-template-rows: 52px minmax(0, 1fr);
  }

  .reader-content {
    padding: 22px 16px max(24px, env(safe-area-inset-bottom));
    grid-template-columns: 1fr;
    align-content: start;
    gap: 34px;
    overflow-y: auto;
  }

  .reader-book-column {
    padding-right: 8px;
  }

  .reader-book {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .reader-spine {
    padding-block: 9px;
  }

  .reader-spine span {
    display: none;
  }

  .reader-spine strong {
    max-height: 88px;
    font-size: 8px;
    letter-spacing: 0.04em;
  }

  .reader-details {
    padding: 26px 0 0;
    border-top: 1px solid rgba(19, 18, 15, 0.14);
    border-left: 0;
  }

  .reader-details > p {
    margin-bottom: 24px;
  }

  .reader-details > a {
    margin-top: 24px;
  }
}

/* Quantity-aware IP editions ----------------------------------------- */

/* Keep the WebGL surface as a neutral editorial window. The gallery
   camera already renders every cover square-on; these guards prevent a
   later CSS transform from reintroducing the tilted-card treatment. */
.series-volume-stage,
.series-volume-stage canvas {
  perspective: none;
  transform: none !important;
}

.series-volume-stage {
  width: 100%;
  height: 100%;
  max-height: clamp(340px, 46dvh, 460px);
  align-self: center;
  justify-self: center;
}

/* One edition: give the single book a clear focal field and align its
   metadata beneath the same visual centre instead of leaving it at the
   far-left edge of the shelf. */
.series-index-panel:has(.series-deck-list > .series-deck:only-child) .series-volume-stage {
  max-height: clamp(350px, 52dvh, 500px);
}

.series-index-panel:has(.series-deck-list > .series-deck:only-child) .series-volume-caption {
  left: 50%;
  width: min(64%, 620px);
  max-width: none;
  transform: translateX(-50%);
}

.series-index-panel:has(.series-deck-list > .series-deck:only-child) .series-deck-list {
  justify-content: center;
}

.series-index-panel:has(.series-deck-list > .series-deck:only-child) .series-deck {
  max-width: min(100%, 520px);
}

/* Two editions: shorten the viewport just enough for both 16:9 books to
   fit as one composed pair, with equal air on both sides. */
.series-index-panel:has(.series-deck-list > .series-deck:first-child:nth-last-child(2)) .series-volume-stage {
  max-height: clamp(320px, 44dvh, 410px);
}

.series-index-panel:has(.series-deck-list > .series-deck:first-child:nth-last-child(2)) .series-volume-caption {
  left: 50%;
  width: min(92%, 820px);
  max-width: none;
  transform: translateX(-50%);
}

.series-index-panel:has(.series-deck-list > .series-deck:first-child:nth-last-child(2)) .series-deck-list {
  justify-content: center;
}

/* Three or more editions retain the horizontal archive rail. A slightly
   shallower stage exposes the following volume earlier and makes scrolling
   discoverable without turning the books into tiny thumbnails. */
.series-index-panel:has(.series-deck-list > .series-deck:nth-child(3)) .series-volume-stage {
  max-height: clamp(330px, 46dvh, 440px);
}

/* Header filters ------------------------------------------------------ */

.site-header {
  gap: clamp(20px, 3vw, 36px);
}

.header-filter-nav {
  flex: 0 0 auto;
  width: auto;
  height: 32px;
  grid-template-columns: 60px 64px 58px;
  column-gap: 12px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.header-filter {
  min-height: 30px;
  padding: 0 3px;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 1fr;
  align-content: center;
  gap: 4px;
  position: relative;
  border: 0;
  background: transparent;
  transition: background 160ms ease;
}

.header-filter:first-child {
  border-left: 0;
}

.header-filter:last-of-type {
  border-right: 0;
}

.header-filter:hover,
.header-filter:focus-within {
  background: #f7f7f5;
  box-shadow: none;
}

.header-filter-trigger {
  min-width: 0;
  width: 100%;
  height: 30px;
  overflow: hidden;
  padding: 0 11px 0 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background:
    linear-gradient(45deg, transparent 50%, currentColor 50%) right 3px center / 4px 4px no-repeat,
    linear-gradient(135deg, currentColor 50%, transparent 50%) right 0 center / 4px 4px no-repeat;
  text-overflow: ellipsis;
  text-align: left;
  white-space: nowrap;
  font: 650 9px/1.2 Inter, "PingFang SC", sans-serif;
  cursor: pointer;
}

.header-filter-trigger span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-filter-trigger:focus-visible {
  box-shadow: none;
}

.filter-native {
  display: none !important;
}

.header-filter-menu {
  position: absolute;
  z-index: 100;
  top: calc(100% + 5px);
  left: 0;
  width: 84px;
  max-height: min(360px, calc(100vh - 88px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: #f7f7f5;
  box-shadow: none;
}

#ipFilterMenu {
  width: 112px;
}

#yearFilterMenu {
  right: 0;
  left: auto;
  width: 72px;
}

.header-filter-menu button {
  width: 100%;
  min-height: 32px;
  padding: 7px 8px;
  display: block;
  border: 0;
  border-bottom: 1px solid rgba(19, 18, 15, 0.055);
  border-radius: 0;
  color: var(--ink);
  background: #f7f7f5;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  font: 600 9px/1.35 Inter, "PingFang SC", sans-serif;
  cursor: pointer;
}

.header-filter-menu button:last-child {
  border-bottom: 0;
}

.header-filter-menu button:hover,
.header-filter-menu button:focus-visible {
  color: var(--ink);
  background: #efefec;
  outline: 0;
}

.header-filter-menu button[aria-selected="true"] {
  background: #e7e7e3;
  box-shadow: none;
  font-weight: 750;
}

.header-filter-menu button[aria-selected="true"]:hover,
.header-filter-menu button[aria-selected="true"]:focus-visible {
  color: var(--ink);
  background: #e2e2de;
}

/* At compact desktop widths the field label sits above its value. This
   gives long IP names their own line and keeps the custom arrow clear. */
@media (min-width: 821px) and (max-width: 1180px) {
  .header-filter-nav {
    width: auto;
    grid-template-columns: 60px 64px 58px;
    column-gap: 12px;
  }

  .header-filter {
    min-height: 30px;
    padding: 0 5px;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 1fr;
    align-content: center;
    gap: 4px;
  }

  .header-filter-trigger {
    height: 30px;
    padding-block: 0;
    font-size: 8.5px;
  }
}

@media (max-width: 820px) {
  body {
    grid-template-rows: 108px minmax(0, 1fr);
  }

  .site-header {
    height: 108px;
    min-height: 108px;
    padding: 13px clamp(16px, 4vw, 22px);
    gap: 9px;
  }

  .wordmark img {
    width: clamp(112px, 16vw, 122px);
  }

  .header-filter-nav {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 38px;
    grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.16fr) minmax(0, 0.9fr);
    column-gap: 8px;
    border-radius: 0;
  }

  .header-filter {
    min-width: 0;
    min-height: 38px;
    padding: 0 8px;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 1fr;
    align-content: center;
    gap: 6px;
  }

  .header-filter > span {
    overflow: hidden;
    font-size: 6px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-filter-trigger {
    min-width: 0;
    height: 36px;
    padding: 0 18px 0 0;
    background-position: right 3px center, right 0 center;
    font-size: 9px;
  }

  .header-filter-menu button {
    min-height: 42px;
    padding-block: 10px;
  }

  .header-filter-menu {
    width: 88px;
  }

  #ipFilterMenu {
    width: 120px;
  }

  #yearFilterMenu {
    width: 76px;
  }

  .series-index-panel {
    grid-template-rows: 28px minmax(0, 1fr) 46px;
  }

  .series-volume-stage {
    max-height: clamp(230px, 34svh, 300px);
  }

  .series-index-panel:has(.series-deck-list > .series-deck:only-child) .series-volume-stage {
    max-height: clamp(250px, 40svh, 340px);
  }

  .series-index-panel:has(.series-deck-list > .series-deck:only-child) .series-volume-caption {
    width: min(92%, 520px);
  }

  .series-index-panel:has(.series-deck-list > .series-deck:first-child:nth-last-child(2)) .series-volume-stage {
    max-height: clamp(150px, 20svh, 170px);
  }

  .series-index-panel:has(.series-deck-list > .series-deck:first-child:nth-last-child(2)) .series-volume-caption {
    display: none;
  }

  .series-index-panel:has(.series-deck-list > .series-deck:nth-child(3)) .series-volume-stage {
    max-height: clamp(230px, 34svh, 300px);
  }

  .series-index-panel:has(.series-deck-list > .series-deck:first-child:nth-last-child(2)) .series-deck-list {
    gap: 8px;
  }
}

@media (max-width: 480px) {
  body {
    grid-template-rows: 100px minmax(0, 1fr);
  }

  .site-header {
    height: 100px;
    min-height: 100px;
    padding: 11px 16px;
    gap: 8px;
  }

  .wordmark img {
    width: 112px;
  }

  .header-filter-nav,
  .header-filter {
    min-height: 36px;
  }

  .header-filter-nav {
    height: 36px;
    column-gap: 6px;
  }

  .header-filter {
    padding-inline: 7px;
  }

  .header-filter-trigger {
    height: 34px;
    font-size: 8.5px;
  }
}
