/*!
 * Tudao Share Poster (Aquila) — frontend styles
 * 命名空间：.tdsp-*  避免与主题样式冲突
 */

/* ============ Trigger 按钮 ============ */
.tdsp-trigger-wrap {
    margin: 28px 0 16px;
    text-align: center;
}

.tdsp-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 22px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    /* 去渐变、深酒红单色，减少塑料感 */
    background: #b91c1c;
    color: #fff !important;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: 0.06em;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    /* 柔和阴影，不再“漂浮” */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 14px -6px rgba(185, 28, 28, 0.32);
    text-decoration: none;
    -webkit-font-smoothing: antialiased;
}
.tdsp-trigger:hover {
    background: #991b1b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 8px 18px -6px rgba(185, 28, 28, 0.42);
}
.tdsp-trigger:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.tdsp-trigger-icon {
    font-size: 14px;
    line-height: 1;
    opacity: 0.85;
    /* 让彩色 emoji 不那么抢镜头 */
    filter: saturate(0.85);
}
.tdsp-trigger-label {
    font-feature-settings: "palt" 1;
}

/* 浮动按钮 */
.tdsp-trigger-floating {
    position: fixed;
    right: 20px;
    bottom: 80px;
    z-index: 9000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08), 0 12px 24px -8px rgba(185, 28, 28, 0.40);
}
@media (max-width: 720px) {
    .tdsp-trigger-floating {
        right: 14px;
        bottom: 90px;
        padding: 8px 18px;
        font-size: 13px;
    }
}

/* ============ Modal ============ */
.tdsp-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}
.tdsp-modal.tdsp-modal-open {
    display: flex;
    animation: tdsp-fade 200ms ease-out;
}
@keyframes tdsp-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tdsp-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(2px);
    cursor: pointer;
}

.tdsp-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(420px, 92vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.tdsp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}
.tdsp-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #111827;
}

.tdsp-modal-close {
    background: transparent;
    border: 0;
    font-size: 24px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.tdsp-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.tdsp-modal-body {
    padding: 18px 20px;
    overflow: auto;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    background: #f3f4f6;
}

.tdsp-poster-stage {
    /* 海报模板会被 clone 进来用于截图，clone 完毕后立即销毁 */
    position: absolute;
    left: -99999px;
    top: 0;
    pointer-events: none;
    opacity: 0;
}

.tdsp-preview {
    width: 100%;
    text-align: center;
}
.tdsp-preview img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 10px;
    box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.2);
    display: block;
    margin: 0 auto;
}
.tdsp-tip {
    margin: 12px 0 0;
    color: #6b7280;
    font-size: 13px;
}

/* loading */
.tdsp-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: #4b5563;
    font-size: 14px;
}
.tdsp-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #ef4444;
    border-radius: 50%;
    animation: tdsp-spin 0.8s linear infinite;
}
@keyframes tdsp-spin {
    to { transform: rotate(360deg); }
}

/* error */
.tdsp-error {
    color: #b91c1c;
    text-align: center;
}

.tdsp-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.tdsp-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 0;
    cursor: pointer;
    line-height: 1.2;
    text-decoration: none;
    transition: all 0.15s ease;
}
.tdsp-btn-primary {
    background: #ef4444;
    color: #fff !important;
}
.tdsp-btn-primary:hover {
    background: #dc2626;
}
.tdsp-btn-ghost {
    background: #f3f4f6;
    color: #374151 !important;
}
.tdsp-btn-ghost:hover {
    background: #e5e7eb;
}

body.tdsp-noscroll {
    overflow: hidden;
}

