/* Folio — PDF flip-view reader.
 * Loaded only on ?action=flipbook. Kept separate from style.css so the
 * cost of this page never touches the listing or any other screen. */

html, body.flip-body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #1b1b1e;
}

.flip-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    font-family: var(--sans);
}

.flip-back {
    color: var(--ink);
    text-decoration: none;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.flip-back:hover { color: var(--accent); }

.flip-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.flip-pageno {
    font-size: 0.78rem;
    color: var(--quiet);
    white-space: nowrap;
}

.flip-page-input {
    width: 3em;
    text-align: center;
    font-family: var(--sans);
    font-size: 0.78rem;
    padding: 0.15rem 0.3rem;
    border: 1px solid var(--rule);
    border-radius: 2px;
    background: var(--leaf);
    color: var(--ink);
}
.flip-page-input:focus { outline: none; border-color: var(--accent); }

.flip-download {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--quiet);
    text-decoration: none;
    border: 1px solid var(--rule);
    border-radius: 2px;
    padding: 0.18rem 0.6rem;
    white-space: nowrap;
}
.flip-download:hover { color: var(--accent); border-color: var(--accent); }

/* ---- Stage -------------------------------------------------------- */

.flip-stage {
    position: relative;
    height: calc(100vh - 3rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5vh 4vw;
    box-sizing: border-box;
    cursor: pointer;
}

.flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 2400px;
}

.flip-under,
.flip-leaf {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flip-under canvas,
.flip-leaf-face canvas {
    box-shadow: 0 1.5vh 4vh -1.5vh var(--gutter);
    background: var(--leaf);
    max-width: 100%;
    max-height: 100%;
}

.flip-leaf {
    transform: rotateY(0deg);
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.45, 0.05, 0.15, 1);
    will-change: transform;
}

.flip-leaf-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
}

/* A soft shadow that sweeps across the leaf while it is mid-turn, standing
   in for the light a real page would catch as it lifts. */
.flip-leaf-face::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to right,
        rgba(0, 0, 0, 0.22) 0%, transparent 14%,
        transparent 86%, rgba(0, 0, 0, 0.22) 100%);
    opacity: 0;
    transition: opacity 0.55s ease;
    pointer-events: none;
}
.flip-leaf.is-flipping-next .flip-leaf-face::after,
.flip-leaf.is-flipping-prev .flip-leaf-face::after {
    opacity: 1;
}

.flip-leaf.is-flipping-next {
    transform-origin: left center;
    transform: rotateY(-150deg);
}
.flip-leaf.is-flipping-prev {
    transform-origin: right center;
    transform: rotateY(150deg);
}

.flip-status {
    font-family: var(--sans);
    font-size: 0.85rem;
    color: #d8d6d0;
    background: transparent;
    text-align: center;
    max-width: 26rem;
    padding: 0 1rem;
}
.flip-status-error { color: #e58a8a; }

/* ---- Narrow screens ------------------------------------------------ */

@media (max-width: 560px) {
    .flip-topbar { padding: 0.5rem 0.75rem; gap: 0.6rem; }
    .flip-back { font-size: 0.78rem; }
    .flip-controls { gap: 0.35rem; }
    .flip-download { padding: 0.16rem 0.45rem; }
    .flip-stage { padding: 1.5vh 3vw; }
}

/* Respect the site-wide reduced-motion rule from style.css: it already
   collapses all transition-duration to ~0, which neutralises the flip
   transition here too. The JS layer also skips the animated path entirely
   under prefers-reduced-motion, so this is defense in depth, not the only
   guard. */
