

/* ========== CSS Reset / Normalize ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--bg-body);
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(200, 132, 60, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(180, 160, 140, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(200, 180, 150, 0.04) 0%, transparent 50%);
    min-height: 100vh;
    overflow-x: hidden;
    letter-spacing: 0.01em;
}

article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section {
    display: block;
}

ul, ol {
    list-style: none;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    outline: none;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
    border: 0;
    vertical-align: middle;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.35;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }

p {
    margin-bottom: 1em;
}

input, textarea, select, button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    outline: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

code, kbd, pre, samp {
    font-family: var(--font-mono);
}

::selection {
    background-color: var(--accent);
    color: #fff;
}

::-moz-selection {
    background-color: var(--accent);
    color: #fff;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: #c4b8aa;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #a89a88;
}

body.dark-mode::-webkit-scrollbar-thumb {
    background-color: #4d453e;
}

body.dark-mode::-webkit-scrollbar-thumb:hover {
    background-color: #6b5e4f;
}

/* ========== Keyframe Animations ========== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 0 12px transparent; }
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-on-scroll {
    opacity: 1;
    transform: none;
}

/* 仅 JS ready 后，对未进入视口的元素应用隐藏偏移 */
.js-ready .animate-on-scroll:not(.is-visible) {
    opacity: 0;
    transform: translateY(30px);
}

