/* =============================================================
 * MSBS Ebook Viewer — 프리미엄 다크 리더
 * ============================================================= */

.msev {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    line-height: 1.5; /* body 직속 — limud-header 의 body{line-height:0} 상속 차단 */
    display: none;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
    color: #e9e4d8;
}
.msev.is-open { display: flex; }
.msev *, .msev *::before, .msev *::after { box-sizing: border-box; }

.msev__backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(60% 50% at 50% 40%, rgba(60,50,35,0.35), transparent 70%),
        linear-gradient(180deg, #14120e 0%, #0c0b09 100%);
}

/* ── 상단 바 ── */
.msev__top {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 14px;
    background: linear-gradient(180deg, rgba(0,0,0,0.55), transparent);
    transition: opacity .4s ease, transform .4s ease;
}
.msev__title {
    font-family: "Georgia", "Noto Serif KR", serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.msev__meta { font-size: 12px; color: #b7ad97; margin-top: 2px; }
.msev__close {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease;
}
.msev__close:hover { transform: rotate(90deg); background: rgba(255,255,255,0.18); }

/* ── 스테이지 ── */
.msev__stage {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    padding: 2px 0;
    overflow: auto;              /* 확대 시 스크롤 탐색 */
    scrollbar-width: thin;
    scrollbar-color: rgba(226,195,124,0.4) transparent;
}
.msev__pages {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: auto;                /* 중앙 정렬 + 확대 시 스크롤 잘림 방지 */
    padding: 2px 8px;
    /* 확대해서 내용이 화면보다 커지면 flex 중앙정렬이 왼쪽·위를 잘라 먹는다 —
       내용 크기만큼 자리를 잡아 두면 스크롤로 끝까지 볼 수 있다. */
    min-width: min-content;
    min-height: min-content;
}
/* 확대 상태에서 끌어 움직이는 중 — 손 모양으로 바꿔 «잡아끌 수 있다» 를 알린다 */
.msev__stage.is-grabbing { cursor: grabbing; user-select: none; }
.msev__stage::-webkit-scrollbar { width: 8px; height: 8px; }
.msev__stage::-webkit-scrollbar-thumb { background: rgba(226,195,124,0.35); border-radius: 4px; }
.msev__stage::-webkit-scrollbar-track { background: transparent; }
.msev__canvas {
    background: #fff;
    border-radius: 4px;
    /* 자바스크립트가 정해 준 크기를 CSS 가 다시 건드리지 않게 못 박는다 —
       여기서 조금이라도 늘어나면 픽셀 격자가 어긋나 글자 가장자리가 지저분해진다. */
    flex: 0 0 auto;
    max-width: none;
    max-height: none;
    /* 크기가 정확히 맞춰져 있으므로 브라우저가 임의로 뭉개지 않도록 한다 */
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    box-shadow:
        0 30px 80px -20px rgba(0,0,0,0.85),
        0 0 0 1px rgba(255,255,255,0.06);
}
/* 두 페이지 모드: 책등 접합부 느낌 */
.msev__pages .msev__canvas:first-child:not(:only-child) { border-radius: 6px 2px 2px 6px; }
.msev__pages .msev__canvas:last-child:not(:only-child) { border-radius: 2px 6px 6px 2px; box-shadow: inset 6px 0 12px -6px rgba(0,0,0,0.18), 0 30px 80px -20px rgba(0,0,0,0.85); }

.msev__spinner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    font-size: 14px;
    color: #b7ad97;
    z-index: 2;
}
.msev__spinner span {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(226,195,124,0.25);
    border-top-color: #e2c37c;
    animation: msev-spin 0.9s linear infinite;
}
@keyframes msev-spin { to { transform: rotate(360deg); } }

/* 좌우 화살표 (스테이지 스크롤과 무관하게 화면에 고정) */
.msev__arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 54px; height: 54px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(20,18,14,0.55);
    backdrop-filter: blur(6px);
    color: #e9e4d8;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    z-index: 4;
    transition: background .18s ease, transform .18s ease, opacity .3s ease;
}
.msev__arrow:hover { background: rgba(226,195,124,0.22); transform: translateY(-50%) scale(1.06); }
.msev__arrow--prev { left: 22px; }
.msev__arrow--next { right: 22px; }
.msev__arrow.is-off { opacity: 0.25; pointer-events: none; }

/* ── 하단 컨트롤 바 (오버레이) ── */
.msev__bar {
    position: relative;
    z-index: 3;
    padding: 6px 16px 10px;
    background: linear-gradient(0deg, rgba(0,0,0,0.6), transparent);
    transition: opacity .4s ease, transform .4s ease;
}
.msev__progress {
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.14);
    cursor: pointer;
    margin-bottom: 8px;
}
.msev__progress-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    background: linear-gradient(90deg, #c9a24b, #e2c37c);
    box-shadow: 0 0 10px rgba(226,195,124,0.55);
    transition: width .25s ease;
}
.msev__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.msev__btn {
    min-width: 38px; height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(6px);
    color: #e9e4d8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.msev__btn:hover { background: rgba(226,195,124,0.18); }
.msev__btn--txt { font-size: 13px; font-weight: 800; letter-spacing: 0.04em; }
.msev__btn.is-on {
    background: rgba(226,195,124,0.22);
    border-color: rgba(226,195,124,0.7);
    color: #f0dfb2;
}
.msev__sep { width: 1px; height: 22px; background: rgba(255,255,255,0.14); }
.msev__zoomval {
    min-width: 46px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #e2c37c;
    letter-spacing: 0.02em;
}
.msev__pageinfo { font-size: 13.5px; color: #cfc6b2; display: inline-flex; align-items: center; gap: 6px; }
.msev__pagenum {
    width: 56px;
    padding: 6px 4px;
    text-align: center;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.07);
    color: #fff;
    font-size: 13.5px;
    -moz-appearance: textfield;
}
.msev__pagenum::-webkit-outer-spin-button,
.msev__pagenum::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.msev__pagetotal { color: #e2c37c; }

/* 유휴 시 컨트롤 자동 숨김 (마우스 움직이면 복귀) */
.msev.is-idle .msev__top { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.msev.is-idle .msev__bar { opacity: 0; transform: translateY(8px); pointer-events: none; }
.msev.is-idle .msev__arrow { opacity: 0; pointer-events: none; }
.msev.is-idle { cursor: none; }

@media (max-width: 700px) {
    .msev__arrow { width: 42px; height: 42px; font-size: 24px; }
    .msev__arrow--prev { left: 8px; }
    .msev__arrow--next { right: 8px; }
    .msev__btn--txt[data-act="two"] { display: none; } /* 모바일은 1페이지 고정 */
    .msev__title { font-size: 14.5px; }
}
