/* 2026-11 book pass: chapters, contents, the corner tab, per-chapter paper, pause motion.
   Loaded after rhythm.css. Older rules counted cards with :nth-child; a chapter divider now comes
   first, so the opening drawings are marked .is-lead and sized here instead. */

/* Card widths by role rather than position. */
.gallery-grid .gallery-piece:not(.is-lead):not(.is-spread){grid-column:span 2}
@media(max-width:900px){.gallery-grid .gallery-piece:not(.is-lead):not(.is-spread){grid-column:span 3}}
@media(min-width:1001px){.gallery-grid .gallery-piece:not(.is-lead):not(.is-spread){grid-column:span 4}}
.gallery-grid .gallery-piece.is-lead{grid-column:span 3}
@media(max-width:600px){.gallery-grid .gallery-piece.is-lead{grid-column:span 6}}
@media(min-width:1001px){.gallery-grid .gallery-piece.is-lead{grid-column:span 5}.gallery-grid .gallery-chapter+.gallery-piece.is-lead{grid-column:span 7}}
.gallery-grid .gallery-piece.is-lead .gallery-art img{aspect-ratio:1.16!important;object-fit:contain}
@media(max-width:600px){.gallery-grid .gallery-piece.is-lead .gallery-art img{aspect-ratio:1.2!important}}
@media(min-width:1001px){.gallery-grid .gallery-piece.is-lead+.gallery-piece.is-lead .gallery-art img{aspect-ratio:1!important}}
@media(max-width:700px){
 .gallery-grid .gallery-piece:not(.is-lead) .gallery-caption h2{font-size:18px}
 .gallery-grid .gallery-piece:not(.is-lead) .gallery-caption p{font-size:14px}
 .gallery-grid .gallery-piece.is-lead .gallery-caption h2{font-size:21px}
 .gallery-grid .gallery-piece.is-lead .gallery-caption p{font-size:15px}
}
/* The four dark tales sit in one row on desktop, two by two below that. */
.gallery-grid .gallery-piece.is-tale{grid-column:span 3!important}

