/* <yafta-flipbook> — PDF page-flip viewer used on single Branding Book pages */

yafta-flipbook.yf-host {
    display: block;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    direction: ltr;
}

.yf-stage {
    position: relative;
    width: 100%;
}

/* --- loading / error states --- */
.yf-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 380px;
    padding: 32px 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.65);
    font-size: 14px;
    text-align: center;
}

.yf-state--error {
    color: rgba(255, 255, 255, 0.7);
}

.yf-fallback-link {
    color: #ff5c1a;
    text-decoration: underline;
    font-weight: 600;
}

.yf-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #ff5c1a;
    animation: yf-spin 0.8s linear infinite;
}

@keyframes yf-spin {
    to { transform: rotate(360deg); }
}

/* --- the book --- */
.yf-book {
    margin: 0 auto;
    opacity: 0;
    transition: opacity 0.45s ease, transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Closed book: the cover sits on the right half of the spread, so pull it
   back by half a page to centre it. Released on the first flip. */
.yf-book.yf-book--closed {
    transform: translateX(-25%) translateZ(0);
}

.yf-host--ready .yf-book {
    opacity: 1;
}

.yf-page {
    background: #ffffff;
    overflow: hidden;
}

.yf-page__inner {
    position: relative;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.08);
}

.yf-page__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.yf-page__placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.12);
    border-top-color: rgba(0, 0, 0, 0.35);
    animation: yf-spin 0.8s linear infinite;
}

/* --- controls --- */
.yf-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(8px);
    width: fit-content;
    margin-inline: auto;
}

.yf-controls__spacer {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0 2px;
}

.yf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.25s ease, transform 0.2s ease, opacity 0.2s ease;
}

.yf-btn svg {
    width: 18px;
    height: 18px;
}

.yf-btn:hover:not(:disabled) {
    background: #ff5c1a;
    transform: scale(1.08);
}

.yf-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.yf-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.yf-btn--ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
}

.yf-counter {
    min-width: 66px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.75);
    font-variant-numeric: tabular-nums;
}

/* --- light theme --- */
html:not(.dark) .yf-state,
html:not(.dark) .yf-controls {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    color: rgba(0, 0, 0, 0.6);
}

html:not(.dark) .yf-btn {
    color: #111;
    background: rgba(0, 0, 0, 0.06);
}

html:not(.dark) .yf-btn:hover:not(:disabled) {
    color: #fff;
}

html:not(.dark) .yf-btn--ghost {
    background: transparent;
    color: rgba(0, 0, 0, 0.5);
}

html:not(.dark) .yf-counter {
    color: rgba(0, 0, 0, 0.7);
}

html:not(.dark) .yf-controls__spacer {
    background: rgba(0, 0, 0, 0.12);
}

/* --- fullscreen --- */
yafta-flipbook.yf-host--fullscreen {
    max-width: none;
    width: 100vw;
    height: 100vh;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0b0b0b;
}

/* max-width is set inline by _fit() so the book + controls fit the viewport height */
yafta-flipbook.yf-host--fullscreen .yf-stage {
    width: 100%;
    margin: 0 auto;
}
