/* Shared reading chrome for blog, forum, and community articles */

.np-reader-chrome {
    position: sticky;
    top: 5rem;
    z-index: 40;
    margin-bottom: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.np-reading-toolbar {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.35rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #e8edf3;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(10px);
    width: fit-content;
    max-width: 100%;
}

.np-reading-toolbar .tnews-tool-btn {
    min-width: 2.35rem;
    height: 2.35rem;
    border-radius: 999px;
    border: 0;
    background: transparent;
    color: #475569;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.np-reading-toolbar .tnews-tool-btn.active-tool,
.np-reading-toolbar .tnews-tool-btn[aria-pressed="true"] {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

.np-reading-toolbar__divider {
    width: 1px;
    height: 1.5rem;
    background: #e2e8f0;
    margin: 0 0.15rem;
    flex-shrink: 0;
}

/* In-article search — collapsed by default */
.np-reading-search {
    display: none;
    width: 100%;
    max-width: 36rem;
}

.np-reading-search[hidden] {
    display: none !important;
}

.np-reading-search.is-open {
    display: block;
    animation: npReadingSearchIn 0.22s ease-out;
}

@keyframes npReadingSearchIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.np-reading-search__panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem 0.45rem 0.65rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow:
        0 4px 6px -1px rgba(15, 23, 42, 0.05),
        0 12px 28px -8px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(12px);
}

.np-reading-search__field {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    cursor: text;
}

.np-reading-search__icon {
    color: #94a3b8;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.np-reading-search__field:focus-within .np-reading-search__icon {
    color: #6366f1;
}

.np-reading-search input,
.np-reading-search input[type="search"],
.np-reading-search input:hover,
.np-reading-search input:focus,
.np-reading-search input:active {
    display: block;
    height: auto !important;
    min-height: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    color: #0f172a !important;
    font-size: 0.92rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    padding: 0.2rem 0 !important;
    -webkit-appearance: none;
    appearance: none;
}

.np-reading-search input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.np-reading-search__count {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    white-space: nowrap;
}

.np-reading-search__count[hidden] {
    display: none !important;
}

.np-reading-search__hint {
    display: none;
    flex-shrink: 0;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #94a3b8;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.15rem 0.35rem;
    line-height: 1.2;
}

.np-reading-search__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.np-reading-search__close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.np-reading-search mark.np-in-article-hit {
    background: #fde68a;
    color: inherit;
    padding: 0 0.12em;
    border-radius: 3px;
    box-decoration-break: clone;
}

html.dark-theme .np-reading-search__panel {
    background: rgba(24, 24, 27, 0.96);
    border-color: #3f3f46;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.25),
        0 12px 28px -8px rgba(0, 0, 0, 0.45);
}

html.dark-theme .np-reading-search input,
html.dark-theme .np-reading-search input[type="search"],
html.dark-theme .np-reading-search input:focus {
    color: #f4f4f5 !important;
    background: transparent !important;
}

html.dark-theme .np-reading-search input::placeholder {
    color: #71717a;
}

html.dark-theme .np-reading-search__icon {
    color: #71717a;
}

html.dark-theme .np-reading-search__field:focus-within .np-reading-search__icon {
    color: #a5b4fc;
}

html.dark-theme .np-reading-search__count {
    background: #27272a;
    color: #a1a1aa;
}

html.dark-theme .np-reading-search__hint {
    background: #27272a;
    border-color: #3f3f46;
    color: #71717a;
}

html.dark-theme .np-reading-search__close {
    color: #a1a1aa;
}

html.dark-theme .np-reading-search__close:hover {
    background: #27272a;
    color: #fafafa;
}

html.dark-theme .np-reading-search mark.np-in-article-hit {
    background: #854d0e;
    color: #fef3c7;
}

html.dark-theme .np-reading-toolbar__divider {
    background: #3f3f46;
}

@media (min-width: 576px) {
    .np-reading-search__hint {
        display: inline-block;
    }
}

@media (prefers-reduced-motion: reduce) {
    .np-reading-search.is-open {
        animation: none;
    }
}

@media (max-width: 575.98px) {
    .np-reading-search {
        max-width: 100%;
    }

    .np-reading-search__panel {
        border-radius: 12px;
        padding: 0.4rem 0.45rem 0.4rem 0.55rem;
    }
}

.np-resume-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    color: #312e81;
}

.np-resume-bar[hidden] { display: none !important; }

.np-resume-bar__text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.np-resume-bar__text strong { font-size: 0.88rem; }
.np-resume-bar__text span {
    font-size: 0.8rem;
    color: #4338ca;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 42ch;
}

.np-resume-bar__actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.np-resume-bar__go {
    border: 0;
    background: #6366f1;
    color: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.np-resume-bar__dismiss {
    border: 0;
    background: transparent;
    color: #4338ca;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.15rem 0.4rem;
    cursor: pointer;
}

[data-reading-body] {
    width: 100%;
    max-width: none;
    --reading-font-size: 1.125rem;
    --reading-line-height: 1.8;
    font-size: var(--reading-font-size) !important;
    line-height: var(--reading-line-height) !important;
    font-kerning: normal;
    font-feature-settings: "kern" 1, "liga" 1;
    text-rendering: optimizeLegibility;
    quotes: "«" "»" "‹" "›";
    -webkit-hyphens: auto;
    hyphens: auto;
    word-break: break-word;
}

[data-reading-body] :where(p, li, blockquote, td, th, div, span, a, em, strong, u, s, mark, small, figcaption, dt, dd, pre, code) {
    font-size: inherit !important;
    line-height: inherit !important;
}

[data-reading-body] :where(h2, h3, h4, h5, h6) {
    line-height: 1.35 !important;
}

[data-reading-body] h2 { font-size: 1.45em !important; }
[data-reading-body] h3 { font-size: 1.22em !important; }
[data-reading-body] h4 { font-size: 1.08em !important; }

#forum-tw .forum-civis-post__content[data-reading-body],
.community-article__body[data-reading-body] {
    font-size: var(--reading-font-size) !important;
    line-height: var(--reading-line-height) !important;
}

html[data-reading-size="small"] [data-reading-body] {
    --reading-font-size: 1rem;
    --reading-line-height: 1.7;
}

html[data-reading-size="medium"] [data-reading-body] {
    --reading-font-size: 1.125rem;
    --reading-line-height: 1.8;
}

html[data-reading-size="large"] [data-reading-body] {
    --reading-font-size: 1.28rem;
    --reading-line-height: 1.85;
}

html[data-reading-size="xlarge"] [data-reading-body] {
    --reading-font-size: 1.42rem;
    --reading-line-height: 1.9;
}

[data-reading-body].tnews-font-size-small {
    --reading-font-size: 1rem;
    --reading-line-height: 1.7;
}
[data-reading-body].tnews-font-size-medium {
    --reading-font-size: 1.125rem;
    --reading-line-height: 1.8;
}
[data-reading-body].tnews-font-size-large {
    --reading-font-size: 1.28rem;
    --reading-line-height: 1.85;
}
[data-reading-body].tnews-font-size-xlarge {
    --reading-font-size: 1.42rem;
    --reading-line-height: 1.9;
}

html.np-reading-serif [data-reading-body],
html.np-reading-serif [data-reading-body] p,
html.np-reading-serif [data-reading-body] li,
html.np-reading-serif [data-reading-body] blockquote {
    font-family: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif !important;
}

html.tnews-focus-mode-active [data-reading-chrome],
html.tnews-focus-mode-active .th-header,
html.tnews-focus-mode-active .th-footer,
html.tnews-focus-mode-active .breadcumb-wrapper {
    display: none !important;
}

html.tnews-focus-mode-active .np-reader-chrome { top: 0.6rem; }

html.tnews-focus-mode-active #forum-tw main.lg\:col-span-8,
html.tnews-focus-mode-active #forum-tw .grid > main {
    grid-column: 1 / -1;
}

html.tnews-focus-mode-active .community-layout .col-md-8 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
}

