/* Products menu and the illustrated-book reader.
   Shares the site's paper, linen, and gold tokens from index.html. */

.products-trigger {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 10px 0 8px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: #2b2620;
  cursor: pointer;
  position: relative;
}

.products-trigger__label {
  position: relative;
  display: inline-block;
  font-family: var(--caps);
  font-style: normal;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.3em;
  line-height: 1;
  text-transform: uppercase;
  margin-right: -0.3em;
}

.products-trigger__label::after {
  content: "";
  position: absolute;
  right: 0.3em;
  bottom: -7px;
  height: 1px;
  width: calc(100% - 0.3em);
  background: #c4a96a;
  transition: width 0.4s ease;
}

.products-trigger:hover .products-trigger__label::after,
.products-trigger[aria-expanded="true"] .products-trigger__label::after,
.products-trigger:focus-visible .products-trigger__label::after {
  width: calc(100% - 0.3em + 10px);
}

.products-menu {
  position: absolute;
  top: calc(100% + 18px);
  right: 0;
  left: auto;
  width: max-content;
  max-width: min(78vw, 420px);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
  background: none;
  border: 0;
  box-shadow: none;
  pointer-events: none;
}

.products-menu[hidden] {
  display: none;
}

.products-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 9px;
  width: auto;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: #2b2620;
  font: inherit;
  text-align: right;
  cursor: pointer;
  pointer-events: auto;
  animation: products-rise 300ms ease-out both;
  animation-delay: calc(var(--i, 0) * 70ms);
  transition: padding-bottom 0.35s ease;
}

.products-item:hover,
.products-item:focus-visible {
  padding-bottom: 26px;
}

@keyframes products-rise {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.products-item__mark {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: #c4a96a;
}

.products-item__copy {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: none;
}

.products-item__title {
  position: relative;
  display: inline-block;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 16.5px;
  letter-spacing: 0.015em;
  line-height: 1.15;
  white-space: nowrap;
}

.products-item__title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  height: 1px;
  width: 0;
  background: #c4a96a;
  transition: width 400ms ease-out;
}

.products-item:hover .products-item__title::after,
.products-item:focus-visible .products-item__title::after {
  width: 100%;
}

