Major performance optimizations addressing PageSpeed Insights warnings:
**Phase 1: Replace Framer Motion with CSS (~60-100KB savings)**
- Remove Framer Motion from components/post-layout.tsx
- Add CSS transitions to styles/globals.css for TOC animations
- Replace motion.div/motion.button with regular elements + CSS classes
- Remove framer-motion package dependency
**Phase 2: Replace FontAwesome with React Icons (~150-250KB savings)**
- Replace FontAwesome in 16 components with react-icons
- Use Feather icons (react-icons/fi) for UI elements
- Use FontAwesome brand icons (react-icons/fa) for social media
- Remove 4 @fortawesome packages (@fortawesome/fontawesome-svg-core,
@fortawesome/free-brands-svg-icons, @fortawesome/free-solid-svg-icons,
@fortawesome/react-fontawesome)
- Updated components:
- app/error.tsx, app/tags/page.tsx, app/tags/[tag]/page.tsx
- components/hero.tsx, components/mastodon-feed.tsx
- components/meta-item.tsx, components/nav-menu.tsx
- components/post-card.tsx, components/post-layout.tsx
- components/post-list-item.tsx, components/post-list-with-controls.tsx
- components/post-storyline-nav.tsx, components/post-toc.tsx
- components/right-sidebar.tsx, components/search-modal.tsx
- components/site-footer.tsx, components/theme-toggle.tsx
**Phase 3: Convert Mastodon Feed to Server Component**
- Convert components/mastodon-feed.tsx from Client Component to async Server Component
- Replace client-side useEffect fetching with server-side ISR
- Add 30-minute revalidation (next: { revalidate: 1800 })
- Eliminate 2 blocking client-side network requests
- Remove loading state (rendered on server)
**Total Impact:**
- JavaScript bundle: ~210-350KB reduction
- Blocking network requests: 2 eliminated
- Main thread time: Reduced by ~100-160ms
- Build: ✅ Verified successful
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
599 lines
13 KiB
CSS
599 lines
13 KiB
CSS
@tailwind base;
|
|
@tailwind components;
|
|
@tailwind utilities;
|
|
|
|
:root {
|
|
--motion-duration-short: 180ms;
|
|
--motion-duration-medium: 260ms;
|
|
--motion-ease-snappy: cubic-bezier(0.32, 0.72, 0, 1);
|
|
--card-translate-y: -6px;
|
|
--line-height-body: clamp(1.5, 0.15vw + 1.45, 1.65);
|
|
--font-weight-regular: 400;
|
|
--font-weight-medium: 500;
|
|
--font-weight-semibold: 600;
|
|
--font-system-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'PingFang TC', 'PingFang SC', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Segoe UI Variable Text', 'Segoe UI', 'Microsoft JhengHei', 'Microsoft YaHei', 'Noto Sans TC', 'Noto Sans SC', 'Noto Sans CJK TC', 'Noto Sans CJK SC', 'Source Han Sans TC', 'Source Han Sans SC', 'Roboto', 'Ubuntu', 'Cantarell', 'Inter', 'Helvetica Neue', Arial, sans-serif;
|
|
|
|
font-size: clamp(15px, 0.65vw + 11px, 19px);
|
|
}
|
|
|
|
@media (min-width: 2560px) {
|
|
:root {
|
|
font-size: 20px;
|
|
}
|
|
}
|
|
|
|
body {
|
|
@apply bg-white text-gray-900 transition-colors duration-200 ease-snappy dark:bg-gray-950 dark:text-gray-100;
|
|
font-size: 1rem;
|
|
line-height: var(--line-height-body);
|
|
font-family: var(--font-system-sans);
|
|
}
|
|
|
|
@keyframes timeline-scroll {
|
|
0% {
|
|
transform: translate(-50%, -10%);
|
|
opacity: 0;
|
|
}
|
|
|
|
15% {
|
|
opacity: 1;
|
|
}
|
|
|
|
85% {
|
|
opacity: 1;
|
|
}
|
|
|
|
100% {
|
|
transform: translate(-50%, 110%);
|
|
opacity: 0;
|
|
}
|
|
}
|
|
|
|
@keyframes pageEnter {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(20px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
.page-transition {
|
|
opacity: 0;
|
|
}
|
|
|
|
/* Scroll reveal animations - CSS only */
|
|
.scroll-reveal {
|
|
opacity: 0;
|
|
transform: translateY(12px);
|
|
transition: opacity 0.5s cubic-bezier(0.32, 0.72, 0, 1),
|
|
transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
|
|
}
|
|
|
|
.scroll-reveal.is-visible {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
/* Respect user's motion preferences */
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.scroll-reveal {
|
|
opacity: 1;
|
|
transform: none;
|
|
transition: none;
|
|
}
|
|
}
|
|
|
|
|
|
.toc-target-highlight {
|
|
@apply bg-yellow-50/60 dark:bg-yellow-900/40 transition-colors duration-500;
|
|
}
|
|
|
|
/* Subtle hover for article elements */
|
|
.prose blockquote {
|
|
@apply transition-transform transition-shadow duration-180 ease-snappy;
|
|
border-left: 4px solid var(--color-accent, #2563eb);
|
|
background: linear-gradient(135deg, rgba(37, 99, 235, 0.04), rgba(37, 99, 235, 0.08));
|
|
padding: 1.2rem 1.5rem;
|
|
font-style: italic;
|
|
color: rgba(15, 23, 42, 0.75);
|
|
position: relative;
|
|
}
|
|
|
|
.dark .prose blockquote {
|
|
background: linear-gradient(135deg, rgba(96, 165, 250, 0.12), rgba(96, 165, 250, 0.06));
|
|
color: rgba(226, 232, 240, 0.8);
|
|
border-left-color: rgba(96, 165, 250, 0.9);
|
|
}
|
|
|
|
.prose blockquote:hover {
|
|
@apply -translate-y-0.5 shadow-sm;
|
|
}
|
|
|
|
.prose blockquote::before {
|
|
content: '“';
|
|
position: absolute;
|
|
top: 0.5rem;
|
|
left: 0.8rem;
|
|
font-size: 3rem;
|
|
font-family: 'Times New Roman', 'Noto Serif TC', serif;
|
|
color: rgba(37, 99, 235, 0.25);
|
|
pointer-events: none;
|
|
}
|
|
|
|
.prose pre {
|
|
@apply transition-transform transition-shadow duration-180 ease-snappy;
|
|
}
|
|
|
|
.prose pre:hover {
|
|
@apply -translate-y-0.5 shadow-md;
|
|
}
|
|
|
|
.prose {
|
|
font-size: clamp(1rem, 0.2vw + 0.9rem, 1.2rem);
|
|
line-height: var(--line-height-body);
|
|
}
|
|
|
|
.prose h1 {
|
|
font-size: clamp(2.2rem, 1.4rem + 2.2vw, 3.4rem);
|
|
line-height: 1.25;
|
|
}
|
|
|
|
.prose h2 {
|
|
font-size: clamp(1.8rem, 1.1rem + 1.6vw, 2.8rem);
|
|
line-height: 1.3;
|
|
}
|
|
|
|
.prose h3 {
|
|
font-size: clamp(1.4rem, 0.9rem + 1vw, 2rem);
|
|
line-height: 1.35;
|
|
}
|
|
|
|
.prose p,
|
|
.prose li {
|
|
font-size: clamp(1rem, 0.2vw + 0.9rem, 1.15rem);
|
|
line-height: var(--line-height-body);
|
|
}
|
|
|
|
.prose small,
|
|
.prose figcaption {
|
|
font-size: clamp(0.85rem, 0.2vw + 0.8rem, 0.95rem);
|
|
}
|
|
|
|
.prose h1>a,
|
|
.prose h2>a,
|
|
.prose h3>a,
|
|
.prose h4>a,
|
|
.prose h5>a,
|
|
.prose h6>a {
|
|
text-decoration: none !important;
|
|
color: inherit !important;
|
|
}
|
|
|
|
.hero-title {
|
|
position: relative;
|
|
display: inline-flex;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.hero-title__sweep {
|
|
position: absolute;
|
|
inset: 0;
|
|
background: linear-gradient(120deg, transparent 10%, rgba(59, 130, 246, 0.35) 45%, transparent 90%);
|
|
transform: translateX(-120%);
|
|
animation: hero-sweep 4s var(--motion-ease-snappy) infinite;
|
|
pointer-events: none;
|
|
}
|
|
|
|
|
|
@keyframes hero-sweep {
|
|
0% {
|
|
transform: translateX(-120%);
|
|
opacity: 0;
|
|
}
|
|
|
|
30% {
|
|
opacity: 0.4;
|
|
}
|
|
|
|
60% {
|
|
transform: translateX(120%);
|
|
opacity: 0;
|
|
}
|
|
|
|
100% {
|
|
transform: translateX(120%);
|
|
opacity: 0;
|
|
}
|
|
}
|
|
|
|
.tag-chip {
|
|
position: relative;
|
|
overflow: hidden;
|
|
transition: color var(--motion-duration-short) var(--motion-ease-snappy), background-color var(--motion-duration-short) var(--motion-ease-snappy);
|
|
}
|
|
|
|
.tag-chip::after {
|
|
content: '';
|
|
position: absolute;
|
|
left: 50%;
|
|
bottom: 4px;
|
|
width: 0;
|
|
height: 2px;
|
|
background: currentColor;
|
|
opacity: 0.5;
|
|
transition: width var(--motion-duration-short) var(--motion-ease-snappy), left var(--motion-duration-short) var(--motion-ease-snappy);
|
|
}
|
|
|
|
.tag-chip:hover::after,
|
|
.tag-chip:focus-visible::after {
|
|
width: 100%;
|
|
left: 0;
|
|
}
|
|
|
|
/* TOC transitions - replaces Framer Motion */
|
|
.toc-sidebar {
|
|
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
|
|
will-change: opacity, transform;
|
|
}
|
|
|
|
.toc-sidebar-enter {
|
|
opacity: 0;
|
|
transform: translateX(20px);
|
|
}
|
|
|
|
.toc-sidebar-enter-active {
|
|
opacity: 1;
|
|
transform: translateX(0);
|
|
}
|
|
|
|
.toc-sidebar-exit {
|
|
opacity: 1;
|
|
transform: translateX(0);
|
|
}
|
|
|
|
.toc-sidebar-exit-active {
|
|
opacity: 0;
|
|
transform: translateX(20px);
|
|
}
|
|
|
|
.toc-mobile {
|
|
transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
|
|
will-change: opacity, transform;
|
|
}
|
|
|
|
.toc-mobile-enter {
|
|
opacity: 0;
|
|
transform: translateY(20px);
|
|
}
|
|
|
|
.toc-mobile-enter-active {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.toc-mobile-exit {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.toc-mobile-exit-active {
|
|
opacity: 0;
|
|
transform: translateY(20px);
|
|
}
|
|
|
|
.toc-button {
|
|
transition: all 0.2s ease-in-out;
|
|
}
|
|
|
|
.toc-button:active {
|
|
transform: scale(0.95);
|
|
}
|
|
|
|
.toc-button:hover {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
@layer components {
|
|
.type-display {
|
|
font-size: clamp(2.2rem, 1.6rem + 2.4vw, 3.5rem);
|
|
line-height: 1.2;
|
|
font-weight: var(--font-weight-semibold);
|
|
font-family: var(--font-serif-eng), "Songti SC", serif;
|
|
}
|
|
|
|
.type-title {
|
|
font-size: clamp(1.6rem, 1.1rem + 1.4vw, 2.6rem);
|
|
line-height: 1.3;
|
|
font-weight: var(--font-weight-semibold);
|
|
font-family: var(--font-serif-eng), "Songti SC", serif;
|
|
letter-spacing: 0.02em;
|
|
}
|
|
|
|
.type-subtitle {
|
|
font-size: clamp(1.25rem, 0.9rem + 1vw, 1.9rem);
|
|
line-height: 1.35;
|
|
font-weight: var(--font-weight-medium);
|
|
font-family: var(--font-serif-eng), "Songti SC", serif;
|
|
letter-spacing: 0.02em;
|
|
}
|
|
|
|
.type-body {
|
|
font-size: clamp(1rem, 0.2vw + 0.9rem, 1.15rem);
|
|
line-height: var(--line-height-body);
|
|
font-weight: var(--font-weight-regular);
|
|
}
|
|
|
|
.type-small {
|
|
font-size: clamp(0.85rem, 0.2vw + 0.8rem, 0.95rem);
|
|
line-height: 1.4;
|
|
font-weight: var(--font-weight-regular);
|
|
}
|
|
|
|
h1 {
|
|
font-weight: 700;
|
|
letter-spacing: -0.03em;
|
|
font-family: var(--font-serif-eng), "Songti SC", serif;
|
|
}
|
|
|
|
h2 {
|
|
font-weight: 600;
|
|
letter-spacing: -0.02em;
|
|
font-family: var(--font-serif-eng), "Songti SC", serif;
|
|
}
|
|
|
|
.type-nav {
|
|
font-size: clamp(0.95rem, 0.2vw + 0.85rem, 1.05rem);
|
|
font-weight: var(--font-weight-medium);
|
|
letter-spacing: 0.04em;
|
|
}
|
|
|
|
.motion-card {
|
|
transition: transform var(--motion-duration-medium) var(--motion-ease-snappy),
|
|
box-shadow var(--motion-duration-medium) var(--motion-ease-snappy),
|
|
background-color var(--motion-duration-medium) var(--motion-ease-snappy),
|
|
border-color var(--motion-duration-medium) var(--motion-ease-snappy);
|
|
}
|
|
|
|
.motion-card:hover {
|
|
transform: translateY(var(--card-translate-y));
|
|
}
|
|
|
|
.motion-link {
|
|
transition: color var(--motion-duration-short) var(--motion-ease-snappy),
|
|
transform var(--motion-duration-short) var(--motion-ease-snappy);
|
|
}
|
|
}
|
|
|
|
/* Pagefind Search Styles - Use CSS variables to override defaults */
|
|
:root {
|
|
--pagefind-ui-scale: 1;
|
|
--pagefind-ui-primary: #2563eb;
|
|
--pagefind-ui-text: #0f172a;
|
|
--pagefind-ui-background: #ffffff;
|
|
--pagefind-ui-border: #e2e8f0;
|
|
--pagefind-ui-tag: #f1f5f9;
|
|
--pagefind-ui-border-width: 1px;
|
|
--pagefind-ui-border-radius: 0.5rem;
|
|
--pagefind-ui-font: var(--font-system-sans);
|
|
}
|
|
|
|
.dark {
|
|
--pagefind-ui-primary: #60a5fa;
|
|
--pagefind-ui-text: #f1f5f9;
|
|
--pagefind-ui-background: #0f172a;
|
|
--pagefind-ui-border: #475569;
|
|
--pagefind-ui-tag: #334155;
|
|
}
|
|
|
|
/* Enhanced text colors for better readability */
|
|
.pagefind-ui__result-title {
|
|
color: var(--pagefind-ui-text) !important;
|
|
}
|
|
|
|
.dark .pagefind-ui__result-title {
|
|
color: #f8fafc !important;
|
|
}
|
|
|
|
.pagefind-ui__result-excerpt {
|
|
color: #475569 !important;
|
|
}
|
|
|
|
.dark .pagefind-ui__result-excerpt {
|
|
color: #cbd5e1 !important;
|
|
}
|
|
|
|
.pagefind-ui__result-link {
|
|
color: var(--pagefind-ui-primary) !important;
|
|
}
|
|
|
|
.dark .pagefind-ui__result-link {
|
|
color: #93c5fd !important;
|
|
}
|
|
|
|
/* Additional custom styling for highlights */
|
|
.pagefind-ui__result-excerpt mark {
|
|
@apply bg-yellow-200 font-semibold text-slate-900 dark:bg-yellow-600 dark:text-slate-100;
|
|
padding: 0.125rem 0.25rem;
|
|
border-radius: 0.25rem;
|
|
}
|
|
|
|
.pagefind-ui__search-input:focus {
|
|
@apply ring-2 ring-blue-500 dark:ring-blue-400;
|
|
}
|
|
|
|
/* Code Syntax Highlighting Styles (rehype-pretty-code) */
|
|
.prose pre {
|
|
@apply overflow-x-auto rounded-lg border border-slate-200 dark:border-slate-700;
|
|
padding: 1rem 1.2rem;
|
|
margin: 1.5rem 0;
|
|
background-color: #f8fafc;
|
|
}
|
|
|
|
.dark .prose pre {
|
|
background-color: #0f172a;
|
|
}
|
|
|
|
.prose pre > code {
|
|
@apply grid;
|
|
counter-reset: line;
|
|
font-size: 0.9em;
|
|
line-height: 1.7;
|
|
}
|
|
|
|
.prose pre > code > [data-line] {
|
|
padding: 0 1rem;
|
|
border-left: 2px solid transparent;
|
|
}
|
|
|
|
.prose pre > code > [data-line]::before {
|
|
counter-increment: line;
|
|
content: counter(line);
|
|
display: inline-block;
|
|
width: 1.5rem;
|
|
margin-right: 1.5rem;
|
|
text-align: right;
|
|
color: #94a3b8;
|
|
user-select: none;
|
|
}
|
|
|
|
.dark .prose pre > code > [data-line]::before {
|
|
color: #475569;
|
|
}
|
|
|
|
/* Highlighted lines */
|
|
.prose pre > code > [data-highlighted-line] {
|
|
background-color: rgba(59, 130, 246, 0.1);
|
|
border-left-color: rgb(59, 130, 246);
|
|
}
|
|
|
|
.dark .prose pre > code > [data-highlighted-line] {
|
|
background-color: rgba(96, 165, 250, 0.15);
|
|
border-left-color: rgb(96, 165, 250);
|
|
}
|
|
|
|
/* Inline code */
|
|
.prose :not(pre) > code {
|
|
@apply rounded bg-slate-100 px-1.5 py-0.5 text-sm font-semibold text-slate-800 dark:bg-slate-800 dark:text-slate-200;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
/* Code title (if specified in markdown: ```js title="example.js") */
|
|
.prose [data-rehype-pretty-code-title] {
|
|
@apply rounded-t-lg border border-b-0 border-slate-200 bg-slate-100 px-4 py-2 text-sm font-semibold text-slate-700 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300;
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.prose [data-rehype-pretty-code-title] + pre {
|
|
@apply mt-0 rounded-t-none;
|
|
}
|
|
|
|
/* GitHub-style Callouts/Alerts */
|
|
.prose .callout {
|
|
@apply my-6 rounded-lg border-l-4 p-4 shadow-sm;
|
|
background: linear-gradient(135deg, var(--callout-bg-start), var(--callout-bg-end));
|
|
}
|
|
|
|
.prose .callout-header {
|
|
@apply mb-3 flex items-center gap-2;
|
|
}
|
|
|
|
.prose .callout-icon {
|
|
@apply text-2xl;
|
|
line-height: 1;
|
|
}
|
|
|
|
.prose .callout-title {
|
|
@apply text-sm font-bold uppercase tracking-wider;
|
|
color: var(--callout-title-color);
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.prose .callout-content {
|
|
@apply text-sm leading-relaxed;
|
|
}
|
|
|
|
.prose .callout-content > *:first-child {
|
|
@apply mt-0;
|
|
}
|
|
|
|
.prose .callout-content > *:last-child {
|
|
@apply mb-0;
|
|
}
|
|
|
|
/* NOTE - Blue */
|
|
.prose .callout-note {
|
|
--callout-bg-start: rgba(59, 130, 246, 0.08);
|
|
--callout-bg-end: rgba(59, 130, 246, 0.04);
|
|
--callout-title-color: #2563eb;
|
|
@apply border-blue-500;
|
|
}
|
|
|
|
.dark .prose .callout-note {
|
|
--callout-bg-start: rgba(96, 165, 250, 0.12);
|
|
--callout-bg-end: rgba(96, 165, 250, 0.06);
|
|
--callout-title-color: #93c5fd;
|
|
@apply border-blue-400;
|
|
}
|
|
|
|
/* TIP - Green */
|
|
.prose .callout-tip {
|
|
--callout-bg-start: rgba(34, 197, 94, 0.08);
|
|
--callout-bg-end: rgba(34, 197, 94, 0.04);
|
|
--callout-title-color: #16a34a;
|
|
@apply border-green-500;
|
|
}
|
|
|
|
.dark .prose .callout-tip {
|
|
--callout-bg-start: rgba(74, 222, 128, 0.12);
|
|
--callout-bg-end: rgba(74, 222, 128, 0.06);
|
|
--callout-title-color: #86efac;
|
|
@apply border-green-400;
|
|
}
|
|
|
|
/* IMPORTANT - Purple */
|
|
.prose .callout-important {
|
|
--callout-bg-start: rgba(168, 85, 247, 0.08);
|
|
--callout-bg-end: rgba(168, 85, 247, 0.04);
|
|
--callout-title-color: #9333ea;
|
|
@apply border-purple-500;
|
|
}
|
|
|
|
.dark .prose .callout-important {
|
|
--callout-bg-start: rgba(192, 132, 252, 0.12);
|
|
--callout-bg-end: rgba(192, 132, 252, 0.06);
|
|
--callout-title-color: #c084fc;
|
|
@apply border-purple-400;
|
|
}
|
|
|
|
/* WARNING - Orange/Yellow */
|
|
.prose .callout-warning {
|
|
--callout-bg-start: rgba(251, 191, 36, 0.08);
|
|
--callout-bg-end: rgba(251, 191, 36, 0.04);
|
|
--callout-title-color: #d97706;
|
|
@apply border-yellow-500;
|
|
}
|
|
|
|
.dark .prose .callout-warning {
|
|
--callout-bg-start: rgba(253, 224, 71, 0.12);
|
|
--callout-bg-end: rgba(253, 224, 71, 0.06);
|
|
--callout-title-color: #fde047;
|
|
@apply border-yellow-400;
|
|
}
|
|
|
|
/* CAUTION - Red */
|
|
.prose .callout-caution {
|
|
--callout-bg-start: rgba(239, 68, 68, 0.08);
|
|
--callout-bg-end: rgba(239, 68, 68, 0.04);
|
|
--callout-title-color: #dc2626;
|
|
@apply border-red-500;
|
|
}
|
|
|
|
.dark .prose .callout-caution {
|
|
--callout-bg-start: rgba(248, 113, 113, 0.12);
|
|
--callout-bg-end: rgba(248, 113, 113, 0.06);
|
|
--callout-title-color: #fca5a5;
|
|
@apply border-red-400;
|
|
} |