/* lainRuPDF — просмотр PDF на lainru.org. Оформление окна общее с lainRuShot (.lrshot__*),
   здесь только то, что нужно страницам PDF. Слой текста — по образцу pdf_viewer.css из PDF.js (Apache-2.0). */

.lrpdf__sheet {
    position: relative;
    overflow: hidden;
    background-color: #fff;
    --scale-round-x: 1px;
    --scale-round-y: 1px;
}

.lrpdf__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

/* ---------- слой текста (выделение) */
.lrpdf .textLayer {
    color-scheme: only light;
    position: absolute;
    text-align: initial;
    inset: 0;
    overflow: clip;
    opacity: 1;
    line-height: 1;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    forced-color-adjust: none;
    transform-origin: 0 0;
    z-index: 1;
    --min-font-size: 1;
    --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
    --min-font-size-inv: calc(1 / var(--min-font-size));
}

.lrpdf .textLayer :is(span, br) {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}

.lrpdf .textLayer> :not(.markedContent),
.lrpdf .textLayer .markedContent span:not(.markedContent) {
    z-index: 1;
    --font-height: 0;
    font-size: calc(var(--text-scale-factor) * var(--font-height));
    --scale-x: 1;
    --rotate: 0deg;
    transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}

.lrpdf .textLayer .markedContent {
    display: contents;
}

.lrpdf .textLayer span[role="img"] {
    user-select: none;
    cursor: default;
}

.lrpdf .textLayer ::selection {
    background: rgba(0, 90, 255, .28);
}

.lrpdf .textLayer br::selection {
    background: transparent;
}

.lrpdf .textLayer .endOfContent {
    display: block;
    position: absolute;
    inset: 100% 0 0;
    z-index: 0;
    cursor: default;
    user-select: none;
}

.lrpdf .textLayer.selecting .endOfContent {
    top: 0;
}

/* пока выделение выключено, текст не выделяется: перетаскивание листает и двигает страницу */
.lrpdf:not(.lrpdf--select) .textLayer,
.lrpdf:not(.lrpdf--select) .textLayer * {
    -webkit-user-select: none;
    user-select: none;
    cursor: inherit;
}

.lrpdf--select .textLayer,
.lrpdf--select .textLayer * {
    -webkit-user-select: text;
    user-select: text;
}

.lrpdf--select .lrshot__stage {
    cursor: text;
}

.lrpdf .lrshot__btn[aria-pressed="true"] {
    opacity: 1;
    color: var(--lrshot-accent);
    background: rgba(255, 255, 255, .1);
}

/* ---------- ссылки из PDF */
.lrpdf__links {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.lrpdf__link {
    position: absolute;
    display: block;
    pointer-events: auto;
    cursor: pointer;
    border-radius: 2px;
    /* как в «Просмотре» на macOS: ссылка обведена синей рамкой */
    box-shadow: inset 0 0 0 1.5px rgba(0, 122, 255, .8);
    transition: background-color .15s, box-shadow .15s;
}

.lrpdf__link:hover,
.lrpdf__link:focus-visible {
    background: rgba(0, 122, 255, .12);
    box-shadow: inset 0 0 0 2px rgba(0, 122, 255, 1);
    outline: none;
}

/* ---------- превью страниц без готовых картинок */
.lrpdf .lrshot__thumb canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.lrpdf__thumbnum {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 11px;
    color: var(--lrshot-muted);
}

/* ---------- PDF не открылся */
.lrpdf__fail {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    padding: 18px 22px;
    max-width: 90vw;
    text-align: center;
    color: var(--lrshot-fg);
    background: rgba(0, 0, 0, .6);
}

.lrpdf__fail p {
    margin: 0 0 10px;
}

.lrpdf__fail a {
    color: var(--lrshot-fg);
    text-decoration: underline;
}

/* ---------- кнопка превью (data-act="thumbs") прячет и заголовок документа: страница на весь экран */
.lrpdf:not(.lrshot--thumbs) .lrshot__caption {
    display: none;
}

.lrpdf:not(.lrshot--thumbs) .lrshot__stage {
    bottom: 0;
}

/* ---------- «Продолжить чтение (страница N)» рядом с документом на странице сайта */
a.lrpdfResume {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 12px;
    padding: 8px 16px;
    border: 1px solid var(--color-accent, #73809e);
    border-radius: 999px;
    color: var(--color-accent, #73809e);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color .15s, color .15s;
}

a.lrpdfResume:hover,
a.lrpdfResume:focus-visible {
    background: var(--color-accent, #73809e);
    color: var(--color-blank, #fff);
    outline: none;
}

a.lrpdfResume svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex: none;
}
