:root {
  --indigo: #173f72;
  --indigo-deep: #071a35;
  --gold: #e8cc78;
  --paper: #efe4c7;
  --paper-deep: #d7c7a4;
  --ink: #2d261c;
  --wood: #442713;
  --wood-light: #875626;
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: #fff9e9;
  background: var(--indigo-deep);
  font-family: "Noto Serif JP", serif;
  font-weight: 300;
}

body:has(.book-dialog[open]) {
  overflow: hidden;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

.wall {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url("/world-wall.webp") center / cover no-repeat;
  filter: brightness(1.42) saturate(1.08);
}

.wall::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(90, 145, 201, 0.14), transparent 48%),
    linear-gradient(180deg, rgba(7, 23, 49, 0.05), rgba(5, 17, 38, 0.42));
}

.world-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  background: rgba(13, 35, 67, 0.94);
  border-bottom: 1px solid rgba(232, 204, 120, 0.32);
  box-shadow: 0 8px 28px rgba(2, 9, 22, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.world-nav-inner {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: grid;
  gap: 2px;
  color: #fff7df;
  text-decoration: none;
  letter-spacing: 0.15em;
}

.brand span {
  font-size: 0.86rem;
}

.brand small {
  color: var(--gold);
  font: 500 0.61rem/1.4 "Cormorant Garamond", serif;
  letter-spacing: 0.24em;
}

.back-link {
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-underline-offset: 5px;
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.world-intro {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(78px, 10vw, 132px) 0 clamp(70px, 8vw, 105px);
  text-align: center;
}

.eyebrow,
.archive-number {
  margin: 0 0 14px;
  color: var(--gold);
  font: 500 0.72rem/1.5 "Cormorant Garamond", serif;
  letter-spacing: 0.3em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5.4vw, 4.2rem);
  font-weight: 300;
  letter-spacing: 0.12em;
  text-shadow: 0 3px 22px rgba(1, 9, 23, 0.72);
}

.world-lead {
  max-width: 660px;
  margin: 34px auto 0;
  font-size: clamp(0.96rem, 1.8vw, 1.15rem);
  line-height: 2.15;
  letter-spacing: 0.05em;
}

.mobile-break {
  display: none;
}

.mobile-title-break {
  display: none;
}

.archive {
  padding: 0 0 120px;
}

.archive-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 30px;
  margin-bottom: 26px;
}

.archive-heading h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2.15rem);
  font-weight: 300;
  letter-spacing: 0.12em;
}

.archive-heading > p {
  margin: 0;
  color: rgba(255, 249, 233, 0.7);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 0.78rem;
  line-height: 1.9;
  text-align: right;
}

.bookcase {
  position: relative;
  overflow: hidden;
  padding: clamp(72px, 8.5vw, 104px) clamp(48px, 7.5vw, 94px) clamp(86px, 9.5vw, 112px);
  border: 0;
  background: url("/book-spines/antique-bookcase-empty.webp") center / 100% 100% no-repeat;
  box-shadow:
    0 38px 82px rgba(1, 7, 18, 0.44);
}

.bookcase::before,
.bookcase::after {
  content: none;
}

.shelf-top {
  display: none;
}

.books {
  min-height: 390px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: clamp(8px, 1.5vw, 18px);
  padding: 36px clamp(8px, 3vw, 42px) 0;
  overflow: hidden;
  background: transparent;
}

