/**
 * Activity Bar - Frontend Stylesheet
 * Top notification bar with carousel, popup, and responsive support
 * CSS classes match the PHP-rendered HTML structure
 */

/* ========================================
   Notification Bar Container
   ======================================== */
.abar-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    /* H5 刘海：padding 加在栏高外侧（content-box），避免主题全局 border-box 把安全区算进固定高度 */
    box-sizing: content-box;
    padding-top: env(safe-area-inset-top, 0px);
    height: var(--abar-height, 48px);
    background: var(--abar-bg, #1a73e8);
    color: var(--abar-text, #ffffff);
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 高于主题菜单，但低于 WP admin bar（99999），避免后台管理栏被遮住 */
    z-index: 99998;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
}

/* Bar hidden state - slides up and fades out */
.abar-bar.abar-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

/* ========================================
   Body Spacing
   ======================================== */
/* 正文区上移量：由 JS 测量栏在视口中的实际下边沿（含 admin bar 下推后的情况），回退为 --abar-height */
body.abar-has-bar {
    padding-top: var(--abar-viewport-spacer, var(--abar-height, 48px));
    transition: padding-top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body.abar-closed {
    padding-top: 0 !important;
}

body.abar-has-bar .etheme-elementor-off-canvas__container[data-abar-panel-adjusted="1"] {
    top: var(--abar-panel-top, var(--wp-admin--admin-bar--height, 0px)) !important;
    height: calc(100dvh - var(--abar-panel-top, var(--wp-admin--admin-bar--height, 0px))) !important;
    z-index: 99997 !important;
}

/* 登录态保留 WP 管理栏可见，不与通知栏重叠 */
body.admin-bar .abar-bar {
    top: 32px;
}
@media screen and (max-width: 782px) {
    body.admin-bar .abar-bar {
        top: 46px;
    }
}

/* ========================================
   Bar Inner Container
   ======================================== */
.abar-bar-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Carousel Container
   ======================================== */
.abar-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    /* pan-y 会导致部分浏览器把横向滑动手势交给默认行为，轮播划不动；由脚本处理横滑，栏很薄竖向滚动可从栏外开始 */
    touch-action: none;
}

.abar-bar.abar-is-swiping {
    cursor: grabbing;
    user-select: none;
    -webkit-user-select: none;
}

.abar-carousel-track {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Slide (Activity Item)
   ======================================== */
.abar-slide {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease,
                transform 0.5s ease,
                visibility 0s 0.5s;
    transform: translateX(40px);
    /* 默认全宽；标准条另行为关闭按钮留空，见下方 :not(.abar-slide--image-only) */
    padding: 0;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

/* 标准条不再在 slide 上设横向 padding（否则背景图 layer 跟着缩进，两侧露底色）；内边距改到 .abar-slide-foreground */
.abar-slide:not(.abar-slide--image-only) {
    padding: 0;
}

/* Current active slide */
.abar-slide.abar-active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition: opacity 0.5s ease,
                transform 0.5s ease,
                visibility 0s 0s;
}

/* Previous slide sliding out to the left */
.abar-slide.abar-prev {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-40px);
    transition: opacity 0.5s ease,
                transform 0.5s ease,
                visibility 0s 0.5s;
}

/* ========================================
   Slide Content
   ======================================== */
.abar-slide-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.abar-slide-hit {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* touch-action 不继承；链接/按钮默认为 auto 会抢走横滑，与整图 hit 行为对齐 */
    touch-action: none;
}

a.abar-slide-hit,
button.abar-slide-hit {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    /* 桌面端整行 <a> 默认可拖，会抢横滑并出现「拖链接」幽灵图 */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

a.abar-slide-hit:hover,
button.abar-slide-hit:hover {
    text-decoration: none;
    color: inherit;
}

a.abar-slide-hit:focus-visible,
button.abar-slide-hit:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: -2px;
}

/* ========================================
   Slide Image
   ======================================== */
.abar-slide-image {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 100%;
    max-height: 30px;
    line-height: 0;
}

.abar-slide-image img {
    display: block;
    max-height: 30px;
    width: auto;
    object-fit: contain;
    vertical-align: middle;
}

/* ========================================
   Slide Text
   ======================================== */
/* inline-flex + baseline：换行时 Emoji 与首行文字对齐，而不是垂直居中整块文案 */
.abar-slide-text {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35em;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
}

.abar-slide-icon {
    flex-shrink: 0;
    line-height: 1;
}

/* 不铺独立底色；整块由 .abar-bar 的 --abar-bg 打底，背景图在 hit 内通栏铺满 */
.abar-slide-content--standard {
    align-items: center;
    justify-content: center;
    min-height: 100%;
    align-self: stretch;
    padding: 0;
    background: transparent;
}

/* 仅有背景图时也不再加一层写死冷色，对比度只靠底图 + .abar-slide-bg-overlay */
.abar-slide-content--with-bg {
    background: transparent;
}

.abar-slide-bg-img,
.abar-slide-bg-overlay {
    position: absolute;
    inset: 0;
}

.abar-slide-bg-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.abar-slide-bg-overlay {
    background: rgba(0, 0, 0, 0.42);
    pointer-events: none;
}

.abar-slide-foreground {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* 仅标准条：前景为关闭钮与安全区留白；背景图在父级 hit 上通栏 */
.abar-slide-content--standard .abar-slide-foreground {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(44px, calc(12px + env(safe-area-inset-right, 0px)));
    box-sizing: border-box;
}

/* 不让文案占满剩余宽度，否则会把按钮顶到最右侧，看起来「不居中」 */
.abar-slide-content--standard .abar-slide-text {
    min-width: 0;
    flex: 0 1 auto;
    max-width: 100%;
}

.abar-slide-content--standard .abar-slide-btn {
    flex-shrink: 0;
    pointer-events: none;
}

/* ========================================
   Full-width image banner slide
   ======================================== */
.abar-slide--image-only {
    white-space: normal;
}

.abar-slide-content--banner {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
    line-height: 0;
}

/* 链接 / 按钮 / 静态容器：整块可点或可聚焦 */
.abar-slide-banner-hit {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    line-height: 0;
    text-align: center;
    border-radius: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

a.abar-slide-banner-hit:hover {
    opacity: 0.95;
}

button.abar-slide-banner-hit:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: -2px;
}

/* 铺满当前栏高的横幅图（栏高含 Settings 里的 Image banner height） */
.abar-slide-banner-img {
    display: block;
    width: 100%;
    height: var(--abar-height, 48px);
    object-fit: cover;
    object-position: center center;
    vertical-align: bottom;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* ========================================
   CTA Button (Slide Button)
   ======================================== */
.abar-slide-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 14px;
    background: var(--abar-btn-bg, #ffffff);
    color: var(--abar-btn-text, #1a73e8);
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: opacity 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
    line-height: 1.4;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.abar-slide-btn:hover {
    opacity: 0.85;
    transform: scale(1.03);
    text-decoration: none;
    color: var(--abar-btn-text, #1a73e8);
}

.abar-slide-btn:visited,
.abar-slide-btn:focus,
.abar-slide-btn:focus-visible,
.abar-slide-btn:active {
    color: var(--abar-btn-text, #1a73e8);
    text-decoration: none;
}

.abar-slide-btn:active {
    transform: scale(0.97);
}

/* ========================================
   Close Button
   ======================================== */
.abar-close-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    line-height: 1;
    padding: 0 4px;
    z-index: 20;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.abar-close-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.abar-close-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: -2px;
}

/* ========================================
   Dot Indicators (Carousel Dots)
   ======================================== */
.abar-carousel-dots {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 2;
}

.abar-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: transparent;
    transition: transform 0.2s ease;
    cursor: pointer;
    border: none;
    padding: 0;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.abar-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transition: background 0.3s ease, transform 0.2s ease;
}

.abar-dot:hover {
    transform: scale(1.04);
}

.abar-dot.abar-dot-active {
    transform: scale(1.08);
}

.abar-dot.abar-dot-active::before {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.15);
}

.abar-dot:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Hide dots when only one activity */
.abar-bar.abar-single .abar-carousel-dots {
    display: none;
}

/* ========================================
   Popup Overlay
   ======================================== */
.abar-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    background: rgba(12, 16, 26, 0.56);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 2147483600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    /* Pad / 手机：刘海与底部手势区；长内容可在遮罩层滚动 */
    padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(16px, env(safe-area-inset-bottom, 0px)) 12px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.abar-popup-overlay.abar-popup-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s 0s;
}

/* ========================================
   Popup Content
   ======================================== */
.abar-popup-content {
    position: relative;
    background: linear-gradient(180deg, #ffffff 0%, #fcfcfd 100%);
    color: #2a2f38;
    border-radius: 16px;
    border: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: 0 24px 56px rgba(10, 16, 28, 0.24), 0 8px 24px rgba(10, 16, 28, 0.14);
    max-width: min(480px, 100%);
    width: min(92vw, 480px);
    max-height: min(85vh, calc(100vh - max(48px, env(safe-area-inset-top, 0px)) - max(32px, env(safe-area-inset-bottom, 0px))));
    padding: clamp(20px, 4vw, 32px);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 1;
    min-height: 0;
    margin-block: auto;
}

.abar-popup-overlay.abar-popup-visible .abar-popup-content {
    transform: scale(1) translateY(0);
}

/* Popup close button */
.abar-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.1);
    font-size: 22px;
    color: #6b7280;
    cursor: pointer;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    line-height: 1;
}

.abar-popup-close:hover {
    background: rgba(233, 69, 96, 0.12);
    color: #e94560;
    transform: translateY(-1px);
}

.abar-popup-close:focus-visible {
    outline: 2px solid #e94560;
    outline-offset: -2px;
}

/* Popup body content */
.abar-popup-body {
    font-size: 15px;
    color: #3f4754;
    line-height: 1.72;
    margin: 0;
    padding-top: 10px;
    padding-right: 28px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.abar-popup-body > :first-child {
    margin-top: 0;
}

.abar-popup-body > :last-child {
    margin-bottom: 0;
}

.abar-popup-body h1,
.abar-popup-body h2,
.abar-popup-body h3,
.abar-popup-body h4 {
    color: #1f2937;
    line-height: 1.35;
    margin-bottom: 0.55em;
}

.abar-popup-body p,
.abar-popup-body ul,
.abar-popup-body ol,
.abar-popup-body blockquote {
    margin-top: 0;
    margin-bottom: 0.85em;
}

.abar-popup-body a {
    color: #e94560;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.abar-popup-body a:hover {
    color: #cf2947;
}

/* 后台富文本里的媒体：不超宽、不强行压扁拉高（保持比例） */
.abar-popup-body img,
.abar-popup-body video,
.abar-popup-body svg {
    max-width: 100%;
    height: auto;
}

.abar-popup-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
}

/* ========================================
   Responsive - Tablet (<=768px)
   ======================================== */
@media (max-width: 768px) {
    /* 仅有「文案条」时在平板压矮；含整图横幅时保留服务端下发的 --abar-height，避免横幅被竖条压瘪 */
    .abar-bar:not(.abar-bar--has-image-banner) {
        font-size: 12px;
        height: 42px !important;
    }

    body.abar-has-bar:not(.abar-has-banner-slide) {
        padding-top: var(--abar-viewport-spacer, 42px) !important;
    }

    body.abar-has-banner-slide.abar-has-bar {
        padding-top: var(--abar-viewport-spacer, var(--abar-height, 72px)) !important;
    }

    .abar-bar.abar-bar--has-image-banner {
        font-size: 12px;
        /* height 沿用内联变量，由插件根据整图栏高计算 */
    }

    /* 文案轮播在小屏允许换行，避免一行撑爆 */
    .abar-slide:not(.abar-slide--image-only) {
        white-space: normal;
        gap: 8px;
        font-size: 12px;
        text-align: center;
    }

    .abar-slide-content--standard .abar-slide-foreground {
        padding-left: max(10px, env(safe-area-inset-left, 0px));
        padding-right: max(40px, calc(8px + env(safe-area-inset-right, 0px)));
    }

    .abar-slide:not(.abar-slide--image-only) .abar-slide-content {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .abar-slide-foreground {
        gap: 8px;
        flex-wrap: wrap;
    }

    .abar-slide-content--standard .abar-slide-text {
        justify-content: center;
    }

    .abar-slide-image {
        max-height: 24px;
    }

    .abar-slide-image img {
        max-height: 24px;
    }

    .abar-slide-btn {
        padding: 3px 10px;
        font-size: 11px;
    }

    .abar-close-btn {
        right: 8px;
        font-size: 18px;
        width: 24px;
        height: 24px;
    }

    .abar-popup-content {
        width: min(94vw, 440px);
        border-radius: 14px;
    }

    .abar-popup-body {
        font-size: 14px;
        padding-right: 24px;
    }
}

/* ========================================
   Responsive - Mobile (<=480px)
   ======================================== */
@media (max-width: 480px) {
    .abar-bar:not(.abar-bar--has-image-banner) {
        font-size: 11px;
        height: 38px !important;
    }

    body.abar-has-bar:not(.abar-has-banner-slide) {
        padding-top: var(--abar-viewport-spacer, 38px) !important;
    }

    body.abar-has-banner-slide.abar-has-bar {
        padding-top: var(--abar-viewport-spacer, var(--abar-height, 72px)) !important;
    }

    .abar-slide:not(.abar-slide--image-only) {
        gap: 6px;
    }

    .abar-slide-content--standard .abar-slide-foreground {
        padding-left: max(8px, env(safe-area-inset-left, 0px));
        padding-right: max(38px, calc(6px + env(safe-area-inset-right, 0px)));
    }

    .abar-slide:not(.abar-slide--image-only) .abar-slide-content {
        gap: 6px;
    }

    .abar-slide-foreground {
        gap: 6px;
    }

    .abar-slide-image {
        max-height: 20px;
    }

    .abar-slide-image img {
        max-height: 20px;
    }

    /* Hide images on very small screens to save space */
    .abar-bar.abar-hide-images .abar-slide-image {
        display: none;
    }

    .abar-slide-btn {
        padding: 2px 8px;
        font-size: 10px;
    }

    .abar-close-btn {
        right: 6px;
        font-size: 16px;
        width: 22px;
        height: 22px;
    }

    .abar-dot {
        width: 30px;
        height: 30px;
    }

    .abar-dot::before {
        width: 7px;
        height: 7px;
    }

    .abar-popup-content {
        width: min(94vw, 100%);
        max-height: min(88vh, calc(100dvh - 40px));
        padding: clamp(16px, 4vw, 22px);
        border-radius: 12px;
    }

    .abar-popup-body {
        font-size: 13px;
    }

    .abar-popup-close {
        top: max(8px, env(safe-area-inset-top, 8px));
        right: 8px;
        font-size: 20px;
        width: 32px;
        height: 32px;
    }
}
