/* =========================================================
   XiaoXiao Media Gallery — Frontend Styles
   设计原则：高级感网格 + 玻璃态弹窗 + 流畅微交互
   全程不使用 !important，全部用特异性与层叠控制
   ========================================================= */

:root {
    --xx-accent: #ff6b9d;
    --xx-title: #ffffff;
    --xx-overlay: rgba(20, 16, 32, 0.55);
    --xx-cols: 2;
    --xx-gap: 16px;
    --xx-card-radius: 16px;
}

/* ---------- 筛选栏 ---------- */
.xx-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.xx-filter__btn {
    appearance: none;
    border: 1px solid color-mix(in srgb, var(--xx-accent) 35%, transparent);
    background: transparent;
    color: var(--xx-accent);
    padding: 9px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
    cursor: pointer;
    transition: background .3s cubic-bezier(.16, 1, .3, 1),
                color .3s ease,
                transform .3s cubic-bezier(.16, 1, .3, 1),
                box-shadow .3s ease;
}

.xx-filter__btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--xx-accent) 25%, transparent);
}

.xx-filter__btn.is-active {
    background: var(--xx-accent);
    color: #fff;
    border-color: var(--xx-accent);
    box-shadow: 0 10px 26px color-mix(in srgb, var(--xx-accent) 35%, transparent);
}

/* 标签按钮：虚线边框区分，更轻量 */
.xx-filter__btn--tag {
    border-style: dashed;
    opacity: .85;
}

.xx-filter__btn--tag:hover,
.xx-filter__btn--tag.is-active {
    opacity: 1;
    border-style: solid;
}

/* 分类与标签之间的分隔符 */
.xx-filter__sep {
    display: inline-block;
    width: 1px;
    height: 24px;
    background: rgba(20, 16, 32, .12);
    margin: 0 4px;
    align-self: center;
}

/* ---------- 网格 ---------- */
.xx-grid {
    display: grid;
    grid-template-columns: repeat(var(--xx-cols), 1fr);
    gap: var(--xx-gap);
}

.xx-card {
    position: relative;
    border-radius: var(--xx-card-radius);
    overflow: hidden;
    cursor: pointer;
    background: #f2f2f5;
    transform: translateZ(0);
    transition: transform .45s cubic-bezier(.16, 1, .3, 1),
                box-shadow .45s ease;
    outline: none;
}

.xx-card:hover,
.xx-card:focus-visible {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(20, 16, 32, .18);
}

.xx-card__media {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.xx-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .7s cubic-bezier(.16, 1, .3, 1);
}

.xx-card:hover .xx-card__img,
.xx-card:focus-visible .xx-card__img {
    transform: scale(1.08);
}

.xx-card__placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, color-mix(in srgb, var(--xx-accent) 30%, #ddd), #eee);
}

/* ---------- 卡片底部浮层：标题(左) + 点赞/评论(右) ---------- */
.xx-card__overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 16px 14px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, .62) 0%, rgba(0, 0, 0, .12) 60%, transparent 100%);
    z-index: 2;
}

.xx-card__title {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    text-shadow: 0 1px 6px rgba(0, 0, 0, .45);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 操作栏：点赞(实心红心) + 评论(实心气泡) */
.xx-card__actions {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.xx-card__like,
.xx-card__comment {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, .9);
    font-size: 13px;
    font-weight: 600;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 999px;
    transition: color .25s ease, background .25s ease, transform .25s cubic-bezier(.16, 1, .3, 1);
}

.xx-card__like:hover,
.xx-card__comment:hover {
    color: #fff;
    background: rgba(255, 255, 255, .18);
    transform: translateY(-1px);
}

/* 实心红心图标默认填充色 */
.xx-card__like .xx-icon-heart path {
    fill: currentColor;
}

.xx-card__like.is-liked .xx-icon-heart path {
    fill: #ff4d6f;
}

.xx-card__like.is-liked {
    color: #ff4d6f;
}

/* 评论气泡实心 */
.xx-card__comment svg path:first-of-type {
    fill: currentColor;
}

.xx-card__count {
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}

.xx-card__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: color-mix(in srgb, var(--xx-accent) 90%, #000 0%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
    transition: transform .4s cubic-bezier(.16, 1, .3, 1);
}

.xx-card:hover .xx-card__play {
    transform: translate(-50%, -50%) scale(1.12);
}

.xx-card.is-hidden {
    display: none;
}

/* ---------- 弹窗 ---------- */
.xx-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .35s ease, visibility .35s ease;
}

.xx-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.xx-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(12, 10, 18, .55);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
}

.xx-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(960px, 100%);
    max-height: 90vh;
    overflow: auto;
    border-radius: 24px;
    padding: 0;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, .5);
    box-shadow: 0 40px 90px rgba(12, 10, 18, .4);
    transform: translateY(26px) scale(.97);
    transition: transform .45s cubic-bezier(.16, 1, .3, 1);
}

