/* 随轩 · 书房
   A walnut study after dark: books stand face-out on lamp-lit shelves and swing toward you when you reach for them.
   The chapter reader turns the lights up: a warm page, a book's contents beside it, notes in the margin.
   walnut #2A1E17 · plank #6B4A33 · lamplight #FFC478 · cream #EFE2CC · brass #D4A65A · page #F9F5EC */

.w-study {
  --bg: #2A1E17; --paper: #F9F5EC; --ink: #EFE2CC; --muted: #B9A68B; --line: rgba(239, 226, 204, .16);
  --acc: #D4A65A; --acc-ink: #2A1E17;
  background:
    radial-gradient(900px 560px at 12% -40px, rgba(255, 196, 120, .26), transparent 70%),
    radial-gradient(700px 500px at 100% 30%, rgba(120, 70, 30, .25), transparent 70%),
    #2A1E17;
}
.w-study .bar { background: rgba(36, 25, 19, .9); border-bottom-color: rgba(212, 166, 90, .3); }
.w-study .bar__logo img { mix-blend-mode: normal; background: #EFE2CC; border-radius: 4px; }
.w-study .bar__nav .nav__a[aria-current="page"] { border-bottom-color: var(--acc); }
.w-study .bar__btn:hover { border-color: var(--acc); }
.w-study .ft { border-top-color: var(--line); }
.w-study .ft__brand img { mix-blend-mode: normal; background: #EFE2CC; border-radius: 6px; }

/* ---------- a book as an object ---------- */
.bk { --w: 156px; --h: 222px; --d: 30px; --spine: hsl(var(--hue) 28% 26%); --spine-ink: rgba(255, 244, 222, .85); display: block; width: var(--w); height: var(--h); perspective: 1300px; }
.bk__in { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateY(24deg) rotateX(3deg); transition: transform .7s cubic-bezier(.2, .9, .25, 1); }
.bk__front, .bk__back, .bk__spine, .bk__pages { position: absolute; display: block; }
.bk__front { inset: 0; transform: translateZ(calc(var(--d) / 2)); overflow: hidden; border-radius: 1px 4px 4px 1px; background: var(--spine); box-shadow: inset 5px 0 7px -3px rgba(0, 0, 0, .45), inset -1px 0 0 rgba(255, 255, 255, .15); }
.bk__front img { width: 100%; height: 100%; object-fit: cover; }
.bk__front::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, rgba(255, 255, 255, .18), transparent 30%, transparent 70%, rgba(0, 0, 0, .18)); }
.bk__back { inset: 0; transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); background: color-mix(in srgb, var(--spine) 78%, #000); }
.bk__spine { top: 0; left: calc(50% - var(--d) / 2); width: var(--d); height: 100%; transform: rotateY(-90deg) translateZ(calc(var(--w) / 2)); background: linear-gradient(90deg, color-mix(in srgb, var(--spine) 72%, #000), var(--spine) 42%, color-mix(in srgb, var(--spine) 82%, #000)); display: flex; align-items: center; justify-content: center; }
.bk__spine b { writing-mode: vertical-rl; font: 700 12px/1 var(--f-serif); letter-spacing: .12em; color: var(--spine-ink); white-space: nowrap; overflow: hidden; max-height: 88%; }
.bk__pages { top: 3px; left: calc(50% - var(--d) / 2 + 2px); width: calc(var(--d) - 4px); height: calc(100% - 6px); transform: rotateY(90deg) translateZ(calc(var(--w) / 2 - 3px)); background: repeating-linear-gradient(90deg, #F3EAD8 0 1px, #DCCFB6 1px 2px); }
.bk__gen { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 22px 16px 16px; color: #F6EAD2; background: radial-gradient(120% 80% at 20% 0%, hsl(var(--hue) 35% 42%), hsl(var(--hue) 30% 26%)); }
.bk__gen b { font: 900 22px/1.3 var(--f-serif); letter-spacing: .04em; }
.bk__gen i { font-style: normal; font-size: 12px; opacity: .8; }
a:hover > .bk .bk__in, a:focus-visible > .bk .bk__in, .bk--big:hover .bk__in { transform: rotateY(6deg) rotateX(2deg) translateZ(34px) translateY(-8px); }
.bk--big { --w: 270px; --h: 384px; --d: 46px; }
.bk--big .bk__spine b { font-size: 16px; }

/* ---------- the shelves ---------- */
.st__head { padding: 70px 0 10px; }
.st__head h1 { font-family: var(--f-serif); font-weight: 900; font-size: 88px; line-height: 1; letter-spacing: .2em; color: #F6EAD2; text-shadow: 0 0 40px rgba(255, 196, 120, .25); }
.st__lede { margin-top: 18px; max-width: 30em; font-family: var(--f-serif); font-size: 18px; line-height: 1.9; color: var(--ink); }
.st__n { margin-top: 10px; font-size: 14px; color: var(--muted); }
.shelf3d { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 64px 28px; margin-top: 60px; }
.shelf3d__i { display: grid; justify-items: center; align-content: start; animation: st-in .9s cubic-bezier(.2, 1, .3, 1) calc(var(--i) * 70ms) both; }
@keyframes st-in { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
.shelf3d__book { position: relative; display: grid; justify-items: center; width: 100%; padding: 10px 0 20px; }
.shelf3d__book::after { content: ""; position: absolute; left: -15px; right: -15px; bottom: 0; height: 20px; background: linear-gradient(#7A563E, #4A3223 70%, #3A2619); box-shadow: 0 16px 20px -10px rgba(0, 0, 0, .7), inset 0 2px 0 rgba(255, 220, 170, .18); border-radius: 2px; }
.shelf3d__book .bk { filter: drop-shadow(14px 18px 14px rgba(0, 0, 0, .55)); }
.shelf3d__info { width: 100%; margin-top: 18px; text-align: center; }
.shelf3d__info h2 { font-family: var(--f-serif); font-weight: 900; font-size: 22px; letter-spacing: .04em; }
.shelf3d__info h2 a { text-decoration: none; color: #F6EAD2; }
.shelf3d__info h2 a:hover { color: var(--acc); }
.shelf3d__sub { margin-top: 4px; font-size: 14px; color: var(--muted); }
.shelf3d__meta { margin-top: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shelf3d__acts { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.shelf3d__acts a { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 17px; font-size: 14px; text-decoration: none; color: var(--ink); box-shadow: inset 0 0 0 1px rgba(212, 166, 90, .5); }
.shelf3d__acts a:hover { background: var(--acc); color: #2A1E17; box-shadow: none; }

/* ---------- one book ---------- */
.bkp__head { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 60px; align-items: center; padding: 70px 0 20px; }
.bkp__obj { display: grid; justify-items: center; filter: drop-shadow(26px 30px 24px rgba(0, 0, 0, .6)); }
.bkp__k a { font-size: 14px; color: var(--muted); }
.bkp__intro h1 { margin-top: 8px; font-family: var(--f-serif); font-weight: 900; font-size: 54px; line-height: 1.2; color: #F6EAD2; }
.bkp__sub { margin-top: 8px; font-family: var(--f-serif); font-size: 20px; color: var(--acc); }
.bkp__meta { margin-top: 12px; font-size: 14px; color: var(--muted); }
.bkp__desc { margin-top: 22px; max-width: 34em; font-family: var(--f-serif); font-size: 17px; line-height: 1.95; }
.bkp__desc p + p { margin-top: .8em; }
.bkp__acts { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.w-study .btn--ink { background: var(--acc); border-color: var(--acc); color: #2A1E17; }
.w-study .btn--ink:hover { background: #F6EAD2; border-color: #F6EAD2; color: #2A1E17; }
.w-study .btn--line { border-color: rgba(212, 166, 90, .6); color: var(--ink); }
.w-study .btn--line:hover { background: var(--acc); color: #2A1E17; }
.bkp__toc { margin-top: 70px; padding: 54px 64px 60px; color: #2A231C; background: #F6EEDC url("../img/tex-paper.png"); box-shadow: 0 40px 60px -30px rgba(0, 0, 0, .7); border-radius: 2px; }
.bkp__toc h2 { text-align: center; font-family: var(--f-serif); font-weight: 900; font-size: 30px; letter-spacing: 1em; text-indent: 1em; }
.bkp__toc ol { display: grid; gap: 2px; max-width: 760px; margin: 30px auto 0; }
.bkp__toc a { display: grid; grid-template-columns: 2.4em minmax(0, max-content) minmax(20px, 1fr) auto; gap: 10px; align-items: baseline; padding: 9px 0; text-decoration: none; }
.bkp__toc a::after { content: ""; grid-column: 3; grid-row: 1; align-self: end; margin-bottom: 7px; border-bottom: 1.5px dotted rgba(42, 35, 28, .4); }
.bkp__no { font-family: var(--f-serif); font-weight: 900; color: #9A6B3A; font-variant-numeric: tabular-nums; }
.bkp__ct { font-family: var(--f-serif); font-size: 17px; }
.bkp__len { grid-column: 4; font-size: 13px; color: #7A6A58; font-variant-numeric: tabular-nums; }
.bkp__toc a:hover .bkp__ct { color: #9A3B2A; text-decoration: underline; text-underline-offset: 4px; }
.bkp__rd { margin-right: 12px; font-style: normal; color: #9A3B2A; }

/* ---------- the chapter reader ---------- */
.w-reader {
  --bg: #EDE6D8; --paper: #F9F5EC; --ink: #22201C; --muted: #6E665B; --line: rgba(34, 32, 28, .14);
  --acc: #9A3B2A; --acc-ink: #FFFFFF;
  background: #EDE6D8;
}
.w-reader .bar { background: rgba(237, 230, 216, .94); border-bottom-color: var(--line); }
.w-reader .bar__logo img { mix-blend-mode: multiply; background: none; }
.w-reader .ft__brand img { mix-blend-mode: multiply; background: none; }
.rd__bar { position: sticky; top: 64px; z-index: 30; background: rgba(249, 245, 236, .92); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.rd__bar-in { display: flex; align-items: center; gap: 16px; width: min(1240px, calc(100% - 64px)); height: 46px; margin-inline: auto; font-size: 14px; }
.rd__book { font-family: var(--f-serif); font-weight: 700; text-decoration: none; }
.rd__book::before { content: "《"; } .rd__book::after { content: "》"; }
:lang(en) .rd__book::before, :lang(en) .rd__book::after { content: ""; }
.rd__pos { color: var(--muted); font-variant-numeric: tabular-nums; }
.rd__fs { display: flex; gap: 4px; margin-left: auto; }
.rd__fs button { height: 30px; padding: 0 10px; border-radius: 15px; font-size: 13px; box-shadow: inset 0 0 0 1px var(--line); }
.rd__fs button:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.rd__head { width: min(760px, calc(100% - 48px)); margin: 64px auto 0; text-align: center; }
.rd__k { font-family: var(--f-serif); font-size: 16px; letter-spacing: .12em; color: var(--acc); }
.rd__k a { text-decoration: none; }
.rd__text > :first-child { margin-top: 0; }
.rd__head h1 { margin-top: 12px; font-family: var(--f-serif); font-weight: 900; font-size: 40px; line-height: 1.35; text-wrap: balance; }
.rd .ag { margin-top: 48px; }
.rd__text { padding: 50px 60px 60px; background: var(--paper); box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 30px 50px -36px rgba(60, 40, 20, .45); font-family: var(--f-serif); font-size: calc(18.5px * var(--rd-fs, 1)); line-height: 2.05; }
.rd__text > p { text-indent: 2em; }
.rd__text > p + p { margin-top: .55em; }
.rd__text h2, .rd__text h3 { text-indent: 0; }
.rd__side a[aria-current="true"] { color: var(--ink); font-weight: 700; background: color-mix(in srgb, var(--acc) 12%, transparent); }
.rd__side ol { max-height: calc(100vh - 220px); overflow-y: auto; scrollbar-width: thin; }
.rd .toc { top: 130px; }
.rd__pager { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: min(980px, calc(100% - 48px)); margin: 60px auto 0; }
.rd__pager a { display: grid; gap: 4px; padding: 20px 24px; text-decoration: none; background: var(--paper); box-shadow: 0 0 0 1px var(--line); transition: box-shadow .2s, transform .2s; }
.rd__pager a:hover { box-shadow: 0 0 0 1px var(--ink), 0 16px 26px -18px rgba(0, 0, 0, .4); transform: translateY(-2px); }
.rd__pager a[data-pager="next"], .rd__pager a:last-child:not([data-pager="prev"]) { text-align: right; }
.rd__pager small { font-size: 13px; color: var(--muted); }
.rd__pager b { font-family: var(--f-serif); font-size: 18px; }
.rd__cmt { margin-top: 70px; }
.w-reader .yhm-mark { background: rgba(154, 59, 42, .14); }

@container yh (max-width: 980px) {
  .bkp__head { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .bk--big { --w: 220px; --h: 312px; --d: 38px; }
}
@container yh (max-width: 760px) {
  .st__head { padding-top: 36px; }
  .st__head h1 { font-size: 60px; }
  .shelf3d { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 44px 14px; margin-top: 36px; }
  .bk { --w: 118px; --h: 168px; --d: 22px; }
  .shelf3d__info h2 { font-size: 18px; }
  .shelf3d__acts { flex-direction: column; align-items: center; }
  .bkp__head { padding-top: 36px; }
  .bkp__intro h1 { font-size: 36px; }
  .bkp__toc { padding: 34px 18px 40px; }
  .bkp__toc a { grid-template-columns: 2em minmax(0, 1fr) auto; }
  .bkp__toc a::after { display: none; }
  .bkp__len { grid-column: 3; }
  .rd__bar { top: 56px; }
  .rd__bar-in { width: calc(100% - 24px); gap: 10px; font-size: 13px; }
  .rd__pos { display: none; }
  .rd__head { margin-top: 36px; }
  .rd__head h1 { font-size: 28px; }
  .rd .ag { margin-top: 26px; }
  .rd__text { padding: 26px 18px 34px; font-size: calc(17.5px * var(--rd-fs, 1)); }
  .rd__pager { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .bk__in { transition: none; } .shelf3d__i { animation: none; } }