/* ============ Classic 海报模板 ============ */
.tdsp-poster {
    /* 模板根容器：固定 750x1334 px (iPhone 标准) */
    width: 750px;
    height: 1334px;
    box-sizing: border-box;
    position: relative;
    /* 改为 flex column 让 main 自动填充剩余空间，避免特色图下方留白 */
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, var(--tdsp-grad-start, #1f2937) 0%, var(--tdsp-grad-end, #111827) 100%);
    color: var(--tdsp-text-on-dark, #fff);
    font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
    overflow: hidden;
}

/* 装饰：右上角光晕 */
.tdsp-poster::before {
    content: "";
    position: absolute;
    top: -120px;
    right: -120px;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--tdsp-primary, #ef4444) 0%, transparent 65%);
    opacity: 0.45;
    pointer-events: none;
}
/* 装饰：左下角光晕 */
.tdsp-poster::after {
    content: "";
    position: absolute;
    bottom: -180px;
    left: -120px;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--tdsp-primary, #ef4444) 0%, transparent 65%);
    opacity: 0.3;
    pointer-events: none;
}

/* 顶部 */
.tdsp-poster__header {
    position: relative;
    padding: 56px 60px 26px;
    display: flex;
    align-items: center;
    gap: 18px;
    z-index: 2;
}
.tdsp-poster__logo {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    object-fit: contain;
    background: rgba(255,255,255,0.08);
    padding: 6px;
}
.tdsp-poster__brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tdsp-poster__brand-name {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 1px;
}
.tdsp-poster__brand-subtitle {
    font-size: 18px;
    opacity: 0.75;
}

/* 主内容 */
.tdsp-poster__main {
    position: relative;
    padding: 18px 60px 24px;
    z-index: 2;
    /* flex: 1 让 main 撑满 header 与 footer 之间的所有空间 */
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0; /* flex 子元素 overflow 修正 */
}
.tdsp-poster__category {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    height: 38px;
    padding: 0 18px;
    border-radius: 999px;
    background: var(--tdsp-primary, #ef4444);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    white-space: nowrap;
    margin-bottom: 24px;
    box-shadow: 0 8px 18px -10px var(--tdsp-primary, #ef4444);
}
.tdsp-poster__title {
    font-size: 42px;
    font-weight: 800;
    line-height: 1.34;
    margin: 0 0 18px;
    color: #fff;
    letter-spacing: 0;
    white-space: pre-line;
    overflow-wrap: normal;
    word-break: normal;
    text-wrap: balance;
    overflow: visible;
}
.tdsp-poster__excerpt {
    font-size: 21px;
    line-height: 1.52;
    color: rgba(255,255,255,0.8);
    margin: 0 0 20px;
    letter-spacing: 0;
    /* 限制最多 4 行 */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 特色图：flex: 1 自动撑满剩余空间，杜绝下方留白 */
.tdsp-poster__thumb-wrap {
    width: 100%;
    flex: 1 1 auto;
    min-height: 360px;
    max-height: 620px;
    border-radius: 16px;
    overflow: hidden;
    margin: 10px 0 18px;
    background: rgba(255,255,255,0.08);
    box-shadow: 0 18px 36px -16px rgba(0,0,0,0.55);
}
.tdsp-poster__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 作者 */
.tdsp-poster__author {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 4px 0 0;
    flex: 0 0 auto;
}
.tdsp-poster__avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    object-fit: cover;
}
.tdsp-poster__author-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tdsp-poster__author-name {
    font-size: 22px;
    font-weight: 600;
    color: #fff;
}
.tdsp-poster__author-date {
    font-size: 17px;
    opacity: 0.65;
}

/* 底部 QR：从 absolute 改为 flex 流内元素，与 main 自然衔接 */
.tdsp-poster__footer {
    position: relative;
    margin: 0 60px 46px;
    z-index: 2;
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: rgba(255,255,255,0.96);
    border-radius: 20px;
    color: #111827;
    box-shadow: 0 12px 24px -8px rgba(0,0,0,0.35);
}
.tdsp-poster__qr {
    width: 170px;
    height: 170px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 10px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tdsp-poster__qr img,
.tdsp-poster__qr canvas {
    width: 100%;
    height: 100%;
    display: block;
}
.tdsp-poster__qr-side {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.tdsp-poster__qr-caption {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
}
.tdsp-poster__qr-tip {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
}
.tdsp-poster__footer-text {
    font-size: 15px;
    color: #4b5563;
    line-height: 1.45;
    margin: 0;
}
.tdsp-poster__qr-domain {
    font-size: 17px;
    color: var(--tdsp-primary, #ef4444);
    font-weight: 600;
    margin-top: 6px;
}

/* 装饰条（内嵌主色） */
.tdsp-poster__accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--tdsp-primary, #ef4444);
    z-index: 3;
}
