/* Nilades Digital Catalog - Viewer styles. All selectors prefixed .ndc- */

.ndc-viewer {
    --ndc-primary: #373F54;
    --ndc-secondary: #99AABC;
    --ndc-accent: #F0A38F;
    --ndc-white: #FEFEFE;
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background: var(--ndc-primary);
    border-radius: 16px;
    overflow: hidden;
    color: var(--ndc-white);
    font-family: inherit;
    max-width: 100%;
}

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

/* ---------------- Loading ---------------- */
.ndc-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
}

.ndc-skeleton {
    width: 60%;
    max-width: 420px;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    background: linear-gradient(100deg,
        rgba(255,255,255,0.06) 30%,
        rgba(255,255,255,0.16) 50%,
        rgba(255,255,255,0.06) 70%);
    background-size: 200% 100%;
    animation: ndc-shimmer 1.4s ease-in-out infinite;
}

@keyframes ndc-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.ndc-progress {
    width: 60%;
    max-width: 420px;
    height: 6px;
    background: rgba(255,255,255,0.12);
    border-radius: 4px;
    overflow: hidden;
}

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

.ndc-progress__label {
    margin: 0;
    font-size: 13px;
    color: var(--ndc-secondary);
}

/* ---------------- Stage / Book ---------------- */
.ndc-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    perspective: 2000px;
    min-height: 0;
}

.ndc-book {
    display: flex;
    gap: 2px;
    align-items: stretch;
    justify-content: center;
    max-height: 100%;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.45));
    transform-style: preserve-3d;
}

.ndc-book--cover,
.ndc-book--single {
    max-width: 55%;
}

.ndc-leaf {
    position: relative;
    background: var(--ndc-white);
    display: flex;
}

.ndc-leaf:first-child { border-radius: 4px 0 0 4px; }
.ndc-leaf:last-child { border-radius: 0 4px 4px 0; }
.ndc-book--cover .ndc-leaf,
.ndc-book--single .ndc-leaf { border-radius: 4px; }

/* Subtle spine shadow between two pages. */
.ndc-book:not(.ndc-book--cover):not(.ndc-book--single) .ndc-leaf:first-child::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 24px;
    background: linear-gradient(to right, rgba(0,0,0,0.18), transparent);
    pointer-events: none;
}
.ndc-book:not(.ndc-book--cover):not(.ndc-book--single) .ndc-leaf:last-child::before {
    content: "";
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 24px;
    background: linear-gradient(to left, rgba(0,0,0,0.18), transparent);
    pointer-events: none;
    z-index: 1;
}

.ndc-page-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

/* ---------------- Flip animations ---------------- */
@keyframes ndc-flip-fwd {
    0% { transform: rotateY(0); }
    50% { transform: rotateY(-14deg); }
    100% { transform: rotateY(0); }
}
@keyframes ndc-flip-back {
    0% { transform: rotateY(0); }
    50% { transform: rotateY(14deg); }
    100% { transform: rotateY(0); }
}
.ndc-book--flip-fwd,
.ndc-book--flip-fwd-rtl { animation: ndc-flip-fwd 0.6s ease; }
.ndc-book--flip-back,
.ndc-book--flip-back-rtl { animation: ndc-flip-back 0.6s ease; }
.ndc-book--flip-fwd-rtl { animation-name: ndc-flip-back; }
.ndc-book--flip-back-rtl { animation-name: ndc-flip-fwd; }

@media (prefers-reduced-motion: reduce) {
    .ndc-book { animation: none !important; }
    .ndc-skeleton { animation: none; }
}

/* ---------------- Toolbar ---------------- */
.ndc-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(55, 63, 84, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(153, 170, 188, 0.25);
}

.ndc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: rgba(153, 170, 188, 0.14);
    color: var(--ndc-white);
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
}
.ndc-btn:hover { background: var(--ndc-accent); color: var(--ndc-primary); }
.ndc-btn:focus-visible { outline: 2px solid var(--ndc-accent); outline-offset: 2px; }
.ndc-btn.is-off { opacity: 0.45; }
.ndc-btn svg { width: 20px; height: 20px; }

.ndc-counter {
    min-width: 110px;
    text-align: center;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: var(--ndc-secondary);
    padding: 0 8px;
}

/* ---------------- Toast (resume) ---------------- */
.ndc-toast {
    position: absolute;
    bottom: 70px;
    inset-inline-start: 50%;
    transform: translateX(-50%);
    z-index: 5;
}
.ndc-toast__btn {
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    background: var(--ndc-accent);
    color: var(--ndc-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}

/* ---------------- Notices ---------------- */
.ndc-notice {
    padding: 16px 20px;
    border-radius: 10px;
    font-size: 14px;
}
.ndc-notice--error {
    background: rgba(240, 163, 143, 0.15);
    border: 1px solid var(--ndc-accent);
    color: var(--ndc-white);
    margin: 20px;
}

/* ---------------- Mobile ---------------- */
@media (max-width: 768px) {
    .ndc-book--cover,
    .ndc-book--single { max-width: 90%; }
    .ndc-book:not(.ndc-book--cover):not(.ndc-book--single) .ndc-leaf:not(:last-child) {
        display: none; /* single-page mode on mobile */
    }
    .ndc-book:not(.ndc-book--cover):not(.ndc-book--single) .ndc-leaf:last-child {
        border-radius: 4px;
        max-width: 90%;
    }
    .ndc-counter { min-width: 80px; font-size: 13px; }
    .ndc-btn { width: 34px; height: 34px; }
}

:fullscreen .ndc-viewer,
.ndc-viewer:fullscreen {
    border-radius: 0;
    width: 100% !important;
    height: 100% !important;
}
