/* Catalog flipbook - fullscreen overlay UI */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --cat-gold: #C89B3C;
    --cat-ink: #1C1714;
    --cat-paper: #ececec;
    --tb-bg: rgba(255, 255, 255, 0.94);
    --tb-border: rgba(0, 0, 0, 0.1);
    --chrome-z: 40;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--cat-paper);
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    color: var(--cat-ink);
}

#catalog-app {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#catalog-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: var(--cat-paper);
}

/* Fixed overlay layer - back + toolbar, never moves with book */
.catalog-chrome {
    position: fixed;
    inset: 0;
    z-index: var(--chrome-z);
    pointer-events: none;
}

.catalog-back,
.catalog-toolbar,
.tb-dropdown {
    pointer-events: auto;
}

.catalog-back {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    z-index: calc(var(--chrome-z) + 2);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px 9px 12px;
    border-radius: 999px;
    background: var(--tb-bg);
    border: 1px solid var(--tb-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    color: var(--cat-ink);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.catalog-back:hover {
    border-color: var(--cat-gold);
    color: var(--cat-ink);
}

.catalog-back svg {
    flex-shrink: 0;
    color: var(--cat-gold);
}

#catalog-loading {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: var(--cat-paper);
    color: #555;
    font-size: 15px;
}

#catalog-loading[hidden] { display: none; }

.catalog-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #ddd;
    border-top-color: var(--cat-gold);
    border-radius: 50%;
    animation: catalog-spin 0.75s linear infinite;
}

@keyframes catalog-spin { to { transform: rotate(360deg); } }

#catalog-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: manipulation;
    cursor: default;
    min-width: 240px;
    min-height: 320px;
}

#catalog-viewport.is-pannable { cursor: default; }
#catalog-viewport.is-panning { cursor: grabbing; }

#catalog-pan-zoom {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

#catalog-book-wrap {
    position: relative;
    margin: 0;
}

#catalog-book {
    margin: 0;
}

/* Zone laterale - mijlocul marginii (colturile raman pentru PageFlip) */
.catalog-edge {
    position: absolute;
    top: 18%;
    height: 64%;
    width: 11%;
    z-index: 6;
    background: transparent;
}
.catalog-edge--left {
    left: 0;
    cursor: w-resize;
}
.catalog-edge--right {
    right: 0;
    cursor: e-resize;
}
.catalog-edge:hover {
    background: linear-gradient(90deg, rgba(200, 155, 60, 0.08), transparent);
}
.catalog-edge--right:hover {
    background: linear-gradient(270deg, rgba(200, 155, 60, 0.08), transparent);
}

@media (max-width: 767px) {
    .catalog-edge { width: 16%; }
}

/* Toolbar pill - overlay jos, centru ecran (peste catalog) */
.catalog-toolbar {
    position: fixed;
    left: 50%;
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: calc(var(--chrome-z) + 1);
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 1px;
    width: max-content;
    max-width: calc(100vw - 20px);
    padding: 5px 8px;
    border-radius: 10px;
    background: var(--tb-bg);
    border: 1px solid var(--tb-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.catalog-toolbar::-webkit-scrollbar { display: none; }

.tb-btn {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    color: #333;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
    font: inherit;
    line-height: 0;
    transition: background 0.12s;
}

.tb-btn svg {
    display: block;
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.tb-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.07); }
.tb-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tb-btn[aria-pressed="true"],
.tb-btn.is-active { color: var(--cat-gold); background: rgba(200, 155, 60, 0.12); }

.tb-sep {
    width: 1px;
    height: 20px;
    background: rgba(0, 0, 0, 0.12);
    margin: 0 3px;
    flex: 0 0 auto;
}

.tb-page {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0 4px;
    flex: 0 0 auto;
    white-space: nowrap;
}

.tb-page input {
    width: 40px;
    height: 30px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 6px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: #fff;
    color: #222;
    padding: 0 3px;
    margin: 0;
}

.tb-page input:focus {
    outline: 2px solid rgba(200, 155, 60, 0.45);
    border-color: var(--cat-gold);
}

.tb-page__sep,
#page-total {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    font-variant-numeric: tabular-nums;
}

.tb-menu-wrap { position: relative; flex: 0 0 auto; }

.tb-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 168px;
    background: #fff;
    border: 1px solid var(--tb-border);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
    padding: 6px;
    z-index: calc(var(--chrome-z) + 5);
}

.tb-dropdown[hidden] { display: none !important; }

.tb-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    font-family: inherit;
}

.tb-dropdown button:hover { background: rgba(0, 0, 0, 0.05); }

#catalog-toast {
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 10px 18px;
    border-radius: 8px;
    background: rgba(28, 23, 20, 0.88);
    color: #fff;
    font-size: 13px;
    pointer-events: none;
}

#catalog-toast[hidden] { display: none; }

/* PageFlip book */
.stf__parent { margin: 0 auto; }
.stf__wrapper { margin: 0 auto; }
.stf__item {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    background: #fff;
}
.stf__item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (max-width: 767px) {
    .catalog-back span { display: none; }
    .catalog-back { padding: 10px; border-radius: 50%; }
    .catalog-toolbar {
        bottom: max(10px, env(safe-area-inset-bottom, 0px));
        padding: 4px 6px;
        max-width: calc(100vw - 12px);
    }
    .tb-btn { width: 32px; height: 32px; min-width: 32px; min-height: 32px; }
    .tb-page input { width: 34px; height: 28px; font-size: 12px; }
}

@media (max-width: 480px) {
    .tb-sep { margin: 0 1px; }
}
