/**
 * Look Inside Sample Reader styles for single-books.php (Option b: Local Canvas Reader)
 */

/* --- Trigger Button inside Book Card --- */
.book-look-inside {
    width: 100%;
    max-width: 300px;
    padding: 0;
    margin: 0;
    text-align: center;
}

.book-look-inside--standalone {
    max-width: 280px;
    margin: 0 0 1.5rem;
    padding: 0;
    text-align: left;
}

.book-card-actions .book-look-inside {
    width: auto;
    max-width: none;
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
}

.book-look-inside-title {
    font-size: 1.2rem;
    margin: 0 0 0.9rem;
    font-weight: 600;
    color: var(--lb-color-text-main);
}

.book-card-actions .book-look-inside-title {
    font-size: 0.78rem;
    line-height: 1.15;
    letter-spacing: 0.01em;
    margin: 0 0 0.35rem;
    color: var(--lb-color-text-muted);
}

.look-inside-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.book-look-inside--standalone .look-inside-buttons {
    justify-content: flex-start;
}

.look-inside-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--lb-color-border-default);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--lb-color-bg-muted);
    color: var(--lb-color-text-muted);
    position: relative;
    cursor: pointer;
    z-index: 1;
    transition: transform 0.2s ease, background 0.25s ease, color 0.25s ease, z-index 0s linear 0.25s;
}

.look-inside-btn:hover {
    transform: scale(1.1);
    background: var(--lb-color-parchment-card);
    color: var(--lb-color-secondary-green, var(--lb-color-primary, #23633d));
    z-index: 20;
    transition: transform 0.2s ease, background 0.25s ease, color 0.25s ease, z-index 0s linear 0s;
}

.look-inside-btn:focus-visible {
    outline: 3px solid var(--lb-color-accent, #2e7d4f);
    outline-offset: 2px;
}

.look-inside-btn__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: currentColor;
    transition: color 0.25s ease;
}

/* Tooltip bubble (matches .buy-btn[data-tooltip]) */
.look-inside-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--global-palette-btn-bg, var(--lb-color-primary));
    color: var(--global-palette-btn, var(--lb-color-text-inverse));
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--lb-radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: var(--lb-shadow-sm);
    z-index: 30;
}

.look-inside-btn[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--lb-color-text-main) transparent transparent transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 25;
}

.look-inside-btn:hover::after,
.look-inside-btn:hover::before {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* --- Body Scroll Lock --- */
html.lb-look-inside-open,
body.lb-look-inside-open {
    overflow: hidden;
}

/* --- Distraction-Free Modal Overlay (above #leitrim-appearance-wrapper z-index: 99999) --- */
.lb-look-inside-modal[hidden] {
    display: none !important;
}

.lb-look-inside-modal {
    position: fixed;
    inset: 0;
    z-index: 100050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 18px;
    box-sizing: border-box;
    font-family: var(--lb-font-sans, system-ui, -apple-system, sans-serif);
}

.lb-look-inside-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 21, 16, 0.92);
    backdrop-filter: blur(6px);
}

.lb-look-inside-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1120px;
    height: 100%;
    max-height: 100%;
    background: #17201b;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.lb-look-inside-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    min-height: 54px;
    padding: 0.55rem 1rem;
    background: #131f18;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #f4f1ea;
    flex-shrink: 0;
}

.lb-look-inside-meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1 1 auto;
}

.lb-look-inside-brand-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #8ec9a3;
}

.lb-look-inside-heading-group {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
    min-width: 0;
}

.lb-look-inside-title {
    margin: 0;
    padding: 0;
    font-family: var(--lb-font-serif, Georgia, serif);
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.25;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 34vw;
}

.lb-look-inside-author {
    font-size: 0.85rem;
    color: #c8d2cc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-look-inside-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
    min-width: 0;
}

.lb-look-inside-bookmarks {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.lb-look-inside-bookmarks::-webkit-scrollbar {
    display: none;
}

.lb-look-inside-bookmarks[hidden] {
    display: none;
}

.lb-bookmark-btn {
    padding: 0.35rem 0.68rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #dce4df;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.lb-bookmark-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.34);
    color: #ffffff;
}

.lb-bookmark-btn.is-active {
    background: rgba(142, 201, 163, 0.22);
    border-color: rgba(142, 201, 163, 0.55);
    color: #ffffff;
}

.lb-bookmark-btn:focus-visible {
    outline: 2px solid #8ec9a3;
    outline-offset: 2px;
}

.lb-look-inside-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.42rem 0.85rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: #23633d;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.lb-look-inside-close:hover {
    background: #2e7d4f;
    border-color: rgba(255, 255, 255, 0.48);
}