html.tnews-focus-mode-active .video-show-page .vp-main {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
}

/* Shared comfort modes for non-blog reading surfaces */
html[data-reading-line="compact"] [data-reading-body] {
    --reading-line-height: 1.6;
}

html[data-reading-line="normal"] [data-reading-body] {
    --reading-line-height: 1.8;
}

html[data-reading-line="relaxed"] [data-reading-body] {
    --reading-line-height: 2;
}

html[data-reading-width="narrow"] [data-reading-body] {
    max-width: 38rem;
    margin-inline: auto;
}

html[data-reading-width="normal"] [data-reading-body] {
    max-width: 46rem;
    margin-inline: auto;
}

html[data-reading-width="wide"] [data-reading-body] {
    max-width: none;
}

/* Video article details stay full main-column width (toolbar/channel aligned). */
.video-show-page [data-reading-body],
html[data-reading-width="narrow"] .video-show-page [data-reading-body],
html[data-reading-width="normal"] .video-show-page [data-reading-body],
html[data-reading-width="wide"] .video-show-page [data-reading-body] {
    max-width: none !important;
    width: 100% !important;
    margin-inline: 0 !important;
}

html.np-reading-sepia [data-reading-body],
html.np-reading-sepia .np-reader-chrome .np-reading-toolbar {
    background-color: #f4ecd8;
    color: #5b4636;
}

