body { background: #eeece6; }
main { padding-top: clamp(14px, 4vh, 40px); }
[hidden] { display: none !important; }
#reader { position: relative; perspective: 1400px; }
.book { width: min(94vw, calc((100svh - 115px) * 1.515)); }
.closed { width: min(88vw, calc((100svh - 115px) * .758)); }
.coverimg { object-fit: contain; }
.intro { padding: 5%; gap: .5rem; }
.intro img { display: block; width: 12%; height: auto; flex: none; aspect-ratio: 446 / 448; object-fit: contain; }
.lagoon .photo { object-fit: contain; }
.book:not(.closed)::after { width: 1.2%; background: linear-gradient(90deg, transparent, rgb(0 0 0 / 6%), transparent); }
.dedication { width: min(100%, 26ch); }
.dedication h1 { font-size: clamp(.75rem, 1.1vw, 1rem); margin: 0 0 .55em; }
.dedication p { font-size: clamp(.625rem, .82vw, .75rem); line-height: 1.45; margin: .65em 0; }
nav { gap: 12px; }
nav button {
    font: 1.4rem/1 Georgia, serif;
    color: #284a50;
    background: #faf9f5;
    border: 1px solid #a9b8b8;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
}
nav button:hover:not(:disabled) { background: #d0dedf; }
nav button:disabled { opacity: .35; cursor: default; }
:focus-visible { outline: 2px solid #467582; outline-offset: 3px; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.turning-leaf { position: absolute; z-index: 2; will-change: transform; transform-style: preserve-3d; pointer-events: none; }
.leaf-face { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; background: #faf9f5; }
.stationary-page { position: absolute; z-index: 1; pointer-events: none; }
.leaf-face.reverse { transform: rotateY(180deg); }
.leaf-face .book { max-width: none; margin: 0; box-shadow: none; }
.leaf-face::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, rgb(0 0 0 / 7%), transparent 35%, rgb(0 0 0 / 3%));
}
@media (max-width: 650px), (max-height: 500px) {
    #p1 .book, .leaf-face .intro-layout { display: block; aspect-ratio: auto; }
    .intro, .lagoon { width: 100%; height: auto; }
    .dedication { width: min(100%, 42ch); }
    .dedication p { font-size: .75rem; }
    .intro img { max-width: 55px; }
    .lagoon .photo { max-height: 48svh; }
    #p1 .book::after, .leaf-face .intro-layout::after { display: none; }
}
/* Viewport-sized presentation, with clean uninterrupted photographic spreads. */
html, body { width:100%;height:100%;overflow:hidden; }
body { background:#e8e7e3; }
main { height:100svh;height:100dvh;padding:12px 12px 0;display:flex;flex-direction:column; }
#reader { flex:1;min-height:0;display:grid;place-items:center;perspective:2200px;touch-action:pan-y; }
.spread { width:100%; }
.book { width:min(calc(100vw - 24px),calc((100dvh - 78px)*1.5151515));aspect-ratio:50/33;box-shadow:0 10px 35px #00000015; }
.book.closed { width:min(calc((100vw - 24px)/2),calc((100dvh - 78px)*.7575758));aspect-ratio:25/33; }
.book:not(.closed)::after { display:none; }
.intro { padding:8%;gap:1.1rem; }
.intro img { width:20%;max-width:100px;mix-blend-mode:normal; }
.dedication { width:100%;max-width:32ch; }
.dedication h1 { font-size:clamp(.8rem,1.5vw,1.5rem);font-weight:normal; }
.dedication p { font-size:clamp(.5rem,1.05vw,1rem);line-height:1.65; }
nav { flex:none;height:54px;margin:0;gap:18px; }
nav button { background:transparent;border:0;width:44px;height:44px; }
.turning-leaf { backface-visibility:visible; }
.leaf-face::after { background:linear-gradient(90deg,#00000004,transparent 30%); }
@media (max-width:650px),(max-height:500px) {
 #p1 .book,.leaf-face .intro-layout { display:flex;aspect-ratio:50/33; }
 .intro,.lagoon { width:50%;height:100%; }
 .intro { padding:5%;gap:.25rem; }
 .intro img { width:22%;max-width:65px; }
 .dedication { max-width:32ch; }
 .dedication h1 { font-size:clamp(.55rem,2vw,1rem);margin-bottom:.4em; }
 .dedication p { font-size:clamp(.4rem,1.45vw,.75rem);line-height:1.45;margin:.5em 0; }
 .lagoon .photo { max-height:none; }
}
.intro img { mix-blend-mode:multiply; }
/* Give phones the largest complete book that fits the available screen. */
@media (hover:none) and (pointer:coarse), (max-width:650px) {
 main { padding:0; }
 .book { width:min(100vw,calc((100dvh - 44px)*1.5151515)); }
 .book.closed { width:min(100vw,calc((100dvh - 44px)*.7575758)); }
 nav { height:44px; }
}
@media (hover:none) and (pointer:coarse) and (orientation:landscape) {
 .book { width:min(100vw,calc(100dvh*1.5151515)); }
 .book.closed { width:min(100vw,calc(100dvh*.7575758)); }
 nav { position:absolute;bottom:env(safe-area-inset-bottom,0px);left:0;right:0;z-index:4;pointer-events:none;justify-content:space-between;padding:0 max(8px,env(safe-area-inset-left,0px)); }
 nav button { pointer-events:auto;background:#faf9f5cc; }
}
body { background:#fff; }
@media (hover:none) and (pointer:coarse), (max-width:650px) {
 main { padding:6px; }
 .book { width:min(calc(100vw - 12px),calc((100dvh - 56px)*1.5151515)); }
 .book.closed { width:min(calc(100vw - 12px),calc((100dvh - 56px)*.7575758)); }
}
@media (hover:none) and (pointer:coarse) and (orientation:landscape) {
 .book { width:min(calc(100vw - 12px),calc((100dvh - 12px)*1.5151515)); }
 .book.closed { width:min(calc(100vw - 12px),calc((100dvh - 12px)*.7575758)); }
}

/* Keep both introductions on the facing page, with room for the emblem. */
.intro { padding: 3.5% 4%; gap: .45rem; container-type: inline-size; }
.intro img { width: 12%; max-width: 50px; }
.dedication { max-width: 44ch; min-height: 0; overflow: auto; }
.dedication h1, .dedication h2 {
    margin: 0 0 .35em;
    color: #46747e;
    font-size: clamp(.625rem, 4.5cqi, .95rem);
    font-weight: normal;
}
.dedication p {
    margin: .32em 0;
    font-size: clamp(.5rem, 3.3cqi, .76rem);
    line-height: 1.3;
}
.dedication .translation { margin-top: .65em; font-style: italic; }

.back-credit {
    align-self: end;
    margin: 0 8% 10%;
    color: #fff;
    font: clamp(.65rem, 2.6vmin, .875rem)/1.3 Georgia, serif;
    text-align: center;
}

.pagination {
    min-width: 3.5rem;
    color: #596668;
    font: .75rem/1 Georgia, serif;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
    .pagination:not(:empty) {
        align-self: center;
        padding: .35rem .5rem;
        background: #faf9f5ed;
        border-radius: .25rem;
    }
}

.photo-lightened { filter: brightness(1.08); }

.pdf-placed-photo {
    position: absolute;
    display: block;
    object-fit: contain;
}

.pdf-intro {
    position: absolute;
    inset: 0 auto 0 0;
    width: 50%;
    height: 100%;
}

.pdf-intro img { mix-blend-mode: multiply; }

#reader { touch-action: pan-y pinch-zoom; }
.reader-options {
    position: absolute;
    z-index: 5;
    right: max(10px, env(safe-area-inset-right));
    top: max(8px, env(safe-area-inset-top));
    display: flex;
    gap: .25rem;
}
.reader-options button, #close-intro {
    border: 0;
    border-radius: .3rem;
    min-width: 44px;
    min-height: 44px;
    background: #faf9f5ed;
    color: #284a50;
    font: .95rem Georgia, serif;
    cursor: pointer;
}
.reader-options button[aria-pressed="true"] { background: #d0dedf; }
#intro-dialog {
    max-width: min(calc(100% - 1rem), 42rem);
    max-height: calc(100% - 1rem);
    border: 0;
    padding: 1rem 1.25rem 2rem;
    background: #faf9f5;
    color: #37484b;
    touch-action: pan-y pinch-zoom;
    text-align: center;
}
#intro-dialog::backdrop { background: #17282b99; }
#close-intro { display: block; margin-left: auto; }
#intro-dialog .dedication { max-width: none; overflow: visible; font-family: Georgia, serif; }
#intro-dialog .dedication h1, #intro-dialog .dedication h2 { font-size: 1.25rem; }
#intro-dialog .dedication p { margin: .65em 0; font-size: 1rem; line-height: 1.45; }
#screen-status:not(:empty) {
    position: fixed;
    bottom: 3.25rem;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 90%;
    padding: .5rem;
    background: #faf9f5;
    z-index: 6;
}
#reader.single-page .spread { overflow: clip; }
#reader.single-page .single-leaf .book:not(.closed) {
    width: calc(2 * min(calc(100vw - 12px), calc((100dvh - 56px) * .7575758)));
    margin: 0;
    left: 50%;
    transform: translateX(-25%);
    clip-path: inset(0 50% 0 0);
}
#reader.single-page.right-page .single-leaf .book:not(.closed) {
    transform: translateX(-75%);
    clip-path: inset(0 0 0 50%);
}
#reader.single-page .intro-book { aspect-ratio: 50/33; height: auto; }
#reader.single-page .pdf-intro { width: 50%; }
#reader.single-page .intro-book .pdf-placed-photo {
    left: 50% !important;
    top: 2% !important;
    width: 50% !important;
    height: 96% !important;
}
#reader.single-page .intro-book .dedication { display: block; }
main:fullscreen { background: #fff; }
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
    main:not(.show-controls) nav, main:not(.show-controls) .reader-options {
        opacity: 0;
        pointer-events: none;
    }
    main:not(.show-controls) nav button { pointer-events: none; }
}

/* Scale the typeset spread as a book page at every viewport size. */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
.intro-book .pdf-intro { padding: 3.5% 4%; gap: min(.45rem, 1vw); }
.intro-book .dedication { overflow: visible; }
.intro-book .dedication h1,
.intro-book .dedication h2 { font-size: min(.95rem, 4.1cqi); }
.intro-book .dedication p {
    font-size: min(.76rem, 2.9cqi);
    line-height: 1.27;
}
@media (max-width: 650px) and (orientation: portrait) {
    .reader-options { top: auto; bottom: 44px; right: 8px; }
}

.reader-toolbar { flex: none; }
.pdf-placed-photo { cursor: zoom-in; }
.pdf-intro { cursor: zoom-in; }
.zoom-controls {
    display: flex;
    justify-content: flex-end;
    gap: .25rem;
    background: #faf9f5;
}
.zoom-controls button {
    border: 0;
    min-width: 44px;
    min-height: 44px;
    color: #284a50;
    background: #faf9f5;
    font: 1.3rem Georgia, serif;
    cursor: pointer;
}
#intro-dialog .zoom-controls { position: sticky; top: -1rem; }
#intro-dialog #close-intro { margin-left: 0; }
#intro-dialog .dedication p { font-size: var(--reading-size, 1rem); }
#photo-dialog {
    width: min(96vw, 90rem);
    height: 94dvh;
    max-width: none;
    max-height: none;
    border: 0;
    padding: 0;
    background: #111;
}
#photo-dialog::backdrop { background: #111e; }
#photo-dialog[open] { display: flex; flex-direction: column; }
#photo-stage {
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: safe center;
    overflow: auto;
    touch-action: pan-x pan-y pinch-zoom;
}
#zoom-photo { display: block; max-width: none; max-height: none; }
@media (pointer: coarse), (max-width: 650px) {
    .reader-toolbar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 44px;
        gap: .25rem;
    }
    .reader-toolbar nav, .reader-toolbar .reader-options {
        position: static;
        opacity: 1 !important;
        pointer-events: auto !important;
        gap: 0;
    }
    .reader-toolbar nav button { pointer-events: auto !important; }
    .reader-toolbar button { flex-shrink: 0; }
    .reader-toolbar .pagination { min-width: 2.7rem; }
    #reader .book { width: min(calc(100vw - 12px), calc((100dvh - 56px) * 1.5151515)); }
    #reader .book.closed { width: min(calc(100vw - 12px), calc((100dvh - 56px) * .7575758)); }
    #reader.single-page .single-leaf .book:not(.closed) {
        width: calc(2 * min(calc(100vw - 12px), calc((100dvh - 56px) * .7575758)));
    }
}
