diff --git a/src/app/globals.css b/src/app/globals.css index ccd1eb1..5bebf04 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -221,27 +221,40 @@ .marquee-container:hover .marquee-track, .marquee-container:focus-within .marquee-track { animation-play-state: paused; } -/* Crow silhouettes scatter once as each new 404 thought appears. */ +/* Crow flight, feather drift, and a two-stage quote handoff. */ @keyframes crow-flight { - 0% { opacity: 0; transform: translate(0, 12px) scale(0.35); } - 18% { opacity: 1; } - 100% { opacity: 0; transform: translate(var(--crow-x), var(--crow-y)) rotate(var(--crow-turn)) scale(0.8); } + 0% { opacity: 0; transform: translate(0, 12px) scale(0.3); } + 12% { opacity: 1; } + 40% { opacity: 0.95; transform: translate(var(--crow-mid-x), var(--crow-mid-y)) rotate(-8deg) scale(var(--crow-scale)); } + 100% { opacity: 0; transform: translate(var(--crow-x), var(--crow-y)) rotate(var(--crow-turn)) scale(0.45); } } @keyframes crow-wings { - from { transform: scaleY(1) rotate(-6deg); } - to { transform: scaleY(0.35) rotate(6deg); } + from { transform: scaleY(1) rotate(-8deg); } + to { transform: scaleY(0.4) rotate(8deg); } +} +@keyframes feather-drift { + 0% { opacity: 0; transform: translate(0, 0) rotate(-20deg); } + 20% { opacity: 0.8; } + 100% { opacity: 0; transform: translate(var(--crow-x), var(--crow-y)) rotate(var(--crow-turn)); } +} +@keyframes quote-dissolve { + 0% { opacity: 1; transform: translateY(0); filter: blur(0); } + 35%, 100% { opacity: 0; transform: translateY(-8px); filter: blur(3px); } } @keyframes quote-materialize { - 0%, 25% { opacity: 0; filter: blur(4px); transform: translateY(5px); } + 0%, 35% { opacity: 0; filter: blur(3px); transform: translateY(10px); } 100% { opacity: 1; filter: blur(0); transform: translateY(0); } } -.crow-flight { color: hsl(var(--ink)); animation: crow-flight 1.2s ease-out both; } -.crow-wings { animation: crow-wings 0.16s ease-in-out 8 alternate; } -.quote-transition .quote-copy { animation: quote-materialize 1.1s ease-out both; } -html.safe-mode .crow-scatter { display: none; } +.crow-flight { color: hsl(var(--ink)); animation: crow-flight 1.6s cubic-bezier(0.22, 0.61, 0.36, 1) both; } +.crow-wings { animation: crow-wings var(--wing-speed, 0.18s) ease-in-out 10 alternate; } +.crow-feather { animation: feather-drift 1.8s ease-out both; } +.quote-transition .quote-outgoing { animation: quote-dissolve 1.6s ease-out both; } +.quote-transition .quote-copy { animation: quote-materialize 1.6s ease-out both; } +html.safe-mode .crow-scatter, +html.safe-mode .quote-outgoing { display: none; } html.safe-mode .quote-copy { animation: none; } @media (prefers-reduced-motion: reduce) { - .crow-scatter { display: none; } + .crow-scatter, .quote-outgoing { display: none; } .quote-transition .quote-copy { animation: none; } } diff --git a/src/components/cyber/__tests__/home-footer-quote.test.tsx b/src/components/cyber/__tests__/home-footer-quote.test.tsx new file mode 100644 index 0000000..cd1d574 --- /dev/null +++ b/src/components/cyber/__tests__/home-footer-quote.test.tsx @@ -0,0 +1,33 @@ +import { act, render, screen } from '@testing-library/react'; +import { HomeFooterQuote } from '../home-footer-quote'; +import { NOT_FOUND_QUOTES } from '@/lib/not-found-quotes'; + +let pathname = '/'; +jest.mock('next/navigation', () => ({ usePathname: () => pathname })); + +beforeEach(() => { + pathname = '/'; + sessionStorage.clear(); + jest.useFakeTimers(); + jest.setSystemTime(new Date('2026-10-07T13:00:00Z')); +}); +afterEach(() => jest.useRealTimers()); + +test('shows the larger home quote, hands off the outgoing quote, and keeps the clock', () => { + const view = render(); + expect(screen.getByText(/One last thought/)).toBeVisible(); + expect(screen.getByRole('blockquote')).toHaveClass('text-2xl'); + act(() => jest.advanceTimersByTime(10000)); + expect(view.container.querySelector('.quote-copy')).toHaveTextContent(NOT_FOUND_QUOTES[1]); + expect(view.container.querySelector('.quote-outgoing')).toHaveTextContent(NOT_FOUND_QUOTES[0]); + expect(view.container.querySelector('.quote-outgoing')).toHaveAttribute('aria-hidden', 'true'); + view.unmount(); + expect(jest.getTimerCount()).toBe(0); +}); + +test.each(['/admin', '/blog/post', '/missing-page'])('does not duplicate quotes on %s', (path) => { + pathname = path; + const view = render(); + expect(view.container).toBeEmptyDOMElement(); + expect(jest.getTimerCount()).toBe(0); +}); diff --git a/src/components/cyber/crow-scatter.tsx b/src/components/cyber/crow-scatter.tsx index f200275..52efaa5 100644 --- a/src/components/cyber/crow-scatter.tsx +++ b/src/components/cyber/crow-scatter.tsx @@ -13,14 +13,31 @@ export function CrowScatter() { '--crow-x': `${Math.cos(angle) * radius}px`, '--crow-y': `${Math.sin(angle) * radius - 35}px`, '--crow-turn': `${Math.cos(angle) * 35}deg`, - animationDelay: `${(index % 5) * 35}ms`, + '--crow-mid-x': `${Math.cos(angle + 0.3) * radius * 0.4}px`, + '--crow-mid-y': `${Math.sin(angle + 0.3) * radius * 0.3 - 20}px`, + '--crow-scale': String(0.65 + (index % 4) * 0.16), + '--wing-speed': `${0.14 + (index % 4) * 0.025}s`, + animationDuration: `${1.45 + (index % 4) * 0.12}s`, + animationDelay: `${(index % 5) * 45}ms`, } as CSSProperties; return - - + + + ; })} + {Array.from({ length: 7 }, (_, index) => + + + + )} ; } diff --git a/src/components/cyber/home-footer-quote.tsx b/src/components/cyber/home-footer-quote.tsx new file mode 100644 index 0000000..63293ce --- /dev/null +++ b/src/components/cyber/home-footer-quote.tsx @@ -0,0 +1,10 @@ +'use client'; + +import { usePathname } from 'next/navigation'; +import { RotatingQuote } from './rotating-quote'; + +export function HomeFooterQuote() { + const pathname = usePathname(); + if (pathname !== '/') return null; + return
; +} diff --git a/src/components/cyber/not-found-screen.tsx b/src/components/cyber/not-found-screen.tsx index 8f11cf4..7247166 100644 --- a/src/components/cyber/not-found-screen.tsx +++ b/src/components/cyber/not-found-screen.tsx @@ -2,49 +2,14 @@ import dynamic from 'next/dynamic'; import Link from 'next/link'; -import { useEffect, useState } from 'react'; -import { NOT_FOUND_QUOTES, getQuoteClock, quoteIndexAt, QUOTE_INTERVAL_MS } from '@/lib/not-found-quotes'; -import { CrowScatter } from './crow-scatter'; +import { RotatingQuote } from './rotating-quote'; const SharinganEye = dynamic(() => import('./sharingan').then((module) => module.SharinganEye), { ssr: false, loading: () =>
Opening eye…
, }); -// In-memory continuity for browsers that block storage. -let fallbackAnchor: number | undefined; - export function NotFoundScreen() { - const [quoteIndex, setQuoteIndex] = useState(0); - const [ready, setReady] = useState(false); - const [paused, setPaused] = useState(false); - - useEffect(() => { - if (paused) return; - const now = Date.now(); - let anchor: number; - try { - anchor = getQuoteClock(window.sessionStorage, now); - } catch { - fallbackAnchor ??= now; - anchor = fallbackAnchor; - } - let timer: ReturnType; - const update = () => { - clearTimeout(timer); - const current = Date.now(); - setQuoteIndex(quoteIndexAt(anchor, current)); - setReady(true); - timer = setTimeout(update, QUOTE_INTERVAL_MS - (Math.max(0, current - anchor) % QUOTE_INTERVAL_MS)); - }; - update(); - document.addEventListener('visibilitychange', update); - return () => { - clearTimeout(timer); - document.removeEventListener('visibilitychange', update); - }; - }, [paused]); - return (
@@ -73,17 +38,7 @@ export function NotFoundScreen() {

Even this eye cannot locate your page.

-
-

Intercepted thought // {String(quoteIndex + 1).padStart(2, '0')} / {NOT_FOUND_QUOTES.length}

-
- {ready && } -
“{NOT_FOUND_QUOTES[quoteIndex]}”
-
-

Original words // new thought every 10 seconds

- -
+
diff --git a/src/components/cyber/rotating-quote.tsx b/src/components/cyber/rotating-quote.tsx new file mode 100644 index 0000000..1129a70 --- /dev/null +++ b/src/components/cyber/rotating-quote.tsx @@ -0,0 +1,60 @@ +'use client'; + +import { useEffect, useState } from 'react'; +import { NOT_FOUND_QUOTES, getQuoteClock, quoteIndexAt, QUOTE_INTERVAL_MS } from '@/lib/not-found-quotes'; +import { CrowScatter } from './crow-scatter'; + +// Used only in the browser when storage is unavailable. +let fallbackAnchor: number | undefined; + +export function RotatingQuote({ large = false, label = 'Intercepted thought' }: { large?: boolean; label?: string }) { + const [quote, setQuote] = useState({ index: 0, previous: null as number | null, ready: false }); + const [paused, setPaused] = useState(false); + + useEffect(() => { + if (paused) return; + const now = Date.now(); + let anchor: number; + try { + anchor = getQuoteClock(window.sessionStorage, now); + } catch { + fallbackAnchor ??= now; + anchor = fallbackAnchor; + } + let timer: ReturnType; + const update = () => { + clearTimeout(timer); + const current = Date.now(); + const index = quoteIndexAt(anchor, current); + setQuote((old) => old.ready && old.index === index ? old : { + index, + previous: old.ready ? old.index : null, + ready: true, + }); + timer = setTimeout(update, QUOTE_INTERVAL_MS - (Math.max(0, current - anchor) % QUOTE_INTERVAL_MS)); + }; + update(); + document.addEventListener('visibilitychange', update); + return () => { + clearTimeout(timer); + document.removeEventListener('visibilitychange', update); + }; + }, [paused]); + + return
+

{label}{' // '}{String(quote.index + 1).padStart(2, '0')} / {NOT_FOUND_QUOTES.length}

+
+ {quote.ready && } +
+ {quote.previous !== null && “{NOT_FOUND_QUOTES[quote.previous]}”} + “{NOT_FOUND_QUOTES[quote.index]}” +
+
+
+

Original words // new thought every 10 seconds

+ +
+
; +} diff --git a/src/components/site-footer.tsx b/src/components/site-footer.tsx index 480423b..a6450be 100644 --- a/src/components/site-footer.tsx +++ b/src/components/site-footer.tsx @@ -1,6 +1,7 @@ import { cn } from '@/lib/utils'; import Link from 'next/link'; import { Github, Linkedin, Mail, FileText, type LucideIcon } from 'lucide-react'; +import { HomeFooterQuote } from '@/components/cyber/home-footer-quote'; interface PersonalData { name: string; @@ -72,6 +73,8 @@ export function SiteFooter({ className, personalData }: React.HTMLAttributes )} + +
END OF TRANSMISSION 通信終了