html.np-reading-sepia [data-reading-body] a {
    color: #8a4b08;
}

html.dark-theme.np-reading-sepia [data-reading-body],
html.dark-theme.np-reading-sepia .np-reader-chrome .np-reading-toolbar {
    background-color: #2a2418;
    color: #e8dcc4;
}

html.np-reading-dyslexia [data-reading-body],
html.np-reading-dyslexia [data-reading-body] p,
html.np-reading-dyslexia [data-reading-body] li {
    font-family: "Atkinson Hyperlegible", "Comic Sans MS", Verdana, sans-serif !important;
    letter-spacing: 0.03em;
    word-spacing: 0.08em;
}

html.np-text-only-mode .video-show-page .vp-player-wrap,
html.np-text-only-mode [data-reading-body] img,
html.np-text-only-mode [data-reading-body] video,
html.np-text-only-mode [data-reading-body] iframe,
html.np-text-only-mode [data-reading-body] figure {
    display: none !important;
}

html.dark-theme .np-reading-toolbar {
    background: rgba(24, 24, 27, 0.92);
    border-color: #3f3f46;
    color: #e4e4e7;
}

html.dark-theme .np-reading-toolbar .tnews-tool-btn { color: #e4e4e7; }

html.dark-theme .np-resume-bar {
    background: #1e1b4b;
    border-color: #4338ca;
    color: #e0e7ff;
}

@media (max-width: 575.98px) {
    .np-reading-toolbar { border-radius: 14px; }
    .np-resume-bar { flex-direction: column; align-items: flex-start; }

    .np-reader-chrome {
        position: static;
        top: auto;
        margin-bottom: 0.85rem;
    }

    .np-reading-toolbar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        max-width: 100%;
        border-radius: 14px;
        padding: 0.4rem;
        gap: 0.25rem;
    }

    .np-reading-toolbar::-webkit-scrollbar { display: none; }

    .np-reading-toolbar .tnews-tool-btn {
        flex: 0 0 auto;
        min-width: 2.75rem;
        min-height: 2.75rem;
        height: 2.75rem;
    }

    .np-reading-toolbar__divider {
        flex: 0 0 auto;
        align-self: center;
        height: 1.5rem;
    }
}
