/* PDF меню – листалка, по една страница на екран */

:root {
    --accent: #c8963e;
    --bar-bg: #1d1b19;
    --bar-fg: #f3efe9;
    --bar-fg-dim: #a49c90;
    --page-ground: #2a2724;
    --sheet: #ffffff;
    --bar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--page-ground);
    color: var(--bar-fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Лента с инструменти ------------------------------------------- */

.toolbar {
    flex: 0 0 auto;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 14px;
    background: var(--bar-bg);
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    box-shadow: 0 1px 12px rgba(0, 0, 0, .35);
    z-index: 20;
}




.toolbar__pager {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.pager__state {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--bar-fg-dim);
    font-variant-numeric: tabular-nums;
}

.pager__input {
    width: 42px;
    padding: 5px 4px;
    text-align: center;
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--bar-fg);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 6px;
}

.pager__input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, .1);
}

.pager__count { color: var(--bar-fg); }

/* --- Бутони --------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    color: var(--bar-fg);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, opacity .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, .13);
    border-color: rgba(255, 255, 255, .2);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: .35;
    cursor: default;
}

.btn--icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
    line-height: 1;
    padding: 0;
}

.btn--primary {
    height: 40px;
    padding: 0 20px;
    margin-top: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #17140f;
    background: var(--accent);
    border-color: var(--accent);
}

.btn--primary:hover {
    background: var(--accent);
    opacity: .88;
}

/* --- Лента за зареждане --------------------------------------------- */

.progress {
    position: relative;
    flex: 0 0 auto;
    height: 3px;
    background: transparent;
    overflow: hidden;
    z-index: 15;
}

.progress__bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .2s ease;
}

.progress.is-done .progress__bar {
    opacity: 0;
    transition: opacity .4s ease .1s;
}

/* --- Страниците ------------------------------------------------------ */

.viewer {
    position: relative;
    flex: 1 1 auto;
    overflow: hidden;
    touch-action: manipulation;
}

.viewer:focus { outline: none; }

/* Сцената дава перспективата, без която въртенето изглежда плоско. */
.stage {
    position: absolute;
    inset: 0;
    perspective: 2200px;
    perspective-origin: 50% 50%;
}

/* Всички листове стоят един върху друг; вижда се само текущият и този
   под него по време на прелистване. */
.slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    transform-style: preserve-3d;
}

.slide.is-current,
.slide.is-under { visibility: visible; }

.slide.is-under   { z-index: 1; }
.slide.is-current { z-index: 2; }

.sheet {
    position: relative;
    background: var(--sheet);
    border-radius: 3px;
    box-shadow: 0 6px 28px rgba(0, 0, 0, .5);
    overflow: hidden;
    /* Листът се върти около вътрешния си ръб, както е закачен в книга. */
    transform-origin: left center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* --- Прелистване ------------------------------------------------------ */

/* Сянката, която пада върху листа, докато се вдига – без нея въртенето
   изглежда като плъзгане на картинка, а не като хартия. */
.sheet__shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, .5), rgba(0, 0, 0, 0) 60%);
    opacity: 0;
    pointer-events: none;
}

.slide.is-flip-out .sheet { animation: flipOut 620ms cubic-bezier(.38, .06, .22, 1) forwards; }
.slide.is-flip-in  .sheet { animation: flipIn  620ms cubic-bezier(.38, .06, .22, 1) forwards; }

.slide.is-flip-out .sheet__shade { animation: shadeIn  620ms ease-out forwards; }
.slide.is-flip-in  .sheet__shade { animation: shadeOut 620ms ease-out forwards; }

/* Напред: текущият лист се вдига и отива наляво, отдолу се показва следващият. */
@keyframes flipOut {
    from { transform: rotateY(0deg); }
    to   { transform: rotateY(-172deg); }
}

/* Назад: предишният лист се връща отляво върху текущия. */
@keyframes flipIn {
    from { transform: rotateY(-172deg); }
    to   { transform: rotateY(0deg); }
}

@keyframes shadeIn {
    from { opacity: 0; }
    to   { opacity: .55; }
}

@keyframes shadeOut {
    from { opacity: .55; }
    to   { opacity: 0; }
}

.sheet canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.sheet__num {
    position: absolute;
    right: 8px;
    bottom: 6px;
    padding: 2px 7px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: rgba(0, 0, 0, .42);
    border-radius: 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}

.sheet.is-rendered .sheet__num { opacity: 1; }

/* Скелет, докато страницата още не е рендерирана */
.sheet:not(.is-rendered)::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, #f4f1ec 30%, #e6e1d9 50%, #f4f1ec 70%);
    background-size: 220% 100%;
    animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
    from { background-position: 180% 0; }
    to   { background-position: -80% 0; }
}

/* --- Състояния (зареждане / грешка / няма меню) ---------------------- */

.state {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

.state--overlay {
    position: absolute;
    inset: 0;
    background: var(--page-ground);
    z-index: 10;
}

.state.is-hidden { display: none; }

.state__box { max-width: 380px; }

.state__title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
}

.state__text {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--bar-fg-dim);
}

.spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 16px;
    border: 3px solid rgba(255, 255, 255, .14);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

/* --- Мобилни ------------------------------------------------------- */

@media (max-width: 720px) {
    :root { --bar-h: 52px; }

    .toolbar {
        gap: 8px;
        padding: 0 10px;
    }

    .toolbar__label { display: none; }

    .btn--wide-only { display: none; }

    .btn--icon {
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 420px) {
    .toolbar__name { font-size: 14px; }
    .pager__sep { display: none; }
    .pager__input { width: 38px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::after { animation: none !important; transition: none !important; }

    .sheet__shade { display: none; }
}