.lb-look-inside-close:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* --- Reader Viewport Stage --- */
.lb-look-inside-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: #1a231e;
    padding: 22px 18px 44px;
    user-select: none;
    -webkit-user-select: none;
}

.lb-look-inside-stage:focus {
    outline: none;
}

.lb-reader-pages {
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

/* --- Page Canvas Container --- */
.lb-reader-page {
    position: relative;
    width: 100%;
    background: #ffffff;
    border-radius: 3px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.42);
    overflow: hidden;
}

.lb-reader-canvas {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.lb-reader-page-shield {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
}

.lb-reader-page-loader {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f7f3;
}

.lb-reader-page[data-status="loaded"] .lb-reader-page-loader,
.lb-reader-page[data-status="error"] .lb-reader-page-loader {
    display: none;
}

.lb-look-inside-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(35, 99, 61, 0.18);
    border-top-color: #23633d;
    border-radius: 50%;
    animation: lb-look-inside-spin 0.8s linear infinite;
}

.lb-reader-page-error {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1rem;
    text-align: center;
    background: #f6f4ee;
    color: #2b3530;
    font-size: 0.9rem;
}

.lb-reader-page[data-status="error"] .lb-reader-page-error {
    display: flex;
}

.lb-reader-retry-btn {
    padding: 0.42rem 0.9rem;
    border-radius: 6px;
    border: 1px solid #23633d;
    background: #23633d;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

/* --- Sample Gap Notices ("This is a sample..." / "Pages X - Y are not included...") --- */
.lb-reader-notice {
    width: 100%;
    max-width: 600px;
    padding: 0.72rem 1.15rem;
    box-sizing: border-box;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #d7e1db;
    font-size: 0.86rem;
    line-height: 1.4;
    text-align: center;
}

.lb-reader-notice--pages-missing {
    background: rgba(142, 201, 163, 0.1);
    border-color: rgba(142, 201, 163, 0.28);
    color: #eef5f0;
    font-weight: 500;
}

/* --- End-of-Sample Closing Action --- */
.lb-reader-end {
    margin-top: 0.35rem;
    text-align: center;
}

.lb-reader-end-btn {
    padding: 0.55rem 1.25rem;
    border-radius: var(--lb-radius-pill, 9999px);
    border: 1px solid rgba(255, 255, 255, 0.26);
    background: rgba(255, 255, 255, 0.08);
    color: #f4f1ea;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.lb-reader-end-btn:hover {
    background: #23633d;
    border-color: #8ec9a3;
    color: #ffffff;
}

.lb-reader-end-btn:focus-visible {
    outline: 2px solid #8ec9a3;
    outline-offset: 2px;
}

@keyframes lb-look-inside-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .lb-look-inside-modal {
        padding: 0;
    }

    .lb-look-inside-dialog {
        border-radius: 0;
        border: 0;
    }

    .lb-look-inside-header {
        flex-wrap: wrap;
        padding: 0.5rem 0.75rem;
        gap: 0.45rem 0.55rem;
    }

    .lb-look-inside-meta {
        order: 1;
        flex: 1 1 0;
        min-width: 0;
    }

    .lb-look-inside-title {
        font-size: 0.94rem;
        max-width: 100%;
    }

    .lb-look-inside-author {
        display: none;
    }

    .lb-look-inside-actions {
        display: contents;
    }

    .lb-look-inside-close {
        order: 2;
        padding: 0.38rem 0.72rem;
        font-size: 0.82rem;
    }

    .lb-look-inside-bookmarks {
        order: 3;
        flex: 1 0 100%;
        width: 100%;
    }

    .lb-bookmark-btn {
        padding: 0.32rem 0.56rem;
        font-size: 0.75rem;
    }

    .lb-look-inside-stage {
        padding: 12px 10px 28px;
    }

    .lb-reader-pages {
        gap: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .look-inside-btn,
    .lb-bookmark-btn,
    .lb-look-inside-close,
    .lb-reader-end-btn {
        transition: none;
    }

    .lb-look-inside-spinner {
        animation: none;
        border-color: #23633d;
        opacity: 0.65;
    }
}

@media print {
    #lb-look-inside-modal {
        display: none !important;
    }
}
