/* =============================================================
   每日一言 · Liquid Glass 液态玻璃样式
   模块划分：
   1. 设计令牌（CSS 变量 / 主题）
   2. 基础重置
   3. 背景层（流动光斑 + 噪点）
   4. 舞台布局
   5. 顶部栏 / 品牌 / 主题按钮
   6. 玻璃卡片
   7. 按钮区
   8. 加载骨架 / 错误提示
   9. 页脚
   10. 动画
   11. 响应式
   ============================================================= */

/* ============================================================
   1. 设计令牌
   ============================================================ */
:root {
    /* 字体 */
    --font-display: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
    --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "Microsoft YaHei", sans-serif;

    /* 尺寸 */
    --card-max: 720px;
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-pill: 999px;

    /* 玻璃材质 */
    --glass-bg: rgba(255, 255, 255, 0.32);
    --glass-bg-strong: rgba(255, 255, 255, 0.5);
    --glass-border: rgba(255, 255, 255, 0.55);
    --glass-highlight: rgba(255, 255, 255, 0.75);
    --glass-blur: 22px;
    --glass-shadow: 0 20px 60px -20px rgba(31, 38, 80, 0.35),
        0 8px 24px -12px rgba(31, 38, 80, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);

    /* 文字 */
    --text-strong: #1a1f3a;
    --text: #2b3252;
    --text-muted: #5a6080;
    --text-faint: #8a90b0;

    /* 背景渐变（浅色：冰蓝 / 薰衣草 / 蜜桃） */
    --bg-base: #eef2ff;
    --blob-1: #a5c9ff;
    --blob-2: #c4b5ff;
    --blob-3: #ffd6c4;
    --blob-4: #b9f0e8;

    /* 强调色 */
    --accent: #6d5cff;
    --accent-soft: rgba(109, 92, 255, 0.16);

    /* 骨架 */
    --skeleton: rgba(255, 255, 255, 0.55);

    /* 动效时长 */
    --t-fast: 0.25s;
    --t-base: 0.45s;
    --t-slow: 0.8s;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* 深色模式令牌 */
[data-theme="dark"] {
    --glass-bg: rgba(28, 30, 54, 0.42);
    --glass-bg-strong: rgba(40, 44, 74, 0.6);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-highlight: rgba(255, 255, 255, 0.22);
    --glass-shadow: 0 24px 70px -24px rgba(0, 0, 0, 0.65),
        0 8px 28px -14px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);

    --text-strong: #f4f6ff;
    --text: #d8dcf2;
    --text-muted: #a0a6c8;
    --text-faint: #6c7299;

    /* 深色背景：深靛 / 夜紫 / 墨蓝 */
    --bg-base: #0b0e22;
    --blob-1: #2a2a8a;
    --blob-2: #5b2a9e;
    --blob-3: #1d4ed8;
    --blob-4: #0e7490;

    --accent: #9d8bff;
    --accent-soft: rgba(157, 139, 255, 0.2);

    --skeleton: rgba(255, 255, 255, 0.12);
}

/* ============================================================
   2. 基础重置
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--bg-base);
    overflow-x: hidden;
    position: relative;
    transition: background-color var(--t-base) var(--ease),
        color var(--t-base) var(--ease);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

/* ============================================================
   3. 背景层
   ============================================================ */
.background {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--bg-base);
    transition: background-color var(--t-base) var(--ease);
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.85;
    will-change: transform;
    mix-blend-mode: screen;
}

[data-theme="dark"] .blob {
    opacity: 0.7;
    mix-blend-mode: screen;
}

.blob--1 {
    width: 46vw;
    height: 46vw;
    background: var(--blob-1);
    top: -10vw;
    left: -8vw;
    animation: drift1 22s var(--ease) infinite alternate;
}

.blob--2 {
    width: 40vw;
    height: 40vw;
    background: var(--blob-2);
    top: 8vh;
    right: -12vw;
    animation: drift2 26s var(--ease) infinite alternate;
}

.blob--3 {
    width: 38vw;
    height: 38vw;
    background: var(--blob-3);
    bottom: -12vw;
    left: 18vw;
    animation: drift3 24s var(--ease) infinite alternate;
}