.book {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: clamp(68px, 8.6vw, 104px);
  height: var(--book-height, 330px);
  flex: 0 1 104px;
  border: 1px solid rgba(248, 219, 145, 0.42);
  border-left-color: rgba(255, 234, 175, 0.24);
  border-right-color: rgba(43, 24, 12, 0.76);
  border-radius: 5px 12px 9px 4px;
  padding: 18px 10px;
  cursor: pointer;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  text-align: center;
  background:
    var(--book-image) center / cover no-repeat,
    var(--book-color, #6e2f27);
  box-shadow:
    inset 4px 0 7px rgba(255, 238, 185, 0.1),
    inset -8px 0 11px rgba(0, 0, 0, 0.3),
    6px 8px 12px rgba(0, 0, 0, 0.5);
  transform-origin: 50% 100%;
  transition: transform 0.28s ease, filter 0.28s ease;
}

.book::before,
.book::after {
  content: none;
}

.book:hover,
.book:focus-visible {
  z-index: 2;
  outline: none;
  filter: brightness(1.16);
  transform: translateY(-20px) rotate(-1deg);
}

.book-index,
.book-year {
  position: relative;
  z-index: 1;
  min-width: 70%;
  padding: 5px 3px;
  border-top: 1px solid rgba(245, 210, 125, 0.56);
  border-bottom: 1px solid rgba(72, 39, 18, 0.58);
  background: rgba(32, 17, 10, 0.12);
  font: 500 0.62rem/1.3 "Cormorant Garamond", serif;
  letter-spacing: 0.13em;
  color: #f4dc9b;
  text-shadow: 0 1px 3px rgba(20, 9, 5, 0.75);
}

.book-title {
  position: relative;
  z-index: 1;
  writing-mode: vertical-rl;
  justify-self: center;
  min-height: 48%;
  padding: 13px 6px;
  border-right: 1px solid rgba(247, 216, 138, 0.48);
  border-left: 1px solid rgba(247, 216, 138, 0.48);
  background: linear-gradient(90deg, rgba(18, 8, 5, 0.2), rgba(255, 239, 189, 0.05), rgba(18, 8, 5, 0.22));
  font-size: clamp(0.78rem, 1.3vw, 1rem);
  line-height: 1.7;
  letter-spacing: 0.11em;
  color: #fff2ca;
  text-shadow:
    0 1px 1px rgba(33, 15, 7, 0.94),
    0 0 5px rgba(255, 220, 128, 0.18);
}

.book-story {
  --book-height: 354px;
  --book-image: url("/book-spines/spine-kimyowado.webp");
  --book-color:
    linear-gradient(90deg, #5a1818, #9c382d 43%, #4a1417),
    #78251f;
}

.book-shelf {
  --book-height: 312px;
  --book-image: url("/book-spines/spine-third-shelf.webp");
  --book-color:
    linear-gradient(90deg, #292849, #5c5389 43%, #23223f),
    #413a69;
}

.book-cafe {
  --book-height: 340px;
  --book-image: url("/book-spines/spine-kissa-fukudoku.webp");
  --book-color:
    linear-gradient(90deg, #302018, #80532f 43%, #291a13),
    #58371f;
}

.book-observatory {
  --book-height: 362px;
  --book-image: url("/book-spines/spine-tokiden.webp");
  --book-color:
    linear-gradient(90deg, #183d51, #376f83 43%, #143246),
    #25586c;
}

.book-festival {
  --book-height: 330px;
  --book-image: url("/book-spines/spine-art-festival.webp");
  --book-color:
    linear-gradient(90deg, #664310, #b38323 43%, #4f320d),
    #8e6419;
}

.book-orchestra {
  --book-height: 350px;
  --book-image: url("/book-spines/spine-jar-orchestra.webp");
  --book-color:
    linear-gradient(90deg, #1d5053, #37827c 43%, #173e46),
    #286765;
}

.shelf-base {
  height: 8px;
}

.shelf-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  margin-top: 22px;
}

.shelf-instruction {
  grid-column: 2;
  margin: 0;
  color: rgba(255, 247, 222, 0.84);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-align: center;
  text-shadow: 0 2px 5px rgba(10, 4, 2, 0.92);
}

.shelf-instruction span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  margin-right: 7px;
  place-items: center;
  border: 1px solid rgba(232, 204, 120, 0.52);
  border-radius: 50%;
  color: var(--gold);
}

.shelf-pagination {
  grid-column: 3;
  justify-self: end;
  display: inline-grid;
  grid-template-columns: 34px minmax(34px, auto) 34px;
  align-items: center;
  gap: 2px;
  color: #f5e4af;
}

.shelf-page-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(232, 204, 120, 0.42);
  border-radius: 50%;
  background: rgba(9, 28, 55, 0.54);
  color: var(--gold);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.shelf-page-button:hover,
.shelf-page-button:focus-visible {
  outline: none;
  border-color: rgba(245, 224, 157, 0.88);
  background: rgba(23, 63, 114, 0.82);
}

.shelf-page-button:disabled {
  opacity: 0.28;
  cursor: default;
}

.shelf-page-number {
  min-width: 34px;
  color: #fff4ce;
  font: 500 1.05rem/1 "Cormorant Garamond", serif;
  text-align: center;
}

.book-dialog {
  width: min(1600px, calc(100vw - 12px));
  max-width: none;
  max-height: calc(100dvh - 8px);
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  overflow: visible;
}

.book-dialog::backdrop {
  background: rgba(2, 8, 19, 0.86);
  backdrop-filter: blur(8px);
}

.reader-wrap {
  position: relative;
  padding: 4px;
}

.reader-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(239, 211, 139, 0.72);
  border-radius: 50%;
  color: #fff4d4;
  background: #17385f;
  cursor: pointer;
}

.open-book {
  --open-book-image: url("/open-books/transparent/open-book-red-tight.png");
  position: relative;
  width: min(calc(100vw - 8px), calc((100dvh - 8px) * 1.57));
  aspect-ratio: 1.57;
  margin: 0 auto;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: var(--open-book-image) center / 100% 100% no-repeat;
  filter: drop-shadow(0 30px 44px rgba(0, 0, 0, 0.62));
  animation: open-book 0.42s cubic-bezier(.2,.8,.2,1) both;
}

.book-pages-scroll {
  position: absolute;
  inset: 4.5% 7.5% 6.5%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  font-weight: 400;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(111, 79, 38, 0.52) transparent;
}

.book-pages-scroll::-webkit-scrollbar {
  width: 8px;
}

.book-pages-scroll::-webkit-scrollbar-track {
  background: rgba(129, 99, 57, 0.08);
}

.book-pages-scroll::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(111, 79, 38, 0.52);
  background-clip: padding-box;
}

.open-book::after {
  content: none;
}

@keyframes open-book {
  from { opacity: 0; transform: perspective(1200px) rotateX(7deg) scale(0.9); }
  to { opacity: 1; transform: perspective(1200px) rotateX(0) scale(1); }
}

.book-page {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: clamp(16px, 1.8vw, 28px) clamp(24px, 3vw, 48px) clamp(28px, 3vw, 48px);
  overflow: visible;
  background: transparent;
}

.book-page-left {
  padding-right: clamp(30px, 3.8vw, 58px);
}

.book-page-right {
  padding-left: clamp(30px, 3.8vw, 58px);
}

.reader-index {
  margin: 0;
  color: #76592c;
  font: 600 0.69rem/1.4 "Cormorant Garamond", serif;
  letter-spacing: 0.25em;
}

.reader-state {
  display: inline-block;
  margin: 18px 0 12px;
  padding: 5px 10px;
  border: 1px solid #8c6833;
  color: #62471f;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 0.67rem;
  letter-spacing: 0.12em;
}

.book-page h2 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.65rem);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.08em;
}

.reader-subtitle {
  margin: 10px 0 30px;
  color: #7a5d31;
  font: 600 0.75rem/1.5 "Cormorant Garamond", serif;
  letter-spacing: 0.15em;
}

.reader-summary,
.reader-section,
.reader-meta {
  font-size: 0.88rem;
  line-height: 2;
}

.reader-summary p,
.reader-section p {
  margin: 0 0 1em;
}

.reader-section {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(104, 76, 35, 0.38);
}

.reader-section h3 {
  margin: 0 0 13px;
  color: #6b4a1c;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.13em;
}

.placement-figure {
  margin: 0;
}

.placement-image-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.placement-image-frame::after {
  content: none;
}

.placement-image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) contrast(0.98);
}