.xx-modal.is-open .xx-modal__dialog {
    transform: none;
}

/* 统一重置插件内所有按钮，避免继承 Astra 主题全局 button 的原生外观（appearance/font） */
.xx-card__like,
.xx-card__comment,
.xx-detail__like,
.xx-filter__btn,
.xx-page,
.xx-comment-form__submit,
.xx-modal__close {
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
}

/* 关闭按钮：提高特异性并重置，避免与 Astra 主题全局 button 样式（padding/appearance/min-width）冲突 */
.xx-modal__close.xx-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    min-width: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #1f1f1f;
    background: none;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
    font: inherit;
    line-height: normal;
    transition: color .25s ease, background .25s ease, transform .3s ease;
}

.xx-modal__close.xx-modal__close:hover {
    color: #333;
    background: rgba(0, 0, 0, .06);
    transform: rotate(90deg);
}

.xx-modal__body {
    padding: 0;
}

/* ---------- 详情布局（全文 + 评论，单列） ---------- */
.xx-detail {
    display: block;
    padding: 0;
}

.xx-detail__info {
    padding: 28px 56px 28px 26px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.xx-detail__title {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: #1c1830;
}

.xx-detail__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.xx-detail__like {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #6a6380;
    font-size: 15px;
    font-weight: 700;
    background: rgba(20, 16, 32, .05);
    border: none;
    cursor: pointer;
    padding: 9px 16px;
    border-radius: 999px;
    transition: color .3s ease, background .3s ease, transform .3s cubic-bezier(.16, 1, .3, 1);
}

.xx-detail__like:hover {
    color: var(--xx-accent);
    transform: translateY(-2px);
}

.xx-detail__like.is-liked {
    color: var(--xx-accent);
    background: color-mix(in srgb, var(--xx-accent) 14%, transparent);
}

.xx-detail__like.is-liked .xx-icon-heart path {
    fill: var(--xx-accent);
}

.xx-detail__like .xx-icon-heart {
    transition: transform .3s cubic-bezier(.16, 1, .3, 1);
}

.xx-detail__like:hover .xx-icon-heart {
    transform: scale(1.15);
}

/* 文章正文排版（文字 + 图片 + 视频自动呈现） */
.xx-detail__content {
    font-size: 15px;
    line-height: 1.8;
    color: #3a3448;
}

.xx-detail__content p {
    margin: 0 0 14px;
}

.xx-detail__content img {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
    margin: 8px 0;
}

.xx-detail__content a {
    color: var(--xx-accent);
}

/* 视频 / 嵌入自动响应式 */
.xx-detail__content .wp-block-embed__wrapper,
.xx-detail__content iframe,
.xx-detail__content video {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 14px;
    margin: 8px 0;
    display: block;
}

/* ---------- 评论 ---------- */
.xx-comments {
    margin-top: 8px;
    border-top: 1px solid rgba(20, 16, 32, .08);
    padding-top: 16px;
}

.xx-comments__title {
    font-size: 16px;
    font-weight: 700;
    color: #1c1830;
    margin: 0 0 12px;
}

.xx-comment-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.xx-comment {
    display: flex;
    gap: 12px;
}

.xx-comment__avatar img {
    border-radius: 50%;
    display: block;
}

.xx-comment__body {
    flex: 1;
}

.xx-comment__meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 4px;
}

.xx-comment__author {
    font-weight: 700;
    font-size: 14px;
    color: #1c1830;
}

.xx-comment__date {
    font-size: 12px;
    color: #9a93a8;
}

.xx-comment__content {
    font-size: 14px;
    line-height: 1.65;
    color: #3a3448;
    background: rgba(20, 16, 32, .04);
    padding: 10px 14px;
    border-radius: 14px;
}

.xx-comment-empty {
    font-size: 13px;
    color: #9a93a8;
    margin: 0 0 16px;
}

/* 评论表单 */
.xx-comment-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.xx-comment-form__row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.xx-comment-form__input,
.xx-comment-form__textarea {
    width: 100%;
    border: 1px solid rgba(20, 16, 32, .12);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    background: rgba(255, 255, 255, .8);
    color: #1c1830;
    transition: border-color .3s ease, box-shadow .3s ease;
}

.xx-comment-form__row .xx-comment-form__input {
    flex: 1;
    min-width: 160px;
}

.xx-comment-form__input:focus,
.xx-comment-form__textarea:focus {
    outline: none;
    border-color: var(--xx-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--xx-accent) 22%, transparent);
}

.xx-comment-form__textarea {
    resize: vertical;
}

.xx-comment-form__loggedin {
    font-size: 13px;
    color: #6a6380;
    margin: 0;
}