.blob--4 {
    width: 30vw;
    height: 30vw;
    background: var(--blob-4);
    bottom: 6vh;
    right: 8vw;
    animation: drift4 20s var(--ease) infinite alternate;
}

/* 噪点纹理：SVG 内联，增强材质质感 */
.noise {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    opacity: 0.06;
    mix-blend-mode: overlay;
    pointer-events: none;
}

/* ============================================================
   4. 舞台布局
   ============================================================ */
.stage {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 28px 24px 40px;
    padding-top: max(28px, env(safe-area-inset-top));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

/* ============================================================
   5. 顶部栏
   ============================================================ */
.topbar {
    position: absolute;
    top: max(24px, env(safe-area-inset-top));
    left: 0;
    right: 0;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--card-max);
    margin: 0 auto;
    opacity: 0;
    animation: fadeDown 0.7s var(--ease) 0.1s forwards;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.brand__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    animation: pulse 2.4s ease-in-out infinite;
}

/* 图标按钮（玻璃质感） */
.icon-btn {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 var(--glass-highlight),
        0 6px 18px -8px rgba(31, 38, 80, 0.3);
    color: var(--text-muted);
    transition: transform var(--t-fast) var(--ease),
        background var(--t-fast) var(--ease),
        color var(--t-fast) var(--ease);
}

.icon-btn:hover {
    transform: translateY(-2px);
    background: var(--glass-bg-strong);
    color: var(--text-strong);
}

.icon-btn:active {
    transform: translateY(0) scale(0.95);
}

/* 主题图标显隐 */
.icon--moon {
    display: none;
}

[data-theme="dark"] .icon--sun {
    display: none;
}

[data-theme="dark"] .icon--moon {
    display: block;
}

/* ============================================================
   6. 玻璃卡片
   ============================================================ */
.card {
    position: relative;
    width: 100%;
    max-width: var(--card-max);
    padding: 56px 52px 44px;
    border-radius: var(--radius-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    text-align: center;
    overflow: hidden;
    opacity: 0;
    transform: translateY(24px) scale(0.98);
    animation: cardIn var(--t-slow) var(--ease) 0.25s forwards;
    transition: background var(--t-base) var(--ease),
        border-color var(--t-base) var(--ease);
}

/* 卡片顶部高光（液态玻璃反射） */
.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12%;
    right: 12%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        var(--glass-highlight) 50%,
        transparent);
    opacity: 0.9;
}

/* 卡片内角落柔光 */
.card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(120% 80% at 50% 0%,
        var(--glass-highlight) 0%,
        transparent 55%);
    opacity: 0.35;
    pointer-events: none;
}

.card__mark {
    line-height: 0;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.quote-glyph {
    font-family: var(--font-display);
    font-size: 64px;
    font-weight: 700;
    color: var(--accent);
    opacity: 0.5;
    display: inline-block;
    line-height: 1;
}

.card__quote {
    font-family: var(--font-display);
    font-size: clamp(22px, 3.4vw, 34px);
    line-height: 1.6;
    font-weight: 500;
    color: var(--text-strong);
    letter-spacing: 0.02em;
    min-height: 1.6em;
    position: relative;
    z-index: 1;
    transition: opacity var(--t-base) var(--ease),
        transform var(--t-base) var(--ease);
}

/* 内容切换时的过渡态 */
.card__quote.is-leaving {
    opacity: 0;
    transform: translateY(-10px);
}

.card__quote.is-entering {
    opacity: 0;
    transform: translateY(14px);
}

.card__divider {
    width: 48px;
    height: 2px;
    margin: 26px auto 18px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.7;
    position: relative;
    z-index: 1;
}

.card__author {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-faint);
    letter-spacing: 0.06em;
    position: relative;
    z-index: 1;
}

/* ============================================================
   7. 按钮区
   ============================================================ */