.placement-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 17px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.placement-steps li {
  position: relative;
  min-width: 0;
  padding-top: 7px;
  border-top: 1px solid rgba(107, 74, 28, 0.42);
}

.placement-steps li:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 7px;
  right: -13px;
  color: rgba(107, 74, 28, 0.58);
  font-size: 0.72rem;
}

.placement-steps span {
  display: block;
  color: #8b6a39;
  font: 600 0.55rem/1.3 "Cormorant Garamond", serif;
  letter-spacing: 0.12em;
}

.placement-steps strong {
  display: block;
  margin-top: 2px;
  color: #523817;
  font-size: clamp(0.62rem, 0.8vw, 0.73rem);
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0.04em;
}

.placement-note {
  margin: 13px 0 0;
  color: #68491f;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.75;
  letter-spacing: 0.04em;
  text-align: center;
}

.reader-figure {
  width: min(88%, 370px);
  margin: 0 auto 24px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: none;
}

.reader-image-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.reader-figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.1) saturate(0.88);
}

.reader-figure figcaption {
  padding: 8px 2px 0;
  color: #735a37;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 0.67rem;
  line-height: 1.6;
}

.photo-pending {
  min-height: 220px;
  margin-bottom: 24px;
  border: 1px dashed rgba(103, 77, 41, 0.48);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: #806744;
  text-align: center;
}

.photo-pending[hidden],
.reader-figure[hidden] {
  display: none;
}

.photo-pending span {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid #9c7540;
  border-radius: 50%;
  font-size: 1.2rem;
}

.photo-pending p {
  margin: 0;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 0.76rem;
}

.reader-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
  margin: 24px 0 0;
  padding: 18px 0;
  border-top: 1px solid rgba(104, 76, 35, 0.32);
}

.reader-meta dt {
  color: #76582f;
  font-size: 0.72rem;
}

.reader-meta dd {
  margin: 0;
  font-size: 0.72rem;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.reader-actions a {
  padding: 9px 13px;
  border: 1px solid #755526;
  color: #4d3516;
  font-size: 0.72rem;
  text-decoration: none;
}

footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 50px;
  border-top: 1px solid rgba(232, 204, 120, 0.3);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: rgba(255, 249, 233, 0.68);
  font-size: 0.73rem;
  letter-spacing: 0.08em;
}