.xx-comment-form__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.xx-comment-form__status {
    font-size: 13px;
    color: var(--xx-accent);
}

.xx-comment-form__submit {
    appearance: none;
    border: none;
    cursor: pointer;
    background: var(--xx-accent);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    padding: 11px 24px;
    border-radius: 999px;
    transition: transform .3s cubic-bezier(.16, 1, .3, 1), box-shadow .3s ease, opacity .3s ease;
}

.xx-comment-form__submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px color-mix(in srgb, var(--xx-accent) 38%, transparent);
}

.xx-comment-form__submit:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

/* honey trap 防机器人（绝不使用 !important） */
.xxmg-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* 加载指示 */
.xx-modal__loading {
    padding: 60px 20px;
    text-align: center;
    color: #6a6380;
    font-size: 14px;
}

.xx-spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 14px;
    border: 3px solid rgba(20, 16, 32, .15);
    border-top-color: var(--xx-accent);
    border-radius: 50%;
    animation: xx-spin .8s linear infinite;
}

@keyframes xx-spin {
    to { transform: rotate(360deg); }
}

.xx-empty {
    padding: 30px;
    text-align: center;
    color: #9a93a8;
    font-size: 14px;
}

/* ---------- 数字分页 ---------- */
.xx-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 28px;
}

.xx-page {
    appearance: none;
    border: 1px solid rgba(20, 16, 32, .12);
    background: transparent;
    color: #3a3448;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    padding: 0 10px;
    transition: background .25s ease,
                color .25s ease,
                border-color .25s ease,
                transform .25s cubic-bezier(.16, 1, .3, 1);
}

.xx-page:hover {
    background: var(--xx-accent, #ff6b9d);
    color: #fff;
    border-color: var(--xx-accent, #ff6b9d);
    transform: translateY(-2px);
}

.xx-page.is-active {
    background: var(--xx-accent, #ff6b9d);
    color: #fff;
    border-color: var(--xx-accent, #ff6b9d);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--xx-accent, #ff6b9d) 35%, transparent);
}

.xx-page__dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    font-size: 15px;
    color: #9a93a8;
    user-select: none;
}

/* ---------- 响应式 ---------- */
/* 桌面端默认 --xx-cols:2 已在 :root 定义；以下为断点兜底，
   widget 内联 <style> 会按控件值覆盖同变量，优先级更高 */
@media (max-width: 1024px) {
    .xx-grid {
        --xx-cols: 2;
    }
}
@media (max-width: 767px) {
    .xx-grid {
        --xx-cols: 1;
    }
}
@media (max-width: 560px) {
    .xx-modal {
        padding: 0;
    }
    .xx-modal__dialog {
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }
    .xx-pagination {
        gap: 6px;
        margin-top: 20px;
    }
    .xx-page {
        min-width: 34px;
        height: 34px;
        font-size: 13px;
    }
}

/* ---------- 暗色模式 ---------- */
@media (prefers-color-scheme: dark) {
    .xx-card {
        background: #1a1726;
    }
    .xx-card__overlay {
        background: linear-gradient(to top, rgba(0, 0, 0, .72) 0%, rgba(0, 0, 0, .2) 55%, transparent 100%);
    }
    .xx-card__like,
    .xx-card__comment {
        color: rgba(255, 255, 255, .85);
    }
    .xx-detail__like {
        color: #cfc9e0;
        background: rgba(255, 255, 255, .08);
    }
    .xx-modal__dialog {
        background: rgba(26, 23, 38, .92);
        border-color: rgba(255, 255, 255, .08);
        color: #ece9f5;
    }
    .xx-modal__close.xx-modal__close {
        color: #fff;
        background: none;
    }
    .xx-modal__close.xx-modal__close:hover {
        color: #fff;
        background: rgba(255, 255, 255, .1);
    }
    .xx-detail__title,
    .xx-comments__title,
    .xx-comment__author {
        color: #f3f0fb;
    }
    .xx-detail__content,
    .xx-comment__content {
        color: #cfc9e0;
    }
    .xx-comment__content {
        background: rgba(255, 255, 255, .06);
    }
    .xx-comment-form__input,
    .xx-comment-form__textarea {
        background: rgba(255, 255, 255, .06);
        border-color: rgba(255, 255, 255, .14);
        color: #f3f0fb;
    }
    .xx-comments {
        border-top-color: rgba(255, 255, 255, .1);
    }
}

/* 尊重「减少动效」偏好（靠层叠顺序覆盖，不使用 !important） */
@media (prefers-reduced-motion: reduce) {
    .xx-card,
    .xx-card__img,
    .xx-modal,
    .xx-modal__dialog,
    .xx-filter__btn {
        transition-duration: 0.001ms;
        animation-duration: 0.001ms;
        animation-iteration-count: 1;
    }
}