.js-ready .animate-on-scroll {
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.js-ready .animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.animate-on-scroll.animate-delay-1 { transition-delay: 0.08s; }
.animate-on-scroll.animate-delay-2 { transition-delay: 0.16s; }
.animate-on-scroll.animate-delay-3 { transition-delay: 0.24s; }
.animate-on-scroll.animate-delay-4 { transition-delay: 0.32s; }
.animate-on-scroll.animate-delay-5 { transition-delay: 0.4s; }

/* Shiguang canvas and glass surfaces */
html {
    background: var(--bg-body);
}

body.handsome-body {
    position: relative;
    isolation: isolate;
    color: var(--text-primary);
    background:
        radial-gradient(circle at 6% 10%, rgba(90, 194, 255, .42), transparent 31%),
        radial-gradient(circle at 93% 18%, rgba(255, 165, 210, .32), transparent 32%),
        radial-gradient(circle at 82% 84%, rgba(177, 151, 255, .24), transparent 35%),
        radial-gradient(circle at 8% 88%, rgba(117, 232, 205, .22), transparent 31%),
        linear-gradient(145deg, #edf8ff, #fff 50%, #f2f7ff);
    background-attachment: fixed;
}

body.handsome-body::before,
body.handsome-body::after {
    content: "";
    position: fixed;
    z-index: -1;
    width: min(46vw, 700px);
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(86px);
    opacity: .24;
    pointer-events: none;
}

body.handsome-body::before {
    left: -17vw;
    top: 8vh;
    background: rgba(91, 193, 255, .60);
}

body.handsome-body::after {
    right: -17vw;
    bottom: 1vh;
    background: rgba(232, 141, 239, .46);
}

body.dark-mode.handsome-body {
    background:
        radial-gradient(circle at 8% 12%, rgba(47, 136, 207, .20), transparent 32%),
        radial-gradient(circle at 91% 18%, rgba(155, 77, 143, .16), transparent 33%),
        radial-gradient(circle at 80% 85%, rgba(99, 78, 180, .15), transparent 36%),
        linear-gradient(145deg, #0d1522, #121b29 52%, #101724);
}

body.dark-mode.handsome-body::before,
body.dark-mode.handsome-body::after {
    opacity: .16;
}

.desktop-header,
.mobile-header,
.search-modal,
.app-aside,
.post-card:not(.post-card-b),
.single-post,
.comments-section,
.sidebar-widget,
.empty-state,
.load-more-btn,
.floating-action-btn,
.back-to-top {
    border: 1px solid var(--glass-border);
    background: linear-gradient(135deg, rgba(255,255,255,.82), var(--glass-bg));
    box-shadow: var(--shadow-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

body.dark-mode .desktop-header,
body.dark-mode .mobile-header,
body.dark-mode .search-modal,
body.dark-mode .app-aside,
body.dark-mode .post-card:not(.post-card-b),
body.dark-mode .single-post,
body.dark-mode .comments-section,
body.dark-mode .sidebar-widget,
body.dark-mode .empty-state,
body.dark-mode .load-more-btn,
body.dark-mode .floating-action-btn,
body.dark-mode .back-to-top {
    background: linear-gradient(135deg, rgba(39,52,72,.86), var(--glass-bg));
    border-color: var(--glass-border);
}

/* Optional page transitions */
@supports (view-transition-name: none) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.4s;
        animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
    }
    ::view-transition-old(root) {
        animation-name: vt-fade-out;
    }
    ::view-transition-new(root) {
        animation-name: vt-fade-in;
    }
    @keyframes vt-fade-out {
        to { opacity: 0; transform: translateY(-8px) scale(0.99); }
    }
    @keyframes vt-fade-in {
        from { opacity: 0; transform: translateY(12px) scale(0.99); }
    }
}

.page-transition-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    overflow: hidden;
}

.page-transition-curtain {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    transform: translateY(100%);
    background: linear-gradient(
        to top,
        #0b0908 0%,
        #15100a 55%,
        #1f1608 100%
    );
    will-change: transform;
}

.page-transition-overlay.active .page-transition-curtain {
    animation: pt-rise 0.56s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes pt-rise {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.page-transition-glow {
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--accent) 25%,
        #ffffff 50%,
        var(--accent) 75%,
        transparent 100%
    );
    box-shadow:
        0 0 24px 6px var(--accent-glow),
        0 -10px 40px var(--accent-glow),
        0 0 60px 10px rgba(245, 158, 11, 0.15);
    opacity: 0;
    transform: scaleX(0.4);
}

.page-transition-overlay.active .page-transition-glow {
    animation: pt-glow-flash 0.62s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pt-glow-flash {
    0%   { opacity: 0; transform: scaleX(0.4); }
    40%  { opacity: 1; transform: scaleX(1); }
    100% { opacity: 1; transform: scaleX(1); }
}

.page-transition-streak {
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background: linear-gradient(
        105deg,
        transparent 0%,
        rgba(255, 255, 255, 0.04) 40%,
        rgba(255, 213, 128, 0.10) 50%,
        rgba(255, 255, 255, 0.04) 60%,
        transparent 100%
    );
    transform: translateX(-100%);
    will-change: transform, opacity;
    opacity: 0;
}

.page-transition-overlay.active .page-transition-streak {
    animation: pt-streak 0.72s cubic-bezier(0.22, 1, 0.36, 1) 0.04s forwards;
}

@keyframes pt-streak {
    0%   { transform: translateX(-100%); opacity: 0; }
    20%  { opacity: 1; }
    100% { transform: translateX(350%); opacity: 0; }
}

body.has-page-transitions .app-main {
    animation: pt-page-enter 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pt-page-enter {
    from { opacity: 0; }
    to   { opacity: 1; }
}

body.dark-mode .page-transition-curtain {
    background: linear-gradient(
        to top,
        #050403 0%,
        #0e0a05 55%,
        #1a1208 100%
    );
}

@media (prefers-reduced-motion: reduce) {
    .page-transition-curtain,
    .page-transition-glow,
    .page-transition-streak {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
    body.has-page-transitions .app-main {
        animation: none !important;
    }
}

/* Button ripple interaction */
.floating-action-btn,
.back-to-top,
.desktop-action-btn,
.load-more-btn {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0);
    animation: ripple-spread 0.6s ease-out;
    pointer-events: none;
}

body.dark-mode .ripple {
    background: rgba(255, 255, 255, 0.2);
}

@keyframes ripple-spread {
    to { transform: scale(4); opacity: 0; }
}

/* Scrollbars and text selection */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
    background-clip: content-box;
}

::selection {
    background: var(--accent-glow);
    color: var(--text-primary);
}

/* Accessible hidden text and skip link */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.skip-link {
    position: fixed;
    top: 10px;
    left: 12px;
    z-index: 10020;
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    background: var(--accent-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-160%);
    transition: transform var(--transition-fast);
}
.skip-link:focus { transform: translateY(0); }

/* Remix Icon v3.5.0 — locally hosted; Apache-2.0 */
@font-face {
    font-family: "remixicon";
    src: url("../fonts/remixicon.woff2?v=3.5.0") format("woff2");
    font-display: swap;
    font-style: normal;
    font-weight: 400;
}
[class^="ri-"], [class*=" ri-"] {
    font-family: "remixicon" !important;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
[data-ri-glyph]::before { content: attr(data-ri-glyph) !important; }
.ri-spin { animation: ri-spin 1s linear infinite; }
@keyframes ri-spin { to { transform: rotate(360deg); } }
.ri-apps-line:before { content: "\ea44"; }
.ri-arrow-down-line:before { content: "\ea4c"; }
.ri-arrow-down-s-line:before { content: "\ea4e"; }
.ri-arrow-left-line:before { content: "\ea60"; }
.ri-arrow-left-s-line:before { content: "\ea64"; }
.ri-arrow-right-s-line:before { content: "\ea6e"; }
.ri-arrow-up-line:before { content: "\ea76"; }
.ri-article-line:before { content: "\ea7e"; }
.ri-calendar-check-line:before { content: "\eb23"; }
.ri-calendar-line:before { content: "\eb27"; }
.ri-chat-1-line:before { content: "\eb4d"; }
.ri-chat-3-line:before { content: "\eb51"; }
.ri-chat-smile-2-line:before { content: "\eb6f"; }
.ri-check-line:before { content: "\eb7b"; }
.ri-close-circle-line:before { content: "\eb97"; }
.ri-close-line:before { content: "\eb99"; }
.ri-compass-discover-line:before { content: "\ebc2"; }
.ri-compass-line:before { content: "\ebc4"; }
.ri-discuss-line:before { content: "\ec3a"; }
.ri-error-warning-line:before { content: "\eca1"; }
.ri-external-link-line:before { content: "\ecaf"; }
.ri-eye-line:before { content: "\ecb5"; }
.ri-file-line:before { content: "\eceb"; }
.ri-file-search-line:before { content: "\ed05"; }
.ri-flashlight-line:before { content: "\ed3d"; }
.ri-folder-3-line:before { content: "\ed54"; }
.ri-folder-line:before { content: "\ed6a"; }
.ri-gradienter-line:before { content: "\eddd"; }
.ri-home-line:before { content: "\ee2b"; }
.ri-inbox-line:before { content: "\ee4f"; }
.ri-information-line:before { content: "\ee59"; }
.ri-layout-right-line:before { content: "\ee9b"; }
.ri-link:before { content: "\eeb2"; }
.ri-loader-4-line:before { content: "\eec6"; }
.ri-lock-line:before { content: "\eece"; }
.ri-megaphone-line:before { content: "\f385"; }
.ri-menu-line:before { content: "\ef3e"; }
.ri-moon-line:before { content: "\ef75"; }
.ri-price-tag-3-line:before { content: "\f023"; }
.ri-pushpin-2-fill:before { content: "\f036"; }
.ri-quill-pen-line:before { content: "\f04a"; }
.ri-reply-line:before { content: "\f07a"; }
.ri-search-line:before { content: "\f0d1"; }
.ri-send-plane-2-fill:before { content: "\f0d7"; }
.ri-settings-3-line:before { content: "\f0e6"; }
.ri-shopping-bag-3-line:before { content: "\f116"; }
.ri-shopping-bag-line:before { content: "\f118"; }
.ri-shopping-cart-line:before { content: "\f120"; }
.ri-sun-line:before { content: "\f1bf"; }
.ri-time-line:before { content: "\f20f"; }
.ri-user-3-line:before { content: "\f256"; }
.ri-user-line:before { content: "\f264"; }
