/* TU DAO V79 — Reader background layer + selectable background sheet.
   Background art sits on a fixed layer behind the reading flow, so vertical
   scrolling never reveals tile seams. Users can switch between 15 image
   backgrounds and one plain-color background. */

.ng-reader {
    --ng-reader-bg-image: url('/assets/images/reader-backgrounds/bg-05.png?v=79');
}

.ng-reader__panel {
    isolation: isolate;
    background: var(--ng-reader-bg);
}

.ng-reader__panel::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: var(--ng-reader-bg);
    background-image: var(--ng-reader-bg-image);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    transition: background-image .18s ease, background-color .18s ease;
}

/* Let the fixed background layer show through the reading surface. */
.ng-reader__scroller,
.ng-reader__flow,
.ng-reader__flow > .ng-reader__story-head,
.ng-reader__body,
.ng-reader__social {
    background-color: transparent !important;
    background-image: none !important;
}

.ng-reader__scroller {
    position: relative;
    z-index: 0;
}

.ng-reader[data-reader-mode="horizontal"] .ng-reader__flow {
    background: transparent !important;
}

.ng-reader-bg-sheet[hidden] {
    display: none !important;
}

.ng-reader-bg-sheet {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
}

.ng-reader-bg-sheet.is-open {
    pointer-events: auto;
}

.ng-reader-bg-sheet__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(9, 7, 4, .56);
}

.ng-reader-bg-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    min-height: min(68dvh, 620px);
    max-height: min(86dvh, 760px);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border: 1px solid rgba(183, 141, 70, .42);
    border-bottom: 0;
    background:
        linear-gradient(180deg, rgba(246, 234, 203, .98), rgba(230, 205, 154, .98)),
        url('/assets/images/reader-backgrounds/bg-05.png?v=79') center/cover no-repeat;
    box-shadow: 0 -18px 48px rgba(12, 8, 5, .34);
    overflow: hidden;
}

.ng-reader-bg-sheet__handle {
    width: 56px;
    height: 6px;
    margin: 10px auto 6px;
    border-radius: 999px;
    background: rgba(106, 76, 34, .30);
}

.ng-reader-bg-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 14px 12px;
    border-bottom: 1px solid rgba(133, 97, 46, .24);
    color: #4a3318;
}

.ng-reader-bg-sheet__head strong {
    display: block;
    font-size: 1.08rem;
}

.ng-reader-bg-sheet__head span {
    display: block;
    margin-top: 4px;
    color: #7d6035;
    font-size: .83rem;
    font-weight: 700;
}

.ng-reader-bg-sheet__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(142, 106, 49, .44);
    border-radius: 999px;
    background: linear-gradient(180deg, #2d2115 0%, #18120c 100%);
    color: #ebcf88;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

.ng-reader-bg-sheet__grid {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.ng-reader-bg-sheet__item {
    padding: 0;
    border: 1px solid rgba(139, 102, 48, .42);
    border-radius: 14px;
    background: rgba(255, 250, 240, .42);
    box-shadow: 0 6px 18px rgba(58, 33, 11, .10);
    text-align: left;
    cursor: pointer;
    overflow: hidden;
}

.ng-reader-bg-sheet__item.is-active {
    border-color: #8f291c;
    box-shadow:
        0 0 0 2px rgba(143, 41, 28, .18),
        0 10px 24px rgba(58, 33, 11, .16);
}

.ng-reader-bg-sheet__preview {
    aspect-ratio: 3 / 4;
    background-color: #f3ead8;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
}

.ng-reader-bg-sheet__item--plain .ng-reader-bg-sheet__preview {
    background-image: none !important;
}

.ng-reader-bg-sheet__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 10px 11px;
}

.ng-reader-bg-sheet__label {
    color: #3b2a16;
    font-size: .9rem;
    font-weight: 800;
}

.ng-reader-bg-sheet__check {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(132, 95, 40, .4);
    background: rgba(255,255,255,.45);
}

.ng-reader-bg-sheet__item.is-active .ng-reader-bg-sheet__check {
    border-color: #8f291c;
    background: linear-gradient(180deg, #a12c20 0%, #6a170e 100%);
    box-shadow: inset 0 0 0 4px #f6e4be;
}

@media (min-width: 520px) {
    .ng-reader-bg-sheet__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .ng-reader__panel::before {
        background-size: cover;
        background-position: center center;
    }

    .ng-reader-bg-sheet__panel {
        left: 50%;
        right: auto;
        width: min(100%, 900px);
        transform: translateX(-50%);
    }
}


/* V82 — small adaptation credit between the two Reader divider lines. */
.ng-reader__flow > .ng-reader__story-head {
    margin-bottom: 0;
}

.ng-reader__adaptation-mark {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    margin: 0 0 18px;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(127, 127, 127, 0.22);
    color: #8a5b22;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: .12em;
    text-align: center;
    white-space: nowrap;
    break-inside: avoid-column;
}

.ng-reader[data-reader-mode="horizontal"] .ng-reader__adaptation-mark {
    break-inside: avoid-column;
}
