/* tbv2-viewer — v0.5.4: remove position:relative from .tbv2-page */

*, *::before, *::after { box-sizing: border-box; }

#tbv2-root {
    position: relative;
    width: 100%;
    height: calc(100vh - var(--wp-admin--admin-bar--height, 0px));
    display: flex;
    flex-direction: column;
    /* align-items/justify-content removed — default stretch keeps stage full width */
    background: #1a1a2e;
    overflow: hidden;
    font-family: system-ui, -apple-system, sans-serif;
    user-select: none;
}

/* ── Nav toggle ───────────────────────────────────────────────────────────── */

#tbv2-nav-toggle {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 30;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
#tbv2-nav-toggle:hover { background: rgba(255,255,255,0.22); }

/* ── Nav backdrop + panel ─────────────────────────────────────────────────── */

#tbv2-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0,0,0,0.5);
}

#tbv2-nav {
    position: fixed;
    top: 0; right: 0;
    z-index: 50;
    width: clamp(280px, 33vw, 600px);
    max-width: 92vw;
    height: 100%;
    background: #16213e;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.5);
    transform: translateX(0);
    transition: transform 0.28s ease;
}
#tbv2-nav[hidden] {
    display: flex !important;
    transform: translateX(100%);
    pointer-events: none;
}
#tbv2-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.9rem;
    font-weight: 600;
    color: #aab;
}
#tbv2-nav-close {
    background: none;
    border: none;
    color: #aab;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}
#tbv2-nav-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    color: #99a;
    font-size: 0.85rem;
}

/* ── Book stage ───────────────────────────────────────────────────────────── */

#tbv2-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 8px 48px;
    overflow: hidden;
    position: relative;
}

/* #tbv2-stage::after removed for testing */

#tbv2-book {
    position: relative;
    box-shadow: 0 12px 40px rgba(0,0,0,0.8), 0 2px 8px rgba(0,0,0,0.6);
}

.tbv2-page {
    /* position:relative removed — testing if this breaks StPageFlip 3D */
    background: #f8f5ef;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tbv2-page-num {
    font-size: 4rem;
    font-weight: 700;
    color: #333;
    opacity: 0.25;
}

/* ── Controls bar ─────────────────────────────────────────────────────────── */

#tbv2-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10,12,30,0.92);
    border-top: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    z-index: 10;
}

#tbv2-btn-group {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 8px;
}

#tbv2-btn-group button {
    margin: 0;
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    width: 26px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
#tbv2-btn-group button:hover:not(:disabled) {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.4);
}

#tbv2-btn-group #tbv2-page-info {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.65);
    min-width: 44px;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border: none;
    background: none;
    cursor: default;
}

#tbv2-btn-group .tbv2-ctrl-sep {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.18);
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    cursor: default;
    pointer-events: none;
}

#tbv2-version-select {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: rgba(255,255,255,0.85);
    font-size: 0.72rem;
    padding: 0 4px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
    max-width: 120px;
}
#tbv2-version-select option { background: #2a2a2a; color: #fff; }

#tbv2-help { font-size: 0.7rem; font-weight: 700; color: rgba(255,255,255,0.75); }

/* ── Audio bar — position:fixed + transform:translateX(-50%) ──────────────── */

#tbv2-audio-bar {
    position: fixed;
    bottom: 38px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(14,22,50,0.92);
    border: 1px solid rgba(100,180,255,0.25);
    border-radius: 20px;
    padding: 5px 14px;
    backdrop-filter: blur(12px);
    color: #b0c8e8;
    font-size: 0.78rem;
}
#tbv2-audio-bar[hidden] { display: none !important; }

/* ── Media panel — position:absolute + transform:translateX(-50%) ─────────── */

#tbv2-media {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    border-radius: 24px;
    padding: 5px 14px;
}
#tbv2-media[hidden] { display: none !important; }