.products-item__subtitle {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  display: block;
  opacity: 0;
  font-family: "Cormorant SC", var(--caps);
  font-style: normal;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.16em;
  line-height: 1.35;
  text-transform: uppercase;
  color: rgba(43, 38, 32, 0.62);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.products-item:hover .products-item__subtitle,
.products-item:focus-visible .products-item__subtitle {
  opacity: 1;
}

@media (max-width: 600px) {
  .products-trigger {
    min-height: 44px;
    padding: 8px 0;
  }

  .products-trigger__label {
    font-size: 12px;
    letter-spacing: 0.26em;
    margin-right: -0.26em;
  }

  .products-trigger__label::after {
    right: 0.26em;
    width: calc(100% - 0.26em);
  }

  .products-trigger:hover .products-trigger__label::after,
  .products-trigger[aria-expanded="true"] .products-trigger__label::after,
  .products-trigger:focus-visible .products-trigger__label::after {
    width: calc(100% - 0.26em + 8px);
  }

  .products-menu {
    top: calc(100% + 8px);
    gap: 14px;
  }

  .products-item {
    min-height: 44px;
    align-items: center;
    padding: 0;
  }

  .products-item:hover,
  .products-item:focus-visible {
    padding-bottom: 28px;
  }

  .products-item__mark {
    margin-top: 0;
  }

  .products-item__title {
    font-size: 16px;
  }

  .products-item__subtitle {
    font-size: 9px;
    letter-spacing: 0.1em;
    white-space: normal;
    text-align: right;
    max-width: 68vw;
  }
}

/* ─── Reader ─── */

.reader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  color: var(--paper-ink, #2a1f0f);
  background:
    radial-gradient(ellipse 80% 65% at 50% 42%, rgba(255, 252, 244, 0.45), transparent 68%),
    radial-gradient(ellipse 140% 100% at 50% 50%, transparent 58%, rgba(90, 75, 55, 0.12) 100%),
    var(--linen),
    var(--paper, #f2ead8);
  background-size: auto, auto, 300px 300px, auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.reader.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.reader-close {
  position: absolute;
  top: 22px;
  left: 24px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: rgba(255, 252, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(180, 170, 155, 0.2);
  border-radius: 24px;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #5a5550;
  box-shadow: 0 2px 8px rgba(35, 32, 28, 0.06);
}

.reader-close svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.5;
}

.reader-close:hover {
  background: rgba(255, 252, 248, 0.95);
  color: #3a352f;
}

.reader-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 28px 6px;
}

.book-shell {
  position: relative;
  width: min(1100px, 100%);
  margin: 0 auto;
}

#book {
  width: 100%;
  touch-action: none;
}

.reader .stf__parent {
  touch-action: none !important;
  -ms-touch-action: none !important;
  margin: 0 auto;
}

.reader .stf__wrapper {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.book-page {
  position: relative;
  background: #f6f1e4;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.book-page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.page-link {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

.page-link__mark,
.page-link__hit {
  position: absolute;
  box-sizing: border-box;
}

.page-link__mark {
  pointer-events: none;
  border-bottom: 1px solid transparent;
}

.page-link__hit {
  pointer-events: auto;
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  min-height: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.page-link:has(.page-link__hit:hover) .page-link__mark,
.page-link:has(.page-link__hit:focus-visible) .page-link__mark {
  background: rgba(196, 169, 106, 0.28);
  border-bottom-color: rgba(140, 100, 40, 0.95);
}

.page-link__hit:focus-visible {
  outline: 1px solid rgba(168, 132, 62, 0.75);
  outline-offset: 1px;
}

/* Plate style switch: a whisper of spaced small caps above each plate. */
.plate-art {
  position: absolute;
  z-index: 2;
  display: block;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}

.plate-art.is-shown {
  opacity: 1;
}

.plate-styles {
  position: absolute;
  z-index: 4;
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.55em;
  padding-bottom: 0.9em;
  font-family: var(--serif);
  font-size: max(9px, calc(var(--page-w, 560px) * 0.0205));
  font-variant: small-caps;
  letter-spacing: 0.12em;
  line-height: 1;
  white-space: nowrap;
  color: rgba(106, 80, 40, 0.62);
  pointer-events: none;
}

.plate-styles__sep {
  color: rgba(138, 111, 58, 0.45);
}

.plate-styles__choice {
  position: relative;
  pointer-events: auto;
  appearance: none;
  margin: 0;
  padding: 0.5em 0.1em;
  border: 0;
  background: transparent;
  font: inherit;
  font-variant: small-caps;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 240ms ease;
}

.plate-styles__choice::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0.15em;
  width: 0;
  height: 1px;
  background: var(--gold-light, #a88a4e);
  transition: width 320ms ease, left 320ms ease;
}

.plate-styles__choice:hover {
  color: var(--gold-deep, #6a5028);
}

.plate-styles__choice.is-active {
  color: var(--gold-deep, #6a5028);
}

.plate-styles__choice.is-active::after {
  left: 18%;
  width: 64%;
}

.plate-styles__choice:focus-visible {
  outline: 1px solid rgba(168, 132, 62, 0.75);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .plate-art,
  .plate-styles__choice,
  .plate-styles__choice::after {
    transition: none;
  }
}

.stf__item.--left.book-page {
  box-shadow: inset -14px 0 18px rgba(48, 32, 14, 0.07);
}

.stf__item.--right.book-page {
  box-shadow: inset 14px 0 18px rgba(48, 32, 14, 0.07);
}

.book-gutter,
.book-edge,
.book-cast {
  position: absolute;
  pointer-events: none;
}

.book-gutter {
  z-index: 4;
  width: 46px;
  background: linear-gradient(
    90deg,
    rgba(48, 32, 14, 0) 0%,
    rgba(48, 32, 14, 0.05) 28%,
    rgba(36, 24, 10, 0.22) 50%,
    rgba(48, 32, 14, 0.05) 72%,
    rgba(48, 32, 14, 0) 100%
  );
  mix-blend-mode: multiply;
}

.book-edge {
  z-index: 3;
  border-radius: 0 1px 1px 0;
  background: repeating-linear-gradient(
    to right,
    #f7f1e3 0px,
    #f7f1e3 1px,
    #e4d7c0 1px,
    #cbbfa6 2px
  );
  box-shadow: 1px 0 2px rgba(40, 28, 12, 0.12);
}

.book-edge-left {
  border-radius: 1px 0 0 1px;
  box-shadow: -1px 0 2px rgba(40, 28, 12, 0.1);
}

.book-cast {
  z-index: 1;
  height: 28px;
  background: radial-gradient(ellipse at center, rgba(40, 28, 12, 0.32), transparent 70%);
  filter: blur(3px);
}

.reader.is-flipping .book-gutter {
  opacity: 0;
}

.reader-status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: #8a7350;
  pointer-events: none;
}

.reader-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(180, 154, 82, 0.35);
  background: rgba(242, 234, 216, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.reader-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
}

#readerJump {
  margin: 0;
}

.reader-bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: #5c4a2c;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
}

.reader-bar button svg {
  width: 18px;
  height: 18px;
  display: block;
}

.reader-icon {
  width: 36px;
  padding: 0;
  position: relative;
}

.reader-icon[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 3px 9px 4px;
  border: 1px solid rgba(180, 154, 82, 0.5);
  border-radius: 999px;
  background: #f7f1e4;
  color: #5a4524;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(40, 28, 12, 0.12);
  transition: opacity 0.2s ease;
}

.reader-icon[data-tip]:hover::after,
.reader-icon[data-tip]:focus-visible::after {
  opacity: 1;
}

.reader-bar button:hover {
  color: #3a2e18;
}

.reader-bar button:disabled {
  opacity: 0.35;
  cursor: default;
}

.reader-jump {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: #3a3228;
}

.reader-page-input {
  width: 4.4ch;
  padding: 0 0 1px;
  border: 0;
  border-bottom: 1px solid rgba(168, 138, 78, 0.7);
  background: transparent;
  color: #2a1f0f;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.reader-page-input:focus {
  outline: none;
  border-bottom-color: #8a6f3a;
}

.reader-sep {
  width: 1px;
  height: 16px;
  background: rgba(180, 154, 82, 0.45);
}

.contents-panel {
  position: absolute;
  right: 22px;
  bottom: 74px;
  z-index: 6;
  width: min(440px, calc(100vw - 32px));
  max-height: min(62vh, 560px);
  display: flex;
  flex-direction: column;
  padding: 18px 8px 12px 20px;
  background: linear-gradient(180deg, #fefcf8 0%, #f8f3e8 100%);
  border: 1px solid rgba(180, 154, 82, 0.4);
  border-radius: 8px;
  box-shadow:
    0 1px 0 rgba(255, 252, 245, 0.8) inset,
    0 18px 44px rgba(40, 28, 12, 0.16);
}

.contents-panel[hidden] {
  display: none;
}

.contents-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 8px;
  margin-bottom: 6px;
}

.contents-head h2 {
  font-family: var(--caps);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #6a5028;
}

.contents-head button {
  border: 0;
  background: transparent;
  color: #8a7350;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}

.contents-list {
  overflow: auto;
  padding-right: 10px;
}

.contents-list::-webkit-scrollbar {
  width: 8px;
}

.contents-list::-webkit-scrollbar-thumb {
  background: rgba(180, 154, 82, 0.45);
  border-radius: 8px;
}

.toc-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 7px 8px 7px 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.35;
  color: #3d3428;
}

.toc-item[data-depth="0"] {
  margin-top: 12px;
  font-family: var(--caps);
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6a5028;
}

.toc-item[data-depth="1"] {
  padding-left: 12px;
}

.toc-item.is-current,
.toc-item:hover {
  color: #6a5028;
}

.toc-item.is-current {
  background: rgba(196, 169, 106, 0.12);
  border-radius: 4px;
}

.reader button:focus-visible,
.reader input:focus-visible,
.products-trigger:focus-visible,
.products-item:focus-visible,
.toc-item:focus-visible {
  outline: 1px solid #c4a96a;
  outline-offset: 3px;
}

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

@media (max-width: 600px) {
  .reader-close {
    top: 12px;
    left: 12px;
    padding: 8px 14px;
  }

  .reader-stage {
    padding: 56px 8px 2px;
  }

  .reader-bar {
    gap: 2px 12px;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .reader-bar button,
  .reader-jump,
  .reader-page-input {
    font-size: 15px;
  }

  .contents-panel {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 68px;
    max-height: 54vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader,
  .products-trigger,
  .products-trigger__label::after,
  .products-item,
  .products-item__title::after,
  .products-item__subtitle {
    transition: none;
    animation: none;
  }
}
