:root {
    color-scheme: light;
    --background: #eae6da;
    --paper: #fbf8ef;
    --ink: #112c47;
    --muted: #52636a;
    --line: #ddd6c5;
    --serif: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif CJK JP", serif;
    --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: clip;
}
a { color: inherit; text-underline-offset: .25em; }
img { display: block; max-width: 100%; height: auto; }
figure, h1, h2, p { margin: 0; }
a:focus-visible { outline: 3px solid #885c34; outline-offset: 5px; }

.wrap {
    width: min(75rem, calc(100% - 5rem));
    margin-inline: auto;
}

.masthead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 5.5rem;
    gap: 1rem;
}
.brand { display: inline-flex; gap: .75rem; align-items: center; text-decoration: none; }
.brand img { border-radius: 23%; }
.brand span { display: grid; gap: .1rem; }
.brand b { font: 700 1.35rem var(--serif); letter-spacing: .12em; }
.brand small { font-size: .8rem; letter-spacing: .08em; color: var(--muted); }
.masthead nav { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; font-size: .9rem; }
.masthead nav a { text-decoration: none; padding-block: .45rem; }
.masthead nav a:hover { text-decoration: underline; }

.book {
    position: relative;
    display: flex;
    container: book / size;
    direction: rtl;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    border-radius: 9px 9px 12px 12px;
    box-shadow: 0 5px 0 -1px #ddd6c5, 0 11px 0 -3px #d8cfbb, 0 20px 42px #5042321c;
}
.book:focus-visible { outline: 3px solid #885c34; outline-offset: 4px; }
.leaf {
    flex: 0 0 100%;
    min-width: 0;
    direction: ltr;
    container-type: size;
    overflow: clip;
    scroll-snap-align: start;
    background: var(--paper);
    border: 1px solid #d6cebb;
    border-radius: inherit;
}
.spread {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "image cover";
}
.vertical { writing-mode: vertical-rl; text-orientation: mixed; line-break: strict; }
.vertical > :is(h1, h2, p) {
    box-sizing: content-box;
    inline-size: round(down, calc(100% - var(--text-inset, 0px)), 1em);
    padding-inline-start: var(--text-inset, 0px);
}
.cover {
    grid-area: cover;
    padding: min(2.85rem, 4cqh) clamp(1.1rem, 4vw, 4.5rem);
    display: grid;
    justify-items: center;
    align-content: safe center;
    gap: min(2rem, 3cqh);
}
.cover-text {
    height: min(28rem, 65cqh);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: clamp(.7rem, 2.4vw, 2.15rem);
    font-family: var(--serif);
}
.cover-type {
    --text-inset: .45rem;
    font: 600 .875rem var(--sans);
    letter-spacing: .14em;
    color: var(--muted);
}
.cover h1 {
    font-size: min(5.35vw, 9cqh, 4rem);
    font-weight: 700;
    line-height: 1.21;
    white-space: nowrap;
}
.cover-description {
    --text-inset: min(2rem, 4cqh);
    font-size: clamp(.875rem, min(1.45vw, 4.4cqh), 1.22rem);
    line-height: 1.9;
    color: #364b51;
}
.download {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 3.05rem;
    padding: .75rem 1.6rem;
    border-radius: .35rem;
    font-size: .95rem;
    font-weight: 650;
    color: #fffdf5;
    background: var(--ink);
    text-decoration: none;
}
.download:hover { background: #244961; }
.frontispiece {
    grid-area: image;
    display: grid;
    justify-items: center;
    align-content: safe center;
    gap: min(1.1rem, 3cqh);
    padding: min(2.5rem, 5cqh) 1rem;
    background: linear-gradient(90deg, #f0ece1, #f7f3e9 82%, #e4ddcd);
    border-right: 1px solid #d9d1be;
    border-radius: 7px 0 0 11px;
}
.frontispiece figcaption { color: var(--muted); font-size: .85rem; letter-spacing: .11em; }
.cover-capture-compact {
    display: none;
    width: min(100%, 22rem, 30cqh);
    overflow: hidden;
    border: 1px solid #ded7c8;
    border-radius: .7rem;
    background: #fff;
    box-shadow: .35rem .5rem 1rem #152f4320;
}
.screen {
    display: block;
    width: min(16.25rem, 32cqh);
}
.frontispiece .screen { filter: drop-shadow(0 .65rem 1.05rem #152f4333); }

.chapter {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(15rem, .7fr);
    grid-template-areas: "illustration text";
    align-content: safe center;
    align-items: center;
    gap: clamp(2rem, 6vw, 6rem);
    padding: min(6rem, 8cqh) clamp(1.5rem, 6.5vw, 6.5rem);
}
.chapter-text {
    grid-area: text;
    justify-self: center;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: clamp(1rem, 2.4vw, 2rem);
    inline-size: min(19rem, 62cqh);
    font-family: var(--serif);
}
.chapter h2 {
    font-size: min(3.7vw, 8cqh, 2.7rem);
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
}
.chapter p {
    --text-inset: .65rem;
    color: #334a51;
    font-family: "YuMincho", "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
    font-weight: 500;
    line-height: 1.85;
    font-size: clamp(.875rem, 3.1cqh, 1.06rem);
}
.chapter-visual {
    grid-area: illustration;
    display: grid;
    justify-items: center;
    align-items: center;
    justify-self: center;
    width: min(100%, 34rem);
    min-width: 0;
    padding: min(2.5rem, 4vw, 4cqh);
    border-radius: .4rem;
    box-shadow: .45rem .65rem 1.15rem #1d303620;
}
.chapter-visual > img { max-height: 68cqh; width: auto; }
.watch-visual { background: #e9eee8; max-width: 24rem; }
.watch-visual img { max-width: min(100%, 12rem); border-radius: 23%; }
.month-visual { background: #e8eef1; }
.month-compact { display: none; }
.month-visual img { border: 1px solid #c9d3d7; border-radius: .6rem; }
.epub-visual { background: #eee7d4; max-width: 21rem; }
.epub-visual .screen { width: min(100%, 13rem, 35cqh); }
.closing-actions {
    grid-area: illustration;
    display: grid;
    justify-items: center;
    gap: min(1.25rem, 4cqh);
    padding-block: min(1.25rem, 3cqh);
}
.closing img { border-radius: 23%; }
.support-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .65rem 1.25rem; font-size: .9rem; }
.page-turn {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: .5rem;
    min-height: 4.3rem;
    padding-top: .5rem;
}
.page-turn a {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    width: fit-content;
    min-height: 2.75rem;
    padding-inline: .15rem;
    font-size: .875rem;
    text-decoration: none;
}
.page-turn a[hidden] { display: none; }
.page-turn a:hover { text-decoration: underline; }
#next-page { grid-column: 1; grid-row: 1; font-weight: 650; }
#next-page::before {
    content: "←";
    font-size: 1.2em;
    line-height: 1;
}
#next-page:not(.has-turned) {
    animation: page-hint-pulse 1.35s ease-in-out 3s 3;
}
@keyframes page-hint-pulse {
    50% { opacity: .45; }
}
.page-hint-touch { display: none; }
#previous-page { grid-column: 3; grid-row: 1; justify-self: end; }
#page-title { grid-column: 2; grid-row: 1; color: var(--muted); font-size: .875rem; }

@media (max-width: 56rem) {
    .wrap { width: calc(100% - 2rem); }
    .cover { padding-inline: 1rem; }
    .screen { width: min(13rem, 32cqh); }
}

@media (max-width: 40rem) {
    .wrap { width: calc(100% - 1.5rem); }
    .masthead { min-height: 4.25rem; }
    .masthead nav { gap: .55rem; font-size: .83rem; }
    .brand { gap: .45rem; }
    .brand img { width: 2rem; }
    .brand b { font-size: 1.05rem; }
    .brand small { font-size: .68rem; }
    .spread { grid-template-columns: minmax(0, 1fr); grid-template-rows: 57% 43%; grid-template-areas: "cover" "image"; }
    .cover { padding: min(1.4rem, 3cqh) 1rem min(1rem, 2cqh); gap: min(.65rem, 1.5cqh); }
    .cover-text { height: min(16rem, 38cqh); gap: .85rem; }
    .cover h1 { font-size: min(8.6vw, 4.8cqh, 2.65rem); }
    .cover-description { --text-inset: min(.75rem, 2cqh); font-size: .875rem; line-height: 1.65; }
    .cover-type { font-size: .8rem; }
    .frontispiece {
        border-top: 1px solid var(--line);
        border-right: none;
        border-radius: 0 0 11px 11px;
        padding: min(1rem, 2cqh);
        gap: .5rem;
    }
    .chapter {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "text" "illustration";
        gap: min(1.25rem, 3cqh);
        padding: min(2.75rem, 7cqh) 1.25rem;
    }
    .chapter-text { inline-size: min(13.25rem, 34cqh); gap: .95rem; }
    .chapter h2 { font-size: min(7.5vw, 4.5cqh, 2rem); }
    .chapter p { font-size: .875rem; line-height: 1.55; }
    .watch-visual, .epub-visual { max-width: 17rem; }
    .chapter-visual > img { max-height: 39cqh; }
    .epub-visual .screen { width: min(100%, 11.5rem, 21cqh); }
    .page-turn { min-height: 3.7rem; }
    .page-turn a { gap: .35rem; font-size: .8rem; }
    #page-title { font-size: .8rem; }
}

@media (max-height: 43rem) {
    .masthead { min-height: 3.25rem; }
    .masthead .brand img { width: 2rem; }
    .page-turn { min-height: 3.2rem; padding-top: .25rem; }
}

@container book ((min-width: 21rem) and (max-width: 48rem) and (min-aspect-ratio: 7/10))
                or ((min-width: 40rem) and (max-height: 27rem)) {
    .spread {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
        grid-template-rows: minmax(0, 1fr);
        grid-template-areas: "image cover";
    }
    .cover { padding: 1rem .6rem; gap: min(1.25rem, 4cqh); }
    .cover-text {
        height: min(25rem, 57cqh);
        gap: clamp(.45rem, 1.35vw, .85rem);
    }
    .cover h1 { font-size: min(6.2vw, 7.9cqh, 3.55rem); }
    .cover-description { font-size: clamp(.875rem, 2vw, 1rem); line-height: 1.5; }
    .cover-type { font-size: .75rem; }
    .cover .download { padding-inline: 1rem; }
    .frontispiece {
        padding: 1rem .65rem;
        border-top: 0;
        border-right: 1px solid #d9d1be;
        border-radius: 7px 0 0 11px;
    }
    .frontispiece figcaption { font-size: .75rem; text-align: center; }
    .cover-capture-compact { width: min(100%, 22rem, 66cqh); }
    .chapter {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "illustration text";
        gap: clamp(.75rem, 3vw, 2rem);
        padding: min(2.5rem, 7cqh) clamp(.85rem, 3.5vw, 3rem);
    }
    .chapter-text {
        inline-size: min(22rem, 74cqh);
        gap: clamp(.55rem, 2vw, 1.2rem);
        justify-self: center;
    }
    .chapter h2 { font-size: min(5.25vw, 8.5cqh, 2.5rem); }
    .chapter p { font-size: clamp(.875rem, 2.2vw, 1rem); line-height: 1.55; }
    .chapter-visual { padding: min(1.1rem, 3cqh, 3vw); }
    .chapter-visual > img { max-height: 70cqh; }
    .month-wide { display: none; }
    .month-compact { display: block; }
    .epub-visual { max-width: 17rem; }
    .epub-visual .screen { width: min(100%, 12.75rem, 34cqh); }
    .support-links { gap: .65rem; font-size: .8rem; }
}

@media (max-width: 35rem), (max-width: 40rem) and (max-aspect-ratio: 5/8),
       (max-width: 50rem) and (max-height: 40rem), (max-height: 27rem) {
    .frontispiece .screen { display: none; }
    .cover-capture-compact { display: block; }
}

@container book (min-width: 21rem) and (max-width: 31rem) and (min-aspect-ratio: 7/10) {
    .spread { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
    .cover-text { height: min(25rem, 70cqh); }
    .cover h1 { font-size: min(6.2vw, 9.7cqh, 3.55rem); }
    .frontispiece {
        background: linear-gradient(90deg, #f0ece1, #f7f3e9 80%, #e4ddcd);
    }
    .frontispiece .screen { display: none; }
    .cover-capture-compact {
        display: block;
        width: min(100%, 22rem, 66cqh);
    }
}

@container book (max-width: 31rem) {
    .closing .download {
        padding-inline: .9rem;
        white-space: nowrap;
    }
}

@container book (max-width: 23rem) {
    .spread {
        --copy-top: clamp(min(1.8rem, 5.25cqh), calc((100cqh - 31rem) / 2), 4.5rem);
        --copy-height: min(49cqh, 15rem);
        --art-width: min(54cqw, 46cqh, 16rem);
        --action-bottom: min(1.8rem, 4cqh);
        grid-template: "overlap" minmax(0, 1fr) / minmax(0, 1fr);
        isolation: isolate;
    }
    .spread .frontispiece {
        grid-area: overlap;
        display: flex;
        flex-direction: column;
        align-items: start;
        justify-content: end;
        gap: .4rem;
        padding: 0 0 calc(var(--action-bottom) + 3.3rem) min(1.2rem, 5cqw);
        border: 0;
        border-radius: inherit;
    }
    .spread .screen { display: none; }
    .spread .cover-capture-compact {
        display: block;
        width: var(--art-width);
    }
    .spread figcaption {
        width: var(--art-width);
        font-size: .75rem;
        text-align: center;
    }
    .spread .cover {
        position: relative;
        z-index: 1;
        grid-area: overlap;
        display: block;
        padding: 0;
        pointer-events: none;
    }
    .cover-text,
    .chapter-text {
        position: absolute;
        top: min(1.8rem, 5.25cqh);
        right: min(.95rem, 3.75cqw);
        z-index: 1;
        gap: clamp(.4rem, 2cqw, .75rem);
        padding: .5rem .45rem;
        text-shadow:
            -1px 0 1px var(--paper), 1px 0 1px var(--paper),
            0 -1px 1px var(--paper), 0 1px 1px var(--paper),
            0 0 5px var(--paper), 2px 3px 5px #31425770;
    }
    .cover-text {
        top: var(--copy-top);
        height: var(--copy-height);
        pointer-events: auto;
    }
    .cover h1 { font-size: min(8cqw, 5.45cqh, 2rem); }
    .cover-description { --text-inset: .35rem; line-height: 1.45; }
    .cover .download {
        position: absolute;
        bottom: var(--action-bottom);
        right: min(.95rem, 3.75cqw);
        min-height: 2.65rem;
        padding: .55rem .95rem;
        font-size: .875rem;
        pointer-events: auto;
    }
    .chapter {
        --copy-top: clamp(min(1.8rem, 5.25cqh), calc((100cqh - 30rem) / 2), 5.5rem);
        --copy-height: min(16rem, 52cqh);
        position: relative;
        isolation: isolate;
        display: block;
        padding: 0;
    }
    .chapter-text { top: var(--copy-top); inline-size: var(--copy-height); }
    .chapter h2 { font-size: min(7.3cqw, 5.8cqh, 1.85rem); }
    #record .chapter-text p { max-inline-size: 12em; }
    .chapter-visual {
        position: absolute;
        top: calc(var(--copy-top) + var(--copy-height) - min(2rem, 7cqh));
        left: min(.8rem, 3.5cqw);
        width: min(73cqw, 17rem);
        padding: min(.9rem, 2.5cqh);
    }
    .chapter-visual > img { max-height: min(12.5rem, 43cqh); }
    .month-wide { display: none; }
    .month-compact { display: block; }
    .epub-visual {
        top: calc(var(--copy-top) + var(--copy-height) - min(3.7rem, 12cqh));
        width: min(62cqw, 13.5rem);
    }
    .epub-visual .screen { width: min(100%, 11.75rem, 23cqh); }
    .closing-actions {
        position: absolute;
        top: 50%;
        left: min(.8rem, 3.5cqw);
        width: min(73cqw, 17rem);
        transform: translateY(-50%);
    }
    .closing-actions .support-links {
        position: absolute;
        top: 100%;
        inset-inline: 0;
    }
}

@media (pointer: coarse) {
    #next-page::before { content: "→"; }
    .page-hint-wide { display: none; }
    .page-hint-touch { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
    .book { scroll-behavior: auto; }
    #next-page:not(.has-turned) { animation: none; }
}
