/* CoffeeHunters EN - NewsXpress adaptation layer
   (marquee ticker, CMS pagination, search overlay, misc fixes) */

/* ---- Ticker marquee (theme CSS hides .marquee-content-right until JS ready) ---- */
body .marquee-content-right {
    opacity: 1 !important;
    visibility: visible !important;
}
.nx-marquee-track {
    display: flex;
    align-items: center;
    width: max-content;
    animation: nxMarquee 45s linear infinite;
}
.marquee-content-right:hover .nx-marquee-track {
    animation-play-state: paused;
}
@keyframes nxMarquee {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
.nx-marquee-track .theme-marquee-item {
    min-width: 24rem;
}

/* ---- CMS pagination ---- */
.nx-pagination {
    margin-top: 2rem;
    font-size: var(--theme-font-size-small, 1.4rem);
}
.nx-pagination-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.nx-pagination-inner a,
.nx-pagination-inner span,
.nx-pagination-inner li,
.nx-pagination-inner strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.6rem;
    min-height: 3.6rem;
    padding: 0 1rem;
    border-radius: 0.4rem;
    background-color: var(--theme-component-color, #1b1b1b);
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(128, 128, 128, 0.25);
}
.nx-pagination-inner .active,
.nx-pagination-inner strong,
.nx-pagination-inner span:not(:has(a)):not(:empty) {
    background-color: var(--theme-accent-color, #d13131);
    color: #fff;
    border-color: transparent;
}
.nx-pagination-inner ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ---- Search overlay ---- */
.nx-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.nx-search-overlay.is-open {
    display: flex;
}
.nx-search-box {
    width: min(92vw, 64rem);
}
.nx-search-form {
    display: flex;
    gap: 0.6rem;
}
.nx-search-form input {
    flex: 1;
    font-size: 1.8rem;
    padding: 1.2rem 1.6rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(128, 128, 128, 0.4);
    background: #141414;
    color: #eee;
}
.nx-search-form button[type="submit"] {
    font-size: 1.6rem;
    padding: 1.2rem 2.4rem;
    border: 0;
    border-radius: 0.5rem;
    background: var(--theme-accent-color, #d13131);
    color: #fff;
    cursor: pointer;
}
.nx-search-close {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 3.2rem;
    line-height: 1;
    cursor: pointer;
}

/* ---- Scroll to top ---- */
.nx-scroll-top {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    width: 4.4rem;
    height: 4.4rem;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: var(--theme-accent-color, #d13131);
    color: #fff;
    cursor: pointer;
    z-index: 999;
}
.nx-scroll-top.is-visible {
    display: flex;
}
.nx-scroll-top .svg-icon {
    width: 2.2rem;
    height: 2.2rem;
}

/* ---- Single post ---- */
.entry-header.has-box-shadow {
    padding: 2rem;
    border-radius: 0.5rem;
    background-color: var(--theme-component-color, #1b1b1b);
}
.entry-header.has-box-shadow .newsxpress-meta {
    margin-top: 0.6rem;
}
.entry-content {
    font-size: 1.7rem;
    line-height: 1.75;
}
.entry-content img {
    max-width: 100%;
    height: auto;
}
.entry-content h1,
.entry-content h2,
.entry-content h3 {
    line-height: 1.3;
}
.nx-source-note {
    margin-top: 2.5rem;
    opacity: 0.65;
}
.nx-tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 2rem;
}
.nx-tag {
    padding: 0.4rem 1.2rem;
    border-radius: 10rem;
    border: 1px solid rgba(128, 128, 128, 0.35);
    font-size: var(--theme-font-size-small, 1.4rem);
    text-decoration: none;
}

/* ---- Related posts grid fallback (theme grid needs 3 items) ---- */
.nx-related-grid {
    grid-template-columns: repeat(3, 1fr) !important;
}
@media (max-width: 64rem) {
    .nx-related-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}
.nx-related-grid .entry-image-small img {
    width: 100%;
    height: auto;
}

/* ---- Misc ---- */
.nx-no-results {
    padding: 4rem 0;
    text-align: center;
    opacity: 0.75;
    font-size: 1.7rem;
}
.nx-error-box {
    padding: 8rem 0;
    text-align: center;
}
.nx-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 0 0 1rem;
    font-size: var(--theme-font-size-small, 1.4rem);
}
.theme-display-clock {
    display: inline;
    font-variant-numeric: tabular-nums;
}
/* Entry images fill width like WP theme */
.article-block-wrapper .featured-media img,
.entry-image .featured-media img {
    width: 100%;
    height: auto;
    object-fit: cover;
}
.single .entry-image .featured-media img {
    max-height: 52rem;
}
/* Screen reader helper (theme provides, but ensure present) */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    width: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute !important;
    word-wrap: normal !important;
}

/* ---- Fix oversized inline SVG icons in topbar ---- */
.site-topbar .svg-icon {
    width: 1.6rem !important;
    height: 1.6rem !important;
    flex-shrink: 0;
}
.site-topbar-component {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}
/* Ticker tiny images sizing */
.marquee-content-right .entry-image-tiny img {
    width: 7rem;
    height: 4.6rem;
    object-fit: cover;
}

/* ---- Light-mode component overrides (match www.coffeehunters.net) ---- */
body .entry-header.has-box-shadow {
    background-color: #fff;
    color: var(--theme-accent-hover-color, #404040);
    border: 1px solid var(--theme-accent-color, #4db2ec);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.07);
}
body .entry-header.has-box-shadow .entry-title {
    color: #546e7a;
}
body .entry-header.has-box-shadow .newsxpress-meta {
    color: #969fa4;
}
body .site-footer {
    background-color: #f7f7f7;
    color: #444;
}
body .site-footer a {
    color: #444;
}
body .theme-footer-bottom {
    border-top: 1px solid #e5e5e5;
}
body .nx-pagination-inner a,
body .nx-pagination-inner span,
body .nx-pagination-inner li,
body .nx-pagination-inner strong {
    background-color: #fff;
    color: #444;
}
body .nx-pagination-inner .active,
body .nx-pagination-inner strong {
    background-color: var(--theme-accent-color, #4db2ec);
    color: #fff;
}
body .nx-search-form input {
    background: #fff;
    color: #333;
}
body .nx-tag {
    background: #fff;
}
body .widget-content {
    background: transparent;
}

/* ===== v1.1 additions: slider / swiper buttons / dark toggle / trending tags ===== */

.nx-slider .swiper-wrapper {
    display: grid;
    overflow: hidden;
}
.nx-slider .swiper-slide {
    grid-area: 1 / 1;
    min-width: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity .5s ease, visibility .5s ease;
    pointer-events: none;
}
.nx-slider .swiper-slide:first-child {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.nx-slider .swiper-slide.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.site-section-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-swiper-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #e3e6ea;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}
.theme-swiper-button:hover {
    background: #f2f5f8;
    color: #000;
}
.theme-swiper-button .svg-icon {
    width: 16px;
    height: 16px;
}

.nx-dark-toggle {
    cursor: pointer;
}

.trending-tags-panel .trending-tags-link {
    white-space: nowrap;
}

[data-theme="dark"] .theme-swiper-button {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #fff;
}
[data-theme="dark"] .nx-slider .swiper-wrapper {
    background: transparent;
}

/* ===== v1.2 additions: sidebar blocks / tabs / fullwidth widget / more-to-read ===== */

/* Sidebar block headings (WP block widgets style) */
.widget-area .wp-block-heading {
    position: relative;
    margin: 0 0 16px;
    padding-bottom: 12px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: #111;
    border-bottom: 1px solid #e6e9ec;
}
.widget-area .wp-block-heading::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 46px;
    height: 2px;
    background: #d8232a;
}
.widget-area .widget {
    margin-bottom: 34px;
}
.widget-area .wp-block-latest-posts__list,
.widget-area .wp-block-categories-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.widget-area .wp-block-latest-posts__list li,
.widget-area .wp-block-categories-list li {
    padding: 9px 0;
    border-bottom: 1px dashed #e9ecef;
    font-size: 14px;
    line-height: 1.5;
}
.widget-area .wp-block-latest-posts__list li:last-child,
.widget-area .wp-block-categories-list li:last-child {
    border-bottom: 0;
}
.widget-area .wp-block-latest-posts__post-title,
.widget-area .wp-block-categories-list a {
    color: #1a1a1a;
    text-decoration: none;
}
.widget-area .wp-block-latest-posts__post-title:hover,
.widget-area .wp-block-categories-list a:hover {
    color: #d8232a;
}

/* Sidebar search form */
.widget_search .wp-block-search__inside-wrapper {
    display: flex;
    gap: 6px;
}
.widget_search .wp-block-search__label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
}
.widget_search .wp-block-search__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #dfe3e8;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}
.widget_search .wp-block-search__button {
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 4px;
    background: #d8232a;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.widget_search .wp-block-search__button:hover {
    background: #b91c22;
}

/* Tab widget (Popular / Recent) */
.theme-widget-tab .widget-tab-header {
    margin-bottom: 16px;
    border-bottom: 1px solid #e6e9ec;
}
.theme-widget-tab .tab-header-list {
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.theme-widget-tab .widget-tab-presentation button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 38px;
    padding: 0;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: #8a9099;
    cursor: pointer;
}
.theme-widget-tab .widget-tab-presentation.active button {
    border-bottom-color: #d8232a;
    color: #d8232a;
}
.theme-widget-tab .tab-content-panel {
    display: none;
}
.theme-widget-tab .tab-content-panel.active {
    display: block;
}
.theme-widget-tab .theme-widget-list .theme-list-post {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px dashed #e9ecef;
}
.theme-widget-tab .entry-image-thumbnail img,
.theme-recent-widget .entry-image-thumbnail img {
    width: 78px;
    height: 62px;
    object-fit: cover;
    border-radius: 3px;
}

/* Fullwidth widget area (Coffee Origins spotlight) */
.fullwidth-widgetarea-top {
    padding: 30px 0;
}
.fullwidth-widgetarea-top .theme-widgetarea-full {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}
.fullwidth-widgetarea-top .theme-widget-title {
    position: relative;
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e6e9ec;
}
.fullwidth-widgetarea-top .theme-widget-title .widget-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #111;
}
.fullwidth-widgetarea-top .theme-widget-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 56px;
    height: 3px;
    background: #d8232a;
}
@media (max-width: 991px) {
.fullwidth-widget-content {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}
.fullwidth-widget-content .widget-panel-1 {
    flex: 0 0 46%;
    max-width: 46%;
}
.fullwidth-widget-content .widget-panel-2 {
    flex: 1 1 auto;
    min-width: 0;
}
.fullwidth-widget-content .widget-story-list {
    display: flex;
    gap: 16px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px dashed #e9ecef;
}
.fullwidth-widget-content .widget-story-list:last-child {
    border-bottom: 0;
    margin-bottom: 0;
}
.fullwidth-widget-content .entry-image-thumbnail img {
    width: 130px;
    height: 96px;
    object-fit: cover;
    border-radius: 3px;
}
}

/* More To Read */
.site-read-more-section {
    padding: 34px 0;
}
.site-read-more-section .theme-default-post .entry-image-small img {
    width: 100%;
    height: auto;
    border-radius: 3px;
}
.site-read-more-section .theme-default-post .entry-title {
    margin: 10px 0 6px;
}

/* You May Also Like */
.site-you-may-like-section {
    padding: 10px 0 40px;
}

/* Hot Topics slider inside sidebar */
.widget-area .theme-widget-slider .swiper-wrapper {
    display: block;
}
.widget-area .theme-widget-slider .swiper-slide + .swiper-slide {
    margin-top: 18px;
}
.widget-area .theme-widget-slider .entry-image-big img {
    width: 100%;
    height: auto;
    border-radius: 3px;
}
.widget-area .theme-widget-slider .entry-title {
    margin: 10px 0 6px;
}

/* Dark mode adjustments for new blocks */
[data-theme="dark"] .widget-area .wp-block-heading,
[data-theme="dark"] .fullwidth-widgetarea-top .theme-widget-title .widget-title {
    color: #f2f2f2;
    border-bottom-color: #333;
}
[data-theme="dark"] .widget-area .wp-block-latest-posts__post-title,
[data-theme="dark"] .widget-area .wp-block-categories-list a {
    color: #e8e8e8;
}
[data-theme="dark"] .widget-area .wp-block-latest-posts__list li,
[data-theme="dark"] .widget-area .wp-block-categories-list li,
[data-theme="dark"] .theme-widget-tab .theme-widget-list .theme-list-post,
[data-theme="dark"] .fullwidth-widget-content .widget-story-list {
    border-bottom-color: #333;
}
[data-theme="dark"] .widget_search .wp-block-search__input {
    background: #1e1e1e;
    border-color: #3a3a3a;
    color: #eee;
}

/* Responsive */
@media (max-width: 900px) {
    .fullwidth-widget-content {
        flex-direction: column;
    }
    .fullwidth-widget-content .widget-panel-1 {
        flex: 1 1 auto;
        max-width: 100%;
    }
}

/* ===== v1.2.2: banner slider height floor (avoid collapse while images load) ===== */
@media (min-width: 992px) {
    .main-banner-slider .swiper-slide {
        min-height: 400px;
    }
}

/* ===== v1.2.4: 修复详情页/列表页「右栏掉到文章底部」 =====
   1) flex 子项默认 min-width:auto，正文大图/宽表格会把主列撑破，右栏被挤出容器
   2) 正文内媒体与宽元素强制不溢出容器 */
#site-content #primary,
#site-content #secondary {
    min-width: 0;
}
#site-content #secondary {
    box-sizing: border-box;
}
.entry-content img,
.entry-content iframe,
.entry-content video,
.entry-content embed,
.entry-content object,
.entry-content svg,
.entry-content .wp-block-image img,
.entry-content figure img {
    max-width: 100%;
    height: auto;
}
.entry-content table,
.entry-content pre {
    max-width: 100%;
    overflow-x: auto;
}
.entry-content {
    overflow-wrap: break-word;
    word-wrap: break-word;
    min-width: 0;
}
/* 窄屏：恢复单列堆叠，右栏在文章下方（正常） */
@media (max-width: 991px) {
    #site-content #primary,
    #site-content #secondary {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
    }
    #site-content #secondary {
        min-height: 0;
    }
}

/* ===== v1.2.5: 修复搜索/列表页标签被压成竖排 =====
   .newsxpress-meta-group 是 nowrap flex，标签一多每项被压缩到 1 字符宽 → 文字竖排 */
.newsxpress-meta-group {
    flex-wrap: wrap;
    row-gap: 0.6rem;
}
.newsxpress-meta-group .nx-tag,
.newsxpress-meta-group .post-date,
.newsxpress-meta-group .newsxpress-meta-author {
    white-space: nowrap;
    flex: 0 0 auto;
}