footer p {
  margin: 0;
}

footer a {
  color: var(--gold);
}

@media (max-width: 760px) {
  .world-nav-inner {
    width: min(100% - 48px, 1180px);
    min-height: 62px;
    padding: 11px 0;
    gap: 16px;
  }

  .brand {
    min-width: 0;
    letter-spacing: 0.1em;
  }

  .brand span {
    overflow: hidden;
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand small {
    display: none;
  }

  .back-link {
    flex: 0 0 auto;
    font-size: 0.66rem;
    white-space: nowrap;
  }

  main {
    width: min(100% - 48px, 1180px);
  }

  .world-intro {
    padding: 62px 0 58px;
  }

  h1 {
    font-size: clamp(1.75rem, 8.5vw, 2.35rem);
    letter-spacing: 0.08em;
  }

  .mobile-title-break {
    display: inline;
  }

  .world-lead {
    margin-top: 27px;
    font-size: 0.9rem;
    line-height: 2.05;
    letter-spacing: 0.02em;
  }

  .mobile-break {
    display: inline;
  }

  .archive-heading {
    display: block;
  }

  .archive-heading > p {
    margin-top: 16px;
    text-align: left;
  }

  .bookcase {
    max-width: 100%;
    padding: 62px 12px 30px;
    background-size: auto 100%;
  }

  .books {
    min-height: 310px;
    gap: 3px;
    padding: 36px 5px 22px;
    justify-content: center;
    overflow: hidden;
  }

  .book {
    --mobile-book-width: clamp(38px, 11.5vw, 46px);
    width: var(--mobile-book-width);
    min-width: var(--mobile-book-width);
    max-width: var(--mobile-book-width);
    flex-basis: var(--mobile-book-width);
    height: calc(var(--book-height) * 0.78);
    padding: 13px 3px;
  }

  .book::before {
    inset: 6px 4px;
  }

  .book-title {
    font-size: clamp(0.59rem, 2.6vw, 0.68rem);
    line-height: 1.35;
    min-height: 46%;
    padding: 10px 2px;
  }

  .book-index,
  .book-year {
    min-width: 76%;
    padding: 4px 2px;
  }

  .book-year {
    font-size: 0.42rem;
  }

  .shelf-footer {
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 20px;
  }

  .shelf-instruction,
  .shelf-pagination {
    grid-column: 1;
    justify-self: center;
  }

  .shelf-instruction {
    font-size: 0.7rem;
  }

  .book-dialog {
    width: calc(100% - 14px);
    max-height: calc(100dvh - 14px);
  }

  .reader-wrap {
    padding: 26px 3px 3px;
  }

  .reader-close {
    top: -4px;
    right: 3px;
  }

  .open-book {
    width: 100%;
    aspect-ratio: auto;
    max-height: calc(100dvh - 43px);
    display: block;
    overflow: hidden;
    border-radius: 8px;
    background:
      linear-gradient(90deg, rgba(103, 72, 30, 0.22), transparent 7%, transparent 93%, rgba(103, 72, 30, 0.18)),
      #eadfbe;
    box-shadow:
      inset 0 0 0 1px rgba(113, 78, 33, 0.42),
      inset 0 0 34px rgba(104, 72, 29, 0.18);
    filter: drop-shadow(0 22px 32px rgba(0, 0, 0, 0.5));
  }

  .book-pages-scroll {
    position: static;
    display: block;
    overflow-y: auto;
    max-height: calc(100dvh - 43px);
    scrollbar-gutter: auto;
    background:
      radial-gradient(ellipse at 18% 12%, rgba(255, 250, 226, 0.56), transparent 34%),
      radial-gradient(ellipse at 82% 88%, rgba(130, 91, 37, 0.11), transparent 38%),
      repeating-linear-gradient(0deg, rgba(91, 64, 29, 0.018) 0 1px, transparent 1px 4px),
      linear-gradient(90deg, rgba(105, 73, 31, 0.12), transparent 8%, transparent 92%, rgba(105, 73, 31, 0.1)),
      #efe4c5;
  }

  .open-book::after {
    display: none;
  }

  .book-page {
    min-height: 0;
    margin: 0;
    padding: 54px 34px 62px;
    overflow: visible;
    background-color: transparent;
    background-image: none;
  }

  .book-page-left {
    padding-right: 42px;
  }

  .book-page-right {
    padding-left: 42px;
  }

  .book-page-left {
    border-bottom: 1px solid rgba(104, 76, 35, 0.42);
  }

  .reader-figure {
    width: min(100%, 380px);
  }

  footer {
    width: min(100% - 48px, 1180px);
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