.actions {
    display: flex;
    gap: 14px;
    opacity: 0;
    animation: fadeUp 0.7s var(--ease) 0.5s forwards;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 14px 30px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border-radius: var(--radius-pill);
    transition: transform var(--t-fast) var(--ease),
        box-shadow var(--t-fast) var(--ease),
        background var(--t-fast) var(--ease),
        opacity var(--t-fast) var(--ease);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn--primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #8b7bff);
    box-shadow: 0 10px 26px -8px var(--accent-soft),
        0 4px 12px -4px rgba(109, 92, 255, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
    position: relative;
    overflow: hidden;
}

/* 按钮 hover 光晕 */
.btn--primary::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg, #8b7bff, var(--accent));
    opacity: 0;
    filter: blur(14px);
    transition: opacity var(--t-fast) var(--ease);
    z-index: -1;
}

.btn--primary:hover {
    transform: translateY(-2px);
}

.btn--primary:hover::after {
    opacity: 0.7;
}

.btn--primary:active {
    transform: translateY(0) scale(0.97);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn .icon--refresh {
    transition: transform 0.6s var(--ease);
}

.btn--primary:hover .icon--refresh {
    transform: rotate(180deg);
}

.btn.is-loading .icon--refresh {
    animation: spin 0.9s linear infinite;
}

/* ============================================================
   8. 加载骨架 / 错误提示
   ============================================================ */
.skeleton {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.skeleton__line {
    display: block;
    width: 80%;
    height: 1.1em;
    border-radius: 8px;
    background: var(--skeleton);
    background-image: linear-gradient(
        90deg,
        var(--skeleton) 0%,
        rgba(255, 255, 255, 0.7) 50%,
        var(--skeleton) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton__line--short {
    width: 45%;
}

/* Toast 错误提示 */
.toast {
    position: fixed;
    left: 50%;
    bottom: 14vh;
    transform: translateX(-50%) translateY(20px);
    padding: 14px 24px;
    border-radius: var(--radius-pill);
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base) var(--ease),
        transform var(--t-base) var(--ease);
    z-index: 50;
    max-width: 90vw;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   9. 页脚
   ============================================================ */
.footer {
    position: absolute;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    text-align: center;
    font-size: 12px;
    color: var(--text-faint);
    letter-spacing: 0.05em;
    opacity: 0;
    animation: fadeIn 0.8s var(--ease) 0.8s forwards;
}

.footer__tagline {
    margin: 0;
}

.footer__beian {
    margin: 6px 0 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.footer__link {
    color: var(--text-faint);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}

.footer__link:hover {
    color: var(--text-muted);
    text-decoration: underline;
}

.footer__link--gov {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.footer__badge {
    flex-shrink: 0;
    opacity: 0.8;
}

.footer__sep {
    opacity: 0.6;
}

/* ============================================================
   10. 动画关键帧
   ============================================================ */
@keyframes cardIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(109, 92, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(109, 92, 255, 0);
    }
}

/* 背景光斑漂移 */
@keyframes drift1 {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(12vw, 14vh) scale(1.15);
    }
}

@keyframes drift2 {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(-14vw, 18vh) scale(1.1);
    }
}

@keyframes drift3 {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(-10vw, -16vh) scale(1.2);
    }
}

@keyframes drift4 {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(14vw, -12vh) scale(1.1);
    }
}

/* ============================================================
   11. 响应式
   ============================================================ */
@media (max-width: 768px) {
    .stage {
        gap: 22px;
        padding: 24px 18px 36px;
    }

    .card {
        padding: 44px 26px 34px;
        border-radius: 22px;
    }

    .quote-glyph {
        font-size: 50px;
    }

    .card__quote {
        font-size: clamp(20px, 5.5vw, 28px);
        line-height: 1.55;
    }

    .card__divider {
        margin: 22px auto 16px;
    }

    .topbar {
        padding: 0 20px;
    }

    .btn {
        padding: 13px 26px;
        font-size: 14px;
    }

    .toast {
        bottom: 10vh;
        font-size: 13px;
    }
}

@media (max-width: 380px) {
    .card {
        padding: 38px 20px 30px;
    }

    .actions {
        width: 100%;
    }

    .btn--primary {
        width: 100%;
        justify-content: center;
    }
}

/* 尊重「减少动态」偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .blob {
        animation: none !important;
    }
}