/* Chapter dividers: a pencil rule, the chapter, one line. The dark tale keeps its black card. */
.gallery-grid .gallery-chapter{scroll-margin-top:20px}
.gallery-grid .gallery-chapter:focus{outline:none}
.gallery-grid .gallery-chapter:focus-visible{outline:2px solid var(--gallery-red);outline-offset:6px}
.gallery-chapter.is-light{display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:30px;align-items:baseline;margin:34px 0 0;padding:30px 0 20px;text-align:left;color:var(--gallery-ink);background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='8' preserveAspectRatio='none'%3E%3Cpath d='M1 5 C 80 2, 160 6, 240 4 S 420 2, 520 5 S 580 4, 599 3' fill='none' stroke='%23b9a593' stroke-width='1.2' stroke-linecap='round' opacity='.8'/%3E%3C/svg%3E") top left/100% 8px no-repeat;box-shadow:none;transform:none;border-radius:0}
.gallery-grid>.gallery-chapter.is-light:first-child{margin-top:0}
.gallery-chapter.is-light:before{display:none}
.gallery-chapter.is-light small{grid-column:1/-1;font-family:inherit;font-size:12px;line-height:1.8;letter-spacing:2px;color:#7d5660;margin-bottom:6px}
.gallery-chapter.is-light h2{font-size:34px;letter-spacing:6px;text-indent:0;margin:0}
.gallery-chapter.is-light p{font-size:14px;color:#6b5b52}
@media(max-width:700px){
 .gallery-chapter.is-light{grid-template-columns:1fr;margin-top:22px;padding:24px 0 12px}
 .gallery-chapter.is-light h2{font-size:27px;letter-spacing:4px}
 .gallery-chapter.is-light p{margin-top:6px}
}

/* Each chapter tints the paper a little; the change is slow so it reads as turning a page. */
body{transition:background-color .9s ease}
body[data-chapter="画自己"]{background-color:#f9f1ec}
body[data-chapter="随手涂鸦"]{background-color:#f6f4ed}
body[data-chapter="窗外风景"]{background-color:#eff2ea}
body[data-chapter="黑童话"]{background-color:#ece5df}

/* Toolbar entry to the contents. */
.contents-open{min-height:44px;padding:8px 2px;border:0;background:none;font:inherit;font-size:13px;color:#8e4755;white-space:nowrap;cursor:pointer}
.contents-open>span{margin-right:3px}
@media(hover:hover) and (pointer:fine){.contents-open:hover{color:#713748;text-decoration:underline;text-underline-offset:5px}}
@media(max-width:700px){.contents-open{font-size:14px}}

/* Corner tab: where you are in the book; it opens the contents. */
.chapter-tab{position:fixed;z-index:30;left:max(16px,env(safe-area-inset-left));bottom:max(16px,env(safe-area-inset-bottom));display:flex;align-items:center;gap:10px;min-height:40px;padding:7px 14px;border:1px solid #dccfbf;border-radius:20px;background:#fffaf2e8;box-shadow:0 6px 18px #5f4a3514;font:inherit;font-size:12px;letter-spacing:.5px;color:#5d4a44;white-space:nowrap;cursor:pointer}
.chapter-tab-page{font-variant-numeric:tabular-nums;letter-spacing:1px;color:#7d3a48}
.chapter-tab-open{padding-left:10px;border-left:1px solid #dccfbf;color:#8e4755}
@media(hover:hover) and (pointer:fine){.chapter-tab:hover{border-color:#b58a88}}
@media(max-width:700px){.chapter-tab{left:50%;transform:translateX(-50%);bottom:max(12px,env(safe-area-inset-bottom));gap:8px;padding:6px 12px}}
body.has-dialog .chapter-tab,body:has(dialog[open]) .chapter-tab{display:none}

/* Contents sheet. */
.contents-sheet{width:min(520px,calc(100vw - 32px));max-height:min(82dvh,660px);padding:24px 26px 16px;border:1px solid #d8c9b9;border-radius:4px;background:#fffaf2;color:#493e39;box-shadow:0 30px 80px #3b2a2433}
.contents-sheet::backdrop{background:#3b2a2447}
.contents-head{display:flex;align-items:center;justify-content:space-between;padding-bottom:10px;border-bottom:1px solid #e2d6c7}
.contents-head h2{margin:0;font:400 28px/1.4 JournalSerif,'Songti SC',serif;letter-spacing:8px}
.contents-head button{min-height:44px;padding:0 4px;border:0;background:none;font:inherit;font-size:13px;color:#8e4755;cursor:pointer}
.contents-list{margin:0;padding:0;list-style:none}
.contents-list button{display:flex;align-items:center;gap:16px;width:100%;padding:13px 4px;border:0;border-bottom:1px dashed #e2d6c7;background:none;font:inherit;color:inherit;text-align:left;cursor:pointer}
.contents-list li:last-child button{border-bottom:0}
.contents-list img{flex:none;width:56px;height:56px;padding:3px;object-fit:cover;background:#fff;border:1px solid #e2d8c9;transform:rotate(-2deg)}
.contents-list li:nth-child(even) img{transform:rotate(2deg)}
.contents-text{flex:1;min-width:0}
.contents-line{display:flex;align-items:baseline;gap:8px}
.contents-line strong{font-size:16px;font-weight:400;letter-spacing:1px;white-space:nowrap}
.contents-dots{flex:1;min-width:12px;border-bottom:1px dotted #bfae9c;transform:translateY(-4px)}
.contents-pages{font-size:12px;font-variant-numeric:tabular-nums;color:#7d3a48;white-space:nowrap}
.contents-text small{display:block;margin-top:4px;font-size:12px;line-height:1.7;color:#6b5b52}
@media(hover:hover) and (pointer:fine){.contents-list button:hover strong{color:#7d3a48}}
.contents-foot{margin:10px 0 0;font-size:11px;letter-spacing:1px;color:#8a776c;text-align:center}
@media(max-width:420px){.contents-sheet{padding:18px 16px 12px}.contents-list button{gap:12px}.contents-list img{width:46px;height:46px}.contents-line strong{font-size:15px}}

/* Viewer: copy the link to the drawing that is open. */
.viewer-share{display:inline-flex;align-items:center;min-height:36px;margin-top:6px;padding:4px 0;border:0;background:none;font:inherit;font-size:12px;color:#8e4755;text-decoration:underline;text-decoration-color:#cfada5;text-underline-offset:5px;cursor:pointer}

/* Pause motion (footer display settings). Static tilt stays; everything that moves stops. */
html.feiqi-still *,html.feiqi-still *:before,html.feiqi-still *:after{animation-duration:.001s!important;animation-iteration-count:1!important;transition-duration:.001s!important;scroll-behavior:auto!important}
html.feiqi-still .gallery-piece:not(.is-lead) .gallery-art:hover{transform:rotate(var(--tilt,0deg));box-shadow:none}
html.feiqi-still .gallery-art:hover img{transform:none}

@media(forced-colors:active),(prefers-contrast:more){
 .chapter-tab,.contents-sheet{background:Canvas;color:CanvasText;border-color:CanvasText;box-shadow:none}
 .chapter-tab-page,.chapter-tab-open,.contents-pages{color:CanvasText}
 .gallery-chapter.is-light{background:none;border-top:1px solid CanvasText}
}
